shelving 1.77.0 → 1.80.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 (313) hide show
  1. package/{api → modules/api}/Resource.d.ts +0 -0
  2. package/{api → modules/api}/Resource.js +0 -0
  3. package/{api → modules/api}/index.d.ts +0 -0
  4. package/{api → modules/api}/index.js +0 -0
  5. package/{constraint → modules/constraint}/Constraint.d.ts +0 -0
  6. package/{constraint → modules/constraint}/Constraint.js +0 -0
  7. package/{constraint → modules/constraint}/Constraints.d.ts +0 -0
  8. package/{constraint → modules/constraint}/Constraints.js +2 -2
  9. package/{constraint → modules/constraint}/FilterConstraint.d.ts +1 -1
  10. package/{constraint → modules/constraint}/FilterConstraint.js +0 -0
  11. package/{constraint → modules/constraint}/FilterConstraints.d.ts +0 -0
  12. package/{constraint → modules/constraint}/FilterConstraints.js +0 -0
  13. package/{constraint → modules/constraint}/QueryConstraints.d.ts +1 -1
  14. package/{constraint → modules/constraint}/QueryConstraints.js +1 -1
  15. package/{constraint → modules/constraint}/SortConstraint.d.ts +0 -0
  16. package/{constraint → modules/constraint}/SortConstraint.js +0 -0
  17. package/{constraint → modules/constraint}/SortConstraints.d.ts +0 -0
  18. package/{constraint → modules/constraint}/SortConstraints.js +0 -0
  19. package/{constraint → modules/constraint}/index.d.ts +0 -0
  20. package/{constraint → modules/constraint}/index.js +0 -0
  21. package/{db → modules/db}/Change.d.ts +9 -12
  22. package/{db → modules/db}/Change.js +2 -2
  23. package/{db → modules/db}/Collection.d.ts +34 -6
  24. package/{db → modules/db}/Collection.js +47 -7
  25. package/modules/db/Database.d.ts +76 -0
  26. package/modules/db/Database.js +95 -0
  27. package/{db → modules/db}/Item.d.ts +9 -9
  28. package/{db → modules/db}/Item.js +19 -21
  29. package/{db → modules/db}/Query.d.ts +4 -4
  30. package/{db → modules/db}/Query.js +2 -3
  31. package/{db → modules/db}/index.d.ts +0 -0
  32. package/{db → modules/db}/index.js +0 -0
  33. package/{error → modules/error}/AssertionError.d.ts +0 -0
  34. package/{error → modules/error}/AssertionError.js +0 -0
  35. package/{error → modules/error}/ConditionError.d.ts +0 -0
  36. package/{error → modules/error}/ConditionError.js +0 -0
  37. package/{error → modules/error}/PermissionError.d.ts +0 -0
  38. package/{error → modules/error}/PermissionError.js +0 -0
  39. package/{error → modules/error}/RequiredError.d.ts +0 -0
  40. package/{error → modules/error}/RequiredError.js +0 -0
  41. package/{error → modules/error}/ThroughError.d.ts +0 -0
  42. package/{error → modules/error}/ThroughError.js +0 -0
  43. package/{error → modules/error}/UnsupportedError.d.ts +0 -0
  44. package/{error → modules/error}/UnsupportedError.js +0 -0
  45. package/{error → modules/error}/ValidationError.d.ts +0 -0
  46. package/{error → modules/error}/ValidationError.js +0 -0
  47. package/{error → modules/error}/index.d.ts +0 -0
  48. package/{error → modules/error}/index.js +0 -0
  49. package/{feedback → modules/feedback}/ErrorFeedback.d.ts +0 -0
  50. package/{feedback → modules/feedback}/ErrorFeedback.js +1 -5
  51. package/{feedback → modules/feedback}/Feedback.d.ts +0 -0
  52. package/{feedback → modules/feedback}/Feedback.js +1 -5
  53. package/{feedback → modules/feedback}/InvalidFeedback.d.ts +0 -0
  54. package/{feedback → modules/feedback}/InvalidFeedback.js +1 -5
  55. package/{feedback → modules/feedback}/SuccessFeedback.d.ts +0 -0
  56. package/{feedback → modules/feedback}/SuccessFeedback.js +1 -5
  57. package/{feedback → modules/feedback}/WarningFeedback.d.ts +0 -0
  58. package/{feedback → modules/feedback}/WarningFeedback.js +1 -5
  59. package/{feedback → modules/feedback}/hydrations.d.ts +0 -0
  60. package/{feedback → modules/feedback}/hydrations.js +0 -0
  61. package/{feedback → modules/feedback}/index.d.ts +0 -0
  62. package/{feedback → modules/feedback}/index.js +0 -0
  63. package/{firestore → modules/firestore}/client/FirestoreClientProvider.d.ts +3 -3
  64. package/{firestore → modules/firestore}/client/FirestoreClientProvider.js +4 -4
  65. package/{firestore → modules/firestore}/client/index.d.ts +0 -0
  66. package/{firestore → modules/firestore}/client/index.js +0 -0
  67. package/{firestore → modules/firestore}/lite/FirestoreLiteProvider.d.ts +3 -3
  68. package/{firestore → modules/firestore}/lite/FirestoreLiteProvider.js +4 -4
  69. package/{firestore → modules/firestore}/lite/index.d.ts +0 -0
  70. package/{firestore → modules/firestore}/lite/index.js +0 -0
  71. package/{firestore → modules/firestore}/server/FirestoreServerProvider.d.ts +3 -3
  72. package/{firestore → modules/firestore}/server/FirestoreServerProvider.js +4 -4
  73. package/{firestore → modules/firestore}/server/index.d.ts +0 -0
  74. package/{firestore → modules/firestore}/server/index.js +0 -0
  75. package/{index.d.ts → modules/index.d.ts} +0 -0
  76. package/{index.js → modules/index.js} +0 -0
  77. package/{markup → modules/markup}/index.d.ts +0 -0
  78. package/{markup → modules/markup}/index.js +0 -0
  79. package/{markup → modules/markup}/options.d.ts +0 -0
  80. package/{markup → modules/markup}/options.js +0 -0
  81. package/{markup → modules/markup}/regexp.d.ts +0 -0
  82. package/{markup → modules/markup}/regexp.js +0 -0
  83. package/{markup → modules/markup}/render.d.ts +0 -0
  84. package/{markup → modules/markup}/render.js +0 -0
  85. package/{markup → modules/markup}/rules.d.ts +0 -0
  86. package/{markup → modules/markup}/rules.js +0 -0
  87. package/{observe → modules/observe}/AbstractObserver.d.ts +0 -0
  88. package/{observe → modules/observe}/AbstractObserver.js +0 -0
  89. package/{observe → modules/observe}/AsyncObserver.d.ts +0 -0
  90. package/{observe → modules/observe}/AsyncObserver.js +0 -0
  91. package/{observe → modules/observe}/LastSubject.d.ts +0 -0
  92. package/{observe → modules/observe}/LastSubject.js +0 -0
  93. package/{observe → modules/observe}/MatchObserver.d.ts +0 -0
  94. package/{observe → modules/observe}/MatchObserver.js +0 -0
  95. package/{observe → modules/observe}/MatchableObserver.d.ts +0 -0
  96. package/{observe → modules/observe}/MatchableObserver.js +0 -0
  97. package/{observe → modules/observe}/Observable.d.ts +0 -0
  98. package/{observe → modules/observe}/Observable.js +0 -0
  99. package/{observe → modules/observe}/Observer.d.ts +0 -0
  100. package/{observe → modules/observe}/Observer.js +0 -0
  101. package/{observe → modules/observe}/OnceObserver.d.ts +0 -0
  102. package/{observe → modules/observe}/OnceObserver.js +0 -0
  103. package/{observe → modules/observe}/Subject.d.ts +0 -0
  104. package/{observe → modules/observe}/Subject.js +0 -0
  105. package/{observe → modules/observe}/ThroughObserver.d.ts +0 -0
  106. package/{observe → modules/observe}/ThroughObserver.js +0 -0
  107. package/{observe → modules/observe}/TransformObserver.d.ts +0 -0
  108. package/{observe → modules/observe}/TransformObserver.js +0 -0
  109. package/{observe → modules/observe}/TransformableObserver.d.ts +0 -0
  110. package/{observe → modules/observe}/TransformableObserver.js +0 -0
  111. package/{observe → modules/observe}/index.d.ts +0 -0
  112. package/{observe → modules/observe}/index.js +0 -0
  113. package/{observe → modules/observe}/util.d.ts +0 -0
  114. package/{observe → modules/observe}/util.js +0 -0
  115. package/{provider → modules/provider}/BatchProvider.d.ts +0 -0
  116. package/{provider → modules/provider}/BatchProvider.js +0 -0
  117. package/{provider → modules/provider}/CacheProvider.d.ts +3 -3
  118. package/{provider → modules/provider}/CacheProvider.js +6 -6
  119. package/{provider → modules/provider}/DebugProvider.d.ts +5 -5
  120. package/{provider → modules/provider}/DebugProvider.js +12 -12
  121. package/{provider → modules/provider}/MemoryProvider.d.ts +5 -5
  122. package/{provider → modules/provider}/MemoryProvider.js +9 -8
  123. package/{provider → modules/provider}/Provider.d.ts +7 -7
  124. package/{provider → modules/provider}/Provider.js +0 -0
  125. package/{provider → modules/provider}/ThroughProvider.d.ts +5 -5
  126. package/{provider → modules/provider}/ThroughProvider.js +4 -4
  127. package/{provider → modules/provider}/ValidationProvider.d.ts +11 -11
  128. package/{provider → modules/provider}/ValidationProvider.js +29 -28
  129. package/{provider → modules/provider}/index.d.ts +0 -0
  130. package/{provider → modules/provider}/index.js +0 -0
  131. package/{react → modules/react}/index.d.ts +0 -0
  132. package/{react → modules/react}/index.js +0 -0
  133. package/{react → modules/react}/useCache.d.ts +0 -0
  134. package/{react → modules/react}/useCache.js +0 -0
  135. package/{react → modules/react}/useInstance.d.ts +0 -0
  136. package/{react → modules/react}/useInstance.js +0 -0
  137. package/{react → modules/react}/useItem.d.ts +0 -0
  138. package/{react → modules/react}/useItem.js +0 -0
  139. package/{react → modules/react}/useLazy.d.ts +0 -0
  140. package/{react → modules/react}/useLazy.js +0 -0
  141. package/{react → modules/react}/useQuery.d.ts +0 -0
  142. package/{react → modules/react}/useQuery.js +0 -0
  143. package/{react → modules/react}/useReduce.d.ts +0 -0
  144. package/{react → modules/react}/useReduce.js +0 -0
  145. package/{react → modules/react}/useSubscribe.d.ts +0 -0
  146. package/{react → modules/react}/useSubscribe.js +0 -0
  147. package/{schema → modules/schema}/AllowSchema.d.ts +0 -0
  148. package/{schema → modules/schema}/AllowSchema.js +2 -2
  149. package/{schema → modules/schema}/ArraySchema.d.ts +0 -0
  150. package/{schema → modules/schema}/ArraySchema.js +0 -0
  151. package/{schema → modules/schema}/BooleanSchema.d.ts +0 -0
  152. package/{schema → modules/schema}/BooleanSchema.js +0 -0
  153. package/{schema → modules/schema}/ColorSchema.d.ts +0 -0
  154. package/{schema → modules/schema}/ColorSchema.js +0 -0
  155. package/{schema → modules/schema}/DataSchema.d.ts +5 -1
  156. package/{schema → modules/schema}/DataSchema.js +0 -0
  157. package/{schema → modules/schema}/DateSchema.d.ts +0 -0
  158. package/{schema → modules/schema}/DateSchema.js +0 -0
  159. package/{schema → modules/schema}/EmailSchema.d.ts +0 -0
  160. package/{schema → modules/schema}/EmailSchema.js +0 -0
  161. package/{schema → modules/schema}/KeySchema.d.ts +0 -0
  162. package/{schema → modules/schema}/KeySchema.js +0 -0
  163. package/{schema → modules/schema}/LinkSchema.d.ts +0 -0
  164. package/{schema → modules/schema}/LinkSchema.js +0 -0
  165. package/{schema → modules/schema}/NumberSchema.d.ts +0 -0
  166. package/{schema → modules/schema}/NumberSchema.js +0 -0
  167. package/{schema → modules/schema}/ObjectSchema.d.ts +0 -0
  168. package/{schema → modules/schema}/ObjectSchema.js +0 -0
  169. package/{schema → modules/schema}/OptionalSchema.d.ts +0 -0
  170. package/{schema → modules/schema}/OptionalSchema.js +0 -0
  171. package/{schema → modules/schema}/PhoneSchema.d.ts +0 -0
  172. package/{schema → modules/schema}/PhoneSchema.js +0 -0
  173. package/{schema → modules/schema}/RequiredSchema.d.ts +0 -0
  174. package/{schema → modules/schema}/RequiredSchema.js +0 -0
  175. package/{schema → modules/schema}/Schema.d.ts +0 -0
  176. package/{schema → modules/schema}/Schema.js +0 -0
  177. package/{schema → modules/schema}/SlugSchema.d.ts +0 -0
  178. package/{schema → modules/schema}/SlugSchema.js +0 -0
  179. package/{schema → modules/schema}/StringSchema.d.ts +0 -0
  180. package/{schema → modules/schema}/StringSchema.js +0 -0
  181. package/{schema → modules/schema}/ThroughSchema.d.ts +0 -0
  182. package/{schema → modules/schema}/ThroughSchema.js +0 -0
  183. package/{schema → modules/schema}/index.d.ts +0 -0
  184. package/{schema → modules/schema}/index.js +0 -0
  185. package/{state → modules/state}/ArrayState.d.ts +6 -8
  186. package/modules/state/ArrayState.js +28 -0
  187. package/{state → modules/state}/BooleanState.d.ts +0 -0
  188. package/{state → modules/state}/BooleanState.js +0 -0
  189. package/{state → modules/state}/DataState.d.ts +3 -3
  190. package/{state → modules/state}/DataState.js +2 -1
  191. package/{state → modules/state}/ObjectState.d.ts +1 -1
  192. package/{state → modules/state}/ObjectState.js +4 -4
  193. package/{state → modules/state}/SelfClosingState.d.ts +0 -0
  194. package/{state → modules/state}/SelfClosingState.js +0 -0
  195. package/{state → modules/state}/State.d.ts +0 -0
  196. package/{state → modules/state}/State.js +0 -0
  197. package/{state → modules/state}/index.d.ts +0 -0
  198. package/{state → modules/state}/index.js +0 -0
  199. package/{test → modules/test}/basics.d.ts +0 -0
  200. package/{test → modules/test}/basics.js +0 -0
  201. package/{test → modules/test}/index.d.ts +0 -0
  202. package/{test → modules/test}/index.js +0 -0
  203. package/{test → modules/test}/people.d.ts +0 -0
  204. package/{test → modules/test}/people.js +0 -0
  205. package/{test → modules/test}/util.d.ts +0 -0
  206. package/{test → modules/test}/util.js +0 -0
  207. package/{update → modules/update}/ArrayUpdate.d.ts +0 -0
  208. package/{update → modules/update}/ArrayUpdate.js +1 -1
  209. package/{update → modules/update}/DataUpdate.d.ts +13 -7
  210. package/{update → modules/update}/DataUpdate.js +29 -22
  211. package/{update → modules/update}/Delete.d.ts +0 -0
  212. package/{update → modules/update}/Delete.js +0 -0
  213. package/{update → modules/update}/Increment.d.ts +0 -0
  214. package/{update → modules/update}/Increment.js +0 -0
  215. package/{update → modules/update}/ObjectUpdate.d.ts +0 -0
  216. package/{update → modules/update}/ObjectUpdate.js +0 -0
  217. package/{update → modules/update}/Update.d.ts +0 -0
  218. package/{update → modules/update}/Update.js +0 -0
  219. package/modules/update/hydrations.d.ts +3 -0
  220. package/{update → modules/update}/hydrations.js +2 -2
  221. package/{update → modules/update}/index.d.ts +0 -0
  222. package/{update → modules/update}/index.js +0 -0
  223. package/{util → modules/util}/array.d.ts +6 -52
  224. package/{util → modules/util}/array.js +15 -89
  225. package/{util → modules/util}/assert.d.ts +0 -0
  226. package/{util → modules/util}/assert.js +0 -0
  227. package/{util → modules/util}/async.d.ts +0 -0
  228. package/{util → modules/util}/async.js +0 -0
  229. package/{util → modules/util}/boolean.d.ts +0 -0
  230. package/{util → modules/util}/boolean.js +0 -0
  231. package/{util → modules/util}/class.d.ts +0 -0
  232. package/{util → modules/util}/class.js +0 -0
  233. package/{util → modules/util}/clone.d.ts +0 -0
  234. package/{util → modules/util}/clone.js +0 -0
  235. package/{util → modules/util}/color.d.ts +0 -0
  236. package/{util → modules/util}/color.js +0 -0
  237. package/modules/util/data.d.ts +74 -0
  238. package/modules/util/data.js +27 -0
  239. package/{util → modules/util}/date.d.ts +0 -0
  240. package/{util → modules/util}/date.js +0 -0
  241. package/{util → modules/util}/debug.d.ts +0 -0
  242. package/{util → modules/util}/debug.js +0 -0
  243. package/{util → modules/util}/diff.d.ts +0 -0
  244. package/{util → modules/util}/diff.js +0 -0
  245. package/{util → modules/util}/entry.d.ts +2 -2
  246. package/{util → modules/util}/entry.js +0 -0
  247. package/{util → modules/util}/equal.d.ts +0 -0
  248. package/{util → modules/util}/equal.js +0 -0
  249. package/{util → modules/util}/error.d.ts +0 -0
  250. package/{util → modules/util}/error.js +0 -0
  251. package/{util → modules/util}/filter.d.ts +0 -0
  252. package/{util → modules/util}/filter.js +0 -0
  253. package/{util → modules/util}/function.d.ts +0 -0
  254. package/{util → modules/util}/function.js +0 -0
  255. package/{util → modules/util}/hydrate.d.ts +0 -0
  256. package/{util → modules/util}/hydrate.js +0 -0
  257. package/{util → modules/util}/index.d.ts +0 -0
  258. package/{util → modules/util}/index.js +0 -0
  259. package/{util → modules/util}/iterate.d.ts +0 -0
  260. package/{util → modules/util}/iterate.js +0 -0
  261. package/{util → modules/util}/jsx.d.ts +0 -0
  262. package/{util → modules/util}/jsx.js +0 -0
  263. package/{util → modules/util}/lazy.d.ts +0 -0
  264. package/{util → modules/util}/lazy.js +0 -0
  265. package/{util → modules/util}/map.d.ts +0 -0
  266. package/{util → modules/util}/map.js +0 -0
  267. package/{util → modules/util}/match.d.ts +0 -0
  268. package/{util → modules/util}/match.js +0 -0
  269. package/{util → modules/util}/merge.d.ts +0 -0
  270. package/{util → modules/util}/merge.js +0 -0
  271. package/{util → modules/util}/null.d.ts +0 -0
  272. package/{util → modules/util}/null.js +0 -0
  273. package/{util → modules/util}/number.d.ts +0 -0
  274. package/{util → modules/util}/number.js +0 -0
  275. package/modules/util/object.d.ts +110 -0
  276. package/modules/util/object.js +124 -0
  277. package/{util → modules/util}/random.d.ts +0 -0
  278. package/{util → modules/util}/random.js +0 -0
  279. package/{util → modules/util}/regexp.d.ts +0 -0
  280. package/{util → modules/util}/regexp.js +0 -0
  281. package/{util → modules/util}/serialise.d.ts +0 -0
  282. package/{util → modules/util}/serialise.js +0 -0
  283. package/{util → modules/util}/set.d.ts +0 -0
  284. package/{util → modules/util}/set.js +0 -0
  285. package/{util → modules/util}/sort.d.ts +0 -0
  286. package/{util → modules/util}/sort.js +0 -0
  287. package/{util → modules/util}/source.d.ts +0 -0
  288. package/{util → modules/util}/source.js +0 -0
  289. package/{util → modules/util}/string.d.ts +0 -0
  290. package/{util → modules/util}/string.js +0 -0
  291. package/{util → modules/util}/template.d.ts +0 -0
  292. package/{util → modules/util}/template.js +0 -0
  293. package/{util → modules/util}/timeout.d.ts +0 -0
  294. package/{util → modules/util}/timeout.js +0 -0
  295. package/{util → modules/util}/transform.d.ts +10 -14
  296. package/{util → modules/util}/transform.js +20 -8
  297. package/{util → modules/util}/undefined.d.ts +0 -0
  298. package/{util → modules/util}/undefined.js +0 -0
  299. package/{util → modules/util}/units.d.ts +0 -0
  300. package/{util → modules/util}/units.js +0 -0
  301. package/{util → modules/util}/url.d.ts +0 -0
  302. package/{util → modules/util}/url.js +0 -0
  303. package/{util → modules/util}/validate.d.ts +2 -2
  304. package/{util → modules/util}/validate.js +1 -1
  305. package/package.json +8 -8
  306. package/db/Database.d.ts +0 -42
  307. package/db/Database.js +0 -43
  308. package/state/ArrayState.js +0 -32
  309. package/update/hydrations.d.ts +0 -3
  310. package/util/data.d.ts +0 -126
  311. package/util/data.js +0 -78
  312. package/util/object.d.ts +0 -102
  313. package/util/object.js +0 -121
