@linkurious/ogma-linkurious-parser 4.0.4 → 4.0.6

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.
Files changed (2) hide show
  1. package/README.md +25 -19
  2. package/package.json +2 -2
package/README.md CHANGED
@@ -1,7 +1,7 @@
1
- # Ogma-Linkurious Parser
1
+ # Ogma-Linkurious-Parser
2
2
 
3
3
  ## Description
4
- Ogma-Linkurious Parser is an official library maintained by the Linkurious team that allows you to quickly parse and load a Linkurious visualization in Ogma with one line of code and apply different Linkurious Enterprise styles, filters, captions and more.
4
+ Ogma-Linkurious-Parser is an official library maintained by the Linkurious team that allows you to quickly parse and load a Linkurious Enterprise visualization in Ogma with one line of code and apply different Linkurious Enterprise styles, filters, captions and more.
5
5
 
6
6
  ### Prerequisites
7
7
  - Linkurious Enterprise 2.10.x or above
@@ -16,46 +16,52 @@ Ogma-Linkurious Parser is an official library maintained by the Linkurious team
16
16
 
17
17
  In order to create an Ogma visualization with your Linkurious styles:
18
18
 
19
- 1. Get your visualization using [Linkurios REST API](https://doc.linkurio.us/server-sdk/latest/apidoc/#api-Visualization-getVisualization).
19
+ 1. Get your visualization using [Linkurious Enterprise REST API](https://doc.linkurious.com/server-sdk/latest/apidoc/#api-Visualization-getVisualization).
20
20
 
21
+ 2. Get Linkurious Enterprise configuration using [Linkurious Enterprise REST API](https://doc.linkurious.com/server-sdk/latest/apidoc/#api-Config-getConfiguration).
21
22
 
22
- 2. Get the Linkurious configuration using [Linkurios REST API](https://doc.linkurio.us/server-sdk/latest/apidoc/#api-Config-getConfiguration).
23
+ 3. If you need to reproduce the same caption styles, get graph schema using [Linkurious Enterprise REST API](https://doc.linkurious.com/server-sdk/latest/apidoc/#api-Schema-getTypes).
23
24
 
25
+ 4. Initialize `LKOgma` and call `initVisualization` with the configuration and the visualization data from the previous steps.
24
26
 
25
- 3. Initialize `LKOgma` and call `initVisualization` with the configuration and the visualization data from the previous steps.
26
27
 
27
-
28
- A full working example using the [Linkurious REST Client](https://github.com/Linkurious/linkurious-rest-client/) library:
28
+ A full working example using the [Linkurious Enterprise REST API](https://github.com/Linkurious/linkurious-rest-client/) library:
29
29
 
30
30
  ```js
31
31
  const {RestClient} = require('@linkurious/rest-client');
32
32
  const {LKOgma} = require('@linkurious/ogma-linkurious-parser');
33
33
 
34
34
  async function main() {
35
+
35
36
  // Initialize the rest client
36
37
  const rc = new RestClient({baseUrl: 'http://localhost:3000'});
37
-
38
38
  // Log in
39
39
  await rc.auth.login({
40
40
  usernameOrEmail: 'your-username',
41
41
  password: 'your-password'
42
42
  });
43
-
44
43
  // Get linkurious configuration response
45
44
  const linkuriousConfigurationResponse = await rc.config.getConfiguration();
46
-
47
45
  // Get the visualisation configuration response
48
46
  const visualizationResponse = await rc
49
47
  .visualization.getVisualization({
50
48
  sourceKey: 'e7900d9b',
51
49
  id: 3
52
50
  });
53
-
54
- if (linkuriousConfigurationResponse.isSuccess() && visualizationResponse.isSuccess()) {
51
+ const nodeTypesResponse = await this.rc.graphSchema.getTypesWithAccess({
52
+ entityType: 'node'
53
+ });
54
+ const edgeTypesResponse = await this.rc.graphSchema.getTypesWithAccess({
55
+ entityType: 'edge'
56
+ });
57
+
58
+ if (linkuriousConfigurationResponse.isSuccess() && visualizationResponse.isSuccess() && nodeTypesResponse.isSuccess() && edgeTypesResponse.isSuccess) {
55
59
  const ogmaConfiguration = linkuriousConfigurationResponse.body.ogma;
56
-
60
+ const graphSchema = {
61
+ node: nodeTypesResponse.body.node.results,
62
+ edge: edgeTypesResponse.body.edge.results
63
+ }
57
64
  const visualizationConfiguration = visualizationResponse.body;
58
-
59
65
  // Initialize ogma object
60
66
  const ogma = new LKOgma({
61
67
  ...ogmaConfiguration,
@@ -64,10 +70,10 @@ async function main() {
64
70
  backgroundColor: 'rgba(240, 240, 240)'
65
71
  }
66
72
  });
67
-
68
73
  // Set HTML container where Ogma will be rendered
69
74
  ogma.setContainer('graph-container');
70
-
75
+ // Set graphSchema that will be used in defining caption styles
76
+ ogma.LKCaptions.graphSchema = graphSchema;
71
77
  // Initialize the visualization content & styles
72
78
  await ogma.initVisualization(visualizationConfiguration);
73
79
  }
@@ -77,12 +83,12 @@ main();
77
83
  ```
78
84
  <!--
79
85
  # TODO uncomment when plugins are officially documented
80
- > If you are writing a Linkurious plugin, the Linkurious Rest-Client library will be already initialized.
86
+ > If you are writing a Linkurious Enterprise plugin, the Linkurious Enterprise Rest-Client library will be already initialized.
81
87
  -->
82
88
 
83
89
  You can use any other Ogma feature you would like to apply to the visualization.
84
90
 
85
- > To learn more about Ogma check our [official documentation](https://doc.linkurio.us/ogma/latest/).
91
+ > To learn more about Ogma check our [official documentation](https://doc.linkurious.com/ogma/latest/).
86
92
 
87
93
  ## Licensing
88
- The Ogma-Linkurious parser is licensed under the Apache License, Version 2.0. See [LICENSE](/LICENSE) for the full license text.
94
+ The Ogma-Linkurious-parser is licensed under the Apache License, Version 2.0. See [LICENSE](/LICENSE) for the full license text.
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@linkurious/ogma-linkurious-parser",
3
- "version": "4.0.4",
3
+ "version": "4.0.6",
4
4
  "author": "Linkurious SAS",
5
5
  "description": "Parse and load a Linkurious visualization in Ogma with one line of code ",
6
6
  "files": [
@@ -53,7 +53,7 @@
53
53
  },
54
54
  "devDependencies": {
55
55
  "@linkurious/ogma": "4.4.4",
56
- "@linkurious/rest-client": "4.0.4",
56
+ "@linkurious/rest-client": "4.0.6",
57
57
  "@rollup/plugin-buble": "0.21.3",
58
58
  "@rollup/plugin-commonjs": "17.0.0",
59
59
  "@rollup/plugin-json": "4.1.0",