@fabrika/check 0.9.0-dev.2 → 0.9.0-dev.20
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 +135 -32
- package/src/cli.ts +23 -4
- package/src/contract.ts +42 -6
- package/src/dialect.ts +29 -0
- package/src/finding.ts +14 -6
- package/src/index.ts +4 -12
- package/src/inputs.ts +4 -2
- package/src/layout.ts +21 -10
- 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 +32 -15
- package/src/rules/tests.ts +9 -60
- 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 +18 -9
- 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 +8 -3
- package/types/src/rules/tests.d.ts +6 -14
- package/src/endpoint-fixtures.ts +0 -221
- 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/isolation.d.ts +0 -18
- package/types/src/scaffold-sample.d.ts +0 -8
- package/types/src/scaffold.d.ts +0 -28
package/src/rules/structure.ts
CHANGED
|
@@ -1,12 +1,13 @@
|
|
|
1
1
|
import { isBuiltin } from 'node:module'
|
|
2
2
|
import { type AstNode, child, identifierName, staticKey } from '../ast'
|
|
3
|
-
import { type Report, STRUCTURE_HINT_RULE_IDS } from '../finding'
|
|
3
|
+
import { type Finding, type Report, STRUCTURE_HINT_RULE_IDS } from '../finding'
|
|
4
4
|
import {
|
|
5
5
|
CONTRACT_FILE,
|
|
6
6
|
DATABASE_DIR,
|
|
7
7
|
isRelativeSpecifier,
|
|
8
8
|
isSourceFile,
|
|
9
9
|
isTestFile,
|
|
10
|
+
isToolModule,
|
|
10
11
|
resolveRelative,
|
|
11
12
|
SCHEMAS_DIR,
|
|
12
13
|
SCHEMAS_FILE,
|
|
@@ -19,10 +20,9 @@ import {
|
|
|
19
20
|
import type { ModuleReference } from '../references'
|
|
20
21
|
import { type ImportMappings, mappedTargets } from '../resolution'
|
|
21
22
|
import { isTestKit } from './modules'
|
|
22
|
-
import { isGeneratedTestPath } from './tests'
|
|
23
23
|
|
|
24
|
-
/** The rules of the application architecture (docs/reference/application-architecture.md):
|
|
25
|
-
export const STRUCTURE_RULE_IDS = ['spa-server-import', 'layer-import', '
|
|
24
|
+
/** The rules of the application architecture (docs/reference/application-architecture.md): three refusals and the hints. */
|
|
25
|
+
export const STRUCTURE_RULE_IDS = ['spa-server-import', 'layer-import', 'shared-import', ...STRUCTURE_HINT_RULE_IDS] as const
|
|
26
26
|
|
|
27
27
|
type SlicePart = 'endpoints' | 'logic' | 'queries'
|
|
28
28
|
|
|
@@ -128,12 +128,13 @@ const runtimeClosure = (graph: StructureGraph, start: Targets, descend: (path: s
|
|
|
128
128
|
const isDataPackage = (specifier: string): boolean => specifier === '@fabrika/db' || specifier.startsWith('@fabrika/db/')
|
|
129
129
|
|
|
130
130
|
/** The framework modules logic and queries may import; the rest of `@fabrika/*` is the framework's own composition. */
|
|
131
|
-
const LAYER_PACKAGES: ReadonlySet<string> = new Set(['@fabrika/app', '@fabrika/db'])
|
|
131
|
+
const LAYER_PACKAGES: ReadonlySet<string> = new Set(['@fabrika/app', '@fabrika/app/schema', '@fabrika/db'])
|
|
132
132
|
|
|
133
133
|
/** The framework modules an SPA loads: the typed client, its React hooks, the component kit and its challenge widget. */
|
|
134
134
|
const SPA_PACKAGES: ReadonlySet<string> = new Set([
|
|
135
135
|
'@fabrika/app/client',
|
|
136
136
|
'@fabrika/app/react',
|
|
137
|
+
'@fabrika/app/schema',
|
|
137
138
|
'@fabrika/ui',
|
|
138
139
|
'@fabrika/ui/challenge',
|
|
139
140
|
'@fabrika/ui/styles.css',
|
|
@@ -141,7 +142,7 @@ const SPA_PACKAGES: ReadonlySet<string> = new Set([
|
|
|
141
142
|
])
|
|
142
143
|
|
|
143
144
|
const SPA_ALLOWED =
|
|
144
|
-
'@fabrika/app/client, @fabrika/app/react, @fabrika/ui, @fabrika/ui/challenge, fabrika.contract.ts, src/schemas.ts, modules under src/shared/ and modules under web/; a type-only import of anything else'
|
|
145
|
+
'@fabrika/app/client, @fabrika/app/react, @fabrika/app/schema, @fabrika/ui, @fabrika/ui/challenge, fabrika.contract.ts, src/schemas.ts, modules under src/shared/ and modules under web/; a type-only import of anything else'
|
|
145
146
|
|
|
146
147
|
const isSchemaModule = (path: string): boolean => path === SCHEMAS_FILE || path.startsWith(SCHEMAS_DIR)
|
|
147
148
|
|
|
@@ -168,18 +169,18 @@ const checkSpaReference = (graph: StructureGraph, reference: ModuleReference, ta
|
|
|
168
169
|
if (server !== undefined) report(reference.node, 'spa-server-import', viaMessage(reference, server, 'server code', 'the SPA'), SPA_ALLOWED)
|
|
169
170
|
}
|
|
170
171
|
|
|
171
|
-
/** The
|
|
172
|
-
const
|
|
172
|
+
/** The packages shared code loads, zod's schemas either way; everything else it needs is in other modules of `src/shared/`. */
|
|
173
|
+
const SHARED_PACKAGES: ReadonlySet<string> = new Set(['zod/v4', '@fabrika/app/schema'])
|
|
173
174
|
|
|
174
175
|
/** A shared module runs in the SPA and in every slice, so it loads nothing either side lacks. */
|
|
175
176
|
const checkSharedReference = (reference: ModuleReference, targets: Targets, report: Report): void => {
|
|
176
|
-
const outside = targets.packages.find((specifier) => specifier
|
|
177
|
+
const outside = targets.packages.find((specifier) => !SHARED_PACKAGES.has(specifier)) ?? targets.files.find((path) => !isSharedModule(path))
|
|
177
178
|
if (outside === undefined) return
|
|
178
179
|
report(
|
|
179
180
|
reference.node,
|
|
180
181
|
'shared-import',
|
|
181
182
|
viaMessage(reference, outside, 'outside src/shared/', 'shared code'),
|
|
182
|
-
'zod/v4 and other modules under src/shared/; a type-only import of anything else',
|
|
183
|
+
'zod/v4, @fabrika/app/schema and other modules under src/shared/; a type-only import of anything else',
|
|
183
184
|
)
|
|
184
185
|
}
|
|
185
186
|
|
|
@@ -221,19 +222,35 @@ const checkSliceReference = (place: StructurePlace, reference: ModuleReference,
|
|
|
221
222
|
)
|
|
222
223
|
}
|
|
223
224
|
|
|
225
|
+
/**
|
|
226
|
+
* A `package.json` under `tools/` makes a tool a package, which a workspace or a `file:` dependency lets the application
|
|
227
|
+
* load by its name, past `tool-import`, which judges the files an import resolves to.
|
|
228
|
+
*/
|
|
229
|
+
export const checkToolPackages = (paths: readonly string[]): Finding[] =>
|
|
230
|
+
paths.filter((path) => isToolModule(path) && path.endsWith('/package.json')).map((path) => ({
|
|
231
|
+
file: path,
|
|
232
|
+
line: 1,
|
|
233
|
+
column: 1,
|
|
234
|
+
severity: 'refusal',
|
|
235
|
+
rule: 'tool-import',
|
|
236
|
+
message: `'${path}' makes a developer's tool a package, which the application could load by its name`,
|
|
237
|
+
allowed: "tools/ without a package.json: a tool's dependencies go in the root package.json",
|
|
238
|
+
}))
|
|
239
|
+
|
|
224
240
|
/** The architecture's rules over one module's imports, re-exports and loads, as Bun resolves them for that module. */
|
|
225
241
|
export const checkStructureReferences = (graph: StructureGraph, place: StructurePlace, report: Report): void => {
|
|
226
242
|
for (const reference of graph.referencesOf(place.file)) {
|
|
227
243
|
const targets = referenceTargets(graph, place.file, reference.specifier)
|
|
228
|
-
if (
|
|
244
|
+
if (reference.typeOnly) continue
|
|
245
|
+
const tool = isToolModule(place.file) ? undefined : targets.files.find(isToolModule)
|
|
246
|
+
if (tool !== undefined) {
|
|
229
247
|
report(
|
|
230
248
|
reference.node,
|
|
231
|
-
'
|
|
232
|
-
`'${reference.specifier}'
|
|
233
|
-
'a
|
|
249
|
+
'tool-import',
|
|
250
|
+
`'${reference.specifier}' loads ${tool}, a developer's tool, which nothing outside tools/ loads`,
|
|
251
|
+
'what the application and a tool share under src/ (pure code in src/shared/), imported by the tool',
|
|
234
252
|
)
|
|
235
253
|
}
|
|
236
|
-
if (reference.typeOnly) continue
|
|
237
254
|
if (place.file.startsWith(SPA_DIR) && !place.exempt) checkSpaReference(graph, reference, targets, report)
|
|
238
255
|
if (isSharedModule(place.file) && !place.exempt) checkSharedReference(reference, targets, report)
|
|
239
256
|
if (isLayerModule(place.file)) checkLayerReference(graph, place, reference, targets, report)
|
package/src/rules/tests.ts
CHANGED
|
@@ -1,6 +1,5 @@
|
|
|
1
|
-
import { type AstNode, child, children,
|
|
1
|
+
import { type AstNode, child, children, identifierName, memberPath, memberSuffix, staticString, walk } from '../ast'
|
|
2
2
|
import type { Finding, Report } from '../finding'
|
|
3
|
-
import { ENDPOINT_ACCESS_TEST, isRelativeSpecifier, joinRelative, POLICY_TEST_SUFFIX, POLICY_TESTS_DIR, resolveRelative } from '../layout'
|
|
4
3
|
import { declaringScope } from '../scope'
|
|
5
4
|
import { isKey, parseToml } from '../toml'
|
|
6
5
|
import { BUNFIG_FILE } from '../trust'
|
|
@@ -33,7 +32,7 @@ const isAssertionCall = (node: AstNode): boolean => {
|
|
|
33
32
|
const path = memberPath(callee)
|
|
34
33
|
const [root] = path ?? []
|
|
35
34
|
const last = path?.[path.length - 1]
|
|
36
|
-
return root !== undefined && root !== 'expect' && (
|
|
35
|
+
return root !== undefined && root !== 'expect' && (root.startsWith('assert') || (last !== undefined && ASSERTION_NAME.test(last)))
|
|
37
36
|
}
|
|
38
37
|
|
|
39
38
|
/** Whether a test body runs an assertion; a nested function counts only where it is called or passed to a call. */
|
|
@@ -107,50 +106,12 @@ export const checkTestNode = (node: AstNode, ancestors: readonly AstNode[], repo
|
|
|
107
106
|
}
|
|
108
107
|
}
|
|
109
108
|
|
|
110
|
-
/** The first line of a test written by `fabrika db test-scaffold`, followed by the SHA-256 of everything after that line. */
|
|
111
|
-
export const GENERATED_TEST_HEADER = '// @generated by fabrika db test-scaffold sha256:'
|
|
112
|
-
const GENERATED_TEST_MARKER = '// @generated by fabrika db test-scaffold'
|
|
113
|
-
|
|
114
|
-
const sha256 = async (text: string): Promise<string> => {
|
|
115
|
-
const digest = await crypto.subtle.digest('SHA-256', new TextEncoder().encode(text))
|
|
116
|
-
return Array.from(new Uint8Array(digest), (byte) => byte.toString(16).padStart(2, '0')).join('')
|
|
117
|
-
}
|
|
118
|
-
|
|
119
|
-
/** The header `fabrika db test-scaffold` puts on a generated test with this body. */
|
|
120
|
-
export const generatedTestHeader = async (body: string): Promise<string> => `${GENERATED_TEST_HEADER}${await sha256(body)}`
|
|
121
|
-
|
|
122
|
-
export const checkGeneratedTest = async (text: string, comments: readonly Comment[], report: Report): Promise<void> => {
|
|
123
|
-
if (!text.startsWith(GENERATED_TEST_MARKER)) {
|
|
124
|
-
const misplaced = comments.find((comment) => comment.text.includes(GENERATED_TEST_MARKER.slice('// '.length)))
|
|
125
|
-
if (misplaced !== undefined) {
|
|
126
|
-
report(
|
|
127
|
-
misplaced.position,
|
|
128
|
-
'generated-test-hash',
|
|
129
|
-
'the generated-test header is not the first line of the file',
|
|
130
|
-
'the file as fabrika db test-scaffold wrote it',
|
|
131
|
-
)
|
|
132
|
-
}
|
|
133
|
-
return
|
|
134
|
-
}
|
|
135
|
-
const newline = text.indexOf('\n')
|
|
136
|
-
const header = newline === -1 ? text : text.slice(0, newline)
|
|
137
|
-
const body = newline === -1 ? '' : text.slice(newline + 1)
|
|
138
|
-
if (header === (await generatedTestHeader(body))) return
|
|
139
|
-
report(
|
|
140
|
-
{ line: 1, column: 1 },
|
|
141
|
-
'generated-test-hash',
|
|
142
|
-
'this generated test differs from what fabrika db test-scaffold wrote',
|
|
143
|
-
'the file as generated; rerun fabrika db test-scaffold after a table change',
|
|
144
|
-
)
|
|
145
|
-
}
|
|
146
|
-
|
|
147
109
|
/** `[test]` keys that pick other test files, skip some, or let a failing test pass on a later attempt. */
|
|
148
110
|
const SUITE_NARROWING_TEST_KEYS = ['root', 'pathIgnorePatterns', 'retry'] as const
|
|
149
111
|
|
|
150
112
|
/**
|
|
151
|
-
* The `bunfig.toml` of an application must not narrow its own suite
|
|
152
|
-
*
|
|
153
|
-
* subset is reported by the trust rules.
|
|
113
|
+
* The `bunfig.toml` of an application must not narrow its own suite, which the platform build runs. A file outside the
|
|
114
|
+
* TOML subset is reported by the trust rules.
|
|
154
115
|
*/
|
|
155
116
|
export const checkTestSuiteConfig = (text: string): Finding[] => {
|
|
156
117
|
const document = parseToml(text)
|
|
@@ -174,35 +135,23 @@ export const checkTestSuiteConfig = (text: string): Finding[] => {
|
|
|
174
135
|
return findings
|
|
175
136
|
}
|
|
176
137
|
|
|
177
|
-
/** Whether `path` is a file the scaffold generates: a policy isolation test, the endpoint access test, or one with the header. */
|
|
178
|
-
export const isGeneratedTestPath = (path: string, files: ReadonlyMap<string, string>): boolean =>
|
|
179
|
-
path === ENDPOINT_ACCESS_TEST || (path.startsWith(POLICY_TESTS_DIR) && path.endsWith(POLICY_TEST_SUFFIX))
|
|
180
|
-
|| (files.get(path)?.startsWith(GENERATED_TEST_MARKER) ?? false)
|
|
181
|
-
|
|
182
138
|
/**
|
|
183
|
-
* `mock.module(…)` of the test runner
|
|
184
|
-
*
|
|
139
|
+
* `mock.module(…)` of the test runner or a framework package would let application code replace what the test kit runs
|
|
140
|
+
* on; a computed specifier could name either. Refused anywhere in the application.
|
|
185
141
|
*/
|
|
186
|
-
export const checkMockModule = (node: AstNode,
|
|
142
|
+
export const checkMockModule = (node: AstNode, report: Report): void => {
|
|
187
143
|
if (node.type !== 'CallExpression') return
|
|
188
144
|
const callee = child(node, 'callee')
|
|
189
145
|
if (callee === undefined || callee.type !== 'MemberExpression') return
|
|
190
146
|
const suffix = memberPath(callee) ?? memberSuffix(callee)
|
|
191
147
|
if (suffix.length < 2 || suffix[suffix.length - 1] !== 'module' || suffix[suffix.length - 2] !== 'mock') return
|
|
192
|
-
const allowed = 'mock.module of an application module
|
|
148
|
+
const allowed = 'mock.module of an application module, with a literal specifier'
|
|
193
149
|
const specifier = staticString(children(node, 'arguments')[0] ?? undefined)
|
|
194
150
|
if (specifier === undefined) {
|
|
195
151
|
report(node, 'mock-module', 'mock.module with a computed specifier could replace the test runner or the framework', allowed)
|
|
196
152
|
return
|
|
197
153
|
}
|
|
198
154
|
if (specifier === 'bun:test' || specifier.startsWith('@fabrika/')) {
|
|
199
|
-
report(node, 'mock-module', `mock.module('${specifier}') replaces what the
|
|
200
|
-
return
|
|
201
|
-
}
|
|
202
|
-
if (!isRelativeSpecifier(specifier)) return
|
|
203
|
-
const resolved = resolveRelative((path) => files.has(path), file, specifier)
|
|
204
|
-
const targets = resolved.kind === 'file' ? [resolved.path] : resolved.kind === 'missing' ? [joinRelative(file, specifier) ?? ''] : resolved.paths
|
|
205
|
-
if (targets.some((target) => isGeneratedTestPath(target, files))) {
|
|
206
|
-
report(node, 'mock-module', `mock.module('${specifier}') replaces a generated test`, allowed)
|
|
155
|
+
report(node, 'mock-module', `mock.module('${specifier}') replaces what the test kit runs on`, allowed)
|
|
207
156
|
}
|
|
208
157
|
}
|
package/src/trust.ts
CHANGED
|
@@ -4,7 +4,7 @@
|
|
|
4
4
|
|
|
5
5
|
import type { Finding } from './finding'
|
|
6
6
|
import { parseJsonc } from './jsonc'
|
|
7
|
-
import { isIgnoredSegment, isRelativeSpecifier, isSourceFile, joinRelative } from './layout'
|
|
7
|
+
import { isIgnoredSegment, isRelativeSpecifier, isSourceFile, isToolModule, joinRelative } from './layout'
|
|
8
8
|
import { isKey, parseToml } from './toml'
|
|
9
9
|
|
|
10
10
|
/** Packages whose exports the reader trusts by name, and the packages they rely on. */
|
|
@@ -141,11 +141,15 @@ function checkTsconfig(path: string, text: string, files: ReadonlyMap<string, st
|
|
|
141
141
|
}
|
|
142
142
|
}
|
|
143
143
|
|
|
144
|
-
/**
|
|
144
|
+
/**
|
|
145
|
+
* A test preload must be a checked application file: a skipped or generated one runs unchecked during the build, and a
|
|
146
|
+
* developer's tool is not checked as application code.
|
|
147
|
+
*/
|
|
145
148
|
const isCheckedTestPreload = (target: string): boolean => {
|
|
146
149
|
if (!target.startsWith('./')) return false
|
|
147
150
|
const segments = target.slice(2).split('/')
|
|
148
|
-
return segments[0] !== 'fabrika' &&
|
|
151
|
+
return segments[0] !== 'fabrika' && !isToolModule(target.slice(2))
|
|
152
|
+
&& segments.every((segment) => segment !== '' && segment !== '..' && !isIgnoredSegment(segment))
|
|
149
153
|
&& isSourceFile(target)
|
|
150
154
|
}
|
|
151
155
|
|
|
@@ -180,7 +184,7 @@ function checkBunfig(text: string, report: (needle: string, message: string, all
|
|
|
180
184
|
report(
|
|
181
185
|
at(entry.line),
|
|
182
186
|
'a test preload outside the checked application files runs unchecked in the platform build',
|
|
183
|
-
"'./<path>' of a source file the checker reads, outside fabrika/, dist/, node_modules/ and dot directories",
|
|
187
|
+
"'./<path>' of a source file the checker reads, outside fabrika/, tools/, dist/, node_modules/ and dot directories",
|
|
184
188
|
)
|
|
185
189
|
}
|
|
186
190
|
}
|
package/types/src/ast.d.ts
CHANGED
|
@@ -54,12 +54,18 @@ export declare const unwrap: (node: AstNode) => AstNode;
|
|
|
54
54
|
export declare const memberPath: (node: AstNode) => readonly string[] | undefined;
|
|
55
55
|
/** Whether an `Identifier` denotes a runtime value here, rather than a property name, a key, a label or a type. */
|
|
56
56
|
export declare const isValueReference: (node: AstNode, parent: AstNode | undefined) => boolean;
|
|
57
|
+
/**
|
|
58
|
+
* A node's line and column (from 1), as the parser counts them, for a tree `parseModule` returns: its `loc` is the
|
|
59
|
+
* start of its line (`lineLocations`). A tree parsed any other way has no such `loc` and reads as 1:1.
|
|
60
|
+
*/
|
|
57
61
|
export declare const positionOf: (node: AstNode) => Position;
|
|
58
62
|
/** Visits every node below `root`, depth first, with the chain of its ancestors (nearest last); `'skip'` prunes a subtree. */
|
|
59
63
|
export declare const walk: (root: AstNode, visit: (node: AstNode, ancestors: readonly AstNode[]) => "skip" | undefined | void) => void;
|
|
60
64
|
export declare const utf8Bytes: (text: string) => number;
|
|
61
65
|
/** The nesting depth of the tree below `root`, measured without recursion, so a deep tree cannot exhaust the stack. */
|
|
62
66
|
export declare const nodeDepth: (root: AstNode) => number;
|
|
67
|
+
/** The number of syntax nodes in the tree below `root`, `root` included, counted without recursion. */
|
|
68
|
+
export declare const nodeCount: (root: AstNode) => number;
|
|
63
69
|
export declare const parseModule: (file: string, text: string) => ParseResult;
|
|
64
70
|
/** The sources of a module's import and re-export declarations; `rules/literal.ts` decides which of them are allowed. */
|
|
65
71
|
export declare const importedSpecifiers: (module: ParsedModule) => string[];
|
package/types/src/check.d.ts
CHANGED
|
@@ -1,5 +1,6 @@
|
|
|
1
1
|
import { type Finding } from './finding';
|
|
2
2
|
import type { PackedSet } from './packed';
|
|
3
|
+
import { type MigrationBase } from './rules/migration-history';
|
|
3
4
|
export interface CheckInput {
|
|
4
5
|
/** The application's root directory. */
|
|
5
6
|
readonly root: string;
|
|
@@ -7,6 +8,8 @@ export interface CheckInput {
|
|
|
7
8
|
readonly files?: ReadonlyMap<string, string>;
|
|
8
9
|
/** A local pack whose tarballs `package-replacement` accepts (`fabrika-check --packed`); a deploy build gives none. */
|
|
9
10
|
readonly packed?: PackedSet;
|
|
11
|
+
/** The migrations of a shared branch the tree must still hold unchanged (`fabrika-check`, from git); a deploy build gives none. */
|
|
12
|
+
readonly migrationBase?: MigrationBase;
|
|
10
13
|
}
|
|
11
14
|
export interface ApplicationTree {
|
|
12
15
|
readonly files: ReadonlyMap<string, string>;
|
package/types/src/contract.d.ts
CHANGED
|
@@ -5,6 +5,7 @@ import { type ParsedModule } from './ast';
|
|
|
5
5
|
import { type Finding } from './finding';
|
|
6
6
|
import { ModuleGraph } from './graph';
|
|
7
7
|
export { ContractError } from '@fabrika/app/contract';
|
|
8
|
+
export { accessTables } from '@fabrika/db/tables';
|
|
8
9
|
export { type Finding, formatFinding } from './finding';
|
|
9
10
|
export { contractReaderInputs } from './inputs';
|
|
10
11
|
export { CONTRACT_FILE, MIGRATIONS_DIR, TABLES_FILE } from './layout';
|
|
@@ -0,0 +1,8 @@
|
|
|
1
|
+
/** The database an application's data layer runs on: SQLite in its Durable Object on Cloudflare (ADR-0065), else Postgres. */
|
|
2
|
+
export type ApplicationDialect = 'postgres' | 'sqlite';
|
|
3
|
+
/**
|
|
4
|
+
* Read statically from `fabrika.config.ts`: SQLite when its default export is a call of the `defineApp` that
|
|
5
|
+
* `@fabrika/provider-cloudflare` exports, the config every Cloudflare application writes. Postgres otherwise,
|
|
6
|
+
* including without a config or when the call's origin is not static.
|
|
7
|
+
*/
|
|
8
|
+
export declare const applicationDialect: (files: ReadonlyMap<string, string>) => ApplicationDialect;
|
package/types/src/finding.d.ts
CHANGED
|
@@ -1,14 +1,15 @@
|
|
|
1
1
|
import type { AstNode, Position } from './ast';
|
|
2
2
|
/** Rules whose finding fails the check: the framework's forms and platform integrity. */
|
|
3
|
-
export declare const REFUSAL_RULE_IDS: readonly ["parse-error", "literal", "contract", "forbidden-import", "test-only-import", "unchecked-import", "forbidden-global", "raw-sql", "type-assertion", "any-type", "suppression-comment", "capability-widening", "prototype-assignment", "framework-write", "env-read", "public-env", "cross-app-fetch", "url-endpoint", "on-conflict-index", "key-literal", "client-identity", "sensitive-log", "unsafe-html", "dynamic-code", "migration-name", "file-column-migration", "crontab", "package-replacement", "skipped-test", "test-without-assertion", "
|
|
3
|
+
export declare const REFUSAL_RULE_IDS: readonly ["parse-error", "literal", "contract", "forbidden-import", "test-only-import", "unchecked-import", "forbidden-global", "raw-sql", "type-assertion", "any-type", "suppression-comment", "capability-widening", "prototype-assignment", "framework-write", "env-read", "public-env", "cross-app-fetch", "url-endpoint", "on-conflict-index", "access-view-key", "key-literal", "client-identity", "sensitive-log", "unsafe-html", "dynamic-code", "migration-name", "migration-refused", "backup-schema", "migration-edited", "file-column-migration", "crontab", "package-replacement", "skipped-test", "test-without-assertion", "mock-module", "spa-server-import", "layer-import", "shared-import", "tool-import", "cloudflare-scan", "cloudflare-job-segment", "cloudflare-current-timestamp", "cloudflare-framework-name", "cloudflare-view-trigger"];
|
|
4
4
|
/** Rules that report a step out of the application architecture. */
|
|
5
5
|
export declare const STRUCTURE_HINT_RULE_IDS: readonly ["logic-data-access", "cross-slice-queries", "handler-location", "data-access-location"];
|
|
6
6
|
/**
|
|
7
|
-
* Rules whose findings never fail the check: the architecture's, a `ctx.sql` its site does not declare,
|
|
8
|
-
* `{ member: true }` endpoint of a contract whose external role admits people from outside the organization
|
|
7
|
+
* Rules whose findings never fail the check: the architecture's, a `ctx.sql` its site does not declare, a
|
|
8
|
+
* `{ member: true }` endpoint of a contract whose external role admits people from outside the organization, and a
|
|
9
|
+
* Cloudflare mutation that waits for an outside call inside the object's transaction.
|
|
9
10
|
*/
|
|
10
|
-
export declare const HINT_RULE_IDS: readonly ["logic-data-access", "cross-slice-queries", "handler-location", "data-access-location", "sql-undeclared", "member-admits-external"];
|
|
11
|
-
export declare const RULE_IDS: readonly ["parse-error", "literal", "contract", "forbidden-import", "test-only-import", "unchecked-import", "forbidden-global", "raw-sql", "type-assertion", "any-type", "suppression-comment", "capability-widening", "prototype-assignment", "framework-write", "env-read", "public-env", "cross-app-fetch", "url-endpoint", "on-conflict-index", "key-literal", "client-identity", "sensitive-log", "unsafe-html", "dynamic-code", "migration-name", "file-column-migration", "crontab", "package-replacement", "skipped-test", "test-without-assertion", "
|
|
11
|
+
export declare const HINT_RULE_IDS: readonly ["logic-data-access", "cross-slice-queries", "handler-location", "data-access-location", "sql-undeclared", "member-admits-external", "cloudflare-held-call"];
|
|
12
|
+
export declare const RULE_IDS: readonly ["parse-error", "literal", "contract", "forbidden-import", "test-only-import", "unchecked-import", "forbidden-global", "raw-sql", "type-assertion", "any-type", "suppression-comment", "capability-widening", "prototype-assignment", "framework-write", "env-read", "public-env", "cross-app-fetch", "url-endpoint", "on-conflict-index", "access-view-key", "key-literal", "client-identity", "sensitive-log", "unsafe-html", "dynamic-code", "migration-name", "migration-refused", "backup-schema", "migration-edited", "file-column-migration", "crontab", "package-replacement", "skipped-test", "test-without-assertion", "mock-module", "spa-server-import", "layer-import", "shared-import", "tool-import", "cloudflare-scan", "cloudflare-job-segment", "cloudflare-current-timestamp", "cloudflare-framework-name", "cloudflare-view-trigger", "logic-data-access", "cross-slice-queries", "handler-location", "data-access-location", "sql-undeclared", "member-admits-external", "cloudflare-held-call"];
|
|
12
13
|
export type RefusalRuleId = (typeof REFUSAL_RULE_IDS)[number];
|
|
13
14
|
export type HintRuleId = (typeof HINT_RULE_IDS)[number];
|
|
14
15
|
export type RuleId = (typeof RULE_IDS)[number];
|
package/types/src/index.d.ts
CHANGED
|
@@ -1,6 +1,7 @@
|
|
|
1
1
|
export { type ApplicationTree, checkApplication, type CheckInput, readApplicationTree } from './check';
|
|
2
|
+
export { type ApplicationDialect, applicationDialect } from './dialect';
|
|
2
3
|
export { type Finding, formatFinding, RULE_IDS, type RuleId } from './finding';
|
|
3
|
-
export { CONTRACT_FILE, GENERATED_ENTRY_FILE, MIGRATIONS_DIR, TABLES_FILE, ZEROPS_FILES } from './layout';
|
|
4
|
+
export { CONFIG_FILE, CONTRACT_FILE, GENERATED_ENTRY_FILE, MIGRATIONS_DIR, TABLES_FILE, ZEROPS_FILES } from './layout';
|
|
5
|
+
export { readMigrationBase } from './migration-base';
|
|
4
6
|
export { type PackedSet, type PackedTarball, readPackedSet } from './packed';
|
|
5
|
-
export {
|
|
6
|
-
export { ENDPOINT_ACCESS_TEST, ENDPOINT_FIXTURES_FILE, type GeneratedTest, generatedTests, missingEndpointFixtures, POLICY_TESTS_DIR, policyTestPath, scaffoldInputs, } from './scaffold';
|
|
7
|
+
export type { MigrationBase } from './rules/migration-history';
|
package/types/src/layout.d.ts
CHANGED
|
@@ -1,19 +1,16 @@
|
|
|
1
1
|
/** Where an application keeps what the checker reads. Paths are relative to the application root. */
|
|
2
2
|
export declare const CONTRACT_FILE = "fabrika.contract.ts";
|
|
3
|
+
/** The provider-authored application config, whose `defineApp` names the provider. */
|
|
4
|
+
export declare const CONFIG_FILE = "fabrika.config.ts";
|
|
3
5
|
/** The named export of the contract module that holds `defineContract(…)`. */
|
|
4
6
|
export declare const CONTRACT_EXPORT = "contract";
|
|
5
7
|
export declare const TABLES_FILE = "src/db/tables.ts";
|
|
6
8
|
/** The named export of the tables module that holds `defineTables(…)(…)`. */
|
|
7
9
|
export declare const TABLES_EXPORT = "tables";
|
|
8
10
|
export declare const GENERATED_ENTRY_FILE = "fabrika/entry.generated.ts";
|
|
11
|
+
/** Where a Cloudflare deploy stages the SPA mounts' built files (`@fabrika/provider-cloudflare`): build output, never source. */
|
|
12
|
+
export declare const STAGED_ASSETS_DIR = "fabrika/assets/";
|
|
9
13
|
export declare const MIGRATIONS_DIR = "db/migrations/";
|
|
10
|
-
/** Where `fabrika db test-scaffold` writes the policy isolation tests, `<table>.policy-isolation.test.ts`. */
|
|
11
|
-
export declare const POLICY_TESTS_DIR = "src/db/__tests__/";
|
|
12
|
-
export declare const POLICY_TEST_SUFFIX = ".policy-isolation.test.ts";
|
|
13
|
-
/** The generated endpoint access tests; they import `src/app.ts`, whose default export they boot. */
|
|
14
|
-
export declare const ENDPOINT_ACCESS_TEST = "src/__tests__/endpoint-access.test.ts";
|
|
15
|
-
/** The inputs the author gives the endpoint access tests where the scaffold cannot sample one; read, never run. */
|
|
16
|
-
export declare const ENDPOINT_FIXTURES_FILE = "src/__tests__/endpoint-access.fixtures.ts";
|
|
17
14
|
export declare const ZEROPS_FILES: readonly ["zerops.yaml", "zerops.yml"];
|
|
18
15
|
/** The application architecture (docs/reference/application-architecture.md): where each layer's code lives. */
|
|
19
16
|
export declare const VOCABULARY_FILE = "src/vocabulary.ts";
|
|
@@ -21,9 +18,12 @@ export declare const APP_KIT_FILE = "src/app-kit.ts";
|
|
|
21
18
|
/** The shared zod schemas the shell and the SPA import: one module, or a directory of them once it grows. */
|
|
22
19
|
export declare const SCHEMAS_FILE = "src/schemas.ts";
|
|
23
20
|
export declare const SCHEMAS_DIR = "src/schemas/";
|
|
24
|
-
/**
|
|
21
|
+
/**
|
|
22
|
+
* Pure code the SPA and every slice may import: it loads nothing but `zod/v4`, `@fabrika/app/schema` and other modules of
|
|
23
|
+
* its own directory.
|
|
24
|
+
*/
|
|
25
25
|
export declare const SHARED_DIR = "src/shared/";
|
|
26
|
-
/** `src/db/`: the tables
|
|
26
|
+
/** `src/db/`: the tables and the generated schema; never a slice. */
|
|
27
27
|
export declare const DATABASE_DIR = "src/db/";
|
|
28
28
|
/** A slice is a directory `src/<slice>/` that holds these modules, each optional. */
|
|
29
29
|
export declare const SLICE_ENDPOINTS_FILE = "endpoints.ts";
|
|
@@ -32,12 +32,21 @@ export declare const SLICE_QUERIES_FILE = "queries.ts";
|
|
|
32
32
|
export declare const SPA_DIR = "web/";
|
|
33
33
|
/** The server half of an application: its modules run in the application's process. */
|
|
34
34
|
export declare const SERVER_DIR = "src/";
|
|
35
|
+
/**
|
|
36
|
+
* A developer's tools, such as a command line over the contract: code that runs on a developer's machine and never in
|
|
37
|
+
* the application, so the rules for code that runs there do not apply, and no module outside it may load one.
|
|
38
|
+
*/
|
|
39
|
+
export declare const TOOLS_DIR = "tools/";
|
|
35
40
|
/** Build output, installed packages and tool state are not application source and are never read. */
|
|
36
41
|
export declare const isIgnoredSegment: (segment: string) => boolean;
|
|
42
|
+
/** Whether the checker skips `path` (relative to the root): under a skipped segment, or the staged SPA files. */
|
|
43
|
+
export declare const isSkippedPath: (path: string) => boolean;
|
|
37
44
|
export declare const isSourceFile: (path: string) => boolean;
|
|
38
45
|
export declare const isTestFile: (path: string) => boolean;
|
|
39
46
|
/** A module that runs in the application's server process: under `src/`, not a test. */
|
|
40
47
|
export declare const isServerModule: (path: string) => boolean;
|
|
48
|
+
/** A module under `tools/`, tests included. */
|
|
49
|
+
export declare const isToolModule: (path: string) => boolean;
|
|
41
50
|
export declare const isJsonFile: (path: string) => boolean;
|
|
42
51
|
/** Whether the checker reads this file at all. */
|
|
43
52
|
export declare const isCheckedFile: (path: string) => boolean;
|
package/types/src/limits.d.ts
CHANGED
|
@@ -4,12 +4,22 @@
|
|
|
4
4
|
* step runs.
|
|
5
5
|
*/
|
|
6
6
|
export declare const CONTRACT_LIMITS: {
|
|
7
|
-
/**
|
|
7
|
+
/**
|
|
8
|
+
* UTF-8 bytes of `fabrika.contract.ts` and every module it imports, together. Control reads them in a Cloudflare
|
|
9
|
+
* Worker, whose isolate has 128 MB; handler bodies are sliced out before the parse, so they cost bytes, not nodes.
|
|
10
|
+
*/
|
|
8
11
|
readonly sourceBytes: number;
|
|
12
|
+
/** UTF-8 bytes of one module: its own parse is the peak while it is read, and a dense one needs up to 340 times it. */
|
|
13
|
+
readonly moduleBytes: number;
|
|
14
|
+
/**
|
|
15
|
+
* Syntax nodes the reader holds over each graph (the contract's, the tables'), top-level type declarations left out.
|
|
16
|
+
* At this, `sourceBytes` and `schemaNodes` together, Control's read needs a 95 MB heap of its 128 MB isolate.
|
|
17
|
+
*/
|
|
18
|
+
readonly astNodes: 400000;
|
|
9
19
|
/** Nesting of syntax nodes in one module; the contracts in this repository reach 25. */
|
|
10
20
|
readonly astDepth: 128;
|
|
11
21
|
/** Schema nodes once every shared schema is expanded where the contract uses it, over the whole contract. */
|
|
12
|
-
readonly schemaNodes:
|
|
22
|
+
readonly schemaNodes: 60000;
|
|
13
23
|
/** Nesting of one schema: objects, arrays, unions and wrappers. */
|
|
14
24
|
readonly schemaDepth: 32;
|
|
15
25
|
};
|
|
@@ -0,0 +1,9 @@
|
|
|
1
|
+
import type { MigrationBase } from './rules/migration-history';
|
|
2
|
+
/**
|
|
3
|
+
* The migrations at the merge base of HEAD and `ref` (the remote's default branch when omitted), compared against
|
|
4
|
+
* the merge base so that migrations the default branch added since the branch forked are not read as deleted.
|
|
5
|
+
* `null` when `root` is in no git work tree; `{ skipped }` when it is but the base cannot be read.
|
|
6
|
+
*/
|
|
7
|
+
export declare const readMigrationBase: (root: string, ref?: string) => Promise<MigrationBase | {
|
|
8
|
+
readonly skipped: string;
|
|
9
|
+
} | null>;
|
|
@@ -1,15 +1,18 @@
|
|
|
1
|
+
import { DataSchema } from '@fabrika/app/schema';
|
|
1
2
|
import { z } from 'zod/v4';
|
|
2
3
|
import type { LiteralValue } from './value';
|
|
4
|
+
/** A schema the reader holds: one it read from a chain, or a framework schema (`signedToken()`, `file()`). */
|
|
5
|
+
export type ReadSchema = DataSchema | z.ZodType;
|
|
3
6
|
export type SchemaStep = {
|
|
4
7
|
readonly factory: string;
|
|
5
8
|
readonly iso: boolean;
|
|
6
9
|
} | {
|
|
7
10
|
readonly method: string;
|
|
8
|
-
readonly receiver:
|
|
11
|
+
readonly receiver: ReadSchema | undefined;
|
|
9
12
|
};
|
|
10
13
|
export type BuiltSchema = {
|
|
11
14
|
readonly ok: true;
|
|
12
|
-
readonly schema:
|
|
15
|
+
readonly schema: DataSchema;
|
|
13
16
|
} | {
|
|
14
17
|
readonly ok: false;
|
|
15
18
|
readonly message: string;
|
|
@@ -1,7 +1,7 @@
|
|
|
1
|
-
import type { z } from 'zod/v4';
|
|
2
1
|
import { type AstNode, type ParsedModule } from '../ast';
|
|
3
2
|
import type { Located, ModuleGraph } from '../graph';
|
|
4
3
|
import type { ReaderProblems } from './problems';
|
|
4
|
+
import { type ReadSchema } from './schema';
|
|
5
5
|
/**
|
|
6
6
|
* The builder kit a call belongs to: `c` of `defineContract` and `l` of its link's `procedures`; `app`, the kit
|
|
7
7
|
* `defineApp` returned; `c` of `app.contract` (`shell`) and `r` of a group, a link or an export (`endpoints`).
|
|
@@ -42,7 +42,7 @@ export type LiteralValue = {
|
|
|
42
42
|
/** `nodes` counts the schema with every shared part expanded, as the artifact will hold it; `depth` its nesting. */
|
|
43
43
|
| {
|
|
44
44
|
readonly kind: 'schema';
|
|
45
|
-
readonly schema:
|
|
45
|
+
readonly schema: ReadSchema;
|
|
46
46
|
readonly nodes: number;
|
|
47
47
|
readonly depth: number;
|
|
48
48
|
/** The chain that built it, factory first (`iso` for `z.iso.*`), across a const and the methods applied to it. */
|
|
@@ -0,0 +1,9 @@
|
|
|
1
|
+
import { type ContractArtifact } from '@fabrika/auth-core';
|
|
2
|
+
import type { Finding } from '../finding';
|
|
3
|
+
/**
|
|
4
|
+
* What an application on Cloudflare cannot declare (ADR-0065): a file kind that scans, because no scanner runs there; a
|
|
5
|
+
* job longer than one segment, because the object runs it inside an alarm or a request. And a hint for a mutation that
|
|
6
|
+
* declares an outside call: the object runs one transaction at a time, and the mutation holds it while the call waits
|
|
7
|
+
* (backlog 216 item 7).
|
|
8
|
+
*/
|
|
9
|
+
export declare const checkCloudflareContract: (artifact: ContractArtifact) => Finding[];
|
|
@@ -0,0 +1,7 @@
|
|
|
1
|
+
import type { Finding } from '../finding';
|
|
2
|
+
/**
|
|
3
|
+
* What the reader refuses of `src/db/tables.ts`, and a contract that does not compile against its policies: Control
|
|
4
|
+
* reads the commit with the same calls and refuses the deploy. `readable` is false while the literal, trust or
|
|
5
|
+
* contract rules report the sources, so a refusal is not reported twice.
|
|
6
|
+
*/
|
|
7
|
+
export declare const checkContractCompiles: (files: ReadonlyMap<string, string>, readable: boolean) => Finding[];
|
|
@@ -12,7 +12,7 @@ export type TrustedBindings = ReadonlyMap<string, readonly TrustedBinding[]>;
|
|
|
12
12
|
export declare const trustedBindings: (file: string, program: AstNode, mappings: ImportMappings) => TrustedBindings;
|
|
13
13
|
/**
|
|
14
14
|
* A write to a member of a value from `@fabrika/*` or `zod`: an assignment, `delete`, `++`, or a writer call on it. A
|
|
15
|
-
* replaced `
|
|
15
|
+
* replaced `openPostgres` receives the database URL; a patched schema changes what the contract admits. A write
|
|
16
16
|
* through a prototype is `prototype-assignment`'s. A local that shadows such a name is not one.
|
|
17
17
|
*/
|
|
18
18
|
export declare const checkFrameworkWrite: (node: AstNode, ancestors: readonly AstNode[], bindings: TrustedBindings, report: Report) => void;
|
|
@@ -0,0 +1,12 @@
|
|
|
1
|
+
import type { Finding } from '../finding';
|
|
2
|
+
/** The migrations of `db/migrations` at the commit the tree is compared with, by path relative to the root. */
|
|
3
|
+
export interface MigrationBase {
|
|
4
|
+
/** How the commit is named to the author, such as `origin/main`. */
|
|
5
|
+
readonly ref: string;
|
|
6
|
+
readonly files: ReadonlyMap<string, string>;
|
|
7
|
+
}
|
|
8
|
+
/**
|
|
9
|
+
* Each migration of `base` that the tree changed (at its first changed line) or no longer holds. A file renamed is one
|
|
10
|
+
* removed and one new, and the new one would run again where the old one ran, so the removal is what is reported.
|
|
11
|
+
*/
|
|
12
|
+
export declare const checkMigrationHistory: (files: ReadonlyMap<string, string>, base: MigrationBase) => Finding[];
|
|
@@ -1,6 +1,22 @@
|
|
|
1
1
|
import type { Finding } from '../finding';
|
|
2
2
|
/** Migration file names sort by creation time, so parallel worktrees never claim the same name. */
|
|
3
3
|
export declare const checkMigrationNames: (paths: readonly string[]) => Finding[];
|
|
4
|
+
/**
|
|
5
|
+
* On SQLite `DEFAULT CURRENT_TIMESTAMP` stores `YYYY-MM-DD HH:MM:SS`, which every read of the table refuses as
|
|
6
|
+
* `unexpected_row` (backlog 216 item 13). Refused with or without parentheses, at the line of `CURRENT_TIMESTAMP`.
|
|
7
|
+
*/
|
|
8
|
+
export declare const checkCurrentTimestampDefaults: (files: ReadonlyMap<string, string>) => Finding[];
|
|
9
|
+
/**
|
|
10
|
+
* On SQLite an application migration runs verbatim, with no name rule, so a view or a trigger over a framework table
|
|
11
|
+
* would reach what `ctx.sql`'s name rule keeps it from. Every `fabrika_*` name is refused (any case, quoted, bracketed,
|
|
12
|
+
* or as a string SQLite may read as a name) but `fabrika_files` right after `REFERENCES`, a file column's foreign key.
|
|
13
|
+
*/
|
|
14
|
+
export declare const checkSqliteFrameworkNames: (files: ReadonlyMap<string, string>) => Finding[];
|
|
15
|
+
/**
|
|
16
|
+
* A view is read-only (ADR-0072); on SQLite an INSTEAD OF trigger would make a view writable, so it is refused. SQLite
|
|
17
|
+
* takes INSTEAD OF only on a view, so the timing alone, written before the trigger's `ON`, names one.
|
|
18
|
+
*/
|
|
19
|
+
export declare const checkSqliteViewTriggers: (files: ReadonlyMap<string, string>) => Finding[];
|
|
4
20
|
/** A declared file column: `table.column` holds files of `kind`. */
|
|
5
21
|
export interface FileColumn {
|
|
6
22
|
readonly table: string;
|
|
@@ -27,3 +43,15 @@ export interface ConflictInsert {
|
|
|
27
43
|
* checked: another receiver of `insert` is no table of the data layer.
|
|
28
44
|
*/
|
|
29
45
|
export declare const checkConflictIndexes: (files: ReadonlyMap<string, string>, tables: ReadonlySet<string>, inserts: readonly ConflictInsert[]) => Finding[];
|
|
46
|
+
/** A table that names an access view under `key` (ADR-0076). */
|
|
47
|
+
export interface AccessKey {
|
|
48
|
+
readonly table: string;
|
|
49
|
+
readonly key: string;
|
|
50
|
+
readonly views: readonly string[];
|
|
51
|
+
}
|
|
52
|
+
/**
|
|
53
|
+
* A table that names an access view needs its key unique on its own, or the view's `row` names several rows at once
|
|
54
|
+
* (ADR-0076 section 1). A view as the target keeps its key unique by its SQL; any other name no migration creates as a
|
|
55
|
+
* table is refused, so a statement the reader does not follow fails closed.
|
|
56
|
+
*/
|
|
57
|
+
export declare const checkAccessViewKeys: (files: ReadonlyMap<string, string>, keys: readonly AccessKey[]) => Finding[];
|
|
@@ -0,0 +1,15 @@
|
|
|
1
|
+
import { type MigrationDialect } from '@fabrika/platform-node/sql';
|
|
2
|
+
import type { Finding } from '../finding';
|
|
3
|
+
/**
|
|
4
|
+
* Every statement Control's classifier refuses, at its file and line, against the application's access tables and in its
|
|
5
|
+
* dialect. Control refuses a deploy whose new migration holds
|
|
6
|
+
* one (`migrations-refused`), and its run log names neither, so this is where the author finds it. Every file is
|
|
7
|
+
* checked, applied or not: the checker does not know which an environment holds.
|
|
8
|
+
*/
|
|
9
|
+
export declare const checkMigrationClassification: (files: ReadonlyMap<string, string>, appId: string, accessTables: readonly string[], dialect: MigrationDialect) => Finding[];
|
|
10
|
+
/**
|
|
11
|
+
* On Cloudflare, the backup's refusal of the migrated schema (`planOpsDump`), at the newest migration that names the
|
|
12
|
+
* table. Every migration deploy backs the environment up first, so a schema the backup refuses blocks every migration
|
|
13
|
+
* after the one that made it. A migration set that does not apply is codegen's to report, so it finds nothing here.
|
|
14
|
+
*/
|
|
15
|
+
export declare const checkBackupPlan: (files: ReadonlyMap<string, string>) => Promise<Finding[]>;
|