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|executeEntitiesForList' 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 ctx = fixture.context;

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

const rows = await Q.customerOrders().comment("Read verification order")
.withOrderNumberContaining("VERIFY-10001").purpose("Verify persisted result")
.executeEntitiesForList(ctx);
expect(rows).toHaveLength(1);
});

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.