Huge News!Announcing our $40M Series B led by Abstract Ventures.Learn More
Socket
Sign inDemoInstall
Socket

datagrok-api

Package Overview
Dependencies
Maintainers
4
Versions
485
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

datagrok-api - npm Package Compare versions

Comparing version 0.1.39 to 0.1.40

0

dg.d.ts

@@ -0,0 +0,0 @@ import * as _chem from './src/chem';

1

dg.js

@@ -18,2 +18,3 @@ import * as _chem from './src/chem.js';

export * from './src/wrappers_impl';
export {time} from './src/utils.js';
export {JsEntityMeta} from './ui';

@@ -20,0 +21,0 @@

@@ -0,0 +0,0 @@ import * as _chem from './src/chem';

@@ -0,0 +0,0 @@ import * as _chem from './src/chem';

@@ -0,0 +0,0 @@ {

4

package.json
{
"name": "datagrok-api",
"version": "0.1.39",
"version": "0.1.40",
"description": "",

@@ -23,2 +23,2 @@ "dependencies": {

}
}
}

@@ -0,0 +0,0 @@ /**

@@ -19,12 +19,21 @@ /**

* @async
* @param {Column} column - Molecule column to search in.
* @param {string} molecule - Reference molecule in SMILES format.
* @param {SimilarityMetric} metric - Metric to use.
* @param {number} limit - Maximum number of results to return.
* @param {number} minScore - Minimum similarity score for a molecule to be included.
* @param {Column} column - Molecule column to search in
* @param {string} pattern - Reference molecule in one of formats supported by RDKit:
* smiles, cxsmiles, molblock, v3Kmolblock
* @param {boolean} settings.sorted -
* if set, returns a two-column dataframe with molecule strings and scores,
* sorted in descending order by the score
* @returns {Promise<DataFrame>}
* */
export function similaritySearch(column, molecule, metric = SIMILARITY_METRIC.TANIMOTO, limit = 10, minScore = 0.7) {
return new Promise((resolve, reject) => grok_Chem_SimilaritySearch(column.d, molecule, metric,
limit, minScore, (t) => resolve(new DataFrame(t))));
export async function similarityScoring(column, pattern, settings = { sorted: false }) {
let foo = await grok.functions.eval('Chem:similarityScoring');
let call = await foo.prepare({
'molStringsColumn': column,
'molString': pattern,
'sorted': settings.sorted
});
await call.call();
return call.getParamValue('result');
}

@@ -49,11 +58,20 @@

* @async
* @param {Column} column - Column with molecules to search.
* @param {string} pattern - Pattern, either SMARTS or SMILES.
* @param {boolean} isSmarts - Whether the pattern is SMARTS.
* @param {Column} column - Column with molecules to search
* @param {string} pattern - Pattern, either one of which RDKit supports
* @returns {Promise<BitSet>}
* */
export function substructureSearch(column, pattern, isSmarts = true) {
return new Promise((resolve, reject) => grok_Chem_SubstructureSearch(column.d, pattern, isSmarts, (bs) => resolve(new BitSet(bs))));
export async function substructureSearch(column, pattern, settings = {}) {
let foo = await grok.functions.eval('Chem:substructureSearch');
let call = await foo.prepare({
'molStringsColumn': column,
'molString': pattern
});
await call.call();
// unpacking our BitSet object from a synthetic column
return call.getParamValue('result').get(0);
}
/**

@@ -126,7 +144,7 @@ * Performs R-group analysis.

/**
* Molecule sketcher.
* @param {function} handler Molecule on change handler, SMILES
* Sketches Molecule sketcher.
* @param {function} onChangedCallback - a function that accepts (smiles, molfile)
* @param {string} smiles Initial molecule
* @returns {HTMLElement}
* */
export function sketcher(handler, smiles = '') { return grok_Chem_Sketcher(handler, smiles); }
export function sketcher(onChangedCallback, smiles = '') { return grok_Chem_Sketcher(onChangedCallback, smiles); }

@@ -0,0 +0,0 @@ export const enum AGG {

@@ -0,0 +0,0 @@ /**

@@ -0,0 +0,0 @@ import {

@@ -11,3 +11,5 @@ import {

TableInfo,
User
User,
LogEvent,
LogEventType
} from "./entities";

@@ -116,2 +118,14 @@ import {ViewLayout} from "./view";

}
/** Administering API endpoint
* @type {AdminDataSource} */
get admin() { return new AdminDataSource(grok_Dapi_Admin()); }
/** Logging API endpoint
* @type {HttpDataSource<LogEvent>} */
get log() { return new HttpDataSource(grok_Dapi_Log(), (a) => new LogEvent(a)); }
/** Logging API endpoint
* @type {HttpDataSource<LogEventType>} */
get logTypes() { return new HttpDataSource(grok_Dapi_LogTypes(), (a) => new LogEventType(a)); }
}

@@ -224,2 +238,10 @@

}
/** Includes entity in the result
* @param {string} include
* @returns {HttpDataSource} */
include(include) {
this.s = grok_DataSource_Include(this.s, include);
return this;
}
}

