eslint-plugin-slonik 1.5.1 → 1.6.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/README.md CHANGED
@@ -178,13 +178,13 @@ targets: [
178
178
 
179
179
  ```bash
180
180
  pnpm add slonik zod
181
- pnpm add -D eslint-plugin-slonik @typescript-eslint/utils libpg-query
181
+ pnpm add -D eslint-plugin-slonik libpg-query
182
182
  ```
183
183
 
184
184
  ### 2. Create your SQL tag with type aliases
185
185
 
186
186
  ```ts
187
- // src/db/sql.ts
187
+ // src/slonik.ts
188
188
  import { createSqlTag } from "slonik";
189
189
  import { z } from "zod";
190
190
 
@@ -231,8 +231,7 @@ export default tseslint.config(
231
231
  ### 4. Write validated queries
232
232
 
233
233
  ```ts
234
- import { sql } from "./db/sql";
235
- import { pool } from "./db/pool";
234
+ import { pool, sql } from "./slonik";
236
235
 
237
236
  // ✅ Valid - query matches schema
238
237
  const users = await pool.many(
package/dist/index.cjs CHANGED
@@ -1072,9 +1072,16 @@ function checkType(params) {
1072
1072
  `);
1073
1073
  }
1074
1074
 
1075
- const distDir = node_url.fileURLToPath(new URL("../../dist", (typeof document === 'undefined' ? require('u' + 'rl').pathToFileURL(__filename).href : (_documentCurrentScript && _documentCurrentScript.tagName.toUpperCase() === 'SCRIPT' && _documentCurrentScript.src || new URL('index.cjs', document.baseURI).href))));
1075
+ const currentDir = node_url.fileURLToPath(new URL(".", (typeof document === 'undefined' ? require('u' + 'rl').pathToFileURL(__filename).href : (_documentCurrentScript && _documentCurrentScript.tagName.toUpperCase() === 'SCRIPT' && _documentCurrentScript.src || new URL('index.cjs', document.baseURI).href))));
1076
+ const isSourceDir = currentDir.includes(path__default.sep + "src" + path__default.sep);
1077
+ function getWorkerPath(name) {
1078
+ if (isSourceDir) {
1079
+ return path__default.join(currentDir, "../../dist/workers", `${name}.worker.mjs`);
1080
+ }
1081
+ return path__default.join(currentDir, "workers", `${name}.worker.mjs`);
1082
+ }
1076
1083
  function defineWorker(params) {
1077
- return synckit.createSyncFn(path__default.join(distDir, `./workers/${params.name}.worker.mjs`), {
1084
+ return synckit.createSyncFn(getWorkerPath(params.name), {
1078
1085
  tsRunner: "tsx",
1079
1086
  timeout: params.timeout
1080
1087
  });
@@ -1119,6 +1126,11 @@ const zBaseSchema = z__default.object({
1119
1126
  * Whether or not keep the connection alive. Change it only if you know what you're doing.
1120
1127
  */
1121
1128
  keepAlive: z__default.boolean().optional(),
1129
+ /**
1130
+ * Connection timeout in milliseconds. If the connection is not established within this time,
1131
+ * an error will be thrown. Defaults to 5000 (5 seconds).
1132
+ */
1133
+ connectionTimeout: z__default.number().optional(),
1122
1134
  /**
1123
1135
  * Override defaults
1124
1136
  */