@fabrika/check 0.9.0-dev.18 → 0.9.0-dev.19

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.
@@ -1,57 +0,0 @@
1
- import type { Finding } from './finding';
2
- import type { Sample } from './scaffold-sample';
3
- export declare const FIXTURES_EXPORT = "fixtures";
4
- export declare const SEEDS_EXPORT = "seeds";
5
- export declare const MEMBERS_EXPORT = "members";
6
- export declare const INVITATIONS_EXPORT = "invitations";
7
- export declare const LINKS_EXPORT = "links";
8
- export declare const ROWS_EXPORT = "rows";
9
- export declare const APP_ROWS_EXPORT = "appRows";
10
- export declare const FILES_EXPORT = "files";
11
- export declare const REFUSALS_EXPORT = "refusals";
12
- export declare const PINS_EXPORT = "pins";
13
- export declare const CALLER_ROWS_EXPORT = "callerRows";
14
- type ById = Readonly<Record<string, Readonly<Record<string, Sample>>>>;
15
- export interface EndpointFixtures {
16
- /** The input each endpoint's cases send, by endpoint id. */
17
- readonly inputs: ById;
18
- /** The columns of the row each endpoint addresses, as both scopes' rows are seeded, by endpoint id. */
19
- readonly seeds: ById;
20
- /** The input fields that name a member of the endpoint's member directory, by endpoint id. */
21
- readonly members: Readonly<Record<string, readonly string[]>>;
22
- /** The input fields that name an invitation the endpoint cancels, by endpoint id. */
23
- readonly invitations: Readonly<Record<string, readonly string[]>>;
24
- /** The input fields that name a share link the endpoint revokes, by endpoint id. */
25
- readonly links: Readonly<Record<string, readonly string[]>>;
26
- /** The input fields that name a row lying in the endpoint's object, with that row's table, by endpoint id. */
27
- readonly rows: Readonly<Record<string, Readonly<Record<string, string>>>>;
28
- /** The rows of application tables the endpoint's own case reads, by table, each with its columns, by endpoint id. */
29
- readonly appRows: Readonly<Record<string, Readonly<Record<string, Readonly<Record<string, Sample>>>>>>;
30
- /** The file each case sends in a file field, a path relative to the application's root, by input field, by endpoint id. */
31
- readonly files: Readonly<Record<string, Readonly<Record<string, string>>>>;
32
- /** The error types of the 400s an endpoint's handler may answer its own object with, by endpoint id. */
33
- readonly refusals: Readonly<Record<string, readonly string[]>>;
34
- /** The own scope's value of each pinned text column of the row the endpoint addresses, by endpoint id. */
35
- readonly pins: Readonly<Record<string, Readonly<Record<string, string>>>>;
36
- /** The rows of application tables the caller of every global case holds, by table, each with its columns. */
37
- readonly callerRows: Readonly<Record<string, Readonly<Record<string, Sample>>>>;
38
- }
39
- export declare const NO_FIXTURES: EndpointFixtures;
40
- /**
41
- * Whether `path` may name a file fixture: relative to the application's root, `/`-separated, and each segment of
42
- * letters, digits, `_`, `-` and `.` that starts with neither `.` nor `-`, so it never leaves the root, names no dotfile and
43
- * reads the same as a URL path.
44
- */
45
- export declare const isFixtureFilePath: (path: string) => boolean;
46
- export declare function isSampleObject(value: Sample): value is {
47
- readonly [key: string]: Sample;
48
- };
49
- /** The fixtures of `files`, by endpoint id; none without the file. */
50
- export declare function readEndpointFixtures(files: ReadonlyMap<string, string>): {
51
- readonly ok: true;
52
- readonly fixtures: EndpointFixtures;
53
- } | {
54
- readonly ok: false;
55
- readonly findings: readonly Finding[];
56
- };
57
- export {};
@@ -1,18 +0,0 @@
1
- import type { Finding } from '../finding';
2
- import { type GeneratedTest } from '../scaffold';
3
- /** The tests the scaffold writes for these files, or the findings that stop it from reading them. */
4
- export declare const expectedGeneratedTests: (files: ReadonlyMap<string, string>) => Promise<{
5
- readonly ok: true;
6
- readonly tests: ReadonlyMap<string, GeneratedTest>;
7
- readonly missing: readonly Finding[];
8
- } | {
9
- readonly ok: false;
10
- readonly findings: readonly Finding[];
11
- }>;
12
- /**
13
- * Every generated test is byte for byte what the scaffold writes from the current contract and policies: a missing,
14
- * edited or replaced one is a finding, header or not, and so is a generated test the scaffold no longer writes.
15
- * `readable` is false while the literal or trust rules report the sources; otherwise what the reader refuses is
16
- * reported here, so a source it cannot read does not silence the check.
17
- */
18
- export declare const checkGeneratedTests: (files: ReadonlyMap<string, string>, readable: boolean) => Promise<Finding[]>;
@@ -1,8 +0,0 @@
1
- import type { SchemaShape } from '@fabrika/auth-core';
2
- export type Sample = null | boolean | number | string | readonly Sample[] | {
3
- readonly [key: string]: Sample;
4
- };
5
- /** A value `shape` admits, or `undefined`. */
6
- export declare function sample(shape: SchemaShape): Sample | undefined;
7
- /** The literal as dprint writes it: single quotes, bare keys where they are identifiers. */
8
- export declare function renderSample(value: Sample): string;
@@ -1,36 +0,0 @@
1
- import { type ContractArtifact, type TablePolicyArtifact } from '@fabrika/auth-core';
2
- import { type Tables } from '@fabrika/db/tables';
3
- import { type ApplicationDialect } from './dialect';
4
- import { type EndpointFixtures } from './endpoint-fixtures';
5
- import type { Finding } from './finding';
6
- export { ENDPOINT_ACCESS_TEST, ENDPOINT_FIXTURES_FILE, POLICY_TEST_SUFFIX, POLICY_TESTS_DIR } from './layout';
7
- export declare const policyTestPath: (table: string) => string;
8
- /** One generated test file: its full text, header included, and the name of every test case it registers. */
9
- export interface GeneratedTest {
10
- readonly text: string;
11
- readonly cases: readonly string[];
12
- /** What the test cannot check, one line each, which `fabrika db test-scaffold` prints: a ruled-out capability case. */
13
- readonly notes: readonly string[];
14
- }
15
- type Policies = Readonly<Record<string, TablePolicyArtifact>>;
16
- /**
17
- * Every test the scaffold writes for these policies and, when the application has a contract, its artifact; by path.
18
- * Endpoint access tests exist only for an application on `@fabrika/db`, which has policies to seed rows from. They
19
- * open the test database of the application's dialect.
20
- */
21
- export declare const generatedTests: (policies: Policies, artifact: ContractArtifact | null, fixtures?: EndpointFixtures, dialect?: ApplicationDialect) => Promise<ReadonlyMap<string, GeneratedTest>>;
22
- export interface ScaffoldInputs {
23
- /** What `src/db/tables.ts` defines, its column list included; `null` without the file. */
24
- readonly tables: Tables<unknown, unknown> | null;
25
- readonly policies: Policies;
26
- readonly artifact: ContractArtifact | null;
27
- readonly fixtures: EndpointFixtures;
28
- readonly dialect: ApplicationDialect;
29
- }
30
- /** What the scaffold reads from an application's files; throws `ContractSourceError` or `ContractError` as the reader does. */
31
- export declare const scaffoldInputs: (files: ReadonlyMap<string, string>) => ScaffoldInputs;
32
- /**
33
- * What stops the endpoint access tests from covering every endpoint: one whose input the scaffold cannot sample and
34
- * the author gave no fixture, and a fixture of no tested endpoint. Each is an `endpoint-fixture` finding.
35
- */
36
- export declare const missingEndpointFixtures: ({ tables, policies, artifact, fixtures }: ScaffoldInputs) => readonly Finding[];