@fabrika/check 0.9.0-dev.30 → 0.9.0-dev.31
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 +6 -6
- package/src/ast.ts +0 -12
- package/src/contract.ts +2 -1
- package/src/inputs.ts +2 -1
- package/src/references.ts +16 -1
- package/types/src/ast.d.ts +0 -2
- package/types/src/references.d.ts +6 -1
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@fabrika/check",
|
|
3
|
-
"version": "0.9.0-dev.
|
|
3
|
+
"version": "0.9.0-dev.31",
|
|
4
4
|
"type": "module",
|
|
5
5
|
"repository": {
|
|
6
6
|
"type": "git",
|
|
@@ -52,11 +52,11 @@
|
|
|
52
52
|
},
|
|
53
53
|
"dependencies": {
|
|
54
54
|
"@babel/parser": "8.0.7",
|
|
55
|
-
"@fabrika/app": "0.9.0-dev.
|
|
56
|
-
"@fabrika/auth-core": "0.9.0-dev.
|
|
57
|
-
"@fabrika/db": "0.9.0-dev.
|
|
58
|
-
"@fabrika/operations-contract": "0.9.0-dev.
|
|
59
|
-
"@fabrika/platform-node": "0.9.0-dev.
|
|
55
|
+
"@fabrika/app": "0.9.0-dev.31",
|
|
56
|
+
"@fabrika/auth-core": "0.9.0-dev.31",
|
|
57
|
+
"@fabrika/db": "0.9.0-dev.31",
|
|
58
|
+
"@fabrika/operations-contract": "0.9.0-dev.31",
|
|
59
|
+
"@fabrika/platform-node": "0.9.0-dev.31",
|
|
60
60
|
"zod": "^3.25.76"
|
|
61
61
|
}
|
|
62
62
|
}
|
package/src/ast.ts
CHANGED
|
@@ -317,15 +317,3 @@ export const parseModule = (file: string, text: string): ParseResult => {
|
|
|
317
317
|
return { ok: false, message, position: syntaxErrorPosition(error) }
|
|
318
318
|
}
|
|
319
319
|
}
|
|
320
|
-
|
|
321
|
-
/** The sources of a module's import and re-export declarations; `rules/literal.ts` decides which of them are allowed. */
|
|
322
|
-
export const importedSpecifiers = (module: ParsedModule): string[] => {
|
|
323
|
-
const specifiers: string[] = []
|
|
324
|
-
for (const statement of children(module.program, 'body')) {
|
|
325
|
-
const source = statement === null ? undefined : staticString(child(statement, 'source'))
|
|
326
|
-
if (source !== undefined && statement?.['importKind'] !== 'type' && statement?.['exportKind'] !== 'type') {
|
|
327
|
-
specifiers.push(source)
|
|
328
|
-
}
|
|
329
|
-
}
|
|
330
|
-
return specifiers
|
|
331
|
-
}
|
package/src/contract.ts
CHANGED
|
@@ -5,7 +5,7 @@
|
|
|
5
5
|
import { type AnyContract, compileContract } from '@fabrika/app/contract'
|
|
6
6
|
import type { ContractArtifact, TablePolicyArtifact } from '@fabrika/auth-core'
|
|
7
7
|
import { type TablePolicies, tablePolicies, type Tables } from '@fabrika/db/tables'
|
|
8
|
-
import { child, children,
|
|
8
|
+
import { child, children, nodeCount, nodeDepth, type ParsedModule, utf8Bytes } from './ast'
|
|
9
9
|
import { type Finding, formatFinding } from './finding'
|
|
10
10
|
import { ModuleGraph } from './graph'
|
|
11
11
|
import { CONTRACT_EXPORT, CONTRACT_FILE, isRelativeSpecifier, isSourceFile, resolveRelative, TABLES_EXPORT, TABLES_FILE } from './layout'
|
|
@@ -14,6 +14,7 @@ import { ReaderProblems } from './reader/problems'
|
|
|
14
14
|
import { readContractValue } from './reader/surface'
|
|
15
15
|
import { readTablesValue } from './reader/tables'
|
|
16
16
|
import { ValueReader } from './reader/value'
|
|
17
|
+
import { importedSpecifiers } from './references'
|
|
17
18
|
import { checkLiteralGraph } from './rules/literal'
|
|
18
19
|
import { offsets, parseShellModule, type Range } from './slice'
|
|
19
20
|
import { checkTrustedResolution } from './trust'
|
package/src/inputs.ts
CHANGED
|
@@ -1,10 +1,11 @@
|
|
|
1
1
|
// Which files of an application the static reader needs. Control reads a commit file by file, and the reader cannot
|
|
2
2
|
// tell a missing file from one it was not given, so the caller asks here until nothing is missing. Worker-safe.
|
|
3
3
|
|
|
4
|
-
import {
|
|
4
|
+
import { utf8Bytes } from './ast'
|
|
5
5
|
import { parseJsonc } from './jsonc'
|
|
6
6
|
import { CONTRACT_FILE, isRelativeSpecifier, isSourceFile, joinRelative, resolveRelative, TABLES_FILE } from './layout'
|
|
7
7
|
import { CONTRACT_LIMITS } from './limits'
|
|
8
|
+
import { importedSpecifiers } from './references'
|
|
8
9
|
import { parseShellModule } from './slice'
|
|
9
10
|
import { BUNFIG_FILE } from './trust'
|
|
10
11
|
|
package/src/references.ts
CHANGED
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import { type AstNode, child, children, identifierName, memberPath, staticKey, staticString, stringField, walk } from './ast'
|
|
1
|
+
import { type AstNode, child, children, identifierName, memberPath, type ParsedModule, staticKey, staticString, stringField, walk } from './ast'
|
|
2
2
|
|
|
3
3
|
/**
|
|
4
4
|
* One way a module names another: a static import, a re-export, a dynamic `import()`, `require()` (also `module.require`
|
|
@@ -93,3 +93,18 @@ export const moduleReferences = (program: AstNode): readonly ModuleReference[] =
|
|
|
93
93
|
})
|
|
94
94
|
return references
|
|
95
95
|
}
|
|
96
|
+
|
|
97
|
+
const STATIC_DECLARATIONS = new Set(['ImportDeclaration', 'ExportNamedDeclaration', 'ExportAllDeclaration'])
|
|
98
|
+
|
|
99
|
+
/**
|
|
100
|
+
* The sources of a module's import and re-export declarations that Bun evaluates: a type-only one, also one left with
|
|
101
|
+
* `type` specifiers alone once the slice removed the rest, is erased. `rules/literal.ts` decides which are allowed.
|
|
102
|
+
*/
|
|
103
|
+
export const importedSpecifiers = (module: ParsedModule): string[] => {
|
|
104
|
+
const specifiers: string[] = []
|
|
105
|
+
for (const statement of children(module.program, 'body')) {
|
|
106
|
+
const reference = statement !== null && STATIC_DECLARATIONS.has(statement.type) ? referenceOf(statement, []) : undefined
|
|
107
|
+
if (reference !== undefined && !reference.typeOnly) specifiers.push(reference.specifier)
|
|
108
|
+
}
|
|
109
|
+
return specifiers
|
|
110
|
+
}
|
package/types/src/ast.d.ts
CHANGED
|
@@ -67,5 +67,3 @@ export declare const nodeDepth: (root: AstNode) => number;
|
|
|
67
67
|
/** The number of syntax nodes in the tree below `root`, `root` included, counted without recursion. */
|
|
68
68
|
export declare const nodeCount: (root: AstNode) => number;
|
|
69
69
|
export declare const parseModule: (file: string, text: string) => ParseResult;
|
|
70
|
-
/** The sources of a module's import and re-export declarations; `rules/literal.ts` decides which of them are allowed. */
|
|
71
|
-
export declare const importedSpecifiers: (module: ParsedModule) => string[];
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import { type AstNode } from './ast';
|
|
1
|
+
import { type AstNode, type ParsedModule } from './ast';
|
|
2
2
|
/**
|
|
3
3
|
* One way a module names another: a static import, a re-export, a dynamic `import()`, `require()` (also `module.require`
|
|
4
4
|
* and `import.meta.require`) or `import x = require()`.
|
|
@@ -13,3 +13,8 @@ export interface ModuleReference {
|
|
|
13
13
|
}
|
|
14
14
|
export declare const isRequire: (callee: AstNode | undefined) => boolean;
|
|
15
15
|
export declare const moduleReferences: (program: AstNode) => readonly ModuleReference[];
|
|
16
|
+
/**
|
|
17
|
+
* The sources of a module's import and re-export declarations that Bun evaluates: a type-only one, also one left with
|
|
18
|
+
* `type` specifiers alone once the slice removed the rest, is erased. `rules/literal.ts` decides which are allowed.
|
|
19
|
+
*/
|
|
20
|
+
export declare const importedSpecifiers: (module: ParsedModule) => string[];
|