@wdio/shared-store-service 8.33.0 → 9.0.0-alpha.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.
- package/build/cjs/package.json +3 -1
- package/build/client.d.ts +4 -4
- package/build/client.d.ts.map +1 -1
- package/build/client.js +35 -13
- package/package.json +7 -8
package/build/cjs/package.json
CHANGED
package/build/client.d.ts
CHANGED
|
@@ -12,23 +12,23 @@ export declare const getValue: (key: string) => Promise<string | number | boolea
|
|
|
12
12
|
* @param {string} key
|
|
13
13
|
* @param {*} value `store[key]` value (plain object)
|
|
14
14
|
*/
|
|
15
|
-
export declare const setValue: (key: string, value: JsonCompatible | JsonPrimitive) => Promise<
|
|
15
|
+
export declare const setValue: (key: string, value: JsonCompatible | JsonPrimitive) => Promise<number | void>;
|
|
16
16
|
/**
|
|
17
17
|
*
|
|
18
18
|
* @param {string} key
|
|
19
19
|
* @param {*} value
|
|
20
20
|
*/
|
|
21
|
-
export declare const setResourcePool: (key: string, value: JsonArray) => Promise<
|
|
21
|
+
export declare const setResourcePool: (key: string, value: JsonArray) => Promise<number | void>;
|
|
22
22
|
/**
|
|
23
23
|
*
|
|
24
24
|
* @param {string} key
|
|
25
25
|
* @param {*} value
|
|
26
26
|
*/
|
|
27
|
-
export declare const getValueFromPool: (key: string, options?: GetValueOptions) => Promise<
|
|
27
|
+
export declare const getValueFromPool: (key: string, options?: GetValueOptions) => Promise<any>;
|
|
28
28
|
/**
|
|
29
29
|
*
|
|
30
30
|
* @param {string} key
|
|
31
31
|
* @param {*} value
|
|
32
32
|
*/
|
|
33
|
-
export declare const addValueToPool: (key: string, value: JsonPrimitive | JsonCompatible) => Promise<
|
|
33
|
+
export declare const addValueToPool: (key: string, value: JsonPrimitive | JsonCompatible) => Promise<number>;
|
|
34
34
|
//# sourceMappingURL=client.d.ts.map
|
package/build/client.d.ts.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"client.d.ts","sourceRoot":"","sources":["../src/client.ts"],"names":[],"mappings":"
|
|
1
|
+
{"version":3,"file":"client.d.ts","sourceRoot":"","sources":["../src/client.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,cAAc,EAAE,aAAa,EAAE,UAAU,EAAE,SAAS,EAAE,MAAM,aAAa,CAAA;AACvF,OAAO,KAAK,EAAE,eAAe,EAAE,MAAM,YAAY,CAAA;AAYjD,eAAO,MAAM,OAAO,SAAU,MAAM,SAQnC,CAAA;AAED;;;;GAIG;AACH,eAAO,MAAM,QAAQ,QAAe,MAAM,KAAG,QAAQ,MAAM,GAAG,MAAM,GAAG,OAAO,GAAG,UAAU,GAAG,SAAS,GAAG,IAAI,GAAG,SAAS,CAWzH,CAAA;AAED;;;;GAIG;AACH,eAAO,MAAM,QAAQ,QAAe,MAAM,SAAS,cAAc,GAAG,aAAa,2BAUhF,CAAA;AAED;;;;GAIG;AACH,eAAO,MAAM,eAAe,QAAe,MAAM,6CAUhD,CAAA;AAED;;;;GAIG;AACH,eAAO,MAAM,gBAAgB,QAAe,MAAM,YAAY,eAAe,iBAW5E,CAAA;AAED;;;;GAIG;AACH,eAAO,MAAM,cAAc,QAAe,MAAM,SAAS,aAAa,GAAG,cAAc,oBAWtF,CAAA"}
|
package/build/client.js
CHANGED
|
@@ -1,8 +1,10 @@
|
|
|
1
|
-
import got from 'got';
|
|
2
1
|
let baseUrlResolve;
|
|
3
2
|
const baseUrlPromise = new Promise((resolve) => {
|
|
4
3
|
baseUrlResolve = resolve;
|
|
5
4
|
});
|
|
5
|
+
const headers = {
|
|
6
|
+
'Content-Type': 'application/json'
|
|
7
|
+
};
|
|
6
8
|
let isBaseUrlReady = false;
|
|
7
9
|
export const setPort = (port) => {
|
|
8
10
|
/**
|
|
@@ -23,8 +25,12 @@ export const getValue = async (key) => {
|
|
|
23
25
|
throw new Error('Attempting to use `getValue` before the server has been initialized.');
|
|
24
26
|
}
|
|
25
27
|
const baseUrl = await baseUrlPromise;
|
|
26
|
-
const res = await
|
|
27
|
-
|
|
28
|
+
const res = await fetch(`${baseUrl}/${key}`, {
|
|
29
|
+
method: 'get',
|
|
30
|
+
headers
|
|
31
|
+
}).catch(errHandler);
|
|
32
|
+
const responseBody = await res.json();
|
|
33
|
+
return responseBody.value ?? undefined;
|
|
28
34
|
};
|
|
29
35
|
/**
|
|
30
36
|
* make a request to the server to set a value to the store
|
|
@@ -33,9 +39,13 @@ export const getValue = async (key) => {
|
|
|
33
39
|
*/
|
|
34
40
|
export const setValue = async (key, value) => {
|
|
35
41
|
const setPromise = baseUrlPromise.then((baseUrl) => {
|
|
36
|
-
return
|
|
42
|
+
return fetch(`${baseUrl}/`, {
|
|
43
|
+
method: 'post',
|
|
44
|
+
body: JSON.stringify({ key, value }),
|
|
45
|
+
headers
|
|
46
|
+
}).catch(errHandler);
|
|
37
47
|
});
|
|
38
|
-
return isBaseUrlReady ? setPromise : Promise.resolve();
|
|
48
|
+
return isBaseUrlReady ? (await setPromise).status : Promise.resolve();
|
|
39
49
|
};
|
|
40
50
|
/**
|
|
41
51
|
*
|
|
@@ -44,9 +54,13 @@ export const setValue = async (key, value) => {
|
|
|
44
54
|
*/
|
|
45
55
|
export const setResourcePool = async (key, value) => {
|
|
46
56
|
const setPromise = baseUrlPromise.then((baseUrl) => {
|
|
47
|
-
return
|
|
57
|
+
return fetch(`${baseUrl}/pool`, {
|
|
58
|
+
method: 'post',
|
|
59
|
+
body: JSON.stringify({ key, value }),
|
|
60
|
+
headers
|
|
61
|
+
}).catch(errHandler);
|
|
48
62
|
});
|
|
49
|
-
return isBaseUrlReady ? setPromise : Promise.resolve();
|
|
63
|
+
return isBaseUrlReady ? (await setPromise).status : Promise.resolve();
|
|
50
64
|
};
|
|
51
65
|
/**
|
|
52
66
|
*
|
|
@@ -58,8 +72,12 @@ export const getValueFromPool = async (key, options) => {
|
|
|
58
72
|
throw new Error('Attempting to use `getValueFromPool` before the server has been initialized.');
|
|
59
73
|
}
|
|
60
74
|
const baseUrl = await baseUrlPromise;
|
|
61
|
-
const res = await
|
|
62
|
-
|
|
75
|
+
const res = await fetch(`${baseUrl}/pool/${key}${typeof options?.timeout === 'number' ? `?timeout=${options.timeout}` : ''}`, {
|
|
76
|
+
method: 'get',
|
|
77
|
+
headers
|
|
78
|
+
}).catch(errHandler);
|
|
79
|
+
const responseBody = await res.json();
|
|
80
|
+
return responseBody.value ?? undefined;
|
|
63
81
|
};
|
|
64
82
|
/**
|
|
65
83
|
*
|
|
@@ -71,9 +89,13 @@ export const addValueToPool = async (key, value) => {
|
|
|
71
89
|
throw new Error('Attempting to use `addValueToPool` before the server has been initialized.');
|
|
72
90
|
}
|
|
73
91
|
const baseUrl = await baseUrlPromise;
|
|
74
|
-
const res = await
|
|
75
|
-
|
|
92
|
+
const res = await fetch(`${baseUrl}/pool/${key}`, {
|
|
93
|
+
method: 'post',
|
|
94
|
+
body: JSON.stringify({ value }),
|
|
95
|
+
headers
|
|
96
|
+
}).catch(errHandler);
|
|
97
|
+
return res.status;
|
|
76
98
|
};
|
|
77
|
-
const errHandler = (err) => {
|
|
78
|
-
throw new Error(`${err.
|
|
99
|
+
const errHandler = async (err) => {
|
|
100
|
+
throw new Error(`${err.message || 'Shared store server threw an error'}`);
|
|
79
101
|
};
|
package/package.json
CHANGED
|
@@ -1,12 +1,12 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@wdio/shared-store-service",
|
|
3
|
-
"version": "
|
|
3
|
+
"version": "9.0.0-alpha.0",
|
|
4
4
|
"description": "A WebdriverIO service to exchange data across processes",
|
|
5
5
|
"author": "Mykola Grybyk <mykola.grybyk@gmail.com>",
|
|
6
6
|
"homepage": "https://github.com/webdriverio/webdriverio/tree/main/packages/wdio-shared-store-service",
|
|
7
7
|
"license": "MIT",
|
|
8
8
|
"engines": {
|
|
9
|
-
"node": "
|
|
9
|
+
"node": ">=18"
|
|
10
10
|
},
|
|
11
11
|
"repository": {
|
|
12
12
|
"type": "git",
|
|
@@ -40,17 +40,16 @@
|
|
|
40
40
|
"typeScriptVersion": "3.8.3",
|
|
41
41
|
"dependencies": {
|
|
42
42
|
"@polka/parse": "^1.0.0-next.0",
|
|
43
|
-
"@wdio/logger": "
|
|
44
|
-
"@wdio/types": "
|
|
45
|
-
"got": "^12.6.1",
|
|
43
|
+
"@wdio/logger": "9.0.0-alpha.0",
|
|
44
|
+
"@wdio/types": "9.0.0-alpha.0",
|
|
46
45
|
"polka": "^0.5.2",
|
|
47
|
-
"webdriverio": "
|
|
46
|
+
"webdriverio": "9.0.0-alpha.0"
|
|
48
47
|
},
|
|
49
48
|
"devDependencies": {
|
|
50
|
-
"@wdio/globals": "
|
|
49
|
+
"@wdio/globals": "9.0.0-alpha.0"
|
|
51
50
|
},
|
|
52
51
|
"publishConfig": {
|
|
53
52
|
"access": "public"
|
|
54
53
|
},
|
|
55
|
-
"gitHead": "
|
|
54
|
+
"gitHead": "75d45a1efff8705785f0fbcd2379ac624d16e007"
|
|
56
55
|
}
|