@diory/client-js 0.4.0-rc1 → 0.4.0-rc2

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 (33) hide show
  1. package/README.md +2 -1
  2. package/dist/connectionClient/connectionClient.d.ts +15 -14
  3. package/dist/connectionClient/connectionClient.js +92 -36
  4. package/dist/connectionClient/connectionClient.spec.js +17 -17
  5. package/dist/dioryClient/addDefaultDiograph.d.ts +2 -0
  6. package/dist/dioryClient/addDefaultDiograph.js +17 -0
  7. package/dist/dioryClient/addDefaultRoom.d.ts +5 -0
  8. package/dist/dioryClient/addDefaultRoom.js +13 -0
  9. package/dist/dioryClient/dioryClient.d.ts +6 -16
  10. package/dist/dioryClient/dioryClient.js +25 -114
  11. package/dist/dioryClient/getDefaultDiograph.d.ts +2 -2
  12. package/dist/dioryClient/getDefaultDiograph.js +19 -16
  13. package/dist/dioryClient/getDefaultDiosphere.d.ts +2 -2
  14. package/dist/dioryClient/getDefaultDiosphere.js +15 -12
  15. package/dist/index.d.ts +1 -2
  16. package/dist/index.js +1 -3
  17. package/dist/types.d.ts +8 -27
  18. package/dist/utils/addDefaultDiograph.d.ts +2 -0
  19. package/dist/utils/addDefaultDiograph.js +14 -0
  20. package/dist/utils/addDefaultRoom.d.ts +2 -0
  21. package/dist/utils/addDefaultRoom.js +10 -0
  22. package/dist/utils/getConnectionClients.d.ts +7 -4
  23. package/dist/utils/getConnectionClients.js +12 -12
  24. package/package.json +4 -4
  25. package/src/dioryClient/dioryClient.ts +29 -153
  26. package/src/index.ts +1 -2
  27. package/src/types.ts +8 -34
  28. package/src/{dioryClient/getDefaultDiograph.ts → utils/addDefaultDiograph.ts} +3 -6
  29. package/src/utils/addDefaultRoom.ts +11 -0
  30. package/src/connectionClient/connectionClient.spec.ts +0 -19
  31. package/src/connectionClient/connectionClient.ts +0 -54
  32. package/src/dioryClient/getDefaultDiosphere.ts +0 -14
  33. package/src/utils/getConnectionClients.ts +0 -24
package/README.md CHANGED
@@ -12,7 +12,8 @@ yarn add @diory/client-js
12
12
 
