shelving 1.82.0 → 1.83.0

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.
Files changed (91) hide show
  1. package/constraint/Constraints.js +3 -3
  2. package/constraint/FilterConstraint.d.ts +5 -5
  3. package/constraint/SortConstraint.d.ts +2 -2
  4. package/db/Change.d.ts +12 -12
  5. package/db/Collection.d.ts +4 -4
  6. package/db/Database.d.ts +29 -29
  7. package/db/Item.d.ts +4 -4
  8. package/db/Query.d.ts +4 -4
  9. package/feedback/Feedback.d.ts +2 -2
  10. package/feedback/Feedback.js +3 -2
  11. package/firestore/client/FirestoreClientProvider.js +2 -2
  12. package/firestore/lite/FirestoreLiteProvider.js +2 -2
  13. package/firestore/server/FirestoreServerProvider.js +2 -2
  14. package/package.json +1 -1
  15. package/provider/CacheProvider.d.ts +12 -12
  16. package/provider/DebugProvider.d.ts +21 -21
  17. package/provider/MemoryProvider.d.ts +16 -16
  18. package/provider/MemoryProvider.js +3 -3
  19. package/provider/Provider.d.ts +30 -30
  20. package/provider/ThroughProvider.d.ts +23 -23
  21. package/provider/ValidationProvider.d.ts +22 -22
  22. package/provider/ValidationProvider.js +2 -2
  23. package/react/useItem.d.ts +4 -4
  24. package/react/useQuery.d.ts +4 -4
  25. package/schema/AllowSchema.d.ts +25 -24
  26. package/schema/AllowSchema.js +25 -29
  27. package/schema/ArraySchema.d.ts +2 -2
  28. package/schema/BooleanSchema.d.ts +2 -2
  29. package/schema/DataSchema.d.ts +2 -2
  30. package/schema/DataSchema.js +2 -2
  31. package/schema/DateSchema.d.ts +2 -2
  32. package/schema/DictionarySchema.d.ts +19 -0
  33. package/schema/{ObjectSchema.js → DictionarySchema.js} +6 -6
  34. package/schema/LinkSchema.d.ts +2 -2
  35. package/schema/NumberSchema.d.ts +2 -2
  36. package/schema/Schema.d.ts +10 -8
  37. package/schema/Schema.js +1 -1
  38. package/schema/StringSchema.d.ts +12 -10
  39. package/schema/index.d.ts +1 -1
  40. package/schema/index.js +1 -1
  41. package/state/ArrayState.js +4 -4
  42. package/state/DataState.js +3 -3
  43. package/state/DictionaryState.d.ts +15 -0
  44. package/state/{ObjectState.js → DictionaryState.js} +6 -6
  45. package/state/index.d.ts +2 -2
  46. package/state/index.js +2 -2
  47. package/test/basics.js +1 -1
  48. package/update/ArrayUpdate.js +2 -2
  49. package/update/DataUpdate.d.ts +10 -9
  50. package/update/DataUpdate.js +6 -4
  51. package/update/DictionaryUpdate.d.ts +29 -0
  52. package/update/{ObjectUpdate.js → DictionaryUpdate.js} +14 -14
  53. package/update/hydrations.js +2 -2
  54. package/update/index.d.ts +1 -1
  55. package/update/index.js +1 -1
  56. package/util/array.d.ts +40 -111
  57. package/util/array.js +50 -114
  58. package/util/clone.d.ts +2 -2
  59. package/util/clone.js +5 -5
  60. package/util/data.d.ts +20 -53
  61. package/util/data.js +11 -1
  62. package/util/dictionary.d.ts +39 -0
  63. package/util/dictionary.js +33 -0
  64. package/util/diff.d.ts +3 -3
  65. package/util/entry.d.ts +7 -5
  66. package/util/entry.js +8 -6
  67. package/util/filter.d.ts +0 -5
  68. package/util/filter.js +0 -3
  69. package/util/hydrate.d.ts +2 -2
  70. package/util/hydrate.js +7 -8
  71. package/util/index.d.ts +1 -0
  72. package/util/index.js +1 -0
  73. package/util/map.d.ts +28 -6
  74. package/util/map.js +22 -6
  75. package/util/merge.d.ts +3 -6
  76. package/util/merge.js +4 -6
  77. package/util/object.d.ts +77 -90
  78. package/util/object.js +23 -76
  79. package/util/set.d.ts +10 -0
  80. package/util/set.js +17 -0
  81. package/util/template.d.ts +3 -3
  82. package/util/template.js +3 -3
  83. package/util/transform.d.ts +22 -45
  84. package/util/transform.js +20 -37
  85. package/util/units.d.ts +6 -12
  86. package/util/units.js +8 -4
  87. package/util/validate.d.ts +6 -5
  88. package/util/validate.js +5 -4
  89. package/schema/ObjectSchema.d.ts +0 -19
  90. package/state/ObjectState.d.ts +0 -16
  91. package/update/ObjectUpdate.d.ts +0 -29
