eslint-plugin-slonik 1.0.0

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.
Files changed (35) hide show
  1. package/LICENSE +48 -0
  2. package/README.md +368 -0
  3. package/dist/config.cjs +61 -0
  4. package/dist/config.cjs.map +1 -0
  5. package/dist/config.d.cts +192 -0
  6. package/dist/config.d.mts +192 -0
  7. package/dist/config.d.ts +192 -0
  8. package/dist/config.mjs +59 -0
  9. package/dist/config.mjs.map +1 -0
  10. package/dist/index.cjs +27 -0
  11. package/dist/index.cjs.map +1 -0
  12. package/dist/index.d.cts +319 -0
  13. package/dist/index.d.mts +319 -0
  14. package/dist/index.d.ts +319 -0
  15. package/dist/index.mjs +20 -0
  16. package/dist/index.mjs.map +1 -0
  17. package/dist/shared/eslint-plugin-slonik.1m1xlVmw.d.cts +611 -0
  18. package/dist/shared/eslint-plugin-slonik.1m1xlVmw.d.mts +611 -0
  19. package/dist/shared/eslint-plugin-slonik.1m1xlVmw.d.ts +611 -0
  20. package/dist/shared/eslint-plugin-slonik.BxexVlk1.cjs +1539 -0
  21. package/dist/shared/eslint-plugin-slonik.BxexVlk1.cjs.map +1 -0
  22. package/dist/shared/eslint-plugin-slonik.C0xTyWZ2.mjs +2866 -0
  23. package/dist/shared/eslint-plugin-slonik.C0xTyWZ2.mjs.map +1 -0
  24. package/dist/shared/eslint-plugin-slonik.DbzoLz5_.mjs +1514 -0
  25. package/dist/shared/eslint-plugin-slonik.DbzoLz5_.mjs.map +1 -0
  26. package/dist/shared/eslint-plugin-slonik.rlOTrCdf.cjs +2929 -0
  27. package/dist/shared/eslint-plugin-slonik.rlOTrCdf.cjs.map +1 -0
  28. package/dist/workers/check-sql.worker.cjs +2436 -0
  29. package/dist/workers/check-sql.worker.cjs.map +1 -0
  30. package/dist/workers/check-sql.worker.d.cts +171 -0
  31. package/dist/workers/check-sql.worker.d.mts +171 -0
  32. package/dist/workers/check-sql.worker.d.ts +171 -0
  33. package/dist/workers/check-sql.worker.mjs +2412 -0
  34. package/dist/workers/check-sql.worker.mjs.map +1 -0
  35. package/package.json +103 -0
