@gustavo-valsechi/node 1.0.35 → 1.0.36

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/dist/index.js CHANGED
@@ -320,20 +320,26 @@ var TenantService = class {
320
320
  this.idTenant = idTenant;
321
321
  }
322
322
  async getTenantQueryRunner() {
323
- var _a;
324
- if (this.runner) return this.runner;
323
+ var _a, _b;
324
+ if (this.runner && !this.runner.isReleased) {
325
+ await this.runner.query(`SET search_path TO "${this.idTenant}"`);
326
+ return this.runner;
327
+ }
328
+ if ((_a = this.runner) == null ? void 0 : _a.isReleased) {
329
+ this.runner = void 0;
330
+ }
325
331
  const runner = this.db.createQueryRunner();
326
332
  await runner.connect();
327
333
  const result = await runner.query(`
328
334
  SELECT EXISTS (
329
335
  SELECT 1
330
336
  FROM information_schema.schemata
331
- WHERE schema_name = '${this.idTenant}'
337
+ WHERE schema_name = $1
332
338
  ) AS "exists"
333
- `);
339
+ `, [this.idTenant]);
334
340
  await runner.query(`CREATE SCHEMA IF NOT EXISTS "${this.idTenant}"`);
335
341
  await runner.query(`SET search_path TO "${this.idTenant}"`);
336
- if (!((_a = result == null ? void 0 : result[0]) == null ? void 0 : _a.exists)) await runner.query(this.migrations);
342
+ if (!((_b = result == null ? void 0 : result[0]) == null ? void 0 : _b.exists)) await runner.query(this.migrations);
337
343
  this.runner = runner;
338
344
  return runner;
339
345
  }
@@ -349,6 +355,8 @@ var TenantService = class {
349
355
  await this.getTenantQueryRunner();
350
356
  await ((_a = this.runner) == null ? void 0 : _a.query("SET search_path TO public"));
351
357
  await ((_b = this.runner) == null ? void 0 : _b.release());
358
+ this.runner = void 0;
359
+ this.repository = void 0;
352
360
  }
353
361
  };
354
362
  // Annotate the CommonJS export names for ESM import in node:
package/dist/index.mjs CHANGED
@@ -289,20 +289,26 @@ var TenantService = class {
289
289
  this.idTenant = idTenant;
290
290
  }
291
291
  async getTenantQueryRunner() {
292
- var _a;
293
- if (this.runner) return this.runner;
292
+ var _a, _b;
293
+ if (this.runner && !this.runner.isReleased) {
294
+ await this.runner.query(`SET search_path TO "${this.idTenant}"`);
295
+ return this.runner;
296
+ }
297
+ if ((_a = this.runner) == null ? void 0 : _a.isReleased) {
298
+ this.runner = void 0;
299
+ }
294
300
  const runner = this.db.createQueryRunner();
295
301
  await runner.connect();
296
302
  const result = await runner.query(`
297
303
  SELECT EXISTS (
298
304
  SELECT 1
299
305
  FROM information_schema.schemata
300
- WHERE schema_name = '${this.idTenant}'
306
+ WHERE schema_name = $1
301
307
  ) AS "exists"
302
- `);
308
+ `, [this.idTenant]);
303
309
  await runner.query(`CREATE SCHEMA IF NOT EXISTS "${this.idTenant}"`);
304
310
  await runner.query(`SET search_path TO "${this.idTenant}"`);
305
- if (!((_a = result == null ? void 0 : result[0]) == null ? void 0 : _a.exists)) await runner.query(this.migrations);
311
+ if (!((_b = result == null ? void 0 : result[0]) == null ? void 0 : _b.exists)) await runner.query(this.migrations);
306
312
  this.runner = runner;
307
313
  return runner;
308
314
  }
@@ -318,6 +324,8 @@ var TenantService = class {
318
324
  await this.getTenantQueryRunner();
319
325
  await ((_a = this.runner) == null ? void 0 : _a.query("SET search_path TO public"));
320
326
  await ((_b = this.runner) == null ? void 0 : _b.release());
327
+ this.runner = void 0;
328
+ this.repository = void 0;
321
329
  }
322
330
  };
