-
Notifications
You must be signed in to change notification settings - Fork 3
Remove onLog from @relayburn/sdk@2.x option types (#374) #384
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Changes from all commits
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,56 @@ | ||
| // Regression guard for issue #374. The 2.x Node facade is SQLite-native and | ||
| // has no archive-fallback path to surface, so `onLog` was always a no-op at | ||
| // the napi boundary. We removed it from the public option types; this test | ||
| // fails if it ever sneaks back in (verb-by-verb), so we don't accidentally | ||
| // re-document a callback that doesn't fire. | ||
| // | ||
| // Also asserts that calling each verb with a stray `onLog` property is | ||
| // tolerated at runtime — JS allows extra props on options bags, and we don't | ||
| // want to break embedders mid-migration from 1.x just because they haven't | ||
| // dropped the field yet. | ||
|
|
||
| import { test } from 'node:test'; | ||
| import assert from 'node:assert/strict'; | ||
| import { readFileSync } from 'node:fs'; | ||
| import { dirname, join, resolve } from 'node:path'; | ||
| import { fileURLToPath } from 'node:url'; | ||
|
|
||
| const __dirname = dirname(fileURLToPath(import.meta.url)); | ||
| const DTS_PATH = resolve(__dirname, '..', 'src', 'index.d.ts'); | ||
|
|
||
| test('public option types no longer declare onLog (#374)', () => { | ||
| const dts = readFileSync(DTS_PATH, 'utf8'); | ||
| const offending = dts | ||
| .split('\n') | ||
| .map((line, i) => ({ line, n: i + 1 })) | ||
| .filter(({ line }) => /^\s*onLog\??\s*:/.test(line)); | ||
| assert.deepStrictEqual( | ||
| offending, | ||
| [], | ||
| `onLog reappeared in src/index.d.ts at:\n` + | ||
| offending.map(({ n, line }) => ` ${n}: ${line.trim()}`).join('\n'), | ||
| ); | ||
| }); | ||
|
|
||
| test('verbs tolerate a stray onLog property at runtime', async (t) => { | ||
| if (process.env.RELAYBURN_SDK_NAPI_BUILT !== '1') { | ||
| t.skip('napi-rs binding not built — set RELAYBURN_SDK_NAPI_BUILT=1'); | ||
| return; | ||
| } | ||
| let sdk; | ||
| try { | ||
| sdk = await import(join(__dirname, '..', 'src', 'index.js')); | ||
| } catch (err) { | ||
| if (/native binding not found/i.test(String(err && err.message))) { | ||
| t.skip('napi-rs binding load failed — build artifact missing'); | ||
| return; | ||
| } | ||
| throw err; | ||
| } | ||
| // Cast through any-shape to bypass the now-stricter option types: the | ||
| // contract under test is the runtime forgiveness, not the TS shape. | ||
| const stray = { onLog: () => {} }; | ||
| await assert.doesNotReject(() => sdk.summary(stray)); | ||
| await assert.doesNotReject(() => sdk.sessionCost(stray)); | ||
| await assert.doesNotReject(() => sdk.hotspots(stray)); | ||
| }); | ||
|
Comment on lines
+35
to
+56
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Runtime tolerance test does not cover all affected 2.x verbs. The test claims “each verb” but currently checks only Suggested expansion await assert.doesNotReject(() => sdk.summary(stray));
await assert.doesNotReject(() => sdk.sessionCost(stray));
+ await assert.doesNotReject(() => sdk.overhead(stray));
+ await assert.doesNotReject(() => sdk.overheadTrim(stray));
await assert.doesNotReject(() => sdk.hotspots(stray));
+ await assert.doesNotReject(() =>
+ sdk.compare({ models: ['model-a', 'model-b'], onLog: () => {} }),
+ );🤖 Prompt for AI Agents |
||
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Make the Unreleased entry concise and impact-first.
This line includes architecture backstory and an issue link; keep it to API impact and migration effect only.
Suggested edit
As per coding guidelines, “Curate
[Unreleased]sections … with concise, impact-first entries … drop issue/PR links, internal notes, backstory…”.📝 Committable suggestion
🧰 Tools
🪛 LanguageTool
[grammar] ~7-~7: Ensure spelling is correct
Context: ...the callback was already a no-op at the napi boundary. (
#374) ## [2.1.0] - 2026-05-...(QB_NEW_EN_ORTHOGRAPHY_ERROR_IDS_1)
🤖 Prompt for AI Agents