@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.
- package/dist/dioryClient/dioryClient.d.ts +6 -6
- package/dist/dioryClient/dioryClient.js +17 -17
- package/dist/dioryClient/dioryClient.spec.d.ts +1 -0
- package/dist/dioryClient/dioryClient.spec.js +1 -0
- package/dist/types.d.ts +6 -6
- package/dist/utils/getConnectionClients.js +4 -2
- package/package.json +1 -1
- package/src/dioryClient/dioryClient.spec.ts +2 -0
- package/src/dioryClient/dioryClient.ts +17 -21
- package/src/types.ts +6 -6
- package/src/utils/getConnectionClients.ts +2 -2
|
@@ -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: (
|
|
17
|
-
saveDiograph: (
|
|
18
|
-
importDiograph: (
|
|
19
|
-
generateDiograph: (
|
|
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: (
|
|
23
|
-
saveDiosphere: (
|
|
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 (
|
|
36
|
-
console.info('getDiograph'
|
|
35
|
+
this.getDiograph = async () => {
|
|
36
|
+
console.info('getDiograph');
|
|
37
37
|
let diographObject;
|
|
38
|
-
await Promise.all(this.getDiographClients(
|
|
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 (
|
|
51
|
-
console.info('saveDiograph'
|
|
50
|
+
this.saveDiograph = async () => {
|
|
51
|
+
console.info('saveDiograph');
|
|
52
52
|
const diographObject = this.diograph.toObject();
|
|
53
|
-
await Promise.all(this.getDiographClients(
|
|
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 (
|
|
60
|
+
this.importDiograph = async () => {
|
|
61
61
|
var _a;
|
|
62
|
-
const diographObject = await this.generateDiograph(
|
|
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 (
|
|
81
|
-
console.info('generateDiograph'
|
|
80
|
+
this.generateDiograph = async () => {
|
|
81
|
+
console.info('generateDiograph');
|
|
82
82
|
let diographObject;
|
|
83
|
-
await Promise.all(this.getDiographClients(
|
|
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 (
|
|
105
|
-
console.info('getDiosphere'
|
|
104
|
+
this.getDiosphere = async () => {
|
|
105
|
+
console.info('getDiosphere');
|
|
106
106
|
let diosphereObject;
|
|
107
|
-
await Promise.all(this.getDiosphereClients(
|
|
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 (
|
|
120
|
-
console.info('saveDiosphere'
|
|
119
|
+
this.saveDiosphere = async () => {
|
|
120
|
+
console.info('saveDiosphere');
|
|
121
121
|
const diosphereObject = this.diosphere.toObject();
|
|
122
|
-
await Promise.all(this.getDiosphereClients(
|
|
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 {};
|
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: (
|
|
54
|
-
saveDiograph: (
|
|
55
|
-
importDiograph: (
|
|
56
|
-
generateDiograph: (
|
|
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: (
|
|
60
|
-
saveDiosphere: (
|
|
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
|
|
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
|
@@ -59,12 +59,12 @@ class DioryClient implements IDioryClient {
|
|
|
59
59
|
return this.diograph
|
|
60
60
|
}
|
|
61
61
|
|
|
62
|
-
getDiograph = async (
|
|
63
|
-
console.info('getDiograph'
|
|
62
|
+
getDiograph = async (): Promise<IDiographObject | undefined> => {
|
|
63
|
+
console.info('getDiograph')
|
|
64
64
|
|
|
65
65
|
let diographObject
|
|
66
66
|
await Promise.all(
|
|
67
|
-
this.getDiographClients(
|
|
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 (
|
|
82
|
-
console.info('saveDiograph'
|
|
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(
|
|
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 (
|
|
97
|
-
const diographObject = await this.generateDiograph(
|
|
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
|
-
|
|
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(
|
|
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
|
-
|
|
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(
|
|
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 (
|
|
175
|
-
console.info('saveDiosphere'
|
|
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(
|
|
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: (
|
|
64
|
-
saveDiograph: (
|
|
65
|
-
importDiograph: (
|
|
66
|
-
generateDiograph: (
|
|
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: (
|
|
70
|
-
saveDiosphere: (
|
|
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
|
|
15
|
+
connections: IConnectionObject[] = [],
|
|
16
16
|
): IConnectionClient[] {
|
|
17
17
|
return connections
|
|
18
|
-
|
|
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)
|