@diory/client-js 0.1.3 → 0.1.4

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.
@@ -1,23 +1,30 @@
1
1
  "use strict";
2
2
  Object.defineProperty(exports, "__esModule", { value: true });
3
3
  exports.ConnectionClient = void 0;
4
+ const path_browserify_1 = require("path-browserify");
5
+ const DIOSPHERE_JSON = 'diosphere.json';
6
+ const DIOGRAPH_JSON = 'diograph.json';
4
7
  class ConnectionClient {
5
8
  constructor(dataClient, connection) {
6
9
  this.getDiosphere = async () => {
7
- const diosphereString = await this.client.readTextItem(this.connection.address);
10
+ const path = (0, path_browserify_1.join)(this.connection.address, DIOSPHERE_JSON);
11
+ const diosphereString = await this.client.readTextItem(path);
8
12
  return JSON.parse(diosphereString);
9
13
  };
10
14
  this.saveDiosphere = async (diosphereObject) => {
15
+ const path = (0, path_browserify_1.join)(this.connection.address, DIOSPHERE_JSON);
11
16
  const diosphereString = JSON.stringify(diosphereObject, null, 2);
12
- return this.client.writeItem(this.connection.address, diosphereString);
17
+ return this.client.writeItem(path, diosphereString);
13
18
  };
14
19
  this.getDiograph = async () => {
15
- const diographString = await this.client.readTextItem(this.connection.address);
20
+ const path = (0, path_browserify_1.join)(this.connection.address, DIOGRAPH_JSON);
21
+ const diographString = await this.client.readTextItem(path);
16
22
  return JSON.parse(diographString);
17
23
  };
18
24
  this.saveDiograph = async (diographObject) => {
25
+ const path = (0, path_browserify_1.join)(this.connection.address, DIOGRAPH_JSON);
19
26
  const diographString = JSON.stringify(diographObject, null, 2);
20
- return this.client.writeItem(this.connection.address, diographString);
27
+ return this.client.writeItem(path, diographString);
21
28
  };
22
29
  this.type = dataClient.type;
23
30
  this.client = dataClient;
package/package.json CHANGED
@@ -1,16 +1,20 @@
1
1
  {
2
2
  "name": "@diory/client-js",
3
- "version": "0.1.3",
3
+ "version": "0.1.4",
4
4
  "main": "dist/index.js",
5
5
  "types": "dist/index.d.ts",
6
6
  "author": "Olli-Pekka Pohjola <op@diory.me>, Jouni Alanen <jouni@diory.me>",
7
7
  "license": "MIT",
8
8
  "dependencies": {
9
9
  "@diograph/diograph": "0.3.0-rc12",
10
- "@diory/diosphere-js": "0.2.6-rc1"
10
+ "@diory/diosphere-js": "0.2.6-rc1",
11
+ "path-browserify": "^1.0.1",
12
+ "uuid": "8.3.2"
11
13
  },
12
14
  "devDependencies": {
13
15
  "@types/jest": "^27.4.0",
16
+ "@types/path-browserify": "^1.0.2",
17
+ "@types/uuid": "8.3.2",
14
18
  "jest": "^27.5.0",
15
19
  "prettier": "^2.5.1",
16
20
  "ts-jest": "^27.1.3",
@@ -1,7 +1,12 @@
1
+ import { join } from 'path-browserify'
2
+
1
3
  import { IDiographObject } from '@diograph/diograph'
2
4
  import { IConnectionObject, IDiosphereObject } from '@diory/diosphere-js'
3
5
  import { IConnectionClient, IDataClient } from './types'
4
6
 
7
+ const DIOSPHERE_JSON = 'diosphere.json'
8
+ const DIOGRAPH_JSON = 'diograph.json'
9
+
5
10
  class ConnectionClient implements IConnectionClient {
6
11
  type: string
7
12
  client: IDataClient
@@ -14,23 +19,27 @@ class ConnectionClient implements IConnectionClient {
14
19
  }
15
20
 
16
21
  getDiosphere = async () => {
17
- const diosphereString = await this.client.readTextItem(this.connection.address)
22
+ const path = join(this.connection.address, DIOSPHERE_JSON)
23
+ const diosphereString = await this.client.readTextItem(path)
18
24
  return JSON.parse(diosphereString)
19
25
  }
20
26
 
21
27
  saveDiosphere = async (diosphereObject: IDiosphereObject) => {
28
+ const path = join(this.connection.address, DIOSPHERE_JSON)
22
29
  const diosphereString = JSON.stringify(diosphereObject, null, 2)
23
- return this.client.writeItem(this.connection.address, diosphereString)
30
+ return this.client.writeItem(path, diosphereString)
24
31
  }
25
32
 
26
33
  getDiograph = async () => {
27
- const diographString = await this.client.readTextItem(this.connection.address)
34
+ const path = join(this.connection.address, DIOGRAPH_JSON)
35
+ const diographString = await this.client.readTextItem(path)
28
36
  return JSON.parse(diographString)
29
37
  }
30
38
 
31
39
  saveDiograph = async (diographObject: IDiographObject) => {
40
+ const path = join(this.connection.address, DIOGRAPH_JSON)
32
41
  const diographString = JSON.stringify(diographObject, null, 2)
33
- return this.client.writeItem(this.connection.address, diographString)
42
+ return this.client.writeItem(path, diographString)
34
43
  }
35
44
  }
36
45