shelving 1.79.0 → 1.81.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.
- package/{modules/api → api}/Resource.d.ts +0 -0
- package/{modules/api → api}/Resource.js +0 -1
- package/{modules/api → api}/index.d.ts +0 -0
- package/{modules/api → api}/index.js +0 -0
- package/{modules/constraint → constraint}/Constraint.d.ts +0 -0
- package/{modules/constraint → constraint}/Constraint.js +0 -0
- package/{modules/constraint → constraint}/Constraints.d.ts +0 -0
- package/{modules/constraint → constraint}/Constraints.js +2 -2
- package/{modules/constraint → constraint}/FilterConstraint.d.ts +0 -0
- package/{modules/constraint → constraint}/FilterConstraint.js +0 -0
- package/{modules/constraint → constraint}/FilterConstraints.d.ts +0 -0
- package/{modules/constraint → constraint}/FilterConstraints.js +1 -1
- package/{modules/constraint → constraint}/QueryConstraints.d.ts +1 -1
- package/{modules/constraint → constraint}/QueryConstraints.js +2 -2
- package/{modules/constraint → constraint}/SortConstraint.d.ts +0 -0
- package/{modules/constraint → constraint}/SortConstraint.js +0 -0
- package/{modules/constraint → constraint}/SortConstraints.d.ts +0 -0
- package/{modules/constraint → constraint}/SortConstraints.js +1 -1
- package/{modules/constraint → constraint}/index.d.ts +0 -0
- package/{modules/constraint → constraint}/index.js +0 -0
- package/{modules/db → db}/Change.d.ts +0 -0
- package/{modules/db → db}/Change.js +3 -3
- package/{modules/db → db}/Collection.d.ts +0 -5
- package/{modules/db → db}/Collection.js +0 -4
- package/{modules/db → db}/Database.d.ts +0 -5
- package/{modules/db → db}/Database.js +0 -4
- package/{modules/db → db}/Item.d.ts +9 -16
- package/{modules/db → db}/Item.js +9 -10
- package/{modules/db → db}/Query.d.ts +7 -14
- package/{modules/db → db}/Query.js +11 -12
- package/{modules/db → db}/index.d.ts +0 -0
- package/{modules/db → db}/index.js +0 -0
- package/{modules/error → error}/AssertionError.d.ts +0 -0
- package/{modules/error → error}/AssertionError.js +0 -0
- package/{modules/error → error}/ConditionError.d.ts +0 -0
- package/{modules/error → error}/ConditionError.js +0 -0
- package/{modules/error → error}/PermissionError.d.ts +0 -0
- package/{modules/error → error}/PermissionError.js +0 -0
- package/{modules/error → error}/RequiredError.d.ts +0 -0
- package/{modules/error → error}/RequiredError.js +0 -0
- package/{modules/error → error}/ThroughError.d.ts +0 -0
- package/{modules/error → error}/ThroughError.js +0 -0
- package/{modules/error → error}/UnsupportedError.d.ts +0 -0
- package/{modules/error → error}/UnsupportedError.js +0 -0
- package/{modules/error → error}/ValidationError.d.ts +0 -0
- package/{modules/error → error}/ValidationError.js +0 -0
- package/{modules/error → error}/index.d.ts +0 -0
- package/{modules/error → error}/index.js +0 -0
- package/{modules/feedback → feedback}/ErrorFeedback.d.ts +0 -0
- package/{modules/feedback → feedback}/ErrorFeedback.js +0 -0
- package/{modules/feedback → feedback}/Feedback.d.ts +0 -0
- package/{modules/feedback → feedback}/Feedback.js +0 -0
- package/{modules/feedback → feedback}/InvalidFeedback.d.ts +0 -0
- package/{modules/feedback → feedback}/InvalidFeedback.js +0 -0
- package/{modules/feedback → feedback}/SuccessFeedback.d.ts +0 -0
- package/{modules/feedback → feedback}/SuccessFeedback.js +0 -0
- package/{modules/feedback → feedback}/WarningFeedback.d.ts +0 -0
- package/{modules/feedback → feedback}/WarningFeedback.js +0 -0
- package/{modules/feedback → feedback}/hydrations.d.ts +0 -0
- package/{modules/feedback → feedback}/hydrations.js +0 -0
- package/{modules/feedback → feedback}/index.d.ts +0 -0
- package/{modules/feedback → feedback}/index.js +0 -0
- package/{modules/firestore → firestore}/client/FirestoreClientProvider.d.ts +3 -5
- package/{modules/firestore → firestore}/client/FirestoreClientProvider.js +10 -11
- package/{modules/firestore → firestore}/client/index.d.ts +0 -0
- package/{modules/firestore → firestore}/client/index.js +0 -0
- package/{modules/firestore → firestore}/lite/FirestoreLiteProvider.d.ts +3 -4
- package/{modules/firestore → firestore}/lite/FirestoreLiteProvider.js +3 -8
- package/{modules/firestore → firestore}/lite/index.d.ts +0 -0
- package/{modules/firestore → firestore}/lite/index.js +0 -0
- package/{modules/firestore → firestore}/server/FirestoreServerProvider.d.ts +4 -6
- package/{modules/firestore → firestore}/server/FirestoreServerProvider.js +12 -16
- package/{modules/firestore → firestore}/server/index.d.ts +0 -0
- package/{modules/firestore → firestore}/server/index.js +0 -0
- package/{modules/index.d.ts → index.d.ts} +8 -7
- package/{modules/index.js → index.js} +13 -16
- package/iterate/AbstractGenerator.d.ts +8 -0
- package/iterate/AbstractGenerator.js +26 -0
- package/iterate/InspectGenerator.d.ts +32 -0
- package/iterate/InspectGenerator.js +67 -0
- package/iterate/ThroughGenerator.d.ts +9 -0
- package/iterate/ThroughGenerator.js +18 -0
- package/iterate/index.d.ts +3 -0
- package/iterate/index.js +3 -0
- package/{modules/markup → markup}/index.d.ts +0 -0
- package/{modules/markup → markup}/index.js +0 -0
- package/{modules/markup → markup}/options.d.ts +0 -0
- package/{modules/markup → markup}/options.js +0 -0
- package/{modules/markup → markup}/regexp.d.ts +0 -0
- package/{modules/markup → markup}/regexp.js +0 -0
- package/{modules/markup → markup}/render.d.ts +0 -0
- package/{modules/markup → markup}/render.js +0 -0
- package/{modules/markup → markup}/rules.d.ts +0 -0
- package/{modules/markup → markup}/rules.js +0 -0
- package/package.json +7 -4
- package/{modules/provider → provider}/CacheProvider.d.ts +2 -4
- package/{modules/provider → provider}/CacheProvider.js +12 -38
- package/{modules/provider → provider}/DebugProvider.d.ts +2 -4
- package/provider/DebugProvider.js +268 -0
- package/{modules/provider → provider}/MemoryProvider.d.ts +27 -24
- package/provider/MemoryProvider.js +264 -0
- package/{modules/provider → provider}/Provider.d.ts +26 -45
- package/{modules/provider → provider}/Provider.js +0 -0
- package/{modules/provider → provider}/ThroughProvider.d.ts +4 -6
- package/{modules/provider → provider}/ThroughProvider.js +8 -8
- package/{modules/provider → provider}/ValidationProvider.d.ts +2 -4
- package/{modules/provider → provider}/ValidationProvider.js +18 -37
- package/{modules/provider → provider}/index.d.ts +0 -1
- package/{modules/provider → provider}/index.js +0 -1
- package/{modules/react → react}/index.d.ts +2 -1
- package/{modules/react → react}/index.js +3 -3
- package/{modules/react → react}/useCache.d.ts +1 -1
- package/{modules/react → react}/useCache.js +0 -0
- package/{modules/react → react}/useInstance.d.ts +0 -0
- package/{modules/react → react}/useInstance.js +0 -0
- package/{modules/react → react}/useItem.d.ts +3 -7
- package/{modules/react → react}/useItem.js +12 -30
- package/{modules/react → react}/useLazy.d.ts +0 -0
- package/{modules/react → react}/useLazy.js +0 -0
- package/{modules/react → react}/useQuery.d.ts +6 -8
- package/{modules/react → react}/useQuery.js +23 -39
- package/{modules/react → react}/useReduce.d.ts +0 -0
- package/{modules/react → react}/useReduce.js +0 -0
- package/react/useSequence.d.ts +9 -0
- package/react/useSequence.js +19 -0
- package/react/useState.d.ts +11 -0
- package/react/useState.js +12 -0
- package/{modules/schema → schema}/AllowSchema.d.ts +0 -0
- package/{modules/schema → schema}/AllowSchema.js +2 -2
- package/{modules/schema → schema}/ArraySchema.d.ts +0 -0
- package/{modules/schema → schema}/ArraySchema.js +0 -0
- package/{modules/schema → schema}/BooleanSchema.d.ts +0 -0
- package/{modules/schema → schema}/BooleanSchema.js +0 -0
- package/{modules/schema → schema}/ColorSchema.d.ts +0 -0
- package/{modules/schema → schema}/ColorSchema.js +0 -0
- package/{modules/schema → schema}/DataSchema.d.ts +0 -0
- package/{modules/schema → schema}/DataSchema.js +0 -0
- package/{modules/schema → schema}/DateSchema.d.ts +0 -0
- package/{modules/schema → schema}/DateSchema.js +0 -0
- package/{modules/schema → schema}/EmailSchema.d.ts +0 -0
- package/{modules/schema → schema}/EmailSchema.js +0 -0
- package/{modules/schema → schema}/KeySchema.d.ts +0 -0
- package/{modules/schema → schema}/KeySchema.js +0 -0
- package/{modules/schema → schema}/LinkSchema.d.ts +0 -0
- package/{modules/schema → schema}/LinkSchema.js +0 -0
- package/{modules/schema → schema}/NumberSchema.d.ts +0 -0
- package/{modules/schema → schema}/NumberSchema.js +0 -0
- package/{modules/schema → schema}/ObjectSchema.d.ts +0 -0
- package/{modules/schema → schema}/ObjectSchema.js +0 -0
- package/{modules/schema → schema}/OptionalSchema.d.ts +0 -0
- package/{modules/schema → schema}/OptionalSchema.js +0 -0
- package/{modules/schema → schema}/PhoneSchema.d.ts +0 -0
- package/{modules/schema → schema}/PhoneSchema.js +0 -0
- package/{modules/schema → schema}/RequiredSchema.d.ts +0 -0
- package/{modules/schema → schema}/RequiredSchema.js +0 -0
- package/{modules/schema → schema}/Schema.d.ts +0 -0
- package/{modules/schema → schema}/Schema.js +0 -0
- package/{modules/schema → schema}/SlugSchema.d.ts +0 -0
- package/{modules/schema → schema}/SlugSchema.js +0 -0
- package/{modules/schema → schema}/StringSchema.d.ts +0 -0
- package/{modules/schema → schema}/StringSchema.js +0 -0
- package/{modules/schema → schema}/ThroughSchema.d.ts +0 -0
- package/{modules/schema → schema}/ThroughSchema.js +0 -0
- package/{modules/schema → schema}/index.d.ts +0 -0
- package/{modules/schema → schema}/index.js +0 -0
- package/sequence/AbstractSequence.d.ts +8 -0
- package/sequence/AbstractSequence.js +26 -0
- package/sequence/DeferredSequence.d.ts +30 -0
- package/sequence/DeferredSequence.js +64 -0
- package/sequence/InspectSequence.d.ts +32 -0
- package/sequence/InspectSequence.js +67 -0
- package/sequence/LazyDeferredSequence.d.ts +9 -0
- package/sequence/LazyDeferredSequence.js +14 -0
- package/sequence/RegisteringSequence.d.ts +9 -0
- package/sequence/RegisteringSequence.js +51 -0
- package/sequence/ThroughSequence.d.ts +9 -0
- package/sequence/ThroughSequence.js +20 -0
- package/sequence/index.d.ts +6 -0
- package/sequence/index.js +6 -0
- package/{modules/state → state}/ArrayState.d.ts +6 -8
- package/state/ArrayState.js +28 -0
- package/{modules/state → state}/BooleanState.d.ts +0 -0
- package/{modules/state → state}/BooleanState.js +1 -1
- package/{modules/state → state}/DataState.d.ts +5 -9
- package/{modules/state → state}/DataState.js +8 -16
- package/{modules/state → state}/ObjectState.d.ts +6 -5
- package/{modules/state → state}/ObjectState.js +9 -8
- package/{modules/state → state}/State.d.ts +12 -16
- package/state/State.js +60 -0
- package/{modules/state → state}/index.d.ts +0 -1
- package/{modules/state → state}/index.js +0 -1
- package/{modules/test → test}/basics.d.ts +0 -0
- package/{modules/test → test}/basics.js +0 -0
- package/{modules/test → test}/index.d.ts +0 -0
- package/{modules/test → test}/index.js +0 -0
- package/{modules/test → test}/people.d.ts +0 -0
- package/{modules/test → test}/people.js +0 -0
- package/test/util.d.ts +19 -0
- package/{modules/test → test}/util.js +26 -7
- package/{modules/update → update}/ArrayUpdate.d.ts +0 -0
- package/{modules/update → update}/ArrayUpdate.js +1 -1
- package/{modules/update → update}/DataUpdate.d.ts +1 -3
- package/{modules/update → update}/DataUpdate.js +1 -1
- package/{modules/update → update}/Delete.d.ts +0 -0
- package/{modules/update → update}/Delete.js +0 -0
- package/{modules/update → update}/Increment.d.ts +0 -0
- package/{modules/update → update}/Increment.js +0 -0
- package/{modules/update → update}/ObjectUpdate.d.ts +0 -0
- package/{modules/update → update}/ObjectUpdate.js +0 -0
- package/{modules/update → update}/Update.d.ts +0 -0
- package/{modules/update → update}/Update.js +0 -0
- package/update/hydrations.d.ts +3 -0
- package/{modules/update → update}/hydrations.js +2 -2
- package/{modules/update → update}/index.d.ts +0 -0
- package/{modules/update → update}/index.js +0 -0
- package/util/activity.d.ts +38 -0
- package/util/activity.js +64 -0
- package/{modules/util → util}/array.d.ts +6 -52
- package/{modules/util → util}/array.js +15 -89
- package/{modules/util → util}/assert.d.ts +0 -0
- package/{modules/util → util}/assert.js +0 -0
- package/{modules/util → util}/async.d.ts +17 -14
- package/{modules/util → util}/async.js +20 -31
- package/{modules/util → util}/boolean.d.ts +0 -0
- package/{modules/util → util}/boolean.js +0 -0
- package/{modules/util → util}/class.d.ts +1 -1
- package/{modules/util → util}/class.js +0 -0
- package/{modules/util → util}/clone.d.ts +0 -0
- package/{modules/util → util}/clone.js +0 -0
- package/{modules/util → util}/color.d.ts +0 -0
- package/{modules/util → util}/color.js +0 -0
- package/util/data.d.ts +74 -0
- package/util/data.js +27 -0
- package/{modules/util → util}/date.d.ts +0 -0
- package/{modules/util → util}/date.js +0 -0
- package/{modules/util → util}/debug.d.ts +0 -0
- package/{modules/util → util}/debug.js +0 -0
- package/{modules/util → util}/diff.d.ts +0 -0
- package/{modules/util → util}/diff.js +0 -0
- package/{modules/util → util}/entry.d.ts +2 -2
- package/{modules/util → util}/entry.js +0 -0
- package/{modules/util → util}/equal.d.ts +0 -0
- package/{modules/util → util}/equal.js +0 -0
- package/util/error.d.ts +3 -0
- package/{modules/util → util}/error.js +0 -1
- package/{modules/util → util}/filter.d.ts +0 -0
- package/{modules/util → util}/filter.js +0 -0
- package/{modules/util → util}/function.d.ts +6 -0
- package/{modules/util → util}/function.js +0 -0
- package/{modules/util → util}/hydrate.d.ts +0 -0
- package/{modules/util → util}/hydrate.js +0 -0
- package/{modules/util → util}/index.d.ts +2 -0
- package/{modules/util → util}/index.js +2 -0
- package/util/iterate.d.ts +42 -0
- package/{modules/util → util}/iterate.js +2 -88
- package/{modules/util → util}/jsx.d.ts +0 -0
- package/{modules/util → util}/jsx.js +0 -0
- package/{modules/util → util}/lazy.d.ts +0 -0
- package/{modules/util → util}/lazy.js +0 -0
- package/{modules/util → util}/map.d.ts +0 -0
- package/{modules/util → util}/map.js +0 -0
- package/{modules/util → util}/match.d.ts +0 -0
- package/{modules/util → util}/match.js +0 -0
- package/{modules/util → util}/merge.d.ts +0 -0
- package/{modules/util → util}/merge.js +0 -0
- package/{modules/util → util}/null.d.ts +0 -0
- package/{modules/util → util}/null.js +0 -0
- package/{modules/util → util}/number.d.ts +0 -0
- package/{modules/util → util}/number.js +0 -0
- package/util/object.d.ts +110 -0
- package/util/object.js +124 -0
- package/{modules/util → util}/random.d.ts +0 -0
- package/{modules/util → util}/random.js +0 -0
- package/{modules/util → util}/regexp.d.ts +0 -0
- package/{modules/util → util}/regexp.js +0 -0
- package/util/sequence.d.ts +22 -0
- package/util/sequence.js +75 -0
- package/{modules/util → util}/serialise.d.ts +0 -0
- package/{modules/util → util}/serialise.js +0 -0
- package/{modules/util → util}/set.d.ts +0 -0
- package/{modules/util → util}/set.js +0 -0
- package/{modules/util → util}/sort.d.ts +0 -0
- package/{modules/util → util}/sort.js +0 -0
- package/{modules/util → util}/source.d.ts +0 -0
- package/{modules/util → util}/source.js +0 -0
- package/{modules/util → util}/string.d.ts +0 -0
- package/{modules/util → util}/string.js +0 -0
- package/{modules/util → util}/template.d.ts +0 -0
- package/{modules/util → util}/template.js +0 -0
- package/{modules/util → util}/timeout.d.ts +0 -0
- package/{modules/util → util}/timeout.js +0 -0
- package/{modules/util → util}/transform.d.ts +8 -12
- package/{modules/util → util}/transform.js +20 -8
- package/{modules/util → util}/undefined.d.ts +0 -0
- package/{modules/util → util}/undefined.js +0 -0
- package/{modules/util → util}/units.d.ts +0 -0
- package/{modules/util → util}/units.js +0 -0
- package/{modules/util → util}/url.d.ts +0 -0
- package/{modules/util → util}/url.js +0 -0
- package/{modules/util → util}/validate.d.ts +2 -2
- package/{modules/util → util}/validate.js +1 -1
- package/modules/observe/AbstractObserver.d.ts +0 -15
- package/modules/observe/AbstractObserver.js +0 -42
- package/modules/observe/AsyncObserver.d.ts +0 -5
- package/modules/observe/AsyncObserver.js +0 -8
- package/modules/observe/LastSubject.d.ts +0 -5
- package/modules/observe/LastSubject.js +0 -12
- package/modules/observe/MatchObserver.d.ts +0 -9
- package/modules/observe/MatchObserver.js +0 -12
- package/modules/observe/MatchableObserver.d.ts +0 -7
- package/modules/observe/MatchableObserver.js +0 -10
- package/modules/observe/Observable.d.ts +0 -24
- package/modules/observe/Observable.js +0 -4
- package/modules/observe/Observer.d.ts +0 -31
- package/modules/observe/Observer.js +0 -48
- package/modules/observe/OnceObserver.d.ts +0 -5
- package/modules/observe/OnceObserver.js +0 -8
- package/modules/observe/Subject.d.ts +0 -46
- package/modules/observe/Subject.js +0 -116
- package/modules/observe/ThroughObserver.d.ts +0 -5
- package/modules/observe/ThroughObserver.js +0 -8
- package/modules/observe/TransformObserver.d.ts +0 -9
- package/modules/observe/TransformObserver.js +0 -12
- package/modules/observe/TransformableObserver.d.ts +0 -7
- package/modules/observe/TransformableObserver.js +0 -8
- package/modules/observe/index.d.ts +0 -13
- package/modules/observe/index.js +0 -13
- package/modules/observe/util.d.ts +0 -24
- package/modules/observe/util.js +0 -34
- package/modules/provider/BatchProvider.d.ts +0 -26
- package/modules/provider/BatchProvider.js +0 -75
- package/modules/provider/DebugProvider.js +0 -241
- package/modules/provider/MemoryProvider.js +0 -227
- package/modules/react/useSubscribe.d.ts +0 -9
- package/modules/react/useSubscribe.js +0 -22
- package/modules/state/ArrayState.js +0 -32
- package/modules/state/SelfClosingState.d.ts +0 -18
- package/modules/state/SelfClosingState.js +0 -34
- package/modules/state/State.js +0 -82
- package/modules/test/util.d.ts +0 -9
- package/modules/update/hydrations.d.ts +0 -3
- package/modules/util/data.d.ts +0 -126
- package/modules/util/data.js +0 -78
- package/modules/util/error.d.ts +0 -4
- package/modules/util/iterate.d.ts +0 -93
- package/modules/util/object.d.ts +0 -102
- package/modules/util/object.js +0 -121
|
File without changes
|
|
@@ -9,7 +9,6 @@ import { ValidationError } from "../error/ValidationError.js";
|
|
|
9
9
|
* @param returns The `Validator` the function's returned value must conform to (defaults to `undefined` if not specified).
|
|
10
10
|
*/
|
|
11
11
|
export class Resource {
|
|
12
|
-
// Protected to require use of `Resource.create()`
|
|
13
12
|
constructor(payload, result) {
|
|
14
13
|
this.payload = payload;
|
|
15
14
|
this.result = result;
|
|
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. */
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
@@ -22,6 +22,6 @@ export class FilterConstraints extends Constraints {
|
|
|
22
22
|
}
|
|
23
23
|
// Stringify as object syntax.
|
|
24
24
|
toString() {
|
|
25
|
-
return `{${this._constraints.map(String).join(",")}
|
|
25
|
+
return this._constraints.length ? `"filters":{${this._constraints.map(String).join(",")}}` : "";
|
|
26
26
|
}
|
|
27
27
|
}
|
|
@@ -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/
|
|
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";
|
|
@@ -87,7 +87,7 @@ export class QueryConstraints extends Constraint {
|
|
|
87
87
|
}
|
|
88
88
|
// Implement toString()
|
|
89
89
|
toString() {
|
|
90
|
-
return
|
|
90
|
+
return [this.filters.toString(), this.sorts.toString(), typeof this.limit === "number" ? `"limit":${this.limit}` : null].filter(Boolean).join(",");
|
|
91
91
|
}
|
|
92
92
|
}
|
|
93
93
|
function* _getAfterFilters(sorts, item) {
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
@@ -24,6 +24,6 @@ export class SortConstraints extends Constraints {
|
|
|
24
24
|
}
|
|
25
25
|
// Stringify as array syntax.
|
|
26
26
|
toString() {
|
|
27
|
-
return `[${this._constraints.map(String).join(",")}]
|
|
27
|
+
return this._constraints.length ? `"sorts":[${this._constraints.map(String).join(",")}]` : "";
|
|
28
28
|
}
|
|
29
29
|
}
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
@@ -1,10 +1,10 @@
|
|
|
1
1
|
import { QueryConstraints } from "../constraint/QueryConstraints.js";
|
|
2
2
|
import { FilterConstraint } from "../constraint/FilterConstraint.js";
|
|
3
3
|
import { notNullish } from "../util/null.js";
|
|
4
|
-
import {
|
|
4
|
+
import { flattenItems } from "../util/iterate.js";
|
|
5
5
|
/** Apply a set of changes to a synchronous provider. */
|
|
6
6
|
export function changeProvider(provider, ...changes) {
|
|
7
|
-
return Array.from(
|
|
7
|
+
return Array.from(flattenItems(changes)).filter(notNullish).map(_changeItem, provider);
|
|
8
8
|
}
|
|
9
9
|
function _changeItem(change) {
|
|
10
10
|
const { action, collection } = change;
|
|
@@ -20,7 +20,7 @@ function _changeItem(change) {
|
|
|
20
20
|
}
|
|
21
21
|
/** Apply a set of changes to an asynchronous provider. */
|
|
22
22
|
export function changeAsyncProvider(provider, ...changes) {
|
|
23
|
-
return Promise.all(Array.from(
|
|
23
|
+
return Promise.all(Array.from(flattenItems(changes)).filter(notNullish).map(_changeAsyncItem, provider));
|
|
24
24
|
}
|
|
25
25
|
async function _changeAsyncItem(change) {
|
|
26
26
|
const { collection, action } = change;
|
|
@@ -4,9 +4,6 @@ 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
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";
|
|
10
7
|
import type { AsyncDatabase, Database } from "./Database.js";
|
|
11
8
|
import { ItemData, AsyncItem, Item, ItemValue } from "./Item.js";
|
|
12
9
|
import { AsyncQuery, Query } from "./Query.js";
|
|
@@ -23,8 +20,6 @@ declare abstract class BaseCollection<T extends Datas = Datas, K extends Key<T>
|
|
|
23
20
|
abstract change(...changes: DeepIterable<Nullish<WriteChange<T, K>>>[]): ItemChanges<T, K> | Promise<ItemChanges<T, K>>;
|
|
24
21
|
/** Get an item from this collection. */
|
|
25
22
|
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
23
|
/** Add an item to this collection. */
|
|
29
24
|
abstract add(data: T[K]): string | Promise<string>;
|
|
30
25
|
/** Set a document in this collection. */
|
|
@@ -3,10 +3,6 @@ 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
|
-
}
|
|
10
6
|
/** Get an add change for this collection. */
|
|
11
7
|
getAdd(data) {
|
|
12
8
|
return this.db.getAdd(this.collection, data);
|
|
@@ -6,9 +6,6 @@ import type { FilterList } from "../constraint/FilterConstraint.js";
|
|
|
6
6
|
import type { SortList } from "../constraint/SortConstraint.js";
|
|
7
7
|
import type { ItemData, ItemValue } from "../db/Item.js";
|
|
8
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
9
|
import { Item, AsyncItem } from "./Item.js";
|
|
13
10
|
import { Query, AsyncQuery } from "./Query.js";
|
|
14
11
|
import { Collection, AsyncCollection } from "./Collection.js";
|
|
@@ -26,8 +23,6 @@ declare abstract class BaseDatabase<T extends Datas> {
|
|
|
26
23
|
abstract change(...changes: DeepIterable<Nullish<WriteChange<T>>>[]): ItemChanges<T> | Promise<ItemChanges<T>>;
|
|
27
24
|
/** Get a document from a collection in this database. */
|
|
28
25
|
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
26
|
/** Add a document to a collection in this database. */
|
|
32
27
|
abstract add<K extends Key<T>>(collection: K, data: T[K]): string | Promise<string>;
|
|
33
28
|
/** Set a document in a collection in this database. */
|
|
@@ -4,10 +4,6 @@ import { Collection, AsyncCollection } from "./Collection.js";
|
|
|
4
4
|
import { changeAsyncProvider, changeProvider } from "./Change.js";
|
|
5
5
|
/** Database with a synchronous or asynchronous provider. */
|
|
6
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
7
|
/** Get an add change for a collection in this database. */
|
|
12
8
|
getAdd(collection, data) {
|
|
13
9
|
return { action: "ADD", collection, data };
|
|
@@ -1,13 +1,11 @@
|
|
|
1
|
-
import { Data, Datas, Key } from "../util/data.js";
|
|
2
|
-
import type { Dispatch } from "../util/function.js";
|
|
3
|
-
import type { PartialObserver } from "../observe/Observer.js";
|
|
4
1
|
import type { ImmutableArray } from "../util/array.js";
|
|
5
|
-
import type {
|
|
6
|
-
import { DataUpdate, Updates } from "../update/DataUpdate.js";
|
|
2
|
+
import type { Stop, Handler, Dispatch } from "../util/function.js";
|
|
7
3
|
import type { QueryConstraints } from "../constraint/QueryConstraints.js";
|
|
8
|
-
import
|
|
9
|
-
import
|
|
4
|
+
import { Data, Datas, Key } from "../util/data.js";
|
|
5
|
+
import { DataUpdate, Updates } from "../update/DataUpdate.js";
|
|
10
6
|
import type { DeleteChange, SetChange, UpdateChange } from "./Change.js";
|
|
7
|
+
import type { AsyncQuery, Query } from "./Query.js";
|
|
8
|
+
import type { AsyncDatabase, Database } from "./Database.js";
|
|
11
9
|
/** Item data with a string ID that uniquely identifies it. */
|
|
12
10
|
export declare type ItemData<T extends Data = Data> = T & {
|
|
13
11
|
id: string;
|
|
@@ -19,7 +17,7 @@ export declare type ItemArray<T extends Data = Data> = ImmutableArray<ItemData<T
|
|
|
19
17
|
/** A set of query constraints for item data. */
|
|
20
18
|
export declare type ItemConstraints<T extends Data = Data> = QueryConstraints<ItemData<T>>;
|
|
21
19
|
/** Reference to an item in a synchronous or asynchronous database. */
|
|
22
|
-
declare abstract class BaseItem<T extends Datas = Datas, K extends Key<T> = Key<T>> implements
|
|
20
|
+
declare abstract class BaseItem<T extends Datas = Datas, K extends Key<T> = Key<T>> implements AsyncIterable<ItemValue<T[K]>> {
|
|
23
21
|
abstract readonly db: Database<T> | AsyncDatabase<T>;
|
|
24
22
|
abstract readonly collection: K;
|
|
25
23
|
abstract readonly id: string;
|
|
@@ -43,14 +41,6 @@ declare abstract class BaseItem<T extends Datas = Datas, K extends Key<T> = Key<
|
|
|
43
41
|
* @throws RequiredError if the item does not exist.
|
|
44
42
|
*/
|
|
45
43
|
abstract data: ItemData<T[K]> | PromiseLike<ItemData<T[K]>>;
|
|
46
|
-
/**
|
|
47
|
-
* Subscribe to the result of this item (indefinitely).
|
|
48
|
-
* - `next()` is called once with the initial result, and again any time the result changes.
|
|
49
|
-
*
|
|
50
|
-
* @param next Observer with `next`, `error`, or `complete` methods or a `next()` dispatcher.
|
|
51
|
-
* @return Function that ends the subscription.
|
|
52
|
-
*/
|
|
53
|
-
subscribe(next: PartialObserver<ItemValue<T[K]>> | Dispatch<[ItemValue<T[K]>]>): Unsubscribe;
|
|
54
44
|
/** Set the complete data of this item. */
|
|
55
45
|
abstract set(data: T[K]): void | PromiseLike<void>;
|
|
56
46
|
/** Update this item. */
|
|
@@ -64,6 +54,9 @@ declare abstract class BaseItem<T extends Datas = Datas, K extends Key<T> = Key<
|
|
|
64
54
|
/** Get a delete change for this item. */
|
|
65
55
|
getDelete(): DeleteChange<T, K>;
|
|
66
56
|
toString(): `${K}/${string}`;
|
|
57
|
+
/** Subscribe to this item. */
|
|
58
|
+
subscribe(onNext?: Dispatch<[ItemValue<T[K]>]>, onError?: Handler): Stop;
|
|
59
|
+
[Symbol.asyncIterator](): AsyncIterator<ItemValue<T[K]>>;
|
|
67
60
|
}
|
|
68
61
|
/** Reference to an item in a synchronous database. */
|
|
69
62
|
export declare class Item<T extends Datas = Datas, K extends Key<T> = Key<T>> extends BaseItem<T, K> {
|
|
@@ -1,17 +1,8 @@
|
|
|
1
1
|
import { getData } from "../util/data.js";
|
|
2
2
|
import { FilterConstraint } from "../constraint/FilterConstraint.js";
|
|
3
|
+
import { runSequence } from "../util/sequence.js";
|
|
3
4
|
/** Reference to an item in a synchronous or asynchronous database. */
|
|
4
5
|
class BaseItem {
|
|
5
|
-
/**
|
|
6
|
-
* Subscribe to the result of this item (indefinitely).
|
|
7
|
-
* - `next()` is called once with the initial result, and again any time the result changes.
|
|
8
|
-
*
|
|
9
|
-
* @param next Observer with `next`, `error`, or `complete` methods or a `next()` dispatcher.
|
|
10
|
-
* @return Function that ends the subscription.
|
|
11
|
-
*/
|
|
12
|
-
subscribe(next) {
|
|
13
|
-
return this.db.subscribe(this.collection, this.id, next);
|
|
14
|
-
}
|
|
15
6
|
/** Get a set change for this item. */
|
|
16
7
|
getSet(data) {
|
|
17
8
|
return this.db.getSet(this.collection, this.id, data);
|
|
@@ -28,6 +19,14 @@ class BaseItem {
|
|
|
28
19
|
toString() {
|
|
29
20
|
return `${this.collection}/${this.id}`;
|
|
30
21
|
}
|
|
22
|
+
/** Subscribe to this item. */
|
|
23
|
+
subscribe(onNext, onError) {
|
|
24
|
+
return runSequence(this, onNext, onError);
|
|
25
|
+
}
|
|
26
|
+
// Implement AsyncIterable
|
|
27
|
+
[Symbol.asyncIterator]() {
|
|
28
|
+
return this.db.provider.getItemSequence(this.collection, this.id)[Symbol.asyncIterator]();
|
|
29
|
+
}
|
|
31
30
|
}
|
|
32
31
|
/** Reference to an item in a synchronous database. */
|
|
33
32
|
export class Item extends BaseItem {
|
|
@@ -1,15 +1,13 @@
|
|
|
1
|
-
import type { Dispatch } from "../util/function.js";
|
|
2
1
|
import type { Key, Datas } from "../util/data.js";
|
|
2
|
+
import type { Dispatch, Handler, Stop } from "../util/function.js";
|
|
3
3
|
import type { Updates } from "../update/DataUpdate.js";
|
|
4
|
-
import type { PartialObserver } from "../observe/Observer.js";
|
|
5
|
-
import type { Observable, Unsubscribe } from "../observe/Observable.js";
|
|
6
4
|
import type { FilterList } from "../constraint/FilterConstraint.js";
|
|
7
5
|
import type { SortList } from "../constraint/SortConstraint.js";
|
|
8
6
|
import { QueryConstraints } from "../constraint/QueryConstraints.js";
|
|
9
7
|
import type { ItemArray, ItemValue, ItemData } from "./Item.js";
|
|
10
8
|
import type { AsyncDatabase, Database } from "./Database.js";
|
|
11
9
|
/** Reference to a set of items in a sync or async provider. */
|
|
12
|
-
declare abstract class BaseQuery<T extends Datas = Datas, K extends Key<T> = Key<T>> extends QueryConstraints<ItemData<T[K]>> implements
|
|
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]>> {
|
|
13
11
|
abstract readonly db: Database<T> | AsyncDatabase<T>;
|
|
14
12
|
abstract readonly collection: K;
|
|
15
13
|
/**
|
|
@@ -47,14 +45,6 @@ declare abstract class BaseQuery<T extends Datas = Datas, K extends Key<T> = Key
|
|
|
47
45
|
* @throws RequiredError if there were no results for this query.
|
|
48
46
|
*/
|
|
49
47
|
abstract lastData: ItemData<T[K]> | PromiseLike<ItemData<T[K]>>;
|
|
50
|
-
/**
|
|
51
|
-
* Subscribe to all matching items.
|
|
52
|
-
* - `next()` is called once with the initial results, and again any time the results change.
|
|
53
|
-
*
|
|
54
|
-
* @param next Observer with `next`, `error`, or `complete` methods or a `next()` dispatcher.
|
|
55
|
-
* @return Function that ends the subscription.
|
|
56
|
-
*/
|
|
57
|
-
subscribe(next: PartialObserver<ItemArray<T[K]>> | Dispatch<[ItemArray<T[K]>]>): Unsubscribe;
|
|
58
48
|
/**
|
|
59
49
|
* Set all matching items to the same exact value.
|
|
60
50
|
*
|
|
@@ -75,9 +65,12 @@ declare abstract class BaseQuery<T extends Datas = Datas, K extends Key<T> = Key
|
|
|
75
65
|
*/
|
|
76
66
|
abstract delete(): number | PromiseLike<number>;
|
|
77
67
|
toString(): string;
|
|
68
|
+
/** Subscribe to this item. */
|
|
69
|
+
subscribe(onNext?: Dispatch<[ItemArray<T[K]>]>, onError?: Handler): Stop;
|
|
70
|
+
[Symbol.asyncIterator](): AsyncIterator<ItemArray<T[K]>>;
|
|
78
71
|
}
|
|
79
72
|
/** Reference to a set of items in a provider. */
|
|
80
|
-
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 Key<T> = Key<T>> extends BaseQuery<T, K> {
|
|
81
74
|
readonly db: Database<T>;
|
|
82
75
|
readonly collection: K;
|
|
83
76
|
constructor(db: Database<T>, collection: K, filters?: FilterList<Partial<ItemData<T[K]>>>, sorts?: SortList<Partial<ItemData<T[K]>>>, limit?: number | null);
|
|
@@ -93,7 +86,7 @@ export declare class Query<T extends Datas = Datas, K extends Key<T> = Key<T>> e
|
|
|
93
86
|
delete(): number;
|
|
94
87
|
}
|
|
95
88
|
/** Reference to a set of items in a provider. */
|
|
96
|
-
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 Key<T> = Key<T>> extends BaseQuery<T, K> {
|
|
97
90
|
readonly db: AsyncDatabase<T>;
|
|
98
91
|
readonly collection: K;
|
|
99
92
|
constructor(db: AsyncDatabase<T>, collection: K, filters?: FilterList<Partial<ItemData<T[K]>>>, sorts?: SortList<Partial<ItemData<T[K]>>>, limit?: number | null);
|
|
@@ -1,21 +1,20 @@
|
|
|
1
1
|
import { getFirstItem, getLastItem, getOptionalFirstItem, getOptionalLastItem } from "../util/array.js";
|
|
2
|
-
import { QueryConstraints } from "../constraint/QueryConstraints.js";
|
|
3
2
|
import { countItems, hasItems } from "../util/iterate.js";
|
|
3
|
+
import { runSequence } from "../util/sequence.js";
|
|
4
|
+
import { QueryConstraints } from "../constraint/QueryConstraints.js";
|
|
4
5
|
/** Reference to a set of items in a sync or async provider. */
|
|
5
6
|
class BaseQuery extends QueryConstraints {
|
|
6
|
-
/**
|
|
7
|
-
* Subscribe to all matching items.
|
|
8
|
-
* - `next()` is called once with the initial results, and again any time the results change.
|
|
9
|
-
*
|
|
10
|
-
* @param next Observer with `next`, `error`, or `complete` methods or a `next()` dispatcher.
|
|
11
|
-
* @return Function that ends the subscription.
|
|
12
|
-
*/
|
|
13
|
-
subscribe(next) {
|
|
14
|
-
return this.db.provider.subscribeQuery(this.collection, this, typeof next === "function" ? { next } : next);
|
|
15
|
-
}
|
|
16
7
|
// Override to include the collection name.
|
|
17
8
|
toString() {
|
|
18
|
-
return `${this.collection}
|
|
9
|
+
return `${this.collection}?{${super.toString()}`;
|
|
10
|
+
}
|
|
11
|
+
/** Subscribe to this item. */
|
|
12
|
+
subscribe(onNext, onError) {
|
|
13
|
+
return runSequence(this, onNext, onError);
|
|
14
|
+
}
|
|
15
|
+
// Implement AsyncIterable
|
|
16
|
+
[Symbol.asyncIterator]() {
|
|
17
|
+
return this.db.provider.getQuerySequence(this.collection, this)[Symbol.asyncIterator]();
|
|
19
18
|
}
|
|
20
19
|
}
|
|
21
20
|
/** Reference to a set of items in a provider. */
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
@@ -1,10 +1,8 @@
|
|
|
1
1
|
import type { Firestore } from "firebase/firestore";
|
|
2
2
|
import type { Data } from "../../util/data.js";
|
|
3
|
-
import type { Unsubscribe } from "../../observe/Observable.js";
|
|
4
3
|
import type { AsyncProvider } from "../../provider/Provider.js";
|
|
5
4
|
import type { ItemArray, ItemValue, ItemConstraints } from "../../db/Item.js";
|
|
6
|
-
import {
|
|
7
|
-
import { Updates } from "../../update/DataUpdate.js";
|
|
5
|
+
import { Updates } from "../../update/index.js";
|
|
8
6
|
/**
|
|
9
7
|
* Firestore client database provider.
|
|
10
8
|
* - Works with the Firebase JS SDK.
|
|
@@ -15,13 +13,13 @@ export declare class FirestoreClientProvider implements AsyncProvider {
|
|
|
15
13
|
private readonly _firestore;
|
|
16
14
|
constructor(firestore: Firestore);
|
|
17
15
|
getItem(collection: string, id: string): Promise<ItemValue>;
|
|
18
|
-
|
|
16
|
+
getItemSequence<K extends string>(collection: K, id: string): AsyncIterable<ItemValue>;
|
|
19
17
|
addItem(collection: string, data: Data): Promise<string>;
|
|
20
18
|
setItem(collection: string, id: string, data: Data): Promise<void>;
|
|
21
19
|
updateItem(collection: string, id: string, updates: Updates): Promise<void>;
|
|
22
20
|
deleteItem(collection: string, id: string): Promise<void>;
|
|
23
21
|
getQuery(collection: string, constraints: ItemConstraints): Promise<ItemArray>;
|
|
24
|
-
|
|
22
|
+
getQuerySequence<K extends string>(collection: K, constraints: ItemConstraints): AsyncIterable<ItemArray>;
|
|
25
23
|
setQuery(collection: string, constraints: ItemConstraints, data: Data): Promise<number>;
|
|
26
24
|
updateQuery(collection: string, constraints: ItemConstraints, updates: Updates): Promise<number>;
|
|
27
25
|
deleteQuery(collection: string, constraints: ItemConstraints): Promise<number>;
|
|
@@ -1,11 +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
|
-
import {
|
|
3
|
-
import { ArrayUpdate } from "../../update/
|
|
4
|
-
import { DataUpdate } from "../../update/DataUpdate.js";
|
|
5
|
-
import { Increment } from "../../update/Increment.js";
|
|
6
|
-
import { ObjectUpdate } from "../../update/ObjectUpdate.js";
|
|
7
|
-
import { Delete } from "../../update/Delete.js";
|
|
8
|
-
import { Update } from "../../update/Update.js";
|
|
2
|
+
import { LazyDeferredSequence } from "../../sequence/LazyDeferredSequence.js";
|
|
3
|
+
import { ArrayUpdate, DataUpdate, Increment, ObjectUpdate, Delete, Update } from "../../update/index.js";
|
|
9
4
|
// Constants.
|
|
10
5
|
// const ID = "__name__"; // DH: `__name__` is the entire path of the document. `__id__` is just ID.
|
|
11
6
|
const ID = "__id__"; // Internal way Firestore Queries can reference the ID of the current document.
|
|
@@ -91,8 +86,10 @@ export class FirestoreClientProvider {
|
|
|
91
86
|
async getItem(collection, id) {
|
|
92
87
|
return _getItemValue(await getDoc(firestoreDocument(this._firestore, collection, id)));
|
|
93
88
|
}
|
|
94
|
-
|
|
95
|
-
return onSnapshot(firestoreDocument(this._firestore, collection, id),
|
|
89
|
+
getItemSequence(collection, id) {
|
|
90
|
+
return new LazyDeferredSequence(({ resolve, reject }) => onSnapshot(firestoreDocument(this._firestore, collection, id), //
|
|
91
|
+
//
|
|
92
|
+
snapshot => resolve(_getItemValue(snapshot)), reject));
|
|
96
93
|
}
|
|
97
94
|
async addItem(collection, data) {
|
|
98
95
|
const reference = await addDoc(firestoreCollection(this._firestore, collection), data);
|
|
@@ -110,8 +107,10 @@ export class FirestoreClientProvider {
|
|
|
110
107
|
async getQuery(collection, constraints) {
|
|
111
108
|
return _getItems(await getDocs(_getQuery(this._firestore, collection, constraints)));
|
|
112
109
|
}
|
|
113
|
-
|
|
114
|
-
return onSnapshot(_getQuery(this._firestore, collection, constraints),
|
|
110
|
+
getQuerySequence(collection, constraints) {
|
|
111
|
+
return new LazyDeferredSequence(({ resolve, reject }) => onSnapshot(_getQuery(this._firestore, collection, constraints), //
|
|
112
|
+
//
|
|
113
|
+
snapshot => resolve(_getItems(snapshot)), reject));
|
|
115
114
|
}
|
|
116
115
|
async setQuery(collection, constraints, data) {
|
|
117
116
|
const snapshot = await getDocs(_getQuery(this._firestore, collection, constraints));
|
|
File without changes
|
|
File without changes
|
|
@@ -1,9 +1,8 @@
|
|
|
1
1
|
import type { Firestore } from "firebase/firestore/lite";
|
|
2
2
|
import type { Data } from "../../util/data.js";
|
|
3
|
-
import type { Unsubscribe } from "../../observe/Observable.js";
|
|
4
3
|
import type { AsyncProvider } from "../../provider/Provider.js";
|
|
5
4
|
import type { ItemArray, ItemValue, ItemConstraints } from "../../db/Item.js";
|
|
6
|
-
import { Updates } from "../../update/
|
|
5
|
+
import { Updates } from "../../update/index.js";
|
|
7
6
|
/**
|
|
8
7
|
* Firestore Lite client database provider.
|
|
9
8
|
* - Works with the Firebase JS SDK.
|
|
@@ -14,13 +13,13 @@ export declare class FirestoreLiteProvider implements AsyncProvider {
|
|
|
14
13
|
private readonly _firestore;
|
|
15
14
|
constructor(firestore: Firestore);
|
|
16
15
|
getItem(collection: string, id: string): Promise<ItemValue>;
|
|
17
|
-
|
|
16
|
+
getItemSequence(): AsyncIterableIterator<ItemValue>;
|
|
18
17
|
addItem(collection: string, data: Data): Promise<string>;
|
|
19
18
|
setItem(collection: string, id: string, data: Data): Promise<void>;
|
|
20
19
|
updateItem(collection: string, id: string, updates: Updates): Promise<void>;
|
|
21
20
|
deleteItem(collection: string, id: string): Promise<void>;
|
|
22
21
|
getQuery(collection: string, constraints: ItemConstraints): Promise<ItemArray>;
|
|
23
|
-
|
|
22
|
+
getQuerySequence(): AsyncIterableIterator<ItemArray>;
|
|
24
23
|
setQuery(collection: string, constraints: ItemConstraints, data: Data): Promise<number>;
|
|
25
24
|
updateQuery(collection: string, constraints: ItemConstraints, updates: Updates): Promise<number>;
|
|
26
25
|
deleteQuery(collection: string, constraints: ItemConstraints): Promise<number>;
|
|
@@ -1,11 +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 } from "../../update/
|
|
4
|
-
import { DataUpdate } from "../../update/DataUpdate.js";
|
|
5
|
-
import { Increment } from "../../update/Increment.js";
|
|
6
|
-
import { ObjectUpdate } from "../../update/ObjectUpdate.js";
|
|
7
|
-
import { Update } from "../../update/Update.js";
|
|
8
|
-
import { Delete } from "../../update/Delete.js";
|
|
3
|
+
import { ArrayUpdate, DataUpdate, Increment, ObjectUpdate, Delete, Update } from "../../update/index.js";
|
|
9
4
|
// Constants.
|
|
10
5
|
// const ID = "__name__"; // DH: `__name__` is the entire path of the document. `__id__` is just ID.
|
|
11
6
|
const ID = "__id__"; // Internal way Firestore Queries can reference the ID of the current document.
|
|
@@ -91,7 +86,7 @@ export class FirestoreLiteProvider {
|
|
|
91
86
|
async getItem(collection, id) {
|
|
92
87
|
return _getItemValue(await getDoc(firestoreDocument(this._firestore, collection, id)));
|
|
93
88
|
}
|
|
94
|
-
|
|
89
|
+
getItemSequence() {
|
|
95
90
|
throw new UnsupportedError("FirestoreLiteProvider does not support realtime subscriptions");
|
|
96
91
|
}
|
|
97
92
|
async addItem(collection, data) {
|
|
@@ -110,7 +105,7 @@ export class FirestoreLiteProvider {
|
|
|
110
105
|
async getQuery(collection, constraints) {
|
|
111
106
|
return _getItems(await getDocs(_getQuery(this._firestore, collection, constraints)));
|
|
112
107
|
}
|
|
113
|
-
|
|
108
|
+
getQuerySequence() {
|
|
114
109
|
throw new UnsupportedError("FirestoreLiteProvider does not support realtime subscriptions");
|
|
115
110
|
}
|
|
116
111
|
async setQuery(collection, constraints, data) {
|
|
File without changes
|
|
File without changes
|