323
331
  export {
@@ -33,20 +33,26 @@ var TenantService = class {
33
33
  this.idTenant = idTenant;
34
34
  }
35
35
  async getTenantQueryRunner() {
36
- var _a;
37
- if (this.runner) return this.runner;
36
+ var _a, _b;
37
+ if (this.runner && !this.runner.isReleased) {
38
+ await this.runner.query(`SET search_path TO "${this.idTenant}"`);
39
+ return this.runner;
40
+ }
41
+ if ((_a = this.runner) == null ? void 0 : _a.isReleased) {
42
+ this.runner = void 0;
43
+ }
38
44
  const runner = this.db.createQueryRunner();
39
45
  await runner.connect();
40
46
  const result = await runner.query(`
41
47
  SELECT EXISTS (
42
48
  SELECT 1
43
49
  FROM information_schema.schemata
44
- WHERE schema_name = '${this.idTenant}'
50
+ WHERE schema_name = $1
45
51
  ) AS "exists"
46
- `);
52
+ `, [this.idTenant]);
47
53
  await runner.query(`CREATE SCHEMA IF NOT EXISTS "${this.idTenant}"`);
48
54
  await runner.query(`SET search_path TO "${this.idTenant}"`);
49
- if (!((_a = result == null ? void 0 : result[0]) == null ? void 0 : _a.exists)) await runner.query(this.migrations);
55
+ if (!((_b = result == null ? void 0 : result[0]) == null ? void 0 : _b.exists)) await runner.query(this.migrations);
50
56
  this.runner = runner;
51
57
  return runner;
52
58
  }
@@ -62,6 +68,8 @@ var TenantService = class {
62
68
  await this.getTenantQueryRunner();
63
69
  await ((_a = this.runner) == null ? void 0 : _a.query("SET search_path TO public"));
64
70
  await ((_b = this.runner) == null ? void 0 : _b.release());
71
+ this.runner = void 0;
72
+ this.repository = void 0;
65
73
  }
66
74
  };
67
75
  // Annotate the CommonJS export names for ESM import in node:
@@ -7,20 +7,26 @@ var TenantService = class {
7
7
  this.idTenant = idTenant;
8
8
  }
9
9
  async getTenantQueryRunner() {
10
- var _a;
11
- if (this.runner) return this.runner;
10
+ var _a, _b;
11
+ if (this.runner && !this.runner.isReleased) {
12
+ await this.runner.query(`SET search_path TO "${this.idTenant}"`);
13
+ return this.runner;
14
+ }
15
+ if ((_a = this.runner) == null ? void 0 : _a.isReleased) {
16
+ this.runner = void 0;
17
+ }
12
18
  const runner = this.db.createQueryRunner();
13
19
  await runner.connect();
14
20
  const result = await runner.query(`
15
21
  SELECT EXISTS (
16
22
  SELECT 1
17
23
  FROM information_schema.schemata
18
- WHERE schema_name = '${this.idTenant}'
24
+ WHERE schema_name = $1
19
25
  ) AS "exists"
20
- `);
26
+ `, [this.idTenant]);
21
27
  await runner.query(`CREATE SCHEMA IF NOT EXISTS "${this.idTenant}"`);
22
28
  await runner.query(`SET search_path TO "${this.idTenant}"`);
23
- if (!((_a = result == null ? void 0 : result[0]) == null ? void 0 : _a.exists)) await runner.query(this.migrations);
29
+ if (!((_b = result == null ? void 0 : result[0]) == null ? void 0 : _b.exists)) await runner.query(this.migrations);
24
30
  this.runner = runner;
25
31
  return runner;
26
32
  }
@@ -36,6 +42,8 @@ var TenantService = class {
36
42
  await this.getTenantQueryRunner();
37
43
  await ((_a = this.runner) == null ? void 0 : _a.query("SET search_path TO public"));
38
44
  await ((_b = this.runner) == null ? void 0 : _b.release());
45
+ this.runner = void 0;
46
+ this.repository = void 0;
39
47
  }
40
48
  };
41
49
  export {
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@gustavo-valsechi/node",
3
- "version": "1.0.35",
3
+ "version": "1.0.36",
4
4
  "main": "dist/index.js",
5
5
  "module": "dist/index.js",
6
6
  "types": "dist/index.d.ts",