1.0.3 • Published 9 months ago

@luzmo/dashboard-contents-types v1.0.3

Weekly downloads
-
License
-
Repository
-
Last release
9 months ago

Types and JSON schemas for Luzmo dashboard contents

This packages contains different dashboard contents' types and JSON schemas for Luzmo dashboard contents.

Content Item Types

Here is the list of some types for content items. There are more types available in the package.

TypeDescription
AreaChartAn Area Chart type.
AreaChartViewOptionsAn Area Chart options type.
AreaChartSlotsAn Area Chart slots type.
BarChartA Bar Chart type.
BarChartViewOptionsA Bar Chart options type.
BarChartSlotsA Bar Chart slots type.
BoxPlotA Box Plot type.
BoxPlotViewOptionsA Box Plot options type.
BoxPlotSlotsA Box Plot slots type.
BubbleChartA Bubble Chart type.
BubbleChartViewOptionsA Bubble Chart options type.
BubbleChartSlotsA Bubble Chart slots type.
BulletChartA Bullet Chart type.
BulletChartViewOptionsA Bullet Chart options type.
BulletChartSlotsA Bullet Chart slots type.
ChoroplethMapA Choropleth Map type.
ChoroplethMapViewOptionsA Choropleth Map options type.
ChoroplethMapSlotsA Choropleth Map slots type.
CircularGaugeA Circular Gauge type.
CircularGaugeViewOptionsA Circular Gauge options type.
CircularGaugeSlotsA Circular Gauge slots type.
ColumnChartA Column Chart type.
ColumnChartViewOptionsA Column Chart options type.
ColumnChartSlotsA Column Chart slots type.
CombinationChartA Combination Chart type.
CombinationChartViewOptionsA Combination Chart options type.
CombinationChartSlotsA Combination Chart slots type.
ConditionalNumberA Conditional Number type.
ConditionalNumberViewOptionsA Conditional Number options type.
ConditionalNumberSlotsA Conditional Number slots type.
DateFilterA Date Filter type.
DateFilterViewOptionsA Date Filter options type.
DateFilterSlotsA Date Filter slots type.
DonutChartA Donut Chart type.
DonutChartViewOptionsA Donut Chart options type.
DonutChartSlotsA Donut Chart slots type.
DropdownFilterA Dropdown Filter type.
DropdownFilterViewOptionsA Dropdown Filter options type.
DropdownFilterSlotsA Dropdown Filter slots type.
EvolutionNumberAn Evolution Number type.
EvolutionNumberViewOptionsAn Evolution Number options type.
EvolutionNumberSlotsAn Evolution Number slots type.
FunnelChartA Funnel Chart type.
FunnelChartViewOptionsA Funnel Chart options type.
FunnelChartSlotsA Funnel Chart slots type.
ImageAn Image type.
ImageViewOptionsAn Image options type.
LineChartA Line Chart type.
LineChartViewOptionsA Line Chart options type.
LineChartSlotsA Line Chart slots type.
PivotTableA Pivot Table type.
PivotTableViewOptionsA Pivot Table options type.
PivotTableSlotsA Pivot Table slots type.
RegularTableA Regular Table type.
RegularTableViewOptionsA Regular Table options type.
RegularTableSlotsA Regular Table slots type.
SankeyDiagramA ScatterPlot type.
SankeyDiagramViewOptionsA Sankey Diagram options type.
SankeyDiagramSlotsA Sankey Diagram slots type.
ScatterPlotA Scatter Plot type.
ScatterPlotViewOptionsA Scatter Plot options type.
ScatterPlotSlotsA Scatter Plot slots type.
SlicerFilterA Slicer Filter type.
SlicerFilterViewOptionsA Slicer Filter options type.
SlicerFilterSlotsA Slicer Filter slots type.
SliderFilterA Slider Filter type.
SliderFilterViewOptionsA Slider Filter options type.
SliderFilterSlotsA Slider Filter slots type.
TextA Text type.
TextViewOptionsA Text options type.
VizItemTypeA union type for content item types.
OptionsA union type for all the options from all the charts.
SlotsA union type for all the slots from all the charts.

JSON Schemas

The library also provides JSON schemas for the content items. The schemas are provided as an object with the schema name as the key and the schema as the value.

import { JSON_SCHEMAS } from '@luzmo/dashboard-contents-types';

console.log(JSON_SCHEMAS);
console.log(JSON_SCHEMAS['text-options.schema.json']);

The JSON schemas are not dereferenced. You can use a library like json-schema-ref-parser to dereference the schemas. json-schema-ref-parser is a Node library so to use it in a browser environment you should add a configuration for that.

import * as refParser from '@apidevtools/json-schema-ref-parser';
import { JSON_SCHEMAS } from '@luzmo/dashboard-contents-types';

const refParserResolver = {
  order: 101,
  canRead: /^https:\/\/developer\.luzmo\.com/,
  read: (file, callback) => {
    const name = file.url.split('/').pop();
    const schema = JSON_SCHEMAS[name];

    if (schema) {
      callback(null, JSON.stringify(schema));
    } else {
      callback(new Error('Schema not found'));
    }
  }
};

const refParserOptions = {
  mutateInputSchema: false,
  resolve: {
    http: refParserResolver,
    external: true
  }
};

refParser.dereference(JSON_SCHEMAS['area-chart-slots.schema.json'], refParserOptions)
  .then((dereferencedSchema) => {
    console.log(dereferencedSchema);
  })
  .catch((err) => {
    console.error(err);
  });

To validate a content item against a schema, you can use a library like ajv.

import Ajv from "ajv";
import ajvAddFormats from 'ajv-formats';
import { JSON_SCHEMAS } from '@luzmo/dashboard-contents-types';

const ajv = new Ajv({
  schemas: Object.keys(JSON_SCHEMAS).map(key => JSON_SCHEMAS[key]),
  allowUnionTypes: true,
  strictTuples: false
});

ajvAddFormats(ajv);

const schemaId = 'https://developer.luzmo.com/assets/json-schemas/0.1.89/text-options.schema.json';
const validate = ajv.getSchema(schemaId);
const isValid = validate('VALUE TO VALIDATE');

console.log(isValid);
1.0.3

9 months ago

1.0.2

9 months ago

1.0.1

9 months ago

1.0.0

9 months ago

0.1.88

10 months ago

0.1.89

10 months ago

0.1.88-beta.7

10 months ago

0.1.88-beta.6

10 months ago

0.1.88-beta.5

10 months ago

0.1.88-beta.4

10 months ago

0.1.88-beta.3

10 months ago

0.1.88-beta.2

10 months ago

0.1.88-beta.1

10 months ago

0.1.87-beta.1

11 months ago