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

@influxdata/giraffe

Package Overview
Dependencies
Maintainers
21
Versions
179
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

@influxdata/giraffe - npm Package Compare versions

Comparing version 0.29.0 to 0.30.0

2

dist/index.d.ts
export { Plot } from './components/Plot';
export { fromFlux, FromFluxResult } from './utils/fromFlux';
export { fromFlux, fromFluxWithSchema, FromFluxResult } from './utils/fromFlux';
export { fromRows } from './utils/fromRows';

@@ -4,0 +4,0 @@ export { newTable } from './utils/newTable';

@@ -446,3 +446,3 @@ /// <reference types="react" />

export interface Tag {
[tagName: string]: string[];
[tagName: string]: Set<string | number>;
}

@@ -449,0 +449,0 @@ export interface SchemaValues {

import { Schema, Table } from '../types';
export interface FromFluxResult {
schema: Schema;
schema?: Schema;
table: Table;

@@ -8,1 +8,2 @@ fluxGroupKeyUnion: string[];

export declare const fromFlux: (fluxCSV: string) => FromFluxResult;
export declare const fromFluxWithSchema: (fluxCSV: string) => FromFluxResult;
{
"name": "@influxdata/giraffe",
"version": "0.29.0",
"version": "0.30.0",
"main": "dist/index.js",

@@ -66,3 +66,3 @@ "license": "MIT",

"node-sass": "^4.14.1",
"papaparse": "^4.6.3",
"papaparse": "^5.3.0",
"prettier": "^1.19.1",

@@ -69,0 +69,0 @@ "react": "^16.8.0",

@@ -5,3 +5,3 @@ // Components

// Utils
export {fromFlux, FromFluxResult} from './utils/fromFlux'
export {fromFlux, fromFluxWithSchema, FromFluxResult} from './utils/fromFlux'
export {fromRows} from './utils/fromRows'

@@ -8,0 +8,0 @@ export {newTable} from './utils/newTable'

@@ -619,3 +619,3 @@ import CSS from 'csstype'

export interface Tag {
[tagName: string]: string[]
[tagName: string]: Set<string | number>
}

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

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

import {fromFlux} from './fromFlux'
import {fromFlux, fromFluxWithSchema} from './fromFlux'

@@ -191,3 +191,3 @@ describe('fromFlux', () => {

it('fromFlux should return an empty object when an empty string is passed in', () => {
const {schema} = fromFlux('')
const {schema} = fromFluxWithSchema('')
expect(schema).toStrictEqual({})

@@ -205,3 +205,3 @@ })

const {schema} = fromFlux(resp)
const {schema} = fromFluxWithSchema(resp)
expect(schema).toStrictEqual({})

@@ -219,3 +219,3 @@ })

const {schema} = fromFlux(resp)
const {schema} = fromFluxWithSchema(resp)
expect(schema).toStrictEqual({

@@ -235,5 +235,9 @@ measurement_name: {type: 'string', fields: [], tags: {}},

const {schema} = fromFlux(resp)
const {schema} = fromFluxWithSchema(resp)
expect(schema).toStrictEqual({
mem: {type: 'string', fields: ['active'], tags: {host: ['oox4k.local']}},
mem: {
type: 'string',
fields: ['active'],
tags: {host: new Set(['oox4k.local'])},
},
})

@@ -259,5 +263,9 @@ })

const {schema} = fromFlux(resp)
const {schema} = fromFluxWithSchema(resp)
expect(schema).toStrictEqual({
mem: {type: 'string', fields: ['active'], tags: {host: ['oox4k.local']}},
mem: {
type: 'string',
fields: ['active'],
tags: {host: new Set(['oox4k.local'])},
},
})

@@ -284,9 +292,13 @@ })

const {schema} = fromFlux(resp)
const {schema} = fromFluxWithSchema(resp)
expect(schema).toStrictEqual({
mem: {type: 'string', fields: ['active'], tags: {host: ['oox4k.local']}},
mem: {
type: 'string',
fields: ['active'],
tags: {host: new Set(['oox4k.local'])},
},
measurement_name: {
type: 'string',
fields: ['field_name'],
tags: {host: ['tag_value']},
tags: {host: new Set(['tag_value'])},
},

@@ -293,0 +305,0 @@ })

@@ -10,3 +10,3 @@ import {csvParse, csvParseRows} from 'd3-dsv'

export interface FromFluxResult {
schema: Schema
schema?: Schema
// The single parsed `Table`

@@ -131,4 +131,68 @@ table: Table

const schema = {}
for (const chunk of chunks) {
const tableText = extractTableText(chunk)
const tableData = csvParse(tableText)
const annotationText = extractAnnotationText(chunk)
const annotationData = parseAnnotations(annotationText, tableData.columns)
for (const columnName of tableData.columns.slice(1)) {
const columnType = toColumnType(
annotationData.datatypeByColumnName[columnName]
)
const columnKey = `${columnName} (${columnType})`
if (!columns[columnKey]) {
columns[columnKey] = {
name: columnName,
type: columnType,
data: [],
} as Column
}
const colData = columns[columnKey].data
const columnDefault = annotationData.defaultByColumnName[columnName]
for (let i = 0; i < tableData.length; i++) {
colData[tableLength + i] = parseValue(
tableData[i][columnName] || columnDefault,
columnType
)
}
if (annotationData.groupKey.includes(columnName)) {
fluxGroupKeyUnion.add(columnKey)
}
}
tableLength += tableData.length
}
resolveNames(columns, fluxGroupKeyUnion)
const table = Object.entries(columns).reduce(
(table, [key, {name, type, data}]) => {
data.length = tableLength
return table.addColumn(key, type, data, name)
},
newTable(tableLength)
)
const result = {
table,
fluxGroupKeyUnion: Array.from(fluxGroupKeyUnion),
}
return result
}
export const fromFluxWithSchema = (fluxCSV: string): FromFluxResult => {
const columns: Columns = {}
const fluxGroupKeyUnion = new Set<string>()
const chunks = splitChunks(fluxCSV)
let tableLength = 0
const schema: Schema = {}
for (const chunk of chunks) {

@@ -255,8 +319,10 @@ formatSchemaByChunk(chunk, schema)

})
.reduce((acc, [k, v]) => {
if (k !== undefined && v !== undefined) {
.reduce((acc, [k, vals]) => {
if (k !== undefined && vals !== undefined) {
const values: Set<string | number> = vals as Set<string | number>
if (acc[k]) {
acc[k] = [...acc[k], v]
const currentValues: Set<string | number> = acc[k]
acc[k] = new Set([...currentValues, ...values])
} else {
acc[k] = [v]
acc[k] = new Set([values])
}

@@ -272,12 +338,6 @@ }

}
const existingTags = schema[measurement].tags || {}
const existingTags = schema[measurement].tags || new Set()
Object.entries(existingTags).forEach(([k, values]) => {
if (tags[k]) {
let tagValues = tags[k]
values.forEach(value => {
if (!tagValues.includes(value)) {
tagValues = tagValues.concat(value)
}
})
tags[k] = tagValues
if (tags[k] && values) {
tags[k] = new Set([...tags[k], ...values])
}

@@ -284,0 +344,0 @@ })

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

Sorry, the diff of this file is not supported yet

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