Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -61,7 +61,7 @@ describe('bare-day $lte on Field.datetime — the #3777 repro', () => {
await driver.create(
'task',
{ id, title: id, created_at: new Date(at), created_on: at.slice(0, 10) },
{ bypassTenantAudit: true } as any,
{ bypassTenantAudit: true },
);
}
});
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -61,6 +61,7 @@

import { describe, it, expect, beforeAll, afterAll } from 'vitest';
import knexLib from 'knex';
import type { DriverOptions } from '@objectstack/spec/data';
import { SqlDriver } from './index.js';

const TABLE = 'os6577_zero_page';
Expand Down Expand Up @@ -96,7 +97,7 @@ function paginationTail(sql: string): string {
return m ? m[0].toLowerCase() : '';
}

const READ = { bypassTenantAudit: true } as any;
const READ: DriverOptions = { bypassTenantAudit: true };

describe('driver-sql — `limit: 0` returns no records on every door (#6577)', () => {
let driver: InspectableSqlDriver;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -108,7 +108,7 @@ describe('SqlDriver — defaultValue runtime tokens never become a column DEFAUL

// A system/anonymous write: exactly the seed-replay shape that produced the
// two dangling `sys_user:current_user` references #4551's audit reported.
await driver.create('field_zoo', { id: 'z1', title: 'specimen' }, { bypassTenantAudit: true } as any);
await driver.create('field_zoo', { id: 'z1', title: 'specimen' }, { bypassTenantAudit: true });

const row = await knexInstance('field_zoo').where('id', 'z1').first();
expect(row.f_owner).toBeNull();
Expand All @@ -118,7 +118,7 @@ describe('SqlDriver — defaultValue runtime tokens never become a column DEFAUL
it('an explicitly supplied user id is still stored (the column is a normal lookup)', async () => {
const driver = makeDriver();
await driver.initObjects(fieldZoo as any);
await driver.create('field_zoo', { id: 'z2', title: 't', f_owner: 'usr_42' }, { bypassTenantAudit: true } as any);
await driver.create('field_zoo', { id: 'z2', title: 't', f_owner: 'usr_42' }, { bypassTenantAudit: true });
const row = await knexInstance('field_zoo').where('id', 'z2').first();
expect(row.f_owner).toBe('usr_42');
});
Expand All @@ -128,7 +128,7 @@ describe('SqlDriver — defaultValue runtime tokens never become a column DEFAUL
it("REGRESSION: 'NOW()' still gets its driver-native default and stores a canonical instant", async () => {
const driver = makeDriver();
await driver.initObjects(fieldZoo as any);
await driver.create('field_zoo', { id: 'z3', title: 't' }, { bypassTenantAudit: true } as any);
await driver.create('field_zoo', { id: 'z3', title: 't' }, { bypassTenantAudit: true });
const row = await knexInstance('field_zoo').where('id', 'z3').first();
expect(row.f_seen_at).toMatch(ISO_Z);
expect(String(row.f_seen_at)).not.toContain('NOW()');
Expand Down Expand Up @@ -217,7 +217,7 @@ describe('SqlDriver — defaultValue runtime tokens never become a column DEFAUL
expect(info.f_owner.defaultValue ?? null).toBeNull();
expect(await driver.detectManagedDrift(fieldZoo as any)).toEqual([]);

await driver.create('field_zoo', { id: 'after', title: 'C' }, { bypassTenantAudit: true } as any);
await driver.create('field_zoo', { id: 'after', title: 'C' }, { bypassTenantAudit: true });
const row = await knexInstance('field_zoo').where('id', 'after').first();
expect(row.f_owner).toBeNull();
});
Expand All @@ -244,7 +244,7 @@ describe('SqlDriver — defaultValue runtime tokens never become a column DEFAUL
expect(String(info.f_seen_at.defaultValue ?? '')).toContain('strftime');
expect(String(info.f_status.defaultValue ?? '')).toContain('open');

await driver.create('field_zoo', { id: 'post', title: 'D' }, { bypassTenantAudit: true } as any);
await driver.create('field_zoo', { id: 'post', title: 'D' }, { bypassTenantAudit: true });
const row = await knexInstance('field_zoo').where('id', 'post').first();
expect(row.f_seen_at).toMatch(ISO_Z);
expect(row.f_status).toBe('open');
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -193,7 +193,7 @@ function declareDatetimeSweep(cell: DialectCell): void {
on: r.on,
why: r.why,
},
{ bypassTenantAudit: true } as any,
{ bypassTenantAudit: true },
);
}
});
Expand Down Expand Up @@ -307,7 +307,7 @@ function declareTimeSweep(cell: DialectCell): void {
at: r.writerForm === 'native' ? new Date(`1970-01-01T${r.at}Z`) : r.at,
why: r.why,
},
{ bypassTenantAudit: true } as any,
{ bypassTenantAudit: true },
);
}
});
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -143,7 +143,7 @@ describe('#5262 — tenant-audit fires on a posture-only walled deployment', ()
await driver.create(
'account',
{ id: 'x1', organization_id: 'org_a', name: 'X1' },
{ bypassTenantAudit: true } as any,
{ bypassTenantAudit: true },
);
expect(tenantAuditWarned()).toBe(false);
});
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -433,7 +433,7 @@ describe('SqlDriver tenant scope (organization_id)', () => {
await driver.create(
'account',
{ id: 'x1', organization_id: 'org_a', name: 'X1' },
{ bypassTenantAudit: true } as any,
{ bypassTenantAudit: true },
);
expect(warnSpy).toHaveLength(0);
});
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -70,7 +70,7 @@ describe('[#6409] driver-sqlite-wasm — aggregate vocabulary conformance', () =
},
]);
for (const row of AGGREGATION_ROWS) {
await driver.create(OBJECT, { ...row }, { bypassTenantAudit: true } as any);
await driver.create(OBJECT, { ...row }, { bypassTenantAudit: true });
}
});

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -29,7 +29,7 @@ describe('SqliteWasmDriver — bare-day $lte covers the whole day (#3777)', () =
await driver.create(
'task',
{ id, title: id, created_at: new Date(at) },
{ bypassTenantAudit: true } as any,
{ bypassTenantAudit: true },
);
}
});
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -332,7 +332,7 @@ describe('SqliteWasmDriver tenant scope (organization_id)', () => {
await driver.create(
'account',
{ id: 'x1', organization_id: 'org_a', name: 'X1' },
{ bypassTenantAudit: true } as any,
{ bypassTenantAudit: true },
);
expect(warnSpy).toHaveLength(0);
} finally {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -32,8 +32,8 @@ describe('[#5240] driver-sqlite-wasm inherits the zero-operator field-constraint
await driver.initObjects([
{ name: 'deal', fields: { stage: { type: 'string' }, owner: { type: 'string' } } },
]);
await driver.create('deal', { id: '1', stage: 'won', owner: 'u1' }, { bypassTenantAudit: true } as any);
await driver.create('deal', { id: '2', stage: 'lost', owner: 'u2' }, { bypassTenantAudit: true } as any);
await driver.create('deal', { id: '1', stage: 'won', owner: 'u1' }, { bypassTenantAudit: true });
await driver.create('deal', { id: '2', stage: 'lost', owner: 'u2' }, { bypassTenantAudit: true });
});

afterAll(async () => {
Expand All @@ -44,7 +44,7 @@ describe('[#5240] driver-sqlite-wasm inherits the zero-operator field-constraint
const rows = await driver.find(
'deal',
{ object: 'deal', fields: ['id'], where } as any,
{ bypassTenantAudit: true } as any,
{ bypassTenantAudit: true },
);
return (rows as any[]).map((r) => String(r.id)).sort();
};
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -48,7 +48,7 @@ describe('driver-sqlite-wasm — filter logic conformance', () => {
},
]);
for (const row of FILTER_LOGIC_ROWS) {
await driver.create('conformance', { ...row }, { bypassTenantAudit: true } as any);
await driver.create('conformance', { ...row }, { bypassTenantAudit: true });
}
});

