@deephaven-enterprise/client-utils 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 +136 -0
- package/README.md +59 -0
- package/dist/CorePlusManager.d.ts +52 -0
- package/dist/CorePlusManager.js +1 -0
- package/dist/createAuthenticatedCoreClient.d.ts +14 -0
- package/dist/createAuthenticatedCoreClient.js +41 -0
- package/dist/createCoreClient.d.ts +14 -0
- package/dist/createCoreClient.js +15 -0
- package/dist/createEnterpriseClient.d.ts +11 -0
- package/dist/createEnterpriseClient.js +17 -0
- package/dist/getWorkerCredentials.d.ts +11 -0
- package/dist/getWorkerCredentials.js +15 -0
- package/dist/getWorkerKind.d.ts +9 -0
- package/dist/getWorkerKind.js +10 -0
- package/dist/index.d.ts +8 -0
- package/dist/index.js +8 -0
- package/dist/isCommunityWorkerKind.d.ts +13 -0
- package/dist/isCommunityWorkerKind.js +15 -0
- package/dist/types.d.ts +21 -0
- package/dist/types.js +1 -0
- package/package.json +33 -0
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,59 @@
|
|
|
1
|
+
# @deephaven-enterprise/client-utils
|
|
2
|
+
|
|
3
|
+
Deephaven Enterprise client connectivity utilities.
|
|
4
|
+
|
|
5
|
+
Utilities for creating and managing connections to a Deephaven Enterprise
|
|
6
|
+
server and the Core+ workers it provisions, along with related client types and
|
|
7
|
+
worker helpers.
|
|
8
|
+
|
|
9
|
+
This is a low-level building block. For most applications, use
|
|
10
|
+
[`@deephaven-enterprise/jsapi-nodejs`](../jsapi-nodejs), which wires these
|
|
11
|
+
clients together with authentication and worker connections for you.
|
|
12
|
+
|
|
13
|
+
## Usage
|
|
14
|
+
|
|
15
|
+
`createEnterpriseClient` connects to the server and resolves once the client is
|
|
16
|
+
connected. The result is _unauthenticated_; log in by calling `login` directly
|
|
17
|
+
on the client:
|
|
18
|
+
|
|
19
|
+
```typescript
|
|
20
|
+
import { createEnterpriseClient } from '@deephaven-enterprise/client-utils';
|
|
21
|
+
|
|
22
|
+
const serverUrl = new URL('https://my-dhe-server:8000/');
|
|
23
|
+
|
|
24
|
+
// `dhe` is the Enterprise JS API instance loaded from an Deephaven enterprise
|
|
25
|
+
// server.
|
|
26
|
+
const client = await createEnterpriseClient(dhe, serverUrl);
|
|
27
|
+
|
|
28
|
+
await client.login({
|
|
29
|
+
type: 'password',
|
|
30
|
+
username: 'my-username',
|
|
31
|
+
token: 'my-password',
|
|
32
|
+
});
|
|
33
|
+
```
|
|
34
|
+
|
|
35
|
+
Both password and key-pair authentication can be performed directly on the
|
|
36
|
+
client. [`@deephaven-enterprise/auth-nodejs`](../auth-nodejs) is optional — it
|
|
37
|
+
provides helper utilities that abstract some of this away, such as building
|
|
38
|
+
credentials and handling the key-pair challenge/response and signing.
|
|
39
|
+
|
|
40
|
+
With an authenticated Enterprise client, connect to a Core+ worker.
|
|
41
|
+
`getWorkerCredentials` requests a worker auth token from the Enterprise client,
|
|
42
|
+
and `createAuthenticatedCoreClient` uses it to log into the worker:
|
|
43
|
+
|
|
44
|
+
```typescript
|
|
45
|
+
import {
|
|
46
|
+
createCoreClient,
|
|
47
|
+
createAuthenticatedCoreClient,
|
|
48
|
+
getWorkerCredentials,
|
|
49
|
+
} from '@deephaven-enterprise/client-utils';
|
|
50
|
+
|
|
51
|
+
const workerCredentials = await getWorkerCredentials(client);
|
|
52
|
+
|
|
53
|
+
const coreClient = await createAuthenticatedCoreClient(
|
|
54
|
+
dh, // the Core (Community) JS API for the worker
|
|
55
|
+
createCoreClient,
|
|
56
|
+
workerCredentials,
|
|
57
|
+
workerGrpcUrl
|
|
58
|
+
);
|
|
59
|
+
```
|
|
@@ -0,0 +1,52 @@
|
|
|
1
|
+
import type { EnterpriseDhType, WorkerKind } from '@deephaven-enterprise/jsapi-types';
|
|
2
|
+
import type { dh as DhType } from '@deephaven/jsapi-types';
|
|
3
|
+
import type { AuthenticatedEnterpriseClient } from './types';
|
|
4
|
+
/**
|
|
5
|
+
* Interface defining a connection manager for fetching APIs from and creating
|
|
6
|
+
* connections to CorePlus workers, and managing the lifecycle of the underlying
|
|
7
|
+
* client.
|
|
8
|
+
*/
|
|
9
|
+
export interface CorePlusManager {
|
|
10
|
+
/** The Enterprise DHE JS API */
|
|
11
|
+
get dhe(): EnterpriseDhType;
|
|
12
|
+
/** The DHE JS API client */
|
|
13
|
+
get dheClient(): AuthenticatedEnterpriseClient;
|
|
14
|
+
/** Whether this has been disposed. */
|
|
15
|
+
get isDisposed(): boolean;
|
|
16
|
+
/** Dispose resources. */
|
|
17
|
+
dispose(): Promise<void>;
|
|
18
|
+
/**
|
|
19
|
+
* Get the API for the specified worker kind.
|
|
20
|
+
* @param engine The engine to get the API for
|
|
21
|
+
* @param jsApiUrl The URL to load the API from
|
|
22
|
+
* @return The API for the specified worker kind
|
|
23
|
+
*/
|
|
24
|
+
getApi(engine: string, jsApiUrl: string): Promise<typeof DhType>;
|
|
25
|
+
/**
|
|
26
|
+
* Get the CoreClient for the specified worker.
|
|
27
|
+
* @param dh The Core API to create the CoreClient with.
|
|
28
|
+
* @param grpcUrl The gRPC URL
|
|
29
|
+
* @param envoyPrefix The envoy prefix
|
|
30
|
+
* @return The CoreClient for the specified worker kind
|
|
31
|
+
*/
|
|
32
|
+
getClient(dh: typeof DhType, grpcUrl: string, envoyPrefix?: string | null): Promise<DhType.CoreClient>;
|
|
33
|
+
/**
|
|
34
|
+
* Get the IDE connection for the specified worker.
|
|
35
|
+
* @param dh The Core API to create the CoreClient with.
|
|
36
|
+
* @param grpcUrl The gRPC URL
|
|
37
|
+
* @param envoyPrefix The envoy prefix
|
|
38
|
+
* @return The IDE connection for the specified worker kind
|
|
39
|
+
*/
|
|
40
|
+
getConnection(dh: typeof DhType, grpcUrl: string, envoyPrefix?: string | null): Promise<DhType.IdeConnection>;
|
|
41
|
+
/**
|
|
42
|
+
* Get the worker kind or null for the specified engine.
|
|
43
|
+
* @param engine The engine to get the worker kind for
|
|
44
|
+
*/
|
|
45
|
+
getEngineWorkerKind(engine: string): WorkerKind | null;
|
|
46
|
+
/**
|
|
47
|
+
* Check if an engine is a community worker kind.
|
|
48
|
+
* @param engine The engine name to check
|
|
49
|
+
*/
|
|
50
|
+
isCommunityWorkerKind(engine: string | null): boolean;
|
|
51
|
+
}
|
|
52
|
+
export default CorePlusManager;
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export {};
|
|
@@ -0,0 +1,14 @@
|
|
|
1
|
+
import type { dh as DhType } from '@deephaven/jsapi-types';
|
|
2
|
+
import type { AuthenticatedCoreClient, CoreClientFactory } from './types.ts';
|
|
3
|
+
/**
|
|
4
|
+
* Create an authenticated Core client for a given DHE client and JS API. This
|
|
5
|
+
* function will request an auth token from the DHE client and use it to log into
|
|
6
|
+
* the Core client.
|
|
7
|
+
* @param dh The JS API instance to use for creating the Core client
|
|
8
|
+
* @param createCoreClient The factory function to create a Core client
|
|
9
|
+
* @param serverUrl The URL of the Core server
|
|
10
|
+
* @param envoyPrefix Optional prefix for the Envoy proxy
|
|
11
|
+
* @returns A promise that resolves to an authenticated Core client
|
|
12
|
+
*/
|
|
13
|
+
export declare function createAuthenticatedCoreClient(dh: typeof DhType, createCoreClient: CoreClientFactory, credentials: DhType.LoginCredentials, serverUrl: string, envoyPrefix?: string | null): Promise<AuthenticatedCoreClient>;
|
|
14
|
+
export default createAuthenticatedCoreClient;
|
|
@@ -0,0 +1,41 @@
|
|
|
1
|
+
import Log from '@deephaven/log';
|
|
2
|
+
const log = Log.module('createAuthenticatedCoreClient');
|
|
3
|
+
let communityClientCount = 0;
|
|
4
|
+
/**
|
|
5
|
+
* Create an authenticated Core client for a given DHE client and JS API. This
|
|
6
|
+
* function will request an auth token from the DHE client and use it to log into
|
|
7
|
+
* the Core client.
|
|
8
|
+
* @param dh The JS API instance to use for creating the Core client
|
|
9
|
+
* @param createCoreClient The factory function to create a Core client
|
|
10
|
+
* @param serverUrl The URL of the Core server
|
|
11
|
+
* @param envoyPrefix Optional prefix for the Envoy proxy
|
|
12
|
+
* @returns A promise that resolves to an authenticated Core client
|
|
13
|
+
*/
|
|
14
|
+
export async function createAuthenticatedCoreClient(dh, createCoreClient, credentials, serverUrl, envoyPrefix) {
|
|
15
|
+
// Use an incrementing id for each call to `createAuthenticatedCoreClient` to
|
|
16
|
+
// tie logs for async events together for a particular core client instance.
|
|
17
|
+
communityClientCount += 1;
|
|
18
|
+
const clientLogId = communityClientCount - 1;
|
|
19
|
+
const logInfo = log.info.bind(log, `[createAuthenticatedCoreClient:${clientLogId}]`);
|
|
20
|
+
const logDebug = log.debug.bind(log, `[createAuthenticatedCoreClient:${clientLogId}]`);
|
|
21
|
+
const logError = log.error.bind(log, `[createAuthenticatedCoreClient:${clientLogId}]`);
|
|
22
|
+
logInfo('Init community client', serverUrl);
|
|
23
|
+
const coreClient = await createCoreClient(dh, serverUrl, envoyPrefix);
|
|
24
|
+
logDebug('Core client', coreClient, serverUrl);
|
|
25
|
+
try {
|
|
26
|
+
logDebug('Created auth token', credentials.token, serverUrl);
|
|
27
|
+
logDebug('Logging in with', credentials, serverUrl);
|
|
28
|
+
await coreClient.login(credentials);
|
|
29
|
+
logInfo('Log in success', serverUrl);
|
|
30
|
+
return coreClient;
|
|
31
|
+
}
|
|
32
|
+
catch (err) {
|
|
33
|
+
logError(`Log in failed for ${serverUrl}`, err);
|
|
34
|
+
// If login fails, the client connection is no longer useful and needs to be
|
|
35
|
+
// discarded. Since it won't be available to the caller when we throw, we
|
|
36
|
+
// need to disconnect it here.
|
|
37
|
+
coreClient.disconnect();
|
|
38
|
+
throw err;
|
|
39
|
+
}
|
|
40
|
+
}
|
|
41
|
+
export default createAuthenticatedCoreClient;
|
|
@@ -0,0 +1,14 @@
|
|
|
1
|
+
import type { dh as DhType } from '@deephaven/jsapi-types';
|
|
2
|
+
import type { UnauthenticatedCoreClient } from './types.ts';
|
|
3
|
+
/**
|
|
4
|
+
* Create a connected, unauthenticated Core client.
|
|
5
|
+
* @param dh The dh JsApi.
|
|
6
|
+
* @param serverUrl The server URL.
|
|
7
|
+
* @param envoyPrefix Optional Envoy prefix to include in the request headers.
|
|
8
|
+
* If set, this will override any `envoy-prefix` header provided in
|
|
9
|
+
* `connectOptions`.
|
|
10
|
+
* @param connectOptions Optional connection options.
|
|
11
|
+
* @returns The connected Core client.
|
|
12
|
+
*/
|
|
13
|
+
export declare function createCoreClient(dh: typeof DhType, serverUrl: string, envoyPrefix?: string | null, connectOptions?: DhType.ConnectOptions): UnauthenticatedCoreClient;
|
|
14
|
+
export default createCoreClient;
|
|
@@ -0,0 +1,15 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Create a connected, unauthenticated Core client.
|
|
3
|
+
* @param dh The dh JsApi.
|
|
4
|
+
* @param serverUrl The server URL.
|
|
5
|
+
* @param envoyPrefix Optional Envoy prefix to include in the request headers.
|
|
6
|
+
* If set, this will override any `envoy-prefix` header provided in
|
|
7
|
+
* `connectOptions`.
|
|
8
|
+
* @param connectOptions Optional connection options.
|
|
9
|
+
* @returns The connected Core client.
|
|
10
|
+
*/
|
|
11
|
+
export function createCoreClient(dh, serverUrl, envoyPrefix, connectOptions) {
|
|
12
|
+
const envoyHeaders = envoyPrefix == null ? undefined : { 'envoy-prefix': envoyPrefix };
|
|
13
|
+
return new dh.CoreClient(serverUrl, Object.assign(Object.assign({}, connectOptions), { headers: Object.assign(Object.assign({}, connectOptions === null || connectOptions === void 0 ? void 0 : connectOptions.headers), envoyHeaders) }));
|
|
14
|
+
}
|
|
15
|
+
export default createCoreClient;
|
|
@@ -0,0 +1,11 @@
|
|
|
1
|
+
import type { ConnectOptions, EnterpriseDhType as DheType } from '@deephaven-enterprise/jsapi-types';
|
|
2
|
+
import type { UnauthenticatedEnterpriseClient } from './types.ts';
|
|
3
|
+
/**
|
|
4
|
+
* Create a connected, unauthenticated DHE client.
|
|
5
|
+
* @param dhe DHE JsApi.
|
|
6
|
+
* @param serverUrl The DHE server URL.
|
|
7
|
+
* @param connectOptions Optional connection options.
|
|
8
|
+
* @returns A connected, unauthenticated DHE client.
|
|
9
|
+
*/
|
|
10
|
+
export declare function createEnterpriseClient(dhe: DheType, serverUrl: URL, connectOptions?: ConnectOptions): Promise<UnauthenticatedEnterpriseClient>;
|
|
11
|
+
export default createEnterpriseClient;
|
|
@@ -0,0 +1,17 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Create a connected, unauthenticated DHE client.
|
|
3
|
+
* @param dhe DHE JsApi.
|
|
4
|
+
* @param serverUrl The DHE server URL.
|
|
5
|
+
* @param connectOptions Optional connection options.
|
|
6
|
+
* @returns A connected, unauthenticated DHE client.
|
|
7
|
+
*/
|
|
8
|
+
export async function createEnterpriseClient(dhe, serverUrl, connectOptions) {
|
|
9
|
+
const dheClient = new dhe.Client(serverUrl.toString(), connectOptions);
|
|
10
|
+
return new Promise(resolve => {
|
|
11
|
+
const unsubscribe = dheClient.addEventListener(dhe.Client.EVENT_CONNECT, () => {
|
|
12
|
+
unsubscribe();
|
|
13
|
+
resolve(dheClient);
|
|
14
|
+
});
|
|
15
|
+
});
|
|
16
|
+
}
|
|
17
|
+
export default createEnterpriseClient;
|
|
@@ -0,0 +1,11 @@
|
|
|
1
|
+
import type { EnterpriseClient } from '@deephaven-enterprise/jsapi-types';
|
|
2
|
+
import type { dh as DhType } from '@deephaven/jsapi-types';
|
|
3
|
+
/**
|
|
4
|
+
* Create login credentials for a Core+ worker from a DHE client. Requests an
|
|
5
|
+
* auth token from the DHE client for the `RemoteQueryProcessor` and wraps it in
|
|
6
|
+
* the token login options expected by a `CoreClient`.
|
|
7
|
+
* @param client The DHE JS API client to request the auth token from
|
|
8
|
+
* @returns Login credentials for logging into a Core+ worker
|
|
9
|
+
*/
|
|
10
|
+
export declare function getWorkerCredentials(client: EnterpriseClient): Promise<DhType.LoginCredentials>;
|
|
11
|
+
export default getWorkerCredentials;
|
|
@@ -0,0 +1,15 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Create login credentials for a Core+ worker from a DHE client. Requests an
|
|
3
|
+
* auth token from the DHE client for the `RemoteQueryProcessor` and wraps it in
|
|
4
|
+
* the token login options expected by a `CoreClient`.
|
|
5
|
+
* @param client The DHE JS API client to request the auth token from
|
|
6
|
+
* @returns Login credentials for logging into a Core+ worker
|
|
7
|
+
*/
|
|
8
|
+
export async function getWorkerCredentials(client) {
|
|
9
|
+
const token = await client.createAuthToken('RemoteQueryProcessor');
|
|
10
|
+
return {
|
|
11
|
+
type: 'io.deephaven.proto.auth.Token',
|
|
12
|
+
token,
|
|
13
|
+
};
|
|
14
|
+
}
|
|
15
|
+
export default getWorkerCredentials;
|
|
@@ -0,0 +1,9 @@
|
|
|
1
|
+
import type { WorkerKind } from '@deephaven-enterprise/jsapi-types';
|
|
2
|
+
/**
|
|
3
|
+
* Get the worker kind for a given engine from a list of worker kinds
|
|
4
|
+
* @param engine The name of the engine to find the worker kind for
|
|
5
|
+
* @param workerKinds The list of available worker kinds
|
|
6
|
+
* @returns The worker kind that matches the given engine, or undefined if not found
|
|
7
|
+
*/
|
|
8
|
+
export declare function getWorkerKind(engine: string, workerKinds: readonly WorkerKind[]): WorkerKind | undefined;
|
|
9
|
+
export default getWorkerKind;
|
|
@@ -0,0 +1,10 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Get the worker kind for a given engine from a list of worker kinds
|
|
3
|
+
* @param engine The name of the engine to find the worker kind for
|
|
4
|
+
* @param workerKinds The list of available worker kinds
|
|
5
|
+
* @returns The worker kind that matches the given engine, or undefined if not found
|
|
6
|
+
*/
|
|
7
|
+
export function getWorkerKind(engine, workerKinds) {
|
|
8
|
+
return workerKinds === null || workerKinds === void 0 ? void 0 : workerKinds.find(({ name }) => name === engine);
|
|
9
|
+
}
|
|
10
|
+
export default getWorkerKind;
|
package/dist/index.d.ts
ADDED
|
@@ -0,0 +1,8 @@
|
|
|
1
|
+
export * from './CorePlusManager.ts';
|
|
2
|
+
export * from './createAuthenticatedCoreClient.ts';
|
|
3
|
+
export * from './createCoreClient.ts';
|
|
4
|
+
export * from './createEnterpriseClient.ts';
|
|
5
|
+
export * from './getWorkerCredentials.ts';
|
|
6
|
+
export * from './getWorkerKind.ts';
|
|
7
|
+
export * from './isCommunityWorkerKind.ts';
|
|
8
|
+
export * from './types.ts';
|
package/dist/index.js
ADDED
|
@@ -0,0 +1,8 @@
|
|
|
1
|
+
export * from "./CorePlusManager.js";
|
|
2
|
+
export * from "./createAuthenticatedCoreClient.js";
|
|
3
|
+
export * from "./createCoreClient.js";
|
|
4
|
+
export * from "./createEnterpriseClient.js";
|
|
5
|
+
export * from "./getWorkerCredentials.js";
|
|
6
|
+
export * from "./getWorkerKind.js";
|
|
7
|
+
export * from "./isCommunityWorkerKind.js";
|
|
8
|
+
export * from "./types.js";
|
|
@@ -0,0 +1,13 @@
|
|
|
1
|
+
import type { WorkerKind } from '@deephaven-enterprise/jsapi-types';
|
|
2
|
+
export declare const PROTOCOL: Readonly<{
|
|
3
|
+
COMMUNITY: "Community";
|
|
4
|
+
ENTERPRISE_WEBSOCKET: "EnterpriseWebsocket";
|
|
5
|
+
ENTERPRISE_COMM: "EnterpriseComm";
|
|
6
|
+
}>;
|
|
7
|
+
/**
|
|
8
|
+
* Check if a given worker kind is a community worker kind
|
|
9
|
+
* @param workerKind The worker kind to check
|
|
10
|
+
* @returns True if the worker kind is a community worker kind, false otherwise
|
|
11
|
+
*/
|
|
12
|
+
export declare function isCommunityWorkerKind(workerKind?: WorkerKind): boolean;
|
|
13
|
+
export default isCommunityWorkerKind;
|
|
@@ -0,0 +1,15 @@
|
|
|
1
|
+
export const PROTOCOL = Object.freeze({
|
|
2
|
+
COMMUNITY: 'Community',
|
|
3
|
+
ENTERPRISE_WEBSOCKET: 'EnterpriseWebsocket',
|
|
4
|
+
ENTERPRISE_COMM: 'EnterpriseComm',
|
|
5
|
+
});
|
|
6
|
+
/**
|
|
7
|
+
* Check if a given worker kind is a community worker kind
|
|
8
|
+
* @param workerKind The worker kind to check
|
|
9
|
+
* @returns True if the worker kind is a community worker kind, false otherwise
|
|
10
|
+
*/
|
|
11
|
+
export function isCommunityWorkerKind(workerKind) {
|
|
12
|
+
var _a, _b;
|
|
13
|
+
return (_b = (_a = workerKind === null || workerKind === void 0 ? void 0 : workerKind.protocols) === null || _a === void 0 ? void 0 : _a.includes(PROTOCOL.COMMUNITY)) !== null && _b !== void 0 ? _b : false;
|
|
14
|
+
}
|
|
15
|
+
export default isCommunityWorkerKind;
|
package/dist/types.d.ts
ADDED
|
@@ -0,0 +1,21 @@
|
|
|
1
|
+
import type { Brand } from '@deephaven/utils/dist/TypeUtils.d.ts';
|
|
2
|
+
import type { dh as DhType } from '@deephaven/jsapi-types';
|
|
3
|
+
import type { ConnectOptions, EnterpriseClient, EnterpriseDhType as DheType } from '@deephaven-enterprise/jsapi-types';
|
|
4
|
+
export type AuthenticatedCoreClient = Brand<'AuthenticatedCoreClient', DhType.CoreClient>;
|
|
5
|
+
export type UnauthenticatedCoreClient = Brand<'UnauthenticatedCoreClient', DhType.CoreClient>;
|
|
6
|
+
export type AuthenticatedEnterpriseClient = Brand<'AuthenticatedEnterpriseClient', EnterpriseClient>;
|
|
7
|
+
export type UnauthenticatedEnterpriseClient = Brand<'UnauthenticatedEnterpriseClient', EnterpriseClient>;
|
|
8
|
+
/**
|
|
9
|
+
* Loads the JS API from a URL. Environment-specific (browser dynamic import vs
|
|
10
|
+
* Node module loading).
|
|
11
|
+
*/
|
|
12
|
+
export type CoreApiLoader = (jsApiUrl: string) => Promise<typeof DhType>;
|
|
13
|
+
export type EnterpriseApiLoader = (serverUrl: URL) => Promise<DheType>;
|
|
14
|
+
/**
|
|
15
|
+
* Constructs an unauthenticated `CoreClient` for a worker.
|
|
16
|
+
*/
|
|
17
|
+
export type CoreClientFactory = (dh: typeof DhType, serverUrl: string, envoyPrefix?: string | null, connectOptions?: DhType.ConnectOptions) => UnauthenticatedCoreClient | Promise<UnauthenticatedCoreClient>;
|
|
18
|
+
/**
|
|
19
|
+
* Constructs an unauthenticated `EnterpriseClient`.
|
|
20
|
+
*/
|
|
21
|
+
export type EnterpriseClientFactory = (dhe: DheType, serverUrl: URL, connectOptions?: ConnectOptions) => Promise<UnauthenticatedEnterpriseClient>;
|
package/dist/types.js
ADDED
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export {};
|
package/package.json
ADDED
|
@@ -0,0 +1,33 @@
|
|
|
1
|
+
{
|
|
2
|
+
"name": "@deephaven-enterprise/client-utils",
|
|
3
|
+
"version": "2026.1.43",
|
|
4
|
+
"description": "Deephaven Enterprise Client Connectivity Utils",
|
|
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/client-utils"
|
|
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/jsapi-types": "1.0.0-dev0.40.5",
|
|
26
|
+
"@deephaven-enterprise/jsapi-types": "2026.1.43",
|
|
27
|
+
"@deephaven/log": "^0.97.0",
|
|
28
|
+
"@deephaven/utils": "^0.97.0"
|
|
29
|
+
},
|
|
30
|
+
"publishConfig": {
|
|
31
|
+
"access": "public"
|
|
32
|
+
}
|
|
33
|
+
}
|