@@ -246,4 +268,23 @@

}
/** Returns current session
* @returns {Promise<UserSession>} */
currentSession() {
return new Promise((resolve, reject) => grok_UsersDataSource_CurrentSession(this.s, (q) => resolve(toJs(q))));
}
}
export class AdminDataSource {
/** @constructs AdminDataSource*/
constructor(s) {
this.s = s;
}
/** Returns information about the services
* @returns {Promise<Map>} */
getServiceInfos() {
return new Promise((resolve, reject) => grok_Dapi_Admin_GetServiceInfos(this.s, (q) => resolve(toJs(q)), (e) => reject(e)));
}
}
/**

@@ -250,0 +291,0 @@ * Functionality for handling groups collection from server

@@ -0,0 +0,0 @@ import {DataFrame} from "./dataframe";

@@ -0,0 +0,0 @@ import {DataFrame} from "./dataframe";

@@ -0,0 +0,0 @@ import {Observable} from 'rxjs';

@@ -5,3 +5,16 @@ import * as rxjs from 'rxjs';

import {toDart, toJs} from "./wrappers";
import {SIMILARITY_METRIC} from "./const";
import {_getIterator, _toIterable} from "./utils";
class MapProxy {
constructor(d) {
this.d = d;
return new Proxy({}, {
get: function(target, prop) { return DG.toJs(grok_Map_Get(d, prop)); },
set: function(target, prop, value) { grok_Map_Set(d, prop, DG.toDart(value)); }
})
}
}
/**

@@ -18,5 +31,16 @@ * DataFrame is a high-performance, easy to use tabular structure with

this.d = d;
this.columns = new ColumnList(grok_DataFrame_Columns(this.d));
this.columns = toJs(grok_DataFrame_Columns(this.d));
this.rows = new RowList(this, grok_DataFrame_Rows(this.d));
this.filter = new BitSet(grok_DataFrame_Get_Filter(this.d));
this.temp = new MapProxy(grok_DataFrame_Get_Temp(this.d));
this.tags = new MapProxy(grok_DataFrame_Get_Tags(this.d));
// return new Proxy(this, {
// get(target, name) {
// if (target.hasOwnProperty(name))
// return target[name];
// return target.table.get(name, target.idx);
// }
// });
}

@@ -44,4 +68,2 @@

toString() { return `${this.name} (${this.rowCount} rows, ${this.columns.length} columns)` };
/** Returns number of rows in the table.

@@ -88,3 +110,3 @@ * @returns {number} */

* @returns {Column} */
col(name) { return new Column(grok_DataFrame_ColumnByName(this.d, name)); }
col(name) { return toJs(grok_DataFrame_ColumnByName(this.d, name)); }

@@ -116,3 +138,3 @@ /** Returns a {@link Cell} with the specified name.

clone(rowMask = null, columnIds = null, saveSelection = false) {
return new DataFrame(grok_DataFrame_Clone(this.d, rowMask.d, columnIds, saveSelection));
return new DataFrame(grok_DataFrame_Clone(this.d, toDart(rowMask), columnIds, saveSelection));
}

@@ -127,3 +149,3 @@

* @type {Column} */
get currentCol() { return new Column(grok_DataFrame_Get_CurrentCol(this.d)); }
get currentCol() { return toJs(grok_DataFrame_Get_CurrentCol(this.d)); }
set currentCol(col) { grok_DataFrame_Set_CurrentCol(this.d, col.d); }

@@ -163,3 +185,3 @@

changeColumnType(column, newType, format = null) {
return new Column(grok_DataFrame_ChangeColumnType(this.d, toDart(column), newType, format));
return toJs(grok_DataFrame_ChangeColumnType(this.d, toDart(column), newType, format));
}

@@ -173,2 +195,21 @@

unpivot(copyColumnNames, mergeColumnNames, categoryColumnName = 'Category', valueColumnName = 'Value') {
return new DataFrame(grok_DataFrame_Unpivot(this.d, copyColumnNames, mergeColumnNames, categoryColumnName, valueColumnName));
}
/**
* Merges two tables by the specified key columns.
* @param {DataFrame} t2
* @param {string[]} keyColumns1
* @param {string[]} keyColumns2
* @param {string[]} valueColumns1
* @param {string[]} valueColumns2
* @param {JoinType} joinType
* @param {boolean} inPlace - merges content in-place into the source table
* @returns {DataFrame}
* */
join(t2, keyColumns1, keyColumns2, valueColumns1, valueColumns2, joinType, inPlace) {
return new DataFrame(grok_JoinTables(this.d, t2.d, keyColumns1, keyColumns2, valueColumns1, valueColumns2, joinType, inPlace));
}
append(t2, inPlace = false) { return new DataFrame(grok_DataFrame_Append(this.d, t2.d, inPlace)); }

@@ -205,2 +246,5 @@

fireValuesChanged() { grok_DataFrame_FireValuesChanged(this.d); }
/** @returns {string} */
toString() { return grok_Object_ToString(this.d); }
}

@@ -222,6 +266,5 @@

