@protontech/drive-sdk 0.3.2 → 0.4.1
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/interface/nodes.d.ts +4 -0
- package/dist/interface/nodes.js.map +1 -1
- package/dist/internal/apiService/errorCodes.d.ts +1 -0
- package/dist/internal/apiService/errors.d.ts +3 -0
- package/dist/internal/apiService/errors.js +7 -1
- package/dist/internal/apiService/errors.js.map +1 -1
- package/dist/internal/devices/interface.d.ts +1 -1
- package/dist/internal/devices/manager.js +1 -1
- package/dist/internal/devices/manager.js.map +1 -1
- package/dist/internal/devices/manager.test.js +3 -3
- package/dist/internal/devices/manager.test.js.map +1 -1
- package/dist/internal/events/apiService.js +1 -1
- package/dist/internal/events/apiService.js.map +1 -1
- package/dist/internal/events/coreEventManager.js +1 -1
- package/dist/internal/events/coreEventManager.js.map +1 -1
- package/dist/internal/events/coreEventManager.test.js +18 -24
- package/dist/internal/events/coreEventManager.test.js.map +1 -1
- package/dist/internal/events/index.d.ts +3 -4
- package/dist/internal/events/index.js +4 -4
- package/dist/internal/events/index.js.map +1 -1
- package/dist/internal/events/interface.d.ts +3 -0
- package/dist/internal/nodes/apiService.d.ts +12 -3
- package/dist/internal/nodes/apiService.js +54 -13
- package/dist/internal/nodes/apiService.js.map +1 -1
- package/dist/internal/nodes/apiService.test.js +35 -2
- package/dist/internal/nodes/apiService.test.js.map +1 -1
- package/dist/internal/nodes/cache.test.js +1 -0
- package/dist/internal/nodes/cache.test.js.map +1 -1
- package/dist/internal/nodes/cryptoService.d.ts +1 -1
- package/dist/internal/nodes/cryptoService.js +1 -1
- package/dist/internal/nodes/cryptoService.js.map +1 -1
- package/dist/internal/nodes/cryptoService.test.js +4 -4
- package/dist/internal/nodes/cryptoService.test.js.map +1 -1
- package/dist/internal/nodes/errors.d.ts +4 -0
- package/dist/internal/nodes/errors.js +9 -0
- package/dist/internal/nodes/errors.js.map +1 -0
- package/dist/internal/nodes/extendedAttributes.d.ts +2 -2
- package/dist/internal/nodes/extendedAttributes.js +15 -11
- package/dist/internal/nodes/extendedAttributes.js.map +1 -1
- package/dist/internal/nodes/extendedAttributes.test.js +19 -1
- package/dist/internal/nodes/extendedAttributes.test.js.map +1 -1
- package/dist/internal/nodes/index.test.js +2 -1
- package/dist/internal/nodes/index.test.js.map +1 -1
- package/dist/internal/nodes/interface.d.ts +5 -1
- package/dist/internal/nodes/nodesAccess.d.ts +3 -3
- package/dist/internal/nodes/nodesAccess.js +25 -15
- package/dist/internal/nodes/nodesAccess.js.map +1 -1
- package/dist/internal/nodes/nodesAccess.test.js +48 -8
- package/dist/internal/nodes/nodesAccess.test.js.map +1 -1
- package/dist/internal/nodes/nodesManagement.d.ts +2 -0
- package/dist/internal/nodes/nodesManagement.js +87 -9
- package/dist/internal/nodes/nodesManagement.js.map +1 -1
- package/dist/internal/nodes/nodesManagement.test.js +81 -5
- package/dist/internal/nodes/nodesManagement.test.js.map +1 -1
- package/dist/internal/photos/albums.d.ts +9 -7
- package/dist/internal/photos/albums.js +26 -13
- package/dist/internal/photos/albums.js.map +1 -1
- package/dist/internal/photos/apiService.d.ts +34 -3
- package/dist/internal/photos/apiService.js +96 -3
- package/dist/internal/photos/apiService.js.map +1 -1
- package/dist/internal/photos/index.d.ts +31 -4
- package/dist/internal/photos/index.js +57 -7
- package/dist/internal/photos/index.js.map +1 -1
- package/dist/internal/photos/interface.d.ts +25 -1
- package/dist/internal/photos/shares.d.ts +43 -0
- package/dist/internal/photos/shares.js +112 -0
- package/dist/internal/photos/shares.js.map +1 -0
- package/dist/internal/photos/timeline.d.ts +15 -0
- package/dist/internal/photos/timeline.js +22 -0
- package/dist/internal/photos/timeline.js.map +1 -0
- package/dist/internal/photos/upload.d.ts +59 -0
- package/dist/internal/photos/upload.js +104 -0
- package/dist/internal/photos/upload.js.map +1 -0
- package/dist/internal/shares/manager.d.ts +1 -1
- package/dist/internal/shares/manager.js +4 -4
- package/dist/internal/shares/manager.js.map +1 -1
- package/dist/internal/shares/manager.test.js +7 -7
- package/dist/internal/shares/manager.test.js.map +1 -1
- package/dist/internal/sharing/interface.d.ts +1 -1
- package/dist/internal/sharing/sharingAccess.js +1 -1
- package/dist/internal/sharing/sharingAccess.js.map +1 -1
- package/dist/internal/sharing/sharingAccess.test.js +1 -1
- package/dist/internal/sharing/sharingAccess.test.js.map +1 -1
- package/dist/internal/sharingPublic/apiService.js +2 -0
- package/dist/internal/sharingPublic/apiService.js.map +1 -1
- package/dist/internal/upload/apiService.d.ts +2 -2
- package/dist/internal/upload/apiService.js +1 -1
- package/dist/internal/upload/apiService.js.map +1 -1
- package/dist/internal/upload/cryptoService.d.ts +2 -2
- package/dist/internal/upload/cryptoService.js.map +1 -1
- package/dist/internal/upload/fileUploader.d.ts +1 -0
- package/dist/internal/upload/fileUploader.js +3 -0
- package/dist/internal/upload/fileUploader.js.map +1 -1
- package/dist/internal/upload/interface.d.ts +3 -0
- package/dist/internal/upload/manager.d.ts +12 -11
- package/dist/internal/upload/manager.js +8 -2
- package/dist/internal/upload/manager.js.map +1 -1
- package/dist/internal/upload/manager.test.js +8 -0
- package/dist/internal/upload/manager.test.js.map +1 -1
- package/dist/internal/upload/streamUploader.d.ts +34 -24
- package/dist/internal/upload/streamUploader.js +7 -4
- package/dist/internal/upload/streamUploader.js.map +1 -1
- package/dist/internal/upload/streamUploader.test.js +1 -1
- package/dist/internal/upload/streamUploader.test.js.map +1 -1
- package/dist/protonDriveClient.d.ts +20 -3
- package/dist/protonDriveClient.js +23 -4
- package/dist/protonDriveClient.js.map +1 -1
- package/dist/protonDrivePhotosClient.d.ts +102 -12
- package/dist/protonDrivePhotosClient.js +149 -29
- package/dist/protonDrivePhotosClient.js.map +1 -1
- package/dist/transformers.d.ts +1 -1
- package/dist/transformers.js +1 -0
- package/dist/transformers.js.map +1 -1
- package/package.json +1 -1
- package/src/interface/nodes.ts +4 -0
- package/src/internal/apiService/errorCodes.ts +1 -0
- package/src/internal/apiService/errors.ts +6 -0
- package/src/internal/devices/interface.ts +1 -1
- package/src/internal/devices/manager.test.ts +3 -3
- package/src/internal/devices/manager.ts +1 -1
- package/src/internal/events/apiService.ts +1 -1
- package/src/internal/events/coreEventManager.test.ts +21 -27
- package/src/internal/events/coreEventManager.ts +1 -1
- package/src/internal/events/index.ts +3 -4
- package/src/internal/events/interface.ts +4 -0
- package/src/internal/nodes/apiService.test.ts +58 -1
- package/src/internal/nodes/apiService.ts +104 -17
- package/src/internal/nodes/cache.test.ts +1 -0
- package/src/internal/nodes/cryptoService.test.ts +8 -8
- package/src/internal/nodes/cryptoService.ts +1 -1
- package/src/internal/nodes/errors.ts +5 -0
- package/src/internal/nodes/extendedAttributes.test.ts +23 -1
- package/src/internal/nodes/extendedAttributes.ts +26 -18
- package/src/internal/nodes/index.test.ts +2 -1
- package/src/internal/nodes/interface.ts +6 -1
- package/src/internal/nodes/nodesAccess.test.ts +68 -8
- package/src/internal/nodes/nodesAccess.ts +42 -15
- package/src/internal/nodes/nodesManagement.test.ts +100 -5
- package/src/internal/nodes/nodesManagement.ts +101 -13
- package/src/internal/photos/albums.ts +31 -12
- package/src/internal/photos/apiService.ts +159 -4
- package/src/internal/photos/index.ts +116 -9
- package/src/internal/photos/interface.ts +23 -1
- package/src/internal/photos/shares.ts +134 -0
- package/src/internal/photos/timeline.ts +24 -0
- package/src/internal/photos/upload.ts +209 -0
- package/src/internal/shares/manager.test.ts +7 -7
- package/src/internal/shares/manager.ts +4 -4
- package/src/internal/sharing/interface.ts +1 -1
- package/src/internal/sharing/sharingAccess.test.ts +1 -1
- package/src/internal/sharing/sharingAccess.ts +1 -1
- package/src/internal/sharingPublic/apiService.ts +2 -0
- package/src/internal/upload/apiService.ts +3 -3
- package/src/internal/upload/cryptoService.ts +2 -2
- package/src/internal/upload/fileUploader.ts +12 -0
- package/src/internal/upload/interface.ts +3 -0
- package/src/internal/upload/manager.test.ts +8 -0
- package/src/internal/upload/manager.ts +20 -10
- package/src/internal/upload/streamUploader.test.ts +17 -12
- package/src/internal/upload/streamUploader.ts +35 -27
- package/src/protonDriveClient.ts +33 -4
- package/src/protonDrivePhotosClient.ts +251 -32
- package/src/transformers.ts +2 -0
- package/dist/internal/photos/cache.d.ts +0 -6
- package/dist/internal/photos/cache.js +0 -15
- package/dist/internal/photos/cache.js.map +0 -1
- package/dist/internal/photos/photosTimeline.d.ts +0 -10
- package/dist/internal/photos/photosTimeline.js +0 -19
- package/dist/internal/photos/photosTimeline.js.map +0 -1
- package/src/internal/photos/cache.ts +0 -11
- package/src/internal/photos/photosTimeline.ts +0 -17
package/src/protonDriveClient.ts
CHANGED
|
@@ -27,6 +27,7 @@ import {
|
|
|
27
27
|
ThumbnailType,
|
|
28
28
|
ThumbnailResult,
|
|
29
29
|
SDKEvent,
|
|
30
|
+
NodeType,
|
|
30
31
|
} from './interface';
|
|
31
32
|
import {
|
|
32
33
|
getUid,
|
|
@@ -252,7 +253,7 @@ export class ProtonDriveClient {
|
|
|
252
253
|
}
|
|
253
254
|
|
|
254
255
|
/**
|
|
255
|
-
* Subscribes to
|
|
256
|
+
* Subscribes to the remote general data updates.
|
|
256
257
|
*
|
|
257
258
|
* Only one instance of the SDK should subscribe to updates.
|
|
258
259
|
*/
|
|
@@ -285,7 +286,7 @@ export class ProtonDriveClient {
|
|
|
285
286
|
*/
|
|
286
287
|
async getMyFilesRootFolder(): Promise<MaybeNode> {
|
|
287
288
|
this.logger.info('Getting my files root folder');
|
|
288
|
-
return convertInternalNodePromise(this.nodes.access.
|
|
289
|
+
return convertInternalNodePromise(this.nodes.access.getVolumeRootFolder());
|
|
289
290
|
}
|
|
290
291
|
|
|
291
292
|
/**
|
|
@@ -297,9 +298,14 @@ export class ProtonDriveClient {
|
|
|
297
298
|
* @param signal - Signal to abort the operation.
|
|
298
299
|
* @returns An async generator of the children of the given parent node.
|
|
299
300
|
*/
|
|
300
|
-
async *iterateFolderChildren(
|
|
301
|
+
async *iterateFolderChildren(
|
|
302
|
+
parentNodeUid: NodeOrUid,
|
|
303
|
+
filterOptions?: { type?: NodeType },
|
|
304
|
+
signal?: AbortSignal,
|
|
305
|
+
): AsyncGenerator<MaybeNode> {
|
|
301
306
|
this.logger.info(`Iterating children of ${getUid(parentNodeUid)}`);
|
|
302
|
-
|
|
307
|
+
const iterator = this.nodes.access.iterateFolderChildren(getUid(parentNodeUid), filterOptions, signal);
|
|
308
|
+
yield* convertInternalNodeIterator(iterator);
|
|
303
309
|
}
|
|
304
310
|
|
|
305
311
|
/**
|
|
@@ -384,6 +390,29 @@ export class ProtonDriveClient {
|
|
|
384
390
|
yield* this.nodes.management.moveNodes(getUids(nodeUids), getUid(newParentNodeUid), signal);
|
|
385
391
|
}
|
|
386
392
|
|
|
393
|
+
/**
|
|
394
|
+
* Copy the nodes to a new parent node.
|
|
395
|
+
*
|
|
396
|
+
* The operation is performed node by node and the results are yielded
|
|
397
|
+
* as they are available. Order of the results is not guaranteed.
|
|
398
|
+
*
|
|
399
|
+
* If one of the nodes fails to copy, the operation continues with the
|
|
400
|
+
* rest of the nodes. Use `NodeResult` to check the status of the action.
|
|
401
|
+
*
|
|
402
|
+
* @param nodeUids - List of node entities or their UIDs.
|
|
403
|
+
* @param newParentNodeUid - Node entity or its UID string.
|
|
404
|
+
* @param signal - Signal to abort the operation.
|
|
405
|
+
* @returns An async generator of the results of the copy operation
|
|
406
|
+
*/
|
|
407
|
+
async *copyNodes(
|
|
408
|
+
nodeUids: NodeOrUid[],
|
|
409
|
+
newParentNodeUid: NodeOrUid,
|
|
410
|
+
signal?: AbortSignal,
|
|
411
|
+
): AsyncGenerator<NodeResult> {
|
|
412
|
+
this.logger.info(`Copying ${nodeUids.length} nodes to ${getUid(newParentNodeUid)}`);
|
|
413
|
+
yield* this.nodes.management.copyNodes(getUids(nodeUids), getUid(newParentNodeUid), signal);
|
|
414
|
+
}
|
|
415
|
+
|
|
387
416
|
/**
|
|
388
417
|
* Trash the nodes.
|
|
389
418
|
*
|
|
@@ -1,19 +1,63 @@
|
|
|
1
|
-
import {
|
|
2
|
-
|
|
1
|
+
import {
|
|
2
|
+
Logger,
|
|
3
|
+
ProtonDriveClientContructorParameters,
|
|
4
|
+
NodeOrUid,
|
|
5
|
+
MaybeMissingNode,
|
|
6
|
+
UploadMetadata,
|
|
7
|
+
FileDownloader,
|
|
8
|
+
FileUploader,
|
|
9
|
+
SDKEvent,
|
|
10
|
+
MaybeNode,
|
|
11
|
+
ThumbnailType,
|
|
12
|
+
ThumbnailResult,
|
|
13
|
+
} from './interface';
|
|
14
|
+
import { getConfig } from './config';
|
|
3
15
|
import { DriveCrypto } from './crypto';
|
|
4
|
-
import {
|
|
16
|
+
import { Telemetry } from './telemetry';
|
|
17
|
+
import {
|
|
18
|
+
convertInternalMissingNodeIterator,
|
|
19
|
+
convertInternalNodeIterator,
|
|
20
|
+
convertInternalNodePromise,
|
|
21
|
+
getUid,
|
|
22
|
+
getUids,
|
|
23
|
+
} from './transformers';
|
|
24
|
+
import { DriveAPIService } from './internal/apiService';
|
|
25
|
+
import { initDownloadModule } from './internal/download';
|
|
26
|
+
import { DriveEventsService, DriveListener, EventSubscription } from './internal/events';
|
|
5
27
|
import { initNodesModule } from './internal/nodes';
|
|
6
|
-
import { initPhotosModule } from './internal/photos';
|
|
7
|
-
import { DriveEventsService } from './internal/events';
|
|
28
|
+
import { initPhotosModule, initPhotoSharesModule, initPhotoUploadModule } from './internal/photos';
|
|
8
29
|
import { SDKEvents } from './internal/sdkEvents';
|
|
9
|
-
import {
|
|
10
|
-
import {
|
|
30
|
+
import { initSharesModule } from './internal/shares';
|
|
31
|
+
import { initSharingModule } from './internal/sharing';
|
|
11
32
|
|
|
12
|
-
|
|
33
|
+
/**
|
|
34
|
+
* ProtonDrivePhotosClient is the interface to access Photos functionality.
|
|
35
|
+
*
|
|
36
|
+
* The client provides high-level operations for managing photos, albums, sharing,
|
|
37
|
+
* and downloading/uploading photos.
|
|
38
|
+
*
|
|
39
|
+
* @deprecated This is an experimental feature that might change without a warning.
|
|
40
|
+
*/
|
|
13
41
|
export class ProtonDrivePhotosClient {
|
|
42
|
+
private logger: Logger;
|
|
43
|
+
private sdkEvents: SDKEvents;
|
|
44
|
+
private events: DriveEventsService;
|
|
45
|
+
private photoShares: ReturnType<typeof initPhotoSharesModule>;
|
|
14
46
|
private nodes: ReturnType<typeof initNodesModule>;
|
|
47
|
+
private sharing: ReturnType<typeof initSharingModule>;
|
|
48
|
+
private download: ReturnType<typeof initDownloadModule>;
|
|
49
|
+
private upload: ReturnType<typeof initPhotoUploadModule>;
|
|
15
50
|
private photos: ReturnType<typeof initPhotosModule>;
|
|
16
51
|
|
|
52
|
+
public experimental: {
|
|
53
|
+
/**
|
|
54
|
+
* Experimental feature to return the URL of the node.
|
|
55
|
+
*
|
|
56
|
+
* See `ProtonDriveClient.experimental.getNodeUrl` for more information.
|
|
57
|
+
*/
|
|
58
|
+
getNodeUrl: (nodeUid: NodeOrUid) => Promise<string>;
|
|
59
|
+
};
|
|
60
|
+
|
|
17
61
|
constructor({
|
|
18
62
|
httpClient,
|
|
19
63
|
entitiesCache,
|
|
@@ -23,41 +67,216 @@ export class ProtonDrivePhotosClient {
|
|
|
23
67
|
srpModule,
|
|
24
68
|
config,
|
|
25
69
|
telemetry,
|
|
70
|
+
latestEventIdProvider,
|
|
26
71
|
}: ProtonDriveClientContructorParameters) {
|
|
27
72
|
if (!telemetry) {
|
|
28
73
|
telemetry = new Telemetry();
|
|
29
74
|
}
|
|
75
|
+
this.logger = telemetry.getLogger('interface');
|
|
30
76
|
|
|
31
77
|
const fullConfig = getConfig(config);
|
|
32
|
-
|
|
78
|
+
this.sdkEvents = new SDKEvents(telemetry);
|
|
33
79
|
const cryptoModule = new DriveCrypto(openPGPCryptoModule, srpModule);
|
|
34
80
|
const apiService = new DriveAPIService(
|
|
35
81
|
telemetry,
|
|
36
|
-
sdkEvents,
|
|
82
|
+
this.sdkEvents,
|
|
37
83
|
httpClient,
|
|
38
84
|
fullConfig.baseUrl,
|
|
39
85
|
fullConfig.language,
|
|
40
86
|
);
|
|
41
|
-
const
|
|
42
|
-
this.
|
|
43
|
-
|
|
44
|
-
|
|
45
|
-
|
|
46
|
-
|
|
47
|
-
|
|
48
|
-
|
|
49
|
-
|
|
50
|
-
|
|
51
|
-
|
|
52
|
-
|
|
53
|
-
|
|
54
|
-
|
|
55
|
-
|
|
56
|
-
|
|
57
|
-
|
|
58
|
-
|
|
59
|
-
|
|
60
|
-
|
|
61
|
-
|
|
62
|
-
|
|
87
|
+
const coreShares = initSharesModule(telemetry, apiService, entitiesCache, cryptoCache, account, cryptoModule);
|
|
88
|
+
this.photoShares = initPhotoSharesModule(
|
|
89
|
+
telemetry,
|
|
90
|
+
apiService,
|
|
91
|
+
entitiesCache,
|
|
92
|
+
cryptoCache,
|
|
93
|
+
account,
|
|
94
|
+
cryptoModule,
|
|
95
|
+
coreShares,
|
|
96
|
+
);
|
|
97
|
+
this.nodes = initNodesModule(
|
|
98
|
+
telemetry,
|
|
99
|
+
apiService,
|
|
100
|
+
entitiesCache,
|
|
101
|
+
cryptoCache,
|
|
102
|
+
account,
|
|
103
|
+
cryptoModule,
|
|
104
|
+
this.photoShares,
|
|
105
|
+
);
|
|
106
|
+
this.photos = initPhotosModule(apiService, this.photoShares, this.nodes.access);
|
|
107
|
+
this.sharing = initSharingModule(
|
|
108
|
+
telemetry,
|
|
109
|
+
apiService,
|
|
110
|
+
entitiesCache,
|
|
111
|
+
account,
|
|
112
|
+
cryptoModule,
|
|
113
|
+
this.photoShares,
|
|
114
|
+
this.nodes.access,
|
|
115
|
+
);
|
|
116
|
+
this.download = initDownloadModule(
|
|
117
|
+
telemetry,
|
|
118
|
+
apiService,
|
|
119
|
+
cryptoModule,
|
|
120
|
+
account,
|
|
121
|
+
this.photoShares,
|
|
122
|
+
this.nodes.access,
|
|
123
|
+
this.nodes.revisions,
|
|
124
|
+
);
|
|
125
|
+
this.upload = initPhotoUploadModule(
|
|
126
|
+
telemetry,
|
|
127
|
+
apiService,
|
|
128
|
+
cryptoModule,
|
|
129
|
+
this.photoShares,
|
|
130
|
+
this.nodes.access,
|
|
131
|
+
fullConfig.clientUid,
|
|
132
|
+
);
|
|
133
|
+
|
|
134
|
+
// These are used to keep the internal cache up to date
|
|
135
|
+
const cacheEventListeners: DriveListener[] = [
|
|
136
|
+
this.nodes.eventHandler.updateNodesCacheOnEvent.bind(this.nodes.eventHandler),
|
|
137
|
+
this.sharing.eventHandler.handleDriveEvent.bind(this.sharing.eventHandler),
|
|
138
|
+
];
|
|
139
|
+
this.events = new DriveEventsService(
|
|
140
|
+
telemetry,
|
|
141
|
+
apiService,
|
|
142
|
+
this.photoShares,
|
|
143
|
+
cacheEventListeners,
|
|
144
|
+
latestEventIdProvider,
|
|
145
|
+
);
|
|
146
|
+
|
|
147
|
+
this.experimental = {
|
|
148
|
+
getNodeUrl: async (nodeUid: NodeOrUid) => {
|
|
149
|
+
this.logger.debug(`Getting node URL for ${getUid(nodeUid)}`);
|
|
150
|
+
return this.nodes.access.getNodeUrl(getUid(nodeUid));
|
|
151
|
+
},
|
|
152
|
+
};
|
|
153
|
+
}
|
|
154
|
+
|
|
155
|
+
/**
|
|
156
|
+
* Subscribes to the general SDK events.
|
|
157
|
+
*
|
|
158
|
+
* See `ProtonDriveClient.onMessage` for more information.
|
|
159
|
+
*/
|
|
160
|
+
onMessage(eventName: SDKEvent, callback: () => void): () => void {
|
|
161
|
+
this.logger.debug(`Subscribing to event ${eventName}`);
|
|
162
|
+
return this.sdkEvents.addListener(eventName, callback);
|
|
163
|
+
}
|
|
164
|
+
|
|
165
|
+
/**
|
|
166
|
+
* Subscribes to the remote data updates for all files in a tree.
|
|
167
|
+
*
|
|
168
|
+
* See `ProtonDriveClient.subscribeToTreeEvents` for more information.
|
|
169
|
+
*/
|
|
170
|
+
async subscribeToTreeEvents(treeEventScopeId: string, callback: DriveListener): Promise<EventSubscription> {
|
|
171
|
+
this.logger.debug('Subscribing to node updates');
|
|
172
|
+
return this.events.subscribeToTreeEvents(treeEventScopeId, callback);
|
|
173
|
+
}
|
|
174
|
+
|
|
175
|
+
/**
|
|
176
|
+
* Subscribes to the remote general data updates.
|
|
177
|
+
*
|
|
178
|
+
* See `ProtonDriveClient.subscribeToDriveEvents` for more information.
|
|
179
|
+
*/
|
|
180
|
+
async subscribeToDriveEvents(callback: DriveListener): Promise<EventSubscription> {
|
|
181
|
+
this.logger.debug('Subscribing to core updates');
|
|
182
|
+
return this.events.subscribeToCoreEvents(callback);
|
|
183
|
+
}
|
|
184
|
+
|
|
185
|
+
/**
|
|
186
|
+
* Iterates all the photos for the timeline view.
|
|
187
|
+
*
|
|
188
|
+
* The output includes only necessary information to quickly prepare
|
|
189
|
+
* the whole timeline view with the break-down per month/year and fast
|
|
190
|
+
* scrollbar.
|
|
191
|
+
*
|
|
192
|
+
* Individual photos details must be loaded separately based on what
|
|
193
|
+
* is visible in the UI.
|
|
194
|
+
*
|
|
195
|
+
* The output is sorted by the capture time, starting from the
|
|
196
|
+
* the most recent photos.
|
|
197
|
+
*/
|
|
198
|
+
async *iterateTimeline(signal?: AbortSignal): AsyncGenerator<{
|
|
199
|
+
nodeUid: string;
|
|
200
|
+
captureTime: Date;
|
|
201
|
+
tags: number[];
|
|
202
|
+
}> {
|
|
203
|
+
// TODO: expose better type
|
|
204
|
+
yield* this.photos.timeline.iterateTimeline(signal);
|
|
205
|
+
}
|
|
206
|
+
|
|
207
|
+
/**
|
|
208
|
+
* Iterates the nodes by their UIDs.
|
|
209
|
+
*
|
|
210
|
+
* See `ProtonDriveClient.iterateNodes` for more information.
|
|
211
|
+
*/
|
|
212
|
+
async *iterateNodes(nodeUids: NodeOrUid[], signal?: AbortSignal): AsyncGenerator<MaybeMissingNode> {
|
|
213
|
+
this.logger.info(`Iterating ${nodeUids.length} nodes`);
|
|
214
|
+
// TODO: expose photo type
|
|
215
|
+
yield* convertInternalMissingNodeIterator(this.nodes.access.iterateNodes(getUids(nodeUids), signal));
|
|
216
|
+
}
|
|
217
|
+
|
|
218
|
+
/**
|
|
219
|
+
* Get the node by its UID.
|
|
220
|
+
*
|
|
221
|
+
* See `ProtonDriveClient.getNode` for more information.
|
|
222
|
+
*/
|
|
223
|
+
async getNode(nodeUid: NodeOrUid): Promise<MaybeNode> {
|
|
224
|
+
this.logger.info(`Getting node ${getUid(nodeUid)}`);
|
|
225
|
+
return convertInternalNodePromise(this.nodes.access.getNode(getUid(nodeUid)));
|
|
226
|
+
}
|
|
227
|
+
|
|
228
|
+
/**
|
|
229
|
+
* Iterates the albums.
|
|
230
|
+
*
|
|
231
|
+
* The output is not sorted and the order of the nodes is not guaranteed.
|
|
232
|
+
*/
|
|
233
|
+
async *iterateAlbums(signal?: AbortSignal): AsyncGenerator<MaybeNode> {
|
|
234
|
+
this.logger.info('Iterating albums');
|
|
235
|
+
// TODO: expose album type
|
|
236
|
+
yield* convertInternalNodeIterator(this.photos.albums.iterateAlbums(signal));
|
|
237
|
+
}
|
|
238
|
+
|
|
239
|
+
/**
|
|
240
|
+
* Get the file downloader to download the node content.
|
|
241
|
+
*
|
|
242
|
+
* See `ProtonDriveClient.getFileDownloader` for more information.
|
|
243
|
+
*/
|
|
244
|
+
async getFileDownloader(nodeUid: NodeOrUid, signal?: AbortSignal): Promise<FileDownloader> {
|
|
245
|
+
this.logger.info(`Getting file downloader for ${getUid(nodeUid)}`);
|
|
246
|
+
return this.download.getFileDownloader(getUid(nodeUid), signal);
|
|
247
|
+
}
|
|
248
|
+
|
|
249
|
+
/**
|
|
250
|
+
* Iterates the thumbnails of the given nodes.
|
|
251
|
+
*
|
|
252
|
+
* See `ProtonDriveClient.iterateThumbnails` for more information.
|
|
253
|
+
*/
|
|
254
|
+
async *iterateThumbnails(
|
|
255
|
+
nodeUids: NodeOrUid[],
|
|
256
|
+
thumbnailType?: ThumbnailType,
|
|
257
|
+
signal?: AbortSignal,
|
|
258
|
+
): AsyncGenerator<ThumbnailResult> {
|
|
259
|
+
this.logger.info(`Iterating ${nodeUids.length} thumbnails`);
|
|
260
|
+
yield* this.download.iterateThumbnails(getUids(nodeUids), thumbnailType, signal);
|
|
261
|
+
}
|
|
262
|
+
|
|
263
|
+
/**
|
|
264
|
+
* Get the file uploader to upload a new file.
|
|
265
|
+
*
|
|
266
|
+
* See `ProtonDriveClient.getFileUploader` for more information.
|
|
267
|
+
*/
|
|
268
|
+
async getFileUploader(
|
|
269
|
+
name: string,
|
|
270
|
+
metadata: UploadMetadata & {
|
|
271
|
+
captureTime?: Date;
|
|
272
|
+
mainPhotoLinkID?: string;
|
|
273
|
+
// TODO: handle tags enum in the SDK
|
|
274
|
+
tags?: (0 | 3 | 1 | 2 | 7 | 4 | 5 | 6 | 8 | 9)[];
|
|
275
|
+
},
|
|
276
|
+
signal?: AbortSignal,
|
|
277
|
+
): Promise<FileUploader> {
|
|
278
|
+
this.logger.info(`Getting file uploader`);
|
|
279
|
+
const parentFolderUid = await this.nodes.access.getVolumeRootFolder();
|
|
280
|
+
return this.upload.getFileUploader(getUid(parentFolderUid), name, metadata, signal);
|
|
281
|
+
}
|
|
63
282
|
}
|
package/src/transformers.ts
CHANGED
|
@@ -23,6 +23,7 @@ type InternalPartialNode = Pick<
|
|
|
23
23
|
| 'type'
|
|
24
24
|
| 'mediaType'
|
|
25
25
|
| 'isShared'
|
|
26
|
+
| 'isSharedPublicly'
|
|
26
27
|
| 'creationTime'
|
|
27
28
|
| 'trashTime'
|
|
28
29
|
| 'activeRevision'
|
|
@@ -90,6 +91,7 @@ export function convertInternalNode(node: InternalPartialNode): PublicMaybeNode
|
|
|
90
91
|
type: node.type,
|
|
91
92
|
mediaType: node.mediaType,
|
|
92
93
|
isShared: node.isShared,
|
|
94
|
+
isSharedPublicly: node.isSharedPublicly,
|
|
93
95
|
creationTime: node.creationTime,
|
|
94
96
|
trashTime: node.trashTime,
|
|
95
97
|
totalStorageSize: node.totalStorageSize,
|
|
@@ -1,15 +0,0 @@
|
|
|
1
|
-
"use strict";
|
|
2
|
-
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
-
exports.PhotosCache = void 0;
|
|
4
|
-
class PhotosCache {
|
|
5
|
-
driveCache;
|
|
6
|
-
constructor(driveCache) {
|
|
7
|
-
this.driveCache = driveCache;
|
|
8
|
-
this.driveCache = driveCache;
|
|
9
|
-
}
|
|
10
|
-
async setAlbum(album) {
|
|
11
|
-
await this.driveCache.setEntity(album.uid, album);
|
|
12
|
-
}
|
|
13
|
-
}
|
|
14
|
-
exports.PhotosCache = PhotosCache;
|
|
15
|
-
//# sourceMappingURL=cache.js.map
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"cache.js","sourceRoot":"","sources":["../../../src/internal/photos/cache.ts"],"names":[],"mappings":";;;AAEA,MAAa,WAAW;IACA;IAApB,YAAoB,UAAoC;QAApC,eAAU,GAAV,UAAU,CAA0B;QACpD,IAAI,CAAC,UAAU,GAAG,UAAU,CAAC;IACjC,CAAC;IAED,KAAK,CAAC,QAAQ,CAAC,KAAU;QACrB,MAAM,IAAI,CAAC,UAAU,CAAC,SAAS,CAAC,KAAK,CAAC,GAAG,EAAE,KAAK,CAAC,CAAC;IACtD,CAAC;CACJ;AARD,kCAQC"}
|
|
@@ -1,10 +0,0 @@
|
|
|
1
|
-
import { PhotosAPIService } from './apiService';
|
|
2
|
-
import { PhotosCache } from './cache';
|
|
3
|
-
import { NodesService } from './interface';
|
|
4
|
-
export declare class PhotosTimeline {
|
|
5
|
-
private apiService;
|
|
6
|
-
private cache;
|
|
7
|
-
private nodesService;
|
|
8
|
-
constructor(apiService: PhotosAPIService, cache: PhotosCache, nodesService: NodesService);
|
|
9
|
-
getTimelineStructure(): Promise<void>;
|
|
10
|
-
}
|
|
@@ -1,19 +0,0 @@
|
|
|
1
|
-
"use strict";
|
|
2
|
-
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
-
exports.PhotosTimeline = void 0;
|
|
4
|
-
class PhotosTimeline {
|
|
5
|
-
apiService;
|
|
6
|
-
cache;
|
|
7
|
-
nodesService;
|
|
8
|
-
constructor(apiService, cache, nodesService) {
|
|
9
|
-
this.apiService = apiService;
|
|
10
|
-
this.cache = cache;
|
|
11
|
-
this.nodesService = nodesService;
|
|
12
|
-
this.apiService = apiService;
|
|
13
|
-
this.cache = cache;
|
|
14
|
-
this.nodesService = nodesService;
|
|
15
|
-
}
|
|
16
|
-
async getTimelineStructure() { }
|
|
17
|
-
}
|
|
18
|
-
exports.PhotosTimeline = PhotosTimeline;
|
|
19
|
-
//# sourceMappingURL=photosTimeline.js.map
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"photosTimeline.js","sourceRoot":"","sources":["../../../src/internal/photos/photosTimeline.ts"],"names":[],"mappings":";;;AAIA,MAAa,cAAc;IAEX;IACA;IACA;IAHZ,YACY,UAA4B,EAC5B,KAAkB,EAClB,YAA0B;QAF1B,eAAU,GAAV,UAAU,CAAkB;QAC5B,UAAK,GAAL,KAAK,CAAa;QAClB,iBAAY,GAAZ,YAAY,CAAc;QAElC,IAAI,CAAC,UAAU,GAAG,UAAU,CAAC;QAC7B,IAAI,CAAC,KAAK,GAAG,KAAK,CAAC;QACnB,IAAI,CAAC,YAAY,GAAG,YAAY,CAAC;IACrC,CAAC;IAED,KAAK,CAAC,oBAAoB,KAAI,CAAC;CAClC;AAZD,wCAYC"}
|
|
@@ -1,11 +0,0 @@
|
|
|
1
|
-
import { ProtonDriveEntitiesCache } from '../../interface';
|
|
2
|
-
|
|
3
|
-
export class PhotosCache {
|
|
4
|
-
constructor(private driveCache: ProtonDriveEntitiesCache) {
|
|
5
|
-
this.driveCache = driveCache;
|
|
6
|
-
}
|
|
7
|
-
|
|
8
|
-
async setAlbum(album: any) {
|
|
9
|
-
await this.driveCache.setEntity(album.uid, album);
|
|
10
|
-
}
|
|
11
|
-
}
|
|
@@ -1,17 +0,0 @@
|
|
|
1
|
-
import { PhotosAPIService } from './apiService';
|
|
2
|
-
import { PhotosCache } from './cache';
|
|
3
|
-
import { NodesService } from './interface';
|
|
4
|
-
|
|
5
|
-
export class PhotosTimeline {
|
|
6
|
-
constructor(
|
|
7
|
-
private apiService: PhotosAPIService,
|
|
8
|
-
private cache: PhotosCache,
|
|
9
|
-
private nodesService: NodesService,
|
|
10
|
-
) {
|
|
11
|
-
this.apiService = apiService;
|
|
12
|
-
this.cache = cache;
|
|
13
|
-
this.nodesService = nodesService;
|
|
14
|
-
}
|
|
15
|
-
|
|
16
|
-
async getTimelineStructure() {}
|
|
17
|
-
}
|