@deephaven/jsapi-utils 0.43.0 → 0.44.1-beta.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/dist/ConnectionUtils.js +39 -0
- package/dist/ConnectionUtils.js.map +1 -0
- package/dist/DateUtils.js +246 -0
- package/dist/DateUtils.js.map +1 -0
- package/dist/Formatter.js +144 -0
- package/dist/Formatter.js.map +1 -0
- package/dist/FormatterUtils.js +36 -0
- package/dist/FormatterUtils.js.map +1 -0
- package/dist/MessageUtils.js +124 -0
- package/dist/MessageUtils.js.map +1 -0
- package/dist/NoConsolesError.js +14 -0
- package/dist/NoConsolesError.js.map +1 -0
- package/dist/SessionUtils.js +101 -0
- package/dist/SessionUtils.js.map +1 -0
- package/dist/Settings.js +2 -0
- package/dist/Settings.js.map +1 -0
- package/dist/TableUtils.js +1367 -0
- package/dist/TableUtils.js.map +1 -0
- package/dist/ViewportDataUtils.js +136 -0
- package/dist/ViewportDataUtils.js.map +1 -0
- package/dist/formatters/BooleanColumnFormatter.js +20 -0
- package/dist/formatters/BooleanColumnFormatter.js.map +1 -0
- package/dist/formatters/CharColumnFormatter.js +11 -0
- package/dist/formatters/CharColumnFormatter.js.map +1 -0
- package/dist/formatters/DateTimeColumnFormatter.js +106 -0
- package/dist/formatters/DateTimeColumnFormatter.js.map +1 -0
- package/dist/formatters/DecimalColumnFormatter.js +115 -0
- package/dist/formatters/DecimalColumnFormatter.js.map +1 -0
- package/dist/formatters/DefaultColumnFormatter.js +10 -0
- package/dist/formatters/DefaultColumnFormatter.js.map +1 -0
- package/dist/formatters/IntegerColumnFormatter.js +112 -0
- package/dist/formatters/IntegerColumnFormatter.js.map +1 -0
- package/dist/formatters/StringColumnFormatter.js +10 -0
- package/dist/formatters/StringColumnFormatter.js.map +1 -0
- package/dist/formatters/TableColumnFormatter.js +59 -0
- package/dist/formatters/TableColumnFormatter.js.map +1 -0
- package/dist/formatters/index.js +10 -0
- package/dist/formatters/index.js.map +1 -0
- package/dist/index.js +13 -0
- package/dist/index.js.map +1 -0
- package/package.json +7 -7
|
@@ -0,0 +1,124 @@
|
|
|
1
|
+
function asyncGeneratorStep(gen, resolve, reject, _next, _throw, key, arg) { try { var info = gen[key](arg); var value = info.value; } catch (error) { reject(error); return; } if (info.done) { resolve(value); } else { Promise.resolve(value).then(_next, _throw); } }
|
|
2
|
+
function _asyncToGenerator(fn) { return function () { var self = this, args = arguments; return new Promise(function (resolve, reject) { var gen = fn.apply(self, args); function _next(value) { asyncGeneratorStep(gen, resolve, reject, _next, _throw, "next", value); } function _throw(err) { asyncGeneratorStep(gen, resolve, reject, _next, _throw, "throw", err); } _next(undefined); }); }; }
|
|
3
|
+
import shortid from 'shortid';
|
|
4
|
+
import Log from '@deephaven/log';
|
|
5
|
+
import { TimeoutError } from '@deephaven/utils';
|
|
6
|
+
var log = Log.module('MessageUtils');
|
|
7
|
+
export var LOGIN_OPTIONS_REQUEST = 'io.deephaven.message.LoginOptions.request';
|
|
8
|
+
export var SESSION_DETAILS_REQUEST = 'io.deephaven.message.SessionDetails.request';
|
|
9
|
+
|
|
10
|
+
/**
|
|
11
|
+
* Use a BroadcastChannel for sending messages between tabs, such as when the user logs out.
|
|
12
|
+
*/
|
|
13
|
+
export var BROADCAST_CHANNEL_NAME = 'io.deephaven.broadcast';
|
|
14
|
+
|
|
15
|
+
/**
|
|
16
|
+
* Event emitted when the user has logged in successfully
|
|
17
|
+
*/
|
|
18
|
+
export var BROADCAST_LOGIN_MESSAGE = 'io.deephaven.broadcast.Login';
|
|
19
|
+
|
|
20
|
+
/**
|
|
21
|
+
* Event emitted when the user has logged out
|
|
22
|
+
*/
|
|
23
|
+
export var BROADCAST_LOGOUT_MESSAGE = 'io.deephaven.broadcast.Logout';
|
|
24
|
+
export function isMessage(obj) {
|
|
25
|
+
var message = obj;
|
|
26
|
+
return message != null && typeof message.id === 'string' && typeof message.message === 'string';
|
|
27
|
+
}
|
|
28
|
+
export function isBroadcastLoginMessage(obj) {
|
|
29
|
+
return isMessage(obj) && obj.message === BROADCAST_LOGIN_MESSAGE;
|
|
30
|
+
}
|
|
31
|
+
export function isBroadcastLogoutMessage(obj) {
|
|
32
|
+
return isMessage(obj) && obj.message === BROADCAST_LOGOUT_MESSAGE;
|
|
33
|
+
}
|
|
34
|
+
export function isResponse(obj) {
|
|
35
|
+
var response = obj;
|
|
36
|
+
return response != null && typeof response.id === 'string';
|
|
37
|
+
}
|
|
38
|
+
|
|
39
|
+
/**
|
|
40
|
+
* Make message object with optional payload
|
|
41
|
+
* @param message Message string
|
|
42
|
+
* @param id Unique message id
|
|
43
|
+
* @param payload Payload to send
|
|
44
|
+
* @returns Message
|
|
45
|
+
*/
|
|
46
|
+
export function makeMessage(message) {
|
|
47
|
+
var id = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : shortid();
|
|
48
|
+
var payload = arguments.length > 2 ? arguments[2] : undefined;
|
|
49
|
+
return {
|
|
50
|
+
message,
|
|
51
|
+
id,
|
|
52
|
+
payload
|
|
53
|
+
};
|
|
54
|
+
}
|
|
55
|
+
|
|
56
|
+
/**
|
|
57
|
+
* Make response object for given message id
|
|
58
|
+
* @param messageId Id of the request message to respond to
|
|
59
|
+
* @param payload Payload to respond with
|
|
60
|
+
* @returns Response
|
|
61
|
+
*/
|
|
62
|
+
export function makeResponse(messageId, payload) {
|
|
63
|
+
return {
|
|
64
|
+
id: messageId,
|
|
65
|
+
payload
|
|
66
|
+
};
|
|
67
|
+
}
|
|
68
|
+
export function getWindowParent() {
|
|
69
|
+
if (window.opener != null) {
|
|
70
|
+
return window.opener;
|
|
71
|
+
}
|
|
72
|
+
if (window.parent != null && window.parent !== window) {
|
|
73
|
+
return window.parent;
|
|
74
|
+
}
|
|
75
|
+
return null;
|
|
76
|
+
}
|
|
77
|
+
|
|
78
|
+
/**
|
|
79
|
+
* Request data from the parent window and wait for response
|
|
80
|
+
* @param request Request message to send to the parent window
|
|
81
|
+
* @param timeout Timeout in ms
|
|
82
|
+
* @returns Payload of the given type, or undefined
|
|
83
|
+
*/
|
|
84
|
+
export function requestParentResponse(_x) {
|
|
85
|
+
return _requestParentResponse.apply(this, arguments);
|
|
86
|
+
}
|
|
87
|
+
function _requestParentResponse() {
|
|
88
|
+
_requestParentResponse = _asyncToGenerator(function* (request) {
|
|
89
|
+
var timeout = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : 30000;
|
|
90
|
+
var parent = getWindowParent();
|
|
91
|
+
if (parent == null) {
|
|
92
|
+
throw new Error('window parent is null, unable to send request.');
|
|
93
|
+
}
|
|
94
|
+
return new Promise((resolve, reject) => {
|
|
95
|
+
var timeoutId;
|
|
96
|
+
var id = shortid();
|
|
97
|
+
var listener = event => {
|
|
98
|
+
var {
|
|
99
|
+
data
|
|
100
|
+
} = event;
|
|
101
|
+
if (!isResponse(data)) {
|
|
102
|
+
log.debug('Ignoring non-deephaven response', data);
|
|
103
|
+
return;
|
|
104
|
+
}
|
|
105
|
+
log.debug('Received message', data);
|
|
106
|
+
if ((data === null || data === void 0 ? void 0 : data.id) !== id) {
|
|
107
|
+
log.debug("Ignore message, id doesn't match", data);
|
|
108
|
+
return;
|
|
109
|
+
}
|
|
110
|
+
window.clearTimeout(timeoutId);
|
|
111
|
+
window.removeEventListener('message', listener);
|
|
112
|
+
resolve(data.payload);
|
|
113
|
+
};
|
|
114
|
+
window.addEventListener('message', listener);
|
|
115
|
+
timeoutId = window.setTimeout(() => {
|
|
116
|
+
window.removeEventListener('message', listener);
|
|
117
|
+
reject(new TimeoutError('Request timed out'));
|
|
118
|
+
}, timeout);
|
|
119
|
+
parent.postMessage(makeMessage(request, id), '*');
|
|
120
|
+
});
|
|
121
|
+
});
|
|
122
|
+
return _requestParentResponse.apply(this, arguments);
|
|
123
|
+
}
|
|
124
|
+
//# sourceMappingURL=MessageUtils.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"MessageUtils.js","names":["shortid","Log","TimeoutError","log","module","LOGIN_OPTIONS_REQUEST","SESSION_DETAILS_REQUEST","BROADCAST_CHANNEL_NAME","BROADCAST_LOGIN_MESSAGE","BROADCAST_LOGOUT_MESSAGE","isMessage","obj","message","id","isBroadcastLoginMessage","isBroadcastLogoutMessage","isResponse","response","makeMessage","payload","makeResponse","messageId","getWindowParent","window","opener","parent","requestParentResponse","request","timeout","Error","Promise","resolve","reject","timeoutId","listener","event","data","debug","clearTimeout","removeEventListener","addEventListener","setTimeout","postMessage"],"sources":["../src/MessageUtils.ts"],"sourcesContent":["import shortid from 'shortid';\nimport Log from '@deephaven/log';\nimport { TimeoutError } from '@deephaven/utils';\n\nconst log = Log.module('MessageUtils');\n\nexport const LOGIN_OPTIONS_REQUEST =\n 'io.deephaven.message.LoginOptions.request';\n\nexport const SESSION_DETAILS_REQUEST =\n 'io.deephaven.message.SessionDetails.request';\n\n/**\n * Use a BroadcastChannel for sending messages between tabs, such as when the user logs out.\n */\nexport const BROADCAST_CHANNEL_NAME = 'io.deephaven.broadcast';\n\n/**\n * Event emitted when the user has logged in successfully\n */\nexport const BROADCAST_LOGIN_MESSAGE = 'io.deephaven.broadcast.Login';\n\n/**\n * Event emitted when the user has logged out\n */\nexport const BROADCAST_LOGOUT_MESSAGE = 'io.deephaven.broadcast.Logout';\n\nexport interface Message<T = unknown> {\n id: string;\n message: string;\n payload?: T;\n}\n\nexport interface BroadcastLoginMessage extends Message<void> {\n message: typeof BROADCAST_LOGIN_MESSAGE;\n}\n\nexport interface BroadcastLogoutMessage extends Message<void> {\n message: typeof BROADCAST_LOGOUT_MESSAGE;\n}\n\nexport interface Response<T = unknown> {\n id: string;\n payload: T;\n}\n\nexport function isMessage(obj: unknown): obj is Message {\n const message = obj as Message;\n return (\n message != null &&\n typeof message.id === 'string' &&\n typeof message.message === 'string'\n );\n}\n\nexport function isBroadcastLoginMessage(\n obj: unknown\n): obj is BroadcastLoginMessage {\n return isMessage(obj) && obj.message === BROADCAST_LOGIN_MESSAGE;\n}\n\nexport function isBroadcastLogoutMessage(\n obj: unknown\n): obj is BroadcastLogoutMessage {\n return isMessage(obj) && obj.message === BROADCAST_LOGOUT_MESSAGE;\n}\n\nexport function isResponse(obj: unknown): obj is Response {\n const response = obj as Response;\n return response != null && typeof response.id === 'string';\n}\n\n/**\n * Make message object with optional payload\n * @param message Message string\n * @param id Unique message id\n * @param payload Payload to send\n * @returns Message\n */\nexport function makeMessage<T>(\n message: string,\n id = shortid(),\n payload?: T\n): Message<T> {\n return { message, id, payload };\n}\n\n/**\n * Make response object for given message id\n * @param messageId Id of the request message to respond to\n * @param payload Payload to respond with\n * @returns Response\n */\nexport function makeResponse<T>(messageId: string, payload: T): Response<T> {\n return { id: messageId, payload };\n}\n\nexport function getWindowParent(): Window | null {\n if (window.opener != null) {\n return window.opener;\n }\n if (window.parent != null && window.parent !== window) {\n return window.parent;\n }\n return null;\n}\n\n/**\n * Request data from the parent window and wait for response\n * @param request Request message to send to the parent window\n * @param timeout Timeout in ms\n * @returns Payload of the given type, or undefined\n */\nexport async function requestParentResponse(\n request: string,\n timeout = 30000\n): Promise<unknown> {\n const parent = getWindowParent();\n if (parent == null) {\n throw new Error('window parent is null, unable to send request.');\n }\n return new Promise((resolve, reject) => {\n let timeoutId: number;\n const id = shortid();\n const listener = (event: MessageEvent) => {\n const { data } = event;\n if (!isResponse(data)) {\n log.debug('Ignoring non-deephaven response', data);\n return;\n }\n log.debug('Received message', data);\n if (data?.id !== id) {\n log.debug(\"Ignore message, id doesn't match\", data);\n return;\n }\n window.clearTimeout(timeoutId);\n window.removeEventListener('message', listener);\n resolve(data.payload);\n };\n window.addEventListener('message', listener);\n timeoutId = window.setTimeout(() => {\n window.removeEventListener('message', listener);\n reject(new TimeoutError('Request timed out'));\n }, timeout);\n parent.postMessage(makeMessage(request, id), '*');\n });\n}\n"],"mappings":";;AAAA,OAAOA,OAAO,MAAM,SAAS;AAC7B,OAAOC,GAAG,MAAM,gBAAgB;AAChC,SAASC,YAAY,QAAQ,kBAAkB;AAE/C,IAAM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EAAEL,QAAQ,CAAC;QAC/CH,OAAO,CAACK,IAAI,CAACjB,OAAO,CAAC;MACvB,CAAC;MACDI,MAAM,CAACiB,gBAAgB,CAAC,SAAS,EAAEN,QAAQ,CAAC;MAC5CD,SAAS,GAAGV,MAAM,CAACkB,UAAU,CAAC,MAAM;QAClClB,MAAM,CAACgB,mBAAmB,CAAC,SAAS,EAAEL,QAAQ,CAAC;QAC/CF,MAAM,CAAC,IAAI9B,YAAY,CAAC,mBAAmB,CAAC,CAAC;MAC/C,CAAC,EAAE0B,OAAO,CAAC;MACXH,MAAM,CAACiB,WAAW,CAACxB,WAAW,CAACS,OAAO,EAAEd,EAAE,CAAC,EAAE,GAAG,CAAC;IACnD,CAAC,CAAC;EACJ,CAAC;EAAA;AAAA"}
|
|
@@ -0,0 +1,14 @@
|
|
|
1
|
+
function _defineProperty(obj, key, value) { key = _toPropertyKey(key); if (key in obj) { Object.defineProperty(obj, key, { value: value, enumerable: true, configurable: true, writable: true }); } else { obj[key] = value; } return obj; }
|
|
2
|
+
function _toPropertyKey(arg) { var key = _toPrimitive(arg, "string"); return typeof key === "symbol" ? key : String(key); }
|
|
3
|
+
function _toPrimitive(input, hint) { if (typeof input !== "object" || input === null) return input; var prim = input[Symbol.toPrimitive]; if (prim !== undefined) { var res = prim.call(input, hint || "default"); if (typeof res !== "object") return res; throw new TypeError("@@toPrimitive must return a primitive value."); } return (hint === "string" ? String : Number)(input); }
|
|
4
|
+
export class NoConsolesError extends Error {
|
|
5
|
+
constructor() {
|
|
6
|
+
super(...arguments);
|
|
7
|
+
_defineProperty(this, "isNoConsolesError", true);
|
|
8
|
+
}
|
|
9
|
+
}
|
|
10
|
+
export function isNoConsolesError(error) {
|
|
11
|
+
return error.isNoConsolesError;
|
|
12
|
+
}
|
|
13
|
+
export default NoConsolesError;
|
|
14
|
+
//# sourceMappingURL=NoConsolesError.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"NoConsolesError.js","names":["NoConsolesError","Error","isNoConsolesError","error"],"sources":["../src/NoConsolesError.ts"],"sourcesContent":["export class NoConsolesError extends Error {\n isNoConsolesError = true;\n}\n\nexport function isNoConsolesError(error: unknown): error is NoConsolesError {\n return (error as NoConsolesError).isNoConsolesError;\n}\n\nexport default NoConsolesError;\n"],"mappings":";;;AAAA,OAAO,MAAMA,eAAe,SAASC,KAAK,CAAC;EAAA;IAAA;IAAA,2CACrB,IAAI;EAAA;AAC1B;AAEA,OAAO,SAASC,iBAAiB,CAACC,KAAc,EAA4B;EAC1E,OAAQA,KAAK,CAAqBD,iBAAiB;AACrD;AAEA,eAAeF,eAAe"}
|
|
@@ -0,0 +1,101 @@
|
|
|
1
|
+
function asyncGeneratorStep(gen, resolve, reject, _next, _throw, key, arg) { try { var info = gen[key](arg); var value = info.value; } catch (error) { reject(error); return; } if (info.done) { resolve(value); } else { Promise.resolve(value).then(_next, _throw); } }
|
|
2
|
+
function _asyncToGenerator(fn) { return function () { var self = this, args = arguments; return new Promise(function (resolve, reject) { var gen = fn.apply(self, args); function _next(value) { asyncGeneratorStep(gen, resolve, reject, _next, _throw, "next", value); } function _throw(err) { asyncGeneratorStep(gen, resolve, reject, _next, _throw, "throw", err); } _next(undefined); }); }; }
|
|
3
|
+
import { requestParentResponse, SESSION_DETAILS_REQUEST } from '@deephaven/jsapi-utils';
|
|
4
|
+
import Log from '@deephaven/log';
|
|
5
|
+
import shortid from 'shortid';
|
|
6
|
+
import NoConsolesError, { isNoConsolesError } from "./NoConsolesError.js";
|
|
7
|
+
var log = Log.module('SessionUtils');
|
|
8
|
+
/**
|
|
9
|
+
* @returns New connection to the server
|
|
10
|
+
*/
|
|
11
|
+
export function createConnection(dh, websocketUrl) {
|
|
12
|
+
log.info("Starting connection to '".concat(websocketUrl, "'..."));
|
|
13
|
+
return new dh.IdeConnection(websocketUrl);
|
|
14
|
+
}
|
|
15
|
+
|
|
16
|
+
/**
|
|
17
|
+
* Create a new session using the default URL
|
|
18
|
+
* @returns A session and config that is ready to use
|
|
19
|
+
*/
|
|
20
|
+
export function createSessionWrapper(_x, _x2, _x3) {
|
|
21
|
+
return _createSessionWrapper.apply(this, arguments);
|
|
22
|
+
}
|
|
23
|
+
function _createSessionWrapper() {
|
|
24
|
+
_createSessionWrapper = _asyncToGenerator(function* (dh, connection, details) {
|
|
25
|
+
log.info('Getting console types...');
|
|
26
|
+
var types = yield connection.getConsoleTypes();
|
|
27
|
+
if (types.length === 0) {
|
|
28
|
+
throw new NoConsolesError('No console types available');
|
|
29
|
+
}
|
|
30
|
+
log.info('Available types:', types);
|
|
31
|
+
var type = types[0];
|
|
32
|
+
log.info('Starting session with type', type);
|
|
33
|
+
var session = yield connection.startSession(type);
|
|
34
|
+
var config = {
|
|
35
|
+
type,
|
|
36
|
+
id: shortid.generate()
|
|
37
|
+
};
|
|
38
|
+
log.info('Console session established', config);
|
|
39
|
+
return {
|
|
40
|
+
session,
|
|
41
|
+
config,
|
|
42
|
+
connection,
|
|
43
|
+
details,
|
|
44
|
+
dh
|
|
45
|
+
};
|
|
46
|
+
});
|
|
47
|
+
return _createSessionWrapper.apply(this, arguments);
|
|
48
|
+
}
|
|
49
|
+
export function createCoreClient(dh, websocketUrl, options) {
|
|
50
|
+
log.info('createCoreClient', websocketUrl);
|
|
51
|
+
return new dh.CoreClient(websocketUrl, options);
|
|
52
|
+
}
|
|
53
|
+
function isSessionDetails(obj) {
|
|
54
|
+
return obj != null && typeof obj === 'object';
|
|
55
|
+
}
|
|
56
|
+
function requestParentSessionDetails() {
|
|
57
|
+
return _requestParentSessionDetails.apply(this, arguments);
|
|
58
|
+
}
|
|
59
|
+
function _requestParentSessionDetails() {
|
|
60
|
+
_requestParentSessionDetails = _asyncToGenerator(function* () {
|
|
61
|
+
var response = yield requestParentResponse(SESSION_DETAILS_REQUEST);
|
|
62
|
+
if (!isSessionDetails(response)) {
|
|
63
|
+
throw new Error("Unexpected session details response: ".concat(response));
|
|
64
|
+
}
|
|
65
|
+
return response;
|
|
66
|
+
});
|
|
67
|
+
return _requestParentSessionDetails.apply(this, arguments);
|
|
68
|
+
}
|
|
69
|
+
export function getSessionDetails() {
|
|
70
|
+
return _getSessionDetails.apply(this, arguments);
|
|
71
|
+
}
|
|
72
|
+
function _getSessionDetails() {
|
|
73
|
+
_getSessionDetails = _asyncToGenerator(function* () {
|
|
74
|
+
var searchParams = new URLSearchParams(window.location.search);
|
|
75
|
+
switch (searchParams.get('authProvider')) {
|
|
76
|
+
case 'parent':
|
|
77
|
+
return requestParentSessionDetails();
|
|
78
|
+
}
|
|
79
|
+
return {};
|
|
80
|
+
});
|
|
81
|
+
return _getSessionDetails.apply(this, arguments);
|
|
82
|
+
}
|
|
83
|
+
export function loadSessionWrapper(_x4, _x5, _x6) {
|
|
84
|
+
return _loadSessionWrapper.apply(this, arguments);
|
|
85
|
+
}
|
|
86
|
+
function _loadSessionWrapper() {
|
|
87
|
+
_loadSessionWrapper = _asyncToGenerator(function* (dh, connection, sessionDetails) {
|
|
88
|
+
var sessionWrapper;
|
|
89
|
+
try {
|
|
90
|
+
sessionWrapper = yield createSessionWrapper(dh, connection, sessionDetails);
|
|
91
|
+
} catch (e) {
|
|
92
|
+
// Consoles may be disabled on the server, but we should still be able to start up and open existing objects
|
|
93
|
+
if (!isNoConsolesError(e)) {
|
|
94
|
+
throw e;
|
|
95
|
+
}
|
|
96
|
+
}
|
|
97
|
+
return sessionWrapper;
|
|
98
|
+
});
|
|
99
|
+
return _loadSessionWrapper.apply(this, arguments);
|
|
100
|
+
}
|
|
101
|
+
//# sourceMappingURL=SessionUtils.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"SessionUtils.js","names":["requestParentResponse","SESSION_DETAILS_REQUEST","Log","shortid","NoConsolesError","isNoConsolesError","log","module","createConnection","dh","websocketUrl","info","IdeConnection","createSessionWrapper","connection","details","types","getConsoleTypes","length","type","session","startSession","config","id","generate","createCoreClient","options","CoreClient","isSessionDetails","obj","requestParentSessionDetails","response","Error","getSessionDetails","searchParams","URLSearchParams","window","location","search","get","loadSessionWrapper","sessionDetails","sessionWrapper","e"],"sources":["../src/SessionUtils.ts"],"sourcesContent":["import type {\n ConnectOptions,\n CoreClient,\n dh as DhType,\n IdeConnection,\n IdeSession,\n} from '@deephaven/jsapi-types';\nimport {\n requestParentResponse,\n SESSION_DETAILS_REQUEST,\n} from '@deephaven/jsapi-utils';\nimport Log from '@deephaven/log';\nimport shortid from 'shortid';\nimport NoConsolesError, { isNoConsolesError } from './NoConsolesError';\n\nconst log = Log.module('SessionUtils');\n\nexport interface SessionConfig {\n type: string;\n id: string;\n}\n\nexport interface SessionDetails {\n workerName?: string;\n processInfoId?: string;\n}\n\nexport interface SessionWrapper {\n session: IdeSession;\n connection: IdeConnection;\n config: SessionConfig;\n details?: SessionDetails;\n dh: DhType;\n}\n\n/**\n * @returns New connection to the server\n */\nexport function createConnection(\n dh: DhType,\n websocketUrl: string\n): IdeConnection {\n log.info(`Starting connection to '${websocketUrl}'...`);\n\n return new dh.IdeConnection(websocketUrl);\n}\n\n/**\n * Create a new session using the default URL\n * @returns A session and config that is ready to use\n */\nexport async function createSessionWrapper(\n dh: DhType,\n connection: IdeConnection,\n details: SessionDetails\n): Promise<SessionWrapper> {\n log.info('Getting console types...');\n\n const types = await connection.getConsoleTypes();\n\n if (types.length === 0) {\n throw new NoConsolesError('No console types available');\n }\n\n log.info('Available types:', types);\n\n const type = types[0];\n\n log.info('Starting session with type', type);\n\n const session = await connection.startSession(type);\n\n const config = { type, id: shortid.generate() };\n\n log.info('Console session established', config);\n\n return {\n session,\n config,\n connection,\n details,\n dh,\n };\n}\n\nexport function createCoreClient(\n dh: DhType,\n websocketUrl: string,\n options?: ConnectOptions\n): CoreClient {\n log.info('createCoreClient', websocketUrl);\n\n return new dh.CoreClient(websocketUrl, options);\n}\n\nfunction isSessionDetails(obj: unknown): obj is SessionDetails {\n return obj != null && typeof obj === 'object';\n}\n\nasync function requestParentSessionDetails(): Promise<SessionDetails> {\n const response = await requestParentResponse(SESSION_DETAILS_REQUEST);\n if (!isSessionDetails(response)) {\n throw new Error(`Unexpected session details response: ${response}`);\n }\n return response;\n}\n\nexport async function getSessionDetails(): Promise<SessionDetails> {\n const searchParams = new URLSearchParams(window.location.search);\n switch (searchParams.get('authProvider')) {\n case 'parent':\n return requestParentSessionDetails();\n }\n return {};\n}\n\nexport async function loadSessionWrapper(\n dh: DhType,\n connection: IdeConnection,\n sessionDetails: SessionDetails\n): Promise<SessionWrapper | undefined> {\n let sessionWrapper: SessionWrapper | undefined;\n try {\n sessionWrapper = await createSessionWrapper(dh, connection, sessionDetails);\n } catch (e) {\n // Consoles may be disabled on the server, but we should still be able to start up and open existing objects\n if (!isNoConsolesError(e)) {\n throw e;\n }\n }\n return sessionWrapper;\n}\n"],"mappings":";;AAOA,SACEA,qBAAqB,EACrBC,uBAAuB,QAClB,wBAAwB;AAC/B,OAAOC,GAAG,MAAM,gBAAgB;AAChC,OAAOC,OAAO,MAAM,SAAS;AAAC,OACvBC,eAAe,IAAIC,iBAAiB;AAE3C,IAAMC,GAAG,GAAGJ,GAAG,CAACK,MAAM,CAAC,cAAc,CAAC;AAoBtC;AACA;AACA;AACA,OAAO,SAASC,gBAAgB,CAC9BC,EAAU,EACVC,YAAoB,EACL;EACfJ,GAAG,CAACK,IAAI,mCAA4BD,YAAY,UAAO;EAEvD,OAAO,IAAID,EAAE,CAACG,aAAa,CAACF,YAAY,CAAC;AAC3C;;AAEA;AACA;AACA;AACA;AACA,gBAAsBG,oBAAoB;EAAA;AAAA;AAgCzC;EAAA,0CAhCM,WACLJ,EAAU,EACVK,UAAyB,EACzBC,OAAuB,EACE;IACzBT,GAAG,CAACK,IAAI,CAAC,0BAA0B,CAAC;IAEpC,IAAMK,KAAK,SAASF,UAAU,CAACG,eAAe,EAAE;IAEhD,IAAID,KAAK,CAACE,MAAM,KAAK,CAAC,EAAE;MACtB,MAAM,IAAId,eAAe,CAAC,4BAA4B,CAAC;IACzD;IAEAE,GAAG,CA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AY,CAACK,GAAG,CAAC,cAAc,CAAC;MACtC,KAAK,QAAQ;QACX,OAAOT,2BAA2B,EAAE;IAAC;IAEzC,OAAO,CAAC,CAAC;EACX,CAAC;EAAA;AAAA;AAED,gBAAsBU,kBAAkB;EAAA;AAAA;AAevC;EAAA,wCAfM,WACL/B,EAAU,EACVK,UAAyB,EACzB2B,cAA8B,EACO;IACrC,IAAIC,cAA0C;IAC9C,IAAI;MACFA,cAAc,SAAS7B,oBAAoB,CAACJ,EAAE,EAAEK,UAAU,EAAE2B,cAAc,CAAC;IAC7E,CAAC,CAAC,OAAOE,CAAC,EAAE;MACV;MACA,IAAI,CAACtC,iBAAiB,CAACsC,CAAC,CAAC,EAAE;QACzB,MAAMA,CAAC;MACT;IACF;IACA,OAAOD,cAAc;EACvB,CAAC;EAAA;AAAA"}
|
package/dist/Settings.js
ADDED
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"Settings.js","names":[],"sources":["../src/Settings.ts"],"sourcesContent":["import { FormattingRule } from './Formatter';\n\nexport interface ColumnFormatSettings {\n formatter?: FormattingRule[];\n}\n\nexport interface DateTimeFormatSettings {\n timeZone?: string;\n defaultDateTimeFormat?: string;\n showTimeZone?: boolean;\n showTSeparator?: boolean;\n}\n\nexport interface NumberFormatSettings {\n defaultDecimalFormatOptions?: {\n defaultFormatString?: string;\n };\n defaultIntegerFormatOptions?: {\n defaultFormatString?: string;\n };\n truncateNumbersWithPound?: boolean;\n}\n\nexport interface Settings\n extends ColumnFormatSettings,\n DateTimeFormatSettings,\n NumberFormatSettings {}\n\nexport default Settings;\n"],"mappings":""}
|