@playwright-orchestrator/pg 1.1.0 → 1.1.2

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.
@@ -1,2 +1 @@
1
- "use strict";
2
- Object.defineProperty(exports, "__esModule", { value: true });
1
+ export {};
package/dist/index.d.ts CHANGED
@@ -1,6 +1,6 @@
1
1
  import { Command } from '@commander-js/extra-typings';
2
- import { CreateArgs } from './create-args';
3
- import { PostgreSQLAdapter } from './postgresql-adapter';
2
+ import { CreateArgs } from './create-args.js';
3
+ import { PostgreSQLAdapter } from './postgresql-adapter.js';
4
4
  export declare function factory(args: CreateArgs): Promise<PostgreSQLAdapter>;
5
5
  export declare function createOptions(command: Command): void;
6
6
  export declare const description = "PostgreSQL storage adapter";
package/dist/index.js CHANGED
@@ -1,32 +1,28 @@
1
- "use strict";
2
- Object.defineProperty(exports, "__esModule", { value: true });
3
- exports.description = void 0;
4
- exports.factory = factory;
5
- exports.createOptions = createOptions;
6
- const extra_typings_1 = require("@commander-js/extra-typings");
7
- const postgresql_adapter_1 = require("./postgresql-adapter");
8
- const promises_1 = require("node:fs/promises");
9
- async function factory(args) {
10
- const { sslCa, sslCert, sslKey } = args;
11
- if (sslCa) {
12
- args.sslCa = await (0, promises_1.readFile)(sslCa);
1
+ import { Option } from '@commander-js/extra-typings';
2
+ import { PostgreSQLAdapter } from './postgresql-adapter.js';
3
+ import { readFile } from 'node:fs/promises';
4
+ export async function factory(args) {
5
+ if (args.sslCa) {
6
+ args.sslCa = await readFile(args.sslCa);
13
7
  }
14
- if (sslCert && sslKey) {
15
- args.sslCert = await (0, promises_1.readFile)(sslCert);
16
- args.sslKey = await (0, promises_1.readFile)(sslKey);
8
+ if (args.sslCert) {
9
+ args.sslCert = await readFile(args.sslCert);
17
10
  }
18
- return new postgresql_adapter_1.PostgreSQLAdapter(args);
11
+ if (args.sslKey) {
12
+ args.sslKey = await readFile(args.sslKey);
13
+ }
14
+ return new PostgreSQLAdapter(args);
19
15
  }
20
- function createOptions(command) {
16
+ export function createOptions(command) {
21
17
  command
22
- .addOption(new extra_typings_1.Option('--table-name-prefix <string>', 'Tables name prefix')
18
+ .addOption(new Option('--table-name-prefix <string>', 'Tables name prefix')
23
19
  .default('playwright_orchestrator')
24
20
  .env('TABLE_NAME_PREFIX'))
25
- .addOption(new extra_typings_1.Option('--ssl-ca <string>', 'SSL CA file').env('SSL_CA'))
26
- .addOption(new extra_typings_1.Option('--ssl-cert <string>', 'SSL certificate file').env('SSL_CERT'))
27
- .addOption(new extra_typings_1.Option('--ssl-key <string>', 'SSL key file').env('SSL_KEY'))
28
- .addOption(new extra_typings_1.Option('--connection-string <string>', 'Connection string')
21
+ .addOption(new Option('--ssl-ca <string>', 'SSL CA').env('SSL_CA'))
22
+ .addOption(new Option('--ssl-cert <string>', 'SSL certificate').env('SSL_CERT'))
23
+ .addOption(new Option('--ssl-key <string>', 'SSL key').env('SSL_KEY'))
24
+ .addOption(new Option('--connection-string <string>', 'Connection string')
29
25
  .makeOptionMandatory()
30
26
  .env('CONNECTION_STRING'));
31
27
  }
32
- exports.description = 'PostgreSQL storage adapter';
28
+ export const description = 'PostgreSQL storage adapter';
@@ -1,5 +1,5 @@
1
1
  import { TestItem, TestRunInfo, Adapter, TestRunConfig } from '@playwright-orchestrator/core';
2
- import { CreateArgs } from './create-args';
2
+ import { CreateArgs } from './create-args.js';
3
3
  export declare class PostgreSQLAdapter extends Adapter {
4
4
  private readonly configTable;
5
5
  private readonly testsTable;
@@ -1,9 +1,9 @@
1
- "use strict";
2
- Object.defineProperty(exports, "__esModule", { value: true });
3
- exports.PostgreSQLAdapter = void 0;
4
- const core_1 = require("@playwright-orchestrator/core");
5
- const pg_1 = require("pg");
6
- class PostgreSQLAdapter extends core_1.Adapter {
1
+ import { Adapter, RunStatus, TestStatus } from '@playwright-orchestrator/core';
2
+ import pg from 'pg';
3
+ export class PostgreSQLAdapter extends Adapter {
4
+ configTable;
5
+ testsTable;
6
+ pool;
7
7
  constructor({ connectionString, tableNamePrefix, sslCa, sslCert, sslKey }) {
8
8
  super();
9
9
  const config = { connectionString };
@@ -15,9 +15,9 @@ class PostgreSQLAdapter extends core_1.Adapter {
15
15
  config.ssl.cert = sslCert;
16
16
  config.ssl.key = sslKey;
17
17
  }
18
- this.pool = new pg_1.Pool(config);
19
- this.configTable = (0, pg_1.escapeIdentifier)(`${tableNamePrefix}_test_runs`);
20
- this.testsTable = (0, pg_1.escapeIdentifier)(`${tableNamePrefix}_tests`);
18
+ this.pool = new pg.Pool(config);
19
+ this.configTable = pg.escapeIdentifier(`${tableNamePrefix}_test_runs`);
20
+ this.testsTable = pg.escapeIdentifier(`${tableNamePrefix}_tests`);
21
21
  }
22
22
  async getNextTest(runId, config) {
23
23
  const client = await this.pool.connect();
@@ -37,7 +37,7 @@ class PostgreSQLAdapter extends core_1.Adapter {
37
37
  FROM next_test
38
38
  WHERE t.run_id = $1 AND t.order_num = next_test.order_num
39
39
  RETURNING *`,
40
- values: [runId, core_1.TestStatus.Ready, core_1.TestStatus.Ongoing],
40
+ values: [runId, TestStatus.Ready, TestStatus.Ongoing],
41
41
  });
42
42
  await client.query('COMMIT');
43
43
  if (result.rowCount === 0)
@@ -53,10 +53,10 @@ class PostgreSQLAdapter extends core_1.Adapter {
53
53
  }
54
54
  }
55
55
  async finishTest(runId, test) {
56
- await this.updateTestStatus(runId, test, core_1.TestStatus.Passed);
56
+ await this.updateTestStatus(runId, test, TestStatus.Passed);
57
57
  }
58
58
  async failTest(runId, test) {
59
- await this.updateTestStatus(runId, test, core_1.TestStatus.Failed);
59
+ await this.updateTestStatus(runId, test, TestStatus.Failed);
60
60
  }
61
61
  async updateTestStatus(runId, test, status) {
62
62
  await this.pool.query({
@@ -71,7 +71,7 @@ class PostgreSQLAdapter extends core_1.Adapter {
71
71
  await this.pool.query({
72
72
  name: 'insert-config',
73
73
  text: `INSERT INTO ${this.configTable} (id, status, config) VALUES ($1, $2, $3)`,
74
- values: [runId, core_1.RunStatus.Created, JSON.stringify({ ...testRun.config, args })],
74
+ values: [runId, RunStatus.Created, JSON.stringify({ ...testRun.config, args })],
75
75
  });
76
76
  const tests = this.flattenTestRun(testRun.testRun);
77
77
  const fields = ['order_num', 'file', 'line', 'character', 'project', 'timeout'];
@@ -131,26 +131,26 @@ class PostgreSQLAdapter extends core_1.Adapter {
131
131
  throw new Error(`Run ${runId} not found`);
132
132
  }
133
133
  const { updated: updatedBefore, status: statusBefore } = result.rows[0];
134
- if (statusBefore === core_1.RunStatus.Created || statusBefore === core_1.RunStatus.Finished) {
134
+ if (statusBefore === RunStatus.Created || statusBefore === RunStatus.Finished) {
135
135
  await client.query({
136
136
  text: `
137
137
  UPDATE ${this.testsTable}
138
138
  SET updated = NOW(), status = $3
139
139
  WHERE run_id = $1 AND status = $2 AND updated <= $4;`,
140
- values: [runId, core_1.TestStatus.Failed, core_1.TestStatus.Ready, updatedBefore],
140
+ values: [runId, TestStatus.Failed, TestStatus.Ready, updatedBefore],
141
141
  });
142
142
  // using str interpolation for case statement to avoid casting ints to strings
143
143
  result = await client.query({
144
144
  text: `
145
145
  UPDATE ${this.configTable}
146
146
  SET status = (CASE
147
- WHEN status = $2 THEN ${core_1.RunStatus.Run}
148
- ELSE ${core_1.RunStatus.RepeatRun}
147
+ WHEN status = $2 THEN ${RunStatus.Run}
148
+ ELSE ${RunStatus.RepeatRun}
149
149
  END),
150
150
  updated = NOW()
151
151
  WHERE id = $1
152
152
  RETURNING *;`,
153
- values: [runId, core_1.RunStatus.Created],
153
+ values: [runId, RunStatus.Created],
154
154
  });
155
155
  }
156
156
  await client.query('COMMIT');
@@ -175,7 +175,7 @@ class PostgreSQLAdapter extends core_1.Adapter {
175
175
  SET status = $1,
176
176
  updated = NOW()
177
177
  WHERE id = $2`,
178
- values: [core_1.RunStatus.Finished, runId],
178
+ values: [RunStatus.Finished, runId],
179
179
  });
180
180
  }
181
181
  async dispose() {
@@ -184,4 +184,3 @@ class PostgreSQLAdapter extends core_1.Adapter {
184
184
  await this.pool.end();
185
185
  }
186
186
  }
187
- exports.PostgreSQLAdapter = PostgreSQLAdapter;
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@playwright-orchestrator/pg",
3
- "version": "1.1.0",
3
+ "version": "1.1.2",
4
4
  "keywords": [],
5
5
  "author": "Rostyslav Kudrevatykh",
6
6
  "license": "Apache-2.0",
@@ -13,18 +13,18 @@
13
13
  "dist"
14
14
  ],
15
15
  "dependencies": {
16
+ "@commander-js/extra-typings": "^13.0.0",
17
+ "@playwright-orchestrator/core": "^1.1.0",
18
+ "commander": "^13.0.0",
16
19
  "pg": "^8.13.1"
17
20
  },
18
21
  "devDependencies": {
19
22
  "@types/pg": "^8.11.0"
20
23
  },
21
- "peerDependencies": {
22
- "@commander-js/extra-typings": "^13.0.0",
23
- "@playwright-orchestrator/core": "^1.0.0"
24
- },
24
+ "main": "dist/index.js",
25
+ "type": "module",
25
26
  "exports": {
26
27
  ".": {
27
- "types": "./dist/index.d.ts",
28
28
  "default": "./dist/index.js"
29
29
  }
30
30
  },
package/dist/package.json DELETED
@@ -1,34 +0,0 @@
1
- {
2
- "name": "@playwright-orchestrator/pg",
3
- "version": "1.1.0",
4
- "keywords": [],
5
- "author": "Rostyslav Kudrevatykh",
6
- "license": "Apache-2.0",
7
- "description": "Playwright orchestrator PostgreSQL plugin",
8
- "repository": {
9
- "type": "git",
10
- "url": "git+https://github.com/rostmanrk/playwright-orchestrator.git"
11
- },
12
- "files": [
13
- "dist"
14
- ],
15
- "dependencies": {
16
- "pg": "^8.13.1"
17
- },
18
- "devDependencies": {
19
- "@types/pg": "^8.11.0"
20
- },
21
- "peerDependencies": {
22
- "@commander-js/extra-typings": "^13.0.0",
23
- "@playwright-orchestrator/core": "^1.0.0"
24
- },
25
- "exports": {
26
- ".": {
27
- "types": "./dist/index.d.ts",
28
- "default": "./dist/index.js"
29
- }
30
- },
31
- "scripts": {
32
- "prepare": "cp ../../LICENSE.md ./"
33
- }
34
- }
@@ -1 +0,0 @@
1
- {"root":["../create-args.ts","../index.ts","../postgresql-adapter.ts","../package.json"],"version":"5.7.2"}