shelving 1.82.0 → 1.82.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.
@@ -1,4 +1,4 @@
1
- import { withItems, withoutItems } from "../util/array.js";
1
+ import { withArrayItems, withoutArrayItems } from "../util/array.js";
2
2
  import { Constraint } from "./Constraint.js";
3
3
  /** Type of Rule that is powered by several sub-constraints (e.g. `Filters` and `Sorts` and `Query` itself extend this). */
4
4
  export class Constraints extends Constraint {
@@ -20,12 +20,12 @@ export class Constraints extends Constraint {
20
20
  }
21
21
  /** Clone this set of constraints but add additional constraints. */
22
22
  with(...constraints) {
23
- const _constraints = withItems(this._constraints, ...constraints);
23
+ const _constraints = withArrayItems(this._constraints, ...constraints);
24
24
  return _constraints !== this._constraints ? { __proto__: Object.getPrototypeOf(this), ...this, _constraints: _constraints } : this;
25
25
  }
26
26
  /** Clone this set of constraints but remove specific constraints. */
27
27
  without(...constraints) {
28
- const _constraints = withoutItems(this._constraints, ...constraints);
28
+ const _constraints = withoutArrayItems(this._constraints, ...constraints);
29
29
  return _constraints !== this._constraints ? { __proto__: Object.getPrototypeOf(this), ...this, _constraints: _constraints } : this;
30
30
  }
31
31
  /** Iterate over the constraints. */
@@ -1,4 +1,4 @@
1
- import type { Data, Key } from "../util/data.js";
1
+ import type { Data, DataKey } from "../util/data.js";
2
2
  import type { Nullish } from "../util/null.js";
3
3
  import { ImmutableArray } from "../util/array.js";
4
4
  import { Matchable } from "../util/match.js";
@@ -6,14 +6,14 @@ import type { Constraint } from "./Constraint.js";
6
6
  /** Possible operator references. */
7
7
  export declare type FilterOperator = "IS" | "NOT" | "IN" | "OUT" | "CONTAINS" | "LT" | "LTE" | "GT" | "GTE";
8
8
  /** Format that allows filters to be specified as a string, e.g. `!name` means `name is not` and `age>` means `age is more than` and `tags[]` means `tags array contains` */
9
- export declare type FilterKey<T extends Data> = Key<T> | `${Key<T>}` | `!${Key<T>}` | `${Key<T>}[]` | `${Key<T>}<` | `${Key<T>}<=` | `${Key<T>}>` | `${Key<T>}>=`;
9
+ export declare type FilterKey<T extends Data> = DataKey<T> | `${DataKey<T>}` | `!${DataKey<T>}` | `${DataKey<T>}[]` | `${DataKey<T>}<` | `${DataKey<T>}<=` | `${DataKey<T>}>` | `${DataKey<T>}>=`;
10
10
  /** Format that allows multiple filters to be specified as a plain object. */
11
11
  export declare type FilterProps<T extends Data> = {
12
- [K in Key<T> as `${K}` | `!${K}`]?: T[K] | ImmutableArray<T[K]>;
12
+ [K in DataKey<T> as `${K}` | `!${K}`]?: T[K] | ImmutableArray<T[K]>;
13
13
  } & {
14
- [K in Key<T> as `${K}[]`]?: Required<T>[K] extends ImmutableArray<infer X> ? X : never;
14
+ [K in DataKey<T> as `${K}[]`]?: Required<T>[K] extends ImmutableArray<infer X> ? X : never;
15
15
  } & {
16
- [K in Key<T> as `${K}<` | `${K}<=` | `${K}>` | `${K}>=`]?: T[K];
16
+ [K in DataKey<T> as `${K}<` | `${K}<=` | `${K}>` | `${K}>=`]?: T[K];
17
17
  };
18
18
  /** List of filters in a flexible format. */
19
19
  export declare type FilterList<T extends Data> = Nullish<FilterProps<T> | FilterConstraint<T>> | Iterable<FilterList<T>>;
@@ -1,4 +1,4 @@
1
- import { getProp } from "../util/object.js";
1
+ import { getObjectProp } from "../util/object.js";
2
2
  import { assert } from "../util/assert.js";
3
3
  import { limitItems } from "../util/iterate.js";
4
4
  import { FilterConstraints } from "./FilterConstraints.js";
@@ -96,7 +96,7 @@ function* _getAfterFilters(sorts, item) {
96
96
  for (const sort of sorts) {
97
97
  const { key, direction } = sort;
98
98
  const filterKey = direction === "ASC" ? (sort === lastSort ? `${key}>` : `${key}>=`) : sort === lastSort ? `${key}<` : `${key}<=`;
99
- yield new FilterConstraint(filterKey, getProp(item, key));
99
+ yield new FilterConstraint(filterKey, getObjectProp(item, key));
100
100
  }
101
101
  }
102
102
  function* _getBeforeFilters(sorts, item) {
@@ -105,6 +105,6 @@ function* _getBeforeFilters(sorts, item) {
105
105
  for (const sort of sorts) {
106
106
  const { key, direction } = sort;
107
107
  const filterKey = direction === "ASC" ? (sort === lastSort ? `${key}<` : `${key}<=`) : sort === lastSort ? `${key}>` : `${key}>=`;
108
- yield new FilterConstraint(filterKey, getProp(item, key));
108
+ yield new FilterConstraint(filterKey, getObjectProp(item, key));
109
109
  }
110
110
  }
@@ -1,10 +1,10 @@
1
1
  import type { ImmutableArray } from "../util/array.js";
2
- import type { Data, Key } from "../util/data.js";
2
+ import type { Data, DataKey } from "../util/data.js";
3
3
  import type { Nullish } from "../util/null.js";
4
4
  import { Rankable } from "../util/sort.js";
5
5
  import type { Constraint } from "./Constraint.js";
6
6
  /** Format that allows sorts to be set as a plain string, e.g. `name` sorts by name in ascending order and `!date` sorts by date in descending order. */
7
- export declare type SortKey<T extends Data> = Key<T> | `${Key<T>}` | `!${Key<T>}`;
7
+ export declare type SortKey<T extends Data> = DataKey<T> | `${DataKey<T>}` | `!${DataKey<T>}`;
8
8
  /** One or more sort keys. */
9
9
  export declare type SortKeys<T extends Data> = SortKey<T> | ImmutableArray<SortKey<T>>;
10
10
  /** Possible operator references. */
package/db/Change.d.ts CHANGED
@@ -1,4 +1,4 @@
1
- import type { Data, Datas, Key } from "../util/data.js";
1
+ import type { Data, Datas, DataKey } from "../util/data.js";
2
2
  import type { ImmutableArray } from "../util/array.js";
3
3
  import type { Provider, AsyncProvider } from "../provider/Provider.js";
4
4
  import { Updates } from "../update/DataUpdate.js";
@@ -6,42 +6,42 @@ import { Nullish } from "../util/null.js";
6
6
  import { DeepIterable } from "../util/iterate.js";
7
7
  import type { ItemConstraints, ItemData } from "./Item.js";
8
8
  /** Change on a collection. */
9
- export interface Change<T extends Datas, K extends Key<T> = Key<T>> {
9
+ export interface Change<T extends Datas, K extends DataKey<T> = DataKey<T>> {
10
10
  readonly action: string;
11
11
  readonly collection: K;
12
12
  }
13
13
  /** Add on an item. */
14
- export interface AddChange<T extends Datas, K extends Key<T> = Key<T>> extends Change<T, K> {
14
+ export interface AddChange<T extends Datas, K extends DataKey<T> = DataKey<T>> extends Change<T, K> {
15
15
  readonly action: "ADD";
16
16
  readonly data: T[K];
17
17
  }
18
18
  /** Set on an item. */
19
- export interface SetChange<T extends Datas, K extends Key<T> = Key<T>> extends Change<T, K> {
19
+ export interface SetChange<T extends Datas, K extends DataKey<T> = DataKey<T>> extends Change<T, K> {
20
20
  readonly action: "SET";
21
21
  readonly id: string;
22
22
  readonly data: T[K];
23
23
  }
24
24
  /** Update change on an item. */
25
- export interface UpdateChange<T extends Datas, K extends Key<T> = Key<T>> extends Change<T, K> {
25
+ export interface UpdateChange<T extends Datas, K extends DataKey<T> = DataKey<T>> extends Change<T, K> {
26
26
  readonly action: "UPDATE";
27
27
  readonly id: string;
28
28
  readonly updates: Updates<T[K]>;
29
29
  }
30
30
  /** Delete change on an item. */
31
- export interface DeleteChange<T extends Datas, K extends Key<T> = Key<T>> extends Change<T, K> {
31
+ export interface DeleteChange<T extends Datas, K extends DataKey<T> = DataKey<T>> extends Change<T, K> {
32
32
  readonly action: "DELETE";
33
33
  readonly id: string;
34
34
  }
35
35
  /** Set, update, or delete change on an item. */
36
- export declare type ItemChange<T extends Datas, K extends Key<T> = Key<T>> = SetChange<T, K> | UpdateChange<T, K> | DeleteChange<T, K>;
36
+ export declare type ItemChange<T extends Datas, K extends DataKey<T> = DataKey<T>> = SetChange<T, K> | UpdateChange<T, K> | DeleteChange<T, K>;
37
37
  /** Array of item changes. */
38
- export declare type ItemChanges<T extends Datas, K extends Key<T> = Key<T>> = ImmutableArray<ItemChange<T, K>>;
38
+ export declare type ItemChanges<T extends Datas, K extends DataKey<T> = DataKey<T>> = ImmutableArray<ItemChange<T, K>>;
39
39
  /** Write change on an item. */
40
- export declare type WriteChange<T extends Datas, K extends Key<T> = Key<T>> = ItemChange<T, K> | AddChange<T, K>;
40
+ export declare type WriteChange<T extends Datas, K extends DataKey<T> = DataKey<T>> = ItemChange<T, K> | AddChange<T, K>;
41
41
  /** Array of write changes. */
42
- export declare type WriteChanges<T extends Datas, K extends Key<T> = Key<T>> = ImmutableArray<WriteChange<T, K>>;
42
+ export declare type WriteChanges<T extends Datas, K extends DataKey<T> = DataKey<T>> = ImmutableArray<WriteChange<T, K>>;
43
43
  /** Apply a set of changes to a synchronous provider. */
44
- export declare function changeProvider<T extends Datas, K extends Key<T>>(provider: Provider<T>, ...changes: DeepIterable<Nullish<WriteChange<T, K>>>[]): ItemChanges<T, K>;
44
+ export declare function changeProvider<T extends Datas, K extends DataKey<T>>(provider: Provider<T>, ...changes: DeepIterable<Nullish<WriteChange<T, K>>>[]): ItemChanges<T, K>;
45
45
  /** Apply a set of changes to an asynchronous provider. */
46
- export declare function changeAsyncProvider<T extends Datas, K extends Key<T>>(provider: AsyncProvider<T>, ...changes: DeepIterable<Nullish<WriteChange<T, K>>>[]): Promise<ItemChanges<T, K>>;
46
+ export declare function changeAsyncProvider<T extends Datas, K extends DataKey<T>>(provider: AsyncProvider<T>, ...changes: DeepIterable<Nullish<WriteChange<T, K>>>[]): Promise<ItemChanges<T, K>>;
47
47
  export declare function _getItemConstraint<T extends Data>(id: string): ItemConstraints<ItemData<T>>;
@@ -1,4 +1,4 @@
1
- import type { Datas, Key } from "../util/data.js";
1
+ import type { Datas, DataKey } from "../util/data.js";
2
2
  import type { Nullish } from "../util/null.js";
3
3
  import type { FilterList } from "../constraint/FilterConstraint.js";
4
4
  import type { SortList } from "../constraint/SortConstraint.js";
@@ -9,7 +9,7 @@ import { ItemData, AsyncItem, Item, ItemValue } from "./Item.js";
9
9
  import { AsyncQuery, Query } from "./Query.js";
10
10
  import { AddChange, ItemChanges, WriteChange, UpdateChange, DeleteChange, SetChange } from "./Change.js";
11
11
  /** Reference to a collection in a synchronous or asynchronous provider. */
12
- declare abstract class BaseCollection<T extends Datas = Datas, K extends Key<T> = Key<T>> {
12
+ declare abstract class BaseCollection<T extends Datas = Datas, K extends DataKey<T> = DataKey<T>> {
13
13
  abstract readonly db: Database<T> | AsyncDatabase<T>;
14
14
  abstract readonly collection: K;
15
15
  /** Create a query on this item's collection. */
@@ -39,7 +39,7 @@ declare abstract class BaseCollection<T extends Datas = Datas, K extends Key<T>
39
39
  toString(): K;
40
40
  }
41
41
  /** Reference to a collection in a synchronous provider. */
42
- export declare class Collection<T extends Datas = Datas, K extends Key<T> = Key<T>> extends BaseCollection<T, K> {
42
+ export declare class Collection<T extends Datas = Datas, K extends DataKey<T> = DataKey<T>> extends BaseCollection<T, K> {
43
43
  readonly db: Database<T>;
44
44
  readonly collection: K;
45
45
  constructor(db: Database<T>, collection: K);
@@ -53,7 +53,7 @@ export declare class Collection<T extends Datas = Datas, K extends Key<T> = Key<
53
53
  delete(id: string): void;
54
54
  }
55
55
  /** Reference to a collection in an asynchronous provider. */
56
- export declare class AsyncCollection<T extends Datas = Datas, K extends Key<T> = Key<T>> extends BaseCollection<T, K> {
56
+ export declare class AsyncCollection<T extends Datas = Datas, K extends DataKey<T> = DataKey<T>> extends BaseCollection<T, K> {
57
57
  readonly db: AsyncDatabase<T>;
58
58
  readonly collection: K;
59
59
  constructor(db: AsyncDatabase<T>, collection: K);
package/db/Database.d.ts CHANGED
@@ -1,4 +1,4 @@
1
- import type { Key, Datas } from "../util/data.js";
1
+ import type { DataKey, Datas } from "../util/data.js";
2
2
  import type { Nullish } from "../util/null.js";
3
3
  import type { DeepIterable } from "../util/iterate.js";
4
4
  import type { AsyncProvider, Provider } from "../provider/Provider.js";
@@ -14,58 +14,58 @@ import { AddChange, DeleteChange, ItemChanges, SetChange, UpdateChange, WriteCha
14
14
  declare abstract class BaseDatabase<T extends Datas> {
15
15
  abstract readonly provider: Provider<T> | AsyncProvider<T>;
16
16
  /** Create a query on a collection in this database. */
17
- abstract collection<K extends Key<T>>(collection: K): Collection<T, K> | AsyncCollection<T, K>;
17
+ abstract collection<K extends DataKey<T>>(collection: K): Collection<T, K> | AsyncCollection<T, K>;
18
18
  /** Create a query on a collection in this database. */
19
- abstract query<K extends Key<T>>(collection: K, filters?: FilterList<Partial<ItemData<T[K]>>>, sorts?: SortList<Partial<ItemData<T[K]>>>, limit?: number | null): Query<T, K> | AsyncQuery<T, K>;
19
+ abstract query<K extends DataKey<T>>(collection: K, filters?: FilterList<Partial<ItemData<T[K]>>>, sorts?: SortList<Partial<ItemData<T[K]>>>, limit?: number | null): Query<T, K> | AsyncQuery<T, K>;
20
20
  /** Reference an item in a collection in this database. */
21
- abstract item<K extends Key<T>>(collection: K, id: string): Item<T, K> | AsyncItem<T, K>;
21
+ abstract item<K extends DataKey<T>>(collection: K, id: string): Item<T, K> | AsyncItem<T, K>;
22
22
  /** Run a set of changes in this database. */
23
23
  abstract change(...changes: DeepIterable<Nullish<WriteChange<T>>>[]): ItemChanges<T> | Promise<ItemChanges<T>>;
24
24
  /** Get a document from a collection in this database. */
25
- abstract get<K extends Key<T>>(collection: K, id: string): ItemValue<T[K]> | Promise<ItemValue<T[K]>>;
25
+ abstract get<K extends DataKey<T>>(collection: K, id: string): ItemValue<T[K]> | Promise<ItemValue<T[K]>>;
26
26
  /** Add a document to a collection in this database. */
27
- abstract add<K extends Key<T>>(collection: K, data: T[K]): string | Promise<string>;
27
+ abstract add<K extends DataKey<T>>(collection: K, data: T[K]): string | Promise<string>;
28
28
  /** Set a document in a collection in this database. */
29
- abstract set<K extends Key<T>>(collection: K, id: string, data: T[K]): void | Promise<void>;
29
+ abstract set<K extends DataKey<T>>(collection: K, id: string, data: T[K]): void | Promise<void>;
30
30
  /** Update a document in a collection in this database. */
31
- abstract update<K extends Key<T>>(collection: K, id: string, updates: Updates<T[K]>): void | Promise<void>;
31
+ abstract update<K extends DataKey<T>>(collection: K, id: string, updates: Updates<T[K]>): void | Promise<void>;
32
32
  /** Delete a document from a collection in this database. */
33
- abstract delete<K extends Key<T>>(collection: K, id: string): void | Promise<void>;
33
+ abstract delete<K extends DataKey<T>>(collection: K, id: string): void | Promise<void>;
34
34
  /** Get an add change for a collection in this database. */
35
- getAdd<K extends Key<T>>(collection: K, data: T[K]): AddChange<T, K>;
35
+ getAdd<K extends DataKey<T>>(collection: K, data: T[K]): AddChange<T, K>;
36
36
  /** Get a set change for a collection in this database. */
37
- getSet<K extends Key<T>>(collection: K, id: string, data: T[K]): SetChange<T, K>;
37
+ getSet<K extends DataKey<T>>(collection: K, id: string, data: T[K]): SetChange<T, K>;
38
38
  /** Get an update change for a collection in this database. */
39
- getUpdate<K extends Key<T>>(collection: K, id: string, updates: Updates<T[K]>): UpdateChange<T, K>;
39
+ getUpdate<K extends DataKey<T>>(collection: K, id: string, updates: Updates<T[K]>): UpdateChange<T, K>;
40
40
  /** Get a delete change for a collection in this database. */
41
- getDelete<K extends Key<T>>(collection: K, id: string): DeleteChange<T, K>;
41
+ getDelete<K extends DataKey<T>>(collection: K, id: string): DeleteChange<T, K>;
42
42
  }
43
43
  /** Database with a synchronous provider. */
44
44
  export declare class Database<T extends Datas = Datas> extends BaseDatabase<T> {
45
45
  readonly provider: Provider<T>;
46
46
  constructor(provider: Provider<T>);
47
- collection<K extends Key<T>>(collection: K): Collection<T, K>;
48
- query<K extends Key<T>>(collection: K, filters?: FilterList<Partial<ItemData<T[K]>>>, sorts?: SortList<Partial<ItemData<T[K]>>>, limit?: number | null): Query<T, K>;
49
- item<K extends Key<T>>(collection: K, id: string): Item<T, K>;
47
+ collection<K extends DataKey<T>>(collection: K): Collection<T, K>;
48
+ query<K extends DataKey<T>>(collection: K, filters?: FilterList<Partial<ItemData<T[K]>>>, sorts?: SortList<Partial<ItemData<T[K]>>>, limit?: number | null): Query<T, K>;
49
+ item<K extends DataKey<T>>(collection: K, id: string): Item<T, K>;
50
50
  change(...changes: DeepIterable<Nullish<WriteChange<T>>>[]): ItemChanges<T>;
51
- get<K extends Key<T>>(collection: K, id: string): ItemValue<T[K]>;
52
- add<K extends Key<T>>(collection: K, data: T[K]): string;
53
- set<K extends Key<T>>(collection: K, id: string, data: T[K]): void;
54
- update<K extends Key<T>>(collection: K, id: string, updates: Updates<T[K]>): void;
55
- delete<K extends Key<T>>(collection: K, id: string): void;
51
+ get<K extends DataKey<T>>(collection: K, id: string): ItemValue<T[K]>;
52
+ add<K extends DataKey<T>>(collection: K, data: T[K]): string;
53
+ set<K extends DataKey<T>>(collection: K, id: string, data: T[K]): void;
54
+ update<K extends DataKey<T>>(collection: K, id: string, updates: Updates<T[K]>): void;
55
+ delete<K extends DataKey<T>>(collection: K, id: string): void;
56
56
  }
57
57
  /** Database with a synchronous provider. */
58
58
  export declare class AsyncDatabase<T extends Datas = Datas> extends BaseDatabase<T> {
59
59
  readonly provider: AsyncProvider<T>;
60
60
  constructor(provider: AsyncProvider<T>);
61
- collection<K extends Key<T>>(collection: K): AsyncCollection<T, K>;
62
- query<K extends Key<T>>(collection: K, filters?: FilterList<Partial<ItemData<T[K]>>>, sorts?: SortList<Partial<ItemData<T[K]>>>, limit?: number | null): AsyncQuery<T, K>;
63
- item<K extends Key<T>>(collection: K, id: string): AsyncItem<T, K>;
61
+ collection<K extends DataKey<T>>(collection: K): AsyncCollection<T, K>;
62
+ query<K extends DataKey<T>>(collection: K, filters?: FilterList<Partial<ItemData<T[K]>>>, sorts?: SortList<Partial<ItemData<T[K]>>>, limit?: number | null): AsyncQuery<T, K>;
63
+ item<K extends DataKey<T>>(collection: K, id: string): AsyncItem<T, K>;
64
64
  change(...changes: DeepIterable<Nullish<WriteChange<T>>>[]): Promise<ItemChanges<T>>;
65
- get<K extends Key<T>>(collection: K, id: string): Promise<ItemValue<T[K]>>;
66
- add<K extends Key<T>>(collection: K, data: T[K]): Promise<string>;
67
- set<K extends Key<T>>(collection: K, id: string, data: T[K]): Promise<void>;
68
- update<K extends Key<T>>(collection: K, id: string, updates: Updates<T[K]>): Promise<void>;
69
- delete<K extends Key<T>>(collection: K, id: string): Promise<void>;
65
+ get<K extends DataKey<T>>(collection: K, id: string): Promise<ItemValue<T[K]>>;
66
+ add<K extends DataKey<T>>(collection: K, data: T[K]): Promise<string>;
67
+ set<K extends DataKey<T>>(collection: K, id: string, data: T[K]): Promise<void>;
68
+ update<K extends DataKey<T>>(collection: K, id: string, updates: Updates<T[K]>): Promise<void>;
69
+ delete<K extends DataKey<T>>(collection: K, id: string): Promise<void>;
70
70
  }
71
71
  export {};
package/db/Item.d.ts CHANGED
@@ -1,7 +1,7 @@
1
1
  import type { ImmutableArray } from "../util/array.js";
2
2
  import type { Stop, Handler, Dispatch } from "../util/function.js";
3
3
  import type { QueryConstraints } from "../constraint/QueryConstraints.js";
4
- import { Data, Datas, Key } from "../util/data.js";
4
+ import { Data, Datas, DataKey } from "../util/data.js";
5
5
  import { DataUpdate, Updates } from "../update/DataUpdate.js";
6
6
  import type { DeleteChange, SetChange, UpdateChange } from "./Change.js";
7
7
  import type { AsyncQuery, Query } from "./Query.js";
@@ -17,7 +17,7 @@ export declare type ItemArray<T extends Data = Data> = ImmutableArray<ItemData<T
17
17
  /** A set of query constraints for item data. */
18
18
  export declare type ItemConstraints<T extends Data = Data> = QueryConstraints<ItemData<T>>;
19
19
  /** Reference to an item in a synchronous or asynchronous database. */
20
- declare abstract class BaseItem<T extends Datas = Datas, K extends Key<T> = Key<T>> implements AsyncIterable<ItemValue<T[K]>> {
20
+ declare abstract class BaseItem<T extends Datas = Datas, K extends DataKey<T> = DataKey<T>> implements AsyncIterable<ItemValue<T[K]>> {
21
21
  abstract readonly db: Database<T> | AsyncDatabase<T>;
22
22
  abstract readonly collection: K;
23
23
  abstract readonly id: string;
@@ -59,7 +59,7 @@ declare abstract class BaseItem<T extends Datas = Datas, K extends Key<T> = Key<
59
59
  [Symbol.asyncIterator](): AsyncIterator<ItemValue<T[K]>>;
60
60
  }
61
61
  /** Reference to an item in a synchronous database. */
62
- export declare class Item<T extends Datas = Datas, K extends Key<T> = Key<T>> extends BaseItem<T, K> {
62
+ export declare class Item<T extends Datas = Datas, K extends DataKey<T> = DataKey<T>> extends BaseItem<T, K> {
63
63
  readonly db: Database<T>;
64
64
  readonly collection: K;
65
65
  readonly id: string;
@@ -73,7 +73,7 @@ export declare class Item<T extends Datas = Datas, K extends Key<T> = Key<T>> ex
73
73
  delete(): void;
74
74
  }
75
75
  /** Reference to an item in an asynchronous database. */
76
- export declare class AsyncItem<T extends Datas = Datas, K extends Key<T> = Key<T>> extends BaseItem<T, K> {
76
+ export declare class AsyncItem<T extends Datas = Datas, K extends DataKey<T> = DataKey<T>> extends BaseItem<T, K> {
77
77
  readonly db: AsyncDatabase<T>;
78
78
  readonly collection: K;
79
79
  readonly id: string;
package/db/Query.d.ts CHANGED
@@ -1,4 +1,4 @@
1
- import type { Key, Datas } from "../util/data.js";
1
+ import type { DataKey, Datas } 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";
@@ -7,7 +7,7 @@ import { QueryConstraints } from "../constraint/QueryConstraints.js";
7
7
  import type { ItemArray, ItemValue, ItemData } from "./Item.js";
8
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 Key<T> = Key<T>> extends QueryConstraints<ItemData<T[K]>> implements AsyncIterable<ItemArray<T[K]>> {
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
11
  abstract readonly db: Database<T> | AsyncDatabase<T>;
12
12
  abstract readonly collection: K;
13
13
  /**
@@ -70,7 +70,7 @@ declare abstract class BaseQuery<T extends Datas = Datas, K extends Key<T> = Key
70
70
  [Symbol.asyncIterator](): AsyncIterator<ItemArray<T[K]>>;
71
71
  }
72
72
  /** Reference to a set of items in a provider. */
73
- export declare class Query<T extends Datas = Datas, K extends Key<T> = Key<T>> extends BaseQuery<T, K> {
73
+ export declare class Query<T extends Datas = Datas, K extends DataKey<T> = DataKey<T>> extends BaseQuery<T, K> {
74
74
  readonly db: Database<T>;
75
75
  readonly collection: K;
76
76
  constructor(db: Database<T>, collection: K, filters?: FilterList<Partial<ItemData<T[K]>>>, sorts?: SortList<Partial<ItemData<T[K]>>>, limit?: number | null);
@@ -86,7 +86,7 @@ export declare class Query<T extends Datas = Datas, K extends Key<T> = Key<T>> e
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 Key<T> = Key<T>> extends BaseQuery<T, K> {
89
+ export declare class AsyncQuery<T extends Datas = Datas, K extends DataKey<T> = DataKey<T>> extends BaseQuery<T, K> {
90
90
  readonly db: AsyncDatabase<T>;
91
91
  readonly collection: K;
92
92
  constructor(db: AsyncDatabase<T>, collection: K, filters?: FilterList<Partial<ItemData<T[K]>>>, sorts?: SortList<Partial<ItemData<T[K]>>>, limit?: number | null);
package/package.json CHANGED
@@ -11,7 +11,7 @@
11
11
  "state-management",
12
12
  "query-builder"
13
13
  ],
14
- "version": "1.82.0",
14
+ "version": "1.82.1",
15
15
  "repository": "https://github.com/dhoulb/shelving",
16
16
  "author": "Dave Houlbrooke <dave@shax.com>",
17
17
  "license": "0BSD",
@@ -1,4 +1,4 @@
1
- import type { Datas, Key } from "../util/data.js";
1
+ import type { Datas, DataKey } 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";
@@ -9,15 +9,15 @@ export declare class CacheProvider<T extends Datas> implements AsyncThroughProvi
9
9
  readonly source: AsyncProvider<T>;
10
10
  readonly memory: MemoryProvider<T>;
11
11
  constructor(source: AsyncProvider<T>, cache?: MemoryProvider<T>);
12
- getItem<K extends Key<T>>(collection: K, id: string): Promise<ItemValue<T[K]>>;
13
- getItemSequence<K extends Key<T>>(collection: K, id: string): AsyncIterableIterator<ItemValue<T[K]>>;
14
- addItem<K extends Key<T>>(collection: K, data: T[K]): Promise<string>;
15
- setItem<K extends Key<T>>(collection: K, id: string, data: T[K]): Promise<void>;
16
- updateItem<K extends Key<T>>(collection: K, id: string, updates: Updates<T[K]>): Promise<void>;
17
- deleteItem<K extends Key<T>>(collection: K, id: string): Promise<void>;
18
- getQuery<K extends Key<T>>(collection: K, constraints: ItemConstraints<T[K]>): Promise<ItemArray<T[K]>>;
19
- getQuerySequence<K extends Key<T>>(collection: K, constraints: ItemConstraints<T[K]>): AsyncIterableIterator<ItemArray<T[K]>>;
20
- setQuery<K extends Key<T>>(collection: K, constraints: ItemConstraints<T[K]>, data: T[K]): Promise<number>;
21
- updateQuery<K extends Key<T>>(collection: K, constraints: ItemConstraints<T[K]>, updates: Updates<T[K]>): Promise<number>;
22
- deleteQuery<K extends Key<T>>(collection: K, constraints: ItemConstraints<T[K]>): Promise<number>;
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>;
23
23
  }
@@ -1,4 +1,4 @@
1
- import type { Datas, Key } from "../util/data.js";
1
+ import type { Datas, DataKey } 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";
@@ -6,35 +6,35 @@ import type { ThroughProvider, AsyncThroughProvider } from "./ThroughProvider.js
6
6
  /** Provider that logs operations to a source provider to the console. */
7
7
  declare abstract class AbstractDebugProvider<T extends Datas> {
8
8
  abstract readonly source: Provider<T> | AsyncProvider<T>;
9
- getItemSequence<K extends Key<T>>(collection: K, id: string): AsyncIterableIterator<ItemValue<T[K]>>;
10
- getQuerySequence<K extends Key<T>>(collection: K, constraints: ItemConstraints<T[K]>): AsyncIterableIterator<ItemArray<T[K]>>;
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]>>;
11
11
  }
12
12
  /** Provider that logs operations to a synchronous source provider to the console. */
13
13
  export declare class DebugProvider<T extends Datas> extends AbstractDebugProvider<T> implements ThroughProvider<T> {
14
14
  readonly source: Provider<T>;
15
15
  constructor(source: Provider<T>);
16
- getItem<K extends Key<T>>(collection: K, id: string): ItemValue<T[K]>;
17
- addItem<K extends Key<T>>(collection: K, data: T[K]): string;
18
- setItem<K extends Key<T>>(collection: K, id: string, data: T[K]): void;
19
- updateItem<K extends Key<T>>(collection: K, id: string, updates: Updates<T[K]>): void;
20
- deleteItem<K extends Key<T>>(collection: K, id: string): void;
21
- getQuery<K extends Key<T>>(collection: K, constraints: ItemConstraints<T[K]>): ItemArray<T[K]>;
22
- setQuery<K extends Key<T>>(collection: K, constraints: ItemConstraints<T[K]>, data: T[K]): number;
23
- updateQuery<K extends Key<T>>(collection: K, constraints: ItemConstraints<T[K]>, updates: Updates<T[K]>): number;
24
- deleteQuery<K extends Key<T>>(collection: K, constraints: ItemConstraints<T[K]>): number;
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;
25
25
  }
26
26
  /** Provider that logs operations to a synchronous source provider to the console. */
27
27
  export declare class AsyncDebugProvider<T extends Datas> extends AbstractDebugProvider<T> implements AsyncThroughProvider<T> {
28
28
  readonly source: AsyncProvider<T>;
29
29
  constructor(source: AsyncProvider<T>);
30
- getItem<K extends Key<T>>(collection: K, id: string): Promise<ItemValue<T[K]>>;
31
- addItem<K extends Key<T>>(collection: K, data: T[K]): Promise<string>;
32
- setItem<K extends Key<T>>(collection: K, id: string, data: T[K]): Promise<void>;
33
- updateItem<K extends Key<T>>(collection: K, id: string, updates: Updates<T[K]>): Promise<void>;
34
- deleteItem<K extends Key<T>>(collection: K, id: string): Promise<void>;
35
- getQuery<K extends Key<T>>(collection: K, constraints: ItemConstraints<T[K]>): Promise<ItemArray<T[K]>>;
36
- setQuery<K extends Key<T>>(collection: K, constraints: ItemConstraints<T[K]>, data: T[K]): Promise<number>;
37
- updateQuery<K extends Key<T>>(collection: K, constraints: ItemConstraints<T[K]>, updates: Updates<T[K]>): Promise<number>;
38
- deleteQuery<K extends Key<T>>(collection: K, constraints: ItemConstraints<T[K]>): Promise<number>;
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>;
39
39
  }
40
40
  export {};
@@ -1,4 +1,4 @@
1
- import type { Data, Datas, Key } from "../util/data.js";
1
+ import type { Data, Datas, DataKey } from "../util/data.js";
2
2
  import type { ItemArray, ItemValue, ItemData, ItemConstraints } from "../db/Item.js";
3
3
  import type { Updates } from "../update/DataUpdate.js";
4
4
  import { DeferredSequence } from "../sequence/DeferredSequence.js";
@@ -12,20 +12,20 @@ export declare class MemoryProvider<T extends Datas> implements Provider<T> {
12
12
  /** List of tables in `{ collection: Table }` format. */
13
13
  private _tables;
14
14
  /** Get a table for a collection. */
15
- getTable<K extends Key<T>>(collection: K): MemoryTable<T[K]>;
16
- getDocumentTime<K extends Key<T>>(collection: K, id: string): number | null;
17
- getItem<K extends Key<T>>(collection: K, id: string): ItemValue<T[K]>;
18
- getItemSequence<K extends Key<T>>(collection: K, id: string): AsyncIterable<ItemValue<T[K]>>;
19
- addItem<K extends Key<T>>(collection: K, data: T[K]): string;
20
- setItem<K extends Key<T>>(collection: K, id: string, data: T[K]): void;
21
- updateItem<K extends Key<T>>(collection: K, id: string, updates: Updates<T[K]>): void;
22
- deleteItem<K extends Key<T>>(collection: K, id: string): void;
23
- getQueryTime<K extends Key<T>>(collection: K, constraints: ItemConstraints<T[K]>): number | null;
24
- getQuery<K extends Key<T>>(collection: K, constraints: ItemConstraints<T[K]>): ItemArray<T[K]>;
25
- getQuerySequence<K extends Key<T>>(collection: K, constraints: ItemConstraints<T[K]>): AsyncIterable<ItemArray<T[K]>>;
26
- setQuery<K extends Key<T>>(collection: K, constraints: ItemConstraints<T[K]>, data: T[K]): number;
27
- updateQuery<K extends Key<T>>(collection: K, constraints: ItemConstraints<T[K]>, updates: Updates<T[K]>): number;
28
- deleteQuery<K extends Key<T>>(collection: K, constraints: ItemConstraints<T[K]>): number;
15
+ getTable<K extends DataKey<T>>(collection: K): MemoryTable<T[K]>;
16
+ getDocumentTime<K extends DataKey<T>>(collection: K, id: string): number | null;
17
+ getItem<K extends DataKey<T>>(collection: K, id: string): ItemValue<T[K]>;
18
+ getItemSequence<K extends DataKey<T>>(collection: K, id: string): AsyncIterable<ItemValue<T[K]>>;
19
+ addItem<K extends DataKey<T>>(collection: K, data: T[K]): string;
20
+ setItem<K extends DataKey<T>>(collection: K, id: string, data: T[K]): void;
21
+ updateItem<K extends DataKey<T>>(collection: K, id: string, updates: Updates<T[K]>): void;
22
+ deleteItem<K extends DataKey<T>>(collection: K, id: string): void;
23
+ getQueryTime<K extends DataKey<T>>(collection: K, constraints: ItemConstraints<T[K]>): number | null;
24
+ getQuery<K extends DataKey<T>>(collection: K, constraints: ItemConstraints<T[K]>): ItemArray<T[K]>;
25
+ getQuerySequence<K extends DataKey<T>>(collection: K, constraints: ItemConstraints<T[K]>): AsyncIterable<ItemArray<T[K]>>;
26
+ setQuery<K extends DataKey<T>>(collection: K, constraints: ItemConstraints<T[K]>, data: T[K]): number;
27
+ updateQuery<K extends DataKey<T>>(collection: K, constraints: ItemConstraints<T[K]>, updates: Updates<T[K]>): number;
28
+ deleteQuery<K extends DataKey<T>>(collection: K, constraints: ItemConstraints<T[K]>): number;
29
29
  }
30
30
  /**
31
31
  * An individual table of data.