@diory/client-js 0.2.0-rc1 → 0.2.0-rc11
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 +7 -5
- package/dist/dioryClient/dioryClient.js +53 -59
- package/dist/index.d.ts +1 -1
- package/dist/types.d.ts +6 -1
- package/dist/utils/getConnectionClients.d.ts +1 -1
- package/dist/utils/getConnectionClients.js +1 -3
- package/package.json +4 -4
- package/src/dioryClient/dioryClient.ts +73 -72
- package/src/index.ts +1 -1
- package/src/types.ts +6 -1
- package/src/utils/getConnectionClients.ts +2 -2
|
@@ -12,10 +12,12 @@ 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
|
-
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
|
|
15
|
+
getDiosphereClients: (connections?: IConnectionObject[]) => import("../types").IConnectionClient[];
|
|
16
|
+
getDiographClients: (connections?: IConnectionObject[]) => import("../types").IConnectionClient[];
|
|
17
|
+
getDiosphere: (connections?: IConnectionObject[]) => Promise<IDiosphere>;
|
|
18
|
+
saveDiosphere: (connections?: IConnectionObject[]) => Promise<IDiosphere>;
|
|
19
|
+
getDiograph: (connections?: IConnectionObject[]) => Promise<IDiograph>;
|
|
20
|
+
saveDiograph: (connections?: IConnectionObject[]) => Promise<IDiograph>;
|
|
21
|
+
generateDiograph: (connections?: IConnectionObject[]) => Promise<IDiograph>;
|
|
20
22
|
}
|
|
21
23
|
export { DioryClient };
|
|
@@ -9,87 +9,81 @@ class DioryClient {
|
|
|
9
9
|
this.dataClients = [];
|
|
10
10
|
this.connections = [];
|
|
11
11
|
this.initialise = async (connections) => {
|
|
12
|
+
console.info('initialise', connections);
|
|
12
13
|
this.connections = connections;
|
|
13
14
|
this.diosphere.resetRooms();
|
|
14
|
-
await this.getDiosphere();
|
|
15
|
-
await this.enterRoom({ id: '/' });
|
|
16
15
|
return this;
|
|
17
16
|
};
|
|
18
17
|
this.enterRoom = async (roomObject) => {
|
|
18
|
+
console.info('enterRoom', roomObject);
|
|
19
19
|
this.room = this.diosphere.getRoom(roomObject);
|
|
20
20
|
this.diograph.resetDiograph();
|
|
21
21
|
await this.getDiograph();
|
|
22
22
|
this.focusDiory({ id: '/' });
|
|
23
|
-
|
|
23
|
+
console.info(this.room);
|
|
24
24
|
return this.room;
|
|
25
25
|
};
|
|
26
26
|
this.focusDiory = (dioryObject) => {
|
|
27
27
|
return (this.diory = this.diograph.getDiory(dioryObject));
|
|
28
28
|
};
|
|
29
|
-
this.
|
|
30
|
-
|
|
31
|
-
|
|
32
|
-
|
|
33
|
-
|
|
34
|
-
|
|
35
|
-
|
|
36
|
-
|
|
37
|
-
|
|
38
|
-
|
|
29
|
+
this.getDiosphereClients = (connections) => {
|
|
30
|
+
return (0, getConnectionClients_1.getConnectionClients)(this.dataClients, connections !== null && connections !== void 0 ? connections : this.connections);
|
|
31
|
+
};
|
|
32
|
+
this.getDiographClients = (connections) => {
|
|
33
|
+
var _a;
|
|
34
|
+
return (0, getConnectionClients_1.getConnectionClients)(this.dataClients, connections !== null && connections !== void 0 ? connections : (_a = this.room) === null || _a === void 0 ? void 0 : _a.connections);
|
|
35
|
+
};
|
|
36
|
+
this.getDiosphere = async (connections) => {
|
|
37
|
+
console.info('getDiosphere', connections);
|
|
38
|
+
await Promise.all(this.getDiosphereClients(connections).map(async (connectionClient) => {
|
|
39
|
+
const diosphereObject = await connectionClient.getDiosphere();
|
|
40
|
+
this.diosphere.addDiosphere(diosphereObject);
|
|
41
|
+
console.info(this.diosphere.toObject());
|
|
42
|
+
return;
|
|
43
|
+
}));
|
|
39
44
|
return this.diosphere;
|
|
40
45
|
};
|
|
41
|
-
this.saveDiosphere = async () => {
|
|
42
|
-
console.info('saveDiosphere',
|
|
43
|
-
|
|
44
|
-
|
|
45
|
-
|
|
46
|
-
|
|
47
|
-
|
|
48
|
-
return;
|
|
49
|
-
}));
|
|
50
|
-
}
|
|
46
|
+
this.saveDiosphere = async (connections) => {
|
|
47
|
+
console.info('saveDiosphere', connections);
|
|
48
|
+
await Promise.all(this.getDiosphereClients(connections).map(async (connectionClient) => {
|
|
49
|
+
await connectionClient.saveDiosphere(this.diosphere.toObject());
|
|
50
|
+
console.info(this.diosphere.toObject());
|
|
51
|
+
return;
|
|
52
|
+
}));
|
|
51
53
|
return this.diosphere;
|
|
52
54
|
};
|
|
53
|
-
this.getDiograph = async () => {
|
|
54
|
-
|
|
55
|
-
|
|
56
|
-
|
|
57
|
-
|
|
58
|
-
|
|
59
|
-
|
|
60
|
-
|
|
61
|
-
this.diograph.addDiograph(diographObject);
|
|
62
|
-
return;
|
|
63
|
-
}));
|
|
64
|
-
}
|
|
55
|
+
this.getDiograph = async (connections) => {
|
|
56
|
+
console.info('getDiograph', connections);
|
|
57
|
+
await Promise.all(this.getDiographClients(connections).map(async (connectionClient) => {
|
|
58
|
+
const diographObject = await connectionClient.getDiograph();
|
|
59
|
+
this.diograph.addDiograph(diographObject);
|
|
60
|
+
console.info(this.diograph.toObject());
|
|
61
|
+
return;
|
|
62
|
+
}));
|
|
65
63
|
return this.diograph;
|
|
66
64
|
};
|
|
67
|
-
this.saveDiograph = async () => {
|
|
68
|
-
|
|
69
|
-
|
|
70
|
-
|
|
71
|
-
|
|
72
|
-
|
|
73
|
-
|
|
74
|
-
await connectionClient.saveDiograph(this.diograph.toObject());
|
|
75
|
-
return;
|
|
76
|
-
}));
|
|
77
|
-
}
|
|
65
|
+
this.saveDiograph = async (connections) => {
|
|
66
|
+
console.info('saveDiograph', connections);
|
|
67
|
+
await Promise.all(this.getDiographClients(connections).map(async (connectionClient) => {
|
|
68
|
+
await connectionClient.saveDiograph(this.diograph.toObject());
|
|
69
|
+
console.info(this.diograph.toObject());
|
|
70
|
+
return;
|
|
71
|
+
}));
|
|
78
72
|
return this.diograph;
|
|
79
73
|
};
|
|
80
|
-
this.generateDiograph = async () => {
|
|
81
|
-
|
|
82
|
-
|
|
83
|
-
|
|
84
|
-
|
|
85
|
-
|
|
86
|
-
|
|
87
|
-
|
|
88
|
-
|
|
89
|
-
|
|
90
|
-
|
|
91
|
-
|
|
92
|
-
}
|
|
74
|
+
this.generateDiograph = async (connections) => {
|
|
75
|
+
console.info('generateDiograph', connections);
|
|
76
|
+
await Promise.all(this.getDiographClients(connections).map(async (connectionClient) => {
|
|
77
|
+
const diographObject = await connectionClient.generateDiograph();
|
|
78
|
+
Object.entries(diographObject).forEach(([key, dioryObject]) => {
|
|
79
|
+
key === '/'
|
|
80
|
+
? this.diograph.addDioryLink({ id: '/' }, diographObject['/'])
|
|
81
|
+
: this.diograph.addDiory(dioryObject);
|
|
82
|
+
});
|
|
83
|
+
await connectionClient.saveDiograph(this.diograph.toObject());
|
|
84
|
+
console.info(this.diograph.toObject());
|
|
85
|
+
return;
|
|
86
|
+
}));
|
|
93
87
|
return this.diograph;
|
|
94
88
|
};
|
|
95
89
|
this.dataClients = dataClients;
|
package/dist/index.d.ts
CHANGED
package/dist/types.d.ts
CHANGED
|
@@ -5,6 +5,9 @@ export interface IMetadata {
|
|
|
5
5
|
name: string;
|
|
6
6
|
created?: string;
|
|
7
7
|
modified?: string;
|
|
8
|
+
duration?: string;
|
|
9
|
+
thumbnail?: string;
|
|
10
|
+
latlng?: string;
|
|
8
11
|
}
|
|
9
12
|
export interface IFileType {
|
|
10
13
|
ext?: string;
|
|
@@ -23,8 +26,10 @@ export interface IDataClient {
|
|
|
23
26
|
list(url: string): Promise<string[]>;
|
|
24
27
|
getFileNames(url: string): Promise<string[]>;
|
|
25
28
|
getFolderNames(url: string): Promise<string[]>;
|
|
26
|
-
getMetadata(url: string): IMetadata;
|
|
27
29
|
getFileType(url: string): Promise<IFileType>;
|
|
30
|
+
getMetadata(url: string): IMetadata;
|
|
31
|
+
getThumbnail?(imageUrl: string): Promise<string | undefined>;
|
|
32
|
+
getVideoMetadata?(videoUrl: string): Promise<IMetadata>;
|
|
28
33
|
}
|
|
29
34
|
export interface IConnectionClient {
|
|
30
35
|
type: string;
|
|
@@ -1,3 +1,3 @@
|
|
|
1
1
|
import { IConnectionObject } from '@diory/diosphere-js';
|
|
2
2
|
import { IConnectionClient, IDataClient } from '../types';
|
|
3
|
-
export declare function getConnectionClients(dataClients: IDataClient[], connections
|
|
3
|
+
export declare function getConnectionClients(dataClients: IDataClient[], connections?: IConnectionObject[]): IConnectionClient[];
|
|
@@ -6,9 +6,7 @@ function getDataClient(dataClients, { client }) {
|
|
|
6
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) => {
|
|
9
|
+
return connections === null || connections === void 0 ? void 0 : connections.filter(({ client }) => dataClients.some(({ type }) => type === client)).map((connection) => {
|
|
12
10
|
const dataClient = getDataClient(dataClients, connection);
|
|
13
11
|
return new connectionClient_1.ConnectionClient(dataClient, connection);
|
|
14
12
|
});
|
package/package.json
CHANGED
|
@@ -1,14 +1,14 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@diory/client-js",
|
|
3
|
-
"version": "0.2.0-
|
|
3
|
+
"version": "0.2.0-rc11",
|
|
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
|
-
"@diograph/folder-generator": "^0.3.0-
|
|
11
|
-
"@diory/diosphere-js": "0.2.6-
|
|
9
|
+
"@diograph/diograph": "^0.3.0-rc15",
|
|
10
|
+
"@diograph/folder-generator": "^0.3.0-rc3",
|
|
11
|
+
"@diory/diosphere-js": "^0.2.6-rc3",
|
|
12
12
|
"path-browserify": "^1.0.1",
|
|
13
13
|
"uuid": "8.3.2"
|
|
14
14
|
},
|
|
@@ -23,23 +23,22 @@ class DioryClient implements IDioryClient {
|
|
|
23
23
|
}
|
|
24
24
|
|
|
25
25
|
initialise = async (connections: IConnectionObject[]): Promise<IDioryClient> => {
|
|
26
|
-
|
|
26
|
+
console.info('initialise', connections)
|
|
27
27
|
|
|
28
|
+
this.connections = connections
|
|
28
29
|
this.diosphere.resetRooms()
|
|
29
|
-
await this.getDiosphere()
|
|
30
|
-
await this.enterRoom({ id: '/' })
|
|
31
30
|
|
|
32
31
|
return this
|
|
33
32
|
}
|
|
34
33
|
|
|
35
34
|
enterRoom = async (roomObject: IRoomObject): Promise<IRoom> => {
|
|
36
|
-
|
|
35
|
+
console.info('enterRoom', roomObject)
|
|
37
36
|
|
|
37
|
+
this.room = this.diosphere.getRoom(roomObject)
|
|
38
38
|
this.diograph.resetDiograph()
|
|
39
39
|
await this.getDiograph()
|
|
40
40
|
this.focusDiory({ id: '/' })
|
|
41
|
-
|
|
42
|
-
await this.generateDiograph()
|
|
41
|
+
console.info(this.room)
|
|
43
42
|
|
|
44
43
|
return this.room
|
|
45
44
|
}
|
|
@@ -48,91 +47,93 @@ class DioryClient implements IDioryClient {
|
|
|
48
47
|
return (this.diory = this.diograph.getDiory(dioryObject))
|
|
49
48
|
}
|
|
50
49
|
|
|
51
|
-
|
|
52
|
-
|
|
53
|
-
|
|
54
|
-
|
|
50
|
+
getDiosphereClients = (connections?: IConnectionObject[]) => {
|
|
51
|
+
return getConnectionClients(this.dataClients, connections ?? this.connections)
|
|
52
|
+
}
|
|
53
|
+
|
|
54
|
+
getDiographClients = (connections?: IConnectionObject[]) => {
|
|
55
|
+
return getConnectionClients(this.dataClients, connections ?? this.room?.connections)
|
|
56
|
+
}
|
|
57
|
+
|
|
58
|
+
getDiosphere = async (connections?: IConnectionObject[]): Promise<IDiosphere> => {
|
|
59
|
+
console.info('getDiosphere', connections)
|
|
60
|
+
await Promise.all(
|
|
61
|
+
this.getDiosphereClients(connections).map(async (connectionClient) => {
|
|
62
|
+
const diosphereObject = await connectionClient.getDiosphere()
|
|
63
|
+
this.diosphere.addDiosphere(diosphereObject)
|
|
64
|
+
console.info(this.diosphere.toObject())
|
|
55
65
|
|
|
56
|
-
|
|
57
|
-
|
|
58
|
-
|
|
59
|
-
console.info(diosphereObject)
|
|
60
|
-
return this.diosphere.addDiosphere(diosphereObject)
|
|
61
|
-
}),
|
|
62
|
-
)
|
|
63
|
-
}
|
|
66
|
+
return
|
|
67
|
+
}),
|
|
68
|
+
)
|
|
64
69
|
|
|
65
70
|
return this.diosphere
|
|
66
71
|
}
|
|
67
72
|
|
|
68
|
-
saveDiosphere = async (): Promise<IDiosphere> => {
|
|
69
|
-
console.info('saveDiosphere',
|
|
70
|
-
|
|
71
|
-
|
|
73
|
+
saveDiosphere = async (connections?: IConnectionObject[]): Promise<IDiosphere> => {
|
|
74
|
+
console.info('saveDiosphere', connections)
|
|
75
|
+
|
|
76
|
+
await Promise.all(
|
|
77
|
+
this.getDiosphereClients(connections).map(async (connectionClient) => {
|
|
78
|
+
await connectionClient.saveDiosphere(this.diosphere.toObject())
|
|
79
|
+
console.info(this.diosphere.toObject())
|
|
72
80
|
|
|
73
|
-
|
|
74
|
-
|
|
75
|
-
|
|
76
|
-
await connectionClient.saveDiosphere(this.diosphere.toObject())
|
|
77
|
-
return
|
|
78
|
-
}),
|
|
79
|
-
)
|
|
80
|
-
}
|
|
81
|
+
return
|
|
82
|
+
}),
|
|
83
|
+
)
|
|
81
84
|
|
|
82
85
|
return this.diosphere
|
|
83
86
|
}
|
|
84
87
|
|
|
85
|
-
getDiograph = async (): Promise<IDiograph> => {
|
|
86
|
-
console.info('getDiograph',
|
|
87
|
-
|
|
88
|
-
|
|
89
|
-
|
|
90
|
-
|
|
91
|
-
|
|
92
|
-
|
|
93
|
-
|
|
94
|
-
|
|
95
|
-
|
|
96
|
-
|
|
97
|
-
)
|
|
98
|
-
}
|
|
88
|
+
getDiograph = async (connections?: IConnectionObject[]): Promise<IDiograph> => {
|
|
89
|
+
console.info('getDiograph', connections)
|
|
90
|
+
|
|
91
|
+
await Promise.all(
|
|
92
|
+
this.getDiographClients(connections).map(async (connectionClient) => {
|
|
93
|
+
const diographObject = await connectionClient.getDiograph()
|
|
94
|
+
this.diograph.addDiograph(diographObject)
|
|
95
|
+
console.info(this.diograph.toObject())
|
|
96
|
+
|
|
97
|
+
return
|
|
98
|
+
}),
|
|
99
|
+
)
|
|
99
100
|
|
|
100
101
|
return this.diograph
|
|
101
102
|
}
|
|
102
103
|
|
|
103
|
-
saveDiograph = async (): Promise<IDiograph> => {
|
|
104
|
-
console.info('saveDiograph',
|
|
105
|
-
if (this.room?.connections) {
|
|
106
|
-
const connectionClients = getConnectionClients(this.dataClients, this.room.connections)
|
|
104
|
+
saveDiograph = async (connections?: IConnectionObject[]): Promise<IDiograph> => {
|
|
105
|
+
console.info('saveDiograph', connections)
|
|
107
106
|
|
|
108
|
-
|
|
109
|
-
|
|
110
|
-
|
|
111
|
-
|
|
112
|
-
|
|
113
|
-
|
|
114
|
-
)
|
|
115
|
-
|
|
107
|
+
await Promise.all(
|
|
108
|
+
this.getDiographClients(connections).map(async (connectionClient) => {
|
|
109
|
+
await connectionClient.saveDiograph(this.diograph.toObject())
|
|
110
|
+
console.info(this.diograph.toObject())
|
|
111
|
+
|
|
112
|
+
return
|
|
113
|
+
}),
|
|
114
|
+
)
|
|
116
115
|
|
|
117
116
|
return this.diograph
|
|
118
117
|
}
|
|
119
118
|
|
|
120
|
-
generateDiograph = async (): Promise<IDiograph> => {
|
|
121
|
-
console.info('generateDiograph',
|
|
122
|
-
|
|
123
|
-
|
|
124
|
-
|
|
125
|
-
|
|
126
|
-
|
|
127
|
-
|
|
128
|
-
|
|
129
|
-
|
|
130
|
-
|
|
131
|
-
|
|
132
|
-
|
|
133
|
-
|
|
134
|
-
|
|
135
|
-
|
|
119
|
+
generateDiograph = async (connections?: IConnectionObject[]): Promise<IDiograph> => {
|
|
120
|
+
console.info('generateDiograph', connections)
|
|
121
|
+
|
|
122
|
+
await Promise.all(
|
|
123
|
+
this.getDiographClients(connections).map(async (connectionClient) => {
|
|
124
|
+
const diographObject = await connectionClient.generateDiograph()
|
|
125
|
+
Object.entries(diographObject).forEach(([key, dioryObject]) => {
|
|
126
|
+
key === '/'
|
|
127
|
+
? this.diograph.addDioryLink({ id: '/' }, diographObject['/'])
|
|
128
|
+
: this.diograph.addDiory(dioryObject)
|
|
129
|
+
})
|
|
130
|
+
|
|
131
|
+
await connectionClient.saveDiograph(this.diograph.toObject())
|
|
132
|
+
console.info(this.diograph.toObject())
|
|
133
|
+
|
|
134
|
+
return
|
|
135
|
+
}),
|
|
136
|
+
)
|
|
136
137
|
|
|
137
138
|
return this.diograph
|
|
138
139
|
}
|
package/src/index.ts
CHANGED
package/src/types.ts
CHANGED
|
@@ -11,6 +11,9 @@ export interface IMetadata {
|
|
|
11
11
|
name: string
|
|
12
12
|
created?: string
|
|
13
13
|
modified?: string
|
|
14
|
+
duration?: string
|
|
15
|
+
thumbnail?: string
|
|
16
|
+
latlng?: string
|
|
14
17
|
}
|
|
15
18
|
|
|
16
19
|
export interface IFileType {
|
|
@@ -31,8 +34,10 @@ export interface IDataClient {
|
|
|
31
34
|
list(url: string): Promise<string[]>
|
|
32
35
|
getFileNames(url: string): Promise<string[]>
|
|
33
36
|
getFolderNames(url: string): Promise<string[]>
|
|
34
|
-
getMetadata(url: string): IMetadata
|
|
35
37
|
getFileType(url: string): Promise<IFileType>
|
|
38
|
+
getMetadata(url: string): IMetadata
|
|
39
|
+
getThumbnail?(imageUrl: string): Promise<string | undefined>
|
|
40
|
+
getVideoMetadata?(videoUrl: string): Promise<IMetadata>
|
|
36
41
|
}
|
|
37
42
|
|
|
38
43
|
export interface IConnectionClient {
|
|
@@ -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)
|