@diory/client-js 0.2.1 → 0.4.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/connectionClient.d.ts +2 -1
- package/dist/dioryClient/dioryClient.d.ts +4 -3
- package/dist/dioryClient/dioryClient.js +7 -9
- package/dist/index.d.ts +1 -1
- package/dist/types.d.ts +3 -33
- package/dist/utils/getConnectionClients.d.ts +2 -1
- package/package.json +3 -2
- package/src/connectionClient/connectionClient.ts +3 -1
- package/src/dioryClient/dioryClient.ts +11 -10
- package/src/index.ts +1 -1
- package/src/types.ts +3 -35
- package/src/utils/getConnectionClients.ts +2 -1
|
@@ -1,6 +1,7 @@
|
|
|
1
1
|
import { IDiographObject } from '@diograph/diograph';
|
|
2
2
|
import { IConnectionObject, IDiosphereObject } from '@diory/diosphere-js';
|
|
3
|
-
import {
|
|
3
|
+
import { IDataClient } from '@diograph/local-client';
|
|
4
|
+
import { IConnectionClient } from '../types';
|
|
4
5
|
declare class ConnectionClient implements IConnectionClient {
|
|
5
6
|
type: string;
|
|
6
7
|
client: IDataClient;
|
|
@@ -1,6 +1,7 @@
|
|
|
1
1
|
import { IConnectionObject, IDiosphere, IDiosphereObject, IRoom, IRoomObject } from '@diory/diosphere-js';
|
|
2
2
|
import { IDiograph, IDiographObject, IDiory, IDioryObject } from '@diograph/diograph';
|
|
3
|
-
import {
|
|
3
|
+
import { IDataClient } from '@diograph/local-client';
|
|
4
|
+
import { IDioryClient } from '../types';
|
|
4
5
|
declare class DioryClient implements IDioryClient {
|
|
5
6
|
dataClients: IDataClient[];
|
|
6
7
|
connections: IConnectionObject[];
|
|
@@ -15,8 +16,8 @@ declare class DioryClient implements IDioryClient {
|
|
|
15
16
|
initialiseDiograph: (roomObject: IRoomObject) => Promise<IDiograph>;
|
|
16
17
|
getDiograph: () => Promise<IDiographObject | undefined>;
|
|
17
18
|
saveDiograph: () => Promise<IDiographObject>;
|
|
18
|
-
importDiograph: () => Promise<IDiograph>;
|
|
19
|
-
generateDiograph: () => Promise<IDiographObject | undefined>;
|
|
19
|
+
importDiograph: (connections?: IConnectionObject[]) => Promise<IDiograph>;
|
|
20
|
+
generateDiograph: (connections?: IConnectionObject[]) => Promise<IDiographObject | undefined>;
|
|
20
21
|
getDiosphereClients: (connections?: IConnectionObject[]) => import("../types").IConnectionClient[];
|
|
21
22
|
initialiseDiosphere: (connections: IConnectionObject[]) => Promise<IDiosphere>;
|
|
22
23
|
getDiosphere: () => Promise<IDiosphereObject | undefined>;
|
|
@@ -23,13 +23,12 @@ class DioryClient {
|
|
|
23
23
|
};
|
|
24
24
|
this.initialiseDiograph = async (roomObject) => {
|
|
25
25
|
var _a;
|
|
26
|
-
console.info('initialiseDiograph', roomObject);
|
|
26
|
+
console.info('initialiseDiograph: room', roomObject);
|
|
27
27
|
this.selectRoom(roomObject);
|
|
28
28
|
this.diograph.resetDiograph();
|
|
29
29
|
const diographObject = (_a = (await this.getDiograph())) !== null && _a !== void 0 ? _a : (0, getDefaultDiograph_1.getDefaultDiograph)();
|
|
30
30
|
this.diograph.addDiograph(diographObject);
|
|
31
31
|
this.focusDiory({ id: '/' });
|
|
32
|
-
console.info(this.diograph.toObject());
|
|
33
32
|
return this.diograph;
|
|
34
33
|
};
|
|
35
34
|
this.getDiograph = async () => {
|
|
@@ -57,9 +56,9 @@ class DioryClient {
|
|
|
57
56
|
}));
|
|
58
57
|
return diographObject;
|
|
59
58
|
};
|
|
60
|
-
this.importDiograph = async () => {
|
|
59
|
+
this.importDiograph = async (connections) => {
|
|
61
60
|
var _a;
|
|
62
|
-
const diographObject = await this.generateDiograph();
|
|
61
|
+
const diographObject = await this.generateDiograph(connections);
|
|
63
62
|
if (diographObject) {
|
|
64
63
|
const diory = (_a = this.diory) === null || _a === void 0 ? void 0 : _a.toObject();
|
|
65
64
|
Object.entries(diographObject).forEach(([key, dioryObject]) => {
|
|
@@ -77,10 +76,10 @@ class DioryClient {
|
|
|
77
76
|
}
|
|
78
77
|
return this.diograph;
|
|
79
78
|
};
|
|
80
|
-
this.generateDiograph = async () => {
|
|
81
|
-
console.info('generateDiograph');
|
|
79
|
+
this.generateDiograph = async (connections) => {
|
|
80
|
+
console.info('generateDiograph', connections);
|
|
82
81
|
let diographObject;
|
|
83
|
-
await Promise.all(this.getDiographClients().map(async (connectionClient) => {
|
|
82
|
+
await Promise.all(this.getDiographClients(connections).map(async (connectionClient) => {
|
|
84
83
|
diographObject = await connectionClient.generateDiograph();
|
|
85
84
|
console.info(diographObject);
|
|
86
85
|
return;
|
|
@@ -92,13 +91,12 @@ class DioryClient {
|
|
|
92
91
|
};
|
|
93
92
|
this.initialiseDiosphere = async (connections) => {
|
|
94
93
|
var _a;
|
|
95
|
-
console.info('initialiseDiosphere', connections);
|
|
94
|
+
console.info('initialiseDiosphere: connections', connections);
|
|
96
95
|
this.connections = connections;
|
|
97
96
|
this.diosphere.resetRooms();
|
|
98
97
|
const diosphereObject = (_a = (await this.getDiosphere())) !== null && _a !== void 0 ? _a : (0, getDefaultDiosphere_1.getDefaultDiosphere)(connections);
|
|
99
98
|
this.diosphere.addDiosphere(diosphereObject);
|
|
100
99
|
this.selectRoom({ id: '/' });
|
|
101
|
-
console.info(this.diosphere.toObject());
|
|
102
100
|
return this.diosphere;
|
|
103
101
|
};
|
|
104
102
|
this.getDiosphere = async () => {
|
package/dist/index.d.ts
CHANGED
|
@@ -1,3 +1,3 @@
|
|
|
1
1
|
export { DioryClient } from './dioryClient/dioryClient';
|
|
2
2
|
export { ConnectionClient } from './connectionClient/connectionClient';
|
|
3
|
-
export { IDioryClient, IConnectionClient
|
|
3
|
+
export { IDioryClient, IConnectionClient } from './types';
|
package/dist/types.d.ts
CHANGED
|
@@ -1,36 +1,6 @@
|
|
|
1
|
-
/// <reference types="node" />
|
|
2
1
|
import { IConnectionObject, IDiosphere, IDiosphereObject, IRoom, IRoomObject } from '@diory/diosphere-js';
|
|
3
2
|
import { IDiograph, IDiographObject, IDiory, IDioryObject } from '@diograph/diograph';
|
|
4
|
-
|
|
5
|
-
name: string;
|
|
6
|
-
created?: string;
|
|
7
|
-
modified?: string;
|
|
8
|
-
duration?: string;
|
|
9
|
-
thumbnail?: string;
|
|
10
|
-
latlng?: string;
|
|
11
|
-
}
|
|
12
|
-
export interface IFileType {
|
|
13
|
-
ext?: string;
|
|
14
|
-
mime?: string;
|
|
15
|
-
}
|
|
16
|
-
export interface IDataClient {
|
|
17
|
-
type: string;
|
|
18
|
-
readTextItem(url: string): Promise<string>;
|
|
19
|
-
readItem(url: string): Promise<Buffer>;
|
|
20
|
-
readToStream(url: string): any;
|
|
21
|
-
exists(url: string): Promise<boolean>;
|
|
22
|
-
writeTextItem(url: string, fileContent: string): Promise<boolean>;
|
|
23
|
-
writeItem(url: string, fileContent: Buffer | string): Promise<boolean>;
|
|
24
|
-
deleteItem(url: string): Promise<boolean>;
|
|
25
|
-
deleteFolder(url: string): Promise<void>;
|
|
26
|
-
list(url: string): Promise<string[]>;
|
|
27
|
-
getFileNames(url: string): Promise<string[]>;
|
|
28
|
-
getFolderNames(url: string): Promise<string[]>;
|
|
29
|
-
getFileType(url: string): Promise<IFileType>;
|
|
30
|
-
getMetadata(url: string): IMetadata;
|
|
31
|
-
getThumbnail?(imageUrl: string): Promise<string | undefined>;
|
|
32
|
-
getVideoMetadata?(videoUrl: string): Promise<IMetadata>;
|
|
33
|
-
}
|
|
3
|
+
import { IDataClient } from '@diograph/local-client';
|
|
34
4
|
export interface IConnectionClient {
|
|
35
5
|
type: string;
|
|
36
6
|
client: IDataClient;
|
|
@@ -52,8 +22,8 @@ export interface IDioryClient {
|
|
|
52
22
|
initialiseDiograph: (roomObject: IRoomObject) => Promise<IDiograph>;
|
|
53
23
|
getDiograph: () => Promise<IDiographObject | undefined>;
|
|
54
24
|
saveDiograph: () => Promise<IDiographObject>;
|
|
55
|
-
importDiograph: () => Promise<IDiograph>;
|
|
56
|
-
generateDiograph: () => Promise<IDiographObject | undefined>;
|
|
25
|
+
importDiograph: (connections?: IConnectionObject[]) => Promise<IDiograph>;
|
|
26
|
+
generateDiograph: (connections?: IConnectionObject[]) => Promise<IDiographObject | undefined>;
|
|
57
27
|
diosphere: IDiosphere;
|
|
58
28
|
initialiseDiosphere: (connections: IConnectionObject[]) => Promise<IDiosphere>;
|
|
59
29
|
getDiosphere: () => Promise<IDiosphereObject | undefined>;
|
|
@@ -1,3 +1,4 @@
|
|
|
1
1
|
import { IConnectionObject } from '@diory/diosphere-js';
|
|
2
|
-
import {
|
|
2
|
+
import { IDataClient } from '@diograph/local-client';
|
|
3
|
+
import { IConnectionClient } from '../types';
|
|
3
4
|
export declare function getConnectionClients(dataClients: IDataClient[], connections?: IConnectionObject[]): IConnectionClient[];
|
package/package.json
CHANGED
|
@@ -1,13 +1,14 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@diory/client-js",
|
|
3
|
-
"version": "0.
|
|
3
|
+
"version": "0.4.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
9
|
"@diograph/diograph": "^0.3.0",
|
|
10
|
-
"@diograph/folder-generator": "^0.
|
|
10
|
+
"@diograph/folder-generator": "^0.4.0-rc1",
|
|
11
|
+
"@diograph/local-client": "^0.3.2",
|
|
11
12
|
"@diory/diosphere-js": "^0.2.6",
|
|
12
13
|
"path-browserify": "^1.0.1",
|
|
13
14
|
"uuid": "8.3.2"
|
|
@@ -3,7 +3,9 @@ import { generateDiograph } from '@diograph/folder-generator'
|
|
|
3
3
|
|
|
4
4
|
import { IDiographObject } from '@diograph/diograph'
|
|
5
5
|
import { IConnectionObject, IDiosphereObject } from '@diory/diosphere-js'
|
|
6
|
-
import {
|
|
6
|
+
import { IDataClient } from '@diograph/local-client'
|
|
7
|
+
|
|
8
|
+
import { IConnectionClient } from '../types'
|
|
7
9
|
|
|
8
10
|
const DIOSPHERE_JSON = 'diosphere.json'
|
|
9
11
|
const DIOGRAPH_JSON = 'diograph.json'
|
|
@@ -7,8 +7,9 @@ import {
|
|
|
7
7
|
IRoomObject,
|
|
8
8
|
} from '@diory/diosphere-js'
|
|
9
9
|
import { Diograph, IDiograph, IDiographObject, IDiory, IDioryObject } from '@diograph/diograph'
|
|
10
|
+
import { IDataClient } from '@diograph/local-client'
|
|
10
11
|
|
|
11
|
-
import { IDioryClient
|
|
12
|
+
import { IDioryClient } from '../types'
|
|
12
13
|
import { getConnectionClients } from '../utils/getConnectionClients'
|
|
13
14
|
import { debounce } from '../utils/debounce'
|
|
14
15
|
|
|
@@ -46,7 +47,7 @@ class DioryClient implements IDioryClient {
|
|
|
46
47
|
}
|
|
47
48
|
|
|
48
49
|
initialiseDiograph = async (roomObject: IRoomObject): Promise<IDiograph> => {
|
|
49
|
-
console.info('initialiseDiograph', roomObject)
|
|
50
|
+
console.info('initialiseDiograph: room', roomObject)
|
|
50
51
|
this.selectRoom(roomObject)
|
|
51
52
|
|
|
52
53
|
this.diograph.resetDiograph()
|
|
@@ -55,7 +56,6 @@ class DioryClient implements IDioryClient {
|
|
|
55
56
|
|
|
56
57
|
this.focusDiory({ id: '/' })
|
|
57
58
|
|
|
58
|
-
console.info(this.diograph.toObject())
|
|
59
59
|
return this.diograph
|
|
60
60
|
}
|
|
61
61
|
|
|
@@ -93,8 +93,8 @@ class DioryClient implements IDioryClient {
|
|
|
93
93
|
return diographObject
|
|
94
94
|
}
|
|
95
95
|
|
|
96
|
-
importDiograph = async (): Promise<IDiograph> => {
|
|
97
|
-
const diographObject = await this.generateDiograph()
|
|
96
|
+
importDiograph = async (connections?: IConnectionObject[]): Promise<IDiograph> => {
|
|
97
|
+
const diographObject = await this.generateDiograph(connections)
|
|
98
98
|
|
|
99
99
|
if (diographObject) {
|
|
100
100
|
const diory = this.diory?.toObject()
|
|
@@ -115,12 +115,14 @@ class DioryClient implements IDioryClient {
|
|
|
115
115
|
return this.diograph
|
|
116
116
|
}
|
|
117
117
|
|
|
118
|
-
generateDiograph = async (
|
|
119
|
-
|
|
118
|
+
generateDiograph = async (
|
|
119
|
+
connections?: IConnectionObject[],
|
|
120
|
+
): Promise<IDiographObject | undefined> => {
|
|
121
|
+
console.info('generateDiograph', connections)
|
|
120
122
|
|
|
121
123
|
let diographObject
|
|
122
124
|
await Promise.all(
|
|
123
|
-
this.getDiographClients().map(async (connectionClient) => {
|
|
125
|
+
this.getDiographClients(connections).map(async (connectionClient) => {
|
|
124
126
|
diographObject = await connectionClient.generateDiograph()
|
|
125
127
|
console.info(diographObject)
|
|
126
128
|
return
|
|
@@ -135,7 +137,7 @@ class DioryClient implements IDioryClient {
|
|
|
135
137
|
}
|
|
136
138
|
|
|
137
139
|
initialiseDiosphere = async (connections: IConnectionObject[]): Promise<IDiosphere> => {
|
|
138
|
-
console.info('initialiseDiosphere', connections)
|
|
140
|
+
console.info('initialiseDiosphere: connections', connections)
|
|
139
141
|
this.connections = connections
|
|
140
142
|
|
|
141
143
|
this.diosphere.resetRooms()
|
|
@@ -144,7 +146,6 @@ class DioryClient implements IDioryClient {
|
|
|
144
146
|
|
|
145
147
|
this.selectRoom({ id: '/' })
|
|
146
148
|
|
|
147
|
-
console.info(this.diosphere.toObject())
|
|
148
149
|
return this.diosphere
|
|
149
150
|
}
|
|
150
151
|
|
package/src/index.ts
CHANGED
|
@@ -1,3 +1,3 @@
|
|
|
1
1
|
export { DioryClient } from './dioryClient/dioryClient'
|
|
2
2
|
export { ConnectionClient } from './connectionClient/connectionClient'
|
|
3
|
-
export { IDioryClient, IConnectionClient
|
|
3
|
+
export { IDioryClient, IConnectionClient } from './types'
|
package/src/types.ts
CHANGED
|
@@ -6,39 +6,7 @@ import {
|
|
|
6
6
|
IRoomObject,
|
|
7
7
|
} from '@diory/diosphere-js'
|
|
8
8
|
import { IDiograph, IDiographObject, IDiory, IDioryObject } from '@diograph/diograph'
|
|
9
|
-
|
|
10
|
-
export interface IMetadata {
|
|
11
|
-
name: string
|
|
12
|
-
created?: string
|
|
13
|
-
modified?: string
|
|
14
|
-
duration?: string
|
|
15
|
-
thumbnail?: string
|
|
16
|
-
latlng?: string
|
|
17
|
-
}
|
|
18
|
-
|
|
19
|
-
export interface IFileType {
|
|
20
|
-
ext?: string
|
|
21
|
-
mime?: string
|
|
22
|
-
}
|
|
23
|
-
|
|
24
|
-
export interface IDataClient {
|
|
25
|
-
type: string
|
|
26
|
-
readTextItem(url: string): Promise<string>
|
|
27
|
-
readItem(url: string): Promise<Buffer>
|
|
28
|
-
readToStream(url: string): any
|
|
29
|
-
exists(url: string): Promise<boolean>
|
|
30
|
-
writeTextItem(url: string, fileContent: string): Promise<boolean>
|
|
31
|
-
writeItem(url: string, fileContent: Buffer | string): Promise<boolean>
|
|
32
|
-
deleteItem(url: string): Promise<boolean>
|
|
33
|
-
deleteFolder(url: string): Promise<void>
|
|
34
|
-
list(url: string): Promise<string[]>
|
|
35
|
-
getFileNames(url: string): Promise<string[]>
|
|
36
|
-
getFolderNames(url: string): Promise<string[]>
|
|
37
|
-
getFileType(url: string): Promise<IFileType>
|
|
38
|
-
getMetadata(url: string): IMetadata
|
|
39
|
-
getThumbnail?(imageUrl: string): Promise<string | undefined>
|
|
40
|
-
getVideoMetadata?(videoUrl: string): Promise<IMetadata>
|
|
41
|
-
}
|
|
9
|
+
import { IDataClient } from '@diograph/local-client'
|
|
42
10
|
|
|
43
11
|
export interface IConnectionClient {
|
|
44
12
|
type: string
|
|
@@ -62,8 +30,8 @@ export interface IDioryClient {
|
|
|
62
30
|
initialiseDiograph: (roomObject: IRoomObject) => Promise<IDiograph>
|
|
63
31
|
getDiograph: () => Promise<IDiographObject | undefined>
|
|
64
32
|
saveDiograph: () => Promise<IDiographObject>
|
|
65
|
-
importDiograph: () => Promise<IDiograph>
|
|
66
|
-
generateDiograph: () => Promise<IDiographObject | undefined>
|
|
33
|
+
importDiograph: (connections?: IConnectionObject[]) => Promise<IDiograph>
|
|
34
|
+
generateDiograph: (connections?: IConnectionObject[]) => Promise<IDiographObject | undefined>
|
|
67
35
|
diosphere: IDiosphere
|
|
68
36
|
initialiseDiosphere: (connections: IConnectionObject[]) => Promise<IDiosphere>
|
|
69
37
|
getDiosphere: () => Promise<IDiosphereObject | undefined>
|
|
@@ -1,7 +1,8 @@
|
|
|
1
1
|
import { IConnectionObject } from '@diory/diosphere-js'
|
|
2
|
+
import { IDataClient } from '@diograph/local-client'
|
|
2
3
|
|
|
3
4
|
import { ConnectionClient } from '../connectionClient/connectionClient'
|
|
4
|
-
import { IConnectionClient
|
|
5
|
+
import { IConnectionClient } from '../types'
|
|
5
6
|
|
|
6
7
|
function getDataClient(
|
|
7
8
|
dataClients: IDataClient[],
|