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

@vizabi/core

Package Overview
Dependencies
Maintainers
4
Versions
43
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

@vizabi/core - npm Package Compare versions

Comparing version 1.19.0 to 1.20.0

2

dist/Dataframe.js

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

// http://vizabi.org v1.19.0 Copyright 2021 Jasper Heeffer and others at Gapminder Foundation
// http://vizabi.org v1.20.0 Copyright 2021 Jasper Heeffer and others at Gapminder Foundation
(function (global, factory) {

@@ -3,0 +3,0 @@ typeof exports === 'object' && typeof module !== 'undefined' ? factory(exports, require('mobx')) :

{
"name": "@vizabi/core",
"version": "1.19.0",
"version": "1.20.0",
"description": "Vizabi core (data layer)",

@@ -5,0 +5,0 @@ "main": "dist/Vizabi.js",

@@ -115,3 +115,3 @@ # VIZABI DATA CORE

debug a single test with breakpoints in VS Code
debug a single test with breakpoints: in VS Code open JS Debug terminal (not the regular console) and run
`npm run debug -- /config.test.js`

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

@@ -276,7 +276,10 @@ import { createKeyStr } from "../../dataframe/dfutils";

let concepts;
let allProperties = kvLookup.get(createKeyStr([dim]));
if (allowedProperties) {
const allProperties = kvLookup.get(createKeyStr([dim]));
if (allProperties && allowedProperties) {
concepts = allowedProperties.filter(c => allProperties.has(c));
} else if (allProperties) {
concepts = allProperties.keys();
} else {
concepts = allProperties.keys();
//dimension has no entity properties --> return dimension name itself
concepts = [dim];
}

@@ -283,0 +286,0 @@ occurences.push(...concepts);

@@ -23,3 +23,3 @@ import { dataConfig } from './dataConfig';

get space() {
return base.space?.filter(dim => this.source.isEntityConcept(dim));
return base.space?.filter(dim => !this.source.isTimeConcept(dim));
},

@@ -29,3 +29,3 @@ get queries() {

return this.space
.filter(dim => kvLookup.get(dim).has(this.concept))
.filter(dim => kvLookup.get(dim)?.has(this.concept))
.map(dim => {

@@ -32,0 +32,0 @@ return this.createQuery({ space: [dim] });

@@ -189,2 +189,5 @@ import { fromPromise } from 'mobx-utils'

},
isTimeConcept(conceptId) {
return this.getConcept(conceptId).concept_type === "time";
},
normalizeResponse(response, query) {

@@ -191,0 +194,0 @@ const cache = {}

@@ -6,2 +6,3 @@ import { inlineReader } from "./../inline/inline";

const TIME_LIKE_CONCEPTS = ["time", "year", "month", "day", "week", "quarter"];
const NAME_LIKE_CONCEPTS = ["name", "title"];
const GOOGLE_DOC_PREFIX = 'https://docs.google.com/spreadsheets/';

@@ -29,2 +30,3 @@ const MISSED_INDICATOR_NAME = 'indicator';

keyConcepts,
nameColumnIndex,
dtypes

@@ -38,3 +40,3 @@ }) {

return Object.assign(inlineReader(getValues().then(({values, keyConcepts}) => ({
return Object.assign(inlineReader(getValues().then(({values, dtypes, keyConcepts}) => ({
values,

@@ -56,3 +58,3 @@ keyConcepts,

.then(transformTimeInColumns)
.then(returnValuesAndKeyConcepts);
.then(returnValuesDtypesAndKeyConcepts);
}

@@ -92,5 +94,8 @@

// turns [name, geo, gender, time, lex] into [geo, gender, time, name, lex]
if (hasNameColumn)
columns.splice(this.keySize + 1, 0, columns.splice(this.nameColumnIndex, 1)[0]);
nameColumnIndex = nameColumnIndex ?? NAME_LIKE_CONCEPTS.map(n => columns.indexOf(n)).find(f => f > -1);
if (hasNameColumn && nameColumnIndex != undefined){
const nameColumn = columns.splice(nameColumnIndex, 1); //mutates columns array
const keySize = guessKeyConcepts(columns, keyConcepts).length;
columns = columns.slice(0, keySize).concat(nameColumn).concat(columns.slice(keySize))
}
return {rows, columns};

@@ -107,7 +112,8 @@ }

function returnValuesAndKeyConcepts({rows, columns}){
function returnValuesDtypesAndKeyConcepts({rows, columns}){
return {
values: autotype(rows),
keyConcepts: guessKeyConcepts(columns, keyConcepts),
columns
columns,
dtypes: TIME_LIKE_CONCEPTS.reduce((dtypes, t) => (dtypes[t] = t, dtypes), {})
}

@@ -114,0 +120,0 @@ }

@@ -69,3 +69,3 @@ import { DataFrame } from "../../dataframe/dataFrame";

function getConcepts(data) {
const types = getTypes(data);
const types = getConceptTypes(data);
return [...data.fields].map(concept => ({

@@ -99,4 +99,9 @@ concept,

if ("join" in query)
console.warn('Inline reader does not handle joins as it handles only one table.', { query })
if ("join" in query){
console.warn('Inline reader does not handle joins as it has only one table. Sections of "where" statement that refer to joins will be ignored.', { query })
//delete where statements that refer to joins
for (let w in where) {
if(Object.keys(join).includes(where[w])) delete where[w];
}
}

@@ -139,2 +144,9 @@ if (relativeComplement([...data.fields], projection).length > 0)

auto: autoParse,
time: (d) => {
if ((""+d).length == 4) return dtypeParsers.year(d);
if (d.length == 7 && d[4] == "-") return dtypeParsers.month(d);
if (d.length == 10) return dtypeParsers.day(d);
if (d[4].toLowerCase() == "w") return dtypeParsers.week(d);
if (d[4].toLowerCase() == "q") return dtypeParsers.quarter(d);
},
year: d3.utcParse("%Y"),

@@ -196,3 +208,3 @@ month: d3.utcParse("%Y-%m"),

function getTypes(data) {
function getConceptTypes(data) {
const types = new Map();

@@ -203,7 +215,7 @@

for (let field in firstRow) {
types.set(field, getType(firstRow[field]));
types.set(field, getConceptType(firstRow[field], field, data.key));
}
// check if those types are consistent
for (let [field, type] in types) {
if (!validateType(data, field, type)) {
if (!validateConceptType(data, field, type)) {
console.warn("Field " + field + " is not consistently typed " + type);

@@ -216,5 +228,5 @@ types.set(field, "mixed");

function validateType(data, field, type) {
function validateConceptType(data, field, type) {
for (row of data.values()) {
if (getType(row[field]) !== type)
if (getConceptType(row[field], field, data.key) !== type)
return false;

@@ -224,4 +236,5 @@ }

function getType(value) {
if (isDate(value)) return 'time';
function getConceptType(value, field, datakey) {
if (isDate(value)) return 'time';
if(datakey.includes(field)) return 'entity_domain';
const type = typeof value;

@@ -231,3 +244,3 @@ if (type == "string") return 'string';

if (type == "number" || isNumber(value)) return 'measure';
console.warn("Couldn't decide type of value.", { value });
console.warn("Couldn't decide type of value", { value, field, datakey });
}

@@ -234,0 +247,0 @@

Sorry, the diff of this file is too big to display

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