shelving 1.89.2 → 1.89.4

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/db/Item.js CHANGED
@@ -1,20 +1,30 @@
1
- import { getData } from "../util/data.js";
2
- import { runSequence } from "../util/sequence.js";
1
+ import { QueryConstraints } from "../constraint/QueryConstraints.js";
3
2
  import { FilterConstraint } from "../constraint/FilterConstraint.js";
4
3
  import { FilterConstraints } from "../constraint/FilterConstraints.js";
4
+ import { getData } from "../util/data.js";
5
+ import { runSequence } from "../util/sequence.js";
6
+ /** Get the ID from item data. */
7
+ export const getID = ({ id }) => id;
8
+ /** Get the IDs of an iterable set item data. */
9
+ export function* getIDs(entities) {
10
+ for (const { id } of entities)
11
+ yield id;
12
+ }
13
+ /** Get a `FilterConstraints` instance that targets a single item by its ID. */
14
+ export const getItemConstraints = (id) => new QueryConstraints(new FilterConstraints(new FilterConstraint("id", id)), undefined, 1);
5
15
  /** Reference to an item in a synchronous or asynchronous database. */
6
16
  class BaseItem {
7
17
  /** Get a set change for this item. */
8
18
  getSet(data) {
9
- return this.db.getSet(this.collection, this.id, data);
19
+ return { action: "SET", collection: this.collection, id: this.id, data };
10
20
  }
11
21
  /** Get an update change for this item. */
12
22
  getUpdate(updates) {
13
- return this.db.getUpdate(this.collection, this.id, updates);
23
+ return { action: "UPDATE", collection: this.collection, id: this.id, updates };
14
24
  }
15
25
  /** Get a delete change for this item. */
16
26
  getDelete() {
17
- return this.db.getDelete(this.collection, this.id);
27
+ return { action: "DELETE", collection: this.collection, id: this.id };
18
28
  }
19
29
  // Implement toString()
20
30
  toString() {
@@ -26,77 +36,60 @@ class BaseItem {
26
36
  }
27
37
  // Implement AsyncIterable
28
38
  [Symbol.asyncIterator]() {
29
- return this.db.provider.getItemSequence(this.collection, this.id)[Symbol.asyncIterator]();
39
+ return this.provider.getItemSequence(this.collection, this.id)[Symbol.asyncIterator]();
30
40
  }
31
41
  }
32
42
  /** Reference to an item in a synchronous database. */
33
43
  export class Item extends BaseItem {
34
- constructor(db, collection, id) {
44
+ constructor(provider, collection, id) {
35
45
  super();
36
- this.db = db;
46
+ this.provider = provider;
37
47
  this.collection = collection;
38
48
  this.id = id;
39
49
  }
40
- get optional() {
41
- return this.db.query(this.collection, getItemFilterConstraints(this.id), undefined, 1);
42
- }
43
50
  get exists() {
44
- return !!this.db.get(this.collection, this.id);
51
+ return !!this.provider.getItem(this.collection, this.id);
45
52
  }
46
53
  get value() {
47
- return this.db.get(this.collection, this.id);
54
+ return this.provider.getItem(this.collection, this.id);
48
55
  }
49
56
  get data() {
50
57
  return getData(this.value);
51
58
  }
52
59
  set(data) {
53
- return this.db.set(this.collection, this.id, data);
60
+ return this.provider.setItem(this.collection, this.id, data);
54
61
  }
55
62
  update(updates) {
56
- return this.db.update(this.collection, this.id, updates);
63
+ return this.provider.updateItem(this.collection, this.id, updates);
57
64
  }
58
65
  delete() {
59
- return this.db.delete(this.collection, this.id);
66
+ return this.provider.deleteItem(this.collection, this.id);
60
67
  }
61
68
  }
62
69
  /** Reference to an item in an asynchronous database. */
63
70
  export class AsyncItem extends BaseItem {
64
- constructor(db, collection, id) {
71
+ constructor(provider, collection, id) {
65
72
  super();
66
- this.db = db;
73
+ this.provider = provider;
67
74
  this.collection = collection;
68
75
  this.id = id;
69
76
  }
70
- get optional() {
71
- return this.db.query(this.collection, { id: this.id }, undefined, 1);
72
- }
73
77
  get exists() {
74
- return this.db.get(this.collection, this.id).then(Boolean);
78
+ return this.provider.getItem(this.collection, this.id).then(Boolean);
75
79
  }
76
80
  get value() {
77
- return this.db.get(this.collection, this.id);
81
+ return this.provider.getItem(this.collection, this.id);
78
82
  }
79
83
  get data() {
80
84
  return this.value.then(getData);
81
85
  }
82
86
  set(data) {
83
- return this.db.set(this.collection, this.id, data);
87
+ return this.provider.setItem(this.collection, this.id, data);
84
88
  }
85
89
  update(updates) {
86
- return this.db.update(this.collection, this.id, updates);
90
+ return this.provider.updateItem(this.collection, this.id, updates);
87
91
  }
88
92
  delete() {
89
- return this.db.delete(this.collection, this.id);
93
+ return this.provider.deleteItem(this.collection, this.id);
90
94
  }
91
95
  }
92
- /** Get the ID from item data. */
93
- export const getID = ({ id }) => id;
94
- /** Get the IDs of an iterable set item data. */
95
- export function* getIDs(entities) {
96
- for (const { id } of entities)
97
- yield id;
98
- }
99
- /** Get a `FilterConstraints` instance that targets a single item by its ID. */
100
- export function getItemFilterConstraints(id) {
101
- return new FilterConstraints(new FilterConstraint("id", id));
102
- }
package/db/ItemState.d.ts CHANGED
@@ -1,17 +1,17 @@
1
- import { DataKey, Datas } from "../util/data.js";
1
+ import { Data } from "../util/data.js";
2
2
  import { Dispatch } from "../util/function.js";
3
3
  import { State } from "../state/State.js";
4
4
  import { BooleanState } from "../state/BooleanState.js";
5
5
  import { ItemValue, Item, AsyncItem, ItemData } from "./Item.js";
6
6
  /** Hold the current state of a item. */
7
- export declare class ItemState<T extends Datas, K extends DataKey<T> = DataKey<T>> extends State<ItemValue<T[K]>> {
8
- readonly ref: Item<T, K> | AsyncItem<T, K>;
7
+ export declare class ItemState<T extends Data = Data> extends State<ItemValue<T>> {
8
+ readonly ref: Item<T> | AsyncItem<T>;
9
9
  readonly busy: BooleanState;
10
10
  /** Get the data of the item (throws `RequiredError` if item doesn't exist). */
11
- get data(): ItemData<T[K]>;
11
+ get data(): ItemData<T>;
12
12
  /** Does the item exist (i.e. its value isn't `null`)? */
13
13
  get exists(): boolean;
14
- constructor(ref: Item<T, K> | AsyncItem<T, K>);
14
+ constructor(ref: Item<T> | AsyncItem<T>);
15
15
  /** Refresh this state from the source provider. */
16
16
  readonly refresh: () => void;
17
17
  private _refresh;
package/db/ItemState.js CHANGED
@@ -15,9 +15,9 @@ export class ItemState extends State {
15
15
  return !!this.value;
16
16
  }
17
17
  constructor(ref) {
18
- const { db, collection, id } = ref;
19
- const cache = getOptionalSource(CacheProvider, db.provider);
20
- const table = cache === null || cache === void 0 ? void 0 : cache.memory.getTable(collection);
18
+ var _a;
19
+ const { provider, collection, id } = ref;
20
+ const table = (_a = getOptionalSource(CacheProvider, provider)) === null || _a === void 0 ? void 0 : _a.memory.getTable(collection);
21
21
  const time = table ? table.getItemTime(id) : null;
22
22
  const isCached = typeof time === "number";
23
23
  super(table && isCached ? table.getItem(id) : State.NOVALUE, table ? new LazyDeferredSequence(() => this.from(table.getCachedItemSequence(id))) : undefined);
package/db/Query.d.ts CHANGED
@@ -1,20 +1,20 @@
1
- import type { DataKey, Datas } from "../util/data.js";
1
+ import type { Data } from "../util/data.js";
2
2
  import type { Dispatch, Handler, Stop } from "../util/function.js";
3
3
  import type { Updates } from "../update/DataUpdate.js";
4
4
  import type { FilterList } from "../constraint/FilterConstraint.js";
5
5
  import type { SortList } from "../constraint/SortConstraint.js";
6
+ import type { Provider, AsyncProvider } from "../provider/Provider.js";
6
7
  import { QueryConstraints } from "../constraint/QueryConstraints.js";
7
8
  import type { ItemArray, ItemValue, ItemData } from "./Item.js";
8
- import type { AsyncDatabase, Database } from "./Database.js";
9
9
  /** Reference to a set of items in a sync or async provider. */
10
- declare abstract class BaseQuery<T extends Datas = Datas, K extends DataKey<T> = DataKey<T>> extends QueryConstraints<ItemData<T[K]>> implements AsyncIterable<ItemArray<T[K]>> {
11
- abstract readonly db: Database<T> | AsyncDatabase<T>;
12
- abstract readonly collection: K;
10
+ declare abstract class BaseQuery<T extends Data = Data> extends QueryConstraints<ItemData<T>> implements AsyncIterable<ItemArray<T>> {
11
+ abstract readonly provider: Provider | AsyncProvider;
12
+ abstract readonly collection: string;
13
13
  /**
14
14
  * Get array of entities for this query.
15
15
  * @return Array of entities.
16
16
  */
17
- abstract value: ItemArray<T[K]> | PromiseLike<ItemArray<T[K]>>;
17
+ abstract value: ItemArray<T> | PromiseLike<ItemArray<T>>;
18
18
  /**
19
19
  * Count the number of results of this set of items.
20
20
  * @return Number of items matching the query (possibly promised).
@@ -29,36 +29,36 @@ declare abstract class BaseQuery<T extends Datas = Datas, K extends DataKey<T> =
29
29
  * Get the first item matched by this query or `null` if this query has no results.
30
30
  * @throws RequiredError if there were no results for this query.
31
31
  */
32
- abstract firstValue: ItemValue<T[K]> | PromiseLike<ItemValue<T[K]>>;
32
+ abstract firstValue: ItemValue<T> | PromiseLike<ItemValue<T>>;
33
33
  /**
34
34
  * Get the first item matched by this query.
35
35
  * @throws RequiredError if there were no results for this query.
36
36
  */
37
- abstract firstData: ItemData<T[K]> | PromiseLike<ItemData<T[K]>>;
37
+ abstract firstData: ItemData<T> | PromiseLike<ItemData<T>>;
38
38
  /**
39
39
  * Get the last item matched by this query or `null` if this query has no results.
40
40
  * @throws RequiredError if there were no results for this query.
41
41
  */
42
- abstract lastValue: ItemValue<T[K]> | PromiseLike<ItemValue<T[K]>>;
42
+ abstract lastValue: ItemValue<T> | PromiseLike<ItemValue<T>>;
43
43
  /**
44
44
  * Get the last item matched by this query.
45
45
  * @throws RequiredError if there were no results for this query.
46
46
  */
47
- abstract lastData: ItemData<T[K]> | PromiseLike<ItemData<T[K]>>;
47
+ abstract lastData: ItemData<T> | PromiseLike<ItemData<T>>;
48
48
  /**
49
49
  * Set all matching items to the same exact value.
50
50
  *
51
51
  * @param data Complete data to set the item to.
52
52
  * @return Nothing (possibly promised).
53
53
  */
54
- abstract set(data: T[K]): number | PromiseLike<number>;
54
+ abstract set(data: T): number | PromiseLike<number>;
55
55
  /**
56
56
  * Update all matching items with the same partial value.
57
57
  *
58
58
  * @param updates `Update` instance or set of updates to apply to every matching item.
59
59
  * @return Nothing (possibly promised).
60
60
  */
61
- abstract update(updates: Updates<T[K]>): number | PromiseLike<number>;
61
+ abstract update(updates: Updates<T>): number | PromiseLike<number>;
62
62
  /**
63
63
  * Delete all matching items.
64
64
  * @return Nothing (possibly promised).
@@ -66,39 +66,39 @@ declare abstract class BaseQuery<T extends Datas = Datas, K extends DataKey<T> =
66
66
  abstract delete(): number | PromiseLike<number>;
67
67
  toString(): string;
68
68
  /** Subscribe to this item. */
69
- subscribe(onNext?: Dispatch<[ItemArray<T[K]>]>, onError?: Handler): Stop;
70
- [Symbol.asyncIterator](): AsyncIterator<ItemArray<T[K]>>;
69
+ subscribe(onNext?: Dispatch<[ItemArray<T>]>, onError?: Handler): Stop;
70
+ [Symbol.asyncIterator](): AsyncIterator<ItemArray<T>>;
71
71
  }
72
72
  /** Reference to a set of items in a provider. */
73
- export declare class Query<T extends Datas = Datas, K extends DataKey<T> = DataKey<T>> extends BaseQuery<T, K> {
74
- readonly db: Database<T>;
75
- readonly collection: K;
76
- constructor(db: Database<T>, collection: K, filters?: FilterList<ItemData<T[K]>>, sorts?: SortList<ItemData<T[K]>>, limit?: number | null);
77
- get value(): ItemArray<T[K]>;
73
+ export declare class Query<T extends Data = Data> extends BaseQuery<T> {
74
+ readonly provider: Provider;
75
+ readonly collection: string;
76
+ constructor(provider: Provider, collection: string, filters?: FilterList<ItemData<T>>, sorts?: SortList<ItemData<T>>, limit?: number | null);
77
+ get value(): ItemArray<T>;
78
78
  get count(): number;
79
79
  get exists(): boolean;
80
- get firstValue(): ItemValue<T[K]>;
81
- get firstData(): ItemData<T[K]>;
82
- get lastValue(): ItemValue<T[K]>;
83
- get lastData(): ItemData<T[K]>;
84
- set(data: T[K]): number;
85
- update(updates: Updates<T[K]>): number;
80
+ get firstValue(): ItemValue<T>;
81
+ get firstData(): ItemData<T>;
82
+ get lastValue(): ItemValue<T>;
83
+ get lastData(): ItemData<T>;
84
+ set(data: T): number;
85
+ update(updates: Updates<T>): number;
86
86
  delete(): number;
87
87
  }
88
88
  /** Reference to a set of items in a provider. */
89
- export declare class AsyncQuery<T extends Datas = Datas, K extends DataKey<T> = DataKey<T>> extends BaseQuery<T, K> {
90
- readonly db: AsyncDatabase<T>;
91
- readonly collection: K;
92
- constructor(db: AsyncDatabase<T>, collection: K, filters?: FilterList<ItemData<T[K]>>, sorts?: SortList<ItemData<T[K]>>, limit?: number | null);
93
- get value(): Promise<ItemArray<T[K]>>;
89
+ export declare class AsyncQuery<T extends Data = Data> extends BaseQuery<T> {
90
+ readonly provider: AsyncProvider;
91
+ readonly collection: string;
92
+ constructor(provider: AsyncProvider, collection: string, filters?: FilterList<ItemData<T>>, sorts?: SortList<ItemData<T>>, limit?: number | null);
93
+ get value(): Promise<ItemArray<T>>;
94
94
  get count(): Promise<number>;
95
95
  get exists(): Promise<boolean>;
96
- get firstValue(): Promise<ItemValue<T[K]>>;
97
- get firstData(): Promise<ItemData<T[K]>>;
98
- get lastValue(): Promise<ItemValue<T[K]>>;
99
- get lastData(): Promise<ItemData<T[K]>>;
100
- set(data: T[K]): Promise<number>;
101
- update(updates: Updates<T[K]>): PromiseLike<number>;
96
+ get firstValue(): Promise<ItemValue<T>>;
97
+ get firstData(): Promise<ItemData<T>>;
98
+ get lastValue(): Promise<ItemValue<T>>;
99
+ get lastData(): Promise<ItemData<T>>;
100
+ set(data: T): Promise<number>;
101
+ update(updates: Updates<T>): PromiseLike<number>;
102
102
  delete(): PromiseLike<number>;
103
103
  }
104
104
  export {};
package/db/Query.js CHANGED
@@ -13,18 +13,18 @@ class BaseQuery extends QueryConstraints {
13
13
  }
14
14
  // Implement AsyncIterable
15
15
  [Symbol.asyncIterator]() {
16
- return this.db.provider.getQuerySequence(this.collection, this)[Symbol.asyncIterator]();
16
+ return this.provider.getQuerySequence(this.collection, this)[Symbol.asyncIterator]();
17
17
  }
18
18
  }
19
19
  /** Reference to a set of items in a provider. */
20
20
  export class Query extends BaseQuery {
21
- constructor(db, collection, filters, sorts, limit) {
21
+ constructor(provider, collection, filters, sorts, limit) {
22
22
  super(filters, sorts, limit);
23
- this.db = db;
23
+ this.provider = provider;
24
24
  this.collection = collection;
25
25
  }
26
26
  get value() {
27
- return this.db.provider.getQuery(this.collection, this);
27
+ return this.provider.getQuery(this.collection, this);
28
28
  }
29
29
  get count() {
30
30
  return this.value.length;
@@ -45,24 +45,24 @@ export class Query extends BaseQuery {
45
45
  return getLastItem(this.value);
46
46
  }
47
47
  set(data) {
48
- return this.db.provider.setQuery(this.collection, this, data);
48
+ return this.provider.setQuery(this.collection, this, data);
49
49
  }
50
50
  update(updates) {
51
- return this.db.provider.updateQuery(this.collection, this, updates);
51
+ return this.provider.updateQuery(this.collection, this, updates);
52
52
  }
53
53
  delete() {
54
- return this.db.provider.deleteQuery(this.collection, this);
54
+ return this.provider.deleteQuery(this.collection, this);
55
55
  }
56
56
  }
57
57
  /** Reference to a set of items in a provider. */
58
58
  export class AsyncQuery extends BaseQuery {
59
- constructor(db, collection, filters, sorts, limit) {
59
+ constructor(provider, collection, filters, sorts, limit) {
60
60
  super(filters, sorts, limit);
61
- this.db = db;
61
+ this.provider = provider;
62
62
  this.collection = collection;
63
63
  }
64
64
  get value() {
65
- return this.db.provider.getQuery(this.collection, this);
65
+ return this.provider.getQuery(this.collection, this);
66
66
  }
67
67
  get count() {
68
68
  return this.value.then(countArray);
@@ -83,12 +83,12 @@ export class AsyncQuery extends BaseQuery {
83
83
  return this.value.then(getLastItem);
84
84
  }
85
85
  set(data) {
86
- return this.db.provider.setQuery(this.collection, this, data);
86
+ return this.provider.setQuery(this.collection, this, data);
87
87
  }
88
88
  update(updates) {
89
- return this.db.provider.updateQuery(this.collection, this, updates);
89
+ return this.provider.updateQuery(this.collection, this, updates);
90
90
  }
91
91
  delete() {
92
- return this.db.provider.deleteQuery(this.collection, this);
92
+ return this.provider.deleteQuery(this.collection, this);
93
93
  }
94
94
  }
@@ -1,30 +1,30 @@
1
- import type { Datas, DataKey } from "../util/data.js";
1
+ import type { Data } from "../util/data.js";
2
2
  import type { Stop } from "../util/function.js";
3
3
  import type { ItemArray, ItemValue, ItemData } from "../db/Item.js";
4
4
  import type { AsyncQuery, Query } from "../db/Query.js";
5
5
  import { State } from "../state/State.js";
6
6
  import { BooleanState } from "../state/BooleanState.js";
7
7
  /** Hold the current state of a query. */
8
- export declare class QueryState<T extends Datas, K extends DataKey<T> = DataKey<T>> extends State<ItemArray<T[K]>> implements Iterable<ItemData<T[K]>> {
9
- readonly ref: Query<T, K> | AsyncQuery<T, K>;
8
+ export declare class QueryState<T extends Data = Data> extends State<ItemArray<T>> implements Iterable<ItemData<T>> {
9
+ readonly ref: Query<T> | AsyncQuery<T>;
10
10
  readonly busy: BooleanState;
11
11
  readonly limit: number;
12
12
  /** Can more items be loaded after the current result. */
13
13
  get hasMore(): boolean;
14
14
  private _hasMore;
15
15
  /** Get the first document matched by this query or `null` if this query has no items. */
16
- get firstValue(): ItemValue<T[K]>;
16
+ get firstValue(): ItemValue<T>;
17
17
  /** Get the first document matched by this query. */
18
- get firstData(): ItemData<T[K]>;
18
+ get firstData(): ItemData<T>;
19
19
  /** Get the last document matched by this query or `null` if this query has no items. */
20
- get lastValue(): ItemValue<T[K]>;
20
+ get lastValue(): ItemValue<T>;
21
21
  /** Get the last document matched by this query. */
22
- get lastData(): ItemData<T[K]>;
22
+ get lastData(): ItemData<T>;
23
23
  /** Does the document have at least one result. */
24
24
  get exists(): boolean;
25
25
  /** Get the number of items matching this query. */
26
26
  get count(): number;
27
- constructor(ref: Query<T, K> | AsyncQuery<T, K>);
27
+ constructor(ref: Query<T> | AsyncQuery<T>);
28
28
  /** Refresh this state from the source provider. */
29
29
  readonly refresh: () => void;
30
30
  private _refresh;
@@ -39,5 +39,5 @@ export declare class QueryState<T extends Datas, K extends DataKey<T> = DataKey<
39
39
  readonly loadMore: () => void;
40
40
  private _loadMore;
41
41
  /** Iterate over the items. */
42
- [Symbol.iterator](): Iterator<ItemData<T[K]>>;
42
+ [Symbol.iterator](): Iterator<ItemData<T>>;
43
43
  }
package/db/QueryState.js CHANGED
@@ -35,9 +35,9 @@ export class QueryState extends State {
35
35
  return this.value.length;
36
36
  }
37
37
  constructor(ref) {
38
- const { db, collection, limit } = ref;
39
- const cache = getOptionalSource(CacheProvider, db.provider);
40
- const table = cache === null || cache === void 0 ? void 0 : cache.memory.getTable(collection);
38
+ var _a;
39
+ const { provider, collection, limit } = ref;
40
+ const table = (_a = getOptionalSource(CacheProvider, provider)) === null || _a === void 0 ? void 0 : _a.memory.getTable(collection);
41
41
  const time = table ? table.getQueryTime(ref) : null;
42
42
  const isCached = typeof time === "number";
43
43
  super(table && isCached ? table.getQuery(ref) : State.NOVALUE, table ? new LazyDeferredSequence(() => this.from(table.getCachedQuerySequence(ref))) : undefined);
@@ -13,13 +13,13 @@ export declare class FirestoreClientProvider implements AsyncProvider {
13
13
  private readonly _firestore;
14
14
  constructor(firestore: Firestore);
15
15
  getItem(collection: string, id: string): Promise<ItemValue>;
16
- getItemSequence<K extends string>(collection: K, id: string): AsyncIterable<ItemValue>;
16
+ getItemSequence(collection: string, id: string): AsyncIterable<ItemValue>;
17
17
  addItem(collection: string, data: Data): Promise<string>;
18
18
  setItem(collection: string, id: string, data: Data): Promise<void>;
19
19
  updateItem(collection: string, id: string, updates: Updates): Promise<void>;
20
20
  deleteItem(collection: string, id: string): Promise<void>;
21
21
  getQuery(collection: string, constraints: ItemConstraints): Promise<ItemArray>;
22
- getQuerySequence<K extends string>(collection: K, constraints: ItemConstraints): AsyncIterable<ItemArray>;
22
+ getQuerySequence(collection: string, constraints: ItemConstraints): AsyncIterable<ItemArray>;
23
23
  setQuery(collection: string, constraints: ItemConstraints, data: Data): Promise<number>;
24
24
  updateQuery(collection: string, constraints: ItemConstraints, updates: Updates): Promise<number>;
25
25
  deleteQuery(collection: string, constraints: ItemConstraints): Promise<number>;
package/package.json CHANGED
@@ -11,7 +11,7 @@
11
11
  "state-management",
12
12
  "query-builder"
13
13
  ],
14
- "version": "1.89.2",
14
+ "version": "1.89.4",
15
15
  "repository": "https://github.com/dhoulb/shelving",
16
16
  "author": "Dave Houlbrooke <dave@shax.com>",
17
17
  "license": "0BSD",
@@ -1,23 +1,23 @@
1
- import type { Datas, DataKey } from "../util/data.js";
1
+ import type { Data } from "../util/data.js";
2
2
  import type { ItemArray, ItemValue, ItemConstraints } from "../db/Item.js";
3
3
  import type { Updates } from "../update/DataUpdate.js";
4
4
  import type { AsyncProvider } from "./Provider.js";
5
5
  import type { AsyncThroughProvider } from "./ThroughProvider.js";
6
6
  import { MemoryProvider } from "./MemoryProvider.js";
7
7
  /** Keep a copy of asynchronous remote data in a local synchronous cache. */
8
- export declare class CacheProvider<T extends Datas> implements AsyncThroughProvider<T> {
9
- readonly source: AsyncProvider<T>;
10
- readonly memory: MemoryProvider<T>;
11
- constructor(source: AsyncProvider<T>, cache?: MemoryProvider<T>);
12
- getItem<K extends DataKey<T>>(collection: K, id: string): Promise<ItemValue<T[K]>>;
13
- getItemSequence<K extends DataKey<T>>(collection: K, id: string): AsyncIterableIterator<ItemValue<T[K]>>;
14
- addItem<K extends DataKey<T>>(collection: K, data: T[K]): Promise<string>;
15
- setItem<K extends DataKey<T>>(collection: K, id: string, data: T[K]): Promise<void>;
16
- updateItem<K extends DataKey<T>>(collection: K, id: string, updates: Updates<T[K]>): Promise<void>;
17
- deleteItem<K extends DataKey<T>>(collection: K, id: string): Promise<void>;
18
- getQuery<K extends DataKey<T>>(collection: K, constraints: ItemConstraints<T[K]>): Promise<ItemArray<T[K]>>;
19
- getQuerySequence<K extends DataKey<T>>(collection: K, constraints: ItemConstraints<T[K]>): AsyncIterableIterator<ItemArray<T[K]>>;
20
- setQuery<K extends DataKey<T>>(collection: K, constraints: ItemConstraints<T[K]>, data: T[K]): Promise<number>;
21
- updateQuery<K extends DataKey<T>>(collection: K, constraints: ItemConstraints<T[K]>, updates: Updates<T[K]>): Promise<number>;
22
- deleteQuery<K extends DataKey<T>>(collection: K, constraints: ItemConstraints<T[K]>): Promise<number>;
8
+ export declare class CacheProvider implements AsyncThroughProvider {
9
+ readonly source: AsyncProvider;
10
+ readonly memory: MemoryProvider;
11
+ constructor(source: AsyncProvider, cache?: MemoryProvider);
12
+ getItem(collection: string, id: string): Promise<ItemValue>;
13
+ getItemSequence(collection: string, id: string): AsyncIterableIterator<ItemValue>;
14
+ addItem(collection: string, data: Data): Promise<string>;
15
+ setItem(collection: string, id: string, data: Data): Promise<void>;
16
+ updateItem(collection: string, id: string, updates: Updates): Promise<void>;
17
+ deleteItem(collection: string, id: string): Promise<void>;
18
+ getQuery(collection: string, constraints: ItemConstraints): Promise<ItemArray>;
19
+ getQuerySequence(collection: string, constraints: ItemConstraints): AsyncIterableIterator<ItemArray>;
20
+ setQuery(collection: string, constraints: ItemConstraints, data: Data): Promise<number>;
21
+ updateQuery(collection: string, constraints: ItemConstraints, updates: Updates): Promise<number>;
22
+ deleteQuery(collection: string, constraints: ItemConstraints): Promise<number>;
23
23
  }
@@ -1,40 +1,40 @@
1
- import type { Datas, DataKey } from "../util/data.js";
1
+ import type { Data } from "../util/data.js";
2
2
  import type { ItemArray, ItemConstraints, ItemValue } from "../db/Item.js";
3
3
  import type { Updates } from "../update/DataUpdate.js";
4
4
  import { Provider, AsyncProvider } from "./Provider.js";
5
5
  import type { ThroughProvider, AsyncThroughProvider } from "./ThroughProvider.js";
6
6
  /** Provider that logs operations to a source provider to the console. */
7
- declare abstract class AbstractDebugProvider<T extends Datas> {
8
- abstract readonly source: Provider<T> | AsyncProvider<T>;
9
- getItemSequence<K extends DataKey<T>>(collection: K, id: string): AsyncIterableIterator<ItemValue<T[K]>>;
10
- getQuerySequence<K extends DataKey<T>>(collection: K, constraints: ItemConstraints<T[K]>): AsyncIterableIterator<ItemArray<T[K]>>;
7
+ declare abstract class AbstractDebugProvider {
8
+ abstract readonly source: Provider | AsyncProvider;
9
+ getItemSequence(collection: string, id: string): AsyncIterableIterator<ItemValue>;
10
+ getQuerySequence(collection: string, constraints: ItemConstraints): AsyncIterableIterator<ItemArray>;
11
11
  }
12
12
  /** Provider that logs operations to a synchronous source provider to the console. */
13
- export declare class DebugProvider<T extends Datas> extends AbstractDebugProvider<T> implements ThroughProvider<T> {
14
- readonly source: Provider<T>;
15
- constructor(source: Provider<T>);
16
- getItem<K extends DataKey<T>>(collection: K, id: string): ItemValue<T[K]>;
17
- addItem<K extends DataKey<T>>(collection: K, data: T[K]): string;
18
- setItem<K extends DataKey<T>>(collection: K, id: string, data: T[K]): void;
19
- updateItem<K extends DataKey<T>>(collection: K, id: string, updates: Updates<T[K]>): void;
20
- deleteItem<K extends DataKey<T>>(collection: K, id: string): void;
21
- getQuery<K extends DataKey<T>>(collection: K, constraints: ItemConstraints<T[K]>): ItemArray<T[K]>;
22
- setQuery<K extends DataKey<T>>(collection: K, constraints: ItemConstraints<T[K]>, data: T[K]): number;
23
- updateQuery<K extends DataKey<T>>(collection: K, constraints: ItemConstraints<T[K]>, updates: Updates<T[K]>): number;
24
- deleteQuery<K extends DataKey<T>>(collection: K, constraints: ItemConstraints<T[K]>): number;
13
+ export declare class DebugProvider extends AbstractDebugProvider implements ThroughProvider {
14
+ readonly source: Provider;
15
+ constructor(source: Provider);
16
+ getItem(collection: string, id: string): ItemValue;
17
+ addItem(collection: string, data: Data): string;
18
+ setItem(collection: string, id: string, data: Data): void;
19
+ updateItem(collection: string, id: string, updates: Updates): void;
20
+ deleteItem(collection: string, id: string): void;
21
+ getQuery(collection: string, constraints: ItemConstraints): ItemArray;
22
+ setQuery(collection: string, constraints: ItemConstraints, data: Data): number;
23
+ updateQuery(collection: string, constraints: ItemConstraints, updates: Updates): number;
24
+ deleteQuery(collection: string, constraints: ItemConstraints): number;
25
25
  }
26
26
  /** Provider that logs operations to a synchronous source provider to the console. */
27
- export declare class AsyncDebugProvider<T extends Datas> extends AbstractDebugProvider<T> implements AsyncThroughProvider<T> {
28
- readonly source: AsyncProvider<T>;
29
- constructor(source: AsyncProvider<T>);
30
- getItem<K extends DataKey<T>>(collection: K, id: string): Promise<ItemValue<T[K]>>;
31
- addItem<K extends DataKey<T>>(collection: K, data: T[K]): Promise<string>;
32
- setItem<K extends DataKey<T>>(collection: K, id: string, data: T[K]): Promise<void>;
33
- updateItem<K extends DataKey<T>>(collection: K, id: string, updates: Updates<T[K]>): Promise<void>;
34
- deleteItem<K extends DataKey<T>>(collection: K, id: string): Promise<void>;
35
- getQuery<K extends DataKey<T>>(collection: K, constraints: ItemConstraints<T[K]>): Promise<ItemArray<T[K]>>;
36
- setQuery<K extends DataKey<T>>(collection: K, constraints: ItemConstraints<T[K]>, data: T[K]): Promise<number>;
37
- updateQuery<K extends DataKey<T>>(collection: K, constraints: ItemConstraints<T[K]>, updates: Updates<T[K]>): Promise<number>;
38
- deleteQuery<K extends DataKey<T>>(collection: K, constraints: ItemConstraints<T[K]>): Promise<number>;
27
+ export declare class AsyncDebugProvider extends AbstractDebugProvider implements AsyncThroughProvider {
28
+ readonly source: AsyncProvider;
29
+ constructor(source: AsyncProvider);
30
+ getItem(collection: string, id: string): Promise<ItemValue>;
31
+ addItem(collection: string, data: Data): Promise<string>;
32
+ setItem(collection: string, id: string, data: Data): Promise<void>;
33
+ updateItem(collection: string, id: string, updates: Updates): Promise<void>;
34
+ deleteItem(collection: string, id: string): Promise<void>;
35
+ getQuery(collection: string, constraints: ItemConstraints): Promise<ItemArray>;
36
+ setQuery(collection: string, constraints: ItemConstraints, data: Data): Promise<number>;
37
+ updateQuery(collection: string, constraints: ItemConstraints, updates: Updates): Promise<number>;
38
+ deleteQuery(collection: string, constraints: ItemConstraints): Promise<number>;
39
39
  }
40
40
  export {};