shelving 1.89.2 → 1.89.3
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/constraint/FilterConstraint.d.ts +3 -3
- package/db/Change.d.ts +16 -16
- package/db/Change.js +3 -4
- package/db/Collection.d.ts +37 -43
- package/db/Collection.js +22 -29
- package/db/Database.d.ts +21 -21
- package/db/Database.js +6 -6
- package/db/Item.d.ts +38 -44
- package/db/Item.js +30 -37
- package/db/ItemState.d.ts +5 -5
- package/db/ItemState.js +3 -3
- package/db/Query.d.ts +36 -36
- package/db/Query.js +13 -13
- package/db/QueryState.d.ts +9 -9
- package/db/QueryState.js +3 -3
- package/firestore/client/FirestoreClientProvider.d.ts +2 -2
- package/package.json +1 -1
- package/provider/CacheProvider.d.ts +16 -16
- package/provider/DebugProvider.d.ts +29 -29
- package/provider/MemoryProvider.d.ts +19 -22
- package/provider/MemoryProvider.js +1 -4
- package/provider/Provider.d.ts +33 -33
- package/provider/ThroughProvider.d.ts +29 -29
- package/provider/ValidationProvider.d.ts +2 -2
- package/react/useData.d.ts +3 -4
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import type { Data
|
|
1
|
+
import type { Data } from "../util/data.js";
|
|
2
2
|
import type { ItemArray, ItemValue, ItemData, ItemConstraints } from "../db/Item.js";
|
|
3
3
|
import { Updates } from "../update/DataUpdate.js";
|
|
4
4
|
import { DeferredSequence } from "../sequence/DeferredSequence.js";
|
|
@@ -8,30 +8,27 @@ import type { Provider } from "./Provider.js";
|
|
|
8
8
|
* - Extremely fast (ideal for caching!), but does not persist data after the browser window is closed.
|
|
9
9
|
* - `get()` etc return the exact same instance of an object that's passed into `set()`
|
|
10
10
|
*/
|
|
11
|
-
export declare class MemoryProvider
|
|
11
|
+
export declare class MemoryProvider implements Provider {
|
|
12
12
|
/** List of tables in `{ collection: Table }` format. */
|
|
13
13
|
private _tables;
|
|
14
14
|
/** Get a table for a collection. */
|
|
15
|
-
getTable
|
|
16
|
-
getDocumentTime
|
|
17
|
-
getItem
|
|
18
|
-
getItemSequence
|
|
19
|
-
addItem
|
|
20
|
-
setItem
|
|
21
|
-
updateItem
|
|
22
|
-
deleteItem
|
|
23
|
-
getQueryTime
|
|
24
|
-
getQuery
|
|
25
|
-
getQuerySequence
|
|
26
|
-
setQuery
|
|
27
|
-
updateQuery
|
|
28
|
-
deleteQuery
|
|
15
|
+
getTable(collection: string): MemoryTable;
|
|
16
|
+
getDocumentTime(collection: string, id: string): number | null;
|
|
17
|
+
getItem(collection: string, id: string): ItemValue;
|
|
18
|
+
getItemSequence(collection: string, id: string): AsyncIterable<ItemValue>;
|
|
19
|
+
addItem(collection: string, data: Data): string;
|
|
20
|
+
setItem(collection: string, id: string, data: Data): void;
|
|
21
|
+
updateItem(collection: string, id: string, updates: Updates): void;
|
|
22
|
+
deleteItem(collection: string, id: string): void;
|
|
23
|
+
getQueryTime(collection: string, constraints: ItemConstraints): number | null;
|
|
24
|
+
getQuery(collection: string, constraints: ItemConstraints): ItemArray;
|
|
25
|
+
getQuerySequence(collection: string, constraints: ItemConstraints): AsyncIterable<ItemArray>;
|
|
26
|
+
setQuery(collection: string, constraints: ItemConstraints, data: Data): number;
|
|
27
|
+
updateQuery(collection: string, constraints: ItemConstraints, updates: Updates): number;
|
|
28
|
+
deleteQuery(collection: string, constraints: ItemConstraints): number;
|
|
29
29
|
}
|
|
30
|
-
/**
|
|
31
|
-
|
|
32
|
-
* - Fires with an array of string IDs.
|
|
33
|
-
*/
|
|
34
|
-
export declare class MemoryTable<T extends Data> {
|
|
30
|
+
/** An individual table of data. */
|
|
31
|
+
export declare class MemoryTable<T extends Data = Data> {
|
|
35
32
|
/** Actual data in this table. */
|
|
36
33
|
protected readonly _data: Map<string, ItemData<T>>;
|
|
37
34
|
/** Times data was last updated. */
|
|
@@ -47,7 +44,7 @@ export declare class MemoryTable<T extends Data> {
|
|
|
47
44
|
private _setItemData;
|
|
48
45
|
setItem(id: string, item: ItemData<T> | T): void;
|
|
49
46
|
setItemValue(id: string, value: ItemData<T> | T | null): void;
|
|
50
|
-
setItemValueSequence(id: string, sequence: AsyncIterable<ItemValue<T>>): AsyncIterable<ItemValue
|
|
47
|
+
setItemValueSequence(id: string, sequence: AsyncIterable<ItemValue<T>>): AsyncIterable<ItemValue>;
|
|
51
48
|
updateItem(id: string, updates: Updates<T>): void;
|
|
52
49
|
deleteItem(id: string): void;
|
|
53
50
|
getQueryTime(constraints: ItemConstraints<T>): number | null;
|
|
@@ -59,10 +59,7 @@ export class MemoryProvider {
|
|
|
59
59
|
return this.getTable(collection).deleteQuery(constraints);
|
|
60
60
|
}
|
|
61
61
|
}
|
|
62
|
-
/**
|
|
63
|
-
* An individual table of data.
|
|
64
|
-
* - Fires with an array of string IDs.
|
|
65
|
-
*/
|
|
62
|
+
/** An individual table of data. */
|
|
66
63
|
export class MemoryTable {
|
|
67
64
|
constructor() {
|
|
68
65
|
/** Actual data in this table. */
|
package/provider/Provider.d.ts
CHANGED
|
@@ -1,18 +1,18 @@
|
|
|
1
1
|
import type { Updates } from "../update/DataUpdate.js";
|
|
2
|
-
import type {
|
|
2
|
+
import type { Data } from "../util/data.js";
|
|
3
3
|
import type { ItemArray, ItemConstraints, ItemValue } from "../db/Item.js";
|
|
4
4
|
/** Provides access to data (e.g. IndexedDB, Firebase, or in-memory cache providers). */
|
|
5
|
-
declare abstract class AbstractProvider
|
|
5
|
+
declare abstract class AbstractProvider {
|
|
6
6
|
/**
|
|
7
7
|
* Get the value of a item.
|
|
8
8
|
*
|
|
9
9
|
* @return The item value, or `null` if it doesn't exist.
|
|
10
10
|
*/
|
|
11
|
-
abstract getItem
|
|
11
|
+
abstract getItem(collection: string, id: string): ItemValue | PromiseLike<ItemValue>;
|
|
12
12
|
/**
|
|
13
13
|
* Subscribe to the value of this item with an async iterator.
|
|
14
14
|
*/
|
|
15
|
-
abstract getItemSequence
|
|
15
|
+
abstract getItemSequence(collection: string, id: string): AsyncIterable<ItemValue>;
|
|
16
16
|
/**
|
|
17
17
|
* Create a new item with a random ID.
|
|
18
18
|
* - Created item is guaranteed to have a unique ID.
|
|
@@ -20,75 +20,75 @@ declare abstract class AbstractProvider<T extends Datas = Datas> {
|
|
|
20
20
|
* @param data Complete data to set the item to.
|
|
21
21
|
* @return String ID for the created item (possibly promised).
|
|
22
22
|
*/
|
|
23
|
-
abstract addItem
|
|
23
|
+
abstract addItem(collection: string, data: Data): string | PromiseLike<string>;
|
|
24
24
|
/**
|
|
25
25
|
* Set the data a item (whether it exists or not).
|
|
26
26
|
* @param data Data to set the item to.
|
|
27
27
|
*/
|
|
28
|
-
abstract setItem
|
|
28
|
+
abstract setItem(collection: string, id: string, data: Data): void | PromiseLike<void>;
|
|
29
29
|
/**
|
|
30
30
|
* Update the data an existing item.
|
|
31
31
|
*
|
|
32
32
|
* @param updates Set of property updates to apply to the item.
|
|
33
33
|
* @throws Error If the item does not exist (ideally a `RequiredError` but may be provider-specific).
|
|
34
34
|
*/
|
|
35
|
-
abstract updateItem
|
|
35
|
+
abstract updateItem(collection: string, id: string, updates: Updates): void | PromiseLike<void>;
|
|
36
36
|
/**
|
|
37
37
|
* Delete a specified item.
|
|
38
38
|
*/
|
|
39
|
-
abstract deleteItem
|
|
39
|
+
abstract deleteItem(collection: string, id: string): void | PromiseLike<void>;
|
|
40
40
|
/**
|
|
41
41
|
* Get all matching items.
|
|
42
42
|
*
|
|
43
43
|
* @return Set of values in `id: data` format.
|
|
44
44
|
*/
|
|
45
|
-
abstract getQuery
|
|
45
|
+
abstract getQuery(collection: string, constraints: ItemConstraints): ItemArray | PromiseLike<ItemArray>;
|
|
46
46
|
/**
|
|
47
47
|
* Subscribe to all matching items with an async iterator.
|
|
48
48
|
*/
|
|
49
|
-
abstract getQuerySequence
|
|
49
|
+
abstract getQuerySequence(collection: string, constraints: ItemConstraints): AsyncIterable<ItemArray>;
|
|
50
50
|
/**
|
|
51
51
|
* Set the data of all matching items.
|
|
52
52
|
*
|
|
53
53
|
* @param data Data to set matching items to.
|
|
54
54
|
* @return Number of items that were set.
|
|
55
55
|
*/
|
|
56
|
-
abstract setQuery
|
|
56
|
+
abstract setQuery(collection: string, constraints: ItemConstraints, data: Data): number | PromiseLike<number>;
|
|
57
57
|
/**
|
|
58
58
|
* Update the data of all matching items.
|
|
59
59
|
*
|
|
60
60
|
* @param updates Set of property updates to apply to matching items.
|
|
61
61
|
* @return Number of items that were updated.
|
|
62
62
|
*/
|
|
63
|
-
abstract updateQuery
|
|
63
|
+
abstract updateQuery(collection: string, constraints: ItemConstraints, updates: Updates): number | PromiseLike<number>;
|
|
64
64
|
/**
|
|
65
65
|
* Delete all matching items.
|
|
66
66
|
* @return Number of items that were deleted.
|
|
67
67
|
*/
|
|
68
|
-
abstract deleteQuery
|
|
68
|
+
abstract deleteQuery(collection: string, constraints: ItemConstraints): number | PromiseLike<number>;
|
|
69
69
|
}
|
|
70
70
|
/** Provider with a fully synchronous interface */
|
|
71
|
-
export declare abstract class Provider
|
|
72
|
-
abstract getItem
|
|
73
|
-
abstract addItem
|
|
74
|
-
abstract setItem
|
|
75
|
-
abstract updateItem
|
|
76
|
-
abstract deleteItem
|
|
77
|
-
abstract getQuery
|
|
78
|
-
abstract setQuery
|
|
79
|
-
abstract updateQuery
|
|
80
|
-
abstract deleteQuery
|
|
71
|
+
export declare abstract class Provider extends AbstractProvider {
|
|
72
|
+
abstract getItem(collection: string, id: string): ItemValue;
|
|
73
|
+
abstract addItem(collection: string, data: Data): string;
|
|
74
|
+
abstract setItem(collection: string, id: string, data: Data): void;
|
|
75
|
+
abstract updateItem(collection: string, id: string, updates: Updates): void;
|
|
76
|
+
abstract deleteItem(collection: string, id: string): void;
|
|
77
|
+
abstract getQuery(collection: string, constraints: ItemConstraints): ItemArray;
|
|
78
|
+
abstract setQuery(collection: string, constraints: ItemConstraints, data: Data): number;
|
|
79
|
+
abstract updateQuery(collection: string, constraints: ItemConstraints, updates: Updates): number;
|
|
80
|
+
abstract deleteQuery(collection: string, constraints: ItemConstraints): number;
|
|
81
81
|
}
|
|
82
82
|
/** Provider with a fully asynchronous interface */
|
|
83
|
-
export declare abstract class AsyncProvider
|
|
84
|
-
abstract getItem
|
|
85
|
-
abstract addItem
|
|
86
|
-
abstract setItem
|
|
87
|
-
abstract updateItem
|
|
88
|
-
abstract deleteItem
|
|
89
|
-
abstract getQuery
|
|
90
|
-
abstract setQuery
|
|
91
|
-
abstract updateQuery
|
|
92
|
-
abstract deleteQuery
|
|
83
|
+
export declare abstract class AsyncProvider extends AbstractProvider {
|
|
84
|
+
abstract getItem(collection: string, id: string): Promise<ItemValue>;
|
|
85
|
+
abstract addItem(collection: string, data: Data): Promise<string>;
|
|
86
|
+
abstract setItem(collection: string, id: string, data: Data): Promise<void>;
|
|
87
|
+
abstract updateItem(collection: string, id: string, updates: Updates): Promise<void>;
|
|
88
|
+
abstract deleteItem(collection: string, id: string): Promise<void>;
|
|
89
|
+
abstract getQuery(collection: string, constraints: ItemConstraints): Promise<ItemArray>;
|
|
90
|
+
abstract setQuery(collection: string, constraints: ItemConstraints, data: Data): Promise<number>;
|
|
91
|
+
abstract updateQuery(collection: string, constraints: ItemConstraints, updates: Updates): Promise<number>;
|
|
92
|
+
abstract deleteQuery(collection: string, constraints: ItemConstraints): Promise<number>;
|
|
93
93
|
}
|
|
94
94
|
export {};
|
|
@@ -1,37 +1,37 @@
|
|
|
1
|
-
import type {
|
|
1
|
+
import type { Data } from "../util/data.js";
|
|
2
2
|
import type { Sourceable } from "../util/source.js";
|
|
3
3
|
import type { ItemArray, ItemConstraints, ItemValue } from "../db/Item.js";
|
|
4
4
|
import type { Updates } from "../update/DataUpdate.js";
|
|
5
5
|
import type { Provider, AsyncProvider } from "./Provider.js";
|
|
6
6
|
/** A provider that passes through to a synchronous source. */
|
|
7
|
-
export declare class ThroughProvider
|
|
8
|
-
readonly source: Provider
|
|
9
|
-
constructor(source: Provider
|
|
10
|
-
getItem
|
|
11
|
-
getItemSequence
|
|
12
|
-
addItem
|
|
13
|
-
setItem
|
|
14
|
-
updateItem
|
|
15
|
-
deleteItem
|
|
16
|
-
getQuery
|
|
17
|
-
getQuerySequence
|
|
18
|
-
setQuery
|
|
19
|
-
updateQuery
|
|
20
|
-
deleteQuery
|
|
7
|
+
export declare class ThroughProvider implements Provider, Sourceable<Provider> {
|
|
8
|
+
readonly source: Provider;
|
|
9
|
+
constructor(source: Provider);
|
|
10
|
+
getItem(collection: string, id: string): ItemValue;
|
|
11
|
+
getItemSequence(collection: string, id: string): AsyncIterable<ItemValue>;
|
|
12
|
+
addItem(collection: string, data: Data): string;
|
|
13
|
+
setItem(collection: string, id: string, data: Data): void;
|
|
14
|
+
updateItem(collection: string, id: string, update: Updates): void;
|
|
15
|
+
deleteItem(collection: string, id: string): void;
|
|
16
|
+
getQuery(collection: string, constraints: ItemConstraints): ItemArray;
|
|
17
|
+
getQuerySequence(collection: string, constraints: ItemConstraints): AsyncIterable<ItemArray>;
|
|
18
|
+
setQuery(collection: string, constraints: ItemConstraints, data: Data): number;
|
|
19
|
+
updateQuery(collection: string, constraints: ItemConstraints, update: Updates): number;
|
|
20
|
+
deleteQuery(collection: string, constraints: ItemConstraints): number;
|
|
21
21
|
}
|
|
22
22
|
/** A provider that passes through to an asynchronous source. */
|
|
23
|
-
export declare class AsyncThroughProvider
|
|
24
|
-
readonly source: AsyncProvider
|
|
25
|
-
constructor(source: AsyncProvider
|
|
26
|
-
getItem
|
|
27
|
-
getItemSequence
|
|
28
|
-
addItem
|
|
29
|
-
setItem
|
|
30
|
-
updateItem
|
|
31
|
-
deleteItem
|
|
32
|
-
getQuery
|
|
33
|
-
getQuerySequence
|
|
34
|
-
setQuery
|
|
35
|
-
updateQuery
|
|
36
|
-
deleteQuery
|
|
23
|
+
export declare class AsyncThroughProvider implements AsyncProvider, Sourceable<AsyncProvider> {
|
|
24
|
+
readonly source: AsyncProvider;
|
|
25
|
+
constructor(source: AsyncProvider);
|
|
26
|
+
getItem(collection: string, id: string): Promise<ItemValue>;
|
|
27
|
+
getItemSequence(collection: string, id: string): AsyncIterable<ItemValue>;
|
|
28
|
+
addItem(collection: string, data: Data): Promise<string>;
|
|
29
|
+
setItem(collection: string, id: string, data: Data): Promise<void>;
|
|
30
|
+
updateItem(collection: string, id: string, updates: Updates): Promise<void>;
|
|
31
|
+
deleteItem(collection: string, id: string): Promise<void>;
|
|
32
|
+
getQuery(collection: string, constraints: ItemConstraints): Promise<ItemArray>;
|
|
33
|
+
getQuerySequence(collection: string, constraints: ItemConstraints): AsyncIterable<ItemArray>;
|
|
34
|
+
setQuery(collection: string, constraints: ItemConstraints, data: Data): Promise<number>;
|
|
35
|
+
updateQuery(collection: string, constraints: ItemConstraints, updates: Updates): Promise<number>;
|
|
36
|
+
deleteQuery(collection: string, constraints: ItemConstraints): Promise<number>;
|
|
37
37
|
}
|
|
@@ -14,7 +14,7 @@ declare abstract class BaseValidationProvider<T extends Datas> {
|
|
|
14
14
|
getQuerySequence<K extends DataKey<T>>(collection: K, constraints: ItemConstraints<T[K]>): AsyncIterable<ItemArray<T[K]>>;
|
|
15
15
|
}
|
|
16
16
|
/** Validate a synchronous source provider (source can have any type because validation guarantees the type). */
|
|
17
|
-
export declare class ValidationProvider<T extends Datas> extends BaseValidationProvider<T> implements Provider
|
|
17
|
+
export declare class ValidationProvider<T extends Datas> extends BaseValidationProvider<T> implements Provider, Sourceable<Provider> {
|
|
18
18
|
readonly source: Provider;
|
|
19
19
|
constructor(source: Provider, schemas: DataSchemas<T>);
|
|
20
20
|
getItem<K extends DataKey<T>>(collection: K, id: string): ItemValue<T[K]>;
|
|
@@ -28,7 +28,7 @@ export declare class ValidationProvider<T extends Datas> extends BaseValidationP
|
|
|
28
28
|
deleteQuery<K extends DataKey<T>>(collection: K, constraints: ItemConstraints<T[K]>): number;
|
|
29
29
|
}
|
|
30
30
|
/** Validate an asynchronous source provider (source can have any type because validation guarantees the type). */
|
|
31
|
-
export declare class AsyncValidationProvider<T extends Datas> extends BaseValidationProvider<T> implements AsyncProvider
|
|
31
|
+
export declare class AsyncValidationProvider<T extends Datas> extends BaseValidationProvider<T> implements AsyncProvider, Sourceable<AsyncProvider> {
|
|
32
32
|
readonly source: AsyncProvider;
|
|
33
33
|
constructor(source: AsyncProvider, schemas: DataSchemas<T>);
|
|
34
34
|
getItem<K extends DataKey<T>>(collection: K, id: string): Promise<ItemValue<T[K]>>;
|
package/react/useData.d.ts
CHANGED
|
@@ -4,11 +4,10 @@ import { AsyncItem } from "../db/Item.js";
|
|
|
4
4
|
import { ItemState } from "../db/ItemState.js";
|
|
5
5
|
import { AsyncQuery } from "../db/Query.js";
|
|
6
6
|
import { QueryState } from "../db/QueryState.js";
|
|
7
|
-
type
|
|
8
|
-
type RefToState<T> = T extends undefined ? undefined : T extends AsyncItem<infer D, infer K> ? ItemState<D, K> : T extends AsyncQuery<infer D, infer K> ? QueryState<D, K> : never;
|
|
7
|
+
type RefToState<T> = T extends undefined ? undefined : T extends AsyncItem<infer X> ? ItemState<X> : T extends AsyncQuery<infer X> ? QueryState<X> : never;
|
|
9
8
|
/** Use one or more data items or queries. */
|
|
10
|
-
export declare function useData<T extends
|
|
11
|
-
export declare function useData<T extends ImmutableArray<
|
|
9
|
+
export declare function useData<T extends AsyncItem | AsyncQuery | undefined>(ref: T): RefToState<T>;
|
|
10
|
+
export declare function useData<T extends ImmutableArray<AsyncItem | AsyncQuery | undefined>>(...refs: T): {
|
|
12
11
|
[K in keyof T]: RefToState<T[K]>;
|
|
13
12
|
};
|
|
14
13
|
/** Wrap components with `<DataCache>` to allow the use of `useData()`. */
|