@deephaven/jsapi-utils 1.12.1 → 1.16.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.
|
@@ -2,11 +2,26 @@ import type { dh } from '@deephaven/jsapi-types';
|
|
|
2
2
|
/** Default timeout for fetching a variable definition */
|
|
3
3
|
export declare const FETCH_TIMEOUT = 10000;
|
|
4
4
|
/**
|
|
5
|
-
* Fetch the definition for a variable given a connection.
|
|
5
|
+
* Fetch the definition for a variable given a connection. Waits for the next
|
|
6
|
+
* field update event and resolves if the variable is found in the created
|
|
7
|
+
* variables.
|
|
6
8
|
* @param connection Connection to get the variable from
|
|
7
9
|
* @param name Name of the definition to fetch
|
|
8
10
|
* @param timeout Timeout for the fetch
|
|
9
|
-
* @returns Promise
|
|
11
|
+
* @returns Promise that resolves to the variable definition if found in the next field update,
|
|
12
|
+
* or rejects if the variable is not found in that update or if the timeout is exceeded
|
|
10
13
|
*/
|
|
11
14
|
export declare function fetchVariableDefinition(connection: dh.IdeConnection, name: string, timeout?: number): Promise<dh.ide.VariableDefinition>;
|
|
15
|
+
/**
|
|
16
|
+
* Fetch the definition for a variable given a connection. Waits for the next
|
|
17
|
+
* field update event and resolves if a variable matching the predicate is found
|
|
18
|
+
* in the created variables.
|
|
19
|
+
* @param connection Connection to get the variable from
|
|
20
|
+
* @param predicate Predicate function to test each variable definition
|
|
21
|
+
* @param timeout Timeout for the fetch
|
|
22
|
+
* @param errorMessage Optional error message for timeout and not found errors
|
|
23
|
+
* @returns Promise that resolves to the variable definition if found in the next field update,
|
|
24
|
+
* or rejects if no matching variable is found in that update or if the timeout is exceeded
|
|
25
|
+
*/
|
|
26
|
+
export declare function fetchVariableDefinitionByPredicate(connection: dh.IdeConnection, predicate: (definition: dh.ide.VariableDefinition) => boolean, timeout?: number, errorMessage?: string): Promise<dh.ide.VariableDefinition>;
|
|
12
27
|
//# sourceMappingURL=ConnectionUtils.d.ts.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"ConnectionUtils.d.ts","sourceRoot":"","sources":["../src/ConnectionUtils.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,EAAE,EAAE,MAAM,wBAAwB,CAAC;AAGjD,yDAAyD;AACzD,eAAO,MAAM,aAAa,QAAS,CAAC;AAEpC
|
|
1
|
+
{"version":3,"file":"ConnectionUtils.d.ts","sourceRoot":"","sources":["../src/ConnectionUtils.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,EAAE,EAAE,MAAM,wBAAwB,CAAC;AAGjD,yDAAyD;AACzD,eAAO,MAAM,aAAa,QAAS,CAAC;AAEpC;;;;;;;;;GASG;AACH,wBAAgB,uBAAuB,CACrC,UAAU,EAAE,EAAE,CAAC,aAAa,EAC5B,IAAI,EAAE,MAAM,EACZ,OAAO,SAAgB,GACtB,OAAO,CAAC,EAAE,CAAC,GAAG,CAAC,kBAAkB,CAAC,CAOpC;AAED;;;;;;;;;;GAUG;AACH,wBAAgB,kCAAkC,CAChD,UAAU,EAAE,EAAE,CAAC,aAAa,EAC5B,SAAS,EAAE,CAAC,UAAU,EAAE,EAAE,CAAC,GAAG,CAAC,kBAAkB,KAAK,OAAO,EAC7D,OAAO,SAAgB,EACvB,YAAY,SAAuB,GAClC,OAAO,CAAC,EAAE,CAAC,GAAG,CAAC,kBAAkB,CAAC,CA0BpC"}
|
package/dist/ConnectionUtils.js
CHANGED
|
@@ -4,35 +4,55 @@ import { TimeoutError } from '@deephaven/utils';
|
|
|
4
4
|
export var FETCH_TIMEOUT = 10000;
|
|
5
5
|
|
|
6
6
|
/**
|
|
7
|
-
* Fetch the definition for a variable given a connection.
|
|
7
|
+
* Fetch the definition for a variable given a connection. Waits for the next
|
|
8
|
+
* field update event and resolves if the variable is found in the created
|
|
9
|
+
* variables.
|
|
8
10
|
* @param connection Connection to get the variable from
|
|
9
11
|
* @param name Name of the definition to fetch
|
|
10
12
|
* @param timeout Timeout for the fetch
|
|
11
|
-
* @returns Promise
|
|
13
|
+
* @returns Promise that resolves to the variable definition if found in the next field update,
|
|
14
|
+
* or rejects if the variable is not found in that update or if the timeout is exceeded
|
|
12
15
|
*/
|
|
13
16
|
export function fetchVariableDefinition(connection, name) {
|
|
14
17
|
var timeout = arguments.length > 2 && arguments[2] !== undefined ? arguments[2] : FETCH_TIMEOUT;
|
|
18
|
+
return fetchVariableDefinitionByPredicate(connection, def => def.title === name, timeout, "Variable ".concat(name, " not found"));
|
|
19
|
+
}
|
|
20
|
+
|
|
21
|
+
/**
|
|
22
|
+
* Fetch the definition for a variable given a connection. Waits for the next
|
|
23
|
+
* field update event and resolves if a variable matching the predicate is found
|
|
24
|
+
* in the created variables.
|
|
25
|
+
* @param connection Connection to get the variable from
|
|
26
|
+
* @param predicate Predicate function to test each variable definition
|
|
27
|
+
* @param timeout Timeout for the fetch
|
|
28
|
+
* @param errorMessage Optional error message for timeout and not found errors
|
|
29
|
+
* @returns Promise that resolves to the variable definition if found in the next field update,
|
|
30
|
+
* or rejects if no matching variable is found in that update or if the timeout is exceeded
|
|
31
|
+
*/
|
|
32
|
+
export function fetchVariableDefinitionByPredicate(connection, predicate) {
|
|
33
|
+
var timeout = arguments.length > 2 && arguments[2] !== undefined ? arguments[2] : FETCH_TIMEOUT;
|
|
34
|
+
var errorMessage = arguments.length > 3 && arguments[3] !== undefined ? arguments[3] : 'Variable not found';
|
|
15
35
|
return new Promise((resolve, reject) => {
|
|
16
36
|
var removeListener;
|
|
17
37
|
var timeoutId = setTimeout(() => {
|
|
18
38
|
var _removeListener;
|
|
19
39
|
(_removeListener = removeListener) === null || _removeListener === void 0 || _removeListener();
|
|
20
|
-
reject(new TimeoutError("Timeout
|
|
40
|
+
reject(new TimeoutError("Timeout: ".concat(errorMessage)));
|
|
21
41
|
}, timeout);
|
|
22
42
|
|
|
23
43
|
/**
|
|
24
|
-
* Checks if
|
|
44
|
+
* Checks if a variable matching the predicate is in the changes, and resolves the promise if it does
|
|
25
45
|
* @param changes Variables changes that have occurred
|
|
26
46
|
*/
|
|
27
47
|
function handleFieldUpdates(changes) {
|
|
28
48
|
var _removeListener2;
|
|
29
|
-
var definition = changes.created.find(
|
|
49
|
+
var definition = changes.created.find(predicate);
|
|
30
50
|
clearTimeout(timeoutId);
|
|
31
51
|
(_removeListener2 = removeListener) === null || _removeListener2 === void 0 || _removeListener2();
|
|
32
52
|
if (definition != null) {
|
|
33
53
|
resolve(definition);
|
|
34
54
|
} else {
|
|
35
|
-
reject(new Error(
|
|
55
|
+
reject(new Error(errorMessage));
|
|
36
56
|
}
|
|
37
57
|
}
|
|
38
58
|
removeListener = connection.subscribeToFieldUpdates(handleFieldUpdates);
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"ConnectionUtils.js","names":["TimeoutError","FETCH_TIMEOUT","fetchVariableDefinition","connection","name","timeout","arguments","length","undefined","Promise","resolve","reject","removeListener","timeoutId","setTimeout","_removeListener","
|
|
1
|
+
{"version":3,"file":"ConnectionUtils.js","names":["TimeoutError","FETCH_TIMEOUT","fetchVariableDefinition","connection","name","timeout","arguments","length","undefined","fetchVariableDefinitionByPredicate","def","title","concat","predicate","errorMessage","Promise","resolve","reject","removeListener","timeoutId","setTimeout","_removeListener","handleFieldUpdates","changes","_removeListener2","definition","created","find","clearTimeout","Error","subscribeToFieldUpdates"],"sources":["../src/ConnectionUtils.ts"],"sourcesContent":["import type { dh } from '@deephaven/jsapi-types';\nimport { TimeoutError } from '@deephaven/utils';\n\n/** Default timeout for fetching a variable definition */\nexport const FETCH_TIMEOUT = 10_000;\n\n/**\n * Fetch the definition for a variable given a connection. Waits for the next\n * field update event and resolves if the variable is found in the created\n * variables.\n * @param connection Connection to get the variable from\n * @param name Name of the definition to fetch\n * @param timeout Timeout for the fetch\n * @returns Promise that resolves to the variable definition if found in the next field update,\n * or rejects if the variable is not found in that update or if the timeout is exceeded\n */\nexport function fetchVariableDefinition(\n connection: dh.IdeConnection,\n name: string,\n timeout = FETCH_TIMEOUT\n): Promise<dh.ide.VariableDefinition> {\n return fetchVariableDefinitionByPredicate(\n connection,\n def => def.title === name,\n timeout,\n `Variable ${name} not found`\n );\n}\n\n/**\n * Fetch the definition for a variable given a connection. Waits for the next\n * field update event and resolves if a variable matching the predicate is found\n * in the created variables.\n * @param connection Connection to get the variable from\n * @param predicate Predicate function to test each variable definition\n * @param timeout Timeout for the fetch\n * @param errorMessage Optional error message for timeout and not found errors\n * @returns Promise that resolves to the variable definition if found in the next field update,\n * or rejects if no matching variable is found in that update or if the timeout is exceeded\n */\nexport function fetchVariableDefinitionByPredicate(\n connection: dh.IdeConnection,\n predicate: (definition: dh.ide.VariableDefinition) => boolean,\n timeout = FETCH_TIMEOUT,\n errorMessage = 'Variable not found'\n): Promise<dh.ide.VariableDefinition> {\n return new Promise<dh.ide.VariableDefinition>((resolve, reject) => {\n let removeListener: () => void;\n\n const timeoutId = setTimeout(() => {\n removeListener?.();\n reject(new TimeoutError(`Timeout: ${errorMessage}`));\n }, timeout);\n\n /**\n * Checks if a variable matching the predicate is in the changes, and resolves the promise if it does\n * @param changes Variables changes that have occurred\n */\n function handleFieldUpdates(changes: dh.ide.VariableChanges): void {\n const definition = changes.created.find(predicate);\n clearTimeout(timeoutId);\n removeListener?.();\n if (definition != null) {\n resolve(definition);\n } else {\n reject(new Error(errorMessage));\n }\n }\n\n removeListener = connection.subscribeToFieldUpdates(handleFieldUpdates);\n });\n}\n"],"mappings":"AACA,SAASA,YAAY,QAAQ,kBAAkB;;AAE/C;AACA,OAAO,IAAMC,aAAa,GAAG,KAAM;;AAEnC;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA,OAAO,SAASC,uBAAuBA,CACrCC,UAA4B,EAC5BC,IAAY,EAEwB;EAAA,IADpCC,OAAO,GAAAC,SAAA,CAAAC,MAAA,QAAAD,SAAA,QAAAE,SAAA,GAAAF,SAAA,MAAGL,aAAa;EAEvB,OAAOQ,kCAAkC,CACvCN,UAAU,EACVO,GAAG,IAAIA,G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CAAC;AACJ","ignoreList":[]}
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@deephaven/jsapi-utils",
|
|
3
|
-
"version": "1.
|
|
3
|
+
"version": "1.16.0",
|
|
4
4
|
"description": "Deephaven JSAPI Utils",
|
|
5
5
|
"author": "Deephaven Data Labs LLC",
|
|
6
6
|
"license": "Apache-2.0",
|
|
@@ -39,5 +39,5 @@
|
|
|
39
39
|
"publishConfig": {
|
|
40
40
|
"access": "public"
|
|
41
41
|
},
|
|
42
|
-
"gitHead": "
|
|
42
|
+
"gitHead": "33a489fbfa08dd8000983267ddae69217db90224"
|
|
43
43
|
}
|