@fabrika/db 0.9.0-dev.3 → 0.9.0-dev.5
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/package.json +34 -3
- package/src/admissions.ts +78 -12
- package/src/application-rows.ts +108 -0
- package/src/capability.ts +5 -0
- package/src/codegen-sqlite.ts +154 -0
- package/src/codegen.ts +59 -9
- package/src/database.ts +227 -61
- package/src/errors.ts +2 -2
- package/src/file-columns.ts +4 -1
- package/src/framework-tables.ts +28 -8
- package/src/framework.ts +14 -5
- package/src/guard.ts +8 -0
- package/src/index.ts +9 -1
- package/src/job-leases.ts +210 -54
- package/src/job-wakes.ts +450 -0
- package/src/links.ts +8 -1
- package/src/migrations-sqlite.ts +163 -0
- package/src/migrations.ts +25 -0
- package/src/nodes.ts +64 -9
- package/src/orm-types.ts +2 -2
- package/src/orm.ts +68 -35
- package/src/policy.ts +8 -2
- package/src/postgres.ts +26 -0
- package/src/registry.ts +11 -2
- package/src/sql.ts +216 -473
- package/src/sqlite-bun.ts +122 -0
- package/src/sqlite-migrate.ts +242 -0
- package/src/sqlite.ts +224 -0
- package/src/store.ts +362 -93
- package/src/stored-files.ts +188 -52
- package/src/tables.ts +16 -0
- package/src/temporal.ts +115 -9
- package/src/testing-shared.ts +733 -0
- package/src/testing-sqlite.ts +513 -0
- package/src/testing.ts +169 -482
- package/types/src/application-rows.d.ts +58 -0
- package/types/src/capability.d.ts +5 -0
- package/types/src/codegen-sqlite.d.ts +6 -0
- package/types/src/codegen.d.ts +30 -0
- package/types/src/database.d.ts +81 -20
- package/types/src/errors.d.ts +2 -2
- package/types/src/framework.d.ts +11 -5
- package/types/src/index.d.ts +1 -1
- package/types/src/job-leases.d.ts +32 -4
- package/types/src/job-wakes.d.ts +101 -0
- package/types/src/migrations-sqlite.d.ts +4 -0
- package/types/src/migrations.d.ts +1 -0
- package/types/src/nodes.d.ts +13 -2
- package/types/src/orm-types.d.ts +2 -2
- package/types/src/policy.d.ts +4 -0
- package/types/src/postgres.d.ts +12 -0
- package/types/src/registry.d.ts +10 -2
- package/types/src/sql.d.ts +29 -21
- package/types/src/sqlite-bun.d.ts +13 -0
- package/types/src/sqlite-migrate.d.ts +28 -0
- package/types/src/sqlite.d.ts +24 -0
- package/types/src/store.d.ts +26 -9
- package/types/src/stored-files.d.ts +6 -2
- package/types/src/tables.d.ts +10 -0
- package/types/src/temporal.d.ts +21 -0
- package/types/src/testing-shared.d.ts +201 -0
- package/types/src/testing-sqlite.d.ts +22 -0
- package/types/src/testing.d.ts +2 -93
package/types/src/testing.d.ts
CHANGED
|
@@ -1,8 +1,7 @@
|
|
|
1
|
-
import { Database } from './database';
|
|
2
|
-
import type { Primitive } from './description';
|
|
3
|
-
import { type Tables } from './policy';
|
|
4
1
|
import type { TableProbe } from './store';
|
|
2
|
+
import { type TestDatabase } from './testing-shared';
|
|
5
3
|
export { ChildTable, defineChildStore, defineStore, DimensionTable, type TableProbe } from './store';
|
|
4
|
+
export { type ApplicationRow, type IsolationWorlds, type SampleValue, SEEDED_OBJECT_VERSION, type SeededApplicationRows, type SeededRow, SeedLimitError, type TestDatabase, type WorldRow, } from './testing-shared';
|
|
6
5
|
export declare const TEST_POSTGRES_URL = "FABRIKA_TEST_POSTGRES_URL";
|
|
7
6
|
/** Set to `1` by the platform build: a missing test database is then a failure, not a skip. */
|
|
8
7
|
export declare const TEST_POSTGRES_REQUIRED = "FABRIKA_TEST_POSTGRES_REQUIRED";
|
|
@@ -17,96 +16,6 @@ export interface TestDatabaseOptions {
|
|
|
17
16
|
*/
|
|
18
17
|
readonly connectionWaitMs?: number;
|
|
19
18
|
}
|
|
20
|
-
/** A value a test row holds in a column; `null` for a nullable column the fixture left empty. */
|
|
21
|
-
export type SampleValue = Primitive | null;
|
|
22
|
-
/** One seeded row and where it lies. */
|
|
23
|
-
export interface WorldRow {
|
|
24
|
-
/** The row's key: the dimension value of a dimension table's row, a child's own key. */
|
|
25
|
-
readonly key: string;
|
|
26
|
-
/** A child row's parent key; `null` for a dimension table. */
|
|
27
|
-
readonly parent: string | null;
|
|
28
|
-
/** The value of the grant dimension the row lies in (`IsolationWorlds.dimension`). */
|
|
29
|
-
readonly scope: string;
|
|
30
|
-
/**
|
|
31
|
-
* Every dimension value the row lies in: a dimension table's own first, then each container, innermost first. A
|
|
32
|
-
* share link's chain is this list.
|
|
33
|
-
*/
|
|
34
|
-
readonly chain: readonly {
|
|
35
|
-
readonly type: string;
|
|
36
|
-
readonly value: string;
|
|
37
|
-
}[];
|
|
38
|
-
/** The row's values of the policy's update columns, as seeded. */
|
|
39
|
-
readonly updates: Readonly<Record<string, SampleValue>>;
|
|
40
|
-
/**
|
|
41
|
-
* The distinct value written into every text column the fixture filled itself, in this row and in its containers.
|
|
42
|
-
* Each occurs in no other fixture, so one found in an answer to another scope is a leaked row.
|
|
43
|
-
*/
|
|
44
|
-
readonly markers: readonly string[];
|
|
45
|
-
}
|
|
46
|
-
/** One seeded row of an application table, which lies in no dimension. */
|
|
47
|
-
export interface ApplicationRow {
|
|
48
|
-
readonly key: string;
|
|
49
|
-
/** The row's values of the policy's update columns, as seeded. */
|
|
50
|
-
readonly updates: Readonly<Record<string, SampleValue>>;
|
|
51
|
-
/** The distinct value written into every text column the fixture filled itself. */
|
|
52
|
-
readonly markers: readonly string[];
|
|
53
|
-
}
|
|
54
|
-
/** A row seeded under another: its key, and the distinct value written into every text column the fixture filled. */
|
|
55
|
-
export interface SeededRow {
|
|
56
|
-
readonly key: string;
|
|
57
|
-
readonly markers: readonly string[];
|
|
58
|
-
}
|
|
59
|
-
/**
|
|
60
|
-
* What the isolation fixture cannot seed for a schema: a CHECK its values fail, a required foreign key to a scoped table
|
|
61
|
-
* outside the containment chain. It is a limit of the generator, named with the constraint or the column, never a
|
|
62
|
-
* failure of the handler or the policy a case is about.
|
|
63
|
-
*/
|
|
64
|
-
export declare class SeedLimitError extends Error {
|
|
65
|
-
readonly name = "SeedLimitError";
|
|
66
|
-
}
|
|
67
|
-
/** One row of a table in each of two containment chains that share no value. */
|
|
68
|
-
export interface IsolationWorlds {
|
|
69
|
-
/**
|
|
70
|
-
* The dimension a caller's grants are scoped by: a dimension table's container, or its own dimension when it has
|
|
71
|
-
* none; a child table's parent's.
|
|
72
|
-
*/
|
|
73
|
-
readonly dimension: string;
|
|
74
|
-
readonly own: WorldRow;
|
|
75
|
-
readonly other: WorldRow;
|
|
76
|
-
}
|
|
77
|
-
export interface TestDatabase {
|
|
78
|
-
/** The connection `boot` binds the data layer to: the runtime role, on the migrated schema. */
|
|
79
|
-
readonly database: Database;
|
|
80
|
-
readonly schema: string;
|
|
81
|
-
/**
|
|
82
|
-
* Seeds one row of `table` in each of two fresh chains, with every container row a table owns. `values` (column →
|
|
83
|
-
* value) are written into both rows of `table`: the state an endpoint's precondition needs. A text column keeps its
|
|
84
|
-
* marker, so a seed of one, or of a column that places the row, throws.
|
|
85
|
-
*/
|
|
86
|
-
seedWorlds<DB, P>(tables: Tables<DB, P>, table: string, values?: Readonly<Record<string, SampleValue>>): Promise<IsolationWorlds>;
|
|
87
|
-
/** Seeds one row of the application table `table`: its key, version and creator stamped, every other column sampled. */
|
|
88
|
-
seedRow<DB, P>(tables: Tables<DB, P>, table: string): Promise<ApplicationRow>;
|
|
89
|
-
/**
|
|
90
|
-
* Seeds one row of `table`, a child or dimension table that lies in the object of `under` (a row `seedWorlds`
|
|
91
|
-
* seeded), placed in that row's chain: the row a fixture names by id, such as a note's comment. Answers its key and
|
|
92
|
-
* the markers it holds.
|
|
93
|
-
*/
|
|
94
|
-
seedUnder<DB, P>(tables: Tables<DB, P>, table: string, under: WorldRow): Promise<SeededRow>;
|
|
95
|
-
/** Values for the policy's insert columns of `table` that its schema accepts: every required one, sampled; a file column a seeded file. */
|
|
96
|
-
sampleInsert<DB, P>(tables: Tables<DB, P>, table: string): Promise<Readonly<Record<string, SampleValue>>>;
|
|
97
|
-
/**
|
|
98
|
-
* The object key of every file the fixture seeded into a file column, oldest first. Each stands for an empty object,
|
|
99
|
-
* which a test's object store holds when a handler serves or opens the file.
|
|
100
|
-
*/
|
|
101
|
-
seededObjects(): readonly string[];
|
|
102
|
-
/** Closes the connections and drops the schema and its roles. */
|
|
103
|
-
close(): Promise<void>;
|
|
104
|
-
}
|
|
105
|
-
/**
|
|
106
|
-
* The object version a seeded file was scanned at: whoever stocks its empty object (`seededObjects`) stores it under
|
|
107
|
-
* this version, so a file of a scanning kind is served as a live one is, by its scanned version.
|
|
108
|
-
*/
|
|
109
|
-
export declare const SEEDED_OBJECT_VERSION = "\"seeded\"";
|
|
110
19
|
/**
|
|
111
20
|
* A fresh schema with the framework's and the application's migrations applied by the real runner (`@fabrika/platform-node`) as its
|
|
112
21
|
* migration role, connected and seeded as its runtime role, or `null` after the standard skip message when
|