no-mistakes 0.69.0 → 0.71.1

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/index.d.ts CHANGED
@@ -1,3 +1,15 @@
1
+ import type { PostgresSqlSource, PostgresSqlFacts } from "./postgres-source-types";
2
+ export type * from "./postgres-source-types";
3
+ /** Parse SQL on the native async worker without repository I/O or a database. */
4
+ export function parsePostgresSql(source: PostgresSqlSource): Promise<PostgresSqlFacts>;
5
+ export function parsePostgresSql(sources: PostgresSqlSource[]): Promise<PostgresSqlFacts[]>;
6
+ import type {
7
+ PostgresCatalog,
8
+ PostgresCatalogOptions,
9
+ PostgresCompleteCatalog,
10
+ PostgresOrderingCatalog,
11
+ } from "./postgres-catalog-types";
12
+ export type * from "./postgres-catalog-types";
1
13
  import type {
2
14
  CheckReport,
3
15
  AnalyzeProjectOptions,
@@ -175,3 +187,17 @@ export function reactCheck(
175
187
  export function reactUsages(
176
188
  options: WithInvocationOptions<ProjectOptions & { target: string }>,
177
189
  ): Promise<ReactUsagesReport>;
190
+
191
+ /**
192
+ * Observe committed PostgreSQL metadata in a read-only transaction and return the catalog that
193
+ * `schemaCatalogPath` reads. Requires psql. `coverage: "ordering"` returns only the ordering facts.
194
+ */
195
+ export function generatePostgresCatalog(
196
+ options: WithInvocationOptions<PostgresCatalogOptions & { coverage: "ordering" }>,
197
+ ): Promise<PostgresOrderingCatalog>;
198
+ export function generatePostgresCatalog(
199
+ options: WithInvocationOptions<PostgresCatalogOptions & { coverage?: "complete" }>,
200
+ ): Promise<PostgresCompleteCatalog>;
201
+ export function generatePostgresCatalog(
202
+ options: WithInvocationOptions<PostgresCatalogOptions>,
203
+ ): Promise<PostgresCatalog>;
package/index.js CHANGED
@@ -24,6 +24,8 @@ function createJsonApis(descriptors) {
24
24
  }
25
25
 
26
26
  const jsonApis = createJsonApis({
27
+ parsePostgresSql: "parsePostgresSqlJson",
28
+ generatePostgresCatalog: "generatePostgresCatalogJson",
27
29
  analyzeProject: "analyzeProjectJson",
28
30
  callSites: "callSitesJson",
29
31
  check: "checkJson",
@@ -164,3 +166,6 @@ module.exports.testsImpact = planning.testsImpact;
164
166
  module.exports.testsPlan = planning.testsPlan;
165
167
  module.exports.testsTargets = planning.testsTargets;
166
168
  module.exports.testsWhy = planning.testsWhy;
169
+
170
+ module.exports.generatePostgresCatalog = jsonApis.generatePostgresCatalog;
171
+ module.exports.parsePostgresSql = jsonApis.parsePostgresSql;
package/index.mjs CHANGED
@@ -20,6 +20,8 @@ export const {
20
20
  exportsOf,
21
21
  fetches,
22
22
  flow,
23
+ generatePostgresCatalog,
24
+ parsePostgresSql,
23
25
  impactedChecks,
24
26
  importUsages,
25
27
  importers,
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "no-mistakes",
3
- "version": "0.69.0",
3
+ "version": "0.71.1",
4
4
  "description": "Deterministic impact maps, test plans, Playwright coverage, and repository checks for coding agents",
5
5
  "license": "MIT",
6
6
  "repository": {
@@ -45,9 +45,9 @@
45
45
  "access": "public"
46
46
  },
47
47
  "optionalDependencies": {
48
- "no-mistakes-darwin-arm64": "0.69.0",
49
- "no-mistakes-linux-arm64-gnu": "0.69.0",
50
- "no-mistakes-linux-x64-gnu": "0.69.0",
51
- "no-mistakes-win32-x64-msvc": "0.69.0"
48
+ "no-mistakes-darwin-arm64": "0.71.1",
49
+ "no-mistakes-linux-arm64-gnu": "0.71.1",
50
+ "no-mistakes-linux-x64-gnu": "0.71.1",
51
+ "no-mistakes-win32-x64-msvc": "0.71.1"
52
52
  }
53
53
  }
@@ -0,0 +1,115 @@
1
+ /** Which facts a generated catalog carries. It is stated in the catalog's `coverage` field. */
2
+ export type PostgresCatalogCoverage = "complete" | "ordering";
3
+ /** Explicit accessible relation names for requested schemas; an unrequested key is absent. */
4
+ export type PostgresSearchPathEvidence = Partial<Record<string, string[] | null>>;
5
+ export interface PostgresCatalogOptions {
6
+ /** Environment variable containing a PostgreSQL connection URL; never pass secrets as options. */
7
+ connectionEnv: string;
8
+ /** Exact PostgreSQL schema name. */
9
+ schema: string;
10
+ /**
11
+ * `complete` (the default) carries every schema fact, and every catalog rule accepts it.
12
+ * `ordering` carries only what conflict and lock ordering need; other catalog rules reject it.
13
+ */
14
+ coverage?: PostgresCatalogCoverage;
15
+ /** Opt in to evidence for these exact schemas; absent or inaccessible schemas become null. */
16
+ searchPathSchemas?: string[];
17
+ }
18
+ export interface PostgresOrderingCatalog {
19
+ formatVersion: 2;
20
+ coverage: "ordering";
21
+ schema: string;
22
+ searchPathEvidence?: PostgresSearchPathEvidence;
23
+ /** Exact connected database name; absent in catalogs generated by older versions. */
24
+ currentDatabase?: string;
25
+ tables: Record<string, PostgresCatalogTable>;
26
+ }
27
+ /** A catalog with every fact the catalog model holds. Every catalog rule accepts it. */
28
+ export interface PostgresCompleteCatalog {
29
+ formatVersion: 2;
30
+ coverage: "complete";
31
+ schema: string;
32
+ searchPathEvidence?: PostgresSearchPathEvidence;
33
+ /** Exact connected database name; absent in catalogs generated by older versions. */
34
+ currentDatabase?: string;
35
+ tables: Record<string, PostgresCompleteCatalogTable>;
36
+ functions: Record<string, PostgresCatalogFunction>;
37
+ enums: Record<string, PostgresCatalogEnum>;
38
+ views: Record<string, PostgresCatalogView>;
39
+ }
40
+ export type PostgresCatalog = PostgresOrderingCatalog | PostgresCompleteCatalog;
41
+ export interface PostgresCatalogColumn {
42
+ dataType: string;
43
+ nullable: boolean;
44
+ ordinalPosition: number;
45
+ defaultExpression: string | null;
46
+ generated: "stored" | "virtual" | null;
47
+ generatedExpression: string | null;
48
+ identity: "a" | "d" | null;
49
+ }
50
+ export interface PostgresCompleteCatalogColumn extends PostgresCatalogColumn {
51
+ comment: string | null;
52
+ }
53
+ export interface PostgresCatalogIndexKey {
54
+ column: string | null;
55
+ opclass: string;
56
+ collation: string | null;
57
+ orderingSupported: boolean;
58
+ expression: string;
59
+ descending: boolean;
60
+ nullsFirst: boolean;
61
+ }
62
+ export interface PostgresCatalogIndex {
63
+ accessMethod: string;
64
+ unique: boolean;
65
+ primary: boolean;
66
+ constraintBacked: boolean;
67
+ immediate: boolean;
68
+ live: boolean;
69
+ valid: boolean;
70
+ ready: boolean;
71
+ predicate: string | null;
72
+ definition: string;
73
+ keys: PostgresCatalogIndexKey[];
74
+ }
75
+ export interface PostgresCatalogTable {
76
+ relationKind: "table" | "partitioned table";
77
+ columns: Record<string, PostgresCatalogColumn>;
78
+ primaryKey: { columns: string[] } | null;
79
+ uniqueConstraints: Record<string, { columns: string[] }>;
80
+ indexes: Record<string, PostgresCatalogIndex>;
81
+ }
82
+ export interface PostgresCatalogForeignKey {
83
+ columns: string[];
84
+ referencedTable: string;
85
+ referencedColumns: string[];
86
+ onDelete: "NO ACTION" | "RESTRICT" | "CASCADE" | "SET NULL" | "SET DEFAULT";
87
+ onUpdate: "NO ACTION" | "RESTRICT" | "CASCADE" | "SET NULL" | "SET DEFAULT";
88
+ validated: boolean;
89
+ }
90
+ export interface PostgresCompleteCatalogTable extends Omit<PostgresCatalogTable, "columns"> {
91
+ columns: Record<string, PostgresCompleteCatalogColumn>;
92
+ comment: string | null;
93
+ /** `pg_get_partkeydef` text such as `RANGE (created_at)`; `null` unless partitioned. */
94
+ physicalPartition: { key: string } | null;
95
+ foreignKeys: Record<string, PostgresCatalogForeignKey>;
96
+ /** `definition` is `pg_get_constraintdef` text; NOT NULL constraints are not checks. */
97
+ checkConstraints: Record<string, { definition: string; validated: boolean }>;
98
+ /** `definition` is `pg_get_triggerdef` text; internal triggers are omitted. */
99
+ triggers: Record<string, { definition: string }>;
100
+ }
101
+ /** Keyed by name and identity arguments, such as `touch()` or `over(a integer)`. */
102
+ export interface PostgresCatalogFunction {
103
+ /** `pg_get_functiondef` text. */
104
+ definition: string;
105
+ }
106
+ export interface PostgresCatalogEnum {
107
+ /** Labels in `enumsortorder`. */
108
+ values: string[];
109
+ }
110
+ export interface PostgresCatalogView {
111
+ materialized: boolean;
112
+ /** `pg_get_viewdef` text. */
113
+ definition: string;
114
+ comment: string | null;
115
+ }
@@ -0,0 +1,11 @@
1
+ import type { PostgresSqlName } from "./postgres-source-types";
2
+ export interface PostgresSqlDrop {
3
+ objectType: string;
4
+ names: PostgresSqlName[];
5
+ table: PostgresSqlName | null;
6
+ signatures: string[];
7
+ ifExists: boolean;
8
+ cascade: boolean;
9
+ restrict: boolean;
10
+ temporary: boolean;
11
+ }
@@ -0,0 +1,25 @@
1
+ import type {
2
+ PostgresSqlDiagnostic,
3
+ PostgresSqlExpression,
4
+ PostgresSqlSpan,
5
+ PostgresSqlStatement,
6
+ } from "./postgres-source-types";
7
+ /** Nested facts are procedural source occurrences, never guaranteed execution. */
8
+ export interface PostgresSqlProceduralBlock {
9
+ language: string;
10
+ bodyEncoding: PostgresSqlBodyEncoding;
11
+ bodySpan: PostgresSqlSpan;
12
+ statements: PostgresSqlStatement[];
13
+ diagnostics: PostgresSqlDiagnostic[];
14
+ complete: boolean;
15
+ }
16
+
17
+ /** Branch DDL describes source occurrences, never guaranteed execution. */
18
+ export interface PostgresSqlConditionalBranch {
19
+ condition: PostgresSqlExpression | null;
20
+ span: PostgresSqlSpan;
21
+ statements: PostgresSqlStatement[];
22
+ }
23
+
24
+ /** Original body source slices retain this enclosing literal encoding. */
25
+ export type PostgresSqlBodyEncoding = "dollarQuoted" | "singleQuoted";
@@ -0,0 +1,198 @@
1
+ import type { PostgresSqlDrop } from "./postgres-drop-types";
2
+ export type * from "./postgres-drop-types";
3
+ import type {
4
+ PostgresSqlConditionalBranch,
5
+ PostgresSqlProceduralBlock,
6
+ } from "./postgres-procedural-types";
7
+ export type * from "./postgres-procedural-types";
8
+ /** Pure SQL source input. No repository, database, or filesystem options are needed. */
9
+ export interface PostgresSqlSource {
10
+ sql: string;
11
+ fileName?: string | null;
12
+ }
13
+ /** UTF-8 byte offset, with one-based Unicode scalar line and column. */
14
+ export interface PostgresSqlPosition {
15
+ offset: number;
16
+ line: number;
17
+ column: number;
18
+ }
19
+ /** End-exclusive source span. */
20
+ export interface PostgresSqlSpan {
21
+ start: PostgresSqlPosition;
22
+ end: PostgresSqlPosition;
23
+ }
24
+ export interface PostgresSqlDiagnostic {
25
+ message: string;
26
+ span: PostgresSqlSpan | null;
27
+ }
28
+ export interface PostgresSqlIdentifier {
29
+ value: string;
30
+ quoted: boolean;
31
+ identity: string;
32
+ }
33
+ export interface PostgresSqlName {
34
+ parts: PostgresSqlIdentifier[];
35
+ sql: string;
36
+ }
37
+ export interface PostgresSqlFunctionReference {
38
+ name: PostgresSqlName;
39
+ span: PostgresSqlSpan | null;
40
+ }
41
+ export interface PostgresSqlExpression {
42
+ sql: string;
43
+ identity: string;
44
+ span: PostgresSqlSpan | null;
45
+ columns: PostgresSqlName[];
46
+ functions: PostgresSqlFunctionReference[];
47
+ }
48
+ export interface PostgresSqlType {
49
+ sql: string;
50
+ name: PostgresSqlName | null;
51
+ builtin: string | null;
52
+ modifiers: string[];
53
+ arrayDimensions: (number | null)[];
54
+ fields: PostgresSqlColumn[];
55
+ }
56
+ export interface PostgresSqlGeneratedColumn {
57
+ expression: PostgresSqlExpression;
58
+ storage: string | null;
59
+ }
60
+ export interface PostgresSqlIdentityColumn {
61
+ mode: string;
62
+ options: string[];
63
+ }
64
+ export interface PostgresSqlColumn {
65
+ name: PostgresSqlIdentifier;
66
+ dataType: PostgresSqlType;
67
+ nullable: boolean;
68
+ default: PostgresSqlExpression | null;
69
+ generated: PostgresSqlGeneratedColumn | null;
70
+ identity: PostgresSqlIdentityColumn | null;
71
+ constraints: PostgresSqlConstraint[];
72
+ span: PostgresSqlSpan | null;
73
+ }
74
+ export type PostgresSqlConstraintKind = "primaryKey" | "unique" | "foreignKey" | "check" | "other";
75
+ export interface PostgresSqlConstraint {
76
+ kind: PostgresSqlConstraintKind;
77
+ name: PostgresSqlIdentifier | null;
78
+ columns: PostgresSqlIdentifier[];
79
+ expression: PostgresSqlExpression | null;
80
+ referencedTable: PostgresSqlName | null;
81
+ referencedColumns: PostgresSqlIdentifier[];
82
+ onDelete: string | null;
83
+ onUpdate: string | null;
84
+ characteristics: string | null;
85
+ sql: string;
86
+ }
87
+ export type PostgresSqlAlterOperation =
88
+ | { kind: "addColumn"; column: PostgresSqlColumn }
89
+ | {
90
+ kind: "alterColumnType";
91
+ column: PostgresSqlIdentifier;
92
+ dataType: PostgresSqlType;
93
+ using: PostgresSqlExpression | null;
94
+ }
95
+ | { kind: "setDefault"; column: PostgresSqlIdentifier; expression: PostgresSqlExpression }
96
+ | { kind: "dropDefault" | "setNotNull" | "dropNotNull"; column: PostgresSqlIdentifier }
97
+ | { kind: "addConstraint"; constraint: PostgresSqlConstraint; notValid: boolean }
98
+ | { kind: "validateConstraint"; name: PostgresSqlIdentifier }
99
+ | { kind: "other"; sql: string };
100
+ export interface PostgresSqlIndexKey {
101
+ expression: PostgresSqlExpression;
102
+ ascending: boolean;
103
+ nullsFirst: boolean;
104
+ operatorClass: PostgresSqlName | null;
105
+ }
106
+ export interface PostgresSqlIndex {
107
+ name: PostgresSqlName | null;
108
+ table: PostgresSqlName;
109
+ method: string;
110
+ unique: boolean;
111
+ nullsDistinct: boolean;
112
+ keys: PostgresSqlIndexKey[];
113
+ include: PostgresSqlIdentifier[];
114
+ predicate: PostgresSqlExpression | null;
115
+ options: string[];
116
+ structuralIdentity: string;
117
+ }
118
+ export interface PostgresSqlView {
119
+ name: PostgresSqlName;
120
+ columns: PostgresSqlIdentifier[];
121
+ materialized: boolean;
122
+ temporary: boolean;
123
+ orReplace: boolean;
124
+ query: string;
125
+ dependencies: PostgresSqlName[];
126
+ dependenciesComplete: boolean;
127
+ functions: PostgresSqlFunctionReference[];
128
+ }
129
+ export interface PostgresSqlTriggerTransition {
130
+ kind: string;
131
+ name: PostgresSqlName;
132
+ }
133
+ export interface PostgresSqlTrigger {
134
+ name: PostgresSqlName;
135
+ table: PostgresSqlName;
136
+ timing: string | null;
137
+ events: string[];
138
+ forEach: string | null;
139
+ condition: PostgresSqlExpression | null;
140
+ function: PostgresSqlName | null;
141
+ arguments: string[];
142
+ constraint: boolean;
143
+ orReplace: boolean;
144
+ referencedTable: PostgresSqlName | null;
145
+ transitions: PostgresSqlTriggerTransition[];
146
+ executionKind: string | null;
147
+ characteristics: string | null;
148
+ }
149
+ export interface PostgresSqlFunctionArgument {
150
+ name: PostgresSqlIdentifier | null;
151
+ mode: string | null;
152
+ dataType: PostgresSqlType;
153
+ default: PostgresSqlExpression | null;
154
+ }
155
+ export interface PostgresSqlFunction {
156
+ name: PostgresSqlName;
157
+ arguments: PostgresSqlFunctionArgument[];
158
+ returnType: PostgresSqlType | null;
159
+ returnsSet: boolean;
160
+ language: string | null;
161
+ behavior: string | null;
162
+ bodySql: string | null;
163
+ orReplace: boolean;
164
+ temporary: boolean;
165
+ calledOnNull: string | null;
166
+ parallel: string | null;
167
+ configuration: string[];
168
+ security: string | null;
169
+ }
170
+ export type PostgresSqlStatementKind =
171
+ | {
172
+ kind: "createTable";
173
+ table: PostgresSqlName;
174
+ columns: PostgresSqlColumn[];
175
+ constraints: PostgresSqlConstraint[];
176
+ temporary: boolean;
177
+ }
178
+ | { kind: "alterTable"; table: PostgresSqlName; operations: PostgresSqlAlterOperation[] }
179
+ | { kind: "createIndex"; index: PostgresSqlIndex }
180
+ | { kind: "createView"; view: PostgresSqlView }
181
+ | { kind: "createTrigger"; trigger: PostgresSqlTrigger }
182
+ | { kind: "createFunction"; function: PostgresSqlFunction }
183
+ | { kind: "drop"; drop: PostgresSqlDrop }
184
+ | { kind: "doBlock"; block: PostgresSqlProceduralBlock }
185
+ | { kind: "conditional"; branches: PostgresSqlConditionalBranch[] }
186
+ | { kind: "other" };
187
+ export type PostgresSqlStatement = PostgresSqlStatementKind & {
188
+ ordinal: number;
189
+ span: PostgresSqlSpan;
190
+ sql: string;
191
+ };
192
+ /** Versioned facts retain valid neighbors when a statement cannot be parsed. */
193
+ export interface PostgresSqlFacts {
194
+ schemaVersion: 1;
195
+ fileName: string | null;
196
+ statements: PostgresSqlStatement[];
197
+ diagnostics: PostgresSqlDiagnostic[];
198
+ }