Skip to content
Open
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
107 changes: 0 additions & 107 deletions packages/appkit/src/database/contract/column-info.ts

This file was deleted.

2 changes: 0 additions & 2 deletions packages/appkit/src/database/contract/index.ts
Original file line number Diff line number Diff line change
@@ -1,4 +1,2 @@
export * from "./column-info";
export * from "./registry";
export * from "./relation";
export * from "./wire";
24 changes: 0 additions & 24 deletions packages/appkit/src/database/contract/relation.ts

This file was deleted.

130 changes: 0 additions & 130 deletions packages/appkit/src/database/contract/tests/column-info.test.ts

This file was deleted.

39 changes: 1 addition & 38 deletions packages/appkit/src/database/contract/tests/registry.test.ts
Original file line number Diff line number Diff line change
@@ -1,11 +1,6 @@
import { describe, expectTypeOf, it } from "vitest";

import type {
DatabaseRegistryEntry,
ReferentialAction,
RegisteredEntity,
RelationEdge,
} from "../index";
import type { DatabaseRegistryEntry, RegisteredEntity } from "../index";

/**
* Type-level tests for the contract. These are verified by `tsc` during
Expand Down Expand Up @@ -58,35 +53,3 @@ describe("DatabaseRegistryEntry shape", () => {
expectTypeOf<DatabaseRegistryEntry>().toHaveProperty("includes");
});
});

describe("RelationEdge shape", () => {
it("requires the from/to columns and allows optional referential actions", () => {
const edge: RelationEdge = {
fromColumn: "author_id",
toTable: "users",
toColumn: "id",
onDelete: "cascade",
onUpdate: "no action",
};
expectTypeOf(edge.fromColumn).toEqualTypeOf<string>();
expectTypeOf(edge.toTable).toEqualTypeOf<string>();
expectTypeOf(edge.toColumn).toEqualTypeOf<string>();
expectTypeOf(edge.onDelete).toEqualTypeOf<ReferentialAction | undefined>();
expectTypeOf(edge.onUpdate).toEqualTypeOf<ReferentialAction | undefined>();
});

it("accepts a minimal edge without referential actions", () => {
const edge: RelationEdge = {
fromColumn: "author_id",
toTable: "users",
toColumn: "id",
};
expectTypeOf(edge).toMatchTypeOf<RelationEdge>();
});

it("pins the referential-action union", () => {
expectTypeOf<ReferentialAction>().toEqualTypeOf<
"cascade" | "set null" | "set default" | "restrict" | "no action"
>();
});
});
6 changes: 6 additions & 0 deletions packages/appkit/src/database/contract/tests/wire.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -8,12 +8,14 @@ import {
isFilterOperator,
MAX_INCLUDES,
MAX_LIMIT,
MAX_OFFSET,
} from "../index";

describe("wire caps", () => {
it("pins the literal cap values", () => {
expect(IN_CAP).toBe(100);
expect(MAX_LIMIT).toBe(500);
expect(MAX_OFFSET).toBe(10_000);
expect(DEFAULT_LIMIT).toBe(50);
expect(MAX_INCLUDES).toBe(10);
});
Expand All @@ -22,6 +24,10 @@ describe("wire caps", () => {
expect(DEFAULT_LIMIT).toBeLessThanOrEqual(MAX_LIMIT);
});

it("keeps MAX_LIMIT within MAX_OFFSET", () => {
expect(MAX_LIMIT).toBeLessThanOrEqual(MAX_OFFSET);
});

it("pins the filter-operator set (snapshot of the supported operators)", () => {
expect(FILTER_OPERATORS).toEqual([
"eq",
Expand Down
9 changes: 5 additions & 4 deletions packages/appkit/src/database/contract/wire.ts
Original file line number Diff line number Diff line change
@@ -1,14 +1,15 @@
/** Max number of values allowed in an `in.(…)` list. */
export const IN_CAP = 100;
/** Hard ceiling for `.limit()` clamp. */
/** Hard ceiling for a runtime query limit. */
export const MAX_LIMIT = 500;
/** Hard ceiling for a runtime query offset. OFFSET scans are unbounded in cost. */
export const MAX_OFFSET = 10_000;
/** Default page size when no `.limit()` is supplied. */
export const DEFAULT_LIMIT = 50;
/** Max number of relations resolvable in a single `.include()`. */
export const MAX_INCLUDES = 10;

/** Filter operators usable in the runtime WHERE translator and the `where` spec type. */
export const FILTER_OPERATORS = [
export const FILTER_OPERATORS = Object.freeze([
"eq",
"neq",
"gt",
Expand All @@ -19,7 +20,7 @@ export const FILTER_OPERATORS = [
"ilike",
"in",
"is",
] as const;
] as const);

export type FilterOperator = (typeof FILTER_OPERATORS)[number];

Expand Down
Loading
Loading