Skip to main content

TypeScript First Verification

TypeScript needs two first gates: a real Node SQL round trip and a browser bundle check. Passing one does not prove the other.

1. Type and package checks​

npm ci
npm run build
npm test
rg 'purpose\(|executeForList' generated/domain/src

Confirm that terminals accept only UserContext and exist only on the executable type returned by purpose().

2. SQLite round trip​

Use a fresh file, register the explicit SQLite Node provider in trusted context, ensure schema, save one audited entity, query it, close the provider, reopen, and query again.

it("persists and reloads a record", async () => {
const fixture = await sqliteFixture();
const context = fixture.context;

const order = Q.customerOrders().comment("Create verification order")
.purpose("Verify SQLite persistence").newEntity(context);
order.updateOrderNumber("VERIFY-10001");
const saved = await order.auditAs("Create verification fixture").save(context);

const rows = await Q.customerOrders().comment("Read verification order")
.withOrderNumberContaining("VERIFY-10001").purpose("Verify persisted result")
.executeForList(context);
expect(rows).toHaveLength(1);
expect(rows[0].id).toBe(saved.id);
});

Use emitted names and add an assertion after reconnect.

3. Browser-safe client​

Bundle a tiny browser entry that imports only the federal client profile. Inspect the bundle/dependency graph and fail if pg, mysql2, better-sqlite3, Node built-ins, or server credentials appear. A root import that accidentally drags SQL drivers into the browser is a release blocker.

4. Governance failures​

Test missing comment/purpose/context/audit, stale version, unknown fields/operators, invalid ranges/paging/sorts, and client attempts to set tenant, merchant, actor, permissions, request policy or purpose policy. All must reject explicitly.

5. SQL and federation evidence​

For Node SQL, retain masked traces proving bound parameters, stable order, native aggregates and partition/window per-parent Top-N. For federation, send the generated protocol request to a real TeaQL backend and compare its native/canonical response with a direct backend query. A generic fetch wrapper is not protocol evidence.

6. Regeneration​

Add a field, regenerate the entire package, rebuild both profiles and rerun tests. Record Node/npm/runtime/generator/provider versions, model and lock hashes, commands, exit codes, native responses, and masked trace shapes.