const setables = ['table', 'idx'];
return new Proxy(this, {
set(target, name, value) {
if (setables.includes(name)) {
if (target.hasOwnProperty(name)) {
target[name] = value;

@@ -234,3 +277,3 @@ return true;

get(target, name) {
if (setables.includes(name))
if (target.hasOwnProperty(name))
return target[name];

@@ -242,4 +285,6 @@ return target.table.get(name, target.idx);

/** Returns th */
get(name, idx) { return this.table.getCol(name).get(idx); }
/** Returns this row's value for the specified column
* @param {string} columnName
* @returns {Object} */
get(columnName) { return this.table.getCol(columnName).get(this.idx); }
}

@@ -249,13 +294,27 @@

export class Column {
constructor(d) { this.d = d; }
static fromStrings(name, list) { return new Column(grok_Column_FromStrings(name, list)); }
constructor(d) {
this.d = d;
this.temp = new MapProxy(grok_Column_Get_Temp(this.d));
this.tags = new MapProxy(grok_Column_Get_Tags(this.d));
//
// return new Proxy(this, {
// get(target, x) {
// if (typeof x === 'number')
// return target.get(x);
// if (target.hasOwnProperty(x))
// return target[x];
// }
// });
}
static fromStrings(name, list) { return toJs(grok_Column_FromStrings(name, list)); }
static fromType(type, name = null, length = 0) {
return new Column(grok_Column_FromType(type, name, length));
return toJs(grok_Column_FromType(type, name, length));
}
/** [array] will be not be copied and will be used as column's storage */
static fromInt32Array(name, array, length = null) { return new Column(grok_Column_FromInt32Array(name, array, length)); }
static fromInt32Array(name, array, length = null) { return toJs(grok_Column_FromInt32Array(name, array, length)); }
/** [array] will be not be copied and will be used as column's storage */
static fromFloat32Array(name, array, length = null) { return new Column(grok_Column_FromFloat32Array(name, array, length)); }
static fromFloat32Array(name, array, length = null) { return toJs(grok_Column_FromFloat32Array(name, array, length)); }

@@ -267,4 +326,10 @@ /** Creates a {@link Column} from the list of values.

* @returns {Column} */
static fromList(type, name, list) { return new Column(grok_Column_FromList(type, name, list)); }
static fromList(type, name, list) { return toJs(grok_Column_FromList(type, name, list)); }
/** Creates a {Column} from the bitset.
* @param {string} name
* @param {BitSet} bitset
* @returns {Column} */
static fromBitSet(name, bitset) { return toJs(grok_Column_FromBitSet(name, bitset.d)); }
/** Creates an integer column with the specified name and length.

@@ -320,16 +385,25 @@ * @param {string} name

/** Column data type. */
/** Column data type.
* @type {string} */
get type() { return grok_Column_Get_Type(this.d); }
/** Number of elements */
/** Number of elements
* @type {number} */
get length() { return grok_Column_Get_Length(this.d); }
/** Parent table */
get dataFrame() { return new DataFrame(grok_Column_Get_DataFrame(this.d)); }
/** Parent table
* @type {DataFrame} */
get dataFrame() { return toJs(grok_Column_Get_DataFrame(this.d)); }
/** Semantic type */
/** Semantic type
* @type {string} */
get semType() { return grok_Column_Get_SemType(this.d); }
set semType(s) { grok_Column_Set_SemType(this.d, s); }
/** Name */
/** Layout column ID
@type {string} */
get layoutColumnId() { return grok_Column_Get_LayoutColumnId(this.d); }
set layoutColumnId(s) { grok_Column_Set_LayoutColumnId(this.d, s); }
/** @type {string} */
get name() { return grok_Column_Get_Name(this.d); }

@@ -350,5 +424,32 @@ set name(s) { grok_Column_Set_Name(this.d, s); }

/** Gets i-th value */
get(i) { return grok_Column_GetValue(this.d, i); }
/** Gets i-th value
* @param {number} row - row index
* @returns {object} - or null if isNone(i) */
get(row) { return grok_Column_GetValue(this.d, row); }
// /** Returns i-th value as integer. Throws exception if column's type is not TYPE_INT or TYPE_DATE_TIME.
// * @param {number} i
// * @returns {number} */
// getInt(i);
//
// /** Returns i-th value as a integer. Works for IntColumns only.
// * @param {number} i
// * @returns {number} */
// getFloat(i)
//
// /** Returns i-th value as boolean. Works for IntColumns only.
// * @param {number} i
// * @returns {number} */
// getBool(i)
//
// /** Returns i-th value as integer. Works for IntColumns only.
// * @param {number} i
// * @returns {number} */
// getDateTime(i)
//
// /** Returns i-th value as integer. Works for IntColumns only.
// * @param {number} i
// * @returns {number} */
// getString(i);
/**

@@ -358,4 +459,5 @@ * Sets [i]-th value to [x]

* @param x
* @param {boolean} notify
*/
set(i, x) { grok_Column_SetValue(this.d, i, x); }
set(i, x, notify = true) { grok_Column_SetValue(this.d, i, x, notify); }

@@ -389,2 +491,10 @@ /** Returns whether i-th value is missing.

/** Sets order of categories
* @param {string[]} order */
setCategoryOrder(order) { grok_Column_SetCategoryOrder(this.d, order); }
/** Gets order of categories
* @returns string[] */
getCategoryOrder() { return grok_Column_GetCategoryOrder(this.d); }
/** Column's minimum value. The result is cached.

@@ -414,4 +524,7 @@ * @returns {number} */

convertTo(newType, format = null) {
return new Column(grok_Column_ConvertTo(this.d, newType, format));
return toJs(grok_Column_ConvertTo(this.d, newType, format));
}
/** @returns {string} */
toString() { return grok_Object_ToString(this.d); }
}

@@ -430,3 +543,3 @@

* @returns {Column} */
byName(name) { return new Column(grok_ColumnList_ByName(this.d, name)); }
byName(name) { return toJs(grok_ColumnList_ByName(this.d, name)); }

@@ -436,3 +549,3 @@ /** Column by index.

* @returns {Column} */
byIndex(index) { return new Column(grok_ColumnList_ByIndex(this.d, index)); }
byIndex(index) { return toJs(grok_ColumnList_ByIndex(this.d, index)); }

@@ -443,3 +556,3 @@ /** First column of [semType], or null.

var col = grok_ColumnList_BySemType(this.d, semType);
return col == null ? null : new Column(col);
return col == null ? null : toJs(col);
}

@@ -460,15 +573,17 @@

//todo
//numerical
/** @returns {Iterable.<Column>} */
byTags(tags) {
return _toIterable(grok_ColumnList_ByTags(this.d, tags));
}
/** @returns {Column[]} */
/** @returns {Iterable.<Column>} */
get categorical() {
//todo: convert to iterable
let result = [];
for (let i = 0; i < this.length; i++)
if (this.byIndex(i).type === COLUMN_TYPE.STRING)
result.push(this.byIndex(i));
return result;
return _toIterable(grok_ColumnList_Categorical(this.d));
}
/** @returns {Iterable.<Column>} */
get numerical() {
return _toIterable(grok_ColumnList_Numerical(this.d));
}
/** Array containing column names.

@@ -486,3 +601,3 @@ * @returns {string[]} */

* @returns {Column} */
add(column, notify = false) {
add(column, notify = true) {
grok_ColumnList_Add(this.d, column.d, notify);

@@ -496,3 +611,3 @@ return column;

* @returns {Column} */
addNew(name, type) { return new Column(grok_ColumnList_AddNew(this.d, name, type)); }
addNew(name, type) { return toJs(grok_ColumnList_AddNew(this.d, name, type)); }

@@ -513,2 +628,17 @@ /** Adds a virtual column.

contains(columnName) { return grok_ColumnList_Contains(this.d, columnName); }
/** Replaces the column with the new column.
* @param {Column} columnToReplace
* @param {Column} newColumn */
replace(columnToReplace, newColumn) { grok_ColumnList_Replace(this.d, (typeof columnToReplace === 'string') ? columnToReplace : columnToReplace.d, newColumn.d); }
/** Iterates over all columns.
* @returns {Iterable.<Column>}
* */
[Symbol.iterator]() {
return _getIterator(this.d);
}
/** @returns {string} */
toString() { return grok_Object_ToString(this.d); }
}

@@ -525,3 +655,4 @@

/** @member {DataFrame} */
this.table = table; this.d = d;
this.table = table;
this.d = d;
}

@@ -575,8 +706,15 @@

select(rowPredicate) {
_applyPredicate(this.table.selection, rowPredicate);
this._applyPredicate(this.table.selection, rowPredicate);
}
filter(rowPredicate) {
_applyPredicate(this.table.filter, rowPredicate);
this._applyPredicate(this.table.filter, rowPredicate);
}
/** Viewers that filter rows should subscribe to DataFrame.onRowsFiltering event.
* When filtering conditions are changed, viewers should call requestFilter(). */
requestFilter() { grok_RowList_RequestFilter(this.d); }
/** @returns {string} */
toString() { return grok_Object_ToString(this.d); }
}

@@ -602,3 +740,3 @@

* @returns {Column} */
get column() { return new Column(grok_Cell_Get_Column(this.d)); }
get column() { return toJs(grok_Cell_Get_Column(this.d)); }

@@ -608,2 +746,5 @@ /** Cell value.

get value() { return grok_Cell_Get_Value(this.d); }
/** @returns {string} */
toString() { return grok_Object_ToString(this.d); }
}

@@ -620,7 +761,30 @@

/** Creates a {BitSet} from the string representing the bitset.
* @param {string} zerosOnes - A string containing '1' and '0'.
* @returns {BitSet} */
static fromString(zerosOnes) { return new BitSet(grok_BitSet_FromString(zerosOnes)); }
/** Creates a {BitSet} from the ArrayBuffer representing the bitset.
* @param {ArrayBuffer} buffer - An array containing 1 and 0.
* @param {Number} bitLength - count of bits.
* @returns {BitSet} */
static fromBytes(buffer, bitLength) {
if (bitLength == null || !Number.isInteger(bitLength) || bitLength < 0)
bitLength = buffer.byteLength * 8;
return new BitSet(grok_BitSet_FromBytes(buffer, bitLength));
}
/** Creates a {BitSet} of the specified length with all bits set to false.
* @param {number} length - Number of bits.
* @param {Function} f - when specified, Sets all bits by setting i-th bit to the results of f(i)
* @returns {BitSet} */
static create(length) { return new BitSet(grok_BitSet(length)); }
static create(length, f = null) {
let bitset = new BitSet(grok_BitSet(length));
if (f != null)
f.init(f);
return bitset;
}
toBinaryString() { return grok_BitSet_ToBinaryString(this.d); }
/** Number of bits in a bitset

@@ -687,3 +851,4 @@ * @type {number} */

/** Sets all bits by setting i-th bit to the results of f(i)
* @param {Function} f */
* @param {Function} f
* @returns {BitSet} */
init(f) {

@@ -704,2 +869,3 @@ let buf = grok_BitSet_Get_Buffer(this.d);

this.fireChanged();
return this;
}

@@ -723,5 +889,8 @@

* @param {BitSet} b - second BitSet.
* @param {string} metric - similarity metric.
* @param {SimilarityMetric} metric - similarity metric to use.
* @returns {number} */
similarityTo(b, metric) { return grok_BitSet_SimilarityTo(this.d, b.d, metric); }
similarityTo(b, metric = SIMILARITY_METRIC.TANIMOTO) { return grok_BitSet_SimilarityTo(this.d, b.d, metric); }
/** @returns {string} */
toString() { return grok_Object_ToString(this.d); }
}

@@ -784,2 +953,5 @@

get q3() { return grok_Stats_Get_Q3(this.d); }
/** @returns {string} */
toString() { return grok_Object_ToString(this.d); }
}

@@ -936,2 +1108,9 @@

/** Adds an aggregation that takes first value for the specified column.
* Call {@link aggregate} when the query is constructed.
* @param {string} srcColName - column name in the source table
* @param {string} [resultColName] - column name in the resulting DataFrame
* @returns {GroupByBuilder} */
first(srcColName, resultColName = null) { return this.add(AGG.FIRST, srcColName, resultColName); }
/**

@@ -941,2 +1120,5 @@ * @param {BitSet} bitset

whereRowMask(bitset) { grok_GroupByBuilder_WhereBitSet(this.d, bitset.d); return this; }
/** @returns {string} */
toString() { return grok_Object_ToString(this.d); }
}