@@ -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,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);
@@ -1,4 +1,4 @@
1
- import { ImmutableObject } from "../util/object.js";
1
+ import type { ImmutableDictionary } from "../util/dictionary.js";
2
2
  /**
3
3
  * The `Feedback` class represents a feedback message that should be shown to the user.
4
4
  * - Basic `Feedback` is neither good nor bad, `SuccessFeedback` indicates good news, and `ErrorFeedback` indicates bad news.
@@ -24,4 +24,4 @@ export declare const isFeedback: <T extends Feedback<unknown>>(v: unknown) => v
24
24
  * Get an object of sub-messages in `{ key: message }` format from a feedback's value.
25
25
  * - Takes the `.value` property from a `Feedback` instance and looks for keyed `Feedback` instances in either `{ key: Feedback }`. `Feedback[]`, or `Map<key, Feedback>` formats.
26
26
  */
27
- export declare const getFeedbackMessages: ({ value }: Feedback) => ImmutableObject<string>;
27
+ export declare const getFeedbackMessages: ({ value }: Feedback) => ImmutableDictionary<string>;
@@ -4,9 +4,10 @@ var __decorate = (this && this.__decorate) || function (decorators, target, key,
4
4
  else for (var i = decorators.length - 1; i >= 0; i--) if (d = decorators[i]) r = (c < 3 ? d(r) : c > 3 ? d(target, key, r) : d(target, key)) || r;
5
5
  return c > 3 && r && Object.defineProperty(target, key, r), r;
6
6
  };
7
- import { isObject } from "../util/object.js";
8
7
  import { getEntries } from "../util/entry.js";
9
8
  import { setPrototype } from "../util/class.js";
9
+ import { isObject } from "../util/object.js";
10
+ import { getString } from "../util/string.js";
10
11
  /**
11
12
  * The `Feedback` class represents a feedback message that should be shown to the user.
12
13
  * - Basic `Feedback` is neither good nor bad, `SuccessFeedback` indicates good news, and `ErrorFeedback` indicates bad news.
@@ -38,5 +39,5 @@ function* _yieldFeedbackMessages(value) {
38
39
  if (isObject(value))
39
40
  for (const [k, v] of getEntries(value))
40
41
  if (isFeedback(v))
41
- yield [k, v.message];
42
+ yield [getString(k), v.message];
42
43
  }
@@ -1,6 +1,6 @@
1
1
  import { orderBy as firestoreOrderBy, where as firestoreWhere, limit as firestoreLimit, increment as firestoreIncrement, arrayUnion as firestoreArrayUnion, arrayRemove as firestoreArrayRemove, deleteField as firestoreDeleteField, collection as firestoreCollection, doc as firestoreDocument, query as firestoreQuery, onSnapshot, addDoc, setDoc, updateDoc, deleteDoc, getDoc, getDocs, } from "firebase/firestore";
2
2
  import { LazyDeferredSequence } from "../../sequence/LazyDeferredSequence.js";
3
- import { ArrayUpdate, DataUpdate, Increment, ObjectUpdate, Delete, Update } from "../../update/index.js";
3
+ import { ArrayUpdate, DataUpdate, Increment, DictionaryUpdate, Delete, Update } from "../../update/index.js";
4
4
  // Constants.
5
5
  // const ID = "__name__"; // DH: `__name__` is the entire path of the document. `__id__` is just ID.
6
6
  const ID = "__id__"; // Internal way Firestore Queries can reference the ID of the current document.
@@ -47,7 +47,7 @@ function _getItemValue(snapshot) {
47
47
  /** Convert `Update` instances into corresponding Firestore `FieldValue` instances. */
