@fabrika/check 0.9.0-dev.2 → 0.9.0-dev.21
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 +7 -7
- package/src/ast.ts +69 -6
- package/src/check.ts +148 -44
- package/src/cli.ts +34 -8
- package/src/contract.ts +42 -6
- package/src/dialect.ts +29 -0
- package/src/finding.ts +14 -7
- package/src/index.ts +4 -12
- package/src/inputs.ts +4 -2
- package/src/layout.ts +41 -12
- package/src/limits.ts +13 -3
- package/src/migration-base.ts +85 -0
- package/src/reader/schema.ts +42 -512
- package/src/reader/surface.ts +43 -5
- package/src/reader/value.ts +18 -6
- package/src/resolution.ts +2 -2
- package/src/rules/cloudflare.ts +59 -0
- package/src/rules/compile.ts +32 -0
- package/src/rules/framework.ts +2 -2
- package/src/rules/literal.ts +3 -1
- package/src/rules/migration-history.ts +70 -0
- package/src/rules/migrations.ts +248 -9
- package/src/rules/modules.ts +9 -3
- package/src/rules/platform-migrations.ts +100 -0
- package/src/rules/runtime.ts +45 -14
- package/src/rules/structure.ts +38 -18
- package/src/rules/tests.ts +9 -60
- package/src/rules/types.ts +17 -16
- package/src/source-maps.ts +2 -0
- package/src/trust.ts +8 -4
- package/types/src/ast.d.ts +6 -0
- package/types/src/check.d.ts +3 -0
- package/types/src/contract.d.ts +1 -0
- package/types/src/dialect.d.ts +8 -0
- package/types/src/finding.d.ts +6 -5
- package/types/src/index.d.ts +4 -3
- package/types/src/layout.d.ts +25 -10
- package/types/src/limits.d.ts +12 -2
- package/types/src/migration-base.d.ts +9 -0
- package/types/src/reader/schema.d.ts +5 -2
- package/types/src/reader/value.d.ts +2 -2
- package/types/src/rules/cloudflare.d.ts +9 -0
- package/types/src/rules/compile.d.ts +7 -0
- package/types/src/rules/framework.d.ts +1 -1
- package/types/src/rules/migration-history.d.ts +12 -0
- package/types/src/rules/migrations.d.ts +28 -0
- package/types/src/rules/platform-migrations.d.ts +15 -0
- package/types/src/rules/runtime.d.ts +7 -2
- package/types/src/rules/structure.d.ts +11 -4
- package/types/src/rules/tests.d.ts +6 -14
- package/types/src/rules/types.d.ts +2 -0
- package/src/endpoint-fixtures.ts +0 -221
- package/src/rules/crontab.ts +0 -147
- package/src/rules/isolation.ts +0 -79
- package/src/scaffold-sample.ts +0 -111
- package/src/scaffold.ts +0 -650
- package/types/src/endpoint-fixtures.d.ts +0 -36
- package/types/src/rules/crontab.d.ts +0 -15
- package/types/src/rules/isolation.d.ts +0 -18
- package/types/src/scaffold-sample.d.ts +0 -8
- package/types/src/scaffold.d.ts +0 -28
|
@@ -1,36 +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
|
-
type ById = Readonly<Record<string, Readonly<Record<string, Sample>>>>;
|
|
10
|
-
export interface EndpointFixtures {
|
|
11
|
-
/** The input each endpoint's cases send, by endpoint id. */
|
|
12
|
-
readonly inputs: ById;
|
|
13
|
-
/** The columns of the row each endpoint addresses, as both scopes' rows are seeded, by endpoint id. */
|
|
14
|
-
readonly seeds: ById;
|
|
15
|
-
/** The input fields that name a member of the endpoint's member directory, by endpoint id. */
|
|
16
|
-
readonly members: Readonly<Record<string, readonly string[]>>;
|
|
17
|
-
/** The input fields that name an invitation the endpoint cancels, by endpoint id. */
|
|
18
|
-
readonly invitations: Readonly<Record<string, readonly string[]>>;
|
|
19
|
-
/** The input fields that name a share link the endpoint revokes, by endpoint id. */
|
|
20
|
-
readonly links: Readonly<Record<string, readonly string[]>>;
|
|
21
|
-
/** The input fields that name a row lying in the endpoint's object, with that row's table, by endpoint id. */
|
|
22
|
-
readonly rows: Readonly<Record<string, Readonly<Record<string, string>>>>;
|
|
23
|
-
}
|
|
24
|
-
export declare const NO_FIXTURES: EndpointFixtures;
|
|
25
|
-
export declare function isSampleObject(value: Sample): value is {
|
|
26
|
-
readonly [key: string]: Sample;
|
|
27
|
-
};
|
|
28
|
-
/** The fixtures of `files`, by endpoint id; none without the file. */
|
|
29
|
-
export declare function readEndpointFixtures(files: ReadonlyMap<string, string>): {
|
|
30
|
-
readonly ok: true;
|
|
31
|
-
readonly fixtures: EndpointFixtures;
|
|
32
|
-
} | {
|
|
33
|
-
readonly ok: false;
|
|
34
|
-
readonly findings: readonly Finding[];
|
|
35
|
-
};
|
|
36
|
-
export {};
|
|
@@ -1,15 +0,0 @@
|
|
|
1
|
-
import { type ParsedModule } from '../ast';
|
|
2
|
-
import type { Finding } from '../finding';
|
|
3
|
-
import { type ModuleGraph } from '../graph';
|
|
4
|
-
export interface ContractJob {
|
|
5
|
-
readonly name: string;
|
|
6
|
-
/** `undefined` when the contract's schedule is not a static string. */
|
|
7
|
-
readonly schedule: string | undefined;
|
|
8
|
-
}
|
|
9
|
-
/**
|
|
10
|
-
* Every `<name>: c.cron('<schedule>', { … })` in the contract, and every `<name>` there that names a const of the
|
|
11
|
-
* kit's `app.cron('<schedule>', { … })`; the schedule is resolved through literal consts.
|
|
12
|
-
*/
|
|
13
|
-
export declare const contractJobs: (contract: ParsedModule, graph: ModuleGraph) => readonly ContractJob[];
|
|
14
|
-
/** Each setup that runs the application carries exactly the contract's jobs as crontab entries, and nothing else. */
|
|
15
|
-
export declare const checkCrontab: (file: string, text: string, jobs: readonly ContractJob[]) => Finding[];
|
|
@@ -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;
|
package/types/src/scaffold.d.ts
DELETED
|
@@ -1,28 +0,0 @@
|
|
|
1
|
-
import { type ContractArtifact, type TablePolicyArtifact } from '@fabrika/auth-core';
|
|
2
|
-
import { type EndpointFixtures } from './endpoint-fixtures';
|
|
3
|
-
import type { Finding } from './finding';
|
|
4
|
-
export { ENDPOINT_ACCESS_TEST, ENDPOINT_FIXTURES_FILE, POLICY_TEST_SUFFIX, POLICY_TESTS_DIR } from './layout';
|
|
5
|
-
export declare const policyTestPath: (table: string) => string;
|
|
6
|
-
/** One generated test file: its full text, header included, and the name of every test case it registers. */
|
|
7
|
-
export interface GeneratedTest {
|
|
8
|
-
readonly text: string;
|
|
9
|
-
readonly cases: readonly string[];
|
|
10
|
-
}
|
|
11
|
-
type Policies = Readonly<Record<string, TablePolicyArtifact>>;
|
|
12
|
-
/**
|
|
13
|
-
* Every test the scaffold writes for these policies and, when the application has a contract, its artifact; by path.
|
|
14
|
-
* Endpoint access tests exist only for an application on `@fabrika/db`, which has policies to seed rows from.
|
|
15
|
-
*/
|
|
16
|
-
export declare const generatedTests: (policies: Policies, artifact: ContractArtifact | null, fixtures?: EndpointFixtures) => Promise<ReadonlyMap<string, GeneratedTest>>;
|
|
17
|
-
export interface ScaffoldInputs {
|
|
18
|
-
readonly policies: Policies;
|
|
19
|
-
readonly artifact: ContractArtifact | null;
|
|
20
|
-
readonly fixtures: EndpointFixtures;
|
|
21
|
-
}
|
|
22
|
-
/** What the scaffold reads from an application's files; throws `ContractSourceError` or `ContractError` as the reader does. */
|
|
23
|
-
export declare const scaffoldInputs: (files: ReadonlyMap<string, string>) => ScaffoldInputs;
|
|
24
|
-
/**
|
|
25
|
-
* What stops the endpoint access tests from covering every endpoint: one whose input the scaffold cannot sample and
|
|
26
|
-
* the author gave no fixture, and a fixture of no tested endpoint. Each is an `endpoint-fixture` finding.
|
|
27
|
-
*/
|
|
28
|
-
export declare const missingEndpointFixtures: ({ policies, artifact, fixtures }: ScaffoldInputs) => readonly Finding[];
|