@@ -943,0 +1125,0 @@

@@ -0,0 +0,0 @@ /**

@@ -97,2 +97,8 @@ /**

/**
* Undocks the element.
* @param {HTMLElement} element - Element to undock
* */
undock(element) { grok_DockManager_Undock(this.d, element); }
// /**

@@ -99,0 +105,0 @@ // * Docks the element relative to the reference node.

@@ -301,2 +301,22 @@ import {SEMTYPE, TYPE} from "./const";

export class LogEvent extends Entity {
constructor(d: any)
/** Description of the event
* @type {string} */
get description(): string
/** Friendly name of the event
* @type {string} */
get name(): string
/** Source of the event
* @type {string} */
get source(): string
/** Session id of the event
* @type {string} */
get session(): string
}
/**

@@ -303,0 +323,0 @@ * Represents a package, which is a unit of distribution of content in the Datagrok platform.

@@ -85,2 +85,31 @@ import {TYPE} from "./const";

/**
* Represents a user session in the Datagrok platform.
* @extends Entity
* */
export class UserSession {
/** @constructs UserSession*/
constructor(d) {
this.d = d;
}
/** Entity ID (GUID)
* @type {string} */
get id() { return grok_Entity_Get_Id(this.d); }
set id(x) { return grok_Entity_Set_Id(this.d, x); }
/** Login
* @type {string} */
get type() { return grok_UserSession_Get_Type(this.d); }
/** External Token
* @type {string} */
get externalToken() { return grok_UserSession_Get_ExternalToken(this.d); }
/** User
* @type {User} */
get user() { return toJs(grok_UserSession_Get_User(this.d)); }
}
/** Represents a function

@@ -92,3 +121,3 @@ * @extends Entity

/** @constructs Func*/
constructor(d) {super(d)}
constructor(d) { super(d); }

