cursedbelt-server 4.63.0 → 4.63.1

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.
@@ -60,9 +60,12 @@ export interface BenchCase {
60
60
  beforeEach?: (c: BenchCase, iteration: number) => void | Promise<void>;
61
61
  }
62
62
  export interface RunCpuBenchOpts {
63
- /** Anything with Hono's `fetch` shape. */
63
+ /**
64
+ * Anything with Hono's `fetch` shape. A METHOD signature on purpose: its parameters are checked bivariantly, so a
65
+ * real `Hono` (whose third parameter is `ExecutionContext`) is accepted — as a function-typed property it was refused.
66
+ */
64
67
  app: {
65
- fetch: (req: Request, env?: unknown, ctx?: unknown) => Response | Promise<Response>;
68
+ fetch(req: Request, env?: unknown, ctx?: unknown): Response | Promise<Response>;
66
69
  };
67
70
  /** The recorder the app's `cpuBudget()` middleware writes through. */
68
71
  recorder: CpuRecorder;
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "cursedbelt-server",
3
- "version": "4.63.0",
3
+ "version": "4.63.1",
4
4
  "license": "ISC",
5
5
  "type": "module",
6
6
  "description": "The app-facing Bun/Hono server tier of the cursedbelt split — storage, sharing, activity, guard, sync. React-free; cursedbelt-core below it.",
@@ -17,7 +17,7 @@
17
17
  },