Expand All @@ -61,7 +61,7 @@ describe('driver-sqlite-wasm — filter logic conformance', () => {
const rows = await driver.find(
'conformance',
{ object: 'conformance', where: c.filter } as any,
{ bypassTenantAudit: true } as any,
{ bypassTenantAudit: true },
);
const got = (rows as any[])
.map((r) => String(r.id))
Expand All @@ -75,7 +75,7 @@ describe('driver-sqlite-wasm — filter logic conformance', () => {
* failed cannot read as a case that correctly excluded everything.
*/
it('the fixture really is all four rows', async () => {
const rows = await driver.find('conformance', {} as any, { bypassTenantAudit: true } as any);
const rows = await driver.find('conformance', {} as any, { bypassTenantAudit: true });
expect((rows as any[]).map((r) => String(r.id)).sort()).toEqual(['1', '2', '3', '4']);
});
});
Original file line number Diff line number Diff line change
Expand Up @@ -41,8 +41,8 @@ describe('[#5347/#5348] driver-sqlite-wasm inherits the out-of-contract filter r
await driver.initObjects([
{ name: 'deal', fields: { stage: { type: 'string' }, score: { type: 'number' } } },
]);
await driver.create('deal', { id: '1', stage: 'won', score: 10 }, { bypassTenantAudit: true } as any);
await driver.create('deal', { id: '2', stage: null, score: 20 }, { bypassTenantAudit: true } as any);
await driver.create('deal', { id: '1', stage: 'won', score: 10 }, { bypassTenantAudit: true });
await driver.create('deal', { id: '2', stage: null, score: 20 }, { bypassTenantAudit: true });
});

afterAll(async () => {
Expand All @@ -53,7 +53,7 @@ describe('[#5347/#5348] driver-sqlite-wasm inherits the out-of-contract filter r
const rows = await driver.find(
'deal',
{ object: 'deal', fields: ['id'], where } as any,
{ bypassTenantAudit: true } as any,
{ bypassTenantAudit: true },
);
return (rows as any[]).map((r) => String(r.id)).sort();
};
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -22,6 +22,7 @@

import { describe, it, expect, beforeAll, afterAll } from 'vitest';
import {
type DriverOptions,
PAGINATION_ALL_IDS,
PAGINATION_CASES,
PAGINATION_ROWS,
Expand All @@ -31,7 +32,7 @@ import {
import { SqliteWasmDriver } from './index.js';

/** Shared read options — a named const so no call site casts its own (#4674). */
const READ_OPTIONS = { bypassTenantAudit: true } as unknown as Parameters<SqliteWasmDriver['find']>[2];
const READ_OPTIONS: DriverOptions = { bypassTenantAudit: true };

describe('driver-sqlite-wasm — paged reads are a partition of the result set', () => {
let driver: SqliteWasmDriver;
Expand All @@ -49,7 +50,7 @@ describe('driver-sqlite-wasm — paged reads are a partition of the result set',
},
]);
for (const row of PAGINATION_ROWS) {
await driver.create('ticket', { ...row }, { bypassTenantAudit: true } as any);
await driver.create('ticket', { ...row }, { bypassTenantAudit: true });
}
});

Expand All @@ -63,7 +64,7 @@ describe('driver-sqlite-wasm — paged reads are a partition of the result set',
const page = await driver.find(
'ticket',
{ ...(orderBy ? { orderBy: [...orderBy] } : {}), limit: pageSize, offset } as any,
{ bypassTenantAudit: true } as any,
{ bypassTenantAudit: true },
);
seen.push(...page.map((r: any) => String(r.id)));
}
Expand All @@ -83,7 +84,7 @@ describe('driver-sqlite-wasm — paged reads are a partition of the result set',
const whole = await driver.find(
'ticket',
{ orderBy: [...testCase.orderBy] } as any,
{ bypassTenantAudit: true } as any,
{ bypassTenantAudit: true },
);
expect(paged).toEqual(whole.map((r: any) => String(r.id)));
});
Expand All @@ -106,7 +107,7 @@ describe('driver-sqlite-wasm — paged reads are a partition of the result set',
}

it('leaves an UNPAGED unordered read alone — no sort is imposed on a caller who asked for none', async () => {
const rows = await driver.find('ticket', {} as any, { bypassTenantAudit: true } as any);
const rows = await driver.find('ticket', {} as any, { bypassTenantAudit: true });
expect(rows.map((r: any) => r.id)).toEqual(PAGINATION_ROWS.map((r) => r.id));
});

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -77,7 +77,7 @@ describe('driver-sqlite-wasm — temporal conformance', () => {
on: r.on,
why: r.why,
},
{ bypassTenantAudit: true } as any,
{ bypassTenantAudit: true },
);
}
});
Expand Down Expand Up @@ -121,7 +121,7 @@ describe('driver-sqlite-wasm — Field.time conformance', () => {
at: r.writerForm === 'native' ? new Date(`1970-01-01T${r.at}Z`) : r.at,
why: r.why,
},
{ bypassTenantAudit: true } as any,
{ bypassTenantAudit: true },
);
}
});
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -49,7 +49,7 @@ describe('[#5495] TursoDriver autonumber re-seed', () => {
it('LOCAL: serves the create on the first attempt after a seed replay lands above the counter', async () => {
const knex = (driver as any).knex;

await driver.create('crm_case', { organization_id: 'orgA', title: 'first' }, { bypassTenantAudit: true } as any);
await driver.create('crm_case', { organization_id: 'orgA', title: 'first' }, { bypassTenantAudit: true });

const rows = [];
for (let n = 2; n <= 30; n++) {
Expand All @@ -60,7 +60,7 @@ describe('[#5495] TursoDriver autonumber re-seed', () => {
const created = await driver.create(
'crm_case',
{ organization_id: 'orgA', title: 'after the seeds' },
{ bypassTenantAudit: true } as any,
{ bypassTenantAudit: true },
);
expect(created.case_number).toBe('CASE-00031');
});
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -111,7 +111,7 @@ describe('TursoDriver — temporal conformance (local mode)', () => {
on: r.on,
why: r.why,
},
{ bypassTenantAudit: true } as any,
{ bypassTenantAudit: true },
);
}
});
Expand Down Expand Up @@ -153,7 +153,7 @@ describe('TursoDriver — Field.time conformance (local mode)', () => {
at: r.writerForm === 'native' ? new Date(`1970-01-01T${r.at}Z`) : r.at,
why: r.why,
},
{ bypassTenantAudit: true } as any,
{ bypassTenantAudit: true },
);
}
});
Expand Down
2 changes: 1 addition & 1 deletion scripts/query-options-erasure-baseline.json
Original file line number Diff line number Diff line change
Expand Up @@ -51,6 +51,6 @@
"packages/services/service-settings/src/settings-service.ts": 2
},
"testSurface": {
"sites": 263
"sites": 256
}
}
Loading