shelving 1.76.2 → 1.79.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/{api → modules/api}/Resource.d.ts +0 -0
- package/{api → modules/api}/Resource.js +0 -0
- package/{api → modules/api}/index.d.ts +0 -0
- package/{api → modules/api}/index.js +0 -0
- package/{constraint → modules/constraint}/Constraint.d.ts +0 -0
- package/{constraint → modules/constraint}/Constraint.js +0 -0
- package/{constraint → modules/constraint}/Constraints.d.ts +1 -1
- package/{constraint → modules/constraint}/Constraints.js +0 -0
- package/{constraint → modules/constraint}/FilterConstraint.d.ts +6 -6
- package/{constraint → modules/constraint}/FilterConstraint.js +1 -1
- package/{constraint → modules/constraint}/FilterConstraints.d.ts +5 -5
- package/{constraint → modules/constraint}/FilterConstraints.js +0 -0
- package/{constraint → modules/constraint}/QueryConstraints.d.ts +4 -4
- package/{constraint → modules/constraint}/QueryConstraints.js +2 -2
- package/{constraint → modules/constraint}/SortConstraint.d.ts +4 -3
- package/{constraint → modules/constraint}/SortConstraint.js +2 -3
- package/{constraint → modules/constraint}/SortConstraints.d.ts +5 -5
- package/{constraint → modules/constraint}/SortConstraints.js +0 -0
- package/{constraint → modules/constraint}/index.d.ts +0 -0
- package/{constraint → modules/constraint}/index.js +0 -0
- package/{db → modules/db}/Change.d.ts +10 -13
- package/{db → modules/db}/Change.js +2 -2
- package/modules/db/Collection.d.ts +74 -0
- package/{db → modules/db}/Collection.js +47 -7
- package/modules/db/Database.d.ts +76 -0
- package/modules/db/Database.js +95 -0
- package/{db → modules/db}/Item.d.ts +9 -9
- package/{db → modules/db}/Item.js +19 -21
- package/{db → modules/db}/Query.d.ts +6 -6
- package/{db → modules/db}/Query.js +2 -3
- package/{db → modules/db}/index.d.ts +0 -0
- package/{db → modules/db}/index.js +0 -0
- package/{error → modules/error}/AssertionError.d.ts +0 -0
- package/{error → modules/error}/AssertionError.js +0 -0
- package/{error → modules/error}/ConditionError.d.ts +0 -0
- package/{error → modules/error}/ConditionError.js +0 -0
- package/{error → modules/error}/PermissionError.d.ts +0 -0
- package/{error → modules/error}/PermissionError.js +0 -0
- package/{error → modules/error}/RequiredError.d.ts +0 -0
- package/{error → modules/error}/RequiredError.js +0 -0
- package/{error → modules/error}/ThroughError.d.ts +0 -0
- package/{error → modules/error}/ThroughError.js +0 -0
- package/{error → modules/error}/UnsupportedError.d.ts +0 -0
- package/{error → modules/error}/UnsupportedError.js +0 -0
- package/{error → modules/error}/ValidationError.d.ts +0 -0
- package/{error → modules/error}/ValidationError.js +0 -0
- package/{error → modules/error}/index.d.ts +0 -0
- package/{error → modules/error}/index.js +0 -0
- package/{feedback → modules/feedback}/ErrorFeedback.d.ts +0 -0
- package/{feedback → modules/feedback}/ErrorFeedback.js +1 -5
- package/{feedback → modules/feedback}/Feedback.d.ts +0 -0
- package/{feedback → modules/feedback}/Feedback.js +1 -5
- package/{feedback → modules/feedback}/InvalidFeedback.d.ts +0 -0
- package/{feedback → modules/feedback}/InvalidFeedback.js +1 -5
- package/{feedback → modules/feedback}/SuccessFeedback.d.ts +0 -0
- package/{feedback → modules/feedback}/SuccessFeedback.js +1 -5
- package/{feedback → modules/feedback}/WarningFeedback.d.ts +0 -0
- package/{feedback → modules/feedback}/WarningFeedback.js +1 -5
- package/{feedback → modules/feedback}/hydrations.d.ts +0 -0
- package/{feedback → modules/feedback}/hydrations.js +0 -0
- package/{feedback → modules/feedback}/index.d.ts +0 -0
- package/{feedback → modules/feedback}/index.js +0 -0
- package/{firestore → modules/firestore}/client/FirestoreClientProvider.d.ts +3 -3
- package/{firestore → modules/firestore}/client/FirestoreClientProvider.js +4 -4
- package/{firestore → modules/firestore}/client/index.d.ts +0 -0
- package/{firestore → modules/firestore}/client/index.js +0 -0
- package/{firestore → modules/firestore}/lite/FirestoreLiteProvider.d.ts +3 -3
- package/{firestore → modules/firestore}/lite/FirestoreLiteProvider.js +4 -4
- package/{firestore → modules/firestore}/lite/index.d.ts +0 -0
- package/{firestore → modules/firestore}/lite/index.js +0 -0
- package/{firestore → modules/firestore}/server/FirestoreServerProvider.d.ts +3 -3
- package/{firestore → modules/firestore}/server/FirestoreServerProvider.js +4 -4
- package/{firestore → modules/firestore}/server/index.d.ts +0 -0
- package/{firestore → modules/firestore}/server/index.js +0 -0
- package/{index.d.ts → modules/index.d.ts} +0 -0
- package/{index.js → modules/index.js} +0 -0
- package/{markup → modules/markup}/index.d.ts +0 -0
- package/{markup → modules/markup}/index.js +0 -0
- package/{markup → modules/markup}/options.d.ts +0 -0
- package/{markup → modules/markup}/options.js +0 -0
- package/{markup → modules/markup}/regexp.d.ts +0 -0
- package/{markup → modules/markup}/regexp.js +0 -0
- package/{markup → modules/markup}/render.d.ts +0 -0
- package/{markup → modules/markup}/render.js +0 -0
- package/{markup → modules/markup}/rules.d.ts +0 -0
- package/{markup → modules/markup}/rules.js +0 -0
- package/{observe → modules/observe}/AbstractObserver.d.ts +0 -0
- package/{observe → modules/observe}/AbstractObserver.js +0 -0
- package/{observe → modules/observe}/AsyncObserver.d.ts +0 -0
- package/{observe → modules/observe}/AsyncObserver.js +0 -0
- package/{observe → modules/observe}/LastSubject.d.ts +0 -0
- package/{observe → modules/observe}/LastSubject.js +0 -0
- package/{observe → modules/observe}/MatchObserver.d.ts +0 -0
- package/{observe → modules/observe}/MatchObserver.js +0 -0
- package/{observe → modules/observe}/MatchableObserver.d.ts +0 -0
- package/{observe → modules/observe}/MatchableObserver.js +0 -0
- package/{observe → modules/observe}/Observable.d.ts +0 -0
- package/{observe → modules/observe}/Observable.js +0 -0
- package/{observe → modules/observe}/Observer.d.ts +0 -0
- package/{observe → modules/observe}/Observer.js +0 -0
- package/{observe → modules/observe}/OnceObserver.d.ts +0 -0
- package/{observe → modules/observe}/OnceObserver.js +0 -0
- package/{observe → modules/observe}/Subject.d.ts +0 -0
- package/{observe → modules/observe}/Subject.js +0 -0
- package/{observe → modules/observe}/ThroughObserver.d.ts +0 -0
- package/{observe → modules/observe}/ThroughObserver.js +0 -0
- package/{observe → modules/observe}/TransformObserver.d.ts +0 -0
- package/{observe → modules/observe}/TransformObserver.js +0 -0
- package/{observe → modules/observe}/TransformableObserver.d.ts +0 -0
- package/{observe → modules/observe}/TransformableObserver.js +0 -0
- package/{observe → modules/observe}/index.d.ts +0 -0
- package/{observe → modules/observe}/index.js +0 -0
- package/{observe → modules/observe}/util.d.ts +0 -0
- package/{observe → modules/observe}/util.js +0 -0
- package/{provider → modules/provider}/BatchProvider.d.ts +0 -0
- package/{provider → modules/provider}/BatchProvider.js +0 -0
- package/{provider → modules/provider}/CacheProvider.d.ts +3 -3
- package/{provider → modules/provider}/CacheProvider.js +6 -6
- package/{provider → modules/provider}/DebugProvider.d.ts +5 -5
- package/{provider → modules/provider}/DebugProvider.js +12 -12
- package/{provider → modules/provider}/MemoryProvider.d.ts +5 -5
- package/{provider → modules/provider}/MemoryProvider.js +9 -8
- package/{provider → modules/provider}/Provider.d.ts +7 -7
- package/{provider → modules/provider}/Provider.js +0 -0
- package/{provider → modules/provider}/ThroughProvider.d.ts +5 -5
- package/{provider → modules/provider}/ThroughProvider.js +4 -4
- package/{provider → modules/provider}/ValidationProvider.d.ts +11 -11
- package/{provider → modules/provider}/ValidationProvider.js +29 -28
- package/{provider → modules/provider}/index.d.ts +0 -0
- package/{provider → modules/provider}/index.js +0 -0
- package/{react → modules/react}/index.d.ts +0 -0
- package/{react → modules/react}/index.js +0 -0
- package/{react → modules/react}/useCache.d.ts +0 -0
- package/{react → modules/react}/useCache.js +0 -0
- package/{react → modules/react}/useInstance.d.ts +0 -0
- package/{react → modules/react}/useInstance.js +0 -0
- package/{react → modules/react}/useItem.d.ts +7 -7
- package/{react → modules/react}/useItem.js +0 -0
- package/{react → modules/react}/useLazy.d.ts +0 -0
- package/{react → modules/react}/useLazy.js +0 -0
- package/{react → modules/react}/useQuery.d.ts +10 -10
- package/{react → modules/react}/useQuery.js +0 -0
- package/{react → modules/react}/useReduce.d.ts +0 -0
- package/{react → modules/react}/useReduce.js +0 -0
- package/{react → modules/react}/useSubscribe.d.ts +0 -0
- package/{react → modules/react}/useSubscribe.js +0 -0
- package/{schema → modules/schema}/AllowSchema.d.ts +0 -0
- package/{schema → modules/schema}/AllowSchema.js +0 -0
- package/{schema → modules/schema}/ArraySchema.d.ts +0 -0
- package/{schema → modules/schema}/ArraySchema.js +0 -0
- package/{schema → modules/schema}/BooleanSchema.d.ts +0 -0
- package/{schema → modules/schema}/BooleanSchema.js +0 -0
- package/{schema → modules/schema}/ColorSchema.d.ts +0 -0
- package/{schema → modules/schema}/ColorSchema.js +0 -0
- package/{schema → modules/schema}/DataSchema.d.ts +5 -1
- package/{schema → modules/schema}/DataSchema.js +0 -0
- package/{schema → modules/schema}/DateSchema.d.ts +0 -0
- package/{schema → modules/schema}/DateSchema.js +0 -0
- package/{schema → modules/schema}/EmailSchema.d.ts +0 -0
- package/{schema → modules/schema}/EmailSchema.js +0 -0
- package/{schema → modules/schema}/KeySchema.d.ts +0 -0
- package/{schema → modules/schema}/KeySchema.js +0 -0
- package/{schema → modules/schema}/LinkSchema.d.ts +0 -0
- package/{schema → modules/schema}/LinkSchema.js +0 -0
- package/{schema → modules/schema}/NumberSchema.d.ts +0 -0
- package/{schema → modules/schema}/NumberSchema.js +0 -0
- package/{schema → modules/schema}/ObjectSchema.d.ts +0 -0
- package/{schema → modules/schema}/ObjectSchema.js +0 -0
- package/{schema → modules/schema}/OptionalSchema.d.ts +0 -0
- package/{schema → modules/schema}/OptionalSchema.js +0 -0
- package/{schema → modules/schema}/PhoneSchema.d.ts +0 -0
- package/{schema → modules/schema}/PhoneSchema.js +0 -0
- package/{schema → modules/schema}/RequiredSchema.d.ts +0 -0
- package/{schema → modules/schema}/RequiredSchema.js +0 -0
- package/{schema → modules/schema}/Schema.d.ts +0 -0
- package/{schema → modules/schema}/Schema.js +0 -0
- package/{schema → modules/schema}/SlugSchema.d.ts +0 -0
- package/{schema → modules/schema}/SlugSchema.js +0 -0
- package/{schema → modules/schema}/StringSchema.d.ts +0 -0
- package/{schema → modules/schema}/StringSchema.js +0 -0
- package/{schema → modules/schema}/ThroughSchema.d.ts +0 -0
- package/{schema → modules/schema}/ThroughSchema.js +0 -0
- package/{schema → modules/schema}/index.d.ts +0 -0
- package/{schema → modules/schema}/index.js +0 -0
- package/{state → modules/state}/ArrayState.d.ts +0 -0
- package/{state → modules/state}/ArrayState.js +0 -0
- package/{state → modules/state}/BooleanState.d.ts +0 -0
- package/{state → modules/state}/BooleanState.js +0 -0
- package/{state → modules/state}/DataState.d.ts +3 -3
- package/{state → modules/state}/DataState.js +0 -0
- package/{state → modules/state}/ObjectState.d.ts +0 -0
- package/{state → modules/state}/ObjectState.js +0 -0
- package/{state → modules/state}/SelfClosingState.d.ts +0 -0
- package/{state → modules/state}/SelfClosingState.js +0 -0
- package/{state → modules/state}/State.d.ts +0 -0
- package/{state → modules/state}/State.js +0 -0
- package/{state → modules/state}/index.d.ts +0 -0
- package/{state → modules/state}/index.js +0 -0
- package/{test → modules/test}/basics.d.ts +0 -0
- package/{test → modules/test}/basics.js +0 -0
- package/{test → modules/test}/index.d.ts +0 -0
- package/{test → modules/test}/index.js +0 -0
- package/{test → modules/test}/people.d.ts +0 -0
- package/{test → modules/test}/people.js +0 -0
- package/{test → modules/test}/util.d.ts +0 -0
- package/{test → modules/test}/util.js +0 -0
- package/{update → modules/update}/ArrayUpdate.d.ts +0 -0
- package/{update → modules/update}/ArrayUpdate.js +0 -0
- package/{update → modules/update}/DataUpdate.d.ts +15 -7
- package/{update → modules/update}/DataUpdate.js +28 -21
- package/{update → modules/update}/Delete.d.ts +0 -0
- package/{update → modules/update}/Delete.js +0 -0
- package/{update → modules/update}/Increment.d.ts +0 -0
- package/{update → modules/update}/Increment.js +0 -0
- package/{update → modules/update}/ObjectUpdate.d.ts +0 -0
- package/{update → modules/update}/ObjectUpdate.js +0 -0
- package/{update → modules/update}/Update.d.ts +0 -0
- package/{update → modules/update}/Update.js +0 -0
- package/{update → modules/update}/hydrations.d.ts +0 -0
- package/{update → modules/update}/hydrations.js +0 -0
- package/{update → modules/update}/index.d.ts +0 -0
- package/{update → modules/update}/index.js +0 -0
- package/{util → modules/util}/array.d.ts +0 -0
- package/{util → modules/util}/array.js +0 -0
- package/{util → modules/util}/assert.d.ts +0 -0
- package/{util → modules/util}/assert.js +0 -0
- package/{util → modules/util}/async.d.ts +0 -0
- package/{util → modules/util}/async.js +0 -0
- package/{util → modules/util}/boolean.d.ts +0 -0
- package/{util → modules/util}/boolean.js +0 -0
- package/{util → modules/util}/class.d.ts +0 -0
- package/{util → modules/util}/class.js +0 -0
- package/{util → modules/util}/clone.d.ts +0 -0
- package/{util → modules/util}/clone.js +0 -0
- package/{util → modules/util}/color.d.ts +0 -0
- package/{util → modules/util}/color.js +0 -0
- package/{util → modules/util}/data.d.ts +0 -0
- package/{util → modules/util}/data.js +0 -0
- package/{util → modules/util}/date.d.ts +0 -0
- package/{util → modules/util}/date.js +0 -0
- package/{util → modules/util}/debug.d.ts +0 -0
- package/{util → modules/util}/debug.js +0 -0
- package/{util → modules/util}/diff.d.ts +0 -0
- package/{util → modules/util}/diff.js +0 -0
- package/{util → modules/util}/entry.d.ts +0 -0
- package/{util → modules/util}/entry.js +0 -0
- package/{util → modules/util}/equal.d.ts +0 -0
- package/{util → modules/util}/equal.js +0 -0
- package/{util → modules/util}/error.d.ts +0 -0
- package/{util → modules/util}/error.js +0 -0
- package/{util → modules/util}/filter.d.ts +0 -0
- package/{util → modules/util}/filter.js +0 -0
- package/{util → modules/util}/function.d.ts +0 -0
- package/{util → modules/util}/function.js +0 -0
- package/{util → modules/util}/hydrate.d.ts +0 -0
- package/{util → modules/util}/hydrate.js +0 -0
- package/{util → modules/util}/index.d.ts +0 -0
- package/{util → modules/util}/index.js +0 -0
- package/{util → modules/util}/iterate.d.ts +0 -0
- package/{util → modules/util}/iterate.js +0 -0
- package/{util → modules/util}/jsx.d.ts +0 -0
- package/{util → modules/util}/jsx.js +0 -0
- package/{util → modules/util}/lazy.d.ts +0 -0
- package/{util → modules/util}/lazy.js +0 -0
- package/{util → modules/util}/map.d.ts +0 -0
- package/{util → modules/util}/map.js +0 -0
- package/{util → modules/util}/match.d.ts +0 -0
- package/{util → modules/util}/match.js +0 -0
- package/{util → modules/util}/merge.d.ts +0 -0
- package/{util → modules/util}/merge.js +0 -0
- package/{util → modules/util}/null.d.ts +0 -0
- package/{util → modules/util}/null.js +0 -0
- package/{util → modules/util}/number.d.ts +0 -0
- package/{util → modules/util}/number.js +0 -0
- package/{util → modules/util}/object.d.ts +0 -0
- package/{util → modules/util}/object.js +0 -0
- package/{util → modules/util}/random.d.ts +0 -0
- package/{util → modules/util}/random.js +0 -0
- package/{util → modules/util}/regexp.d.ts +0 -0
- package/{util → modules/util}/regexp.js +0 -0
- package/{util → modules/util}/serialise.d.ts +0 -0
- package/{util → modules/util}/serialise.js +0 -0
- package/{util → modules/util}/set.d.ts +0 -0
- package/{util → modules/util}/set.js +0 -0
- package/{util → modules/util}/sort.d.ts +0 -0
- package/{util → modules/util}/sort.js +0 -0
- package/{util → modules/util}/source.d.ts +0 -0
- package/{util → modules/util}/source.js +0 -0
- package/{util → modules/util}/string.d.ts +0 -0
- package/{util → modules/util}/string.js +0 -0
- package/{util → modules/util}/template.d.ts +0 -0
- package/{util → modules/util}/template.js +0 -0
- package/{util → modules/util}/timeout.d.ts +0 -0
- package/{util → modules/util}/timeout.js +0 -0
- package/{util → modules/util}/transform.d.ts +3 -3
- package/{util → modules/util}/transform.js +0 -0
- package/{util → modules/util}/undefined.d.ts +0 -0
- package/{util → modules/util}/undefined.js +0 -0
- package/{util → modules/util}/units.d.ts +0 -0
- package/{util → modules/util}/units.js +0 -0
- package/{util → modules/util}/url.d.ts +0 -0
- package/{util → modules/util}/url.js +0 -0
- package/{util → modules/util}/validate.d.ts +0 -0
- package/{util → modules/util}/validate.js +0 -0
- package/package.json +8 -8
- package/db/Collection.d.ts +0 -46
- package/db/Database.d.ts +0 -42
- package/db/Database.js +0 -43
|
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
|
|
@@ -2,7 +2,7 @@ import type { Datas, Key } from "../util/data.js";
|
|
|
2
2
|
import type { ItemArray, ItemValue, ItemConstraints } from "../db/Item.js";
|
|
3
3
|
import type { PartialObserver } from "../observe/Observer.js";
|
|
4
4
|
import type { Unsubscribe } from "../observe/Observable.js";
|
|
5
|
-
import type {
|
|
5
|
+
import type { Updates } from "../update/DataUpdate.js";
|
|
6
6
|
import type { AsyncProvider } from "./Provider.js";
|
|
7
7
|
import type { AsyncThroughProvider } from "./ThroughProvider.js";
|
|
8
8
|
import { MemoryProvider } from "./MemoryProvider.js";
|
|
@@ -15,11 +15,11 @@ export declare class CacheProvider<T extends Datas> implements AsyncThroughProvi
|
|
|
15
15
|
subscribeItem<K extends Key<T>>(collection: K, id: string, observer: PartialObserver<ItemValue<T[K]>>): Unsubscribe;
|
|
16
16
|
addItem<K extends Key<T>>(collection: K, data: T[K]): Promise<string>;
|
|
17
17
|
setItem<K extends Key<T>>(collection: K, id: string, data: T[K]): Promise<void>;
|
|
18
|
-
updateItem<K extends Key<T>>(collection: K, id: string,
|
|
18
|
+
updateItem<K extends Key<T>>(collection: K, id: string, updates: Updates<T[K]>): Promise<void>;
|
|
19
19
|
deleteItem<K extends Key<T>>(collection: K, id: string): Promise<void>;
|
|
20
20
|
getQuery<K extends Key<T>>(collection: K, constraints: ItemConstraints<T[K]>): Promise<ItemArray<T[K]>>;
|
|
21
21
|
subscribeQuery<K extends Key<T>>(collection: K, constraints: ItemConstraints<T[K]>, observer: PartialObserver<ItemArray<T[K]>>): Unsubscribe;
|
|
22
22
|
setQuery<K extends Key<T>>(collection: K, constraints: ItemConstraints<T[K]>, data: T[K]): Promise<number>;
|
|
23
|
-
updateQuery<K extends Key<T>>(collection: K, constraints: ItemConstraints<T[K]>,
|
|
23
|
+
updateQuery<K extends Key<T>>(collection: K, constraints: ItemConstraints<T[K]>, updates: Updates<T[K]>): Promise<number>;
|
|
24
24
|
deleteQuery<K extends Key<T>>(collection: K, constraints: ItemConstraints<T[K]>): Promise<number>;
|
|
25
25
|
}
|
|
@@ -24,11 +24,11 @@ export class CacheProvider {
|
|
|
24
24
|
await this.source.setItem(collection, id, data);
|
|
25
25
|
this.memory.getTable(collection).setItem(id, data);
|
|
26
26
|
}
|
|
27
|
-
async updateItem(collection, id,
|
|
28
|
-
await this.source.updateItem(collection, id,
|
|
27
|
+
async updateItem(collection, id, updates) {
|
|
28
|
+
await this.source.updateItem(collection, id, updates);
|
|
29
29
|
const table = this.memory.getTable(collection);
|
|
30
30
|
if (table.getItem(id))
|
|
31
|
-
table.updateItem(id,
|
|
31
|
+
table.updateItem(id, updates);
|
|
32
32
|
}
|
|
33
33
|
async deleteItem(collection, id) {
|
|
34
34
|
await this.source.deleteItem(collection, id);
|
|
@@ -49,9 +49,9 @@ export class CacheProvider {
|
|
|
49
49
|
this.memory.getTable(collection).setQuery(constraints, data);
|
|
50
50
|
return count;
|
|
51
51
|
}
|
|
52
|
-
async updateQuery(collection, constraints,
|
|
53
|
-
const count = await this.source.updateQuery(collection, constraints,
|
|
54
|
-
this.memory.getTable(collection).updateQuery(constraints,
|
|
52
|
+
async updateQuery(collection, constraints, updates) {
|
|
53
|
+
const count = await this.source.updateQuery(collection, constraints, updates);
|
|
54
|
+
this.memory.getTable(collection).updateQuery(constraints, updates);
|
|
55
55
|
return count;
|
|
56
56
|
}
|
|
57
57
|
async deleteQuery(collection, constraints) {
|
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
import type { Datas, Key } from "../util/data.js";
|
|
2
2
|
import type { ItemArray, ItemConstraints, ItemValue } from "../db/Item.js";
|
|
3
|
-
import type {
|
|
3
|
+
import type { Updates } from "../update/DataUpdate.js";
|
|
4
4
|
import type { PartialObserver } from "../observe/Observer.js";
|
|
5
5
|
import type { Unsubscribe } from "../observe/Observable.js";
|
|
6
6
|
import { Provider, AsyncProvider } from "./Provider.js";
|
|
@@ -18,11 +18,11 @@ export declare class DebugProvider<T extends Datas> extends AbstractDebugProvide
|
|
|
18
18
|
getItem<K extends Key<T>>(collection: K, id: string): ItemValue<T[K]>;
|
|
19
19
|
addItem<K extends Key<T>>(collection: K, data: T[K]): string;
|
|
20
20
|
setItem<K extends Key<T>>(collection: K, id: string, data: T[K]): void;
|
|
21
|
-
updateItem<K extends Key<T>>(collection: K, id: string,
|
|
21
|
+
updateItem<K extends Key<T>>(collection: K, id: string, updates: Updates<T[K]>): void;
|
|
22
22
|
deleteItem<K extends Key<T>>(collection: K, id: string): void;
|
|
23
23
|
getQuery<K extends Key<T>>(collection: K, constraints: ItemConstraints<T[K]>): ItemArray<T[K]>;
|
|
24
24
|
setQuery<K extends Key<T>>(collection: K, constraints: ItemConstraints<T[K]>, data: T[K]): number;
|
|
25
|
-
updateQuery<K extends Key<T>>(collection: K, constraints: ItemConstraints<T[K]>,
|
|
25
|
+
updateQuery<K extends Key<T>>(collection: K, constraints: ItemConstraints<T[K]>, updates: Updates<T[K]>): number;
|
|
26
26
|
deleteQuery<K extends Key<T>>(collection: K, constraints: ItemConstraints<T[K]>): number;
|
|
27
27
|
}
|
|
28
28
|
/** Provider that logs operations to a synchronous source provider to the console. */
|
|
@@ -32,11 +32,11 @@ export declare class AsyncDebugProvider<T extends Datas> extends AbstractDebugPr
|
|
|
32
32
|
getItem<K extends Key<T>>(collection: K, id: string): Promise<ItemValue<T[K]>>;
|
|
33
33
|
addItem<K extends Key<T>>(collection: K, data: T[K]): Promise<string>;
|
|
34
34
|
setItem<K extends Key<T>>(collection: K, id: string, data: T[K]): Promise<void>;
|
|
35
|
-
updateItem<K extends Key<T>>(collection: K, id: string,
|
|
35
|
+
updateItem<K extends Key<T>>(collection: K, id: string, updates: Updates<T[K]>): Promise<void>;
|
|
36
36
|
deleteItem<K extends Key<T>>(collection: K, id: string): Promise<void>;
|
|
37
37
|
getQuery<K extends Key<T>>(collection: K, constraints: ItemConstraints<T[K]>): Promise<ItemArray<T[K]>>;
|
|
38
38
|
setQuery<K extends Key<T>>(collection: K, constraints: ItemConstraints<T[K]>, data: T[K]): Promise<number>;
|
|
39
|
-
updateQuery<K extends Key<T>>(collection: K, constraints: ItemConstraints<T[K]>,
|
|
39
|
+
updateQuery<K extends Key<T>>(collection: K, constraints: ItemConstraints<T[K]>, updates: Updates<T[K]>): Promise<number>;
|
|
40
40
|
deleteQuery<K extends Key<T>>(collection: K, constraints: ItemConstraints<T[K]>): Promise<number>;
|
|
41
41
|
}
|
|
42
42
|
export {};
|
|
@@ -64,11 +64,11 @@ export class DebugProvider extends AbstractDebugProvider {
|
|
|
64
64
|
throw reason;
|
|
65
65
|
}
|
|
66
66
|
}
|
|
67
|
-
updateItem(collection, id,
|
|
67
|
+
updateItem(collection, id, updates) {
|
|
68
68
|
const key = _getItemKey(collection, id);
|
|
69
|
-
console.log(`Update: ${key}:`,
|
|
69
|
+
console.log(`Update: ${key}:`, updates.updates);
|
|
70
70
|
try {
|
|
71
|
-
return this.source.updateItem(collection, id,
|
|
71
|
+
return this.source.updateItem(collection, id, updates);
|
|
72
72
|
}
|
|
73
73
|
catch (reason) {
|
|
74
74
|
console.error(`Error: Update: ${key}:`, reason);
|
|
@@ -108,11 +108,11 @@ export class DebugProvider extends AbstractDebugProvider {
|
|
|
108
108
|
throw reason;
|
|
109
109
|
}
|
|
110
110
|
}
|
|
111
|
-
updateQuery(collection, constraints,
|
|
111
|
+
updateQuery(collection, constraints, updates) {
|
|
112
112
|
const key = _getQueryKey(collection, constraints);
|
|
113
|
-
console.log(`Update: ${key}:`,
|
|
113
|
+
console.log(`Update: ${key}:`, updates.updates);
|
|
114
114
|
try {
|
|
115
|
-
return this.source.updateQuery(collection, constraints,
|
|
115
|
+
return this.source.updateQuery(collection, constraints, updates);
|
|
116
116
|
}
|
|
117
117
|
catch (reason) {
|
|
118
118
|
console.error(`Error: Update: ${key}:`, reason);
|
|
@@ -170,11 +170,11 @@ export class AsyncDebugProvider extends AbstractDebugProvider {
|
|
|
170
170
|
throw reason;
|
|
171
171
|
}
|
|
172
172
|
}
|
|
173
|
-
async updateItem(collection, id,
|
|
173
|
+
async updateItem(collection, id, updates) {
|
|
174
174
|
const key = _getItemKey(collection, id);
|
|
175
|
-
console.log(`Update: ${key}:`,
|
|
175
|
+
console.log(`Update: ${key}:`, updates.updates);
|
|
176
176
|
try {
|
|
177
|
-
return await this.source.updateItem(collection, id,
|
|
177
|
+
return await this.source.updateItem(collection, id, updates);
|
|
178
178
|
}
|
|
179
179
|
catch (reason) {
|
|
180
180
|
console.error(`Error: Update: ${key}:`, reason);
|
|
@@ -214,11 +214,11 @@ export class AsyncDebugProvider extends AbstractDebugProvider {
|
|
|
214
214
|
throw reason;
|
|
215
215
|
}
|
|
216
216
|
}
|
|
217
|
-
async updateQuery(collection, constraints,
|
|
217
|
+
async updateQuery(collection, constraints, updates) {
|
|
218
218
|
const key = _getQueryKey(collection, constraints);
|
|
219
|
-
console.log(`Update: ${key}:`,
|
|
219
|
+
console.log(`Update: ${key}:`, updates.updates);
|
|
220
220
|
try {
|
|
221
|
-
return await this.source.updateQuery(collection, constraints,
|
|
221
|
+
return await this.source.updateQuery(collection, constraints, updates);
|
|
222
222
|
}
|
|
223
223
|
catch (reason) {
|
|
224
224
|
console.error(`Error: Update: ${key}:`, reason);
|
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
import type { Data, Datas, Key } from "../util/data.js";
|
|
2
2
|
import type { ItemArray, ItemValue, ItemData, ItemConstraints } from "../db/Item.js";
|
|
3
|
-
import type {
|
|
3
|
+
import type { Updates } from "../update/DataUpdate.js";
|
|
4
4
|
import type { Dispatch } from "../util/function.js";
|
|
5
5
|
import type { Unsubscribe } from "../observe/Observable.js";
|
|
6
6
|
import { Subject } from "../observe/Subject.js";
|
|
@@ -21,13 +21,13 @@ export declare class MemoryProvider<T extends Datas> implements Provider<T> {
|
|
|
21
21
|
subscribeItem<K extends Key<T>>(collection: K, id: string, observer: PartialObserver<ItemValue<T[K]>>): Unsubscribe;
|
|
22
22
|
addItem<K extends Key<T>>(collection: K, data: T[K]): string;
|
|
23
23
|
setItem<K extends Key<T>>(collection: K, id: string, data: T[K]): void;
|
|
24
|
-
updateItem<K extends Key<T>>(collection: K, id: string,
|
|
24
|
+
updateItem<K extends Key<T>>(collection: K, id: string, updates: Updates<T[K]>): void;
|
|
25
25
|
deleteItem<K extends Key<T>>(collection: K, id: string): void;
|
|
26
26
|
getQueryTime<K extends Key<T>>(collection: K, constraints: ItemConstraints<T[K]>): number | null;
|
|
27
27
|
getQuery<K extends Key<T>>(collection: K, constraints: ItemConstraints<T[K]>): ItemArray<T[K]>;
|
|
28
28
|
subscribeQuery<K extends Key<T>>(collection: K, constraints: ItemConstraints<T[K]>, observer: PartialObserver<ItemArray<T[K]>>): Unsubscribe;
|
|
29
29
|
setQuery<K extends Key<T>>(collection: K, constraints: ItemConstraints<T[K]>, data: T[K]): number;
|
|
30
|
-
updateQuery<K extends Key<T>>(collection: K, constraints: ItemConstraints<T[K]>,
|
|
30
|
+
updateQuery<K extends Key<T>>(collection: K, constraints: ItemConstraints<T[K]>, updates: Updates<T[K]>): number;
|
|
31
31
|
deleteQuery<K extends Key<T>>(collection: K, constraints: ItemConstraints<T[K]>): number;
|
|
32
32
|
}
|
|
33
33
|
/**
|
|
@@ -48,7 +48,7 @@ export declare class MemoryTable<T extends Data> extends Subject<void> {
|
|
|
48
48
|
addItem(data: T): string;
|
|
49
49
|
setItemData(data: ItemData<T>): void;
|
|
50
50
|
setItem(id: string, data: T): void;
|
|
51
|
-
updateItem(id: string,
|
|
51
|
+
updateItem(id: string, updates: Updates<T>): void;
|
|
52
52
|
deleteItem(id: string): void;
|
|
53
53
|
getQueryTime(query: ItemConstraints<T>): number | null;
|
|
54
54
|
setQueryTime(query: ItemConstraints<T>): void;
|
|
@@ -58,6 +58,6 @@ export declare class MemoryTable<T extends Data> extends Subject<void> {
|
|
|
58
58
|
subscribeCachedQuery(query: ItemConstraints<T>, observer: PartialObserver<ItemArray<T>>): Unsubscribe;
|
|
59
59
|
setItems(items: ItemArray<T>): number;
|
|
60
60
|
setQuery(constraints: ItemConstraints<T>, data: T): number;
|
|
61
|
-
updateQuery(constraints: ItemConstraints<T>,
|
|
61
|
+
updateQuery(constraints: ItemConstraints<T>, updates: Updates<T>): number;
|
|
62
62
|
deleteQuery(constraints: ItemConstraints<T>): number;
|
|
63
63
|
}
|
|
@@ -5,6 +5,7 @@ import { RequiredError } from "../error/RequiredError.js";
|
|
|
5
5
|
import { Subject } from "../observe/Subject.js";
|
|
6
6
|
import { dispatchNext } from "../observe/Observer.js";
|
|
7
7
|
import { getArray } from "../util/array.js";
|
|
8
|
+
import { transformData } from "../util/transform.js";
|
|
8
9
|
/**
|
|
9
10
|
* Fast in-memory store for data.
|
|
10
11
|
* - Extremely fast (ideal for caching!), but does not persist data after the browser window is closed.
|
|
@@ -34,8 +35,8 @@ export class MemoryProvider {
|
|
|
34
35
|
setItem(collection, id, data) {
|
|
35
36
|
return this.getTable(collection).setItem(id, data);
|
|
36
37
|
}
|
|
37
|
-
updateItem(collection, id,
|
|
38
|
-
return this.getTable(collection).updateItem(id,
|
|
38
|
+
updateItem(collection, id, updates) {
|
|
39
|
+
return this.getTable(collection).updateItem(id, updates);
|
|
39
40
|
}
|
|
40
41
|
deleteItem(collection, id) {
|
|
41
42
|
return this.getTable(collection).deleteItem(id);
|
|
@@ -52,8 +53,8 @@ export class MemoryProvider {
|
|
|
52
53
|
setQuery(collection, constraints, data) {
|
|
53
54
|
return this.getTable(collection).setQuery(constraints, data);
|
|
54
55
|
}
|
|
55
|
-
updateQuery(collection, constraints,
|
|
56
|
-
return this.getTable(collection).updateQuery(constraints,
|
|
56
|
+
updateQuery(collection, constraints, updates) {
|
|
57
|
+
return this.getTable(collection).updateQuery(constraints, updates);
|
|
57
58
|
}
|
|
58
59
|
deleteQuery(collection, constraints) {
|
|
59
60
|
return this.getTable(collection).deleteQuery(constraints);
|
|
@@ -126,11 +127,11 @@ export class MemoryTable extends Subject {
|
|
|
126
127
|
setItem(id, data) {
|
|
127
128
|
this.setItemData({ ...data, id });
|
|
128
129
|
}
|
|
129
|
-
updateItem(id,
|
|
130
|
+
updateItem(id, updates) {
|
|
130
131
|
const item = this._data.get(id);
|
|
131
132
|
if (!item)
|
|
132
133
|
throw new RequiredError(`Document "${id}" does not exist`);
|
|
133
|
-
this.setItemData({ ...
|
|
134
|
+
this.setItemData({ ...transformData(item, updates), id });
|
|
134
135
|
}
|
|
135
136
|
deleteItem(id) {
|
|
136
137
|
this._data.delete(id);
|
|
@@ -197,11 +198,11 @@ export class MemoryTable extends Subject {
|
|
|
197
198
|
this.next();
|
|
198
199
|
return count;
|
|
199
200
|
}
|
|
200
|
-
updateQuery(constraints,
|
|
201
|
+
updateQuery(constraints, updates) {
|
|
201
202
|
const now = Date.now();
|
|
202
203
|
let count = 0;
|
|
203
204
|
for (const item of _getWriteConstraints(constraints).transform(this._data.values())) {
|
|
204
|
-
this.setItemData({ ...
|
|
205
|
+
this.setItemData({ ...transformData(item, updates), id: item.id });
|
|
205
206
|
count++;
|
|
206
207
|
}
|
|
207
208
|
this._times.set(_getQueryKey(constraints), now);
|
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
import type { Unsubscribe } from "../observe/Observable.js";
|
|
2
2
|
import type { PartialObserver } from "../observe/Observer.js";
|
|
3
|
-
import type {
|
|
3
|
+
import type { Updates } from "../update/DataUpdate.js";
|
|
4
4
|
import type { Datas, Key } from "../util/data.js";
|
|
5
5
|
import type { ItemArray, ItemConstraints, ItemValue } from "../db/Item.js";
|
|
6
6
|
/** Provides access to data (e.g. IndexedDB, Firebase, or in-memory cache providers). */
|
|
@@ -43,7 +43,7 @@ declare abstract class AbstractProvider<T extends Datas = Datas> {
|
|
|
43
43
|
* @param update Update instance to set the document to.
|
|
44
44
|
* @throws Error If the document does not exist (ideally a `RequiredError` but may be provider-specific).
|
|
45
45
|
*/
|
|
46
|
-
abstract updateItem<K extends Key<T>>(collection: K, id: string,
|
|
46
|
+
abstract updateItem<K extends Key<T>>(collection: K, id: string, updates: Updates<T[K]>): void | PromiseLike<void>;
|
|
47
47
|
/**
|
|
48
48
|
* Delete a specified document.
|
|
49
49
|
*/
|
|
@@ -75,7 +75,7 @@ declare abstract class AbstractProvider<T extends Datas = Datas> {
|
|
|
75
75
|
* @param update Update instance to set the document to.
|
|
76
76
|
* @return Number of documents that were updated.
|
|
77
77
|
*/
|
|
78
|
-
abstract updateQuery<K extends Key<T>>(collection: K, constraints: ItemConstraints<T[K]>,
|
|
78
|
+
abstract updateQuery<K extends Key<T>>(collection: K, constraints: ItemConstraints<T[K]>, updates: Updates<T[K]>): number | PromiseLike<number>;
|
|
79
79
|
/**
|
|
80
80
|
* Delete all matching documents.
|
|
81
81
|
* @return Number of documents that were deleted.
|
|
@@ -88,12 +88,12 @@ export declare abstract class Provider<T extends Datas = Datas> extends Abstract
|
|
|
88
88
|
abstract subscribeItem<K extends Key<T>>(collection: K, id: string, observer: PartialObserver<ItemValue<T[K]>>): Unsubscribe;
|
|
89
89
|
abstract addItem<K extends Key<T>>(collection: K, data: T[K]): string;
|
|
90
90
|
abstract setItem<K extends Key<T>>(collection: K, id: string, data: T[K]): void;
|
|
91
|
-
abstract updateItem<K extends Key<T>>(collection: K, id: string,
|
|
91
|
+
abstract updateItem<K extends Key<T>>(collection: K, id: string, updates: Updates<T[K]>): void;
|
|
92
92
|
abstract deleteItem<K extends Key<T>>(collection: K, id: string): void;
|
|
93
93
|
abstract getQuery<K extends Key<T>>(collection: K, constraints: ItemConstraints<T[K]>): ItemArray<T[K]>;
|
|
94
94
|
abstract subscribeQuery<K extends Key<T>>(collection: K, constraints: ItemConstraints<T[K]>, observer: PartialObserver<ItemArray<T[K]>>): Unsubscribe;
|
|
95
95
|
abstract setQuery<K extends Key<T>>(collection: K, constraints: ItemConstraints<T[K]>, data: T[K]): number;
|
|
96
|
-
abstract updateQuery<K extends Key<T>>(collection: K, constraints: ItemConstraints<T[K]>,
|
|
96
|
+
abstract updateQuery<K extends Key<T>>(collection: K, constraints: ItemConstraints<T[K]>, updates: Updates<T[K]>): number;
|
|
97
97
|
abstract deleteQuery<K extends Key<T>>(collection: K, constraints: ItemConstraints<T[K]>): number;
|
|
98
98
|
}
|
|
99
99
|
/** Provider with a fully asynchronous interface */
|
|
@@ -102,12 +102,12 @@ export declare abstract class AsyncProvider<T extends Datas = Datas> extends Abs
|
|
|
102
102
|
abstract subscribeItem<K extends Key<T>>(collection: K, id: string, observer: PartialObserver<ItemValue<T[K]>>): Unsubscribe;
|
|
103
103
|
abstract addItem<K extends Key<T>>(collection: K, data: T[K]): Promise<string>;
|
|
104
104
|
abstract setItem<K extends Key<T>>(collection: K, id: string, data: T[K]): Promise<void>;
|
|
105
|
-
abstract updateItem<K extends Key<T>>(collection: K, id: string,
|
|
105
|
+
abstract updateItem<K extends Key<T>>(collection: K, id: string, updates: Updates<T[K]>): Promise<void>;
|
|
106
106
|
abstract deleteItem<K extends Key<T>>(collection: K, id: string): Promise<void>;
|
|
107
107
|
abstract getQuery<K extends Key<T>>(collection: K, constraints: ItemConstraints<T[K]>): Promise<ItemArray<T[K]>>;
|
|
108
108
|
abstract subscribeQuery<K extends Key<T>>(collection: K, constraints: ItemConstraints<T[K]>, observer: PartialObserver<ItemArray<T[K]>>): Unsubscribe;
|
|
109
109
|
abstract setQuery<K extends Key<T>>(collection: K, constraints: ItemConstraints<T[K]>, data: T[K]): Promise<number>;
|
|
110
|
-
abstract updateQuery<K extends Key<T>>(collection: K, constraints: ItemConstraints<T[K]>,
|
|
110
|
+
abstract updateQuery<K extends Key<T>>(collection: K, constraints: ItemConstraints<T[K]>, updates: Updates<T[K]>): Promise<number>;
|
|
111
111
|
abstract deleteQuery<K extends Key<T>>(collection: K, constraints: ItemConstraints<T[K]>): Promise<number>;
|
|
112
112
|
}
|
|
113
113
|
export {};
|
|
File without changes
|
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
import type { Datas, Key } from "../util/data.js";
|
|
2
2
|
import type { Sourceable } from "../util/source.js";
|
|
3
3
|
import type { ItemArray, ItemConstraints, ItemValue } from "../db/Item.js";
|
|
4
|
-
import type {
|
|
4
|
+
import type { Updates } from "../update/DataUpdate.js";
|
|
5
5
|
import type { PartialObserver } from "../observe/Observer.js";
|
|
6
6
|
import type { Unsubscribe } from "../observe/Observable.js";
|
|
7
7
|
import type { Provider, AsyncProvider } from "./Provider.js";
|
|
@@ -13,12 +13,12 @@ export declare class ThroughProvider<T extends Datas = Datas> implements Provide
|
|
|
13
13
|
subscribeItem<K extends Key<T>>(collection: K, id: string, observer: PartialObserver<ItemValue<T[K]>>): Unsubscribe;
|
|
14
14
|
addItem<K extends Key<T>>(collection: K, data: T[K]): string;
|
|
15
15
|
setItem<K extends Key<T>>(collection: K, id: string, data: T[K]): void;
|
|
16
|
-
updateItem<K extends Key<T>>(collection: K, id: string, update:
|
|
16
|
+
updateItem<K extends Key<T>>(collection: K, id: string, update: Updates<T[K]>): void;
|
|
17
17
|
deleteItem<K extends Key<T>>(collection: K, id: string): void;
|
|
18
18
|
getQuery<K extends Key<T>>(collection: K, constraints: ItemConstraints<T[K]>): ItemArray<T[K]>;
|
|
19
19
|
subscribeQuery<K extends Key<T>>(collection: K, constraints: ItemConstraints<T[K]>, observer: PartialObserver<ItemArray<T[K]>>): Unsubscribe;
|
|
20
20
|
setQuery<K extends Key<T>>(collection: K, constraints: ItemConstraints<T[K]>, data: T[K]): number;
|
|
21
|
-
updateQuery<K extends Key<T>>(collection: K, constraints: ItemConstraints<T[K]>, update:
|
|
21
|
+
updateQuery<K extends Key<T>>(collection: K, constraints: ItemConstraints<T[K]>, update: Updates<T[K]>): number;
|
|
22
22
|
deleteQuery<K extends Key<T>>(collection: K, constraints: ItemConstraints<T[K]>): number;
|
|
23
23
|
}
|
|
24
24
|
/** A provider that passes through to an asynchronous source. */
|
|
@@ -29,11 +29,11 @@ export declare class AsyncThroughProvider<T extends Datas = Datas> implements As
|
|
|
29
29
|
subscribeItem<K extends Key<T>>(collection: K, id: string, observer: PartialObserver<ItemValue<T[K]>>): Unsubscribe;
|
|
30
30
|
addItem<K extends Key<T>>(collection: K, data: T[K]): Promise<string>;
|
|
31
31
|
setItem<K extends Key<T>>(collection: K, id: string, data: T[K]): Promise<void>;
|
|
32
|
-
updateItem<K extends Key<T>>(collection: K, id: string,
|
|
32
|
+
updateItem<K extends Key<T>>(collection: K, id: string, updates: Updates<T[K]>): Promise<void>;
|
|
33
33
|
deleteItem<K extends Key<T>>(collection: K, id: string): Promise<void>;
|
|
34
34
|
getQuery<K extends Key<T>>(collection: K, constraints: ItemConstraints<T[K]>): Promise<ItemArray<T[K]>>;
|
|
35
35
|
subscribeQuery<K extends Key<T>>(collection: K, constraints: ItemConstraints<T[K]>, observer: PartialObserver<ItemArray<T[K]>>): Unsubscribe;
|
|
36
36
|
setQuery<K extends Key<T>>(collection: K, constraints: ItemConstraints<T[K]>, data: T[K]): Promise<number>;
|
|
37
|
-
updateQuery<K extends Key<T>>(collection: K, constraints: ItemConstraints<T[K]>,
|
|
37
|
+
updateQuery<K extends Key<T>>(collection: K, constraints: ItemConstraints<T[K]>, updates: Updates<T[K]>): Promise<number>;
|
|
38
38
|
deleteQuery<K extends Key<T>>(collection: K, constraints: ItemConstraints<T[K]>): Promise<number>;
|
|
39
39
|
}
|
|
@@ -54,8 +54,8 @@ export class AsyncThroughProvider {
|
|
|
54
54
|
setItem(collection, id, data) {
|
|
55
55
|
return this.source.setItem(collection, id, data);
|
|
56
56
|
}
|
|
57
|
-
updateItem(collection, id,
|
|
58
|
-
return this.source.updateItem(collection, id,
|
|
57
|
+
updateItem(collection, id, updates) {
|
|
58
|
+
return this.source.updateItem(collection, id, updates);
|
|
59
59
|
}
|
|
60
60
|
deleteItem(collection, id) {
|
|
61
61
|
return this.source.deleteItem(collection, id);
|
|
@@ -69,8 +69,8 @@ export class AsyncThroughProvider {
|
|
|
69
69
|
setQuery(collection, constraints, data) {
|
|
70
70
|
return this.source.setQuery(collection, constraints, data);
|
|
71
71
|
}
|
|
72
|
-
updateQuery(collection, constraints,
|
|
73
|
-
return this.source.updateQuery(collection, constraints,
|
|
72
|
+
updateQuery(collection, constraints, updates) {
|
|
73
|
+
return this.source.updateQuery(collection, constraints, updates);
|
|
74
74
|
}
|
|
75
75
|
deleteQuery(collection, constraints) {
|
|
76
76
|
return this.source.deleteQuery(collection, constraints);
|
|
@@ -1,46 +1,46 @@
|
|
|
1
1
|
import type { Key, Datas } from "../util/data.js";
|
|
2
2
|
import type { ItemArray, ItemValue, ItemConstraints } from "../db/Item.js";
|
|
3
|
-
import type {
|
|
3
|
+
import type { DataSchemas, DataSchema } from "../schema/DataSchema.js";
|
|
4
4
|
import type { PartialObserver } from "../observe/Observer.js";
|
|
5
5
|
import type { Unsubscribe } from "../observe/Observable.js";
|
|
6
|
-
import {
|
|
6
|
+
import { Updates } from "../update/DataUpdate.js";
|
|
7
7
|
import { Sourceable } from "../util/source.js";
|
|
8
8
|
import { Provider, AsyncProvider } from "./Provider.js";
|
|
9
9
|
/** Validate a source provider (source can have any type because validation guarantees the type). */
|
|
10
10
|
declare abstract class BaseValidationProvider<T extends Datas> {
|
|
11
11
|
abstract source: Provider | AsyncProvider;
|
|
12
|
-
readonly
|
|
13
|
-
constructor(
|
|
14
|
-
|
|
12
|
+
readonly schemas: DataSchemas<T>;
|
|
13
|
+
constructor(schemas: DataSchemas<T>);
|
|
14
|
+
getSchema<K extends Key<T>>(collection: K): DataSchema<T[K]>;
|
|
15
15
|
subscribeItem<K extends Key<T>>(collection: K, id: string, observer: PartialObserver<ItemValue<T[K]>>): Unsubscribe;
|
|
16
16
|
subscribeQuery<K extends Key<T>>(collection: K, constraints: ItemConstraints<T[K]>, observer: PartialObserver<ItemArray<T[K]>>): Unsubscribe;
|
|
17
17
|
}
|
|
18
18
|
/** Validate a synchronous source provider (source can have any type because validation guarantees the type). */
|
|
19
19
|
export declare class ValidationProvider<T extends Datas> extends BaseValidationProvider<T> implements Provider<T>, Sourceable<Provider> {
|
|
20
20
|
readonly source: Provider;
|
|
21
|
-
constructor(source: Provider,
|
|
21
|
+
constructor(source: Provider, schemas: DataSchemas<T>);
|
|
22
22
|
getItem<K extends Key<T>>(collection: K, id: string): ItemValue<T[K]>;
|
|
23
23
|
addItem<K extends Key<T>>(collection: K, data: T[K]): string;
|
|
24
24
|
setItem<K extends Key<T>>(collection: K, id: string, value: T[K]): void;
|
|
25
|
-
updateItem<K extends Key<T>>(collection: K, id: string,
|
|
25
|
+
updateItem<K extends Key<T>>(collection: K, id: string, updates: Updates<T[K]>): void;
|
|
26
26
|
deleteItem<K extends Key<T>>(collection: K, id: string): void;
|
|
27
27
|
getQuery<K extends Key<T>>(collection: K, constraints: ItemConstraints<T[K]>): ItemArray<T[K]>;
|
|
28
28
|
setQuery<K extends Key<T>>(collection: K, constraints: ItemConstraints<T[K]>, value: T[K]): number;
|
|
29
|
-
updateQuery<K extends Key<T>>(collection: K, constraints: ItemConstraints<T[K]>,
|
|
29
|
+
updateQuery<K extends Key<T>>(collection: K, constraints: ItemConstraints<T[K]>, updates: Updates<T[K]>): number;
|
|
30
30
|
deleteQuery<K extends Key<T>>(collection: K, constraints: ItemConstraints<T[K]>): number;
|
|
31
31
|
}
|
|
32
32
|
/** Validate an asynchronous source provider (source can have any type because validation guarantees the type). */
|
|
33
33
|
export declare class AsyncValidationProvider<T extends Datas> extends BaseValidationProvider<T> implements AsyncProvider<T>, Sourceable<AsyncProvider> {
|
|
34
34
|
readonly source: AsyncProvider;
|
|
35
|
-
constructor(source: AsyncProvider,
|
|
35
|
+
constructor(source: AsyncProvider, schemas: DataSchemas<T>);
|
|
36
36
|
getItem<K extends Key<T>>(collection: K, id: string): Promise<ItemValue<T[K]>>;
|
|
37
37
|
addItem<K extends Key<T>>(collection: K, data: T[K]): Promise<string>;
|
|
38
38
|
setItem<K extends Key<T>>(collection: K, id: string, value: T[K]): Promise<void>;
|
|
39
|
-
updateItem<K extends Key<T>>(collection: K, id: string,
|
|
39
|
+
updateItem<K extends Key<T>>(collection: K, id: string, updates: Updates<T[K]>): Promise<void>;
|
|
40
40
|
deleteItem<K extends Key<T>>(collection: K, id: string): Promise<void>;
|
|
41
41
|
getQuery<K extends Key<T>>(collection: K, constraints: ItemConstraints<T[K]>): Promise<ItemArray<T[K]>>;
|
|
42
42
|
setQuery<K extends Key<T>>(collection: K, constraints: ItemConstraints<T[K]>, value: T[K]): Promise<number>;
|
|
43
|
-
updateQuery<K extends Key<T>>(collection: K, constraints: ItemConstraints<T[K]>,
|
|
43
|
+
updateQuery<K extends Key<T>>(collection: K, constraints: ItemConstraints<T[K]>, updates: Updates<T[K]>): Promise<number>;
|
|
44
44
|
deleteQuery<K extends Key<T>>(collection: K, constraints: ItemConstraints<T[K]>): Promise<number>;
|
|
45
45
|
}
|
|
46
46
|
export {};
|
|
@@ -1,3 +1,4 @@
|
|
|
1
|
+
import { validateUpdates } from "../update/DataUpdate.js";
|
|
1
2
|
import { validate } from "../util/validate.js";
|
|
2
3
|
import { Feedback } from "../feedback/Feedback.js";
|
|
3
4
|
import { ValidationError } from "../error/ValidationError.js";
|
|
@@ -5,48 +6,48 @@ import { InvalidFeedback } from "../feedback/InvalidFeedback.js";
|
|
|
5
6
|
import { TransformableObserver } from "../observe/TransformableObserver.js";
|
|
6
7
|
/** Validate a source provider (source can have any type because validation guarantees the type). */
|
|
7
8
|
class BaseValidationProvider {
|
|
8
|
-
constructor(
|
|
9
|
-
this.
|
|
9
|
+
constructor(schemas) {
|
|
10
|
+
this.schemas = schemas;
|
|
10
11
|
}
|
|
11
|
-
|
|
12
|
-
return this.
|
|
12
|
+
getSchema(collection) {
|
|
13
|
+
return this.schemas[collection];
|
|
13
14
|
}
|
|
14
15
|
subscribeItem(collection, id, observer) {
|
|
15
|
-
return this.source.subscribeItem(collection, id, new _ValidateEntityObserver(collection, this.
|
|
16
|
+
return this.source.subscribeItem(collection, id, new _ValidateEntityObserver(collection, this.getSchema(collection), observer));
|
|
16
17
|
}
|
|
17
18
|
subscribeQuery(collection, constraints, observer) {
|
|
18
|
-
return this.source.subscribeQuery(collection, constraints, new _ValidateEntitiesObserver(collection, this.
|
|
19
|
+
return this.source.subscribeQuery(collection, constraints, new _ValidateEntitiesObserver(collection, this.getSchema(collection), observer));
|
|
19
20
|
}
|
|
20
21
|
}
|
|
21
22
|
/** Validate a synchronous source provider (source can have any type because validation guarantees the type). */
|
|
22
23
|
export class ValidationProvider extends BaseValidationProvider {
|
|
23
|
-
constructor(source,
|
|
24
|
-
super(
|
|
24
|
+
constructor(source, schemas) {
|
|
25
|
+
super(schemas);
|
|
25
26
|
this.source = source;
|
|
26
27
|
}
|
|
27
28
|
getItem(collection, id) {
|
|
28
|
-
return _validateEntity(collection, this.source.getItem(collection, id), this.
|
|
29
|
+
return _validateEntity(collection, this.source.getItem(collection, id), this.getSchema(collection));
|
|
29
30
|
}
|
|
30
31
|
addItem(collection, data) {
|
|
31
|
-
return this.source.addItem(collection, validate(data, this.
|
|
32
|
+
return this.source.addItem(collection, validate(data, this.getSchema(collection)));
|
|
32
33
|
}
|
|
33
34
|
setItem(collection, id, value) {
|
|
34
|
-
return this.source.setItem(collection, id, validate(value, this.
|
|
35
|
+
return this.source.setItem(collection, id, validate(value, this.getSchema(collection)));
|
|
35
36
|
}
|
|
36
|
-
updateItem(collection, id,
|
|
37
|
-
return this.source.updateItem(collection, id,
|
|
37
|
+
updateItem(collection, id, updates) {
|
|
38
|
+
return this.source.updateItem(collection, id, validateUpdates(updates, this.getSchema(collection).props));
|
|
38
39
|
}
|
|
39
40
|
deleteItem(collection, id) {
|
|
40
41
|
return this.source.deleteItem(collection, id);
|
|
41
42
|
}
|
|
42
43
|
getQuery(collection, constraints) {
|
|
43
|
-
return _validateEntities(collection, this.source.getQuery(collection, constraints), this.
|
|
44
|
+
return _validateEntities(collection, this.source.getQuery(collection, constraints), this.getSchema(collection));
|
|
44
45
|
}
|
|
45
46
|
setQuery(collection, constraints, value) {
|
|
46
|
-
return this.source.setQuery(collection, constraints, validate(value, this.
|
|
47
|
+
return this.source.setQuery(collection, constraints, validate(value, this.getSchema(collection)));
|
|
47
48
|
}
|
|
48
|
-
updateQuery(collection, constraints,
|
|
49
|
-
return this.source.updateQuery(collection, constraints,
|
|
49
|
+
updateQuery(collection, constraints, updates) {
|
|
50
|
+
return this.source.updateQuery(collection, constraints, validateUpdates(updates, this.getSchema(collection).props));
|
|
50
51
|
}
|
|
51
52
|
deleteQuery(collection, constraints) {
|
|
52
53
|
return this.source.deleteQuery(collection, constraints);
|
|
@@ -54,33 +55,33 @@ export class ValidationProvider extends BaseValidationProvider {
|
|
|
54
55
|
}
|
|
55
56
|
/** Validate an asynchronous source provider (source can have any type because validation guarantees the type). */
|
|
56
57
|
export class AsyncValidationProvider extends BaseValidationProvider {
|
|
57
|
-
constructor(source,
|
|
58
|
-
super(
|
|
58
|
+
constructor(source, schemas) {
|
|
59
|
+
super(schemas);
|
|
59
60
|
this.source = source;
|
|
60
61
|
}
|
|
61
62
|
async getItem(collection, id) {
|
|
62
|
-
return _validateEntity(collection, await this.source.getItem(collection, id), this.
|
|
63
|
+
return _validateEntity(collection, await this.source.getItem(collection, id), this.getSchema(collection));
|
|
63
64
|
}
|
|
64
65
|
addItem(collection, data) {
|
|
65
|
-
return this.source.addItem(collection, validate(data, this.
|
|
66
|
+
return this.source.addItem(collection, validate(data, this.getSchema(collection)));
|
|
66
67
|
}
|
|
67
68
|
setItem(collection, id, value) {
|
|
68
|
-
return this.source.setItem(collection, id, validate(value, this.
|
|
69
|
+
return this.source.setItem(collection, id, validate(value, this.getSchema(collection)));
|
|
69
70
|
}
|
|
70
|
-
updateItem(collection, id,
|
|
71
|
-
return this.source.updateItem(collection, id,
|
|
71
|
+
updateItem(collection, id, updates) {
|
|
72
|
+
return this.source.updateItem(collection, id, validateUpdates(updates, this.getSchema(collection).props));
|
|
72
73
|
}
|
|
73
74
|
deleteItem(collection, id) {
|
|
74
75
|
return this.source.deleteItem(collection, id);
|
|
75
76
|
}
|
|
76
77
|
async getQuery(collection, constraints) {
|
|
77
|
-
return _validateEntities(collection, await this.source.getQuery(collection, constraints), this.
|
|
78
|
+
return _validateEntities(collection, await this.source.getQuery(collection, constraints), this.getSchema(collection));
|
|
78
79
|
}
|
|
79
80
|
setQuery(collection, constraints, value) {
|
|
80
|
-
return this.source.setQuery(collection, constraints, validate(value, this.
|
|
81
|
+
return this.source.setQuery(collection, constraints, validate(value, this.getSchema(collection)));
|
|
81
82
|
}
|
|
82
|
-
updateQuery(collection, constraints,
|
|
83
|
-
return this.source.updateQuery(collection, constraints,
|
|
83
|
+
updateQuery(collection, constraints, updates) {
|
|
84
|
+
return this.source.updateQuery(collection, constraints, validateUpdates(updates, this.getSchema(collection).props));
|
|
84
85
|
}
|
|
85
86
|
deleteQuery(collection, constraints) {
|
|
86
87
|
return this.source.deleteQuery(collection, constraints);
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|