File without changes
File without changes
File without changes
File without changes
File without changes
@@ -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 = withItems(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 = withoutItems(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. */
@@ -11,7 +11,7 @@ export declare type FilterKey<T extends Data> = Key<T> | `${Key<T>}` | `!${Key<T
11
11
  export declare type FilterProps<T extends Data> = {
12
12
  [K in Key<T> as `${K}` | `!${K}`]?: T[K] | ImmutableArray<T[K]>;
13
13
  } & {
14
- [K in Key<T> as `${K}[]`]?: Required<T>[K] extends ReadonlyArray<infer X> ? X : never;
14
+ [K in Key<T> as `${K}[]`]?: Required<T>[K] extends ImmutableArray<infer X> ? X : never;
15
15
  } & {
16
16
  [K in Key<T> as `${K}<` | `${K}<=` | `${K}>` | `${K}>=`]?: T[K];
17
17
  };
@@ -1,4 +1,4 @@
1
- import { Data } from "../util/data.js";
1
+ import type { Data } from "../util/data.js";
2
2
  import { Filterable, FilterConstraints } from "./FilterConstraints.js";
3
3
  import { Sortable, SortConstraints } from "./SortConstraints.js";
4
4
  import { Constraint } from "./Constraint.js";
@@ -1,4 +1,4 @@
1
- import { getProp } from "../util/data.js";
1
+ import { getProp } 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";
File without changes
File without changes
@@ -1,38 +1,35 @@
1
1
  import type { Data, Datas, Key } from "../util/data.js";
2
2
  import type { ImmutableArray } from "../util/array.js";
3
3
  import type { Provider, AsyncProvider } from "../provider/Provider.js";
4
- import { DataUpdate } from "../update/DataUpdate.js";
4
+ import { Updates } from "../update/DataUpdate.js";
5
5
  import { Nullish } from "../util/null.js";
6
6
  import { DeepIterable } from "../util/iterate.js";
7
7
  import type { ItemConstraints, ItemData } from "./Item.js";
8
- export interface Change<T extends Datas> {
8
+ /** Change on a collection. */
9
+ export interface Change<T extends Datas, K extends Key<T> = Key<T>> {
9
10
  readonly action: string;
10
- readonly collection: Key<T>;
11
+ readonly collection: K;
11
12
  }
12
13
  /** Add on an item. */
13
- export interface AddChange<T extends Datas, K extends Key<T> = Key<T>> extends Change<T> {
14
+ export interface AddChange<T extends Datas, K extends Key<T> = Key<T>> extends Change<T, K> {
14
15
  readonly action: "ADD";
15
- readonly collection: K;
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> {
19
+ export interface SetChange<T extends Datas, K extends Key<T> = Key<T>> extends Change<T, K> {
20
20
  readonly action: "SET";
21
- readonly collection: K;
22
21
  readonly id: string;
23
22
  readonly data: T[K];
24
23
  }
25
24
  /** Update change on an item. */
26
- export interface UpdateChange<T extends Datas, K extends Key<T> = Key<T>> extends Change<T> {
25
+ export interface UpdateChange<T extends Datas, K extends Key<T> = Key<T>> extends Change<T, K> {
27
26
  readonly action: "UPDATE";
28
- readonly collection: K;
29
27
  readonly id: string;
30
- readonly update: DataUpdate<T[K]>;
28
+ readonly updates: Updates<T[K]>;
31
29
  }
32
30
  /** Delete change on an item. */
33
- export interface DeleteChange<T extends Datas, K extends Key<T> = Key<T>> extends Change<T> {
31
+ export interface DeleteChange<T extends Datas, K extends Key<T> = Key<T>> extends Change<T, K> {
34
32
  readonly action: "DELETE";
35
- readonly collection: K;
36
33
  readonly id: string;
37
34
  }
38
35
  /** Set, update, or delete change on an item. */
@@ -13,7 +13,7 @@ function _changeItem(change) {
13
13
  else if (action === "SET")
14
14
  this.setItem(collection, change.id, change.data);
15
15
  else if (action === "UPDATE")
16
- this.updateQuery(collection, _getItemConstraint(change.id), change.update);
16
+ this.updateQuery(collection, _getItemConstraint(change.id), change.updates);
17
17
  else if (action === "DELETE")
18
18
  this.deleteItem(collection, change.id);
19
19
  return change;
@@ -29,7 +29,7 @@ async function _changeAsyncItem(change) {
29
29
  else if (action === "SET")
30
30
  await this.setItem(collection, change.id, change.data);
31
31
  else if (action === "UPDATE")
32
- await this.updateQuery(collection, _getItemConstraint(change.id), change.update);
32
+ await this.updateQuery(collection, _getItemConstraint(change.id), change.updates);
33
33
  else if (action === "DELETE")
34
34
  await this.deleteItem(collection, change.id);
35
35
  return change;
@@ -3,10 +3,14 @@ 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";
5
5
  import type { DeepIterable } from "../util/iterate.js";
6
+ import type { Updates } from "../update/DataUpdate.js";
7
+ import type { PartialObserver } from "../observe/Observer.js";
8
+ import type { Dispatch } from "../util/function.js";
9
+ import type { Unsubscribe } from "../observe/Observable.js";
6
10
  import type { AsyncDatabase, Database } from "./Database.js";
7
- import { ItemData, AsyncItem, Item } from "./Item.js";
11
+ import { ItemData, AsyncItem, Item, ItemValue } from "./Item.js";
8
12
  import { AsyncQuery, Query } from "./Query.js";
9
- import { AddChange, ItemChanges, WriteChange } from "./Change.js";
13
+ import { AddChange, ItemChanges, WriteChange, UpdateChange, DeleteChange, SetChange } from "./Change.js";
10
14
  /** Reference to a collection in a synchronous or asynchronous provider. */
11
15
  declare abstract class BaseCollection<T extends Datas = Datas, K extends Key<T> = Key<T>> {
12
16
  abstract readonly db: Database<T> | AsyncDatabase<T>;
@@ -15,12 +19,28 @@ declare abstract class BaseCollection<T extends Datas = Datas, K extends Key<T>
15
19
  abstract query(filters?: FilterList<Partial<ItemData<T[K]>>>, sorts?: SortList<Partial<ItemData<T[K]>>>, limit?: number | null): Query<T, K> | AsyncQuery<T, K>;
16
20
  /** Create a query on this item's collection. */
17
21
  abstract item(id: string): Item<T, K> | AsyncItem<T, K>;
18
- /** Add an item to this collection. */
19
- abstract add(data: T[K]): string | Promise<string>;
20
22
  /** Run a set of changes on this database. */
21
23
  abstract change(...changes: DeepIterable<Nullish<WriteChange<T, K>>>[]): ItemChanges<T, K> | Promise<ItemChanges<T, K>>;
24
+ /** Get an item from this collection. */
25
+ abstract get(id: string): ItemValue<T[K]> | Promise<ItemValue<T[K]>>;
26
+ /** Subscribe a document from a collection in this database. */
27
+ subscribe(id: string, next: PartialObserver<ItemValue<T[K]>> | Dispatch<[ItemValue<T[K]>]>): Unsubscribe;
28
+ /** Add an item to this collection. */
29
+ abstract add(data: T[K]): string | Promise<string>;
30
+ /** Set a document in this collection. */
31
+ abstract set(id: string, data: T[K]): void | Promise<void>;
32
+ /** Update a document in this collection. */
33
+ abstract update(id: string, updates: Updates<T[K]>): void | Promise<void>;
34
+ /** Delete a document in this collection. */
35
+ abstract delete(id: string): void | Promise<void>;
22
36
  /** Get an add change for this collection. */
23
37
  getAdd(data: T[K]): AddChange<T, K>;
38
+ /** Get a set change for this collection. */
39
+ getSet(id: string, data: T[K]): SetChange<T, K>;
40
+ /** Get an update change for this collection. */
41
+ getUpdate(id: string, updates: Updates<T[K]>): UpdateChange<T, K>;
42
+ /** Get a delete change for this collection. */
43
+ getDelete(id: string): DeleteChange<T, K>;
24
44
  toString(): K;
25
45
  }
26
46
  /** Reference to a collection in a synchronous provider. */
@@ -30,8 +50,12 @@ export declare class Collection<T extends Datas = Datas, K extends Key<T> = Key<
30
50
  constructor(db: Database<T>, collection: K);
31
51
  query(filters?: FilterList<Partial<ItemData<T[K]>>>, sorts?: SortList<Partial<ItemData<T[K]>>>, limit?: number | null): Query<T, K>;
32
52
  item(id: string): Item<T, K>;
33
- add(data: T[K]): string;
34
53
  change(...changes: DeepIterable<Nullish<WriteChange<T, K>>>[]): ItemChanges<T, K>;
54
+ get(id: string): ItemValue<T[K]>;
55
+ add(data: T[K]): string;
56
+ set(id: string, data: T[K]): void;
57
+ update(id: string, updates: Updates<T[K]>): void;
58
+ delete(id: string): void;
35
59
  }
36
60
  /** Reference to a collection in an asynchronous provider. */
37
61
  export declare class AsyncCollection<T extends Datas = Datas, K extends Key<T> = Key<T>> extends BaseCollection<T, K> {
@@ -40,7 +64,11 @@ export declare class AsyncCollection<T extends Datas = Datas, K extends Key<T> =
40
64
  constructor(db: AsyncDatabase<T>, collection: K);
41
65
  query(filters?: FilterList<Partial<ItemData<T[K]>>>, sorts?: SortList<Partial<ItemData<T[K]>>>, limit?: number | null): AsyncQuery<T, K>;
42
66
  item(id: string): AsyncItem<T, K>;
43
- add(data: T[K]): Promise<string>;
44
67
  change(...changes: DeepIterable<Nullish<WriteChange<T, K>>>[]): Promise<ItemChanges<T, K>>;
68
+ get(id: string): Promise<ItemValue<T[K]>>;
69
+ add(data: T[K]): Promise<string>;
70
+ set(id: string, data: T[K]): Promise<void>;
71
+ update(id: string, updates: Updates<T[K]>): Promise<void>;
72
+ delete(id: string): Promise<void>;
45
73
  }
46
74
  export {};
@@ -3,9 +3,25 @@ import { AsyncQuery, Query } from "./Query.js";
3
3
  import { changeAsyncProvider, changeProvider } from "./Change.js";
4
4
  /** Reference to a collection in a synchronous or asynchronous provider. */
5
5
  class BaseCollection {
6
+ /** Subscribe a document from a collection in this database. */
7
+ subscribe(id, next) {
8
+ return this.db.subscribe(this.collection, id, typeof next === "function" ? { next } : next);
9
+ }
6
10
  /** Get an add change for this collection. */
7
11
  getAdd(data) {
8
- return { action: "ADD", collection: this.collection, data };
12
+ return this.db.getAdd(this.collection, data);
13
+ }
14
+ /** Get a set change for this collection. */
15
+ getSet(id, data) {
16
+ return this.db.getSet(this.collection, id, data);
17
+ }
18
+ /** Get an update change for this collection. */
19
+ getUpdate(id, updates) {
20
+ return this.db.getUpdate(this.collection, id, updates);
21
+ }
22
+ /** Get a delete change for this collection. */
23
+ getDelete(id) {
24
+ return this.db.getDelete(this.collection, id);
9
25
  }
10
26
  // Implement toString()
11
27
  toString() {
@@ -25,12 +41,24 @@ export class Collection extends BaseCollection {
25
41
  item(id) {
26
42
  return new Item(this.db, this.collection, id);
27
43
  }
28
- add(data) {
29
- return this.db.provider.addItem(this.collection, data);
30
- }
31
44
  change(...changes) {
32
45
  return changeProvider(this.db.provider, changes);
33
46
  }
47
+ get(id) {
48
+ return this.db.get(this.collection, id);
49
+ }
50
+ add(data) {
51
+ return this.db.add(this.collection, data);
52
+ }
53
+ set(id, data) {
54
+ return this.db.set(this.collection, id, data);
55
+ }
56
+ update(id, updates) {
57
+ return this.db.update(this.collection, id, updates);
58
+ }
59
+ delete(id) {
60
+ return this.db.delete(this.collection, id);
61
+ }
34
62
  }
35
63
  /** Reference to a collection in an asynchronous provider. */
36
64
  export class AsyncCollection extends BaseCollection {
@@ -45,10 +73,22 @@ export class AsyncCollection extends BaseCollection {
45
73
  item(id) {
46
74
  return new AsyncItem(this.db, this.collection, id);
47
75
  }
48
- add(data) {
49
- return this.db.provider.addItem(this.collection, data);
50
- }
51
76
  change(...changes) {
52
77
  return changeAsyncProvider(this.db.provider, changes);
53
78
  }
79
+ get(id) {
80
+ return this.db.get(this.collection, id);
81
+ }
82
+ add(data) {
83
+ return this.db.add(this.collection, data);
84
+ }
85
+ set(id, data) {
86
+ return this.db.set(this.collection, id, data);
87
+ }
88
+ update(id, updates) {
89
+ return this.db.update(this.collection, id, updates);
90
+ }
91
+ delete(id) {
92
+ return this.db.delete(this.collection, id);
93
+ }
54
94
  }
@@ -0,0 +1,76 @@
1
+ import type { Key, Datas } from "../util/data.js";
2
+ import type { Nullish } from "../util/null.js";
3
+ import type { DeepIterable } from "../util/iterate.js";
4
+ import type { AsyncProvider, Provider } from "../provider/Provider.js";
5
+ import type { FilterList } from "../constraint/FilterConstraint.js";
6
+ import type { SortList } from "../constraint/SortConstraint.js";
7
+ import type { ItemData, ItemValue } from "../db/Item.js";
8
+ import type { Updates } from "../update/DataUpdate.js";
9
+ import type { PartialObserver } from "../observe/Observer.js";
10
+ import type { Dispatch } from "../util/function.js";
11
+ import type { Unsubscribe } from "../observe/Observable.js";
12
+ import { Item, AsyncItem } from "./Item.js";
13
+ import { Query, AsyncQuery } from "./Query.js";
14
+ import { Collection, AsyncCollection } from "./Collection.js";
15
+ import { AddChange, DeleteChange, ItemChanges, SetChange, UpdateChange, WriteChange } from "./Change.js";
16
+ /** Database with a synchronous or asynchronous provider. */
17
+ declare abstract class BaseDatabase<T extends Datas> {
18
+ abstract readonly provider: Provider<T> | AsyncProvider<T>;
19
+ /** Create a query on a collection in this database. */
20
+ abstract collection<K extends Key<T>>(collection: K): Collection<T, K> | AsyncCollection<T, K>;
21
+ /** Create a query on a collection in this database. */
22
+ 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>;
23
+ /** Reference an item in a collection in this database. */
24
+ abstract item<K extends Key<T>>(collection: K, id: string): Item<T, K> | AsyncItem<T, K>;
25
+ /** Run a set of changes in this database. */
26
+ abstract change(...changes: DeepIterable<Nullish<WriteChange<T>>>[]): ItemChanges<T> | Promise<ItemChanges<T>>;
27
+ /** Get a document from a collection in this database. */
28
+ abstract get<K extends Key<T>>(collection: K, id: string): ItemValue<T[K]> | Promise<ItemValue<T[K]>>;
29
+ /** Subscribe a document from a collection in this database. */
30
+ subscribe<K extends Key<T>>(collection: K, id: string, next: PartialObserver<ItemValue<T[K]>> | Dispatch<[ItemValue<T[K]>]>): Unsubscribe;
31
+ /** Add a document to a collection in this database. */
32
+ abstract add<K extends Key<T>>(collection: K, data: T[K]): string | Promise<string>;
33
+ /** Set a document in a collection in this database. */
34
+ abstract set<K extends Key<T>>(collection: K, id: string, data: T[K]): void | Promise<void>;
35
+ /** Update a document in a collection in this database. */
36
+ abstract update<K extends Key<T>>(collection: K, id: string, updates: Updates<T[K]>): void | Promise<void>;
37
+ /** Delete a document from a collection in this database. */
38
+ abstract delete<K extends Key<T>>(collection: K, id: string): void | Promise<void>;
39
+ /** Get an add change for a collection in this database. */
40
+ getAdd<K extends Key<T>>(collection: K, data: T[K]): AddChange<T, K>;
41
+ /** Get a set change for a collection in this database. */
42
+ getSet<K extends Key<T>>(collection: K, id: string, data: T[K]): SetChange<T, K>;
43
+ /** Get an update change for a collection in this database. */
44
+ getUpdate<K extends Key<T>>(collection: K, id: string, updates: Updates<T[K]>): UpdateChange<T, K>;
45
+ /** Get a delete change for a collection in this database. */
46
+ getDelete<K extends Key<T>>(collection: K, id: string): DeleteChange<T, K>;
47
+ }
48
+ /** Database with a synchronous provider. */
49
+ export declare class Database<T extends Datas = Datas> extends BaseDatabase<T> {
50
+ readonly provider: Provider<T>;
51
+ constructor(provider: Provider<T>);
52
+ collection<K extends Key<T>>(collection: K): Collection<T, K>;
53
+ 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>;
54
+ item<K extends Key<T>>(collection: K, id: string): Item<T, K>;
55
+ change(...changes: DeepIterable<Nullish<WriteChange<T>>>[]): ItemChanges<T>;
56
+ get<K extends Key<T>>(collection: K, id: string): ItemValue<T[K]>;
57
+ add<K extends Key<T>>(collection: K, data: T[K]): string;
58
+ set<K extends Key<T>>(collection: K, id: string, data: T[K]): void;
59
+ update<K extends Key<T>>(collection: K, id: string, updates: Updates<T[K]>): void;
60
+ delete<K extends Key<T>>(collection: K, id: string): void;
61
+ }
62
+ /** Database with a synchronous provider. */
63
+ export declare class AsyncDatabase<T extends Datas = Datas> extends BaseDatabase<T> {
64
+ readonly provider: AsyncProvider<T>;
65
+ constructor(provider: AsyncProvider<T>);
66
+ collection<K extends Key<T>>(collection: K): AsyncCollection<T, K>;
67
+ 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>;
68
+ item<K extends Key<T>>(collection: K, id: string): AsyncItem<T, K>;
69
+ change(...changes: DeepIterable<Nullish<WriteChange<T>>>[]): Promise<ItemChanges<T>>;
70
+ get<K extends Key<T>>(collection: K, id: string): Promise<ItemValue<T[K]>>;
71
+ add<K extends Key<T>>(collection: K, data: T[K]): Promise<string>;
72
+ set<K extends Key<T>>(collection: K, id: string, data: T[K]): Promise<void>;
73
+ update<K extends Key<T>>(collection: K, id: string, updates: Updates<T[K]>): Promise<void>;
74
+ delete<K extends Key<T>>(collection: K, id: string): Promise<void>;
75
+ }
76
+ export {};
@@ -0,0 +1,95 @@
1
+ import { Item, AsyncItem } from "./Item.js";
2
+ import { Query, AsyncQuery } from "./Query.js";
3
+ import { Collection, AsyncCollection } from "./Collection.js";
4
+ import { changeAsyncProvider, changeProvider } from "./Change.js";
5
+ /** Database with a synchronous or asynchronous provider. */
6
+ class BaseDatabase {
7
+ /** Subscribe a document from a collection in this database. */
8
+ subscribe(collection, id, next) {
9
+ return this.provider.subscribeItem(collection, id, typeof next === "function" ? { next } : next);
10
+ }
11
+ /** Get an add change for a collection in this database. */
12
+ getAdd(collection, data) {
13
+ return { action: "ADD", collection, data };
14
+ }
15
+ /** Get a set change for a collection in this database. */
16
+ getSet(collection, id, data) {
17
+ return { action: "SET", collection, id, data };
18
+ }
19
+ /** Get an update change for a collection in this database. */
20
+ getUpdate(collection, id, updates) {
21
+ return { action: "UPDATE", collection, id, updates };
22
+ }
23
+ /** Get a delete change for a collection in this database. */
24
+ getDelete(collection, id) {
25
+ return { action: "DELETE", collection, id };
26
+ }
27
+ }
28
+ /** Database with a synchronous provider. */
29
+ export class Database extends BaseDatabase {
30
+ constructor(provider) {
31
+ super();
32
+ this.provider = provider;
33
+ }
34
+ collection(collection) {
35
+ return new Collection(this, collection);
36
+ }
37
+ query(collection, filters, sorts, limit) {
38
+ return new Query(this, collection, filters, sorts, limit);
39
+ }
40
+ item(collection, id) {
41
+ return new Item(this, collection, id);
42
+ }
43
+ change(...changes) {
44
+ return changeProvider(this.provider, changes);
45
+ }
46
+ get(collection, id) {
47
+ return this.provider.getItem(collection, id);
48
+ }
49
+ add(collection, data) {
50
+ return this.provider.addItem(collection, data);
51
+ }
52
+ set(collection, id, data) {
53
+ return this.provider.setItem(collection, id, data);
54
+ }
55
+ update(collection, id, updates) {
56
+ return this.provider.updateItem(collection, id, updates);
57
+ }
58
+ delete(collection, id) {
59
+ return this.provider.deleteItem(collection, id);
60
+ }
61
+ }
62
+ /** Database with a synchronous provider. */
63
+ export class AsyncDatabase extends BaseDatabase {
64
+ constructor(provider) {
65
+ super();
66
+ this.provider = provider;
67
+ }
68
+ collection(collection) {
69
+ return new AsyncCollection(this, collection);
70
+ }
71
+ query(collection, filters, sorts, limit) {
72
+ return new AsyncQuery(this, collection, filters, sorts, limit);
73
+ }
74
+ item(collection, id) {
75
+ return new AsyncItem(this, collection, id);
76
+ }
77
+ change(...changes) {
78
+ return changeAsyncProvider(this.provider, changes);
79
+ }
80
+ get(collection, id) {
81
+ return this.provider.getItem(collection, id);
82
+ }
83
+ add(collection, data) {
84
+ return this.provider.addItem(collection, data);
85
+ }
86
+ set(collection, id, data) {
87
+ return this.provider.setItem(collection, id, data);
88
+ }
89
+ update(collection, id, updates) {
90
+ return this.provider.updateItem(collection, id, updates);
91
+ }
92
+ delete(collection, id) {
93
+ return this.provider.deleteItem(collection, id);
94
+ }
95
+ }
@@ -3,7 +3,7 @@ import type { Dispatch } from "../util/function.js";
3
3
  import type { PartialObserver } from "../observe/Observer.js";
4
4
  import type { ImmutableArray } from "../util/array.js";
5
5
  import type { Observable, Unsubscribe } from "../observe/Observable.js";
6
- import { DataUpdate, PropUpdates } from "../update/DataUpdate.js";
6
+ import { DataUpdate, Updates } from "../update/DataUpdate.js";
7
7
  import type { QueryConstraints } from "../constraint/QueryConstraints.js";
8
8
  import type { AsyncDatabase, Database } from "./Database.js";
9
9
  import type { AsyncQuery, Query } from "./Query.js";
@@ -18,7 +18,7 @@ export declare type ItemValue<T extends Data = Data> = ItemData<T> | null;
18
18
  export declare type ItemArray<T extends Data = Data> = ImmutableArray<ItemData<T>>;
19
19
  /** A set of query constraints for item data. */
20
20
  export declare type ItemConstraints<T extends Data = Data> = QueryConstraints<ItemData<T>>;
21
- /** Reference to an item in a synchronous or asynchronous provider. */
21
+ /** Reference to an item in a synchronous or asynchronous database. */
22
22
  declare abstract class BaseItem<T extends Datas = Datas, K extends Key<T> = Key<T>> implements Observable<ItemValue<T[K]>> {
23
23
  abstract readonly db: Database<T> | AsyncDatabase<T>;
24
24
  abstract readonly collection: K;
@@ -54,18 +54,18 @@ declare abstract class BaseItem<T extends Datas = Datas, K extends Key<T> = Key<
54
54
  /** Set the complete data of this item. */
55
55
  abstract set(data: T[K]): void | PromiseLike<void>;
56
56
  /** Update this item. */
57
- abstract update(updates: DataUpdate<T[K]> | PropUpdates<T[K]>): void | PromiseLike<void>;
57
+ abstract update(updates: DataUpdate<T[K]> | Updates<T[K]>): void | PromiseLike<void>;
58
58
  /** Delete this item. */
59
59
  abstract delete(): void | PromiseLike<void>;
60
60
  /** Get a set change for this item. */
61
61
  getSet(data: T[K]): SetChange<T, K>;
62
62
  /** Get an update change for this item. */
63
- getUpdate(updates: DataUpdate<T[K]> | PropUpdates<T[K]>): UpdateChange<T, K>;
63
+ getUpdate(updates: Updates<T[K]>): UpdateChange<T, K>;
64
64
  /** Get a delete change for this item. */
65
65
  getDelete(): DeleteChange<T, K>;
66
66
  toString(): `${K}/${string}`;
67
67
  }
68
- /** Reference to an item in a synchronous provider. */
68
+ /** Reference to an item in a synchronous database. */
69
69
  export declare class Item<T extends Datas = Datas, K extends Key<T> = Key<T>> extends BaseItem<T, K> {
70
70
  readonly db: Database<T>;
71
71
  readonly collection: K;
@@ -76,21 +76,21 @@ export declare class Item<T extends Datas = Datas, K extends Key<T> = Key<T>> ex
76
76
  get value(): ItemValue<T[K]>;
77
77
  get data(): ItemData<T[K]>;
78
78
  set(data: T[K]): void;
79
- update(updates: DataUpdate<T[K]> | PropUpdates<T[K]>): void;
79
+ update(updates: Updates<T[K]>): void;
80
80
  delete(): void;
81
81
  }
82
- /** Reference to an item in an asynchronous provider. */
82
+ /** Reference to an item in an asynchronous database. */
83
83
  export declare class AsyncItem<T extends Datas = Datas, K extends Key<T> = Key<T>> extends BaseItem<T, K> {
84
84
  readonly db: AsyncDatabase<T>;
85
85
  readonly collection: K;
86
86
  readonly id: string;
87
- constructor(provider: AsyncDatabase<T>, collection: K, id: string);
87
+ constructor(db: AsyncDatabase<T>, collection: K, id: string);
88
88
  get optional(): AsyncQuery<T, K>;
89
89
  get exists(): Promise<boolean>;
90
90
  get value(): Promise<ItemValue<T[K]>>;
91
91
  get data(): Promise<ItemData<T[K]>>;
92
92
  set(data: T[K]): Promise<void>;
93
- update(updates: DataUpdate<T[K]> | PropUpdates<T[K]>): Promise<void>;
93
+ update(updates: Updates<T[K]>): Promise<void>;
94
94
  delete(): Promise<void>;
95
95
  }
96
96
  /** Get the ID from item data. */
@@ -1,8 +1,6 @@
1
1
  import { getData } from "../util/data.js";
2
2
  import { FilterConstraint } from "../constraint/FilterConstraint.js";
3
- import { DataUpdate } from "../update/DataUpdate.js";
4
- import { isTransformable } from "../util/transform.js";
5
- /** Reference to an item in a synchronous or asynchronous provider. */
3
+ /** Reference to an item in a synchronous or asynchronous database. */
6
4
  class BaseItem {
7
5
  /**
8
6
  * Subscribe to the result of this item (indefinitely).
@@ -12,26 +10,26 @@ class BaseItem {
12
10
  * @return Function that ends the subscription.
13
11
  */
14
12
  subscribe(next) {
15
- return this.db.provider.subscribeItem(this.collection, this.id, typeof next === "function" ? { next } : next);
13
+ return this.db.subscribe(this.collection, this.id, next);
16
14
  }
17
15
  /** Get a set change for this item. */
18
16
  getSet(data) {
19
- return { action: "SET", collection: this.collection, id: this.id, data };
17
+ return this.db.getSet(this.collection, this.id, data);
20
18
  }
21
19
  /** Get an update change for this item. */
22
20
  getUpdate(updates) {
23
- return { action: "UPDATE", collection: this.collection, id: this.id, update: updates instanceof DataUpdate ? updates : new DataUpdate(updates) };
21
+ return this.db.getUpdate(this.collection, this.id, updates);
24
22
  }
25
23
  /** Get a delete change for this item. */
26
24
  getDelete() {
27
- return { action: "DELETE", collection: this.collection, id: this.id };
25
+ return this.db.getDelete(this.collection, this.id);
28
26
  }
29
27
  // Implement toString()
30
28
  toString() {
31
29
  return `${this.collection}/${this.id}`;
32
30
  }
33
31
  }
34
- /** Reference to an item in a synchronous provider. */
32
+ /** Reference to an item in a synchronous database. */
35
33
  export class Item extends BaseItem {
36
34
  constructor(db, collection, id) {
37
35
  super();
@@ -43,29 +41,29 @@ export class Item extends BaseItem {
43
41
  return this.db.query(this.collection, new FilterConstraint("id", this.id), undefined, 1);
44
42
  }
45
43
  get exists() {
46
- return !!this.db.provider.getItem(this.collection, this.id);
44
+ return !!this.db.get(this.collection, this.id);
47
45
  }
48
46
  get value() {
49
- return this.db.provider.getItem(this.collection, this.id);
47
+ return this.db.get(this.collection, this.id);
50
48
  }
51
49
  get data() {
52
50
  return getData(this.value);
53
51
  }
54
52
  set(data) {
55
- return this.db.provider.setItem(this.collection, this.id, data);
53
+ return this.db.set(this.collection, this.id, data);
56
54
  }
57
55
  update(updates) {
58
- return this.db.provider.updateItem(this.collection, this.id, isTransformable(updates) ? updates : new DataUpdate(updates));
56
+ return this.db.update(this.collection, this.id, updates);
59
57
  }
60
58
  delete() {
61
- return this.db.provider.deleteItem(this.collection, this.id);
59
+ return this.db.delete(this.collection, this.id);
62
60
  }
63
61
  }
64
- /** Reference to an item in an asynchronous provider. */
62
+ /** Reference to an item in an asynchronous database. */
65
63
  export class AsyncItem extends BaseItem {
66
- constructor(provider, collection, id) {
64
+ constructor(db, collection, id) {
67
65
  super();
68
- this.db = provider;
66
+ this.db = db;
69
67
  this.collection = collection;
70
68
  this.id = id;
71
69
  }
@@ -73,22 +71,22 @@ export class AsyncItem extends BaseItem {
73
71
  return this.db.query(this.collection, new FilterConstraint("id", this.id), undefined, 1);
74
72
  }
75
73
  get exists() {
76
- return this.db.provider.getItem(this.collection, this.id).then(Boolean);
74
+ return this.db.get(this.collection, this.id).then(Boolean);
77
75
  }
78
76
  get value() {
79
- return this.db.provider.getItem(this.collection, this.id);
77
+ return this.db.get(this.collection, this.id);
80
78
  }
81
79
  get data() {
82
80
  return this.value.then(getData);
83
81
  }
84
82
  set(data) {
85
- return this.db.provider.setItem(this.collection, this.id, data);
83
+ return this.db.set(this.collection, this.id, data);
86
84
  }
87
85
  update(updates) {
88
- return this.db.provider.updateItem(this.collection, this.id, isTransformable(updates) ? updates : new DataUpdate(updates));
86
+ return this.db.update(this.collection, this.id, updates);
89
87
  }
90
88
  delete() {
91
- return this.db.provider.deleteItem(this.collection, this.id);
89
+ return this.db.delete(this.collection, this.id);
92
90
  }
93
91
  }
94
92
  /** Get the ID from item data. */