@diory/client-js 0.4.4-rc3 → 0.4.4-rc5
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.js +9 -8
- package/dist/types.d.ts +1 -0
- package/package.json +2 -2
- package/src/dioryClient/dioryClient.ts +10 -8
- package/src/types.ts +1 -0
|
@@ -9,11 +9,12 @@ const resolveConnection = (address) => {
|
|
|
9
9
|
const addressArray = (address || '').split('/') || [];
|
|
10
10
|
return {
|
|
11
11
|
client: addressArray[0],
|
|
12
|
-
|
|
12
|
+
root: addressArray.slice(1, -2).join('/'),
|
|
13
|
+
path: addressArray[addressArray.length - 2],
|
|
13
14
|
id: addressArray[addressArray.length - 1],
|
|
14
15
|
};
|
|
15
16
|
};
|
|
16
|
-
const getDiographKey = (connection) => `${connection.client}/${connection.path}`;
|
|
17
|
+
const getDiographKey = (connection) => `${connection.client}/${connection.root}/${connection.path}`;
|
|
17
18
|
const findDataClient = (dataClients, client) => {
|
|
18
19
|
return dataClients.find(({ type }) => type === client);
|
|
19
20
|
};
|
|
@@ -33,33 +34,33 @@ class DioryClient {
|
|
|
33
34
|
return this.diographs[diographKey];
|
|
34
35
|
};
|
|
35
36
|
this.fetchDiograph = async (address) => {
|
|
36
|
-
const { client, path } = resolveConnection(address);
|
|
37
|
+
const { client, root, path } = resolveConnection(address);
|
|
37
38
|
const dataClient = findDataClient(this.dataClients, client);
|
|
38
39
|
if (dataClient) {
|
|
39
|
-
const diographString = await dataClient.readTextItem((0, path_browserify_1.join)(path, DIOGRAPH_JSON));
|
|
40
|
+
const diographString = await dataClient.readTextItem((0, path_browserify_1.join)(root, path, DIOGRAPH_JSON));
|
|
40
41
|
if (diographString)
|
|
41
42
|
this.addDiograph(address, JSON.parse(diographString));
|
|
42
43
|
}
|
|
43
44
|
return this;
|
|
44
45
|
};
|
|
45
46
|
this.generateDiograph = async (address, options) => {
|
|
46
|
-
const { client, path } = resolveConnection(address);
|
|
47
|
+
const { client, root, path } = resolveConnection(address);
|
|
47
48
|
const dataClient = findDataClient(this.dataClients, client);
|
|
48
49
|
if (dataClient) {
|
|
49
50
|
// TODO save based on client properties
|
|
50
|
-
const diographObject = await (0, folder_generator_1.generateDiograph)(
|
|
51
|
+
const diographObject = await (0, folder_generator_1.generateDiograph)(root, path, dataClient, options);
|
|
51
52
|
if (diographObject)
|
|
52
53
|
this.addDiograph(address, diographObject);
|
|
53
54
|
}
|
|
54
55
|
return this;
|
|
55
56
|
};
|
|
56
57
|
this.saveDiograph = (address) => (0, debounce_1.debounce)(async () => {
|
|
57
|
-
const { client, path } = resolveConnection(address);
|
|
58
|
+
const { client, root, path } = resolveConnection(address);
|
|
58
59
|
const dataClient = findDataClient(this.dataClients, client);
|
|
59
60
|
if (dataClient) {
|
|
60
61
|
const diograph = this.getDiograph(address);
|
|
61
62
|
if (diograph)
|
|
62
|
-
dataClient.writeItem((0, path_browserify_1.join)(path, DIOGRAPH_JSON), diograph.toJson());
|
|
63
|
+
dataClient.writeItem((0, path_browserify_1.join)(root, path, DIOGRAPH_JSON), diograph.toJson());
|
|
63
64
|
}
|
|
64
65
|
return;
|
|
65
66
|
}, 1000);
|
package/dist/types.d.ts
CHANGED
package/package.json
CHANGED
|
@@ -1,13 +1,13 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@diory/client-js",
|
|
3
|
-
"version": "0.4.4-
|
|
3
|
+
"version": "0.4.4-rc5",
|
|
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.4.3",
|
|
10
|
-
"@diograph/folder-generator": "0.4.4-
|
|
10
|
+
"@diograph/folder-generator": "0.4.4-rc4",
|
|
11
11
|
"path-browserify": "^1.0.1",
|
|
12
12
|
"uuid": "8.3.2"
|
|
13
13
|
},
|
|
@@ -11,12 +11,14 @@ const resolveConnection = (address: string): IConnectionObject => {
|
|
|
11
11
|
const addressArray = (address || '').split('/') || []
|
|
12
12
|
return {
|
|
13
13
|
client: addressArray[0],
|
|
14
|
-
|
|
14
|
+
root: addressArray.slice(1, -2).join('/'),
|
|
15
|
+
path: addressArray[addressArray.length - 2],
|
|
15
16
|
id: addressArray[addressArray.length - 1],
|
|
16
17
|
}
|
|
17
18
|
}
|
|
18
19
|
|
|
19
|
-
const getDiographKey = (connection: IConnectionObject) =>
|
|
20
|
+
const getDiographKey = (connection: IConnectionObject) =>
|
|
21
|
+
`${connection.client}/${connection.root}/${connection.path}`
|
|
20
22
|
|
|
21
23
|
const findDataClient = (dataClients: IDataClient[], client: string): IDataClient | undefined => {
|
|
22
24
|
return dataClients.find(({ type }) => type === client)
|
|
@@ -48,10 +50,10 @@ export class DioryClient implements IDioryClient {
|
|
|
48
50
|
}
|
|
49
51
|
|
|
50
52
|
fetchDiograph = async (address: string): Promise<IDioryClient> => {
|
|
51
|
-
const { client, path } = resolveConnection(address)
|
|
53
|
+
const { client, root, path } = resolveConnection(address)
|
|
52
54
|
const dataClient = findDataClient(this.dataClients, client)
|
|
53
55
|
if (dataClient) {
|
|
54
|
-
const diographString = await dataClient.readTextItem(join(path, DIOGRAPH_JSON))
|
|
56
|
+
const diographString = await dataClient.readTextItem(join(root, path, DIOGRAPH_JSON))
|
|
55
57
|
if (diographString) this.addDiograph(address, JSON.parse(diographString))
|
|
56
58
|
}
|
|
57
59
|
|
|
@@ -62,11 +64,11 @@ export class DioryClient implements IDioryClient {
|
|
|
62
64
|
address: string,
|
|
63
65
|
options?: GenerateDiographOptions,
|
|
64
66
|
): Promise<IDioryClient> => {
|
|
65
|
-
const { client, path } = resolveConnection(address)
|
|
67
|
+
const { client, root, path } = resolveConnection(address)
|
|
66
68
|
const dataClient = findDataClient(this.dataClients, client)
|
|
67
69
|
if (dataClient) {
|
|
68
70
|
// TODO save based on client properties
|
|
69
|
-
const diographObject = await generateDiograph(
|
|
71
|
+
const diographObject = await generateDiograph(root, path, dataClient, options)
|
|
70
72
|
if (diographObject) this.addDiograph(address, diographObject)
|
|
71
73
|
}
|
|
72
74
|
|
|
@@ -75,11 +77,11 @@ export class DioryClient implements IDioryClient {
|
|
|
75
77
|
|
|
76
78
|
saveDiograph = (address: string) =>
|
|
77
79
|
debounce(async () => {
|
|
78
|
-
const { client, path } = resolveConnection(address)
|
|
80
|
+
const { client, root, path } = resolveConnection(address)
|
|
79
81
|
const dataClient = findDataClient(this.dataClients, client)
|
|
80
82
|
if (dataClient) {
|
|
81
83
|
const diograph = this.getDiograph(address)
|
|
82
|
-
if (diograph) dataClient.writeItem(join(path, DIOGRAPH_JSON), diograph.toJson())
|
|
84
|
+
if (diograph) dataClient.writeItem(join(root, path, DIOGRAPH_JSON), diograph.toJson())
|
|
83
85
|
}
|
|
84
86
|
|
|
85
87
|
return
|