18
18
  "scripts": {
19
19
  "clean": "rm -rf dist",
20
- "typecheck": "tsc -p tsconfig.build.json --noEmit",
20
+ "typecheck": "tsc -p tsconfig.json --noEmit",
21
21
  "test": "NODE_ENV=development bun test --timeout 60000 --parallel=6 src",
22
22
  "build": "bun run clean && tsc -p tsconfig.build.json",
23
23
  "paths": "bun run scripts/paths.ts",
@@ -64,8 +64,11 @@ export interface BenchCase {
64
64
  }
65
65
 
66
66
  export interface RunCpuBenchOpts {
67
- /** Anything with Hono's `fetch` shape. */
68
- app: { fetch: (req: Request, env?: unknown, ctx?: unknown) => Response | Promise<Response> };
67
+ /**
68
+ * Anything with Hono's `fetch` shape. A METHOD signature on purpose: its parameters are checked bivariantly, so a
69
+ * real `Hono` (whose third parameter is `ExecutionContext`) is accepted — as a function-typed property it was refused.
70
+ */
71
+ app: { fetch(req: Request, env?: unknown, ctx?: unknown): Response | Promise<Response> };
69
72
  /** The recorder the app's `cpuBudget()` middleware writes through. */
70
73
  recorder: CpuRecorder;
71
74
  cases: BenchCase[];
@@ -48,7 +48,7 @@ describe('createDurableChunkStore — two isolates, one object', () => {
48
48
  for (const intermediate of results.slice(0, -1)) expect(intermediate).toBe(false);
49
49
  const last = results.at(-1);
50
50
  expect(last).not.toBeInstanceOf(Error);
51
- expect(last && !(last instanceof Error) ? last.body : null).toEqual(body);
51
+ expect(last && typeof last === 'object' && 'body' in last ? last.body : null).toEqual(body);
52
52
  });
53
53
 
54
54
  test('🔴 the failure it replaces: two per-isolate ChunkStores never finish the payload', async () => {
@@ -48,8 +48,8 @@ describe('createHttpD1', () => {
48
48
  const res = await db.prepare('INSERT INTO t (v) VALUES (?)').bind('x').run();
49
49
  expect(res.meta.changes).toBe(1);
50
50
  expect(res.meta.last_row_id).toBe(7);
51
- expect(await db.prepare('SELECT COUNT(*) n FROM t').first()).toEqual({ n: 3 });
52
- expect(await db.prepare('SELECT COUNT(*) n FROM t').first('n')).toBe(3);
51
+ expect(await db.prepare('SELECT COUNT(*) n FROM t').first<{ n: number }>()).toEqual({ n: 3 });
52
+ expect(await db.prepare('SELECT COUNT(*) n FROM t').first<number>('n')).toBe(3);
53
53
  });
54
54
 
55
55
  test('batch is ONE request carrying every statement, and answers one result each', async () => {
@@ -141,7 +141,7 @@ describe('🔴 a request that never connected is retried; one that may have run
141
141
 
142
142
  test('2026-10-02, family dangling-media: ConnectionRefused on a wake, then the network is back — the read answers', async () => {
143
143
  const { db, waits, calls } = flaky([refused(), refused()]);
144
- expect(await db.prepare('SELECT 1 n').first('n')).toBe(1);
144
+ expect(await db.prepare('SELECT 1 n').first<number>('n')).toBe(1);
145
145
  expect(calls()).toBe(3);
146
146
  expect(waits).toEqual([2_000, 10_000]);
147
147
  });
@@ -161,7 +161,7 @@ describe('🔴 a request that never connected is retried; one that may have run
161
161
 
162
162
  test('an unresolvable host is a never-connected failure too, and a timeout is not', async () => {
163
163
  const dns = Object.assign(new TypeError('getaddrinfo ENOTFOUND api.cloudflare.com'), { code: 'ENOTFOUND' });
164
- expect(await flaky([dns]).db.prepare('SELECT 1 n').first('n')).toBe(1);
164
+ expect(await flaky([dns]).db.prepare('SELECT 1 n').first<number>('n')).toBe(1);
165
165
  const timeout = flaky([new DOMException('The operation timed out.', 'TimeoutError')]);
166
166
  await expect(timeout.db.prepare('SELECT 1').all()).rejects.toThrow('timed out');
167
167
  expect(timeout.calls()).toBe(1);
@@ -48,7 +48,7 @@ describe('the remote driver reports a slow or D1-failed statement', () => {
48
48
  it('a fast statement says nothing', async () => {
49
49
  const { db, reports } = slowBinding({ ms: 20 });
50
50
  expect((await db.prepare('SELECT v FROM t WHERE id = ?').bind(1).all()).results).toEqual([{ v: 'a' }]);
51
- expect(await db.prepare('SELECT v FROM t WHERE id = ?').bind(2).first('v')).toBe('b');
51
+ expect(await db.prepare('SELECT v FROM t WHERE id = ?').bind(2).first<string>('v')).toBe('b');
52
52
  expect(reports).toEqual([]);
53
53
  });
54
54
 
@@ -1,5 +1,6 @@
1
1
  import { describe, expect, test } from "bun:test";
2
2
  import { Hono } from "hono";
3
+ import type { ContentfulStatusCode } from "hono/utils/http-status";
3
4
  import { matchServerAction, type ServerActionRule, serverActions } from "./actions.js";
4
5
  import { createEventSink, type EventsDataset } from "./sink.js";
5
6
 
@@ -23,7 +24,7 @@ const RULES: ServerActionRule[] = [
23
24
  { method: "GET", route: "/api/search", name: "search", purpose: "search" },
24
25
  ];
25
26
 
26
- function harness(status = 200) {
27
+ function harness(status: ContentfulStatusCode = 200) {
27
28
  const dataset = fakeDataset();
28
29
  const events = createEventSink(dataset, { app: "music", build: "abc", now: () => 1_000 });
29
30
  const app = new Hono();
@@ -186,7 +186,7 @@ describe("resolveActorKind — the schema's rule, branch by branch", () => {
186
186
  [{ actor: { id: "a@b.c" }, facts: { ...facts, userAgent: "bingbot" } }, "bot"],
187
187
  [{ actor: { id: "a@b.c", kind: "agent" as const }, facts }, "agent"],
188
188
  ])("%j → %s", (input, expected) => {
189
- expect(resolveActorKind({ ...input, smokeAccounts })).toBe(expected);
189
+ expect(resolveActorKind({ ...input, smokeAccounts })).toBe(expected as ReturnType<typeof resolveActorKind>);
190
190
  });
191
191
  });
192
192
 
@@ -281,7 +281,7 @@ describe("the D1 recorder's dual write", () => {
281
281
  "/api/engagement",
282
282
  createD1EngagementRecorder({
283
283
  db: db as never,
284
- places: [{ id: "home", label: "" }, { id: "upload", label: "" }],
284
+ places: [{ id: "home", path: "/" }, { id: "upload", path: "/#/upload" }],
285
285
  actions: [{ id: "play", label: "" }],
286
286
  resolveUser: () => user,
287
287
  events: { sink, purposes: { upload: "upload" }, actionPurposes: { play: "play" }, actorOf: () => ({ id: "someone@example.com", owner: true }) },
@@ -1104,7 +1104,7 @@ describe('🔴 a read the store PACES is waited out when asked, typed when not (
1104
1104
  const { store, slept } = pacedStore(1, '7');
1105
1105
  const error = await store.get('parts/0').catch((e: unknown) => e);
1106
1106
  expect(error).toBeInstanceOf(BinaryStoreRateLimitedError);
1107
- expect((error as BinaryStoreRateLimitedError).retryAfterSec).toBe(7);
1107
+ expect((error as InstanceType<typeof BinaryStoreRateLimitedError>).retryAfterSec).toBe(7);
1108
1108
  expect((error as Error).message).toBe('[binary-store] get parts/0: 429');
1109
1109
  expect(slept).toEqual([]);
1110
1110
  expect(store.known('parts/0'), 'a pace is not an absence').toBe('unknown');
@@ -1115,7 +1115,7 @@ describe('🔴 a read the store PACES is waited out when asked, typed when not (
1115
1115
  const error = await store.get('parts/0', { paced: { maxWaitMs: 65_000 } }).catch((e: unknown) => e);
1116
1116
  expect(error).toBeInstanceOf(BinaryStoreRateLimitedError);
1117
1117
  expect(slept).toEqual([30_000, 30_000]);
1118
- expect((error as BinaryStoreRateLimitedError).waitedMs).toBe(60_000);
1118
+ expect((error as InstanceType<typeof BinaryStoreRateLimitedError>).waitedMs).toBe(60_000);
1119
1119
  });
1120
1120
 
1121
1121
  it('the default budget is bounded', async () => {
@@ -113,7 +113,7 @@ describe("the SSE stream", () => {
113
113
  });
114
114
  await Promise.resolve();
115
115
  expect(beat).not.toBeNull();
116
- beat?.();
116
+ (beat as (() => void) | null)?.();
117
117
  const text = await drain(stream, 1);
118
118
  expect(text).toBe(": keep-alive\n\n");
119
119
  expect(parseNewsFrame(text)).toBeNull();
@@ -70,7 +70,7 @@ describe('🔴 cursedbelt-server/worker-argon2 — it exists to be imported by a
70
70
  expect(pkg.exports['./worker-argon2']?.node).toBe('./dist/server/worker-argon2/_nodeRefuses.js');
71
71
  expect(conditions.indexOf('node')).toBeLessThan(conditions.indexOf('import'));
72
72
  expect(conditions.indexOf('bun')).toBeLessThan(conditions.indexOf('node'));
73
- await expect(import('./worker-argon2/_nodeRefuses.ts')).rejects.toThrow('not Node');
73
+ await expect(import('./worker-argon2/_nodeRefuses.js')).rejects.toThrow('not Node');
74
74
  });
75
75
  });
76
76
 
@@ -90,10 +90,10 @@ describe('cursedbelt-server/telemetry', () => {
90
90
  });
91
91
 
92
92
  test('publishes PLACE_COLUMNS — the one declaration the buffer writes and every app reads (task 2141)', async () => {
93
- const telemetry = await import('./telemetry.ts');
93
+ const telemetry = await import('./telemetry.js');
94
94
  expect(telemetry.PLACE_COLUMNS).toEqual(['country', 'region', 'city']);
95
95
  // The same array the Bun buffer inserts from, not a second copy of it.
96
- const { PLACE_COLUMNS } = await import('./metrics/requestPlace.ts');
96
+ const { PLACE_COLUMNS } = await import('./metrics/requestPlace.js');
97
97
  expect(telemetry.PLACE_COLUMNS).toBe(PLACE_COLUMNS);
98
98
  });
99
99
  });