48
48
  function* _getFieldValues(updates, prefix = "") {
49
49
  for (const [key, update] of updates) {
50
- if (update instanceof DataUpdate || update instanceof ObjectUpdate) {
50
+ if (update instanceof DataUpdate || update instanceof DictionaryUpdate) {
51
51
  yield* _getFieldValues(update, `${prefix}${key}.`);
52
52
  }
53
53
  else if (update instanceof ArrayUpdate) {
@@ -1,6 +1,6 @@
1
1
  import { orderBy as firestoreOrderBy, where as firestoreWhere, limit as firestoreLimit, increment as firestoreIncrement, arrayUnion as firestoreArrayUnion, arrayRemove as firestoreArrayRemove, deleteField as firestoreDeleteField, collection as firestoreCollection, doc as firestoreDocument, query as firestoreQuery, setDoc, addDoc, updateDoc, deleteDoc, getDoc, getDocs, } from "firebase/firestore/lite";
2
2
  import { UnsupportedError } from "../../error/UnsupportedError.js";
3
- import { ArrayUpdate, DataUpdate, Increment, ObjectUpdate, Delete, Update } from "../../update/index.js";
3
+ import { ArrayUpdate, DataUpdate, Increment, DictionaryUpdate, Delete, Update } from "../../update/index.js";
4
4
  // Constants.
5
5
  // const ID = "__name__"; // DH: `__name__` is the entire path of the document. `__id__` is just ID.
6
6
  const ID = "__id__"; // Internal way Firestore Queries can reference the ID of the current document.
@@ -47,7 +47,7 @@ function _getItemValue(snapshot) {
47
47
  /** Convert `Update` instances into corresponding Firestore `FieldValue` instances. */
48
48
  function* _getFieldValues(updates, prefix = "") {
49
49
  for (const [key, update] of updates) {
50
- if (update instanceof DataUpdate || update instanceof ObjectUpdate) {
50
+ if (update instanceof DataUpdate || update instanceof DictionaryUpdate) {
51
51
  yield* _getFieldValues(update, `${prefix}${key}.`);
52
52
  }
53
53
  else if (update instanceof ArrayUpdate) {
@@ -1,6 +1,6 @@
1
1
  import { Firestore, FieldValue as FirestoreFieldValue } from "@google-cloud/firestore";
2
2
  import { LazyDeferredSequence } from "../../sequence/LazyDeferredSequence.js";
3
- import { ArrayUpdate, DataUpdate, Increment, ObjectUpdate, Delete, Update } from "../../update/index.js";
3
+ import { ArrayUpdate, DataUpdate, Increment, DictionaryUpdate, Delete, Update } from "../../update/index.js";
4
4
  // Constants.
5
5
  // const ID = "__name__"; // DH: `__name__` is the entire path of the document. `__id__` is just ID.
6
6
  const ID = "__id__"; // Internal way Firestore Queries can reference the ID of the current document.
@@ -47,7 +47,7 @@ function _getItemValue(snapshot) {
47
47
  /** Convert `Update` instances into corresponding Firestore `FieldValue` instances. */
48
48
  function* _getFieldValues(updates, prefix = "") {
49
49
  for (const [key, update] of updates) {
50
- if (update instanceof DataUpdate || update instanceof ObjectUpdate) {
50
+ if (update instanceof DataUpdate || update instanceof DictionaryUpdate) {
51
51
  yield* _getFieldValues(update, `${prefix}${key}.`);
52
52
  }
53
53
  else if (update instanceof ArrayUpdate) {
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.83.0",
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,6 +1,6 @@
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
- import type { Updates } from "../update/DataUpdate.js";
3
+ import { Updates } from "../update/DataUpdate.js";
4
4
  import { DeferredSequence } from "../sequence/DeferredSequence.js";
5
5
  import type { Provider } from "./Provider.js";
6
6
  /**
@@ -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.
@@ -1,9 +1,9 @@
1
+ import { updateData } from "../update/DataUpdate.js";
1
2
  import { QueryConstraints } from "../constraint/QueryConstraints.js";
2
3
  import { getRandomKey } from "../util/random.js";
3
4
  import { isArrayEqual } from "../util/equal.js";
4
5
  import { RequiredError } from "../error/RequiredError.js";
5
6
  import { getArray } from "../util/array.js";
6
- import { transformData } from "../util/transform.js";
7
7
  import { DeferredSequence } from "../sequence/DeferredSequence.js";
8
8
  /**
9
9
  * Fast in-memory store for data.
@@ -135,7 +135,7 @@ export class MemoryTable {
135
135
  const item = this._data.get(id);
136
136
  if (!item)
137
137
  throw new RequiredError(`Document "${id}" does not exist`);
138
- this._data.set(id, { ...transformData(item, updates), id });
138
+ this._data.set(id, { ...updateData(item, updates), id });
139
139
  this._times.set(id, Date.now());
140
140
  this._changed.resolve();
141
141
  }
@@ -231,7 +231,7 @@ export class MemoryTable {
231
231
  let count = 0;
232
232
  for (const item of _getWriteConstraints(constraints).transform(this._data.values())) {
233
233
  const id = item.id;
234
- this._data.set(id, { ...transformData(item, updates), id });
234
+ this._data.set(id, { ...updateData(item, updates), id });
235
235
  this._times.set(id, now);
236
236
  count++;
237
237
  }