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

@datagrok/api-samples

Package Overview
Dependencies
Maintainers
6
Versions
9
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

@datagrok/api-samples - npm Package Compare versions

Comparing version 1.0.3 to 1.0.4

dist/package-test.js

42

package.json
{
"name": "@datagrok/api-samples",
"version": "1.0.3",
"version": "1.0.4",
"author": {
"name": "Alexander Paramonov",
"email": "aparamonov@datagrok.ai"
},
"dependencies": {
"@datagrok-libraries/utils": "^1.15.5",
"cash-dom": "^8.1.1",
"datagrok-api": "^1.12.0",
"dayjs": "latest",
"rxjs": "^6.6.7",
"wu": "latest"
},
"devDependencies": {
"@types/wu": "^2.1.42",
"@typescript-eslint/eslint-plugin": "^5.26.0",
"@typescript-eslint/parser": "^5.26.0",
"datagrok-tools": "^4.7.2",
"eslint": "^8.16.0",
"eslint-config-google": "^0.14.0",
"@types/js-yaml": "^4.0.5",
"js-yaml": "^4.1.0",
"puppeteer": "^13.7.0",
"root-require": "latest",
"ts-loader": "^9.2.6",
"typescript": "^4.4.4",
"webpack": "^5.59.1",
"webpack-cli": "^4.9.1",
"@types/node-fetch": "^2.6.2",
"node-fetch": "^2.6.7"
},
"friendlyName": "API Samples",

@@ -13,4 +43,8 @@ "description": "API Samples",

"scripts": {
"samples-upload": "datagrok-upload http://localhost:8082 deploy",
"publish samples local": "grok publish local"
"publish samples local": "grok publish local",
"publish samples localhost": "grok publish localhost",
"build": "webpack",
"test": "grok test",
"test-dev": "grok test --host dev",
"test-local": "grok test --host localhost"
},

@@ -23,3 +57,3 @@ "canEdit": [

],
"category": "Dev"
"category": "Development"
}

4

README.md