@@ -345,2 +374,78 @@ /** Returns {@link FuncCall} object in a stand-by state

export class LogEventType extends Entity {
constructor(d) { super(d); }
/** Friendly name of the event type
* @type {string} */
get name() { return grok_LogEventType_Get_Name(this.d); }
}
export class LogEvent extends Entity {
constructor(d) { super(d); }
/** Description of the event
* @type {string} */
get description() { return grok_LogEvent_Get_Description(this.d); }
/** Friendly name of the event
* @type {string} */
get name() { return grok_LogEvent_Get_Name(this.d); }
/** Source of the event
* @type {string} */
get source() { return grok_LogEvent_Get_Source(this.d); }
/** Session id of the event
* @type {UserSession} */
get session() { return toJs(grok_LogEvent_Get_Session(this.d)); }
/** Parameters of the event
* @type {ArrayList<LogEventParameterValue>} */
get parameters() { return grok_LogEvent_Get_Parameters(this.d); }
/** Type of the event
* @type {LogEventType} */
get eventType() { return toJs(grok_LogEvent_Get_Type(this.d)); }
}
export class LogEventParameter extends Entity {
constructor(d) { super(d); }
/** Name of the parameter
* @type {string} */
get name() { return grok_LogEventParameter_Get_Name(this.d); }
/** Type of the parameter
* @type {string} */
get type() { return grok_LogEventParameter_Get_Type(this.d); }
/** Description of the parameter
* @type {string} */
get description() { return grok_LogEventParameter_Get_Description(this.d); }
/** Is the parameter input
* @type {Boolean} */
get isInput() { return grok_LogEventParameter_Get_IsInput(this.d); }
/** Is the parameter optional
* @type {Boolean} */
get isOptional() { return grok_LogEventParameter_Get_IsOptional(this.d); }
}
export class LogEventParameterValue extends Entity {
constructor(d) { super(d); }
/** Event of the parameter value
* @type {LogEvent} */
get event() { return toJs(grok_LogEventParameterValue_Get_Event(this.d)); }
/** Parameter of the parameter value
* @type {LogEventParameter} */
get parameter() { return toJs(grok_LogEventParameterValue_Get_Parameter(this.d)); }
/** Parameter value
* @type {string} */
get value() { return grok_LogEventParameterValue_Get_Value(this.d); }
}
/**

@@ -353,2 +458,3 @@ * Represents a package, which is a unit of distribution of content in the Datagrok platform.

this.name = "";
this.version = "";
}

@@ -355,0 +461,0 @@

@@ -0,0 +0,0 @@ import {Observable} from "rxjs";

@@ -28,3 +28,7 @@ import * as rxjs from "rxjs";

/**
* Converts Dart stream to Observable.
* @param {Object} dartStream
* @returns {Observable}
* */
export function observeStream(dartStream) {

@@ -31,0 +35,0 @@ let observable = rxjs.fromEventPattern(

@@ -0,0 +0,0 @@ import {Script} from "./entities";

@@ -0,0 +0,0 @@ import {paramsToJs, toDart, toJs} from "./wrappers";

@@ -0,0 +0,0 @@ import {Cell, Column, Row} from "./dataframe";

import {Viewer} from "./viewer.js";
import {Column} from './dataframe.js';
import {Cell} from "./dataframe";
import {toDart} from "./wrappers";
import {toDart, toJs} from "./wrappers";
import {__obs, _sub, EventData} from "./events";

@@ -130,3 +130,3 @@ import {_identityInt32} from "./utils";

/** Column visibility.
* @returns {string} */
* @returns {boolean} */
get visible() { return grok_GridColumn_Get_Visible(this.d); }

@@ -238,2 +238,12 @@ set visible(x) { return grok_GridColumn_Set_Visible(this.d, x); }

static create(table) { return new Grid(grok_Grid_Create(table.d)); }
/** @returns {RangeSlider} */
get vertScroll() { return toJs(grok_Grid_Get_VertScroll(this.d)); }
/** @returns {RangeSlider} */
get horzScroll() { return toJs(grok_Grid_Get_HorzScroll(this.d)); }
/** Forces the grid to execute calculations that were postponed before the next rendering (such as recalculating layout).
* Call it in case the client code changes column widths and needs to access the new recalculated layout. */
runPostponedComputations() { grok_CanvasViewer_RunPostponedComputations(this.d); }
}

@@ -277,2 +287,5 @@

get defaultWidth() { return null; }
get defaultHeight() { return null; }
/**

@@ -279,0 +292,0 @@ * @param {CanvasRenderingContext2D} g

@@ -0,0 +0,0 @@ /**

@@ -0,0 +0,0 @@ /**

@@ -0,0 +0,0 @@ import {DataFrame} from "./dataframe";

@@ -46,2 +46,14 @@ import {DataFrame} from "./dataframe";

/** Adds a table to the workspace.
* @param {DataFrame} table*/
addTable(table) {
grok_AddTable(table.d);
}
/** Closes a table and removes from the workspace.
* @param {DataFrame} table */
closeTable(table) {
grok_CloseTable(table.d);
}
/** Current user

@@ -53,3 +65,3 @@ * @type {User} */

get o() { return toJs(grok_Get_CurrentObject(), false); }
set o(x) { grok_Set_CurrentObject(toJs(x)); }
set o(x) { grok_Set_CurrentObject(toDart(x)); }

@@ -102,3 +114,3 @@ /** @type {TabControl} */

this.addView(item);
else if (item instanceof HtmlElement)
else if (item instanceof HTMLElement)
this.dockElement(item);

@@ -113,6 +125,8 @@ else

* @param {View} v
* @param {DockType=} dockType
* @param {number=} width
* @returns {View}
*/
addView(v) {
grok_AddView(v.d);
addView(v, dockType = DG.DOCK_TYPE.FILL, width = null) {
grok_AddView(v.d, dockType, width);
return v;

@@ -141,3 +155,3 @@ }

addTableView(table, dockType = DG.DOCK_TYPE.FILL, width = null) {
return new TableView(grok_AddTableView(table.d, dockType, width));
return toJs(grok_AddTableView(table.d, dockType, width));
}

@@ -170,3 +184,3 @@

* @returns {DataFrame} */
tableByName(tableName) { return new DataFrame(grok_TableByName(tableName)); }
tableByName(tableName) { return toJs(grok_TableByName(tableName)); }

@@ -176,3 +190,3 @@ /** Returns the value of the specified variable. Search is case-insensitive.

* @returns {object} */
getVar(variableName) {return _toJs(grok_GetVar(variableName)); }
getVar(variableName) {return toJs(grok_GetVar(variableName)); }

@@ -191,2 +205,5 @@ /** Sets the value of the specified variable, and returns this value.

}
/** Clears dirty flag in scratchpad and open projects. */
clearDirtyFlag() { grok_ClearDirtyFlag(); }
}

@@ -193,0 +210,0 @@

@@ -0,0 +0,0 @@ export function range(length: number): Generator<number, void>

import {Balloon} from "./widgets";
import * as rxjs from 'rxjs';
import {toJs} from "./wrappers";
export function _toIterable(o) {
let iterable = {};
iterable[Symbol.iterator] = () => _getIterator(o);
return iterable;
}
export function _getIterator(d) {
let iterator = grok_Iterable_Get_Iterator(d);
return {
next: function() {
return grok_Iterator_MoveNext(iterator) ?
{value: toJs(grok_Iterator_Current(iterator)), done: false} :
{done: true};
}
}
}
export function _isDartium() {

@@ -35,8 +53,13 @@ return Array

export function time(s, f) {
/** Times the execution of function f
* @param {string} name
* @param {Function} f - function with no parameters that will get measured
* @returns {number} - milliseconds elapsed
* */
export function time(name, f) {
let start = new Date();
let result = f();
let stop = new Date();
console.log(`${s}: ${stop - start}ms`);
Balloon.info(`${s}: ${stop - start}ms`);
console.log(`${name}: ${stop - start}ms`);
new Balloon().info(`${name}: ${stop - start}ms`);
return result;

@@ -43,0 +66,0 @@ }

@@ -0,0 +0,0 @@ import {Menu, ToolboxPage, Widget} from "./widgets";

@@ -10,2 +10,3 @@ import {VIEW_TYPE, VIEWER} from "./const";

import {toJs} from "./wrappers";
import {_toIterable} from "./utils";

@@ -103,4 +104,4 @@

/** Appends an item to this view. Use {@link appendAll} for appending multiple elements.
* @param {HTMLElement | Widget} item */
append(item) { return this.appendAll([item]); }
* @param {Object} item */
append(item) { return this.appendAll([ui.render(item)]); }

@@ -185,2 +186,7 @@ /** Appends multiple elements this view. Use {@link appendAll} for appending multiple elements.

/** Creates a new table view.
* @params {DataFrame} table
* @returns {TableView} */
static create(table) { return new TableView(grok_TableView(table.d)); }
/** Associated table, if it exists (for TableView), or null.

@@ -202,7 +208,10 @@ * @type {DataFrame} */

/** Adds a viewer of the specified type.
* @param {string} viewerType
* @param {string | Viewer} v
* @param options
* @returns {Viewer} */
addViewer(viewerType, options = null) {
let v = new Viewer(grok_View_AddViewer(this.d, viewerType));
addViewer(v, options = null) {
if (typeof v === 'string' )
v = new Viewer(grok_View_AddViewerByName(this.d, v));
else
grok_View_AddViewer(this.d, v.d);
if (options !== null)

@@ -375,2 +384,8 @@ v.setOptions(options);

detachViewers() { grok_View_DetachViewers(this.d); }
/** Returns all viewers.
* @type {Iterable.<Viewer>} */
get viewers() {
return _toIterable(grok_View_Get_Viewers(this.d));
}
}

@@ -377,0 +392,0 @@

@@ -0,0 +0,0 @@ import {VIEWER} from './const';

@@ -10,3 +10,3 @@ /** A viewer that is typically docked inside a [TableView]. */

import {toJs} from "./wrappers";
import {observeStream, StreamSubscription} from "./events";
import {observeStream, StreamSubscription, __obs} from "./events";
import * as rxjs from "rxjs";

@@ -78,2 +78,6 @@

/** Returns viewer type (see VIEWER constants)
* @returns {string} */
get type() { return JSON.parse(args.args.context.getOptions()).type; }
get table() { return toJs(grok_Viewer_Get_DataFrame(this.d)); }

@@ -83,26 +87,4 @@

get dataFrame() { return toJs(grok_Viewer_Get_DataFrame(this.d)); }
set dataFrame(t) { grok_Viewer_Set_DataFrame(this.d, t.d); }
set dataFrame(t) { grok_Viewer_Set_DataFrame(this.d, t == null ? null : t.d); }
/** @type {Observable} */
get onEvent() {
let dartStream = grok_Viewer_Get_EventBus_Events(this.d);
let observable = rxjs.fromEventPattern(
function(handler) { return grok_Stream_Listen(dartStream, function (x) {
handler(new TypedEventArgs(x));
});
},
function(handler, d) { new StreamSubscription(d).cancel(); }
);
return observable;
// function convert(d) {
// return new TypedEventArgs(d);
// let x = toJs(d);
// console.log(x);
// return x;
// }
// return observeStream(grok_Viewer_Get_EventBus_Events(this.d));
}
static grid (t, options = null) { return new Viewer(grok_Viewer_Grid(t.d, _toJson(options))); }

@@ -114,2 +96,4 @@

static heatMap (t, options = null) { return Viewer.fromType(VIEWER.HEAT_MAP, t, options); }
static boxPlot (t, options = null) { return new Viewer(grok_Viewer_BoxPlot(t.d, _toJson(options))); }

@@ -120,2 +104,20 @@

static scatterPlot (t, options = null) { return new Viewer(grok_Viewer_ScatterPlot(t.d, _toJson(options))); }
static lineChart (t, options = null) { return new Viewer(grok_Viewer_LineChart(t.d, _toJson(options))); }
/** Observes platform events with the specified eventId.
* @returns {Observable} */
onEvent(eventId = null) {
if (eventId !== null)
return __obs(eventId, this.d);
let dartStream = grok_Viewer_Get_EventBus_Events(this.d);
return rxjs.fromEventPattern(
function(handler) { return grok_Stream_Listen(dartStream, function (x) {
handler(new TypedEventArgs(x));
});
},
function(handler, d) { new StreamSubscription(d).cancel(); }
);
}
}

@@ -179,3 +181,3 @@

/** @member {Observable[]} */
this.obs = []
this.obs = [];

@@ -182,0 +184,0 @@ /** @member {JsViewerProps} */

@@ -0,0 +0,0 @@ import {Observable} from "rxjs";

@@ -58,3 +58,3 @@ import {toDart, toJs} from "./wrappers";

get root() { return grok_TabControlBase_Get_Root(this.d); }
get root() { return grok_Widget_Get_Root(this.d); }
}

@@ -108,3 +108,3 @@

get root() { return grok_TabControlBase_Get_Root(this.d); }
get root() { return grok_Widget_Get_Root(this.d); }
get header() { return grok_TabControlBase_Get_Header(this.d); }

@@ -184,2 +184,5 @@ get panes() { return grok_TabControlBase_Get_Panes(this.d).map(toJs); }

add(content) { grok_Dialog_Add(this.d, toDart(ui.extract(content))); return this; }
/** Closes the dialog. */
close() { grok_Dialog_Close(this.d); }
}

@@ -489,1 +492,49 @@

}
export class RangeSlider extends DartWidget {
static create() { return toJs(grok_RangeSlider()); }
/** Gets minimum range value.
* @type {number}
*/
get minRange() { return grok_RangeSlider_Get_MinRange(this.d) };
/** Gets maximum range value.
* @type {number}
*/
get maxRange() { return grok_RangeSlider_Get_MaxRange(this.d); };
/** Gets minimum value.
* @type {number}
*/
get min() { return grok_RangeSlider_Get_Min(this.d); };
/** Gets maximum value.
* @type {number}
*/
get max() { return grok_RangeSlider_Get_Max(this.d); };
/** Sets values to range slider.
* @param {number} minRange
* @param {number} maxRange
* @param {number} min
* @param {number} max */
setValues(minRange, maxRange, min, max) { grok_RangeSlider_SetValues(this.d, minRange, maxRange, min, max); };
/** @returns {Observable} */
get onValuesChanged() { return observeStream(grok_RangeSlider_Get_OnValuesChanged(this.d)); }
}
export class HtmlTable extends DartWidget {
/** @constructs {HtmlTable} */
constructor(d) { super(d); }
/** Creates a visual table based on [items], [renderer], and [columnNames]
* @returns {HtmlTable} */
static create(items, renderer, columnNames = null) { return toJs(grok_HtmlTable(items, renderer !== null ? (object, ind) => renderer(toJs(object), ind) : null, columnNames)); }
/** Removes item */
remove(item) { grok_HtmlTable_Remove(this.d, item); }
}

