import { readFileSync } from 'node:fs'; import { fileURLToPath } from 'node:url'; import { describe, expect, it } from 'vitest'; import { PersonalDataServer } from '../packages/core/src/pds.js'; // /xrpc/_health reports a version constant hardcoded in pds.js, because // @pdsjs/core has to run on Workers and Deno where it cannot import // package.json. Nothing in the release process edits source, so the constant // silently went stale — it reported 0.7.0 while the package was 0.8.0. This // test is what keeps the two together. describe('reported version', () => { it('matches the @pdsjs/core package version', async () => { const pkg = JSON.parse( readFileSync( fileURLToPath( new URL('../packages/core/package.json', import.meta.url), ), 'utf8', ), ); // _health touches no storage, so the ports can be bare stubs. const pds = new PersonalDataServer({ actorStorage: /** @type {any} */ ({}), sharedStorage: /** @type {any} */ ({}), blobs: /** @type {any} */ ({}), jwtSecret: 'test-secret', }); const response = await pds.fetch( new Request('https://pds.example.com/xrpc/_health'), ); expect(await response.json()).toEqual({ version: pkg.version }); }); });