@protontech/drive-sdk 0.4.0 → 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/nodes/apiService.js +1 -0
- package/dist/internal/nodes/apiService.js.map +1 -1
- package/dist/internal/nodes/apiService.test.js +16 -0
- 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/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 +1 -0
- package/dist/internal/nodes/index.test.js.map +1 -1
- package/dist/internal/nodes/interface.d.ts +1 -0
- package/dist/internal/nodes/nodesManagement.js +1 -0
- package/dist/internal/nodes/nodesManagement.js.map +1 -1
- package/dist/internal/photos/index.d.ts +11 -0
- package/dist/internal/photos/index.js +27 -0
- package/dist/internal/photos/index.js.map +1 -1
- 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/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/protonDrivePhotosClient.d.ts +18 -2
- package/dist/protonDrivePhotosClient.js +19 -2
- 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/nodes/apiService.test.ts +23 -0
- package/src/internal/nodes/apiService.ts +1 -0
- package/src/internal/nodes/cache.test.ts +1 -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 +1 -0
- package/src/internal/nodes/interface.ts +1 -0
- package/src/internal/nodes/nodesManagement.ts +1 -0
- package/src/internal/photos/index.ts +62 -0
- package/src/internal/photos/upload.ts +209 -0
- 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/protonDrivePhotosClient.ts +46 -6
- package/src/transformers.ts +2 -0
|
@@ -8,20 +8,27 @@ import {
|
|
|
8
8
|
FileUploader,
|
|
9
9
|
SDKEvent,
|
|
10
10
|
MaybeNode,
|
|
11
|
+
ThumbnailType,
|
|
12
|
+
ThumbnailResult,
|
|
11
13
|
} from './interface';
|
|
12
14
|
import { getConfig } from './config';
|
|
13
15
|
import { DriveCrypto } from './crypto';
|
|
14
16
|
import { Telemetry } from './telemetry';
|
|
15
|
-
import {
|
|
17
|
+
import {
|
|
18
|
+
convertInternalMissingNodeIterator,
|
|
19
|
+
convertInternalNodeIterator,
|
|
20
|
+
convertInternalNodePromise,
|
|
21
|
+
getUid,
|
|
22
|
+
getUids,
|
|
23
|
+
} from './transformers';
|
|
16
24
|
import { DriveAPIService } from './internal/apiService';
|
|
17
25
|
import { initDownloadModule } from './internal/download';
|
|
18
26
|
import { DriveEventsService, DriveListener, EventSubscription } from './internal/events';
|
|
19
27
|
import { initNodesModule } from './internal/nodes';
|
|
20
|
-
import { initPhotoSharesModule,
|
|
28
|
+
import { initPhotosModule, initPhotoSharesModule, initPhotoUploadModule } from './internal/photos';
|
|
21
29
|
import { SDKEvents } from './internal/sdkEvents';
|
|
22
30
|
import { initSharesModule } from './internal/shares';
|
|
23
31
|
import { initSharingModule } from './internal/sharing';
|
|
24
|
-
import { initUploadModule } from './internal/upload';
|
|
25
32
|
|
|
26
33
|
/**
|
|
27
34
|
* ProtonDrivePhotosClient is the interface to access Photos functionality.
|
|
@@ -39,7 +46,7 @@ export class ProtonDrivePhotosClient {
|
|
|
39
46
|
private nodes: ReturnType<typeof initNodesModule>;
|
|
40
47
|
private sharing: ReturnType<typeof initSharingModule>;
|
|
41
48
|
private download: ReturnType<typeof initDownloadModule>;
|
|
42
|
-
private upload: ReturnType<typeof
|
|
49
|
+
private upload: ReturnType<typeof initPhotoUploadModule>;
|
|
43
50
|
private photos: ReturnType<typeof initPhotosModule>;
|
|
44
51
|
|
|
45
52
|
public experimental: {
|
|
@@ -115,7 +122,7 @@ export class ProtonDrivePhotosClient {
|
|
|
115
122
|
this.nodes.access,
|
|
116
123
|
this.nodes.revisions,
|
|
117
124
|
);
|
|
118
|
-
this.upload =
|
|
125
|
+
this.upload = initPhotoUploadModule(
|
|
119
126
|
telemetry,
|
|
120
127
|
apiService,
|
|
121
128
|
cryptoModule,
|
|
@@ -208,6 +215,16 @@ export class ProtonDrivePhotosClient {
|
|
|
208
215
|
yield* convertInternalMissingNodeIterator(this.nodes.access.iterateNodes(getUids(nodeUids), signal));
|
|
209
216
|
}
|
|
210
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
|
+
|
|
211
228
|
/**
|
|
212
229
|
* Iterates the albums.
|
|
213
230
|
*
|
|
@@ -229,12 +246,35 @@ export class ProtonDrivePhotosClient {
|
|
|
229
246
|
return this.download.getFileDownloader(getUid(nodeUid), signal);
|
|
230
247
|
}
|
|
231
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
|
+
|
|
232
263
|
/**
|
|
233
264
|
* Get the file uploader to upload a new file.
|
|
234
265
|
*
|
|
235
266
|
* See `ProtonDriveClient.getFileUploader` for more information.
|
|
236
267
|
*/
|
|
237
|
-
async getFileUploader(
|
|
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> {
|
|
238
278
|
this.logger.info(`Getting file uploader`);
|
|
239
279
|
const parentFolderUid = await this.nodes.access.getVolumeRootFolder();
|
|
240
280
|
return this.upload.getFileUploader(getUid(parentFolderUid), name, metadata, signal);
|
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,
|