@@ -25,3 +25,3 @@ import {Property} from "./entities";

* @param d - Dart handle
* @param {boolean} check -
* @param {boolean} check - when true, throws an exception if the object can't be converted to JS.
* @returns JavaScript wrapper for the Dart object

@@ -41,3 +41,3 @@ * */

return wrapper;
} else if (type === TYPE.LIST) {
} else if (type === TYPE.LIST) {
return paramsToJs(d);

@@ -44,0 +44,0 @@ } else if (type === 'DG.TypedEventArgs')

@@ -0,0 +0,0 @@ export function paramsToJs(params: any): any

@@ -0,0 +0,0 @@

@@ -0,0 +0,0 @@ {

@@ -65,4 +65,5 @@ /**

/** @returns {TabControl}
* @param {Object} pages
* @param {boolean} vertical */
export function tabControl(vertical?: boolean): TabControl
export function tabControl(pages?: any, vertical?: boolean): TabControl

@@ -69,0 +70,0 @@ /** Returns DivElement with the specified inner text

@@ -6,6 +6,7 @@ /**

import {Viewer} from "./src/viewer";
import {VirtualView} from "./src/view";
import {Accordion, Dialog, InputBase, Menu, TabControl, TreeViewNode, Widget} from "./src/widgets";
import {toDart} from "./src/wrappers";
import {Accordion, Dialog, InputBase, Menu, TabControl, TreeViewNode, Widget, RangeSlider} from "./src/widgets";
import {toDart, toJs} from "./src/wrappers";
import {Functions} from "./src/functions";

@@ -16,2 +17,9 @@ import $ from "cash-dom";

/**
* @typedef {Object} ElementOptions
* @property {string} id
* @property {string} classes
* @property {Object} style
**/
/**
* Creates an instance of the element for the specified tag, and optionally assigns it a CSS class.

@@ -69,13 +77,23 @@ * @param {string} tagName The name of an element.

/** @returns {TabControl}
* @param {Object} pages - list of page factories
* @param {boolean} vertical */
export function tabControl(vertical = false) { return TabControl.create(vertical); }
export function tabControl(pages = null, vertical = false) {
let tabs = TabControl.create(vertical);
if (pages != null) {
for (let key of Object.keys(pages)) {
let value = pages[key];
tabs.addPane(key, value instanceof Function ? value : () => render(value));
}
}
return tabs;
}
/** Returns DivElement with the specified inner text
* @param {string} text
* @param {string | ElementOptions | null} options
* @returns {HTMLDivElement} */
export function divText(text, className = null) {
export function divText(text, options = null) {
let e = element('div');
e.innerText = text;
if (className != null)
e.classList.add(className);
_options(e, options);

@@ -98,3 +116,3 @@ return e;

if (tooltipMsg !== null)
tooltip(i, tooltipMsg);
tooltip.bind(i, tooltipMsg);
return i;

@@ -153,16 +171,49 @@ }

/** @returns {HTMLDivElement} */
export function div(items = [], className = null) { return grok_UI_Div(items, className); }
/**
* @param {HTMLElement} element
* @param {string | ElementOptions | null} options
* @returns {HTMLElement}
* */
function _options(element, options= null) {
if (options === null)
return element;
if (typeof options === 'string')
element.className += ` ${options}`;
if (options.id != null)
element.id = options.id;
if (options.classes != null)
element.className += ` ${options.classes}`;
if (options.style != null)
Object.assign(element.style, options.style);
return element;
}
/**
* @param {object[]} children
* @param {string | ElementOptions} options
* @returns {HTMLDivElement}
* */
export function div(children = [], options = null) {
return _options(grok_UI_Div(children.map(render), null), options);
}
/** Div flex-box container that positions child elements vertically.
* @param {HTMLElement[]} items
* @param {string} className - comma-separated CSS class names
* @returns {HTMLDivElement} */
export function divV(items, className = null) { return grok_UI_DivV(items, className); }
* @param {object[]} items
* @param {string | ElementOptions} options
* @returns {HTMLDivElement} */
export function divV(items, options = null) { return _options(grok_UI_DivV(items.map(render), null)); }
/** Same as divV, but with margins.
* @param {object[]} items
* @param {string | ElementOptions} options
* @returns {HTMLDivElement} */
export function panel(items, options = null) {
return _options(divV(items, options), 'd4-panel');
}
/** Div flex-box container that positions child elements horizontally.
* @param {HTMLElement[]} items
* @param {string} className - comma-separated CSS class names
* @returns {HTMLDivElement} */
export function divH(items, className = null) { return grok_UI_DivH(items, className); }
* @param {object[]} items
* @param {string | ElementOptions} options
* @returns {HTMLDivElement} */
export function divH(items, options = null) { return _options(grok_UI_DivH(items.map(render), null)); }

@@ -234,2 +285,8 @@ /** Div flex-box container that positions child elements horizontally.

/** Creates a visual table based on [items] and [renderer]. */
export function table(items, renderer, columnNames = null) { return grok_HtmlTable(items, renderer !== null ? (object, ind) => renderer(toJs(object), ind) : null, columnNames).root; }
/** Waits for Future<Element> function to complete and collect its result.*/
export function wait(getElement) { return toJs(grok_UI_Wait(getElement));}
/** Creates a visual element representing list of [items]. */

@@ -244,3 +301,5 @@ export function list(items) { return grok_UI_List(Array.from(items).map(toDart)); }

* tooltip, and popup menu.
* @returns Element. */
* @param item
* @param {Element} element
* @returns {Element}. */
export function bind(item, element) { return grok_UI_Bind(item, element); }

@@ -252,3 +311,3 @@

* @param {boolean} resizable
* @returns Element */
* @returns {HTMLTextAreaElement} */
export function textArea(value, autoSize = false, resizable = true) {

@@ -259,2 +318,17 @@ return grok_UI_TextArea(value, autoSize, resizable);

/**
* @param {string} value
* @returns {HTMLInputElement} */
export function textInput(value) {
var input = element('input');
input.value = value;
return input;
}
export function rangeSlider(minRange, maxRange, min, max) {
let rs = RangeSlider.create();
rs.setValues(minRange, maxRange, min, max);
return rs;
}
/**
* Creates a virtual list widget

@@ -289,3 +363,3 @@ * @param {number} length - number of elements

export function inputs(inputs) { return div(inputs.map((x) => x.root), 'pure-form,pure-form-aligned');}
export function inputs(inputs) { return div(inputs.map((x) => x.root), 'pure-form,pure-form-aligned'); }

@@ -292,0 +366,0 @@ /** Creates new nodes tree

@@ -0,0 +0,0 @@ const path = require('path');

SocketSocket SOC 2 Logo

Product

  • Package Alerts
  • Integrations
  • Docs
  • Pricing
  • FAQ
  • Roadmap
  • Changelog

Packages

npm

Stay in touch

Get open source security insights delivered straight into your inbox.


  • Terms
  • Privacy
  • Security

Made with ⚡️ by Socket Inc