@@ -9,3 +9,3 @@ ApiSamples is a [package](https://datagrok.ai/help/develop/develop#packages) for the [Datagrok](https://datagrok.ai) platform.

* [data-frame](https://github.com/datagrok-ai/public/tree/master/packages/ApiSamples/scripts/data-access)
: directory with [table (data frame)](https://datagrok.ai/help/overview/table) manipulations
: directory with [table (data frame)](https://datagrok.ai/help/datagrok/table) manipulations
* [domains](https://github.com/datagrok-ai/public/tree/master/packages/ApiSamples/scripts/domains)

@@ -18,3 +18,3 @@ : directory with domain specific examples: [bioinformatics](https://github.com/datagrok-ai/public/tree/master/packages/ApiSamples/scripts/domains/bio),

* [functions](https://github.com/datagrok-ai/public/tree/master/packages/ApiSamples/scripts/functions)
: directory with examples how to work with [functions](https://datagrok.ai/help/overview/functions/function)
: directory with examples how to work with [functions](https://datagrok.ai/help/datagrok/functions/function)
* [grid](https://github.com/datagrok-ai/public/tree/master/packages/ApiSamples/scripts/grid)

@@ -21,0 +21,0 @@ : directory with examples how to work with [table grid](https://datagrok.ai/help/visualize/viewers/grid)

//tags: Project
//help-url: https://datagrok.ai/help/overview/project
//help-url: https://datagrok.ai/help/datagrok/project
// gets #demo project list and shows them in the view

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

let user = DG.User.create();
user.login = 'newlogin';
user.status = USER_STATUS.STATUS_NEW;
user.firstName = 'new';

@@ -5,0 +4,0 @@ user.lastName = 'user';

@@ -7,3 +7,3 @@ // Different ways for creating and populating columns with qualified numbers.

manual.set(1, DG.Qnum.exact(5));
manual.set(1, DG.Qnum.less(5));
manual.set(2, DG.Qnum.less(5));

@@ -10,0 +10,0 @@ // Method 2: initialize with exact values (last parameter set to true)

@@ -6,2 +6,2 @@ // This virtual column behaves like a normal int column.

table.columns.addNewVirtual('car', (i) => i * 2, DG.TYPE.INT);
grok.shell.add(table);
grok.shell.addTableView(table);

@@ -1,2 +0,2 @@

// Bitwise AND, OR, XOR, and AND_OR opetations
// Bitwise AND, OR, XOR, and AND_NOT operations

@@ -8,3 +8,3 @@ let bs1 = DG.BitSet.fromString('11100');

b1: ${bs1.toBinaryString()}
b2: ${bs1.toBinaryString()}
b2: ${bs2.toBinaryString()}
and: ${bs1.clone().and(bs2).toBinaryString()}

@@ -11,0 +11,0 @@ or: ${bs1.clone().or(bs2).toBinaryString()}

@@ -5,3 +5,3 @@ // Selecting or filtering rows by predicates

let selection = demog.selection;
grok.shell.add(demog);
grok.shell.addTableView(demog);

@@ -8,0 +8,0 @@ // method 1: init(predicate)

@@ -11,4 +11,4 @@ //tags: DataFrame, construction

Tesla, Roadster, , 1.6, 100000
Tesla, Model S, , 1.6, 120000`, {columnImportOptions: [{name: 'model', semType: 'carModel'}]}););
Tesla, Model S, , 1.6, 120000`, {columnImportOptions: [{name: 'model', semType: 'carModel'}]});
grok.shell.addTableView(table);

@@ -6,2 +6,2 @@ // Selecting or filtering rows by predicates

demog.rows.filter((row) => row.age > 42);
grok.shell.add(demog);
grok.shell.addTableView(demog);

@@ -21,4 +21,3 @@ // The following demo shows, how to work with dynamically changing data in Datagrok.

let addMilliseconds = function (time, ms) {
time.setMilliseconds(time.getMilliseconds() + ms);
return time;
return dayjs(time).add(ms, 'millisecond').toDate();
};

@@ -34,3 +33,3 @@

let upDown = () => Math.random() > 0.5 ? '▲' : '▼';
let getValues = (symbol, time) => [symbol, DG.DateTime.fromDate(time).d, next(symbol), Math.round(Math.random() * 10000), upDown()];
let getValues = (symbol, time) => [symbol, dayjs(time).toDate().toLocaleString('en-US'), next(symbol), Math.round(Math.random() * 10000), upDown()];

@@ -37,0 +36,0 @@ let addTick = function (time) {

@@ -1,45 +0,11 @@

//name: testSubstructureSearch
//description: Substructure search via RDKit
//name: testSubstructureSearchLibrary
//language: javascript
async function time(name, n, f) {
let start = new Date();
for (let k = 0; k < n; ++k) {
await f();
}
let stop = new Date();
console.log(`${name}: ${(stop - start) / n} ms`);
}
// An example of using substructure search
(async () => {
const n = 5;
const N = 2000;
let searchFor = ['c1ccccc1', 'C1CCCCC1', 'CC'];
let df = await grok.data.getDemoTable('chem/zbb/99_p3_4.5-6.csv');
if (N < df.rowCount)
df.rows.removeAt(N, df.rowCount - N, false);
let col = df.col('smiles');
console.log('Substructure search microbenchmark');
await time(`Graph-based search on ${df.rowCount} molecules`, n, async () => {
for (let s of searchFor) {
let result = await grok.chem.searchSubstructure(col, s, {substructLibrary: false});
// console.log(s + ": " + result.toString());
}
});
await time(`Building a library for ${df.rowCount} molecules`, 1, async () => {
await grok.chem.searchSubstructure(col);
});
await time(`Searching the library on ${searchFor.length} molecules`, n, async () => {
for (let s of searchFor) {
let result = await grok.chem.searchSubstructure(col, s);
// console.log(s + ": " + result.toString());
}
});
})();
grok.data.loadTable('https://public.datagrok.ai/demo/sar_small.csv')
.then(t => grok.chem.searchSubstructure(t.col('smiles'), 'O=C1CN=C(C2CCCCC2)C2:C:C:C:C:C:2N1')
.then(function (bs) {
t.filter.copyFrom(bs);
grok.shell.addTableView(t);
}));
//tags: Func
//help-url: https://datagrok.ai/help/overview/functions/function
//help-url: https://datagrok.ai/help/datagrok/functions/function
// Executing functions

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

@@ -8,3 +8,5 @@ //tags: Func

p.onLogUpdated.subscribe((line) => console.log(line));
p.update(50, "Loading foo.csv");
grok.functions.call("Discovery:countToTen",

@@ -11,0 +13,0 @@ {s: "a"}, true, p)

@@ -6,6 +6,6 @@ // This examples shows how to register a function that becomes a first-class

// The code below registers two functions, "jsConcat" and "jsWidget". To test
// jsConcat, enter "jsConcat(42, 33)" in the console(https://datagrok.ai/help/overview/navigation#console).
// jsConcat, enter "jsConcat(42, 33)" in the console(https://datagrok.ai/help/datagrok/navigation#console).
// To test jsWidget, create a new Dashboard, and click on "Widget" under "Widgets".
//
// See also https://datagrok.ai/help/overview/functions/function,
// See also https://datagrok.ai/help/datagrok/functions/function,
// https://datagrok.ai/help/develop/js-api#registering-functions

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

@@ -9,2 +9,10 @@ let t = grok.data.demo.demog();

grok.shell.info(`Column 'subj' color coding: ${t.col('subj').meta.colors.getType()}`); // Off
grok.shell.info(`Column 'height' color coding: ${t.col('height').meta.colors.getType()}`); // Conditional
grok.shell.info(`Column 'age' color coding: ${t.col('age').meta.colors.getType()}`); // Linear
t.col('site').meta.colors.setCategorical({'New York': DG.Color.orange});
t.col('started').meta.colors.setLinear([DG.Color.white, DG.Color.red]);
t.col('weight').meta.colors.setConditional({'<100': DG.Color.green, '100-200': '#ff0000'});
grok.shell.addTableView(t);
// HTML-based grid cells with the markup-driven content.
// For code-driven rendering, check out "html-dynamic-cell.js" sample.
// See also: https://datagrok.ai/help/overview/markup
// See also: https://datagrok.ai/help/datagrok/markup

@@ -5,0 +5,0 @@ let view = grok.shell.addTableView(grok.data.demo.demog());

@@ -8,2 +8,3 @@ // controlling the visibility of the UI parts

.add(ui.boolInput('toolbox', windows.showToolbox, (x) => windows.showToolbox = x))
.add(ui.boolInput('status bar', windows.showStatusBar, (x) => windows.showStatusBar = x))
.add(ui.boolInput('console', windows.showConsole, (x) => windows.showConsole = x))

@@ -10,0 +11,0 @@ .add(ui.boolInput('properties', windows.showProperties, (x) => windows.showProperties = x))

// Creating custom dialogs
var dlg = ui.dialog('Windows');
var dlg = ui.dialog({title: 'Boo', helpUrl: 'https://wikipedia.org'});
dlg

@@ -6,0 +6,0 @@ .add(ui.span(['People of Earth, your attention, please… ']))

@@ -1,8 +0,6 @@

// Creating custom dialogs
// Custom dialogs
ui.dialog('Windows')
.add(ui.span(['People of Earth, your attention, please… ']))
.onOK(() => {
grok.shell.info('OK!');
})
.showModal();
ui.dialog({ showHeader: false, showFooter: false })
.add(ui.span(['Full-screen mode with no header or footer; click on the background, or press ESC to close.']))
.onOK(() => grok.shell.info('OK!'))
.showModal(true);

@@ -8,3 +8,3 @@ let v = grok.shell.newView('demo: inputs-events');

let sex = ui.choiceInput('Sex', 'Male', ['Male', 'Female'], v => msg(v));
let date = ui.dateInput('Birthday', DG.DateTime.fromDate(new Date(1970, 5, 10)), v => msg(v));
let date = ui.dateInput('Birthday', dayjs('1970-5-10'), v => msg(v));
let alien = ui.boolInput('Alien', false, v => msg(v));

@@ -11,0 +11,0 @@ let friends = ui.multiChoiceInput('Friends',

@@ -0,7 +1,36 @@

// Different input types
// Adding an icon to each input that lets you inspect the value
// grok.events.onInputCreated.subscribe(
// (i) => i.root.appendChild(ui.iconFA('eye', () => grok.shell.o = i.value)));
// Different input types
// Adding an icon to each input that lets you inspect the value
// grok.events.onInputCreated.subscribe(
// (i) => i.root.appendChild(ui.iconFA('eye', () => grok.shell.o = i.value)));
let v = grok.shell.newView('demo: inputs');
let type = ui.choiceInput('Form type', 'Default', ['Default', 'Left', 'Wide', 'Condensed'], (x)=>{
switch (x){
case 'Default':
form.className = 'ui-form';
break;
case 'Left':
form.className = 'ui-form ui-form-left';
break;
case 'Wide':
form.className = 'ui-form ui-form-wide';
break;
case 'Condensed':
form.className = 'ui-form ui-form-condensed';
break;
default: form.className = '.ui-form';
}
});
let name = ui.stringInput('Name', 'Arthur Dent');
let age = ui.intInput('Age', 30);
let sex = ui.choiceInput('Sex', 'Male', ['Male', 'Female']);
let date = ui.dateInput('Birthday', DG.DateTime.fromDate(new Date(1970, 5, 10)));
let date = ui.dateInput('Birthday', dayjs('1970-5-10'));
let alien = ui.boolInput('Alien', false);

@@ -11,10 +40,8 @@ let friends = ui.multiChoiceInput('Friends', ['Ford', 'Fenchurch'], ['Ford', 'Fenchurch', 'Zaphod', 'Slartibartfast']);

let color = ui.colorInput('Favorite color', '#ff0000');
let data = ui.tableInput('Details', null);
let memo = ui.textInput('Memo', '');
let inputs = [name, age, sex, date, alien, friends, active];
let container = ui.div();
v.append(container);
container.appendChild(ui.inputs(inputs));
let form = ui.form([type, name, age, date, alien, friends, active, color, data, memo]);
container.appendChild(ui.bigButton('POST', () => {
grok.shell.info(inputs.map((i) => `${i.caption}: ${i.stringValue}`).join('<br>'));
}));
form.append(ui.buttonsInput([ui.bigButton('Submit', ()=>{grok.shell.info(form.className)})]));
v.append(form);

@@ -16,3 +16,2 @@ // Demonstrates handling of Grok-originated events

grok.events.onProjectSaved.subscribe(p => info(`${p.name}: saved`));
grok.events.onProjectUploaded.subscribe(p => info(`${p.name}: uploaded`));

@@ -19,0 +18,0 @@ grok.events.onCurrentProjectChanged.subscribe(p => info(`Current project changed: ${grok.shell.project.name}`));

@@ -5,5 +5,5 @@ let view = grok.shell.addTableView(grok.data.demo.geo(10000));

latitudeColumnName: 'lat',
longitudeColumnName: 'lon'
longitudeColumnName: 'lng'
});
grok.shell.info(leaflet.props.getProperties().map((p) => p.name).join(', '));

@@ -18,2 +18,4 @@ //tags: View

v.statusBarPanels = [ui.divText('Mission Accomplished')];
let acc = ui.accordion();

@@ -20,0 +22,0 @@ acc.addPane('header 1', () => ui.divText('Dynamic content'));

Sorry, the diff of this file is not supported yet

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