@deephaven-enterprise/jsapi-nodejs 2026.1.43

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/LICENSE.md ADDED
@@ -0,0 +1,136 @@
1
+ Deephaven Data Labs is dedicated to developing Deephaven's software in the open
2
+ and is making software available under the following licenses:
3
+
4
+ - **Deephaven Open Source** is made available under the Apache 2.0 License
5
+ - **Deephaven Community** is provided under a source-available license, the
6
+ Deephaven Community License Agreement
7
+
8
+ To request a commercial license for software or uses not covered by these
9
+ licenses or to ask any license-related question, please contact us at:
10
+ [license@deephaven.io](mailto:license@deephaven.io)
11
+
12
+
13
+ # Deephaven Community License Agreement Version 1.0
14
+
15
+ 1. **ACCEPTANCE.** This Deephaven Community License Agreement is entered into by
16
+ and between Deephaven Data Labs LLC, a Delaware Limited Liability Company, with
17
+ an address of 2800 Niagara Lane North, Plymouth, MN 55447 ("Deephaven") and
18
+ “You” (a) in your individual capacity, or (b) on behalf of your company if you
19
+ are licensing the Software for a company for which or with which you work. By
20
+ using the Software, You agree to all of the terms and conditions in this
21
+ Deephaven Community License Agreement (the "Agreement").
22
+
23
+ 2. **THE SOFTWARE.** The "Software" means the version of the Deephaven Community
24
+ Software provided to the original licensee with this Agreement. The Software may
25
+ include third party owned code. Each third party module is subject to the terms
26
+ of its respective license; the details of which can be found in the notices
27
+ served at [https://github.com/deephaven/deephaven-core](https://github.com/deephaven/deephaven-core).
28
+ Since licensees may contribute back to the Software as provided for in Section
29
+ 3(b), the Software may include any such contributions.
30
+
31
+ 3. **GRANT OF LICENSE.** Subject to the terms and conditions of this Agreement,
32
+ Deephaven hereby grants You a royalty-free, worldwide, non-exclusive,
33
+ non-transferable license to the Software (the "License"), subject, in all of the
34
+ cases, to applicable laws and regulations, but not for the Prohibited Use (as
35
+ provided for in Section 4), solely as follows:
36
+
37
+ - a. **Internal Use.** A license to use, copy, compile, and install the
38
+ Software for Your internal use;
39
+
40
+ - b. **Derivative Works.** A license to (i) prepare, develop, compile, and test
41
+ Derivative Works of the Software, (ii) use Your Derivative Works for Your
42
+ internal use solely as expressly permitted in Section 3(a), and (iii) distribute
43
+ Your Derivative Works back to Deephaven under a separate Deephaven Contributor
44
+ Agreement for potential incorporation into the Software at Deephaven's sole
45
+ discretion. A "Derivative Work" means any work that (A) is based on or derived
46
+ from the Software including any modifications to the Software, or (B) meets the
47
+ definition of derivative work under the United States Copyright Act of 1976, 17
48
+ U.S.C. Section 101; and
49
+
50
+ - c. **Distribution and redistribution.** A license to distribute or
51
+ redistribute the Software and Your Derivative Works, and copies of the Software
52
+ and Your Derivative Works, to customers and other third parties for their use
53
+ pursuant to this Agreement subject to the prohibitions in Section 4 and
54
+ Agreement requirement as provided for in Section 5.
55
+
56
+ 4. **PROHIBITED USE.** Notwithstanding any provision of this Agreement to the
57
+ contrary, the original licensee is prohibited from using, distributing, or
58
+ deploying the Software or Derivative Works in such a way that a third party
59
+ (including any recipient under Section 3(c)) can, directly or indirectly
60
+ through the original licensee, its agents, its technology, or solutions made
61
+ available to them, add, define, redefine, or modify the schema for any input
62
+ tables (including source tables, or other input objects) that the Software or
63
+ Derivative Works access. For clarification, every recipient of the Software or
64
+ Derivative Works after the original licensee of the Software is prohibited from
65
+ adding, defining, redefining, or modifying the schema for any input tables
66
+ (including source tables, or other input objects) that the Software or
67
+ Derivative Works access. This prohibition in no way affects the ability of a
68
+ third party to add, define, redefine, or modify the schema of output tables
69
+ (including output tables that are interim or derived). Further, this
70
+ prohibition in no way affects the ability of a third party to add, define,
71
+ redefine, or modify data (as opposed to schema), nor does it cause You to be
72
+ limited in any capacity for Your internal use as permitted in Section 3(a). If
73
+ You have any questions on this prohibition, please contact us at:
74
+ [license@deephaven.io](mailto:license@deephaven.io)
75
+
76
+ 5. **AGREEMENT.** If You distribute the Software, whether directly, as a copy,
77
+ or via Your Derivative Works you must provide recipients a copy of this
78
+ Agreement (which will bind each recipient directly) and You must ensure that all
79
+ copyright, patent, trademark, and attribution notices from the Software are
80
+ retained.
81
+
82
+ 6. **AFFILIATES.** You may permit Your affiliates to exercise the License,
83
+ provided that such exercise must be solely for Your benefit and/or the benefit
84
+ of Your affiliate, and You shall be responsible for all acts and omissions of
85
+ such affiliates in connection with such exercise of the License, including but
86
+ not limited to breach of any terms of this Agreement.
87
+
88
+ 7. **SUBLICENSE.** The License is sublicensable only to Your third-party
89
+ subcontractors and contractors performing services on Your or Your affiliates'
90
+ behalf, subject to the terms and conditions of this Agreement. The License is
91
+ not sublicensable to any other third party nor is it further sublicensable. You
92
+ shall be responsible for all acts and omissions of such subcontractor and
93
+ contractors in connection with such exercise of the sublicense, including but
94
+ not limited to breach of any terms of this Agreement.
95
+
96
+ 8. **PATENTS.** Rights to use the Software do not give You any right to
97
+ implement or use Deephaven's patents independently of the permitted use of the
98
+ Software.
99
+
100
+ 9. **RESERVATION OF RIGHTS.** Deephaven reserves all rights not granted in this
101
+ Agreement. You have no right to use Deephaven trade names, trademarks, service
102
+ marks, or product names except as required for reasonable and customary use in
103
+ describing the origin of the Software.
104
+
105
+ 10. **DISCLAIMER OF WARRANTY.** THE SOFTWARE IS LICENSED ON AN "AS IS" BASIS
106
+ WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND. DEEPHAVEN DISCLAIMS ALL
107
+ WARRANTIES, EXPRESS OR IMPLIED, INCLUDING, WITHOUT LIMITATION, ANY WARRANTIES OF
108
+ TITLE, NON-INFRINGEMENT, MERCHANTABILITY, OR FITNESS FOR A PARTICULAR PURPOSE.
109
+ You are solely responsible for determining the appropriateness of using,
110
+ distributing or redistributing the Software and Derivative Works and assume all
111
+ risks associated with Your exercise of the License.
112
+
113
+ 11. **INDEMNIFICATION.** If You distribute or redistribute the Software or
114
+ Derivative Works, You agree to defend on request, and indemnify, Deephaven and
115
+ its affiliates, officers, directors, employees and agents from and against any
116
+ and all losses, damages, liabilities, claims, costs and expenses (including
117
+ reasonable attorney’s fees and expenses) incurred or arising from the
118
+ exploitation of the Software or Derivative Works.
119
+
120
+ 12. **LIMITATION OF LIABILITY.** THE LICENSE IS GRANTED FOR NO FEE. IN NO EVENT
121
+ AND UNDER NO LEGAL THEORY, WHETHER IN TORT (INCLUDING NEGLIGENCE), CONTRACT, OR
122
+ OTHERWISE, SHALL DEEPHAVEN BE LIABLE FOR ANY DAMAGES ARISING OUT OF OR AS A
123
+ RESULT OF THIS AGREEMENT, INCLUDING ANY DIRECT, INDIRECT, SPECIAL, INCIDENTAL,
124
+ OR CONSEQUENTIAL DAMAGES (INCLUDING BUT NOT LIMITED TO DAMAGES FOR LOSS OF
125
+ GOODWILL, WORK STOPPAGE, COMPUTER FAILURE OR MALFUNCTION, OR LOSS OR CORRUPTION
126
+ OF DATA), EVEN IF DEEPHAVEN HAS BEEN ADVISED OF THE POSSIBILITY OF SUCH DAMAGES.
127
+
128
+ 13. **TERMINATION.** The License will automatically terminate if You violate the
129
+ use rights or prohibitions in this Agreement.
130
+
131
+ 14. **GOVERNING LAW.** This Agreement will be interpreted, construed and
132
+ enforced in all respects in accordance with the laws of the State of Delaware,
133
+ USA without reference to its choice of law rules to the contrary.
134
+
135
+
136
+ # END OF AGREEMENT
package/README.md ADDED
@@ -0,0 +1,83 @@
1
+ # @deephaven-enterprise/jsapi-nodejs
2
+
3
+ Deephaven Enterprise JS API Utils for NodeJS.
4
+
5
+ ## Quickstart
6
+
7
+ Create an interactive console query and run a script against it.
8
+
9
+ ```typescript
10
+ import {
11
+ createInteractiveConsoleQuery,
12
+ createPasswordCredentials,
13
+ initCorePlusManager,
14
+ } from '@deephaven-enterprise/jsapi-nodejs';
15
+
16
+ const serverUrl = new URL('https://my-dhe-server:8000/');
17
+
18
+ const credentials = createPasswordCredentials('my-username', 'my-password');
19
+
20
+ const corePlusManager = await initCorePlusManager({
21
+ serverUrl,
22
+ credentials,
23
+ });
24
+
25
+ const { cn } = await createInteractiveConsoleQuery(corePlusManager, {
26
+ name: 'my-worker-query',
27
+ });
28
+
29
+ const session = await cn.startSession('python');
30
+ const { changes } = await session.runCode(
31
+ 'from deephaven import time_table\nt = time_table("PT1S")'
32
+ );
33
+
34
+ console.log('Created table:', changes.created[0].name);
35
+ ```
36
+
37
+ ## Subscribe to the WebClientData query config table
38
+
39
+ ```js
40
+ import type { dh as DhType } from '@deephaven/jsapi-types';
41
+ import {
42
+ createPasswordCredentials,
43
+ createQueryConfigViewportSubscription,
44
+ initCorePlusManager,
45
+ } from '@deephaven-enterprise/jsapi-nodejs';
46
+
47
+ const serverUrl = new URL('https://my-dhe-server:8000/');
48
+
49
+ const credentials = createPasswordCredentials('my-username', 'my-password');
50
+
51
+ const corePlusManager = await initCorePlusManager({
52
+ serverUrl,
53
+ credentials,
54
+ });
55
+ const { dhe } = corePlusManager;
56
+
57
+ const subscription = await createQueryConfigViewportSubscription({
58
+ columnNames: ['Name', 'Status'],
59
+ corePlusManager,
60
+ });
61
+
62
+ subscription.addEventListener<DhType.ViewportData>(
63
+ dhe.Table.EVENT_UPDATED,
64
+ ({ detail }) => {
65
+ console.log('\nQuery config updated:')
66
+
67
+ for (const row of detail.rows) {
68
+ console.log(
69
+ detail.columns.map((col) => `${col.name}=${row.get(col)}`).join(', '),
70
+ )
71
+ }
72
+ },
73
+ )
74
+ ```
75
+
76
+ ## TLS / self-signed certificates
77
+
78
+ For servers using self-signed or internal-CA certificates, point Node at the CA
79
+ bundle via the `NODE_EXTRA_CA_CERTS` environment variable:
80
+
81
+ ```sh
82
+ export NODE_EXTRA_CA_CERTS=/path/to/ca.pem
83
+ ```
@@ -0,0 +1,26 @@
1
+ import { type CoreApiLoader, type CoreClientFactory, type EnterpriseApiLoader, type EnterpriseClientFactory } from '@deephaven-enterprise/client-utils';
2
+ import type { dh as DhType } from '@deephaven/jsapi-types';
3
+ import type { EnterpriseDhType as DheType } from '@deephaven-enterprise/jsapi-types';
4
+ declare global {
5
+ var iris: DheType;
6
+ }
7
+ export declare const DEFAULT_JS_API_STORAGE_DIR: string;
8
+ export interface JsApiFactories {
9
+ createCoreClient: CoreClientFactory;
10
+ createEnterpriseClient: EnterpriseClientFactory;
11
+ loadCorePlusApi: CoreApiLoader;
12
+ loadEnterpriseApi: EnterpriseApiLoader;
13
+ }
14
+ /**
15
+ * Create a set of factories for creating connected clients and loading APIs.
16
+ * @param storageDir The directory to store downloaded jsapi files. Defaults to
17
+ * a temporary directory.
18
+ * @param transportFactory The transport factory to use for connections. Defaults
19
+ * to NodeHttp2gRPCTransport.factory.
20
+ * @returns An object containing factories for creating clients and loading APIs.
21
+ */
22
+ export declare function createJsApiFactories({ storageDir, transportFactory, }?: {
23
+ storageDir?: string;
24
+ transportFactory?: DhType.ConnectOptions['transportFactory'];
25
+ }): JsApiFactories;
26
+ export default createJsApiFactories;
@@ -0,0 +1,76 @@
1
+ import os from 'node:os';
2
+ import path from 'node:path';
3
+ import { createCoreClient, createEnterpriseClient, } from '@deephaven-enterprise/client-utils';
4
+ import { loadDhModules, loadModules, NodeHttp2gRPCTransport, } from '@deephaven/jsapi-nodejs';
5
+ import { polyfill, polyfillLocation } from "./polyfill.js";
6
+ export const DEFAULT_JS_API_STORAGE_DIR = path.join(os.tmpdir(), 'deephaven-jsapi');
7
+ /**
8
+ * Create a set of factories for creating connected clients and loading APIs.
9
+ * @param storageDir The directory to store downloaded jsapi files. Defaults to
10
+ * a temporary directory.
11
+ * @param transportFactory The transport factory to use for connections. Defaults
12
+ * to NodeHttp2gRPCTransport.factory.
13
+ * @returns An object containing factories for creating clients and loading APIs.
14
+ */
15
+ export function createJsApiFactories({ storageDir = DEFAULT_JS_API_STORAGE_DIR, transportFactory = NodeHttp2gRPCTransport.factory, } = {}) {
16
+ return {
17
+ /**
18
+ * Create a connected, unauthenticated Core client.
19
+ * @param dh The dh JsApi.
20
+ * @param serverUrl The server URL.
21
+ * @param envoyPrefix Optional Envoy prefix to include in the request headers.
22
+ * If set, this will override any `envoy-prefix` header provided in
23
+ * `connectOptions`.
24
+ * @param connectOptions Optional connection options.
25
+ * @returns A promise that resolves to the connected Core client.
26
+ */
27
+ createCoreClient(dh, serverUrl, envoyPrefix, connectOptions) {
28
+ return createCoreClient(dh, serverUrl, envoyPrefix, Object.assign({ transportFactory }, connectOptions));
29
+ },
30
+ /**
31
+ * Create a connected, unauthenticated DHE client.
32
+ * @param dhe The DHE JsApi.
33
+ * @param serverUrl The DHE server URL.
34
+ * @param connectOptions Optional connection options.
35
+ * @returns A connected, unauthenticated DHE client.
36
+ */
37
+ async createEnterpriseClient(dhe, serverUrl, connectOptions) {
38
+ return createEnterpriseClient(dhe, serverUrl, Object.assign({ transportFactory }, connectOptions));
39
+ },
40
+ /**
41
+ * Load the DH Core+ jsapi for a worker from a running server and return the
42
+ * `dh` object.
43
+ * @param jsApiUrl The worker's `jsApiUrl` (ends in `jsapi/dh-core.js`).
44
+ * @returns A promise that resolves to the DH Core+ jsapi.
45
+ */
46
+ async loadCorePlusApi(jsApiUrl) {
47
+ const serverUrl = new URL(jsApiUrl);
48
+ serverUrl.pathname = serverUrl.pathname.replace(/jsapi\/dh-core\.js$/, '');
49
+ return loadDhModules({
50
+ serverUrl,
51
+ storageDir,
52
+ targetModuleType: 'esm',
53
+ });
54
+ },
55
+ /**
56
+ * Load the DHE jsapi from a running server and return the global `iris` object. Node equivalent of the browser's dynamic-import API loading.
57
+ * @param serverUrl URL of the DHE server to download the api from.
58
+ * @returns A promise that resolves to the DHE jsapi.
59
+ */
60
+ async loadEnterpriseApi(serverUrl) {
61
+ polyfill();
62
+ polyfillLocation(serverUrl.protocol === 'https:');
63
+ // Download jsapi `ESM` files from the DHE server.
64
+ await loadModules({
65
+ serverUrl,
66
+ serverPaths: ['irisapi/irisapi.nocache.js'],
67
+ download: true,
68
+ storageDir,
69
+ targetModuleType: 'esm',
70
+ });
71
+ // DHE currently exposes the jsapi via the global `iris` object.
72
+ return globalThis.iris;
73
+ },
74
+ };
75
+ }
76
+ export default createJsApiFactories;
@@ -0,0 +1,8 @@
1
+ export * from '@deephaven-enterprise/auth-nodejs';
2
+ export * from '@deephaven-enterprise/client-utils';
3
+ export * from '@deephaven-enterprise/jsapi-manager';
4
+ export type * from '@deephaven-enterprise/jsapi-types';
5
+ export * from '@deephaven-enterprise/query-utils';
6
+ export * from './createJsApiFactories.ts';
7
+ export * from './initCorePlusManager.ts';
8
+ export * from './polyfill.ts';
package/dist/index.js ADDED
@@ -0,0 +1,9 @@
1
+ // Re-export all the public APIs from the sub-packages for convenience so users
2
+ // can just install @deephaven-enterprise/jsapi-nodejs
3
+ export * from '@deephaven-enterprise/auth-nodejs';
4
+ export * from '@deephaven-enterprise/client-utils';
5
+ export * from '@deephaven-enterprise/jsapi-manager';
6
+ export * from '@deephaven-enterprise/query-utils';
7
+ export * from "./createJsApiFactories.js";
8
+ export * from "./initCorePlusManager.js";
9
+ export * from "./polyfill.js";
@@ -0,0 +1,18 @@
1
+ import { type KeyPairCredentials, type PasswordCredentials } from '@deephaven-enterprise/auth-nodejs';
2
+ import { type CorePlusManager } from '@deephaven-enterprise/client-utils';
3
+ import { type JsApiFactories } from './createJsApiFactories.ts';
4
+ /**
5
+ * Initializes a CorePlusManager instance with the provided server URL and
6
+ * credentials.
7
+ * @param serverUrl The URL of the server to connect to.
8
+ * @param credentials The credentials to use for authentication.
9
+ * @param jsApiFactories Optional factories for creating clients and loading APIs.
10
+ * Defaults to the result of `createJsApiFactories()`.
11
+ * @returns A Promise that resolves to a CorePlusManager instance.
12
+ */
13
+ export declare function initCorePlusManager({ serverUrl, credentials, jsApiFactories, }: {
14
+ serverUrl: URL;
15
+ credentials: KeyPairCredentials | PasswordCredentials;
16
+ jsApiFactories?: JsApiFactories;
17
+ }): Promise<CorePlusManager>;
18
+ export default initCorePlusManager;
@@ -0,0 +1,20 @@
1
+ import { login, } from '@deephaven-enterprise/auth-nodejs';
2
+ import { EnterpriseCorePlusManager } from '@deephaven-enterprise/jsapi-manager';
3
+ import { createJsApiFactories, } from "./createJsApiFactories.js";
4
+ /**
5
+ * Initializes a CorePlusManager instance with the provided server URL and
6
+ * credentials.
7
+ * @param serverUrl The URL of the server to connect to.
8
+ * @param credentials The credentials to use for authentication.
9
+ * @param jsApiFactories Optional factories for creating clients and loading APIs.
10
+ * Defaults to the result of `createJsApiFactories()`.
11
+ * @returns A Promise that resolves to a CorePlusManager instance.
12
+ */
13
+ export async function initCorePlusManager({ serverUrl, credentials, jsApiFactories = createJsApiFactories(), }) {
14
+ const { createEnterpriseClient, loadEnterpriseApi, loadCorePlusApi, createCoreClient, } = jsApiFactories;
15
+ const dhe = await loadEnterpriseApi(serverUrl);
16
+ const dheClient = await login(await createEnterpriseClient(dhe, serverUrl), credentials);
17
+ const { workerKinds } = await dheClient.getServerConfigValues();
18
+ return new EnterpriseCorePlusManager(dhe, dheClient, workerKinds, loadCorePlusApi, createCoreClient);
19
+ }
20
+ export default initCorePlusManager;
@@ -0,0 +1,19 @@
1
+ /**
2
+ * Polyfills needed by the DHE JS API when running under Node.js. The DHE jsapi
3
+ * still relies on `window`/`self`/`window.location` being present (it was
4
+ * written for the browser). These should eventually go away once the jsapi no
5
+ * longer relies on `window` or `self` (DH-17942).
6
+ */
7
+ /**
8
+ * Polyfill `self` and `window` to point at `globalThis` so the DHE jsapi can
9
+ * reference them when loaded in Node.
10
+ */
11
+ export declare function polyfill(): void;
12
+ /**
13
+ * Polyfill `window.location` to mimic running in a local browser environment
14
+ * when making requests to the server. This at least impacts websocket
15
+ * connections; it may be needed for other requests as well. The URL is an
16
+ * arbitrary URL chosen to stand out in logs.
17
+ * @param https Whether to use an `https` scheme for the polyfilled location.
18
+ */
19
+ export declare function polyfillLocation(https?: boolean): void;
@@ -0,0 +1,27 @@
1
+ /**
2
+ * Polyfills needed by the DHE JS API when running under Node.js. The DHE jsapi
3
+ * still relies on `window`/`self`/`window.location` being present (it was
4
+ * written for the browser). These should eventually go away once the jsapi no
5
+ * longer relies on `window` or `self` (DH-17942).
6
+ */
7
+ /**
8
+ * Polyfill `self` and `window` to point at `globalThis` so the DHE jsapi can
9
+ * reference them when loaded in Node.
10
+ */
11
+ export function polyfill() {
12
+ // @ts-expect-error Node global has no `self`/`window` types.
13
+ globalThis.self = globalThis;
14
+ // @ts-expect-error Node global has no `self`/`window` types.
15
+ globalThis.window = globalThis;
16
+ }
17
+ /**
18
+ * Polyfill `window.location` to mimic running in a local browser environment
19
+ * when making requests to the server. This at least impacts websocket
20
+ * connections; it may be needed for other requests as well. The URL is an
21
+ * arbitrary URL chosen to stand out in logs.
22
+ * @param https Whether to use an `https` scheme for the polyfilled location.
23
+ */
24
+ export function polyfillLocation(https = false) {
25
+ // @ts-expect-error Node global has no `window` types.
26
+ globalThis.window.location = new URL(`http${https ? 's' : ''}://deephaven-polyfill.localhost/`);
27
+ }
package/package.json ADDED
@@ -0,0 +1,37 @@
1
+ {
2
+ "name": "@deephaven-enterprise/jsapi-nodejs",
3
+ "version": "2026.1.43",
4
+ "description": "Deephaven Enterprise JS API Utils for NodeJS",
5
+ "author": "Deephaven Data Labs LLC",
6
+ "license": "SEE LICENSE IN LICENSE.md",
7
+ "type": "module",
8
+ "repository": {
9
+ "type": "git",
10
+ "url": "https://github.com/deephaven-ent/iris.git",
11
+ "directory": "web/client-ui/packages/jsapi-nodejs"
12
+ },
13
+ "private": false,
14
+ "source": "src/index.ts",
15
+ "main": "dist/index.js",
16
+ "types": "dist/index.d.ts",
17
+ "files": [
18
+ "dist"
19
+ ],
20
+ "sideEffects": false,
21
+ "scripts": {
22
+ "build": "tsc --build"
23
+ },
24
+ "dependencies": {
25
+ "@deephaven-enterprise/auth-nodejs": "2026.1.43",
26
+ "@deephaven-enterprise/client-utils": "2026.1.43",
27
+ "@deephaven-enterprise/jsapi-manager": "2026.1.43",
28
+ "@deephaven-enterprise/jsapi-types": "2026.1.43",
29
+ "@deephaven-enterprise/query-utils": "2026.1.43",
30
+ "@deephaven/jsapi-nodejs": "^1.15.0",
31
+ "@deephaven/jsapi-types": "1.0.0-dev0.40.5",
32
+ "@deephaven/utils": "^0.97.0"
33
+ },
34
+ "publishConfig": {
35
+ "access": "public"
36
+ }
37
+ }