@diory/client-js 0.2.0 → 0.2.1-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.
@@ -13,13 +13,13 @@ declare class DioryClient implements IDioryClient {
13
13
  selectRoom: (roomObject: IRoomObject) => IRoom;
14
14
  getDiographClients: (connections?: IConnectionObject[]) => import("../types").IConnectionClient[];
15
15
  initialiseDiograph: (roomObject: IRoomObject) => Promise<IDiograph>;
16
- getDiograph: (connections?: IConnectionObject[]) => Promise<IDiographObject | undefined>;
17
- saveDiograph: (connections?: IConnectionObject[]) => Promise<IDiographObject>;
18
- importDiograph: (connections?: IConnectionObject[]) => Promise<IDiograph>;
19
- generateDiograph: (connections?: IConnectionObject[]) => Promise<IDiographObject | undefined>;
16
+ getDiograph: () => Promise<IDiographObject | undefined>;
17
+ saveDiograph: () => Promise<IDiographObject>;
18
+ importDiograph: () => Promise<IDiograph>;
19
+ generateDiograph: () => Promise<IDiographObject | undefined>;
20
20
  getDiosphereClients: (connections?: IConnectionObject[]) => import("../types").IConnectionClient[];
21
21
  initialiseDiosphere: (connections: IConnectionObject[]) => Promise<IDiosphere>;
22
- getDiosphere: (connections?: IConnectionObject[]) => Promise<IDiosphereObject | undefined>;
23
- saveDiosphere: (connections?: IConnectionObject[]) => Promise<IDiosphereObject>;
22
+ getDiosphere: () => Promise<IDiosphereObject | undefined>;
23
+ saveDiosphere: () => Promise<IDiosphereObject>;
24
24
  }
25
25
  export { DioryClient };
@@ -32,10 +32,10 @@ class DioryClient {
32
32
  console.info(this.diograph.toObject());
33
33
  return this.diograph;
34
34
  };