13
13
  ```
14
14
  const clients = [localClient, S3Client, ...]
15
- const { diosphere, room, diograph, diory } = DioryClient(clients)
15
+ const dioryClient = DioryClient(clients)
16
+ dioryClient.initialiseDiosphere([connections])
16
17
  diosphere.initialise([connection])
17
18
  diosphere.enterRoom(room)
18
19
  diograph.focusDiory(diory)
@@ -1,16 +1,17 @@
1
- import { IDiographObject } from '@diograph/diograph';
2
- import { IConnectionObject, IDiosphereObject } from '@diory/diosphere-js';
3
- import { IDataClient } from '@diograph/local-client';
4
- import { IConnectionClient } from '../types';
1
+ import { IDiographObject } from '@diograph/diograph'
2
+ import { IConnectionObject, IDiosphereObject } from '@diory/diosphere-js'
3
+ import { IDataClient } from '@diograph/local-client'
4
+ import { IConnectionClient } from '../types'
5
5
  declare class ConnectionClient implements IConnectionClient {
6
- type: string;
7
- client: IDataClient;
8
- connection: IConnectionObject;
9
- constructor(dataClient: IDataClient, connection: IConnectionObject);
10
- getDiosphere: () => Promise<any>;
11
- saveDiosphere: (diosphereObject: IDiosphereObject) => Promise<boolean>;
12
- getDiograph: () => Promise<any>;
13
- saveDiograph: (diographObject: IDiographObject) => Promise<boolean>;
14
- generateDiograph: () => Promise<IDiographObject>;
6
+ dataClients: IDataClient[]
7
+ connections: IConnectionObject[]
8
+ constructor(dataClients: IDataClient[])
9
+ initialiseConnections: (connections?: IConnectionObject[]) => IConnectionClient
10
+ findDataClient: ({ client }: IConnectionObject) => IDataClient | undefined
11
+ getDiosphere: () => Promise<IDiosphereObject | undefined>
12
+ saveDiosphere: (diosphereObject: IDiosphereObject) => Promise<void>
13
+ getDiograph: () => Promise<IDiographObject | undefined>
14
+ saveDiograph: (diographObject: IDiographObject) => Promise<void>
15
+ generateDiograph: () => Promise<IDiographObject>
15
16
  }
16
- export { ConnectionClient };
17
+ export { ConnectionClient }
@@ -1,39 +1,95 @@
1
- "use strict";
2
- Object.defineProperty(exports, "__esModule", { value: true });
3
- exports.ConnectionClient = void 0;
4
- const path_browserify_1 = require("path-browserify");
5
- const folder_generator_1 = require("@diograph/folder-generator");
6
- const DIOSPHERE_JSON = 'diosphere.json';
7
- const DIOGRAPH_JSON = 'diograph.json';
1
+ 'use strict'
2
+ Object.defineProperty(exports, '__esModule', { value: true })
3
+ exports.ConnectionClient = void 0
4
+ const path_browserify_1 = require('path-browserify')
5
+ const folder_generator_1 = require('@diograph/folder-generator')
6
+ const DIOSPHERE_JSON = 'diosphere.json'
7
+ const DIOGRAPH_JSON = 'diograph.json'
8
8
  class ConnectionClient {
9
- constructor(dataClient, connection) {
10
- this.getDiosphere = async () => {
11
- const path = (0, path_browserify_1.join)(this.connection.address, DIOSPHERE_JSON);
12
- const diosphereString = await this.client.readTextItem(path);
13
- return JSON.parse(diosphereString);
14
- };
15
- this.saveDiosphere = async (diosphereObject) => {
16
- const path = (0, path_browserify_1.join)(this.connection.address, DIOSPHERE_JSON);
17
- const diosphereString = JSON.stringify(diosphereObject, null, 2);
18
- return this.client.writeItem(path, diosphereString);
19
- };
20
- this.getDiograph = async () => {
21
- const path = (0, path_browserify_1.join)(this.connection.address, DIOGRAPH_JSON);
22
- const diographString = await this.client.readTextItem(path);
23
- return JSON.parse(diographString);
24
- };
25
- this.saveDiograph = async (diographObject) => {
26
- const path = (0, path_browserify_1.join)(this.connection.address, DIOGRAPH_JSON);
27
- const diographString = JSON.stringify(diographObject, null, 2);
28
- return this.client.writeItem(path, diographString);
29
- };
30
- this.generateDiograph = async () => {
31
- const { diograph } = await (0, folder_generator_1.generateDiograph)(this.connection.address, this.client);
32
- return diograph.toObject();
33
- };
34
- this.type = dataClient.type;
35
- this.client = dataClient;
36
- this.connection = connection;
9
+ constructor(dataClients) {
10
+ this.connections = []
11
+ this.initialiseConnections = (connections = []) => {
12
+ this.connections = connections
13
+ return this
37
14
  }
15
+ this.findDataClient = ({ client }) => {
16
+ return this.dataClients.find(({ type }) => type === client)
17
+ }
18
+ this.getDiosphere = async () => {
19
+ let diosphereObject
20
+ await Promise.all(
21
+ this.connections.map(async (connection) => {
22
+ const client = this.findDataClient(connection)
23
+ if (client) {
24
+ const path = (0, path_browserify_1.join)(connection.address, DIOSPHERE_JSON)
25
+ const diosphereString = await client.readTextItem(path)
26
+ diosphereObject = JSON.parse(diosphereString)
27
+ }
28
+ }),
29
+ )
30
+ // @ts-ignore
31
+ return diosphereObject
32
+ }
33
+ this.saveDiosphere = async (diosphereObject) => {
34
+ await Promise.all(
35
+ this.connections.map(async (connection) => {
36
+ const client = this.findDataClient(connection)
37
+ if (client) {
38
+ const path = (0, path_browserify_1.join)(connection.address, DIOSPHERE_JSON)
39
+ const diosphereString = JSON.stringify(diosphereObject, null, 2)
40
+ return client.writeItem(path, diosphereString)
41
+ }
42
+ }),
43
+ )
44
+ return
45
+ }
46
+ this.getDiograph = async () => {
47
+ let diographObject
48
+ await Promise.all(
49
+ this.connections.map(async (connection) => {
50
+ const client = this.findDataClient(connection)
51
+ if (client) {
52
+ const path = (0, path_browserify_1.join)(connection.address, DIOGRAPH_JSON)
53
+ const diographString = await client.readTextItem(path)
54
+ diographObject = JSON.parse(diographString)
55
+ }
56
+ }),
57
+ )
58
+ // @ts-ignore
59
+ return diographObject
60
+ }
61
+ this.saveDiograph = async (diographObject) => {
62
+ await Promise.all(
63
+ this.connections.map(async (connection) => {
64
+ const client = this.findDataClient(connection)
65
+ if (client) {
66
+ const path = (0, path_browserify_1.join)(connection.address, DIOGRAPH_JSON)
67
+ const diosphereString = JSON.stringify(diographObject, null, 2)
68
+ return client.writeItem(path, diosphereString)
69
+ }
70
+ }),
71
+ )
72
+ return
73
+ }
74
+ this.generateDiograph = async () => {
75
+ let diographObject
76
+ await Promise.all(
77
+ this.connections.map(async (connection) => {
78
+ const client = this.findDataClient(connection)
79
+ if (client) {
80
+ const { diograph } = await (0, folder_generator_1.generateDiograph)(
81
+ connection.address,
82
+ client,
83
+ )
84
+ diographObject = diograph.toObject()
85
+ return
86
+ }
87
+ }),
88
+ )
89
+ // @ts-ignore
90
+ return diographObject
91
+ }
92
+ this.dataClients = dataClients
93
+ }
38
94
  }
39
- exports.ConnectionClient = ConnectionClient;
95
+ exports.ConnectionClient = ConnectionClient
@@ -1,18 +1,18 @@
1
- "use strict";
1
+ 'use strict'
2
2
  describe('connectionClient', () => {
3
- describe('construct()', () => {
4
- it('should construct with dataClient and connection', () => {
5
- expect(true).toEqual(true);
6
- });
7
- });
8
- describe('getDiosphere()', () => {
9
- it('should get diosphere', () => {
10
- expect(true).toEqual(true);
11
- });
12
- });
13
- describe('saveDiosphere()', () => {
14
- it('should save diosphere object', () => {
15
- expect(true).toEqual(true);
16
- });
17
- });
18
- });
3
+ describe('construct()', () => {
4
+ it('should construct with dataClient and connection', () => {
5
+ expect(true).toEqual(true)
6
+ })
7
+ })
8
+ describe('getDiosphere()', () => {
9
+ it('should get diosphere', () => {
10
+ expect(true).toEqual(true)
11
+ })
12
+ })
13
+ describe('saveDiosphere()', () => {
14
+ it('should save diosphere object', () => {
15
+ expect(true).toEqual(true)
16
+ })
17
+ })
18
+ })
@@ -0,0 +1,2 @@
1
+ import { IDiograph } from '@diograph/diograph'
2
+ export declare const addDefaultDiograph: (diograph: IDiograph) => void
@@ -0,0 +1,17 @@
1
+ 'use strict'
2
+ Object.defineProperty(exports, '__esModule', { value: true })
3
+ exports.addDefaultDiograph = void 0
4
+ const addDefaultDiograph = (diograph) => {
5
+ const diory = diograph.addDiory({
6
+ text: 'Welcome to Diory',
7
+ latlng: '60.01366036242365, 20.007133483886722',
8
+ })
9
+ diograph.addDiory(
10
+ {
11
+ text: 'Root diory',
12
+ links: [{ id: diory.id }],
13
+ },
14
+ '/',
15
+ )
16
+ }
17
+ exports.addDefaultDiograph = addDefaultDiograph
@@ -0,0 +1,5 @@
1
+ import { IConnectionObject, IDiosphere } from '@diory/diosphere-js'
2
+ export declare const addDefaultRoom: (
3
+ diosphere: IDiosphere,
4
+ connections: IConnectionObject[],
5
+ ) => void
@@ -0,0 +1,13 @@
1
+ 'use strict'
2
+ Object.defineProperty(exports, '__esModule', { value: true })
3
+ exports.addDefaultRoom = void 0
4
+ const addDefaultRoom = (diosphere, connections) => {
5
+ diosphere.addRoom(
6
+ {
7
+ text: 'Home room',
8
+ connections,
9
+ },
10
+ '/',
11
+ )
12
+ }
13
+ exports.addDefaultRoom = addDefaultRoom
@@ -1,26 +1,16 @@
1
- import { IConnectionObject, IDiosphere, IDiosphereObject, IRoom, IRoomObject } from '@diory/diosphere-js';
2
- import { IDiograph, IDiographObject, IDiory, IDioryObject } from '@diograph/diograph';
1
+ import { IConnectionObject, IDiosphere, IRoom, IRoomObject } from '@diory/diosphere-js';
2
+ import { IDiograph, IDiory, IDioryObject } from '@diograph/diograph';
3
3
  import { IDataClient } from '@diograph/local-client';
4
4
  import { IDioryClient } from '../types';
5
5
  declare class DioryClient implements IDioryClient {
6
- dataClients: IDataClient[];
7
- connections: IConnectionObject[];
8
6
  diosphere: IDiosphere;
9
- room?: IRoom;
10
7
  diograph: IDiograph;
8
+ room?: IRoom;
11
9
  diory?: IDiory;
12
10
  constructor(dataClients: IDataClient[]);
13
- focusDiory: (dioryObject: IDioryObject) => IDiory;
14
- selectRoom: (roomObject: IRoomObject) => IRoom;
15
- getDiographClients: (connections?: IConnectionObject[]) => import("../types").IConnectionClient[];
16
- initialiseDiograph: (roomObject: IRoomObject) => Promise<IDiograph>;
17
- getDiograph: () => Promise<IDiographObject | undefined>;
18
- saveDiograph: () => Promise<IDiographObject>;
19
- importDiograph: (connections?: IConnectionObject[]) => Promise<IDiograph>;
20
- generateDiograph: (connections?: IConnectionObject[]) => Promise<IDiographObject | undefined>;
21
- getDiosphereClients: (connections?: IConnectionObject[]) => import("../types").IConnectionClient[];
22
11
  initialiseDiosphere: (connections: IConnectionObject[]) => Promise<IDiosphere>;
23
- getDiosphere: () => Promise<IDiosphereObject | undefined>;
24
- saveDiosphere: () => Promise<IDiosphereObject>;
12
+ initialiseDiograph: (roomObject: IRoomObject) => Promise<IDiograph>;
13
+ selectRoom: (roomObject: IRoomObject) => IRoom;
14
+ focusDiory: (dioryObject: IDioryObject) => IDiory;
25
15
  }
26
16
  export { DioryClient };
@@ -3,132 +3,43 @@ Object.defineProperty(exports, "__esModule", { value: true });
3
3
  exports.DioryClient = void 0;
4
4
  const diosphere_js_1 = require("@diory/diosphere-js");
5
5
  const diograph_1 = require("@diograph/diograph");
6
- const getConnectionClients_1 = require("../utils/getConnectionClients");
7
- const debounce_1 = require("../utils/debounce");
8
- const getDefaultDiosphere_1 = require("./getDefaultDiosphere");
9
- const getDefaultDiograph_1 = require("./getDefaultDiograph");
6
+ const local_client_1 = require("@diograph/local-client");
7
+ const addDefaultRoom_1 = require("../utils/addDefaultRoom");
8
+ const addDefaultDiograph_1 = require("../utils/addDefaultDiograph");
10
9
  class DioryClient {
11
10
  constructor(dataClients) {
12
- this.dataClients = [];
13
- this.connections = [];
14
- this.focusDiory = (dioryObject) => {
15
- return (this.diory = this.diograph.getDiory(dioryObject));
16
- };
17
- this.selectRoom = (roomObject) => {
18
- return (this.room = this.diosphere.getRoom(roomObject));
19
- };
20
- this.getDiographClients = (connections) => {
21
- var _a;
22
- return (0, getConnectionClients_1.getConnectionClients)(this.dataClients, connections !== null && connections !== void 0 ? connections : (_a = this.room) === null || _a === void 0 ? void 0 : _a.connections);
11
+ this.initialiseDiosphere = async (connections) => {
12
+ console.info('initialiseDiosphere: connections', connections);
13
+ this.diosphere.initialise(connections);
14
+ await this.diosphere.getDiosphere();
15
+ if (!Object.keys(this.diosphere.rooms)) {
16
+ (0, addDefaultRoom_1.addDefaultRoom)(this.diosphere, connections);
17
+ }
18
+ this.selectRoom({ id: '/' });
19
+ return this.diosphere;
23
20
  };
24
21
  this.initialiseDiograph = async (roomObject) => {
25
- var _a;
22
+ var _a, _b;
26
23
  console.info('initialiseDiograph: room', roomObject);
27
24
  this.selectRoom(roomObject);
28
- this.diograph.resetDiograph();
29
- const diographObject = (_a = (await this.getDiograph())) !== null && _a !== void 0 ? _a : (0, getDefaultDiograph_1.getDefaultDiograph)();
30
- this.diograph.addDiograph(diographObject);
31
- this.focusDiory({ id: '/' });
32
- return this.diograph;
33
- };
34
- this.getDiograph = async () => {
35
- console.info('getDiograph');
36
- let diographObject;
37
- await Promise.all(this.getDiographClients().map(async (connectionClient) => {
38
- try {
39
- diographObject = await connectionClient.getDiograph();
40
- console.info(diographObject);
41
- }
42
- catch (error) {
43
- console.error(error);
25
+ if ((_a = this.room) === null || _a === void 0 ? void 0 : _a.connections) {
26
+ this.diograph.initialise((_b = this.room) === null || _b === void 0 ? void 0 : _b.connections);
27
+ await this.diograph.getDiograph();
28
+ if (!Object.keys(this.diograph.diograph)) {
29
+ (0, addDefaultDiograph_1.addDefaultDiograph)(this.diograph);
44
30
  }
45
- return;
46
- }));
47
- return diographObject;
48
- };
49
- this.saveDiograph = async () => {
50
- console.info('saveDiograph');
51
- const diographObject = this.diograph.toObject();
52
- await Promise.all(this.getDiographClients().map(async (connectionClient) => {
53
- await connectionClient.saveDiograph(diographObject);
54
- console.info(diographObject);
55
- return;
56
- }));
57
- return diographObject;
58
- };
59
- this.importDiograph = async (connections) => {
60
- var _a;
61
- const diographObject = await this.generateDiograph(connections);
62
- if (diographObject) {
63
- const diory = (_a = this.diory) === null || _a === void 0 ? void 0 : _a.toObject();
64
- Object.entries(diographObject).forEach(([key, dioryObject]) => {
65
- try {
66
- key === '/' && diory
67
- ? this.diograph.addDioryLink(diory, diographObject['/'])
68
- : this.diograph.addDiory(dioryObject);
69
- }
70
- catch (error) {
71
- console.error(error);
72
- }
73
- });
74
- await this.saveDiograph();
75
- console.info(this.diograph.toObject());
31
+ this.focusDiory({ id: '/' });
76
32
  }
77
33
  return this.diograph;
78
34
  };
79
- this.generateDiograph = async (connections) => {
80
- console.info('generateDiograph', connections);
81
- let diographObject;
82
- await Promise.all(this.getDiographClients(connections).map(async (connectionClient) => {
83
- diographObject = await connectionClient.generateDiograph();
84
- console.info(diographObject);
85
- return;
86
- }));
87
- return diographObject;
88
- };
89
- this.getDiosphereClients = (connections) => {
90
- return (0, getConnectionClients_1.getConnectionClients)(this.dataClients, connections !== null && connections !== void 0 ? connections : this.connections);
91
- };
92
- this.initialiseDiosphere = async (connections) => {
93
- var _a;
94
- console.info('initialiseDiosphere: connections', connections);
95
- this.connections = connections;
96
- this.diosphere.resetRooms();
97
- const diosphereObject = (_a = (await this.getDiosphere())) !== null && _a !== void 0 ? _a : (0, getDefaultDiosphere_1.getDefaultDiosphere)(connections);
98
- this.diosphere.addDiosphere(diosphereObject);
99
- this.selectRoom({ id: '/' });
100
- return this.diosphere;
101
- };
102
- this.getDiosphere = async () => {
103
- console.info('getDiosphere');
104
- let diosphereObject;
105
- await Promise.all(this.getDiosphereClients().map(async (connectionClient) => {
106
- try {
107
- diosphereObject = await connectionClient.getDiosphere();
108
- console.info(diosphereObject);
109
- }
110
- catch (error) {
111
- console.error(error);
112
- }
113
- return;
114
- }));
115
- return diosphereObject;
35
+ this.selectRoom = (roomObject) => {
36
+ return (this.room = this.diosphere.getRoom(roomObject));
116
37
  };
117
- this.saveDiosphere = async () => {
118
- console.info('saveDiosphere');
119
- const diosphereObject = this.diosphere.toObject();
120
- await Promise.all(this.getDiosphereClients().map(async (connectionClient) => {
121
- await connectionClient.saveDiosphere(diosphereObject);
122
- console.info(diosphereObject);
123
- return;
124
- }));
125
- return diosphereObject;
38
+ this.focusDiory = (dioryObject) => {
39
+ return (this.diory = this.diograph.getDiory(dioryObject));
126
40
  };
127
- this.dataClients = dataClients;
128
- this.diosphere = new diosphere_js_1.Diosphere();
129
- this.diograph = new diograph_1.Diograph();
130
- this.diosphere.saveDiosphere = (0, debounce_1.debounce)(this.saveDiosphere, 1000);
131
- this.diograph.saveDiograph = (0, debounce_1.debounce)(this.saveDiograph, 1000);
41
+ this.diosphere = new diosphere_js_1.Diosphere(new local_client_1.ConnectionClient(dataClients));
42
+ this.diograph = new diograph_1.Diograph(new local_client_1.ConnectionClient(dataClients));
132
43
  }
133
44
  }
134
45
  exports.DioryClient = DioryClient;
@@ -1,2 +1,2 @@
1
- import { IDiographObject } from '@diograph/diograph';
2
- export declare const getDefaultDiograph: () => IDiographObject;
1
+ import { IDiographObject } from '@diograph/diograph'
2
+ export declare const getDefaultDiograph: () => IDiographObject
@@ -1,17 +1,20 @@
1
- "use strict";
2
- Object.defineProperty(exports, "__esModule", { value: true });
3
- exports.getDefaultDiograph = void 0;
4
- const diograph_1 = require("@diograph/diograph");
1
+ 'use strict'
2
+ Object.defineProperty(exports, '__esModule', { value: true })
3
+ exports.getDefaultDiograph = void 0
4
+ const diograph_1 = require('@diograph/diograph')
5
5
  const getDefaultDiograph = () => {
6
- const diograph = new diograph_1.Diograph();
7
- const diory = diograph.addDiory({
8
- text: 'Welcome to Diory',
9
- latlng: '60.01366036242365, 20.007133483886722',
10
- });
11
- diograph.addDiory({
12
- text: 'Root',
13
- links: [{ id: diory.id }],
14
- }, '/');
15
- return diograph.toObject();
16
- };
17
- exports.getDefaultDiograph = getDefaultDiograph;
6
+ const diograph = new diograph_1.Diograph()
7
+ const diory = diograph.addDiory({
8
+ text: 'Welcome to Diory',
9
+ latlng: '60.01366036242365, 20.007133483886722',
10
+ })
11
+ diograph.addDiory(
12
+ {
13
+ text: 'Root',
14
+ links: [{ id: diory.id }],
15
+ },
16
+ '/',
17
+ )
18
+ return diograph.toObject()
19
+ }
20
+ exports.getDefaultDiograph = getDefaultDiograph
@@ -1,2 +1,2 @@
1
- import { IConnectionObject, IDiosphereObject } from '@diory/diosphere-js';
2
- export declare const getDefaultDiosphere: (connections: IConnectionObject[]) => IDiosphereObject;
1
+ import { IConnectionObject, IDiosphereObject } from '@diory/diosphere-js'
2
+ export declare const getDefaultDiosphere: (connections: IConnectionObject[]) => IDiosphereObject
@@ -1,13 +1,16 @@
1
- "use strict";
2
- Object.defineProperty(exports, "__esModule", { value: true });
3
- exports.getDefaultDiosphere = void 0;
4
- const diosphere_js_1 = require("@diory/diosphere-js");
1
+ 'use strict'
2
+ Object.defineProperty(exports, '__esModule', { value: true })
3
+ exports.getDefaultDiosphere = void 0
4
+ const diosphere_js_1 = require('@diory/diosphere-js')
5
5
  const getDefaultDiosphere = (connections) => {
6
- const diosphere = new diosphere_js_1.Diosphere();
7
- diosphere.addRoom({
8
- text: 'Room',
9
- connections,
10
- }, '/');
11
- return diosphere.toObject();
12
- };
13
- exports.getDefaultDiosphere = getDefaultDiosphere;
6
+ const diosphere = new diosphere_js_1.Diosphere()
7
+ diosphere.addRoom(
8
+ {
9
+ text: 'Room',
10
+ connections,
11
+ },
12
+ '/',
13
+ )
14
+ return diosphere.toObject()
15
+ }
16
+ exports.getDefaultDiosphere = getDefaultDiosphere
package/dist/index.d.ts CHANGED
@@ -1,3 +1,2 @@
1
1
  export { DioryClient } from './dioryClient/dioryClient';
2
- export { ConnectionClient } from './connectionClient/connectionClient';
3
- export { IDioryClient, IConnectionClient } from './types';
2
+ export { IDioryClient } from './types';
package/dist/index.js CHANGED
@@ -1,7 +1,5 @@
1
1
  "use strict";
2
2
  Object.defineProperty(exports, "__esModule", { value: true });
3
- exports.ConnectionClient = exports.DioryClient = void 0;
3
+ exports.DioryClient = void 0;
4
4
  var dioryClient_1 = require("./dioryClient/dioryClient");
5
5
  Object.defineProperty(exports, "DioryClient", { enumerable: true, get: function () { return dioryClient_1.DioryClient; } });
6
- var connectionClient_1 = require("./connectionClient/connectionClient");
7
- Object.defineProperty(exports, "ConnectionClient", { enumerable: true, get: function () { return connectionClient_1.ConnectionClient; } });
package/dist/types.d.ts CHANGED
@@ -1,31 +1,12 @@
1
- import { IConnectionObject, IDiosphere, IDiosphereObject, IRoom, IRoomObject } from '@diory/diosphere-js';
2
- import { IDiograph, IDiographObject, IDiory, IDioryObject } from '@diograph/diograph';
3
- import { IDataClient } from '@diograph/local-client';
4
- export interface IConnectionClient {
5
- type: string;
6
- client: IDataClient;
7
- connection: IConnectionObject;
8
- getDiosphere: () => Promise<IDiosphereObject>;
9
- saveDiosphere: (diosphereObject: IDiosphereObject) => void;
10
- getDiograph: () => Promise<IDiographObject>;
11
- saveDiograph: (diographObject: IDiographObject) => void;
12
- generateDiograph: () => Promise<IDiographObject>;
13
- }
1
+ import { IConnectionObject, IDiosphere, IRoom, IRoomObject } from '@diory/diosphere-js';
2
+ import { IDiograph, IDiory, IDioryObject } from '@diograph/diograph';
14
3
  export interface IDioryClient {
15
- dataClients: IDataClient[];
16
- connections: IConnectionObject[];
17
- diory?: IDiory;
18
- focusDiory: (dioryObject: IDioryObject) => IDiory;
19
- room?: IRoom;
20
- selectRoom: (roomObject: IRoomObject) => IRoom;
21
- diograph: IDiograph;
22
- initialiseDiograph: (roomObject: IRoomObject) => Promise<IDiograph>;
23
- getDiograph: () => Promise<IDiographObject | undefined>;
24
- saveDiograph: () => Promise<IDiographObject>;
25
- importDiograph: (connections?: IConnectionObject[]) => Promise<IDiograph>;
26
- generateDiograph: (connections?: IConnectionObject[]) => Promise<IDiographObject | undefined>;
27
4
  diosphere: IDiosphere;
5
+ diograph: IDiograph;
6
+ room?: IRoom;
7
+ diory?: IDiory;
28
8
  initialiseDiosphere: (connections: IConnectionObject[]) => Promise<IDiosphere>;
29
- getDiosphere: () => Promise<IDiosphereObject | undefined>;
30
- saveDiosphere: () => Promise<IDiosphereObject>;
9
+ initialiseDiograph: (roomObject: IRoomObject) => Promise<IDiograph>;
10
+ selectRoom: (roomObject: IRoomObject) => IRoom;
11
+ focusDiory: (dioryObject: IDioryObject) => IDiory;
31
12
  }
@@ -0,0 +1,2 @@
1
+ import { IDiograph } from '@diograph/diograph';
2
+ export declare const addDefaultDiograph: (diograph: IDiograph) => void;
@@ -0,0 +1,14 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ exports.addDefaultDiograph = void 0;
4
+ const addDefaultDiograph = (diograph) => {
5
+ const diory = diograph.addDiory({
6
+ text: 'Welcome to Diory',
7
+ latlng: '60.01366036242365, 20.007133483886722',
8
+ });
9
+ diograph.addDiory({
10
+ text: 'Root diory',
11
+ links: [{ id: diory.id }],
12
+ }, '/');
13
+ };
14
+ exports.addDefaultDiograph = addDefaultDiograph;
@@ -0,0 +1,2 @@
1
+ import { IConnectionObject, IDiosphere } from '@diory/diosphere-js';
2
+ export declare const addDefaultRoom: (diosphere: IDiosphere, connections: IConnectionObject[]) => void;
@@ -0,0 +1,10 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ exports.addDefaultRoom = void 0;
4
+ const addDefaultRoom = (diosphere, connections) => {
5
+ diosphere.addRoom({
6
+ text: 'Home room',
7
+ connections,
8
+ }, '/');
9
+ };
10
+ exports.addDefaultRoom = addDefaultRoom;
@@ -1,4 +1,7 @@
1
- import { IConnectionObject } from '@diory/diosphere-js';
2
- import { IDataClient } from '@diograph/local-client';
3
- import { IConnectionClient } from '../types';
4
- export declare function getConnectionClients(dataClients: IDataClient[], connections?: IConnectionObject[]): IConnectionClient[];
1
+ import { IConnectionObject } from '@diory/diosphere-js'
2
+ import { IDataClient } from '@diograph/local-client'
3
+ import { IConnectionClient } from '../types'
4
+ export declare function getConnectionClients(
5
+ dataClients: IDataClient[],
6
+ connections?: IConnectionObject[],
7
+ ): IConnectionClient[]
@@ -1,16 +1,16 @@
1
- "use strict";
2
- Object.defineProperty(exports, "__esModule", { value: true });
3
- exports.getConnectionClients = void 0;
4
- const connectionClient_1 = require("../connectionClient/connectionClient");
1
+ 'use strict'
2
+ Object.defineProperty(exports, '__esModule', { value: true })
3
+ exports.getConnectionClients = void 0
4
+ const connectionClient_1 = require('../connectionClient/connectionClient')
5
5
  function getDataClient(dataClients, { client }) {
6
- return dataClients.find(({ type }) => type === client);
6
+ return dataClients.find(({ type }) => type === client)
7
7
  }
8
8
  function getConnectionClients(dataClients, connections = []) {
9
- return connections
10
- .filter(({ client }) => dataClients.some(({ type }) => type === client))
11
- .map((connection) => {
12
- const dataClient = getDataClient(dataClients, connection);
13
- return new connectionClient_1.ConnectionClient(dataClient, connection);
14
- });
9
+ return connections
10
+ .filter(({ client }) => dataClients.some(({ type }) => type === client))
11
+ .map((connection) => {
12
+ const dataClient = getDataClient(dataClients, connection)
13
+ return new connectionClient_1.ConnectionClient(dataClient, connection)
14
+ })
15
15
  }
16
- exports.getConnectionClients = getConnectionClients;
16
+ exports.getConnectionClients = getConnectionClients
package/package.json CHANGED
@@ -1,15 +1,15 @@
1
1
  {
2
2
  "name": "@diory/client-js",
3
- "version": "0.4.0-rc1",
3
+ "version": "0.4.0-rc2",
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
- "@diograph/diograph": "^0.3.0",
9
+ "@diograph/diograph": "^0.4.0-rc1",
10
10
  "@diograph/folder-generator": "^0.4.0-rc1",
11
- "@diograph/local-client": "^0.3.2",
12
- "@diory/diosphere-js": "^0.2.6",
11
+ "@diograph/local-client": "^0.4.0-rc3",
12
+ "@diory/diosphere-js": "^0.4.0-rc1",
13
13
  "path-browserify": "^1.0.1",
14
14
  "uuid": "8.3.2"
15
15
  },
@@ -1,186 +1,62 @@
1
- import {
2
- Diosphere,
3
- IConnectionObject,
4
- IDiosphere,
5
- IDiosphereObject,
6
- IRoom,
7
- IRoomObject,
8
- } from '@diory/diosphere-js'
9
- import { Diograph, IDiograph, IDiographObject, IDiory, IDioryObject } from '@diograph/diograph'
10
- import { IDataClient } from '@diograph/local-client'
1
+ import { Diosphere, IConnectionObject, IDiosphere, IRoom, IRoomObject } from '@diory/diosphere-js'
2
+ import { Diograph, IDiograph, IDiory, IDioryObject } from '@diograph/diograph'
3
+ import { IDataClient, ConnectionClient } from '@diograph/local-client'
11
4
 
12
5
  import { IDioryClient } from '../types'
13
- import { getConnectionClients } from '../utils/getConnectionClients'
14
- import { debounce } from '../utils/debounce'
15
6
 
16
- import { getDefaultDiosphere } from './getDefaultDiosphere'
17
- import { getDefaultDiograph } from './getDefaultDiograph'
7
+ import { addDefaultRoom } from '../utils/addDefaultRoom'
8
+ import { addDefaultDiograph } from '../utils/addDefaultDiograph'
18
9
 
19
10
  class DioryClient implements IDioryClient {
20
- dataClients: IDataClient[] = []
21
- connections: IConnectionObject[] = []
22
11
  diosphere: IDiosphere
23
- room?: IRoom
24
12
  diograph: IDiograph
13
+ room?: IRoom
25
14
  diory?: IDiory
26
15
 
27
16
  constructor(dataClients: IDataClient[]) {
28
- this.dataClients = dataClients
17
+ this.diosphere = new Diosphere(new ConnectionClient(dataClients))
18
+ this.diograph = new Diograph(new ConnectionClient(dataClients))
19
+ }
29
20
 
30
- this.diosphere = new Diosphere()
31
- this.diograph = new Diograph()
21
+ initialiseDiosphere = async (connections: IConnectionObject[]): Promise<IDiosphere> => {
22
+ console.info('initialiseDiosphere: connections', connections)
32
23
 
33
- this.diosphere.saveDiosphere = debounce(this.saveDiosphere, 1000)
34
- this.diograph.saveDiograph = debounce(this.saveDiograph, 1000)
35
- }
24
+ this.diosphere.initialise(connections)
25
+ await this.diosphere.getDiosphere()
36
26
 
37
- focusDiory = (dioryObject: IDioryObject): IDiory => {
38
- return (this.diory = this.diograph.getDiory(dioryObject))
39
- }
27
+ if (!Object.keys(this.diosphere.rooms)) {
28
+ addDefaultRoom(this.diosphere, connections)
29
+ }
40
30
 
41
- selectRoom = (roomObject: IRoomObject): IRoom => {
42
- return (this.room = this.diosphere.getRoom(roomObject))
43
- }
31
+ this.selectRoom({ id: '/' })
44
32
 
45
- getDiographClients = (connections?: IConnectionObject[]) => {
46
- return getConnectionClients(this.dataClients, connections ?? this.room?.connections)
33
+ return this.diosphere
47
34
  }
48
35
 
49
36
  initialiseDiograph = async (roomObject: IRoomObject): Promise<IDiograph> => {
50
37
  console.info('initialiseDiograph: room', roomObject)
51
38
  this.selectRoom(roomObject)
52
39
 
53
- this.diograph.resetDiograph()
54
- const diographObject = (await this.getDiograph()) ?? getDefaultDiograph()
55
- this.diograph.addDiograph(diographObject)
56
-
57
- this.focusDiory({ id: '/' })
58
-
59
- return this.diograph
60
- }
61
-
62
- getDiograph = async (): Promise<IDiographObject | undefined> => {
63
- console.info('getDiograph')
64
-
65
- let diographObject
66
- await Promise.all(
67
- this.getDiographClients().map(async (connectionClient) => {
68
- try {
69
- diographObject = await connectionClient.getDiograph()
70
- console.info(diographObject)
71
- } catch (error) {
72
- console.error(error)
73
- }
74
- return
75
- }),
76
- )
77
-
78
- return diographObject
79
- }
80
-
81
- saveDiograph = async (): Promise<IDiographObject> => {
82
- console.info('saveDiograph')
40
+ if (this.room?.connections) {
41
+ this.diograph.initialise(this.room?.connections)
42
+ await this.diograph.getDiograph()
83
43
 
84
- const diographObject = this.diograph.toObject()
85
- await Promise.all(
86
- this.getDiographClients().map(async (connectionClient) => {
87
- await connectionClient.saveDiograph(diographObject)
88
- console.info(diographObject)
89
- return
90
- }),
91
- )
44
+ if (!Object.keys(this.diograph.diograph)) {
45
+ addDefaultDiograph(this.diograph)
46
+ }
92
47
 
93
- return diographObject
94
- }
95
-
96
- importDiograph = async (connections?: IConnectionObject[]): Promise<IDiograph> => {
97
- const diographObject = await this.generateDiograph(connections)
98
-
99
- if (diographObject) {
100
- const diory = this.diory?.toObject()
101
- Object.entries(diographObject).forEach(([key, dioryObject]) => {
102
- try {
103
- key === '/' && diory
104
- ? this.diograph.addDioryLink(diory, diographObject['/'])
105
- : this.diograph.addDiory(dioryObject)
106
- } catch (error) {
107
- console.error(error)
108
- }
109
- })
110
-
111
- await this.saveDiograph()
112
- console.info(this.diograph.toObject())
48
+ this.focusDiory({ id: '/' })
113
49
  }
114
50
 
115
51
  return this.diograph
116
52
  }
117
53
 
118
- generateDiograph = async (
119
- connections?: IConnectionObject[],
120
- ): Promise<IDiographObject | undefined> => {
121
- console.info('generateDiograph', connections)
122
-
123
- let diographObject
124
- await Promise.all(
125
- this.getDiographClients(connections).map(async (connectionClient) => {
126
- diographObject = await connectionClient.generateDiograph()
127
- console.info(diographObject)
128
- return
129
- }),
130
- )
131
-
132
- return diographObject
133
- }
134
-
135
- getDiosphereClients = (connections?: IConnectionObject[]) => {
136
- return getConnectionClients(this.dataClients, connections ?? this.connections)
137
- }
138
-
139
- initialiseDiosphere = async (connections: IConnectionObject[]): Promise<IDiosphere> => {
140
- console.info('initialiseDiosphere: connections', connections)
141
- this.connections = connections
142
-
143
- this.diosphere.resetRooms()
144
- const diosphereObject = (await this.getDiosphere()) ?? getDefaultDiosphere(connections)
145
- this.diosphere.addDiosphere(diosphereObject)
146
-
147
- this.selectRoom({ id: '/' })
148
-
149
- return this.diosphere
150
- }
151
-
152
- getDiosphere = async (): Promise<IDiosphereObject | undefined> => {
153
- console.info('getDiosphere')
154
-
155
- let diosphereObject
156
- await Promise.all(
157
- this.getDiosphereClients().map(async (connectionClient) => {
158
- try {
159
- diosphereObject = await connectionClient.getDiosphere()
160
- console.info(diosphereObject)
161
- } catch (error) {
162
- console.error(error)
163
- }
164
- return
165
- }),
166
- )
167
-
168
- return diosphereObject
54
+ selectRoom = (roomObject: IRoomObject): IRoom => {
55
+ return (this.room = this.diosphere.getRoom(roomObject))
169
56
  }
170
57
 
171
- saveDiosphere = async (): Promise<IDiosphereObject> => {
172
- console.info('saveDiosphere')
173
-
174
- const diosphereObject = this.diosphere.toObject()
175
- await Promise.all(
176
- this.getDiosphereClients().map(async (connectionClient) => {
177
- await connectionClient.saveDiosphere(diosphereObject)
178
- console.info(diosphereObject)
179
- return
180
- }),
181
- )
182
-
183
- return diosphereObject
58
+ focusDiory = (dioryObject: IDioryObject): IDiory => {
59
+ return (this.diory = this.diograph.getDiory(dioryObject))
184
60
  }
185
61
  }
186
62
 
package/src/index.ts CHANGED
@@ -1,3 +1,2 @@
1
1
  export { DioryClient } from './dioryClient/dioryClient'
2
- export { ConnectionClient } from './connectionClient/connectionClient'
3
- export { IDioryClient, IConnectionClient } from './types'
2
+ export { IDioryClient } from './types'
package/src/types.ts CHANGED
@@ -1,39 +1,13 @@
1
- import {
2
- IConnectionObject,
3
- IDiosphere,
4
- IDiosphereObject,
5
- IRoom,
6
- IRoomObject,
7
- } from '@diory/diosphere-js'
8
- import { IDiograph, IDiographObject, IDiory, IDioryObject } from '@diograph/diograph'
9
- import { IDataClient } from '@diograph/local-client'
10
-
11
- export interface IConnectionClient {
12
- type: string
13
- client: IDataClient
14
- connection: IConnectionObject
15
- getDiosphere: () => Promise<IDiosphereObject>
16
- saveDiosphere: (diosphereObject: IDiosphereObject) => void
17
- getDiograph: () => Promise<IDiographObject>
18
- saveDiograph: (diographObject: IDiographObject) => void
19
- generateDiograph: () => Promise<IDiographObject>
20
- }
1
+ import { IConnectionObject, IDiosphere, IRoom, IRoomObject } from '@diory/diosphere-js'
2
+ import { IDiograph, IDiory, IDioryObject } from '@diograph/diograph'
21
3
 
22
4
  export interface IDioryClient {
23
- dataClients: IDataClient[]
24
- connections: IConnectionObject[]
25
- diory?: IDiory
26
- focusDiory: (dioryObject: IDioryObject) => IDiory
27
- room?: IRoom
28
- selectRoom: (roomObject: IRoomObject) => IRoom
29
- diograph: IDiograph
30
- initialiseDiograph: (roomObject: IRoomObject) => Promise<IDiograph>
31
- getDiograph: () => Promise<IDiographObject | undefined>
32
- saveDiograph: () => Promise<IDiographObject>
33
- importDiograph: (connections?: IConnectionObject[]) => Promise<IDiograph>
34
- generateDiograph: (connections?: IConnectionObject[]) => Promise<IDiographObject | undefined>
35
5
  diosphere: IDiosphere
6
+ diograph: IDiograph
7
+ room?: IRoom
8
+ diory?: IDiory
36
9
  initialiseDiosphere: (connections: IConnectionObject[]) => Promise<IDiosphere>
37
- getDiosphere: () => Promise<IDiosphereObject | undefined>
38
- saveDiosphere: () => Promise<IDiosphereObject>
10
+ initialiseDiograph: (roomObject: IRoomObject) => Promise<IDiograph>
11
+ selectRoom: (roomObject: IRoomObject) => IRoom
12
+ focusDiory: (dioryObject: IDioryObject) => IDiory
39
13
  }
@@ -1,18 +1,15 @@
1
- import { Diograph, IDiographObject } from '@diograph/diograph'
1
+ import { IDiograph } from '@diograph/diograph'
2
2
 
3
- export const getDefaultDiograph = (): IDiographObject => {
4
- const diograph = new Diograph()
3
+ export const addDefaultDiograph = (diograph: IDiograph): void => {
5
4
  const diory = diograph.addDiory({
6
5
  text: 'Welcome to Diory',
7
6
  latlng: '60.01366036242365, 20.007133483886722',
8
7
  })
9
8
  diograph.addDiory(
10
9
  {
11
- text: 'Root',
10
+ text: 'Root diory',
12
11
  links: [{ id: diory.id }],
13
12
  },
14
13
  '/',
15
14
  )
16
-
17
- return diograph.toObject()
18
15
  }
@@ -0,0 +1,11 @@
1
+ import { IConnectionObject, IDiosphere } from '@diory/diosphere-js'
2
+
3
+ export const addDefaultRoom = (diosphere: IDiosphere, connections: IConnectionObject[]): void => {
4
+ diosphere.addRoom(
5
+ {
6
+ text: 'Home room',
7
+ connections,
8
+ },
9
+ '/',
10
+ )
11
+ }
@@ -1,19 +0,0 @@
1
- describe('connectionClient', () => {
2
- describe('construct()', () => {
3
- it('should construct with dataClient and connection', () => {
4
- expect(true).toEqual(true)
5
- })
6
- })
7
-
8
- describe('getDiosphere()', () => {
9
- it('should get diosphere', () => {
10
- expect(true).toEqual(true)
11
- })
12
- })
13
-
14
- describe('saveDiosphere()', () => {
15
- it('should save diosphere object', () => {
16
- expect(true).toEqual(true)
17
- })
18
- })
19
- })
@@ -1,54 +0,0 @@
1
- import { join } from 'path-browserify'
2
- import { generateDiograph } from '@diograph/folder-generator'
3
-
4
- import { IDiographObject } from '@diograph/diograph'
5
- import { IConnectionObject, IDiosphereObject } from '@diory/diosphere-js'
6
- import { IDataClient } from '@diograph/local-client'
7
-
8
- import { IConnectionClient } from '../types'
9
-
10
- const DIOSPHERE_JSON = 'diosphere.json'
11
- const DIOGRAPH_JSON = 'diograph.json'
12
-
13
- class ConnectionClient implements IConnectionClient {
14
- type: string
15
- client: IDataClient
16
- connection: IConnectionObject
17
-
18
- constructor(dataClient: IDataClient, connection: IConnectionObject) {
19
- this.type = dataClient.type
20
- this.client = dataClient
21
- this.connection = connection
22
- }
23
-
24
- getDiosphere = async () => {
25
- const path = join(this.connection.address, DIOSPHERE_JSON)
26
- const diosphereString = await this.client.readTextItem(path)
27
- return JSON.parse(diosphereString)
28
- }
29
-
30
- saveDiosphere = async (diosphereObject: IDiosphereObject) => {
31
- const path = join(this.connection.address, DIOSPHERE_JSON)
32
- const diosphereString = JSON.stringify(diosphereObject, null, 2)
33
- return this.client.writeItem(path, diosphereString)
34
- }
35
-
36
- getDiograph = async () => {
37
- const path = join(this.connection.address, DIOGRAPH_JSON)
38
- const diographString = await this.client.readTextItem(path)
39
- return JSON.parse(diographString)
40
- }
41
-
42
- saveDiograph = async (diographObject: IDiographObject) => {
43
- const path = join(this.connection.address, DIOGRAPH_JSON)
44
- const diographString = JSON.stringify(diographObject, null, 2)
45
- return this.client.writeItem(path, diographString)
46
- }
47
-
48
- generateDiograph = async (): Promise<IDiographObject> => {
49
- const { diograph } = await generateDiograph(this.connection.address, this.client)
50
- return diograph.toObject()
51
- }
52
- }
53
-
54
- export { ConnectionClient }
@@ -1,14 +0,0 @@
1
- import { Diosphere, IConnectionObject, IDiosphereObject } from '@diory/diosphere-js'
2
-
3
- export const getDefaultDiosphere = (connections: IConnectionObject[]): IDiosphereObject => {
4
- const diosphere = new Diosphere()
5
- diosphere.addRoom(
6
- {
7
- text: 'Room',
8
- connections,
9
- },
10
- '/',
11
- )
12
-
13
- return diosphere.toObject()
14
- }
@@ -1,24 +0,0 @@
1
- import { IConnectionObject } from '@diory/diosphere-js'
2
- import { IDataClient } from '@diograph/local-client'
3
-
4
- import { ConnectionClient } from '../connectionClient/connectionClient'
5
- import { IConnectionClient } from '../types'
6
-
7
- function getDataClient(
8
- dataClients: IDataClient[],
9
- { client }: IConnectionObject,
10
- ): IDataClient | undefined {
11
- return dataClients.find(({ type }) => type === client)
12
- }
13
-
14
- export function getConnectionClients(
15
- dataClients: IDataClient[],
16
- connections: IConnectionObject[] = [],
17
- ): IConnectionClient[] {
18
- return connections
19
- .filter(({ client }) => dataClients.some(({ type }) => type === client))
20
- .map((connection) => {
21
- const dataClient = getDataClient(dataClients, connection)
22
- return new ConnectionClient(dataClient!, connection)
23
- }) as IConnectionClient[]
24
- }