1
1
import tv4 from 'tv4' ;
2
+ import type RemoteStorage from './remotestorage' ;
2
3
import type { JsonSchemas } from './interfaces/json_schema' ;
3
4
import type { ChangeObj } from './interfaces/change_obj' ;
4
5
import type { QueuedRequestResponse } from './interfaces/queued_request_response' ;
@@ -7,7 +8,6 @@ import SchemaNotFound from './schema-not-found-error';
7
8
import EventHandling from './eventhandling' ;
8
9
import config from './config' ;
9
10
import { applyMixins , cleanPath , isFolder } from './util' ;
10
- import RemoteStorage from './remotestorage' ;
11
11
12
12
function getModuleNameFromBase ( path : string ) : string {
13
13
const parts = path . split ( '/' ) ;
@@ -147,8 +147,8 @@ function getModuleNameFromBase(path: string): string {
147
147
* during sync.
148
148
*
149
149
* > [!NOTE]
150
- * > Automatically receiving remote changes depends on the { @link caching!Caching} settings
151
- * > for your module/paths.
150
+ * > Automatically receiving remote changes depends on the
151
+ * > { @link caching!Caching caching} settings for your module/paths.
152
152
*
153
153
* ### `window`
154
154
*
@@ -180,13 +180,13 @@ function getModuleNameFromBase(path: string): string {
180
180
* }
181
181
* ```
182
182
*
183
- * But when this change is pushed out by asynchronous synchronization, this change
184
- * may be rejected by the server, if the remote version has in the meantime changed
185
- * from `white` to for instance `red`; this will then lead to a change event with
186
- * origin `conflict` ( usually a few seconds after the event with origin `window`,
187
- * if you have those activated) . Note that since you already changed it from
188
- * `white` to `blue` in the local version a few seconds ago, `oldValue` is now
189
- * your local value of `blue`:
183
+ * However, when this change is pushed out by the sync process, it will be
184
+ * rejected by the server, if the remote version has changed in the meantime,
185
+ * for example from `white` to `red`. This will lead to a change event with
186
+ * origin `conflict`, usually a few seconds after the event with origin
187
+ * `window` . Note that since you already changed it from `white` to `blue` in
188
+ * the local version a few seconds ago, `oldValue` is now your local value of
189
+ * `blue`:
190
190
*
191
191
* ```js
192
192
* {
@@ -212,11 +212,6 @@ function getModuleNameFromBase(path: string): string {
212
212
*
213
213
* If there is an algorithm to merge the differences between local and remote
214
214
* versions of the data, conflicts may be automatically resolved.
215
- * {@link storeObject} or {@link storeFile} must not be called synchronously from
216
- * the change event handler, nor by chaining Promises. {@link storeObject} or
217
- * {@link storeFile} must not be called until the next iteration of the JavaScript
218
- * Task Queue, using for example
219
- * [`setTimeout()`](https://developer.mozilla.org/en-US/docs/Web/API/WindowOrWorkerGlobalScope/setTimeout).
220
215
*
221
216
* If no algorithm exists, conflict resolution typically involves displaying local
222
217
* and remote versions to the user, and having the user merge them, or choose
@@ -625,17 +620,16 @@ export class BaseClient {
625
620
* @example
626
621
* client.remove('path/to/object').then(() => console.log('item deleted'));
627
622
*/
628
- // TODO add real return type
629
623
// TODO Don't return the RemoteResponse directly, handle response properly
630
- remove ( path : string ) : Promise < unknown > {
624
+ async remove ( path : string ) : Promise < QueuedRequestResponse > {
631
625
if ( typeof path !== 'string' ) {
632
626
return Promise . reject ( 'Argument \'path\' of baseClient.remove must be a string' ) ;
633
627
}
634
628
if ( ! this . storage . access . checkPathPermission ( this . makePath ( path ) , 'rw' ) ) {
635
629
console . warn ( 'WARNING: Removing a document to which only read access (\'r\') was claimed' ) ;
636
630
}
637
631
638
- return this . storage . delete ( this . makePath ( path ) ) ;
632
+ return this . storage . delete ( this . makePath ( path ) , this . storage . connected ) ;
639
633
}
640
634
641
635
/**
0 commit comments