35
- this.getDiograph = async (connections) => {
36
- console.info('getDiograph', connections);
35
+ this.getDiograph = async () => {
36
+ console.info('getDiograph');
37
37
  let diographObject;
38
- await Promise.all(this.getDiographClients(connections).map(async (connectionClient) => {
38
+ await Promise.all(this.getDiographClients().map(async (connectionClient) => {
39
39
  try {
40
40
  diographObject = await connectionClient.getDiograph();
41
41
  console.info(diographObject);
@@ -47,19 +47,19 @@ class DioryClient {
47
47
  }));
48
48
  return diographObject;
49
49
  };
50
- this.saveDiograph = async (connections) => {
51
- console.info('saveDiograph', connections);
50
+ this.saveDiograph = async () => {
51
+ console.info('saveDiograph');
52
52
  const diographObject = this.diograph.toObject();
53
- await Promise.all(this.getDiographClients(connections).map(async (connectionClient) => {
53
+ await Promise.all(this.getDiographClients().map(async (connectionClient) => {
54
54
  await connectionClient.saveDiograph(diographObject);
55
55
  console.info(diographObject);
56
56
  return;
57
57
  }));
58
58
  return diographObject;
59
59
  };
60
- this.importDiograph = async (connections) => {
60
+ this.importDiograph = async () => {
61
61
  var _a;
62
- const diographObject = await this.generateDiograph(connections);
62
+ const diographObject = await this.generateDiograph();
63
63
  if (diographObject) {
64
64
  const diory = (_a = this.diory) === null || _a === void 0 ? void 0 : _a.toObject();
65
65
  Object.entries(diographObject).forEach(([key, dioryObject]) => {
@@ -77,10 +77,10 @@ class DioryClient {
77
77
  }
78
78
  return this.diograph;
79
79
  };
80
- this.generateDiograph = async (connections) => {
81
- console.info('generateDiograph', connections);
80
+ this.generateDiograph = async () => {
81
+ console.info('generateDiograph');
82
82
  let diographObject;
83
- await Promise.all(this.getDiographClients(connections).map(async (connectionClient) => {
83
+ await Promise.all(this.getDiographClients().map(async (connectionClient) => {
84
84
  diographObject = await connectionClient.generateDiograph();
85
85
  console.info(diographObject);
86
86
  return;
@@ -101,10 +101,10 @@ class DioryClient {
101
101
  console.info(this.diosphere.toObject());
102
102
  return this.diosphere;
103
103
  };
104
- this.getDiosphere = async (connections) => {
105
- console.info('getDiosphere', connections);
104
+ this.getDiosphere = async () => {
105
+ console.info('getDiosphere');
106
106
  let diosphereObject;
107
- await Promise.all(this.getDiosphereClients(connections).map(async (connectionClient) => {
107
+ await Promise.all(this.getDiosphereClients().map(async (connectionClient) => {
108
108
  try {
109
109
  diosphereObject = await connectionClient.getDiosphere();
110
110
  console.info(diosphereObject);
@@ -116,10 +116,10 @@ class DioryClient {
116
116
  }));
117
117
  return diosphereObject;
118
118
  };
119
- this.saveDiosphere = async (connections) => {
120
- console.info('saveDiosphere', connections);
119
+ this.saveDiosphere = async () => {
120
+ console.info('saveDiosphere');
121
121
  const diosphereObject = this.diosphere.toObject();
122
- await Promise.all(this.getDiosphereClients(connections).map(async (connectionClient) => {
122
+ await Promise.all(this.getDiosphereClients().map(async (connectionClient) => {
123
123
  await connectionClient.saveDiosphere(diosphereObject);
124
124
  console.info(diosphereObject);
125
125
  return;
@@ -0,0 +1 @@
1
+ export {};
@@ -1,4 +1,5 @@
1
1
  "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
2
3
  describe('dioryClient', () => {
3
4
  describe('constructor()', () => {
4
5
  it('should construct with dataClient', () => {
package/dist/types.d.ts CHANGED
@@ -50,12 +50,12 @@ export interface IDioryClient {
50
50
  selectRoom: (roomObject: IRoomObject) => IRoom;
51
51
  diograph: IDiograph;
52
52
  initialiseDiograph: (roomObject: IRoomObject) => Promise<IDiograph>;
53
- getDiograph: (connections?: IConnectionObject[]) => Promise<IDiographObject | undefined>;
54
- saveDiograph: (connections?: IConnectionObject[]) => Promise<IDiographObject>;
55
- importDiograph: (connections?: IConnectionObject[]) => Promise<IDiograph>;
56
- generateDiograph: (connections?: IConnectionObject[]) => Promise<IDiographObject | undefined>;
53
+ getDiograph: () => Promise<IDiographObject | undefined>;
54
+ saveDiograph: () => Promise<IDiographObject>;
55
+ importDiograph: () => Promise<IDiograph>;
56
+ generateDiograph: () => Promise<IDiographObject | undefined>;
57
57
  diosphere: IDiosphere;
58
58
  initialiseDiosphere: (connections: IConnectionObject[]) => Promise<IDiosphere>;
59
- getDiosphere: (connections?: IConnectionObject[]) => Promise<IDiosphereObject | undefined>;
60
- saveDiosphere: (connections?: IConnectionObject[]) => Promise<IDiosphereObject>;
59
+ getDiosphere: () => Promise<IDiosphereObject | undefined>;
60
+ saveDiosphere: () => Promise<IDiosphereObject>;
61
61
  }
@@ -5,8 +5,10 @@ const connectionClient_1 = require("../connectionClient/connectionClient");
5
5
  function getDataClient(dataClients, { client }) {
6
6
  return dataClients.find(({ type }) => type === client);
7
7
  }
8
- function getConnectionClients(dataClients, connections) {
9
- return connections === null || connections === void 0 ? void 0 : connections.filter(({ client }) => dataClients.some(({ type }) => type === client)).map((connection) => {
8
+ function getConnectionClients(dataClients, connections = []) {
9
+ return connections
10
+ .filter(({ client }) => dataClients.some(({ type }) => type === client))
11
+ .map((connection) => {
10
12
  const dataClient = getDataClient(dataClients, connection);
11
13
  return new connectionClient_1.ConnectionClient(dataClient, connection);
12
14
  });
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@diory/client-js",
3
- "version": "0.2.0",
3
+ "version": "0.2.1-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>",
@@ -1,3 +1,5 @@
1
+ import { DioryClient } from './dioryClient'
2
+
1
3
  describe('dioryClient', () => {
2
4
  describe('constructor()', () => {
3
5
  it('should construct with dataClient', () => {
@@ -59,12 +59,12 @@ class DioryClient implements IDioryClient {
59
59
  return this.diograph
60
60
  }
61
61
 
62
- getDiograph = async (connections?: IConnectionObject[]): Promise<IDiographObject | undefined> => {
63
- console.info('getDiograph', connections)
62
+ getDiograph = async (): Promise<IDiographObject | undefined> => {
63
+ console.info('getDiograph')
64
64
 
65
65
  let diographObject
66
66
  await Promise.all(
67
- this.getDiographClients(connections).map(async (connectionClient) => {
67
+ this.getDiographClients().map(async (connectionClient) => {
68
68
  try {
69
69
  diographObject = await connectionClient.getDiograph()
70
70
  console.info(diographObject)
@@ -78,12 +78,12 @@ class DioryClient implements IDioryClient {
78
78
  return diographObject
79
79
  }
80
80
 
81
- saveDiograph = async (connections?: IConnectionObject[]): Promise<IDiographObject> => {
82
- console.info('saveDiograph', connections)
81
+ saveDiograph = async (): Promise<IDiographObject> => {
82
+ console.info('saveDiograph')
83
83
 
84
84
  const diographObject = this.diograph.toObject()
85
85
  await Promise.all(
86
- this.getDiographClients(connections).map(async (connectionClient) => {
86
+ this.getDiographClients().map(async (connectionClient) => {
87
87
  await connectionClient.saveDiograph(diographObject)
88
88
  console.info(diographObject)
89
89
  return
@@ -93,8 +93,8 @@ class DioryClient implements IDioryClient {
93
93
  return diographObject
94
94
  }
95
95
 
96
- importDiograph = async (connections?: IConnectionObject[]): Promise<IDiograph> => {
97
- const diographObject = await this.generateDiograph(connections)
96
+ importDiograph = async (): Promise<IDiograph> => {
97
+ const diographObject = await this.generateDiograph()
98
98
 
99
99
  if (diographObject) {
100
100
  const diory = this.diory?.toObject()
@@ -115,14 +115,12 @@ class DioryClient implements IDioryClient {
115
115
  return this.diograph
116
116
  }
117
117
 
118
- generateDiograph = async (
119
- connections?: IConnectionObject[],
120
- ): Promise<IDiographObject | undefined> => {
121
- console.info('generateDiograph', connections)
118
+ generateDiograph = async (): Promise<IDiographObject | undefined> => {
119
+ console.info('generateDiograph')
122
120
 
123
121
  let diographObject
124
122
  await Promise.all(
125
- this.getDiographClients(connections).map(async (connectionClient) => {
123
+ this.getDiographClients().map(async (connectionClient) => {
126
124
  diographObject = await connectionClient.generateDiograph()
127
125
  console.info(diographObject)
128
126
  return
@@ -150,14 +148,12 @@ class DioryClient implements IDioryClient {
150
148
  return this.diosphere
151
149
  }
152
150
 
153
- getDiosphere = async (
154
- connections?: IConnectionObject[],
155
- ): Promise<IDiosphereObject | undefined> => {
156
- console.info('getDiosphere', connections)
151
+ getDiosphere = async (): Promise<IDiosphereObject | undefined> => {
152
+ console.info('getDiosphere')
157
153
 
158
154
  let diosphereObject
159
155
  await Promise.all(
160
- this.getDiosphereClients(connections).map(async (connectionClient) => {
156
+ this.getDiosphereClients().map(async (connectionClient) => {
161
157
  try {
162
158
  diosphereObject = await connectionClient.getDiosphere()
163
159
  console.info(diosphereObject)
@@ -171,12 +167,12 @@ class DioryClient implements IDioryClient {
171
167
  return diosphereObject
172
168
  }
173
169
 
174
- saveDiosphere = async (connections?: IConnectionObject[]): Promise<IDiosphereObject> => {
175
- console.info('saveDiosphere', connections)
170
+ saveDiosphere = async (): Promise<IDiosphereObject> => {
171
+ console.info('saveDiosphere')
176
172
 
177
173
  const diosphereObject = this.diosphere.toObject()
178
174
  await Promise.all(
179
- this.getDiosphereClients(connections).map(async (connectionClient) => {
175
+ this.getDiosphereClients().map(async (connectionClient) => {
180
176
  await connectionClient.saveDiosphere(diosphereObject)
181
177
  console.info(diosphereObject)
182
178
  return
package/src/types.ts CHANGED
@@ -60,12 +60,12 @@ export interface IDioryClient {
60
60
  selectRoom: (roomObject: IRoomObject) => IRoom
61
61
  diograph: IDiograph
62
62
  initialiseDiograph: (roomObject: IRoomObject) => Promise<IDiograph>
63
- getDiograph: (connections?: IConnectionObject[]) => Promise<IDiographObject | undefined>
64
- saveDiograph: (connections?: IConnectionObject[]) => Promise<IDiographObject>
65
- importDiograph: (connections?: IConnectionObject[]) => Promise<IDiograph>
66
- generateDiograph: (connections?: IConnectionObject[]) => Promise<IDiographObject | undefined>
63
+ getDiograph: () => Promise<IDiographObject | undefined>
64
+ saveDiograph: () => Promise<IDiographObject>
65
+ importDiograph: () => Promise<IDiograph>
66
+ generateDiograph: () => Promise<IDiographObject | undefined>
67
67
  diosphere: IDiosphere
68
68
  initialiseDiosphere: (connections: IConnectionObject[]) => Promise<IDiosphere>
69
- getDiosphere: (connections?: IConnectionObject[]) => Promise<IDiosphereObject | undefined>
70
- saveDiosphere: (connections?: IConnectionObject[]) => Promise<IDiosphereObject>
69
+ getDiosphere: () => Promise<IDiosphereObject | undefined>
70
+ saveDiosphere: () => Promise<IDiosphereObject>
71
71
  }
@@ -12,10 +12,10 @@ function getDataClient(
12
12
 
13
13
  export function getConnectionClients(
14
14
  dataClients: IDataClient[],
15
- connections?: IConnectionObject[],
15
+ connections: IConnectionObject[] = [],
16
16
  ): IConnectionClient[] {
17
17
  return connections
18
- ?.filter(({ client }) => dataClients.some(({ type }) => type === client))
18
+ .filter(({ client }) => dataClients.some(({ type }) => type === client))
19
19
  .map((connection) => {
20
20
  const dataClient = getDataClient(dataClients, connection)
21
21
  return new ConnectionClient(dataClient!, connection)