@diory/client-js 0.1.5-rc1 → 0.2.0-rc10

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.
@@ -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 './types';
3
+ import { IConnectionClient, IDataClient } from '../types';
4
4
  declare class ConnectionClient implements IConnectionClient {
5
5
  type: string;
6
6
  client: IDataClient;
@@ -28,7 +28,7 @@ class ConnectionClient {
28
28
  return this.client.writeItem(path, diographString);
29
29
  };
30
30
  this.generateDiograph = async () => {
31
- const { diograph } = await (0, folder_generator_1.generateDiograph)(this.connection.address); // TODO: Client
31
+ const { diograph } = await (0, folder_generator_1.generateDiograph)(this.connection.address, this.client);
32
32
  return diograph.toObject();
33
33
  };
34
34
  this.type = dataClient.type;
@@ -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 { IDataClient, IDioryClient } from './types';
3
+ import { IDioryClient, IDataClient } from '../types';
4
4
  declare class DioryClient implements IDioryClient {
5
5
  dataClients: IDataClient[];
6
6
  connections: IConnectionObject[];
@@ -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("./utils/getConnectionClients");
6
+ const getConnectionClients_1 = require("../utils/getConnectionClients");
7
7
  class DioryClient {
8
8
  constructor(dataClients) {
9
9
  this.dataClients = [];
@@ -20,7 +20,6 @@ class DioryClient {
20
20
  this.diograph.resetDiograph();
21
21
  await this.getDiograph();
22
22
  this.focusDiory({ id: '/' });
23
- await this.generateDiograph();
24
23
  return this.room;
25
24
  };
26
25
  this.focusDiory = (dioryObject) => {
@@ -85,7 +84,11 @@ class DioryClient {
85
84
  await Promise.all(connectionClients.map(async (connectionClient) => {
86
85
  const diographObject = await connectionClient.generateDiograph();
87
86
  console.info(diographObject);
88
- this.diograph.addDiograph(diographObject);
87
+ Object.entries(diographObject).forEach(([key, dioryObject]) => {
88
+ key === '/'
89
+ ? this.diograph.addDioryLink({ id: '/' }, diographObject['/'])
90
+ : this.diograph.addDiory(dioryObject);
91
+ });
89
92
  await connectionClient.saveDiograph(this.diograph.toObject());
90
93
  return;
91
94
  }));
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, IConnectionClient, IDataClient } from './types';
1
+ export { DioryClient } from './dioryClient/dioryClient';
2
+ export { ConnectionClient } from './connectionClient/connectionClient';
3
+ export { IDioryClient, IConnectionClient, IDataClient, IFileType, IMetadata } 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,18 @@
1
1
  /// <reference types="node" />
2
2
  import { IConnectionObject, IDiosphere, IDiosphereObject, IRoom, IRoomObject } from '@diory/diosphere-js';
3
- import { IDiographObject, IDiograph, IDiory, IDioryObject } from '@diograph/diograph';
3
+ import { IDiograph, IDiographObject, IDiory, IDioryObject } from '@diograph/diograph';
4
+ export interface IMetadata {
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
+ }
4
16
  export interface IDataClient {
5
17
  type: string;
6
18
  readTextItem(url: string): Promise<string>;
@@ -12,6 +24,12 @@ export interface IDataClient {
12
24
  deleteItem(url: string): Promise<boolean>;
13
25
  deleteFolder(url: string): Promise<void>;
14
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>;
15
33
  }
16
34
  export interface IConnectionClient {
17
35
  type: string;
@@ -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,13 @@
1
1
  {
2
2
  "name": "@diory/client-js",
3
- "version": "0.1.5-rc1",
3
+ "version": "0.2.0-rc10",
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-rc14",
10
- "@diograph/folder-generator": "^0.2.0-rc1",
10
+ "@diograph/folder-generator": "^0.3.0-rc3",
11
11
  "@diory/diosphere-js": "0.2.6-rc2",
12
12
  "path-browserify": "^1.0.1",
13
13
  "uuid": "8.3.2"
@@ -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
+ })
@@ -3,7 +3,7 @@ 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 { IConnectionClient, IDataClient } from './types'
6
+ import { IConnectionClient, IDataClient } from '../types'
7
7
 
8
8
  const DIOSPHERE_JSON = 'diosphere.json'
9
9
  const DIOGRAPH_JSON = 'diograph.json'
@@ -44,7 +44,7 @@ class ConnectionClient implements IConnectionClient {
44
44
  }
45
45
 
46
46
  generateDiograph = async (): Promise<IDiographObject> => {
47
- const { diograph } = await generateDiograph(this.connection.address) // TODO: Client
47
+ const { diograph } = await generateDiograph(this.connection.address, this.client)
48
48
  return diograph.toObject()
49
49
  }
50
50
  }
@@ -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 { IDataClient, IDioryClient } from './types'
5
- import { getConnectionClients } from './utils/getConnectionClients'
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,8 +39,6 @@ class DioryClient implements IDioryClient {
39
39
  await this.getDiograph()
40
40
  this.focusDiory({ id: '/' })
41
41
 
42
- await this.generateDiograph()
43
-
44
42
  return this.room
45
43
  }
46
44
 
@@ -126,7 +124,11 @@ class DioryClient implements IDioryClient {
126
124
  connectionClients.map(async (connectionClient) => {
127
125
  const diographObject = await connectionClient.generateDiograph()
128
126
  console.info(diographObject)
129
- this.diograph.addDiograph(diographObject)
127
+ Object.entries(diographObject).forEach(([key, dioryObject]) => {
128
+ key === '/'
129
+ ? this.diograph.addDioryLink({ id: '/' }, diographObject['/'])
130
+ : this.diograph.addDiory(dioryObject)
131
+ })
130
132
 
131
133
  await connectionClient.saveDiograph(this.diograph.toObject())
132
134
  return
package/src/index.ts CHANGED
@@ -1,3 +1,3 @@
1
- export { DioryClient } from './dioryClient'
2
- export { ConnectionClient } from './connectionClient'
3
- export { IDioryClient, IConnectionClient, IDataClient } from './types'
1
+ export { DioryClient } from './dioryClient/dioryClient'
2
+ export { ConnectionClient } from './connectionClient/connectionClient'
3
+ export { IDioryClient, IConnectionClient, IDataClient, IFileType, IMetadata } from './types'
package/src/types.ts CHANGED
@@ -5,7 +5,21 @@ import {
5
5
  IRoom,
6
6
  IRoomObject,
7
7
  } from '@diory/diosphere-js'
8
- import { IDiographObject, IDiograph, IDiory, IDioryObject } from '@diograph/diograph'
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
+ }
9
23
 
10
24
  export interface IDataClient {
11
25
  type: string
@@ -18,6 +32,12 @@ export interface IDataClient {
18
32
  deleteItem(url: string): Promise<boolean>
19
33
  deleteFolder(url: string): Promise<void>
20
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>
21
41
  }
22
42
 
23
43
  export interface IConnectionClient {
@@ -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[],