@diory/client-js 0.1.4 → 0.2.0-rc1
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/{connectionClient.d.ts → connectionClient/connectionClient.d.ts} +2 -1
- package/dist/{connectionClient.js → connectionClient/connectionClient.js} +5 -0
- package/dist/connectionClient/connectionClient.spec.js +18 -0
- package/dist/{dioryClient.d.ts → dioryClient/dioryClient.d.ts} +6 -5
- package/dist/{dioryClient.js → dioryClient/dioryClient.js} +30 -11
- package/dist/dioryClient/dioryClient.spec.d.ts +0 -0
- package/dist/{dioryClient.spec.js → dioryClient/dioryClient.spec.js} +5 -0
- package/dist/index.d.ts +3 -3
- package/dist/index.js +2 -2
- package/dist/types.d.ts +20 -5
- package/dist/utils/getConnectionClients.js +1 -1
- package/package.json +4 -3
- package/src/connectionClient/connectionClient.spec.ts +19 -0
- package/src/{connectionClient.ts → connectionClient/connectionClient.ts} +7 -1
- package/src/{dioryClient.spec.ts → dioryClient/dioryClient.spec.ts} +6 -0
- package/src/{dioryClient.ts → dioryClient/dioryClient.ts} +41 -16
- package/src/index.ts +3 -3
- package/src/types.ts +22 -5
- package/src/utils/getConnectionClients.ts +1 -1
- /package/dist/{dioryClient.spec.d.ts → connectionClient/connectionClient.spec.d.ts} +0 -0
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
import { IDiographObject } from '@diograph/diograph';
|
|
2
2
|
import { IConnectionObject, IDiosphereObject } from '@diory/diosphere-js';
|
|
3
|
-
import { IConnectionClient, IDataClient } from '
|
|
3
|
+
import { IConnectionClient, IDataClient } from '../types';
|
|
4
4
|
declare class ConnectionClient implements IConnectionClient {
|
|
5
5
|
type: string;
|
|
6
6
|
client: IDataClient;
|
|
@@ -10,5 +10,6 @@ declare class ConnectionClient implements IConnectionClient {
|
|
|
10
10
|
saveDiosphere: (diosphereObject: IDiosphereObject) => Promise<boolean>;
|
|
11
11
|
getDiograph: () => Promise<any>;
|
|
12
12
|
saveDiograph: (diographObject: IDiographObject) => Promise<boolean>;
|
|
13
|
+
generateDiograph: () => Promise<IDiographObject>;
|
|
13
14
|
}
|
|
14
15
|
export { ConnectionClient };
|
|
@@ -2,6 +2,7 @@
|
|
|
2
2
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
3
|
exports.ConnectionClient = void 0;
|
|
4
4
|
const path_browserify_1 = require("path-browserify");
|
|
5
|
+
const folder_generator_1 = require("@diograph/folder-generator");
|
|
5
6
|
const DIOSPHERE_JSON = 'diosphere.json';
|
|
6
7
|
const DIOGRAPH_JSON = 'diograph.json';
|
|
7
8
|
class ConnectionClient {
|
|
@@ -26,6 +27,10 @@ class ConnectionClient {
|
|
|
26
27
|
const diographString = JSON.stringify(diographObject, null, 2);
|
|
27
28
|
return this.client.writeItem(path, diographString);
|
|
28
29
|
};
|
|
30
|
+
this.generateDiograph = async () => {
|
|
31
|
+
const { diograph } = await (0, folder_generator_1.generateDiograph)(this.connection.address, this.client);
|
|
32
|
+
return diograph.toObject();
|
|
33
|
+
};
|
|
29
34
|
this.type = dataClient.type;
|
|
30
35
|
this.client = dataClient;
|
|
31
36
|
this.connection = connection;
|
|
@@ -0,0 +1,18 @@
|
|
|
1
|
+
"use strict";
|
|
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
|
+
});
|
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
import { IConnectionObject, IDiosphere, IRoom, IRoomObject } from '@diory/diosphere-js';
|
|
2
2
|
import { IDiograph, IDiory, IDioryObject } from '@diograph/diograph';
|
|
3
|
-
import {
|
|
3
|
+
import { IDioryClient, IDataClient } from '../types';
|
|
4
4
|
declare class DioryClient implements IDioryClient {
|
|
5
5
|
dataClients: IDataClient[];
|
|
6
6
|
connections: IConnectionObject[];
|
|
@@ -12,9 +12,10 @@ declare class DioryClient implements IDioryClient {
|
|
|
12
12
|
initialise: (connections: IConnectionObject[]) => Promise<IDioryClient>;
|
|
13
13
|
enterRoom: (roomObject: IRoomObject) => Promise<IRoom>;
|
|
14
14
|
focusDiory: (dioryObject: IDioryObject) => IDiory;
|
|
15
|
-
getDiosphere: () => Promise<
|
|
16
|
-
saveDiosphere: () => Promise<
|
|
17
|
-
getDiograph: () => Promise<
|
|
18
|
-
saveDiograph: () => Promise<
|
|
15
|
+
getDiosphere: () => Promise<IDiosphere>;
|
|
16
|
+
saveDiosphere: () => Promise<IDiosphere>;
|
|
17
|
+
getDiograph: () => Promise<IDiograph>;
|
|
18
|
+
saveDiograph: () => Promise<IDiograph>;
|
|
19
|
+
generateDiograph: () => Promise<IDiograph>;
|
|
19
20
|
}
|
|
20
21
|
export { DioryClient };
|
|
@@ -3,7 +3,7 @@ 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("
|
|
6
|
+
const getConnectionClients_1 = require("../utils/getConnectionClients");
|
|
7
7
|
class DioryClient {
|
|
8
8
|
constructor(dataClients) {
|
|
9
9
|
this.dataClients = [];
|
|
@@ -20,6 +20,7 @@ class DioryClient {
|
|
|
20
20
|
this.diograph.resetDiograph();
|
|
21
21
|
await this.getDiograph();
|
|
22
22
|
this.focusDiory({ id: '/' });
|
|
23
|
+
await this.generateDiograph();
|
|
23
24
|
return this.room;
|
|
24
25
|
};
|
|
25
26
|
this.focusDiory = (dioryObject) => {
|
|
@@ -32,21 +33,22 @@ class DioryClient {
|
|
|
32
33
|
await Promise.all(connectionClients.map(async (connectionClient) => {
|
|
33
34
|
const diosphereObject = await connectionClient.getDiosphere();
|
|
34
35
|
console.info(diosphereObject);
|
|
35
|
-
return this.diosphere.
|
|
36
|
+
return this.diosphere.addDiosphere(diosphereObject);
|
|
36
37
|
}));
|
|
37
38
|
}
|
|
38
|
-
return;
|
|
39
|
+
return this.diosphere;
|
|
39
40
|
};
|
|
40
41
|
this.saveDiosphere = async () => {
|
|
41
42
|
console.info('saveDiosphere', this.connections);
|
|
42
43
|
if (this.connections) {
|
|
43
44
|
const connectionClients = (0, getConnectionClients_1.getConnectionClients)(this.dataClients, this.connections);
|
|
44
|
-
await Promise.all(connectionClients.map((connectionClient) => {
|
|
45
|
+
await Promise.all(connectionClients.map(async (connectionClient) => {
|
|
45
46
|
console.info(this.diosphere.toObject());
|
|
46
|
-
|
|
47
|
+
await connectionClient.saveDiosphere(this.diosphere.toObject());
|
|
48
|
+
return;
|
|
47
49
|
}));
|
|
48
50
|
}
|
|
49
|
-
return;
|
|
51
|
+
return this.diosphere;
|
|
50
52
|
};
|
|
51
53
|
this.getDiograph = async () => {
|
|
52
54
|
var _a, _b;
|
|
@@ -56,22 +58,39 @@ class DioryClient {
|
|
|
56
58
|
await Promise.all(connectionClients.map(async (connectionClient) => {
|
|
57
59
|
const diographObject = await connectionClient.getDiograph();
|
|
58
60
|
console.info(diographObject);
|
|
59
|
-
|
|
61
|
+
this.diograph.addDiograph(diographObject);
|
|
62
|
+
return;
|
|
60
63
|
}));
|
|
61
64
|
}
|
|
62
|
-
return;
|
|
65
|
+
return this.diograph;
|
|
63
66
|
};
|
|
64
67
|
this.saveDiograph = async () => {
|
|
65
68
|
var _a, _b;
|
|
66
69
|
console.info('saveDiograph', (_a = this.room) === null || _a === void 0 ? void 0 : _a.connections);
|
|
67
70
|
if ((_b = this.room) === null || _b === void 0 ? void 0 : _b.connections) {
|
|
68
71
|
const connectionClients = (0, getConnectionClients_1.getConnectionClients)(this.dataClients, this.room.connections);
|
|
69
|
-
await Promise.all(connectionClients.map((connectionClient) => {
|
|
72
|
+
await Promise.all(connectionClients.map(async (connectionClient) => {
|
|
70
73
|
console.info(this.diograph.toObject());
|
|
71
|
-
|
|
74
|
+
await connectionClient.saveDiograph(this.diograph.toObject());
|
|
75
|
+
return;
|
|
76
|
+
}));
|
|
77
|
+
}
|
|
78
|
+
return this.diograph;
|
|
79
|
+
};
|
|
80
|
+
this.generateDiograph = async () => {
|
|
81
|
+
var _a, _b, _c;
|
|
82
|
+
console.info('generateDiograph', (_a = this.room) === null || _a === void 0 ? void 0 : _a.connections);
|
|
83
|
+
if ((_b = this.room) === null || _b === void 0 ? void 0 : _b.connections) {
|
|
84
|
+
const connectionClients = (0, getConnectionClients_1.getConnectionClients)(this.dataClients, (_c = this.room) === null || _c === void 0 ? void 0 : _c.connections);
|
|
85
|
+
await Promise.all(connectionClients.map(async (connectionClient) => {
|
|
86
|
+
const diographObject = await connectionClient.generateDiograph();
|
|
87
|
+
console.info(diographObject);
|
|
88
|
+
this.diograph.addDiograph(diographObject);
|
|
89
|
+
await connectionClient.saveDiograph(this.diograph.toObject());
|
|
90
|
+
return;
|
|
72
91
|
}));
|
|
73
92
|
}
|
|
74
|
-
return;
|
|
93
|
+
return this.diograph;
|
|
75
94
|
};
|
|
76
95
|
this.dataClients = dataClients;
|
|
77
96
|
this.diosphere = new diosphere_js_1.Diosphere();
|
|
File without changes
|
package/dist/index.d.ts
CHANGED
|
@@ -1,3 +1,3 @@
|
|
|
1
|
-
export { DioryClient } from './dioryClient';
|
|
2
|
-
export { ConnectionClient } from './connectionClient';
|
|
3
|
-
export { IDioryClient
|
|
1
|
+
export { DioryClient } from './dioryClient/dioryClient';
|
|
2
|
+
export { ConnectionClient } from './connectionClient/connectionClient';
|
|
3
|
+
export { IDioryClient } from './types';
|
package/dist/index.js
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
"use strict";
|
|
2
2
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
3
|
exports.ConnectionClient = exports.DioryClient = void 0;
|
|
4
|
-
var dioryClient_1 = require("./dioryClient");
|
|
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");
|
|
6
|
+
var connectionClient_1 = require("./connectionClient/connectionClient");
|
|
7
7
|
Object.defineProperty(exports, "ConnectionClient", { enumerable: true, get: function () { return connectionClient_1.ConnectionClient; } });
|
package/dist/types.d.ts
CHANGED
|
@@ -1,6 +1,15 @@
|
|
|
1
1
|
/// <reference types="node" />
|
|
2
2
|
import { IConnectionObject, IDiosphere, IDiosphereObject, IRoom, IRoomObject } from '@diory/diosphere-js';
|
|
3
|
-
import {
|
|
3
|
+
import { IDiograph, IDiographObject, IDiory, IDioryObject } from '@diograph/diograph';
|
|
4
|
+
export interface IMetadata {
|
|
5
|
+
name: string;
|
|
6
|
+
created?: string;
|
|
7
|
+
modified?: string;
|
|
8
|
+
}
|
|
9
|
+
export interface IFileType {
|
|
10
|
+
ext?: string;
|
|
11
|
+
mime?: string;
|
|
12
|
+
}
|
|
4
13
|
export interface IDataClient {
|
|
5
14
|
type: string;
|
|
6
15
|
readTextItem(url: string): Promise<string>;
|
|
@@ -12,6 +21,10 @@ export interface IDataClient {
|
|
|
12
21
|
deleteItem(url: string): Promise<boolean>;
|
|
13
22
|
deleteFolder(url: string): Promise<void>;
|
|
14
23
|
list(url: string): Promise<string[]>;
|
|
24
|
+
getFileNames(url: string): Promise<string[]>;
|
|
25
|
+
getFolderNames(url: string): Promise<string[]>;
|
|
26
|
+
getMetadata(url: string): IMetadata;
|
|
27
|
+
getFileType(url: string): Promise<IFileType>;
|
|
15
28
|
}
|
|
16
29
|
export interface IConnectionClient {
|
|
17
30
|
type: string;
|
|
@@ -21,6 +34,7 @@ export interface IConnectionClient {
|
|
|
21
34
|
saveDiosphere: (diosphereObject: IDiosphereObject) => void;
|
|
22
35
|
getDiograph: () => Promise<IDiographObject>;
|
|
23
36
|
saveDiograph: (diographObject: IDiographObject) => void;
|
|
37
|
+
generateDiograph: () => Promise<IDiographObject>;
|
|
24
38
|
}
|
|
25
39
|
export interface IDioryClient {
|
|
26
40
|
dataClients: IDataClient[];
|
|
@@ -32,8 +46,9 @@ export interface IDioryClient {
|
|
|
32
46
|
initialise: (connections: IConnectionObject[]) => Promise<IDioryClient>;
|
|
33
47
|
enterRoom: (roomObject: IRoomObject) => Promise<IRoom>;
|
|
34
48
|
focusDiory: (dioryObject: IDioryObject) => IDiory;
|
|
35
|
-
getDiosphere: () =>
|
|
36
|
-
saveDiosphere: () =>
|
|
37
|
-
getDiograph: () =>
|
|
38
|
-
saveDiograph: () =>
|
|
49
|
+
getDiosphere: () => Promise<IDiosphere>;
|
|
50
|
+
saveDiosphere: () => Promise<IDiosphere>;
|
|
51
|
+
getDiograph: () => Promise<IDiograph>;
|
|
52
|
+
saveDiograph: () => Promise<IDiograph>;
|
|
53
|
+
generateDiograph: () => Promise<IDiograph>;
|
|
39
54
|
}
|
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
"use strict";
|
|
2
2
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
3
|
exports.getConnectionClients = void 0;
|
|
4
|
-
const connectionClient_1 = require("../connectionClient");
|
|
4
|
+
const connectionClient_1 = require("../connectionClient/connectionClient");
|
|
5
5
|
function getDataClient(dataClients, { client }) {
|
|
6
6
|
return dataClients.find(({ type }) => type === client);
|
|
7
7
|
}
|
package/package.json
CHANGED
|
@@ -1,13 +1,14 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@diory/client-js",
|
|
3
|
-
"version": "0.
|
|
3
|
+
"version": "0.2.0-rc1",
|
|
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-
|
|
10
|
-
"@
|
|
9
|
+
"@diograph/diograph": "0.3.0-rc14",
|
|
10
|
+
"@diograph/folder-generator": "^0.3.0-rc1",
|
|
11
|
+
"@diory/diosphere-js": "0.2.6-rc2",
|
|
11
12
|
"path-browserify": "^1.0.1",
|
|
12
13
|
"uuid": "8.3.2"
|
|
13
14
|
},
|
|
@@ -0,0 +1,19 @@
|
|
|
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,8 +1,9 @@
|
|
|
1
1
|
import { join } from 'path-browserify'
|
|
2
|
+
import { generateDiograph } from '@diograph/folder-generator'
|
|
2
3
|
|
|
3
4
|
import { IDiographObject } from '@diograph/diograph'
|
|
4
5
|
import { IConnectionObject, IDiosphereObject } from '@diory/diosphere-js'
|
|
5
|
-
import { IConnectionClient, IDataClient } from '
|
|
6
|
+
import { IConnectionClient, IDataClient } from '../types'
|
|
6
7
|
|
|
7
8
|
const DIOSPHERE_JSON = 'diosphere.json'
|
|
8
9
|
const DIOGRAPH_JSON = 'diograph.json'
|
|
@@ -41,6 +42,11 @@ class ConnectionClient implements IConnectionClient {
|
|
|
41
42
|
const diographString = JSON.stringify(diographObject, null, 2)
|
|
42
43
|
return this.client.writeItem(path, diographString)
|
|
43
44
|
}
|
|
45
|
+
|
|
46
|
+
generateDiograph = async (): Promise<IDiographObject> => {
|
|
47
|
+
const { diograph } = await generateDiograph(this.connection.address, this.client)
|
|
48
|
+
return diograph.toObject()
|
|
49
|
+
}
|
|
44
50
|
}
|
|
45
51
|
|
|
46
52
|
export { ConnectionClient }
|
|
@@ -1,8 +1,8 @@
|
|
|
1
1
|
import { Diosphere, IConnectionObject, IDiosphere, IRoom, IRoomObject } from '@diory/diosphere-js'
|
|
2
2
|
import { Diograph, IDiograph, IDiory, IDioryObject } from '@diograph/diograph'
|
|
3
3
|
|
|
4
|
-
import {
|
|
5
|
-
import { getConnectionClients } from '
|
|
4
|
+
import { IDioryClient, IDataClient } from '../types'
|
|
5
|
+
import { getConnectionClients } from '../utils/getConnectionClients'
|
|
6
6
|
|
|
7
7
|
class DioryClient implements IDioryClient {
|
|
8
8
|
dataClients: IDataClient[] = []
|
|
@@ -39,6 +39,8 @@ class DioryClient implements IDioryClient {
|
|
|
39
39
|
await this.getDiograph()
|
|
40
40
|
this.focusDiory({ id: '/' })
|
|
41
41
|
|
|
42
|
+
await this.generateDiograph()
|
|
43
|
+
|
|
42
44
|
return this.room
|
|
43
45
|
}
|
|
44
46
|
|
|
@@ -46,7 +48,7 @@ class DioryClient implements IDioryClient {
|
|
|
46
48
|
return (this.diory = this.diograph.getDiory(dioryObject))
|
|
47
49
|
}
|
|
48
50
|
|
|
49
|
-
getDiosphere = async (): Promise<
|
|
51
|
+
getDiosphere = async (): Promise<IDiosphere> => {
|
|
50
52
|
console.info('getDiosphere', this.connections)
|
|
51
53
|
if (this.connections) {
|
|
52
54
|
const connectionClients = getConnectionClients(this.dataClients, this.connections)
|
|
@@ -55,31 +57,32 @@ class DioryClient implements IDioryClient {
|
|
|
55
57
|
connectionClients.map(async (connectionClient) => {
|
|
56
58
|
const diosphereObject = await connectionClient.getDiosphere()
|
|
57
59
|
console.info(diosphereObject)
|
|
58
|
-
return this.diosphere.
|
|
60
|
+
return this.diosphere.addDiosphere(diosphereObject)
|
|
59
61
|
}),
|
|
60
62
|
)
|
|
61
63
|
}
|
|
62
64
|
|
|
63
|
-
return
|
|
65
|
+
return this.diosphere
|
|
64
66
|
}
|
|
65
67
|
|
|
66
|
-
saveDiosphere = async (): Promise<
|
|
68
|
+
saveDiosphere = async (): Promise<IDiosphere> => {
|
|
67
69
|
console.info('saveDiosphere', this.connections)
|
|
68
70
|
if (this.connections) {
|
|
69
71
|
const connectionClients = getConnectionClients(this.dataClients, this.connections)
|
|
70
72
|
|
|
71
73
|
await Promise.all(
|
|
72
|
-
connectionClients.map((connectionClient) => {
|
|
74
|
+
connectionClients.map(async (connectionClient) => {
|
|
73
75
|
console.info(this.diosphere.toObject())
|
|
74
|
-
|
|
76
|
+
await connectionClient.saveDiosphere(this.diosphere.toObject())
|
|
77
|
+
return
|
|
75
78
|
}),
|
|
76
79
|
)
|
|
77
80
|
}
|
|
78
81
|
|
|
79
|
-
return
|
|
82
|
+
return this.diosphere
|
|
80
83
|
}
|
|
81
84
|
|
|
82
|
-
getDiograph = async (): Promise<
|
|
85
|
+
getDiograph = async (): Promise<IDiograph> => {
|
|
83
86
|
console.info('getDiograph', this.room?.connections)
|
|
84
87
|
if (this.room?.connections) {
|
|
85
88
|
const connectionClients = getConnectionClients(this.dataClients, this.room.connections)
|
|
@@ -88,28 +91,50 @@ class DioryClient implements IDioryClient {
|
|
|
88
91
|
connectionClients.map(async (connectionClient) => {
|
|
89
92
|
const diographObject = await connectionClient.getDiograph()
|
|
90
93
|
console.info(diographObject)
|
|
91
|
-
|
|
94
|
+
this.diograph.addDiograph(diographObject)
|
|
95
|
+
return
|
|
92
96
|
}),
|
|
93
97
|
)
|
|
94
98
|
}
|
|
95
99
|
|
|
96
|
-
return
|
|
100
|
+
return this.diograph
|
|
97
101
|
}
|
|
98
102
|
|
|
99
|
-
saveDiograph = async (): Promise<
|
|
103
|
+
saveDiograph = async (): Promise<IDiograph> => {
|
|
100
104
|
console.info('saveDiograph', this.room?.connections)
|
|
101
105
|
if (this.room?.connections) {
|
|
102
106
|
const connectionClients = getConnectionClients(this.dataClients, this.room.connections)
|
|
103
107
|
|
|
104
108
|
await Promise.all(
|
|
105
|
-
connectionClients.map((connectionClient) => {
|
|
109
|
+
connectionClients.map(async (connectionClient) => {
|
|
106
110
|
console.info(this.diograph.toObject())
|
|
107
|
-
|
|
111
|
+
await connectionClient.saveDiograph(this.diograph.toObject())
|
|
112
|
+
return
|
|
113
|
+
}),
|
|
114
|
+
)
|
|
115
|
+
}
|
|
116
|
+
|
|
117
|
+
return this.diograph
|
|
118
|
+
}
|
|
119
|
+
|
|
120
|
+
generateDiograph = async (): Promise<IDiograph> => {
|
|
121
|
+
console.info('generateDiograph', this.room?.connections)
|
|
122
|
+
if (this.room?.connections) {
|
|
123
|
+
const connectionClients = getConnectionClients(this.dataClients, this.room?.connections)
|
|
124
|
+
|
|
125
|
+
await Promise.all(
|
|
126
|
+
connectionClients.map(async (connectionClient) => {
|
|
127
|
+
const diographObject = await connectionClient.generateDiograph()
|
|
128
|
+
console.info(diographObject)
|
|
129
|
+
this.diograph.addDiograph(diographObject)
|
|
130
|
+
|
|
131
|
+
await connectionClient.saveDiograph(this.diograph.toObject())
|
|
132
|
+
return
|
|
108
133
|
}),
|
|
109
134
|
)
|
|
110
135
|
}
|
|
111
136
|
|
|
112
|
-
return
|
|
137
|
+
return this.diograph
|
|
113
138
|
}
|
|
114
139
|
}
|
|
115
140
|
|
package/src/index.ts
CHANGED
|
@@ -1,3 +1,3 @@
|
|
|
1
|
-
export { DioryClient } from './dioryClient'
|
|
2
|
-
export { ConnectionClient } from './connectionClient'
|
|
3
|
-
export { IDioryClient
|
|
1
|
+
export { DioryClient } from './dioryClient/dioryClient'
|
|
2
|
+
export { ConnectionClient } from './connectionClient/connectionClient'
|
|
3
|
+
export { IDioryClient } from './types'
|
package/src/types.ts
CHANGED
|
@@ -5,7 +5,18 @@ import {
|
|
|
5
5
|
IRoom,
|
|
6
6
|
IRoomObject,
|
|
7
7
|
} from '@diory/diosphere-js'
|
|
8
|
-
import {
|
|
8
|
+
import { IDiograph, IDiographObject, IDiory, IDioryObject } from '@diograph/diograph'
|
|
9
|
+
|
|
10
|
+
export interface IMetadata {
|
|
11
|
+
name: string
|
|
12
|
+
created?: string
|
|
13
|
+
modified?: string
|
|
14
|
+
}
|
|
15
|
+
|
|
16
|
+
export interface IFileType {
|
|
17
|
+
ext?: string
|
|
18
|
+
mime?: string
|
|
19
|
+
}
|
|
9
20
|
|
|
10
21
|
export interface IDataClient {
|
|
11
22
|
type: string
|
|
@@ -18,6 +29,10 @@ export interface IDataClient {
|
|
|
18
29
|
deleteItem(url: string): Promise<boolean>
|
|
19
30
|
deleteFolder(url: string): Promise<void>
|
|
20
31
|
list(url: string): Promise<string[]>
|
|
32
|
+
getFileNames(url: string): Promise<string[]>
|
|
33
|
+
getFolderNames(url: string): Promise<string[]>
|
|
34
|
+
getMetadata(url: string): IMetadata
|
|
35
|
+
getFileType(url: string): Promise<IFileType>
|
|
21
36
|
}
|
|
22
37
|
|
|
23
38
|
export interface IConnectionClient {
|
|
@@ -28,6 +43,7 @@ export interface IConnectionClient {
|
|
|
28
43
|
saveDiosphere: (diosphereObject: IDiosphereObject) => void
|
|
29
44
|
getDiograph: () => Promise<IDiographObject>
|
|
30
45
|
saveDiograph: (diographObject: IDiographObject) => void
|
|
46
|
+
generateDiograph: () => Promise<IDiographObject>
|
|
31
47
|
}
|
|
32
48
|
|
|
33
49
|
export interface IDioryClient {
|
|
@@ -40,8 +56,9 @@ export interface IDioryClient {
|
|
|
40
56
|
initialise: (connections: IConnectionObject[]) => Promise<IDioryClient>
|
|
41
57
|
enterRoom: (roomObject: IRoomObject) => Promise<IRoom>
|
|
42
58
|
focusDiory: (dioryObject: IDioryObject) => IDiory
|
|
43
|
-
getDiosphere: () =>
|
|
44
|
-
saveDiosphere: () =>
|
|
45
|
-
getDiograph: () =>
|
|
46
|
-
saveDiograph: () =>
|
|
59
|
+
getDiosphere: () => Promise<IDiosphere>
|
|
60
|
+
saveDiosphere: () => Promise<IDiosphere>
|
|
61
|
+
getDiograph: () => Promise<IDiograph>
|
|
62
|
+
saveDiograph: () => Promise<IDiograph>
|
|
63
|
+
generateDiograph: () => Promise<IDiograph>
|
|
47
64
|
}
|
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
import { IConnectionObject } from '@diory/diosphere-js'
|
|
2
2
|
|
|
3
|
+
import { ConnectionClient } from '../connectionClient/connectionClient'
|
|
3
4
|
import { IConnectionClient, IDataClient } from '../types'
|
|
4
|
-
import { ConnectionClient } from '../connectionClient'
|
|
5
5
|
|
|
6
6
|
function getDataClient(
|
|
7
7
|
dataClients: IDataClient[],
|
|
File without changes
|