@testmuai/playwright-bindings 0.1.4 → 0.1.5-beta.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.
|
@@ -2,8 +2,10 @@ export interface DbRequest {
|
|
|
2
2
|
query: string;
|
|
3
3
|
db_id: string;
|
|
4
4
|
db_name: string;
|
|
5
|
-
timeout?: number;
|
|
5
|
+
timeout?: number | string;
|
|
6
6
|
tunnel_id?: string;
|
|
7
|
+
auth_header?: string;
|
|
8
|
+
automind_url?: string;
|
|
7
9
|
}
|
|
8
10
|
export declare function executeDb(req: DbRequest): Promise<unknown>;
|
|
9
11
|
//# sourceMappingURL=executeDb.d.ts.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"executeDb.d.ts","sourceRoot":"","sources":["../../src/helpers/executeDb.ts"],"names":[],"mappings":"AAIA,MAAM,WAAW,SAAS;IACxB,KAAK,EAAE,MAAM,CAAC;IACd,KAAK,EAAE,MAAM,CAAC;IACd,OAAO,EAAE,MAAM,CAAC;IAChB,OAAO,CAAC,EAAE,MAAM,CAAC;
|
|
1
|
+
{"version":3,"file":"executeDb.d.ts","sourceRoot":"","sources":["../../src/helpers/executeDb.ts"],"names":[],"mappings":"AAIA,MAAM,WAAW,SAAS;IACxB,KAAK,EAAE,MAAM,CAAC;IACd,KAAK,EAAE,MAAM,CAAC;IACd,OAAO,EAAE,MAAM,CAAC;IAChB,OAAO,CAAC,EAAE,MAAM,GAAG,MAAM,CAAC;IAC1B,SAAS,CAAC,EAAE,MAAM,CAAC;IAInB,WAAW,CAAC,EAAE,MAAM,CAAC;IACrB,YAAY,CAAC,EAAE,MAAM,CAAC;CACvB;AAED,wBAAsB,SAAS,CAAC,GAAG,EAAE,SAAS,GAAG,OAAO,CAAC,OAAO,CAAC,CAuDhE"}
|
|
@@ -1,23 +1,54 @@
|
|
|
1
|
-
import {
|
|
1
|
+
import { ltAuthHeader } from '../http.js';
|
|
2
2
|
import { TestmuConfigError } from '../errors.js';
|
|
3
3
|
import { log } from '../log.js';
|
|
4
4
|
export async function executeDb(req) {
|
|
5
|
-
|
|
5
|
+
// Prefer codegen-passed auth_header (base64 user:key); fall back to env.
|
|
6
|
+
// Mirrors PY execute_db.py:101-105.
|
|
7
|
+
const auth = req.auth_header ? `Basic ${req.auth_header}` : ltAuthHeader();
|
|
8
|
+
if (!auth)
|
|
6
9
|
throw new TestmuConfigError('executeDb requires LT creds');
|
|
7
10
|
log.helper(`[execute_db] db_id=${JSON.stringify(req.db_id)} db_name=${JSON.stringify(req.db_name)}`);
|
|
8
|
-
|
|
9
|
-
|
|
11
|
+
// Prefer codegen-passed automind_url, then env, then prod default.
|
|
12
|
+
// Mirrors PY execute_db.py:99-100 — uses truthy ("" falls through),
|
|
13
|
+
// NOT nullish (??), because codegen emits "" for unset fields.
|
|
14
|
+
const automindUrl = (req.automind_url || process.env['AUTOMIND_URL'] || 'https://kaneai-api.lambdatest.com').replace(/\/$/, '');
|
|
15
|
+
const tunnelId = req.tunnel_id || process.env['LT_PROXY_TUNNEL_ID'] || '';
|
|
16
|
+
// Coerce string timeout to int; default to 10000 on parse failure.
|
|
17
|
+
// Mirrors PY execute_db.py:33-38.
|
|
18
|
+
let timeout = 10_000;
|
|
19
|
+
if (typeof req.timeout === 'number' && Number.isFinite(req.timeout)) {
|
|
20
|
+
timeout = req.timeout;
|
|
21
|
+
}
|
|
22
|
+
else if (typeof req.timeout === 'string') {
|
|
23
|
+
const n = parseInt(req.timeout, 10);
|
|
24
|
+
if (Number.isFinite(n))
|
|
25
|
+
timeout = n;
|
|
26
|
+
}
|
|
10
27
|
const payload = {
|
|
11
28
|
query: req.query,
|
|
12
|
-
payload: {
|
|
29
|
+
payload: {
|
|
30
|
+
id: req.db_id,
|
|
31
|
+
db_name: req.db_name,
|
|
32
|
+
timeout,
|
|
33
|
+
tunnel_id: tunnelId,
|
|
34
|
+
},
|
|
13
35
|
};
|
|
14
|
-
|
|
36
|
+
// Direct fetch (not fetchWithAuth) so we don't send x-session-id /
|
|
37
|
+
// x-source headers — PY execute_db.py sends only content-type +
|
|
38
|
+
// Authorization, and the /db-query endpoint behaves differently when
|
|
39
|
+
// those extra headers are present.
|
|
40
|
+
const resp = await fetch(`${automindUrl}/db-query`, {
|
|
15
41
|
method: 'POST',
|
|
16
|
-
headers: {
|
|
42
|
+
headers: {
|
|
43
|
+
'content-type': 'application/json',
|
|
44
|
+
Authorization: auth,
|
|
45
|
+
},
|
|
17
46
|
body: JSON.stringify(payload),
|
|
18
47
|
});
|
|
19
|
-
if (!resp.ok)
|
|
20
|
-
|
|
48
|
+
if (!resp.ok) {
|
|
49
|
+
const body = await resp.text().catch(() => '');
|
|
50
|
+
throw new Error(`executeDb failed: HTTP ${resp.status} ${body}`.trim());
|
|
51
|
+
}
|
|
21
52
|
return await resp.json();
|
|
22
53
|
}
|
|
23
54
|
//# sourceMappingURL=executeDb.js.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"executeDb.js","sourceRoot":"","sources":["../../src/helpers/executeDb.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,
|
|
1
|
+
{"version":3,"file":"executeDb.js","sourceRoot":"","sources":["../../src/helpers/executeDb.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,YAAY,EAAE,MAAM,YAAY,CAAC;AAC1C,OAAO,EAAE,iBAAiB,EAAE,MAAM,cAAc,CAAC;AACjD,OAAO,EAAE,GAAG,EAAE,MAAM,WAAW,CAAC;AAehC,MAAM,CAAC,KAAK,UAAU,SAAS,CAAC,GAAc;IAC5C,yEAAyE;IACzE,oCAAoC;IACpC,MAAM,IAAI,GAAG,GAAG,CAAC,WAAW,CAAC,CAAC,CAAC,SAAS,GAAG,CAAC,WAAW,EAAE,CAAC,CAAC,CAAC,YAAY,EAAE,CAAC;IAC3E,IAAI,CAAC,IAAI;QAAE,MAAM,IAAI,iBAAiB,CAAC,6BAA6B,CAAC,CAAC;IAEtE,GAAG,CAAC,MAAM,C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