document-drive 1.0.0-experimental.3 → 1.0.0-experimental.5
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/package.json +2 -2
- package/src/server/index.ts +13 -12
- package/src/server/types.ts +28 -2
- package/src/storage/types.ts +0 -1
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "document-drive",
|
|
3
|
-
"version": "1.0.0-experimental.
|
|
3
|
+
"version": "1.0.0-experimental.5",
|
|
4
4
|
"license": "AGPL-3.0-only",
|
|
5
5
|
"type": "module",
|
|
6
6
|
"module": "./src/index.ts",
|
|
@@ -16,7 +16,7 @@
|
|
|
16
16
|
"./cache/redis": "./src/cache/redis.ts",
|
|
17
17
|
"./cache/memory": "./src/cache/memory.ts",
|
|
18
18
|
"./queue/redis": "./src/queue/redis.ts",
|
|
19
|
-
"./queue/
|
|
19
|
+
"./queue/base": "./src/queue/base.ts",
|
|
20
20
|
"./utils": "./src/utils/index.ts",
|
|
21
21
|
"./utils/graphql": "./src/utils/graphql.ts",
|
|
22
22
|
"./logger": "./src/utils/logger.ts"
|
package/src/server/index.ts
CHANGED
|
@@ -438,7 +438,7 @@ export class DocumentDriveServer extends BaseDocumentDriveServer {
|
|
|
438
438
|
return documentModel;
|
|
439
439
|
}
|
|
440
440
|
|
|
441
|
-
async addDrive(drive: DriveInput) {
|
|
441
|
+
async addDrive(drive: DriveInput): Promise<DocumentDriveDocument> {
|
|
442
442
|
const id = drive.global.id || generateUUID();
|
|
443
443
|
if (!id) {
|
|
444
444
|
throw new Error('Invalid Drive Id');
|
|
@@ -459,7 +459,7 @@ export class DocumentDriveServer extends BaseDocumentDriveServer {
|
|
|
459
459
|
return document;
|
|
460
460
|
}
|
|
461
461
|
|
|
462
|
-
async addRemoteDrive(url: string, options: RemoteDriveOptions) {
|
|
462
|
+
async addRemoteDrive(url: string, options: RemoteDriveOptions): Promise<DocumentDriveDocument> {
|
|
463
463
|
const { id, name, slug, icon } = await requestPublicDrive(url);
|
|
464
464
|
const {
|
|
465
465
|
pullFilter,
|
|
@@ -823,22 +823,19 @@ export class DocumentDriveServer extends BaseDocumentDriveServer {
|
|
|
823
823
|
}
|
|
824
824
|
}
|
|
825
825
|
|
|
826
|
+
queueOperation(drive: string, id: string, operation: Operation, forceSync = true): Promise<IOperationResult> {
|
|
827
|
+
return this.queueOperations(drive, id, [operation], forceSync);
|
|
828
|
+
}
|
|
826
829
|
|
|
827
830
|
async queueOperations(drive: string,
|
|
828
831
|
id: string,
|
|
829
832
|
operations: Operation[],
|
|
830
833
|
forceSync = true) {
|
|
831
|
-
// try {
|
|
832
|
-
// await this.getDocument(drive, id);
|
|
833
|
-
// } catch (error) {
|
|
834
|
-
// logger.error('Error getting document', error);
|
|
835
|
-
// throw error;
|
|
836
|
-
// }
|
|
837
834
|
|
|
838
835
|
try {
|
|
839
836
|
const jobId = await this.queueManager.addJob({ driveId: drive, documentId: id, operations, forceSync });
|
|
840
837
|
|
|
841
|
-
return new Promise((resolve, reject) => {
|
|
838
|
+
return new Promise<IOperationResult>((resolve, reject) => {
|
|
842
839
|
const unsubscribe = this.queueManager.on('jobCompleted', (job, result) => {
|
|
843
840
|
if (job.jobId === jobId) {
|
|
844
841
|
unsubscribe();
|
|
@@ -1014,18 +1011,22 @@ export class DocumentDriveServer extends BaseDocumentDriveServer {
|
|
|
1014
1011
|
}
|
|
1015
1012
|
}
|
|
1016
1013
|
|
|
1014
|
+
queueDriveOperation(drive: string, operation: Operation<DocumentDriveAction | BaseAction>, forceSync = true): Promise<IOperationResult<DocumentDriveDocument>> {
|
|
1015
|
+
return this.queueDriveOperations(drive, [operation], forceSync);
|
|
1016
|
+
}
|
|
1017
|
+
|
|
1017
1018
|
async queueDriveOperations(
|
|
1018
1019
|
drive: string,
|
|
1019
1020
|
operations: Operation<DocumentDriveAction | BaseAction>[],
|
|
1020
1021
|
forceSync = true
|
|
1021
|
-
): Promise<IOperationResult
|
|
1022
|
+
): Promise<IOperationResult<DocumentDriveDocument>> {
|
|
1022
1023
|
const jobId = await this.queueManager.addJob({ driveId: drive, operations, forceSync });
|
|
1023
|
-
return new Promise((resolve, reject) => {
|
|
1024
|
+
return new Promise<IOperationResult<DocumentDriveDocument>>((resolve, reject) => {
|
|
1024
1025
|
const unsubscribe = this.queueManager.on('jobCompleted', (job, result) => {
|
|
1025
1026
|
if (job.jobId === jobId) {
|
|
1026
1027
|
unsubscribe();
|
|
1027
1028
|
unsubscribeError();
|
|
1028
|
-
resolve(result);
|
|
1029
|
+
resolve(result as IOperationResult<DocumentDriveDocument>);
|
|
1029
1030
|
}
|
|
1030
1031
|
});
|
|
1031
1032
|
const unsubscribeError = this.queueManager.on('jobFailed', (job, error) => {
|
package/src/server/types.ts
CHANGED
|
@@ -178,13 +178,39 @@ export abstract class BaseDocumentDriveServer {
|
|
|
178
178
|
forceSync?: boolean
|
|
179
179
|
): Promise<IOperationResult>;
|
|
180
180
|
|
|
181
|
+
abstract queueOperation(
|
|
182
|
+
drive: string,
|
|
183
|
+
id: string,
|
|
184
|
+
operation: Operation,
|
|
185
|
+
forceSync?: boolean
|
|
186
|
+
): Promise<IOperationResult>;
|
|
187
|
+
abstract queueOperations(
|
|
188
|
+
drive: string,
|
|
189
|
+
id: string,
|
|
190
|
+
operations: Operation[],
|
|
191
|
+
forceSync?: boolean
|
|
192
|
+
): Promise<IOperationResult>;
|
|
193
|
+
|
|
181
194
|
abstract addDriveOperation(
|
|
182
195
|
drive: string,
|
|
183
|
-
operation: Operation<DocumentDriveAction | BaseAction
|
|
196
|
+
operation: Operation<DocumentDriveAction | BaseAction>,
|
|
197
|
+
forceSync?: boolean
|
|
184
198
|
): Promise<IOperationResult<DocumentDriveDocument>>;
|
|
185
199
|
abstract addDriveOperations(
|
|
186
200
|
drive: string,
|
|
187
|
-
operations: Operation<DocumentDriveAction | BaseAction>[]
|
|
201
|
+
operations: Operation<DocumentDriveAction | BaseAction>[],
|
|
202
|
+
forceSync?: boolean
|
|
203
|
+
): Promise<IOperationResult<DocumentDriveDocument>>;
|
|
204
|
+
|
|
205
|
+
abstract queueDriveOperation(
|
|
206
|
+
drive: string,
|
|
207
|
+
operation: Operation<DocumentDriveAction | BaseAction>,
|
|
208
|
+
forceSync?: boolean
|
|
209
|
+
): Promise<IOperationResult<DocumentDriveDocument>>;
|
|
210
|
+
abstract queueDriveOperations(
|
|
211
|
+
drive: string,
|
|
212
|
+
operations: Operation<DocumentDriveAction | BaseAction>[],
|
|
213
|
+
forceSync?: boolean
|
|
188
214
|
): Promise<IOperationResult<DocumentDriveDocument>>;
|
|
189
215
|
|
|
190
216
|
abstract addAction(
|