@digo-org/digo-api 1.0.32 → 1.0.34

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
package/package.json CHANGED
@@ -1,7 +1,7 @@
1
1
  {
2
2
  "name": "@digo-org/digo-api",
3
3
  "private": false,
4
- "version": "1.0.32",
4
+ "version": "1.0.34",
5
5
  "type": "module",
6
6
  "main": "src/index.ts",
7
7
  "types": "src/index.ts",
package/src/constants.ts CHANGED
@@ -3,5 +3,3 @@ export const API_MESSAGES = {
3
3
  updateInstances: 'UPDATE_INSTANCES',
4
4
  updateDefinition: 'UPDATE_DEFINITION',
5
5
  };
6
-
7
- export const KAKA = 'DIGO API';
@@ -0,0 +1,81 @@
1
+ {
2
+ "type": "DATA_ASSET_DEFINITION",
3
+ "value": {
4
+ "timeArray": [],
5
+ "columns": [
6
+ {
7
+ "id": "gdp_2024",
8
+ "name": "GDP 2024 (Trillions USD)",
9
+ "type": "NUMBER",
10
+ "definition": {
11
+ "defaultValue": 0,
12
+ "min": 0,
13
+ "units": "Trillions USD",
14
+ "decimals": 2
15
+ }
16
+ }
17
+ ],
18
+ "rows": [
19
+ {
20
+ "id": "usa",
21
+ "name": "United States",
22
+ "hidden": false,
23
+ "gdp_2024": 30.34
24
+ },
25
+ {
26
+ "id": "china",
27
+ "name": "China",
28
+ "hidden": false,
29
+ "gdp_2024": 19.53
30
+ },
31
+ {
32
+ "id": "germany",
33
+ "name": "Germany",
34
+ "hidden": false,
35
+ "gdp_2024": 4.92
36
+ },
37
+ {
38
+ "id": "japan",
39
+ "name": "Japan",
40
+ "hidden": false,
41
+ "gdp_2024": 4.39
42
+ },
43
+ {
44
+ "id": "india",
45
+ "name": "India",
46
+ "hidden": false,
47
+ "gdp_2024": 4.27
48
+ },
49
+ {
50
+ "id": "united_kingdom",
51
+ "name": "United Kingdom",
52
+ "hidden": false,
53
+ "gdp_2024": 3.73
54
+ },
55
+ {
56
+ "id": "france",
57
+ "name": "France",
58
+ "hidden": false,
59
+ "gdp_2024": 3.28
60
+ },
61
+ {
62
+ "id": "italy",
63
+ "name": "Italy",
64
+ "hidden": false,
65
+ "gdp_2024": 2.46
66
+ },
67
+ {
68
+ "id": "brazil",
69
+ "name": "Brazil",
70
+ "hidden": false,
71
+ "gdp_2024": 2.31
72
+ },
73
+ {
74
+ "id": "canada",
75
+ "name": "Canada",
76
+ "hidden": false,
77
+ "gdp_2024": 2.33
78
+ }
79
+ ]
80
+ }
81
+ }
@@ -0,0 +1,7 @@
1
+ {
2
+ "type": "LINKS",
3
+ "value": {
4
+ "bar-color": "color-1",
5
+ "bar-value": "number-1"
6
+ }
7
+ }
@@ -0,0 +1,93 @@
1
+ {
2
+ "type": "PROJECT",
3
+ "value": {
4
+ "dataAssetDefinition": {
5
+ "timeArray": [],
6
+ "columns": [
7
+ {
8
+ "id": "gdp_2024",
9
+ "name": "GDP 2024 (Trillions USD)",
10
+ "type": "NUMBER",
11
+ "definition": {
12
+ "defaultValue": 0,
13
+ "min": 0,
14
+ "units": "Trillions USD",
15
+ "decimals": 2
16
+ }
17
+ }
18
+ ],
19
+ "rows": [
20
+ {
21
+ "id": "usa",
22
+ "name": "United States",
23
+ "hidden": false,
24
+ "gdp_2024": 30.34
25
+ },
26
+ {
27
+ "id": "china",
28
+ "name": "China",
29
+ "hidden": false,
30
+ "gdp_2024": 19.53
31
+ },
32
+ {
33
+ "id": "germany",
34
+ "name": "Germany",
35
+ "hidden": false,
36
+ "gdp_2024": 4.92
37
+ },
38
+ {
39
+ "id": "japan",
40
+ "name": "Japan",
41
+ "hidden": false,
42
+ "gdp_2024": 4.39
43
+ },
44
+ {
45
+ "id": "india",
46
+ "name": "India",
47
+ "hidden": false,
48
+ "gdp_2024": 4.27
49
+ },
50
+ {
51
+ "id": "united_kingdom",
52
+ "name": "United Kingdom",
53
+ "hidden": false,
54
+ "gdp_2024": 3.73
55
+ },
56
+ {
57
+ "id": "france",
58
+ "name": "France",
59
+ "hidden": false,
60
+ "gdp_2024": 3.28
61
+ },
62
+ {
63
+ "id": "italy",
64
+ "name": "Italy",
65
+ "hidden": false,
66
+ "gdp_2024": 2.46
67
+ },
68
+ {
69
+ "id": "brazil",
70
+ "name": "Brazil",
71
+ "hidden": false,
72
+ "gdp_2024": 2.31
73
+ },
74
+ {
75
+ "id": "canada",
76
+ "name": "Canada",
77
+ "hidden": false,
78
+ "gdp_2024": 2.33
79
+ }
80
+ ]
81
+ },
82
+ "links": {
83
+ "bar-color": "color-1",
84
+ "bar-value": "number-1"
85
+ },
86
+ "vizAssetFiles": {
87
+ "/asset.tsx": "import { DigoAsset } from '@digo-org/digo-api';\n\nimport { ResponsiveContainer, Cell, BarChart, CartesianGrid, XAxis, YAxis, Legend, Bar, Rectangle, Tooltip } from 'recharts';\n\nexport class Asset extends DigoAsset {\n constructor() {\n super();\n }\n\n override render() {\n return (\n <ResponsiveContainer width=\"100%\" height=\"100%\" key=\"responsive-container\">\n <BarChart\n data={this.instances}\n layout=\"horizontal\"\n margin={{\n top: 120,\n right: 60,\n left: 40,\n bottom: 120,\n }}\n style={{ backgroundColor: this.globalParameters['bg-color'] as string }}\n\n >\n <CartesianGrid strokeDasharray=\"3 3\" />\n\n <XAxis dataKey=\"id\" />\n\n <YAxis />\n\n <Legend />\n\n <Tooltip />\n\n <Bar\n dataKey=\"bar-value\"\n fill=\"#ff\"\n animationEasing=\"ease-in-out\"\n animationDuration={200}\n activeBar={<Rectangle fill=\"pink\" stroke=\"blue\" />}\n >\n {this.instances?.map((instance, index) => {\n const color = instance['bar-color'];\n return <Cell key={`cell-${index}`} fill={color as string} />;\n })}\n </Bar>\n\n </BarChart>\n </ResponsiveContainer>\n );\n }\n}\n",
88
+ "/styles.css": "body {\n font-family: sans-serif;\n -webkit-font-smoothing: auto;\n -moz-font-smoothing: auto;\n -moz-osx-font-smoothing: grayscale;\n text-rendering: optimizeLegibility;\n font-smooth: always;\n -webkit-tap-highlight-color: transparent;\n -webkit-touch-callout: none;\n}\n\n.root {\n height: 100vh;\n background-color: 'red';\n display: grid;\n}",
89
+ "/package.json": "{\n \"dependencies\": {\n \"react\": \"^19.0.0\",\n \"react-dom\": \"^19.0.0\",\n \"react-scripts\": \"^5.0.0\",\n \"@digo-org/digo-api\": \"1.0.28\",\n \"@react-three/drei\": \"^10.0.6\",\n \"@react-three/fiber\": \"^9.1.2\",\n \"recharts\": \"^2.15.1\"\n },\n \"main\": \"/index.tsx\",\n \"devDependencies\": {}\n}",
90
+ "/definition.json": "[\n {\n \"id\": \"bg-color\",\n \"group\": \"\",\n \"isGlobal\": true,\n \"properties\": {\n \"name\": \"Background Color\",\n \"type\": 2,\n \"definition\": {\n \"defaultValue\": \"#000\"\n }\n }\n },\n {\n \"id\": \"bar-value\",\n \"group\": \"\",\n \"isGlobal\": false,\n \"properties\": {\n \"name\": \"Value\",\n \"type\": 0,\n \"definition\": {\n \"defaultValue\": 50,\n \"min\": 0,\n \"max\": 100,\n \"icon\": \"icon-[material-symbols--percent-rounded]\",\n \"decimals\": 0,\n \"step\": 1,\n \"units\": \"\"\n }\n }\n },\n {\n \"id\": \"bar-color\",\n \"group\": \"\",\n \"isGlobal\": false,\n \"properties\": {\n \"name\": \"Bar Color\",\n \"type\": 2,\n \"definition\": {\n \"defaultValue\": \"#ffffff\"\n }\n }\n }\n]"
91
+ }
92
+ }
93
+ }
@@ -0,0 +1,9 @@
1
+ {
2
+ "type": "VIZ_FILES",
3
+ "value": {
4
+ "/asset.tsx": "import { DigoAsset } from '@digo-org/digo-api';\n\nimport { ResponsiveContainer, Cell, BarChart, CartesianGrid, XAxis, YAxis, Legend, Bar, Rectangle, Tooltip } from 'recharts';\n\nexport class Asset extends DigoAsset {\n constructor() {\n super();\n }\n\n override render() {\n return (\n <ResponsiveContainer width=\"100%\" height=\"100%\" key=\"responsive-container\">\n <BarChart\n data={this.instances}\n layout=\"horizontal\"\n margin={{\n top: 120,\n right: 60,\n left: 40,\n bottom: 120,\n }}\n style={{ backgroundColor: this.globalParameters['bg-color'] as string }}\n\n >\n <CartesianGrid strokeDasharray=\"3 3\" />\n\n <XAxis dataKey=\"id\" />\n\n <YAxis />\n\n <Legend />\n\n <Tooltip />\n\n <Bar\n dataKey=\"bar-value\"\n fill=\"#ff\"\n animationEasing=\"ease-in-out\"\n animationDuration={200}\n activeBar={<Rectangle fill=\"pink\" stroke=\"blue\" />}\n >\n {this.instances?.map((instance, index) => {\n const color = instance['bar-color'];\n return <Cell key={`cell-${index}`} fill={color as string} />;\n })}\n </Bar>\n\n </BarChart>\n </ResponsiveContainer>\n );\n }\n}\n",
5
+ "/styles.css": "body {\n font-family: sans-serif;\n -webkit-font-smoothing: auto;\n -moz-font-smoothing: auto;\n -moz-osx-font-smoothing: grayscale;\n text-rendering: optimizeLegibility;\n font-smooth: always;\n -webkit-tap-highlight-color: transparent;\n -webkit-touch-callout: none;\n}\n\n.root {\n height: 100vh;\n background-color: 'red';\n display: grid;\n}",
6
+ "/package.json": "{\n \"dependencies\": {\n \"react\": \"^19.0.0\",\n \"react-dom\": \"^19.0.0\",\n \"react-scripts\": \"^5.0.0\",\n \"@digo-org/digo-api\": \"1.0.28\",\n \"@react-three/drei\": \"^10.0.6\",\n \"@react-three/fiber\": \"^9.1.2\",\n \"recharts\": \"^2.15.1\"\n },\n \"main\": \"/index.tsx\",\n \"devDependencies\": {}\n}",
7
+ "/definition.json": "[\n {\n \"id\": \"bg-color\",\n \"group\": \"\",\n \"isGlobal\": true,\n \"properties\": {\n \"name\": \"Background Color\",\n \"type\": 2,\n \"definition\": {\n \"defaultValue\": \"#000\"\n }\n }\n },\n {\n \"id\": \"bar-value\",\n \"group\": \"\",\n \"isGlobal\": false,\n \"properties\": {\n \"name\": \"Value\",\n \"type\": 0,\n \"definition\": {\n \"defaultValue\": 50,\n \"min\": 0,\n \"max\": 100,\n \"icon\": \"icon-[material-symbols--percent-rounded]\",\n \"decimals\": 0,\n \"step\": 1,\n \"units\": \"\"\n }\n }\n },\n {\n \"id\": \"bar-color\",\n \"group\": \"\",\n \"isGlobal\": false,\n \"properties\": {\n \"name\": \"Bar Color\",\n \"type\": 2,\n \"definition\": {\n \"defaultValue\": \"#ffffff\"\n }\n }\n }\n]"
8
+ }
9
+ }
@@ -0,0 +1,74 @@
1
+ import { DataAssetDefinition, ParameterType } from '@digo-org/digo-api';
2
+
3
+ export const DATA_ASSET_DEFINITION_EXAMPLES: DataAssetDefinition[] = [
4
+ {
5
+ rows: [
6
+ {
7
+ 'id': 'row-1',
8
+ 'name': 'Iphone',
9
+ 'hidden': false,
10
+ 'color-1': '#41c968',
11
+ 'number-1': 10,
12
+ 'number-2': 2000,
13
+ },
14
+ {
15
+ 'id': 'row-2',
16
+ 'name': 'Mac',
17
+ 'hidden': false,
18
+ 'color-1': '#536fa6',
19
+ 'number-1': 20,
20
+ 'number-2': 2010,
21
+ },
22
+ {
23
+ 'id': 'row-3',
24
+ 'name': 'Watch',
25
+ 'hidden': false,
26
+ 'color-1': '#a6ba62',
27
+ 'number-1': 40,
28
+ 'number-2': 2020,
29
+ },
30
+ {
31
+ 'id': 'row-4',
32
+ 'name': 'Vision Pro',
33
+ 'hidden': false,
34
+ 'color-1': '#e75a5a',
35
+ 'number-1': 30,
36
+ 'number-2': 2025,
37
+ },
38
+ ],
39
+ columns: [
40
+ {
41
+ id: 'number-1',
42
+ name: 'Market Share (%)',
43
+ type: ParameterType.NUMBER,
44
+ isArray: false,
45
+ definition: {
46
+ max: 100,
47
+ min: 0,
48
+ defaultValue: 0,
49
+ },
50
+ },
51
+ {
52
+ id: 'color-1',
53
+ name: 'Color',
54
+ type: ParameterType.COLOR,
55
+ isArray: false,
56
+ definition: {
57
+ defaultValue: '#FFFFFF',
58
+ },
59
+ },
60
+ {
61
+ id: 'number-2',
62
+ name: 'Year',
63
+ type: ParameterType.NUMBER,
64
+ isArray: false,
65
+ definition: {
66
+ max: 2025,
67
+ min: 2000,
68
+ defaultValue: 0,
69
+ },
70
+ },
71
+ ],
72
+ timeArray: [],
73
+ },
74
+ ];
package/src/index.ts CHANGED
@@ -1,13 +1,17 @@
1
1
  export * from '@digo-org/digo-api/src/constants';
2
2
 
3
+ export * from '@digo-org/digo-api/src/digo-asset';
4
+
3
5
  export * from '@digo-org/digo-api/src/types-common';
4
6
 
7
+ export * from '@digo-org/digo-api/src/types-data';
8
+
5
9
  export * from '@digo-org/digo-api/src/types-misc';
6
10
 
7
- export * from '@digo-org/digo-api/src/types-viz';
11
+ export * from '@digo-org/digo-api/src/types-llm';
8
12
 
9
13
  export * from '@digo-org/digo-api/src/types-viz-files';
10
14
 
11
- export * from '@digo-org/digo-api/src/types-data';
15
+ export * from '@digo-org/digo-api/src/types-viz';
12
16
 
13
- export * from '@digo-org/digo-api/src/digo-asset';
17
+ export * from '@digo-org/digo-api/src/examples/data-examples';
@@ -34,6 +34,7 @@ export interface ParameterGradient {
34
34
  export interface ParameterText {
35
35
  defaultValue: string;
36
36
  placeholder?: string;
37
+ autofocus?: boolean;
37
38
  };
38
39
 
39
40
  export interface ParameterColor {
@@ -44,14 +45,6 @@ export interface ParameterBoolean {
44
45
  defaultValue: boolean;
45
46
  };
46
47
 
47
- export interface ParameterArray {
48
- defaultValue: ParameterValueArray;
49
- definition: ParameterDefinition;
50
- labels: string[];
51
- };
52
-
53
- // VALUE
54
-
55
48
  export type ParameterValue = ParameterValueSingle | ParameterValueArray;
56
49
 
57
50
  export type ParameterValueSingle = number | boolean | string | GradientStop[];
@@ -62,3 +55,9 @@ export interface GradientStop {
62
55
  color: string; // hex
63
56
  percent: number;
64
57
  }
58
+
59
+ export interface Option {
60
+ id: string;
61
+ value: string;
62
+ icon?: string;
63
+ }
package/src/types-data.ts CHANGED
@@ -2,18 +2,18 @@ import { Parameter, ParameterValue } from '@digo-org/digo-api';
2
2
 
3
3
  export interface DataAssetDefinition {
4
4
  timeArray: string[];
5
- variables: Variable[];
6
- entities: Entity[];
5
+ columns: Column[];
6
+ rows: Row[];
7
7
  }
8
8
 
9
- export interface Entity {
10
- id: string;
11
- name: string;
12
- hidden: boolean;
13
- [variableId: string]: ParameterValue;
9
+ export interface Row {
10
+ id: string;
11
+ name: string;
12
+ hidden: boolean;
13
+ [columnId: string]: ParameterValue;
14
14
  }
15
15
 
16
- export interface Variable extends Parameter {
16
+ export interface Column extends Parameter {
17
17
  id: string;
18
18
  name: string;
19
19
  }
@@ -0,0 +1,24 @@
1
+ import { CommonMetadata, DataAssetDefinition, Links, ProjectDefinition, VizAssetDefinition, VizAssetFiles } from '@digo-org/digo-api';
2
+
3
+ export interface Artifact extends CommonMetadata {
4
+ type: ArtifactType;
5
+ value: ProjectDefinition | DataAssetDefinition | VizAssetFiles | VizAssetDefinition | Links;
6
+ }
7
+
8
+ export enum ArtifactType {
9
+ PROJECT_DEFINITION = 'PROJECT_DEFINITION',
10
+ DATA_ASSET_DEFINITION = 'DATA_ASSET_DEFINITION',
11
+ VIZ_ASSET_FILES = 'VIZ_ASSET_FILES',
12
+ VIZ_ASSET_DEFINITION = 'VIZ_ASSET_DEFINITION',
13
+ LINKS = 'LINKS',
14
+ }
15
+
16
+ export interface MessagePart {
17
+ type: MessageType;
18
+ value: string | Artifact;
19
+ }
20
+
21
+ export enum MessageType {
22
+ TEXT = 'TEXT',
23
+ ARCTIFACT = 'ARCTIFACT',
24
+ }
package/src/types-misc.ts CHANGED
@@ -1,9 +1,19 @@
1
- import { ParameterDefinition } from '@digo-org/digo-api';
1
+ import { ArtifactType, DataAssetDefinition, MessagePart, ParameterDefinition, ParameterValueArray, VizAssetDefinition, VizAssetFiles } from '@digo-org/digo-api';
2
+
3
+ export type Links = Record<string, string>; /* parameter-id -> column-id */
2
4
 
3
5
  export interface CommonMetadata {
4
6
  name: string;
5
7
  description?: string;
6
8
  tags?: string[];
9
+ icon?: string;
10
+ }
11
+
12
+ export interface ProjectDefinition {
13
+ dataAssetDefinition: DataAssetDefinition;
14
+ vizAssetDefinition: VizAssetDefinition;
15
+ vizAssetFiles: VizAssetFiles;
16
+ links: Links;
7
17
  }
8
18
 
9
19
  export interface ParameterTypeDefinition {
@@ -12,3 +22,33 @@ export interface ParameterTypeDefinition {
12
22
  icon: string;
13
23
  defaultValue: ParameterDefinition;
14
24
  }
25
+
26
+ export interface ParameterArray {
27
+ defaultValue: ParameterValueArray;
28
+ definition: ParameterDefinition;
29
+ labels: string[];
30
+ };
31
+
32
+ export enum MessageRole {
33
+ USER = 'USER',
34
+ ASSISTANT = 'ASSISTANT',
35
+ }
36
+
37
+ export interface Message {
38
+ id: string;
39
+ role: MessageRole;
40
+ content: MessagePart[];
41
+ createdAt: number;
42
+ }
43
+
44
+ export interface ArtifactStep {
45
+ type: ArtifactType;
46
+ name: string;
47
+ code?: string;
48
+ action: ArctifactStepAction;
49
+ }
50
+
51
+ export enum ArctifactStepAction {
52
+ GENERATED = 'GENERATED',
53
+ EDITED = 'EDITED',
54
+ }