@converse/skeletor 2.0.0 → 3.0.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/skeletor.d.ts +46 -42
- package/dist/skeletor.esm.js +12046 -0
- package/dist/skeletor.esm.js.map +1 -0
- package/dist/skeletor.js +2 -2
- package/dist/skeletor.js.map +1 -0
- package/dist/skeletor.min.js +1 -1
- package/package.json +12 -2
- package/src/collection.ts +5 -2
- package/src/index.ts +7 -6
- package/src/types.ts +5 -0
package/dist/skeletor.d.ts
CHANGED
|
@@ -1,5 +1,39 @@
|
|
|
1
1
|
import localForage from 'localforage';
|
|
2
2
|
|
|
3
|
+
/**
|
|
4
|
+
* @public
|
|
5
|
+
*/
|
|
6
|
+
export declare class BrowserStorage {
|
|
7
|
+
storeInitialized: Promise<void>;
|
|
8
|
+
store: LocalForageWithExtensions;
|
|
9
|
+
name: string;
|
|
10
|
+
static sessionStorageInitialized: Promise<void>;
|
|
11
|
+
static localForage: typeof localForage;
|
|
12
|
+
constructor(id: string, type: 'local' | 'session' | 'indexed' | 'in_memory' | LocalForageWithExtensions, batchedWrites?: boolean);
|
|
13
|
+
/**
|
|
14
|
+
* @param type - The storage type: 'local', 'session', 'indexed', or 'in_memory'
|
|
15
|
+
* @param batchedWrites - Whether to enable batched writes
|
|
16
|
+
*/
|
|
17
|
+
initStore(type: 'local' | 'session' | 'indexed' | 'in_memory', batchedWrites: boolean): Promise<void>;
|
|
18
|
+
flush(): void;
|
|
19
|
+
clear(): Promise<void>;
|
|
20
|
+
sync(): {
|
|
21
|
+
(method: SyncOperation, model: Model, options: SyncOptions): Promise<void>;
|
|
22
|
+
__name__: string;
|
|
23
|
+
};
|
|
24
|
+
removeCollectionReference(model: Model, collection: Collection | undefined): Promise<any> | undefined;
|
|
25
|
+
addCollectionReference(model: Model, collection: Collection | undefined): Promise<any> | undefined;
|
|
26
|
+
getCollectionReferenceData(model: Model): Record<string, string[]>;
|
|
27
|
+
save(model: Model): Promise<any>;
|
|
28
|
+
create(model: Model, options: SyncOptions): Promise<any>;
|
|
29
|
+
update(model: Model): Promise<any>;
|
|
30
|
+
find(model: Model): Promise<any>;
|
|
31
|
+
findAll(): Promise<any[]>;
|
|
32
|
+
destroy(model: Model, collection: Collection | undefined): Promise<Model>;
|
|
33
|
+
getStorageSize(): Promise<number>;
|
|
34
|
+
getItemName(id: string | number): string;
|
|
35
|
+
}
|
|
36
|
+
|
|
3
37
|
/**
|
|
4
38
|
* @public
|
|
5
39
|
*/
|
|
@@ -16,7 +50,7 @@ export declare type ClassConstructor<T = any> = new (...args: any[]) => T;
|
|
|
16
50
|
*/
|
|
17
51
|
export declare class Collection<T extends Model = Model> extends EventEmitterObject {
|
|
18
52
|
[key: symbol]: () => CollectionIterator<T>;
|
|
19
|
-
_browserStorage?:
|
|
53
|
+
_browserStorage?: BrowserStorage;
|
|
20
54
|
_comparator?: Comparator<T>;
|
|
21
55
|
_url: string;
|
|
22
56
|
models: T[];
|
|
@@ -30,8 +64,8 @@ export declare class Collection<T extends Model = Model> extends EventEmitterObj
|
|
|
30
64
|
constructor(models?: T[] | ModelAttributes[] | T | ModelAttributes, options?: CollectionOptions<T>);
|
|
31
65
|
get comparator(): Comparator<T>;
|
|
32
66
|
set comparator(c: Comparator<T>);
|
|
33
|
-
set browserStorage(storage:
|
|
34
|
-
get browserStorage():
|
|
67
|
+
set browserStorage(storage: BrowserStorage);
|
|
68
|
+
get browserStorage(): BrowserStorage | undefined;
|
|
35
69
|
/**
|
|
36
70
|
* The default model for a collection is just a **Model**.
|
|
37
71
|
* This should be overridden in most cases.
|
|
@@ -172,7 +206,7 @@ export declare class Collection<T extends Model = Model> extends EventEmitterObj
|
|
|
172
206
|
* collection immediately, unless `wait: true` is passed, in which case we
|
|
173
207
|
* wait for the server to agree.
|
|
174
208
|
*/
|
|
175
|
-
create(model: T | ModelAttributes, options?:
|
|
209
|
+
create(model: T | ModelAttributes, options?: FetchOrCreateOptions): Promise<T> | T;
|
|
176
210
|
/**
|
|
177
211
|
* **parse** converts a response into a list of models to be added to the
|
|
178
212
|
* collection. The default implementation is just to pass it through.
|
|
@@ -408,6 +442,11 @@ export declare interface EventHandlersMap {
|
|
|
408
442
|
*/
|
|
409
443
|
export declare type EventListenerMap = Record<string, ListeningType>;
|
|
410
444
|
|
|
445
|
+
export declare type FetchOrCreateOptions = Options & {
|
|
446
|
+
promise?: boolean;
|
|
447
|
+
success?: (m: Model, resp: any, callbackOpts: Options) => void;
|
|
448
|
+
};
|
|
449
|
+
|
|
411
450
|
/**
|
|
412
451
|
* @public
|
|
413
452
|
*/
|
|
@@ -472,7 +511,7 @@ export declare interface LocalForageWithExtensions {
|
|
|
472
511
|
* performing computations and transformations on that data.
|
|
473
512
|
*/
|
|
474
513
|
export declare class Model<T extends ModelAttributes = ModelAttributes> extends EventEmitterObject {
|
|
475
|
-
_browserStorage?:
|
|
514
|
+
_browserStorage?: BrowserStorage;
|
|
476
515
|
_changing: boolean;
|
|
477
516
|
_pending: boolean | ModelOptions;
|
|
478
517
|
_previousAttributes?: T;
|
|
@@ -489,8 +528,8 @@ export declare class Model<T extends ModelAttributes = ModelAttributes> extends
|
|
|
489
528
|
* is automatically generated and assigned for you.
|
|
490
529
|
*/
|
|
491
530
|
constructor(attributes?: Partial<T>, options?: ModelOptions);
|
|
492
|
-
set browserStorage(storage:
|
|
493
|
-
get browserStorage():
|
|
531
|
+
set browserStorage(storage: BrowserStorage);
|
|
532
|
+
get browserStorage(): BrowserStorage | undefined;
|
|
494
533
|
/**
|
|
495
534
|
* The default name for the JSON `id` attribute is `"id"`. MongoDB and
|
|
496
535
|
* CouchDB users may want to set this to `"_id"` (by overriding this getter
|
|
@@ -691,41 +730,6 @@ export declare interface SkeletorType {
|
|
|
691
730
|
noConflict?: () => SkeletorType;
|
|
692
731
|
}
|
|
693
732
|
|
|
694
|
-
/**
|
|
695
|
-
* @public
|
|
696
|
-
*/
|
|
697
|
-
declare class Storage_2 {
|
|
698
|
-
storeInitialized: Promise<void>;
|
|
699
|
-
store: LocalForageWithExtensions;
|
|
700
|
-
name: string;
|
|
701
|
-
static sessionStorageInitialized: Promise<void>;
|
|
702
|
-
static localForage: typeof localForage;
|
|
703
|
-
constructor(id: string, type: 'local' | 'session' | 'indexed' | 'in_memory' | LocalForageWithExtensions, batchedWrites?: boolean);
|
|
704
|
-
/**
|
|
705
|
-
* @param type - The storage type: 'local', 'session', 'indexed', or 'in_memory'
|
|
706
|
-
* @param batchedWrites - Whether to enable batched writes
|
|
707
|
-
*/
|
|
708
|
-
initStore(type: 'local' | 'session' | 'indexed' | 'in_memory', batchedWrites: boolean): Promise<void>;
|
|
709
|
-
flush(): void;
|
|
710
|
-
clear(): Promise<void>;
|
|
711
|
-
sync(): {
|
|
712
|
-
(method: SyncOperation, model: Model, options: SyncOptions): Promise<void>;
|
|
713
|
-
__name__: string;
|
|
714
|
-
};
|
|
715
|
-
removeCollectionReference(model: Model, collection: Collection | undefined): Promise<any> | undefined;
|
|
716
|
-
addCollectionReference(model: Model, collection: Collection | undefined): Promise<any> | undefined;
|
|
717
|
-
getCollectionReferenceData(model: Model): Record<string, string[]>;
|
|
718
|
-
save(model: Model): Promise<any>;
|
|
719
|
-
create(model: Model, options: SyncOptions): Promise<any>;
|
|
720
|
-
update(model: Model): Promise<any>;
|
|
721
|
-
find(model: Model): Promise<any>;
|
|
722
|
-
findAll(): Promise<any[]>;
|
|
723
|
-
destroy(model: Model, collection: Collection | undefined): Promise<Model>;
|
|
724
|
-
getStorageSize(): Promise<number>;
|
|
725
|
-
getItemName(id: string | number): string;
|
|
726
|
-
}
|
|
727
|
-
export { Storage_2 as Storage }
|
|
728
|
-
|
|
729
733
|
/**
|
|
730
734
|
* Override this function to change the manner in which Backbone persists
|
|
731
735
|
* models to the server. You will be passed the type of request, and the
|