@@ -0,0 +1,171 @@
1
+ import * as fp_ts_lib_Either from 'fp-ts/lib/Either';
2
+ import postgres from 'postgres';
3
+ import { R as RuleOptionConnection, a as ConnectionTarget } from '../shared/eslint-plugin-slonik.1m1xlVmw.mjs';
4
+ import 'zod';
5
+
6
+ declare class DatabaseInitializationError extends Error {
7
+ _tag: "DatabaseInitializationError";
8
+ constructor(message: string);
9
+ static of(pgError: string): DatabaseInitializationError;
10
+ static to(error: unknown): DatabaseInitializationError;
11
+ toJSON(): {
12
+ _tag: "DatabaseInitializationError";
13
+ message: string;
14
+ };
15
+ }
16
+ declare class InvalidMigrationsPathError extends Error {
17
+ _tag: "InvalidMigrationsPathError";
18
+ migrationsPath: string;
19
+ constructor(migrationsPath: string, message: string);
20
+ static of(filePath: string, pgError: string): InvalidMigrationsPathError;
21
+ static fromErrorC(migrationsPath: string): (error: Error) => InvalidMigrationsPathError;
22
+ toJSON(): {
23
+ _tag: "InvalidMigrationsPathError";
24
+ migrationsPath: string;
25
+ message: string;
26
+ };
27
+ }
28
+ declare class InvalidMigrationError extends Error {
29
+ _tag: "InvalidMigrationError";
30
+ filePath: string;
31
+ constructor(filePath: string, message: string);
32
+ static of(filePath: string, pgError: string): InvalidMigrationError;
33
+ static fromErrorC(migrationsPath: string): (error: Error) => InvalidMigrationError;
34
+ toJSON(): {
35
+ _tag: "InvalidMigrationError";
36
+ filePath: string;
37
+ message: string;
38
+ };
39
+ }
40
+ declare class InternalError extends Error {
41
+ _tag: "InternalError";
42
+ constructor(error: string);
43
+ static of(error: string): InternalError;
44
+ static to(error: unknown): InternalError;
45
+ toJSON(): {
46
+ _tag: "InternalError";
47
+ stack: string | undefined;
48
+ message: string;
49
+ };
50
+ }
51
+ declare class DuplicateColumnsError extends Error {
52
+ _tag: "DuplicateColumnsError";
53
+ columns: string[];
54
+ queryText: string;
55
+ position: number;
56
+ sourcemaps: QuerySourceMapEntry[];
57
+ constructor(params: {
58
+ columns: string[];
59
+ queryText: string;
60
+ position: number;
61
+ sourcemaps: QuerySourceMapEntry[];
62
+ });
63
+ static of(params: {
64
+ columns: string[];
65
+ queryText: string;
66
+ position: number;
67
+ sourcemaps: QuerySourceMapEntry[];
68
+ }): DuplicateColumnsError;
69
+ toJSON(): {
70
+ _tag: "DuplicateColumnsError";
71
+ message: string;
72
+ columns: string[];
73
+ queryText: string;
74
+ position: number;
75
+ sourcemaps: QuerySourceMapEntry[];
76
+ };
77
+ }
78
+ interface QuerySourceMapEntry {
79
+ original: {
80
+ start: number;
81
+ end: number;
82
+ text: string;
83
+ };
84
+ generated: {
85
+ start: number;
86
+ end: number;
87
+ text: string;
88
+ };
89
+ offset: number;
90
+ }
91
+ declare class PostgresError extends Error {
92
+ _tag: "PostgresError";
93
+ queryText: string;
94
+ message: string;
95
+ line: string;
96
+ position: number;
97
+ sourcemaps: QuerySourceMapEntry[];
98
+ constructor(params: {
99
+ queryText: string;
100
+ message: string;
101
+ line: string;
102
+ position: number | string;
103
+ sourcemaps: QuerySourceMapEntry[];
104
+ });
105
+ static of(params: {
106
+ queryText: string;
107
+ message: string;
108
+ line: string;
109
+ position: number | string;
110
+ sourcemaps: QuerySourceMapEntry[];
111
+ }): PostgresError;
112
+ static to(query: string, error: unknown, sourcemaps: QuerySourceMapEntry[]): PostgresError;
113
+ toJSON(): {
114
+ _tag: "PostgresError";
115
+ queryText: string;
116
+ message: string;
117
+ line: string;
118
+ position: number;
119
+ sourcemaps: QuerySourceMapEntry[];
120
+ };
121
+ }
122
+
123
+ type ResolvedTarget = {
124
+ kind: "type";
125
+ value: string;
126
+ type: string;
127
+ base?: string;
128
+ } | {
129
+ kind: "literal";
130
+ value: string;
131
+ base: ResolvedTarget;
132
+ } | {
133
+ kind: "union";
134
+ value: ResolvedTarget[];
135
+ } | {
136
+ kind: "array";
137
+ value: ResolvedTarget;
138
+ syntax?: "array-type" | "type-reference";
139
+ } | {
140
+ kind: "object";
141
+ value: ResolvedTargetEntry[];
142
+ };
143
+ type ResolvedTargetEntry = [string, ResolvedTarget];
144
+ type GenerateResult = {
145
+ output: Extract<ResolvedTarget, {
146
+ kind: "object";
147
+ }> | null;
148
+ unknownColumns: string[];
149
+ stmt: postgres.Statement;
150
+ query: {
151
+ text: string;
152
+ sourcemaps: QuerySourceMapEntry[];
153
+ };
154
+ };
155
+ type GenerateError = DuplicateColumnsError | PostgresError;
156
+
157
+ interface CheckSQLWorkerParams {
158
+ connection: RuleOptionConnection;
159
+ target: ConnectionTarget;
160
+ query: {
161
+ text: string;
162
+ sourcemaps: QuerySourceMapEntry[];
163
+ };
164
+ projectDir: string;
165
+ }
166
+ type CheckSQLWorkerHandler = typeof handler;
167
+ declare function handler(params: CheckSQLWorkerParams): Promise<fp_ts_lib_Either.Either<unknown, string>>;
168
+ type WorkerError = InvalidMigrationsPathError | InvalidMigrationError | InternalError | DatabaseInitializationError | GenerateError;
169
+ type WorkerResult = GenerateResult;
170
+
171
+ export type { CheckSQLWorkerHandler, CheckSQLWorkerParams, WorkerError, WorkerResult };
@@ -0,0 +1,171 @@
1
+ import * as fp_ts_lib_Either from 'fp-ts/lib/Either';
2
+ import postgres from 'postgres';
3
+ import { R as RuleOptionConnection, a as ConnectionTarget } from '../shared/eslint-plugin-slonik.1m1xlVmw.js';
4
+ import 'zod';
5
+
6
+ declare class DatabaseInitializationError extends Error {
7
+ _tag: "DatabaseInitializationError";
8
+ constructor(message: string);
9
+ static of(pgError: string): DatabaseInitializationError;
10
+ static to(error: unknown): DatabaseInitializationError;
11
+ toJSON(): {
12
+ _tag: "DatabaseInitializationError";
13
+ message: string;
14
+ };
15
+ }
16
+ declare class InvalidMigrationsPathError extends Error {
17
+ _tag: "InvalidMigrationsPathError";
18
+ migrationsPath: string;
19
+ constructor(migrationsPath: string, message: string);
20
+ static of(filePath: string, pgError: string): InvalidMigrationsPathError;
21
+ static fromErrorC(migrationsPath: string): (error: Error) => InvalidMigrationsPathError;
22
+ toJSON(): {
23
+ _tag: "InvalidMigrationsPathError";
24
+ migrationsPath: string;
25
+ message: string;
26
+ };
27
+ }
28
+ declare class InvalidMigrationError extends Error {
29
+ _tag: "InvalidMigrationError";
30
+ filePath: string;
31
+ constructor(filePath: string, message: string);
32
+ static of(filePath: string, pgError: string): InvalidMigrationError;
33
+ static fromErrorC(migrationsPath: string): (error: Error) => InvalidMigrationError;
34
+ toJSON(): {
35
+ _tag: "InvalidMigrationError";
36
+ filePath: string;
37
+ message: string;
38
+ };
39
+ }
40
+ declare class InternalError extends Error {
41
+ _tag: "InternalError";
42
+ constructor(error: string);
43
+ static of(error: string): InternalError;
44
+ static to(error: unknown): InternalError;
45
+ toJSON(): {
46
+ _tag: "InternalError";
47
+ stack: string | undefined;
48
+ message: string;
49
+ };
50
+ }
51
+ declare class DuplicateColumnsError extends Error {
52
+ _tag: "DuplicateColumnsError";
53
+ columns: string[];
54
+ queryText: string;
55
+ position: number;
56
+ sourcemaps: QuerySourceMapEntry[];
57
+ constructor(params: {
58
+ columns: string[];
59
+ queryText: string;
60
+ position: number;
61
+ sourcemaps: QuerySourceMapEntry[];
62
+ });
63
+ static of(params: {
64
+ columns: string[];
65
+ queryText: string;
66
+ position: number;
67
+ sourcemaps: QuerySourceMapEntry[];
68
+ }): DuplicateColumnsError;
69
+ toJSON(): {
70
+ _tag: "DuplicateColumnsError";
71
+ message: string;
72
+ columns: string[];
73
+ queryText: string;
74
+ position: number;
75
+ sourcemaps: QuerySourceMapEntry[];
76
+ };
77
+ }
78
+ interface QuerySourceMapEntry {
79
+ original: {
80
+ start: number;
81
+ end: number;
82
+ text: string;
83
+ };
84
+ generated: {
85
+ start: number;
86
+ end: number;
87
+ text: string;
88
+ };
89
+ offset: number;
90
+ }
91
+ declare class PostgresError extends Error {
92
+ _tag: "PostgresError";
93
+ queryText: string;
94
+ message: string;
95
+ line: string;
96
+ position: number;
97
+ sourcemaps: QuerySourceMapEntry[];
98
+ constructor(params: {
99
+ queryText: string;
100
+ message: string;
101
+ line: string;
102
+ position: number | string;
103
+ sourcemaps: QuerySourceMapEntry[];
104
+ });
105
+ static of(params: {
106
+ queryText: string;
107
+ message: string;
108
+ line: string;
109
+ position: number | string;
110
+ sourcemaps: QuerySourceMapEntry[];
111
+ }): PostgresError;
112
+ static to(query: string, error: unknown, sourcemaps: QuerySourceMapEntry[]): PostgresError;
113
+ toJSON(): {
114
+ _tag: "PostgresError";
115
+ queryText: string;
116
+ message: string;
117
+ line: string;
118
+ position: number;
119
+ sourcemaps: QuerySourceMapEntry[];
120
+ };
121
+ }
122
+
123
+ type ResolvedTarget = {
124
+ kind: "type";
125
+ value: string;
126
+ type: string;
127
+ base?: string;
128
+ } | {
129
+ kind: "literal";
130
+ value: string;
131
+ base: ResolvedTarget;
132
+ } | {
133
+ kind: "union";
134
+ value: ResolvedTarget[];
135
+ } | {
136
+ kind: "array";
137
+ value: ResolvedTarget;
138
+ syntax?: "array-type" | "type-reference";
139
+ } | {
140
+ kind: "object";
141
+ value: ResolvedTargetEntry[];
142
+ };
143
+ type ResolvedTargetEntry = [string, ResolvedTarget];
144
+ type GenerateResult = {
145
+ output: Extract<ResolvedTarget, {
146
+ kind: "object";
147
+ }> | null;
148
+ unknownColumns: string[];
149
+ stmt: postgres.Statement;
150
+ query: {
151
+ text: string;
152
+ sourcemaps: QuerySourceMapEntry[];
153
+ };
154
+ };
155
+ type GenerateError = DuplicateColumnsError | PostgresError;
156
+
157
+ interface CheckSQLWorkerParams {
158
+ connection: RuleOptionConnection;
159
+ target: ConnectionTarget;
160
+ query: {
161
+ text: string;
162
+ sourcemaps: QuerySourceMapEntry[];
163
+ };
164
+ projectDir: string;
165
+ }
166
+ type CheckSQLWorkerHandler = typeof handler;
167
+ declare function handler(params: CheckSQLWorkerParams): Promise<fp_ts_lib_Either.Either<unknown, string>>;
168
+ type WorkerError = InvalidMigrationsPathError | InvalidMigrationError | InternalError | DatabaseInitializationError | GenerateError;
169
+ type WorkerResult = GenerateResult;
170
+
171
+ export type { CheckSQLWorkerHandler, CheckSQLWorkerParams, WorkerError, WorkerResult };