shelving 1.17.0 → 1.18.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/Resource.d.ts +16 -20
- package/api/Resource.js +19 -24
- package/api/errors.d.ts +8 -0
- package/api/errors.js +9 -0
- package/db/Change.d.ts +24 -38
- package/db/Change.js +38 -48
- package/db/Database.d.ts +167 -19
- package/db/Database.js +257 -15
- package/db/Pagination.d.ts +26 -0
- package/db/Pagination.js +63 -0
- package/db/errors.d.ts +17 -11
- package/db/errors.js +17 -7
- package/db/index.d.ts +1 -10
- package/db/index.js +1 -13
- package/error/AssertionError.d.ts +9 -0
- package/error/AssertionError.js +13 -0
- package/error/PermissionError.d.ts +4 -0
- package/error/PermissionError.js +7 -0
- package/error/RequiredError.d.ts +4 -0
- package/error/RequiredError.js +7 -0
- package/error/UnsupportedError.d.ts +4 -0
- package/error/UnsupportedError.js +7 -0
- package/error/ValidationError.d.ts +6 -0
- package/error/ValidationError.js +8 -0
- package/error/index.d.ts +5 -0
- package/error/index.js +5 -0
- package/feedback/ErrorFeedback.d.ts +4 -0
- package/feedback/ErrorFeedback.js +4 -0
- package/{util/feedback.d.ts → feedback/Feedback.d.ts} +1 -30
- package/{util/feedback.js → feedback/Feedback.js} +2 -30
- package/feedback/InvalidFeedback.d.ts +4 -0
- package/feedback/InvalidFeedback.js +4 -0
- package/feedback/SuccessFeedback.d.ts +4 -0
- package/feedback/SuccessFeedback.js +4 -0
- package/feedback/WarningFeedback.d.ts +4 -0
- package/feedback/WarningFeedback.js +4 -0
- package/feedback/hydrations.d.ts +13 -0
- package/feedback/hydrations.js +14 -0
- package/feedback/index.d.ts +7 -0
- package/feedback/index.js +7 -0
- package/feedback/util.d.ts +3 -0
- package/feedback/util.js +7 -0
- package/firestore/client/FirestoreClientProvider.d.ts +19 -0
- package/firestore/client/FirestoreClientProvider.js +121 -0
- package/{firestore-client → firestore/client}/index.d.ts +0 -0
- package/{firestore-client → firestore/client}/index.js +0 -0
- package/firestore/lite/FirestoreLiteProvider.d.ts +19 -0
- package/firestore/lite/FirestoreLiteProvider.js +121 -0
- package/{firestore-lite → firestore/lite}/index.d.ts +0 -0
- package/{firestore-lite → firestore/lite}/index.js +0 -0
- package/firestore/server/FirestoreServerProvider.d.ts +17 -0
- package/firestore/server/FirestoreServerProvider.js +129 -0
- package/{firestore-server → firestore/server}/index.d.ts +0 -0
- package/{firestore-server → firestore/server}/index.js +0 -0
- package/index.d.ts +4 -0
- package/index.js +4 -3
- package/markup/helpers.d.ts +1 -1
- package/markup/helpers.js +3 -3
- package/markup/render.js +2 -2
- package/markup/rules.d.ts +2 -59
- package/markup/rules.js +17 -27
- package/markup/types.d.ts +3 -3
- package/package.json +23 -18
- package/{db → provider}/BatchProvider.d.ts +7 -9
- package/{db → provider}/BatchProvider.js +18 -18
- package/provider/CacheProvider.d.ts +31 -0
- package/{db → provider}/CacheProvider.js +31 -48
- package/provider/MemoryProvider.d.ts +23 -0
- package/provider/MemoryProvider.js +135 -0
- package/provider/Provider.d.ts +93 -0
- package/provider/Provider.js +3 -0
- package/provider/ThroughProvider.d.ts +20 -0
- package/provider/ThroughProvider.js +40 -0
- package/provider/ValidationProvider.d.ts +14 -0
- package/provider/ValidationProvider.js +46 -0
- package/provider/index.d.ts +6 -0
- package/provider/index.js +6 -0
- package/query/Filter.d.ts +35 -11
- package/query/Filter.js +38 -40
- package/query/Filters.d.ts +12 -19
- package/query/Filters.js +17 -47
- package/query/Query.d.ts +20 -57
- package/query/Query.js +55 -101
- package/query/Rule.d.ts +3 -12
- package/query/Rule.js +0 -10
- package/query/Rules.d.ts +11 -17
- package/query/Rules.js +14 -34
- package/query/Sort.d.ts +18 -16
- package/query/Sort.js +15 -38
- package/query/Sorts.d.ts +6 -9
- package/query/Sorts.js +9 -33
- package/query/helpers.d.ts +3 -2
- package/query/index.d.ts +0 -1
- package/query/index.js +0 -1
- package/query/types.d.ts +46 -19
- package/react/index.d.ts +4 -3
- package/react/index.js +4 -3
- package/react/useData.d.ts +36 -0
- package/react/useData.js +9 -0
- package/react/useFetch.d.ts +2 -2
- package/react/useFetch.js +21 -12
- package/react/usePagination.d.ts +2 -2
- package/react/usePagination.js +11 -7
- package/react/{useDocuments.d.ts → useQuery.d.ts} +10 -10
- package/react/{useDocuments.js → useQuery.js} +15 -15
- package/react/useResult.d.ts +34 -0
- package/react/{useDocument.js → useResult.js} +14 -21
- package/react/useState.d.ts +3 -8
- package/react/useState.js +12 -30
- package/react/useSubscribe.d.ts +10 -0
- package/react/useSubscribe.js +17 -0
- package/schema/AllowedSchema.d.ts +17 -0
- package/schema/AllowedSchema.js +28 -0
- package/schema/ArraySchema.d.ts +12 -19
- package/schema/ArraySchema.js +17 -62
- package/schema/BooleanSchema.d.ts +9 -16
- package/schema/BooleanSchema.js +6 -18
- package/schema/ColorSchema.d.ts +7 -16
- package/schema/ColorSchema.js +9 -13
- package/schema/DataSchema.d.ts +17 -0
- package/schema/DataSchema.js +21 -0
- package/schema/DateSchema.d.ts +17 -23
- package/schema/DateSchema.js +18 -33
- package/schema/EmailSchema.d.ts +8 -11
- package/schema/EmailSchema.js +10 -9
- package/schema/KeySchema.d.ts +7 -12
- package/schema/KeySchema.js +7 -6
- package/schema/MapSchema.d.ts +15 -27
- package/schema/MapSchema.js +16 -61
- package/schema/NullableSchema.d.ts +13 -0
- package/schema/NullableSchema.js +16 -0
- package/schema/NumberSchema.d.ts +15 -34
- package/schema/NumberSchema.js +18 -53
- package/schema/ObjectSchema.d.ts +18 -26
- package/schema/ObjectSchema.js +21 -63
- package/schema/PhoneSchema.d.ts +5 -13
- package/schema/PhoneSchema.js +5 -9
- package/schema/RequiredSchema.d.ts +8 -0
- package/schema/RequiredSchema.js +13 -0
- package/schema/Schema.d.ts +11 -39
- package/schema/Schema.js +1 -19
- package/schema/StringSchema.d.ts +19 -34
- package/schema/StringSchema.js +21 -55
- package/schema/ThroughSchema.d.ts +11 -0
- package/schema/ThroughSchema.js +19 -0
- package/schema/UrlSchema.d.ts +10 -13
- package/schema/UrlSchema.js +16 -36
- package/schema/index.d.ts +5 -0
- package/schema/index.js +5 -0
- package/stream/AbstractState.d.ts +35 -0
- package/stream/AbstractState.js +84 -0
- package/stream/AbstractStream.d.ts +66 -0
- package/stream/AbstractStream.js +123 -0
- package/stream/ArrayState.d.ts +3 -3
- package/stream/ArrayState.js +3 -7
- package/stream/DataState.d.ts +9 -0
- package/stream/DataState.js +13 -0
- package/stream/DeriveStream.d.ts +9 -17
- package/stream/DeriveStream.js +21 -35
- package/stream/LastStream.d.ts +5 -0
- package/stream/LastStream.js +11 -0
- package/stream/LazyState.d.ts +2 -2
- package/stream/LazyState.js +4 -4
- package/stream/LazyStream.js +6 -7
- package/stream/LimitStream.d.ts +6 -0
- package/stream/LimitStream.js +15 -4
- package/stream/State.d.ts +19 -68
- package/stream/State.js +22 -112
- package/stream/Stream.d.ts +11 -78
- package/stream/Stream.js +11 -135
- package/stream/ValidateStream.d.ts +8 -0
- package/stream/ValidateStream.js +18 -0
- package/stream/errors.d.ts +2 -14
- package/stream/errors.js +3 -17
- package/stream/index.d.ts +6 -4
- package/stream/index.js +6 -4
- package/test/basics.d.ts +23 -0
- package/test/basics.js +27 -0
- package/test/index.d.ts +18 -1
- package/test/index.js +9 -1
- package/test/people.d.ts +22 -0
- package/test/people.js +17 -0
- package/test/util.d.ts +7 -0
- package/test/util.js +49 -0
- package/transform/AddEntriesTransform.d.ts +10 -0
- package/transform/AddEntriesTransform.js +16 -0
- package/transform/AddItemsTransform.d.ts +10 -0
- package/transform/AddItemsTransform.js +16 -0
- package/transform/DataTransform.d.ts +24 -0
- package/transform/DataTransform.js +24 -0
- package/transform/IncrementTransform.d.ts +12 -0
- package/transform/IncrementTransform.js +16 -0
- package/transform/RemoveEntriesTransform.d.ts +10 -0
- package/transform/RemoveEntriesTransform.js +16 -0
- package/transform/RemoveItemsTransform.d.ts +10 -0
- package/transform/RemoveItemsTransform.js +16 -0
- package/transform/Transform.d.ts +9 -0
- package/transform/Transform.js +6 -0
- package/transform/hydrations.d.ts +15 -0
- package/transform/hydrations.js +16 -0
- package/transform/index.d.ts +9 -0
- package/transform/index.js +9 -0
- package/transform/util.d.ts +7 -0
- package/transform/util.js +42 -0
- package/util/array.d.ts +20 -94
- package/util/array.js +45 -117
- package/util/assert.d.ts +19 -5
- package/util/assert.js +38 -7
- package/util/class.d.ts +15 -20
- package/util/class.js +20 -20
- package/util/clone.d.ts +6 -4
- package/util/clone.js +20 -11
- package/util/constants.d.ts +3 -3
- package/util/constants.js +3 -3
- package/util/data.d.ts +23 -19
- package/util/data.js +16 -10
- package/util/date.d.ts +22 -27
- package/util/date.js +56 -57
- package/util/derive.d.ts +91 -0
- package/util/derive.js +56 -0
- package/util/diff.d.ts +12 -11
- package/util/diff.js +11 -11
- package/util/dispatch.d.ts +18 -110
- package/util/dispatch.js +38 -102
- package/util/entry.d.ts +24 -51
- package/util/entry.js +10 -10
- package/util/equal.d.ts +9 -3
- package/util/equal.js +20 -6
- package/util/error.d.ts +8 -27
- package/util/error.js +3 -42
- package/util/filter.d.ts +59 -28
- package/util/filter.js +61 -21
- package/util/function.d.ts +4 -34
- package/util/function.js +0 -4
- package/util/{hydration.d.ts → hydrate.d.ts} +17 -5
- package/util/hydrate.js +67 -0
- package/util/index.d.ts +5 -4
- package/util/index.js +5 -4
- package/util/iterable.d.ts +77 -0
- package/util/iterable.js +141 -0
- package/util/lazy.d.ts +21 -0
- package/util/lazy.js +5 -0
- package/util/map.d.ts +21 -0
- package/util/map.js +10 -0
- package/util/merge.d.ts +4 -4
- package/util/null.d.ts +4 -2
- package/util/null.js +4 -2
- package/util/number.d.ts +1 -1
- package/util/number.js +2 -2
- package/util/object.d.ts +92 -224
- package/util/object.js +58 -184
- package/util/observable.d.ts +24 -17
- package/util/observable.js +53 -6
- package/util/promise.d.ts +3 -4
- package/util/search.d.ts +58 -8
- package/util/search.js +73 -57
- package/util/serialise.js +1 -1
- package/util/sort.d.ts +55 -22
- package/util/sort.js +135 -27
- package/util/string.d.ts +17 -19
- package/util/string.js +40 -31
- package/util/template.d.ts +1 -1
- package/util/template.js +1 -1
- package/util/undefined.d.ts +7 -2
- package/util/undefined.js +7 -2
- package/util/url.d.ts +8 -2
- package/util/url.js +22 -4
- package/util/validate.d.ts +55 -12
- package/util/validate.js +95 -1
- package/db/CacheProvider.d.ts +0 -37
- package/db/Document.d.ts +0 -100
- package/db/Document.js +0 -121
- package/db/Documents.d.ts +0 -148
- package/db/Documents.js +0 -215
- package/db/MemoryProvider.d.ts +0 -30
- package/db/MemoryProvider.js +0 -164
- package/db/MemoryProvider.test.d.ts +0 -1
- package/db/MemoryProvider.test.js +0 -306
- package/db/PaginationState.d.ts +0 -33
- package/db/PaginationState.js +0 -94
- package/db/Provider.d.ts +0 -134
- package/db/Provider.js +0 -1
- package/db/Reference.d.ts +0 -17
- package/db/Reference.js +0 -34
- package/db/ThroughProvider.d.ts +0 -24
- package/db/ThroughProvider.js +0 -52
- package/db/ValidationProvider.d.ts +0 -21
- package/db/ValidationProvider.js +0 -129
- package/firestore-client/FirestoreClientProvider.d.ts +0 -23
- package/firestore-client/FirestoreClientProvider.js +0 -129
- package/firestore-lite/FirestoreLiteProvider.d.ts +0 -23
- package/firestore-lite/FirestoreLiteProvider.js +0 -129
- package/firestore-server/FirestoreServerProvider.d.ts +0 -21
- package/firestore-server/FirestoreServerProvider.js +0 -156
- package/markup/helpers.test.d.ts +0 -1
- package/markup/helpers.test.js +0 -42
- package/markup/render.test.d.ts +0 -1
- package/markup/render.test.js +0 -544
- package/markup/types.test.d.ts +0 -1
- package/markup/types.test.js +0 -8
- package/query/Filter.test.d.ts +0 -1
- package/query/Filter.test.js +0 -69
- package/query/Filters.test.d.ts +0 -1
- package/query/Filters.test.js +0 -6
- package/query/Query.test.d.ts +0 -1
- package/query/Query.test.js +0 -100
- package/query/Slice.d.ts +0 -8
- package/query/Slice.js +0 -18
- package/query/Slice.test.d.ts +0 -1
- package/query/Slice.test.js +0 -15
- package/query/Sort.test.d.ts +0 -1
- package/query/Sort.test.js +0 -39
- package/query/Sorts.test.d.ts +0 -1
- package/query/Sorts.test.js +0 -28
- package/react/useDocument.d.ts +0 -69
- package/react/useObserve.d.ts +0 -8
- package/react/useObserve.js +0 -15
- package/schema/ArraySchema.test.d.ts +0 -1
- package/schema/ArraySchema.test.js +0 -168
- package/schema/BooleanSchema.test.d.ts +0 -1
- package/schema/BooleanSchema.test.js +0 -99
- package/schema/ColorSchema.test.d.ts +0 -1
- package/schema/ColorSchema.test.js +0 -105
- package/schema/DateSchema.test.d.ts +0 -1
- package/schema/DateSchema.test.js +0 -138
- package/schema/EmailSchema.test.d.ts +0 -1
- package/schema/EmailSchema.test.js +0 -153
- package/schema/KeySchema.test.d.ts +0 -1
- package/schema/KeySchema.test.js +0 -96
- package/schema/MapSchema.test.d.ts +0 -1
- package/schema/MapSchema.test.js +0 -141
- package/schema/NumberSchema.test.d.ts +0 -1
- package/schema/NumberSchema.test.js +0 -229
- package/schema/ObjectSchema.test.d.ts +0 -1
- package/schema/ObjectSchema.test.js +0 -196
- package/schema/PhoneSchema.test.d.ts +0 -1
- package/schema/PhoneSchema.test.js +0 -105
- package/schema/StringSchema.test.d.ts +0 -1
- package/schema/StringSchema.test.js +0 -189
- package/schema/UrlSchema.test.d.ts +0 -1
- package/schema/UrlSchema.test.js +0 -270
- package/stream/ArrayState.test.d.ts +0 -1
- package/stream/ArrayState.test.js +0 -31
- package/stream/MapState.d.ts +0 -13
- package/stream/MapState.js +0 -25
- package/stream/SliceStream.d.ts +0 -8
- package/stream/SliceStream.js +0 -15
- package/stream/State.test.d.ts +0 -1
- package/stream/State.test.js +0 -162
- package/stream/Stream.test.d.ts +0 -1
- package/stream/Stream.test.js +0 -124
- package/stream/util.d.ts +0 -6
- package/stream/util.js +0 -10
- package/test/db.d.ts +0 -127
- package/test/db.js +0 -39
- package/tsconfig.build.tsbuildinfo +0 -1
- package/util/array.test.d.ts +0 -1
- package/util/array.test.js +0 -139
- package/util/class.test.d.ts +0 -1
- package/util/class.test.js +0 -15
- package/util/compare.d.ts +0 -11
- package/util/compare.js +0 -76
- package/util/compare.test.d.ts +0 -1
- package/util/compare.test.js +0 -59
- package/util/console.d.ts +0 -5
- package/util/console.js +0 -4
- package/util/date.test.d.ts +0 -1
- package/util/date.test.js +0 -80
- package/util/diff.test.d.ts +0 -1
- package/util/diff.test.js +0 -160
- package/util/equal.test.d.ts +0 -1
- package/util/equal.test.js +0 -208
- package/util/feedback.test.d.ts +0 -1
- package/util/feedback.test.js +0 -33
- package/util/filter.test.d.ts +0 -1
- package/util/filter.test.js +0 -45
- package/util/hydration.js +0 -49
- package/util/hydration.test.d.ts +0 -1
- package/util/hydration.test.js +0 -94
- package/util/merge.test.d.ts +0 -1
- package/util/merge.test.js +0 -183
- package/util/number.test.d.ts +0 -1
- package/util/number.test.js +0 -86
- package/util/object.test.d.ts +0 -1
- package/util/object.test.js +0 -154
- package/util/promise.test.d.ts +0 -1
- package/util/promise.test.js +0 -11
- package/util/random.test.d.ts +0 -1
- package/util/random.test.js +0 -20
- package/util/search.test.d.ts +0 -1
- package/util/search.test.js +0 -87
- package/util/serialise.test.d.ts +0 -1
- package/util/serialise.test.js +0 -32
- package/util/sort.test.d.ts +0 -1
- package/util/sort.test.js +0 -101
- package/util/string.test.d.ts +0 -1
- package/util/string.test.js +0 -88
- package/util/template.test.d.ts +0 -1
- package/util/template.test.js +0 -125
- package/util/transform.d.ts +0 -87
- package/util/transform.js +0 -109
- package/util/units.test.d.ts +0 -1
- package/util/units.test.js +0 -67
package/api/Resource.d.ts
CHANGED
|
@@ -1,38 +1,34 @@
|
|
|
1
|
-
import
|
|
1
|
+
import { Validator, Validatable } from "../util/index.js";
|
|
2
2
|
/**
|
|
3
3
|
* An abstract API resource definition, used to specify types for e.g. serverless functions..
|
|
4
4
|
*
|
|
5
5
|
* @param payload The `Validator` the payload must conform to (defaults to `undefined` if not specified).
|
|
6
6
|
* @param returns The `Validator` the function's returned value must conform to (defaults to `undefined` if not specified).
|
|
7
7
|
*/
|
|
8
|
-
export declare class Resource<P, R> {
|
|
8
|
+
export declare class Resource<P = unknown, R = void> implements Validatable<R> {
|
|
9
9
|
static create<X, Y>(payload: Validator<X>, result: Validator<Y>): Resource<X, Y>;
|
|
10
10
|
static create<Y>(payload: undefined, result: Y): Resource<undefined, Y>;
|
|
11
|
-
static create<X>(payload: Validator<X>, result?: undefined): Resource<X,
|
|
12
|
-
static create(payload?: undefined, result?: undefined): Resource<undefined,
|
|
13
|
-
/** Expose the `P` internal payload type of this resource. */
|
|
14
|
-
readonly PAYLOAD: P;
|
|
15
|
-
/** Expose the `R` internal result type of this resource. */
|
|
16
|
-
readonly RESULT: R;
|
|
11
|
+
static create<X>(payload: Validator<X>, result?: undefined): Resource<X, void>;
|
|
12
|
+
static create(payload?: undefined, result?: undefined): Resource<undefined, void>;
|
|
17
13
|
/** Payload validator. */
|
|
18
14
|
readonly payload: Validator<P>;
|
|
19
15
|
/** Result validator. */
|
|
20
16
|
readonly result: Validator<R>;
|
|
21
17
|
protected constructor(payload: Validator<P>, result: Validator<R>);
|
|
22
18
|
/**
|
|
23
|
-
*
|
|
24
|
-
* - Validates the payload (before dispatching).
|
|
25
|
-
* - Validates the result (after dispatching).
|
|
19
|
+
* Validate a payload for this resource.
|
|
26
20
|
*
|
|
27
|
-
|
|
28
|
-
|
|
29
|
-
|
|
30
|
-
*
|
|
31
|
-
* @returns The result returned from the resource (validated against the result validator).
|
|
21
|
+
*/
|
|
22
|
+
validatePayload(unsafePayload: unknown): P;
|
|
23
|
+
/**
|
|
24
|
+
* Validate a result for this resource.
|
|
32
25
|
*
|
|
33
|
-
* @
|
|
34
|
-
* @throws
|
|
35
|
-
* @throws ValidationError If the result could not be validated.
|
|
26
|
+
* @returns The validated payload for this resource.
|
|
27
|
+
* @throws ValidationError if the result could not be validated.
|
|
36
28
|
*/
|
|
37
|
-
|
|
29
|
+
validate(unsafeResult: unknown): R;
|
|
38
30
|
}
|
|
31
|
+
/** Extract the payload type from a `Resource`. */
|
|
32
|
+
export declare type PayloadType<X extends Resource> = X extends Resource<infer Y, unknown> ? Y : never;
|
|
33
|
+
/** Extract the result type from a `Resource`. */
|
|
34
|
+
export declare type ResourceType<X extends Resource> = X extends Resource<unknown, infer Y> ? Y : never;
|
package/api/Resource.js
CHANGED
|
@@ -1,5 +1,8 @@
|
|
|
1
|
-
import {
|
|
2
|
-
|
|
1
|
+
import { UNDEFINED, validate } from "../util/index.js";
|
|
2
|
+
import { Feedback, throwFeedback } from "../feedback/index.js";
|
|
3
|
+
import { ResourceValidationError } from "./errors.js";
|
|
4
|
+
/** Validator that always returns void/undefined. */
|
|
5
|
+
const UNDEFINED_VALIDATOR = UNDEFINED;
|
|
3
6
|
/**
|
|
4
7
|
* An abstract API resource definition, used to specify types for e.g. serverless functions..
|
|
5
8
|
*
|
|
@@ -7,41 +10,33 @@ const UNDEFINED_SCHEMA = { validate: () => undefined };
|
|
|
7
10
|
* @param returns The `Validator` the function's returned value must conform to (defaults to `undefined` if not specified).
|
|
8
11
|
*/
|
|
9
12
|
export class Resource {
|
|
13
|
+
// Protected to require use of `Resource.create()`
|
|
10
14
|
constructor(payload, result) {
|
|
11
|
-
/** Expose the `P` internal payload type of this resource. */
|
|
12
|
-
this.PAYLOAD = undefined; // eslint-disable-line @typescript-eslint/no-explicit-any
|
|
13
|
-
/** Expose the `R` internal result type of this resource. */
|
|
14
|
-
this.RESULT = undefined; // eslint-disable-line @typescript-eslint/no-explicit-any
|
|
15
15
|
this.payload = payload;
|
|
16
16
|
this.result = result;
|
|
17
17
|
}
|
|
18
|
-
static create(payload =
|
|
18
|
+
static create(payload = UNDEFINED_VALIDATOR, result = UNDEFINED_VALIDATOR) {
|
|
19
19
|
return new Resource(payload, result);
|
|
20
20
|
}
|
|
21
21
|
/**
|
|
22
|
-
*
|
|
23
|
-
* - Validates the payload (before dispatching).
|
|
24
|
-
* - Validates the result (after dispatching).
|
|
22
|
+
* Validate a payload for this resource.
|
|
25
23
|
*
|
|
26
|
-
|
|
27
|
-
|
|
28
|
-
|
|
29
|
-
|
|
30
|
-
|
|
24
|
+
*/
|
|
25
|
+
validatePayload(unsafePayload) {
|
|
26
|
+
return throwFeedback(validate(unsafePayload, this.payload));
|
|
27
|
+
}
|
|
28
|
+
/**
|
|
29
|
+
* Validate a result for this resource.
|
|
31
30
|
*
|
|
32
|
-
* @
|
|
33
|
-
* @throws
|
|
34
|
-
* @throws ValidationError If the result could not be validated.
|
|
31
|
+
* @returns The validated payload for this resource.
|
|
32
|
+
* @throws ValidationError if the result could not be validated.
|
|
35
33
|
*/
|
|
36
|
-
|
|
37
|
-
const result = await resource(this.payload.validate(payload), ...args);
|
|
34
|
+
validate(unsafeResult) {
|
|
38
35
|
try {
|
|
39
|
-
return this.result
|
|
36
|
+
return validate(unsafeResult, this.result);
|
|
40
37
|
}
|
|
41
38
|
catch (thrown) {
|
|
42
|
-
|
|
43
|
-
throw new ValidationError("Resource returned invalid result", thrown);
|
|
44
|
-
throw thrown;
|
|
39
|
+
throw thrown instanceof Feedback ? new ResourceValidationError(this, thrown) : thrown;
|
|
45
40
|
}
|
|
46
41
|
}
|
|
47
42
|
}
|
package/api/errors.d.ts
ADDED
|
@@ -0,0 +1,8 @@
|
|
|
1
|
+
import { Feedback } from "../feedback/index.js";
|
|
2
|
+
import { ValidationError } from "../error/index.js";
|
|
3
|
+
import type { Resource } from "./Resource.js";
|
|
4
|
+
/** Thrown if an API `Resource` can't validate. */
|
|
5
|
+
export declare class ResourceValidationError<P, R> extends ValidationError {
|
|
6
|
+
readonly resource: Resource<P, R>;
|
|
7
|
+
constructor(resource: Resource<P, R>, feedback: Feedback);
|
|
8
|
+
}
|
package/api/errors.js
ADDED
|
@@ -0,0 +1,9 @@
|
|
|
1
|
+
import { ValidationError } from "../error/index.js";
|
|
2
|
+
/** Thrown if an API `Resource` can't validate. */
|
|
3
|
+
export class ResourceValidationError extends ValidationError {
|
|
4
|
+
constructor(resource, feedback) {
|
|
5
|
+
super(`Invalid result for resource`, feedback);
|
|
6
|
+
this.resource = resource;
|
|
7
|
+
}
|
|
8
|
+
}
|
|
9
|
+
ResourceValidationError.prototype.name = "ResourceValidationError";
|
package/db/Change.d.ts
CHANGED
|
@@ -1,53 +1,39 @@
|
|
|
1
|
-
import
|
|
2
|
-
import
|
|
1
|
+
import { Transforms, Transform } from "../transform/index.js";
|
|
2
|
+
import { Datas, ImmutableArray, Key } from "../util/index.js";
|
|
3
|
+
import type { Database, DatabaseDocument } from "./Database.js";
|
|
3
4
|
/** A single change that can be made to a database. */
|
|
4
5
|
export declare abstract class Change<T extends Datas> {
|
|
5
6
|
/** Apply this change to a database. */
|
|
6
7
|
abstract apply(db: Database<T>): void | Promise<void>;
|
|
7
8
|
}
|
|
8
|
-
/** A change that
|
|
9
|
-
export declare class
|
|
10
|
-
|
|
9
|
+
/** A change that writes a document in a database. */
|
|
10
|
+
export declare class Write<D extends Datas, C extends Key<D>> extends Change<D> {
|
|
11
|
+
static on<X extends Datas, Y extends Key<X>>({ collection, id }: DatabaseDocument<X, Y>, value: X[Y] | Transform<X[Y]> | undefined): Write<X, Y>;
|
|
12
|
+
readonly collection: C;
|
|
11
13
|
readonly id: string;
|
|
12
|
-
readonly
|
|
13
|
-
constructor(collection:
|
|
14
|
-
apply(db: Database<
|
|
15
|
-
}
|
|
16
|
-
/** A change that updates the value of a document in a database. */
|
|
17
|
-
export declare class UpdateChange<T extends Datas, K extends keyof T & string> extends Change<T> {
|
|
18
|
-
readonly collection: K;
|
|
19
|
-
readonly id: string;
|
|
20
|
-
readonly transforms: Transforms<T[K]>;
|
|
21
|
-
constructor(collection: K, id: string, transforms: Transforms<T[K]>);
|
|
22
|
-
apply(db: Database<T>): void | Promise<void>;
|
|
23
|
-
}
|
|
24
|
-
/** A change that deletes a document from a database. */
|
|
25
|
-
export declare class DeleteChange<T extends Datas, K extends keyof T & string> extends Change<T> {
|
|
26
|
-
readonly collection: K;
|
|
27
|
-
readonly id: string;
|
|
28
|
-
constructor(collection: K, id: string);
|
|
29
|
-
apply(db: Database<T>): void | Promise<void>;
|
|
14
|
+
readonly value: D[C] | Transform<D[C]> | undefined;
|
|
15
|
+
constructor(collection: C, id: string, value: D[C] | Transform<D[C]> | undefined);
|
|
16
|
+
apply(db: Database<D>): void | Promise<void>;
|
|
30
17
|
}
|
|
31
18
|
/**
|
|
32
|
-
* Set of
|
|
19
|
+
* Set of writes that can be applied to documents in a database.
|
|
33
20
|
* - Sets of changes are predictable and repeatable, so unpredictable operations like `create()` and query operations are not supported.
|
|
34
21
|
* - Every change must be applied to a specific database document in a specific collection.
|
|
35
22
|
*/
|
|
36
|
-
export declare class
|
|
37
|
-
|
|
38
|
-
|
|
39
|
-
|
|
40
|
-
|
|
41
|
-
|
|
42
|
-
|
|
43
|
-
|
|
44
|
-
|
|
45
|
-
|
|
23
|
+
export declare class Writes<D extends Datas> extends Change<D> {
|
|
24
|
+
static on<X extends Datas>(db: Database<X>, ...changes: ImmutableArray<Change<X>>): Writes<X>;
|
|
25
|
+
readonly changes: ImmutableArray<Change<D>>;
|
|
26
|
+
constructor(...changes: ImmutableArray<Change<D>>);
|
|
27
|
+
/** Return a new `Changes` instance with an additional `Write` instance in its changes list. */
|
|
28
|
+
set<C extends Key<D>>({ collection, id }: DatabaseDocument<D, C>, data: D[C]): this;
|
|
29
|
+
/** Return a new `Changes` instance with an additional `Write` instance in its changes list. */
|
|
30
|
+
delete<C extends Key<D>>({ collection, id }: DatabaseDocument<D, C>): this;
|
|
31
|
+
/** Return a new `Changes` instance with an additional `Write` instance in its changes list. */
|
|
32
|
+
update<C extends Key<D>>({ collection, id }: DatabaseDocument<D, C>, transforms: Transforms<D[C]> | Transform<D[C]>): this;
|
|
33
|
+
apply(db: Database<D>): Promise<void> | undefined;
|
|
46
34
|
}
|
|
47
35
|
/** Set of hydrations for all change classes. */
|
|
48
36
|
export declare const CHANGE_HYDRATIONS: {
|
|
49
|
-
|
|
50
|
-
|
|
51
|
-
update: typeof UpdateChange;
|
|
52
|
-
delete: typeof DeleteChange;
|
|
37
|
+
writes: typeof Writes;
|
|
38
|
+
write: typeof Write;
|
|
53
39
|
};
|
package/db/Change.js
CHANGED
|
@@ -1,76 +1,66 @@
|
|
|
1
|
+
import { DataTransform, Transform } from "../transform/index.js";
|
|
2
|
+
import { VOID, isAsync } from "../util/index.js";
|
|
1
3
|
/** A single change that can be made to a database. */
|
|
2
4
|
export class Change {
|
|
3
5
|
}
|
|
4
|
-
/** A change that
|
|
5
|
-
export class
|
|
6
|
-
constructor(collection, id,
|
|
6
|
+
/** A change that writes a document in a database. */
|
|
7
|
+
export class Write extends Change {
|
|
8
|
+
constructor(collection, id, value) {
|
|
7
9
|
super();
|
|
8
10
|
this.collection = collection;
|
|
9
11
|
this.id = id;
|
|
10
|
-
this.
|
|
12
|
+
this.value = value;
|
|
11
13
|
}
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
return db.docs(this.collection).is("id", this.id).set(this.data);
|
|
15
|
-
}
|
|
16
|
-
}
|
|
17
|
-
/** A change that updates the value of a document in a database. */
|
|
18
|
-
export class UpdateChange extends Change {
|
|
19
|
-
constructor(collection, id, transforms) {
|
|
20
|
-
super();
|
|
21
|
-
this.collection = collection;
|
|
22
|
-
this.id = id;
|
|
23
|
-
this.transforms = transforms;
|
|
14
|
+
static on({ collection, id }, value) {
|
|
15
|
+
return new Write(collection, id, value);
|
|
24
16
|
}
|
|
25
17
|
apply(db) {
|
|
26
|
-
return db.doc(this.collection, this.id).
|
|
27
|
-
}
|
|
28
|
-
}
|
|
29
|
-
/** A change that deletes a document from a database. */
|
|
30
|
-
export class DeleteChange extends Change {
|
|
31
|
-
constructor(collection, id) {
|
|
32
|
-
super();
|
|
33
|
-
this.collection = collection;
|
|
34
|
-
this.id = id;
|
|
35
|
-
}
|
|
36
|
-
apply(db) {
|
|
37
|
-
return db.doc(this.collection, this.id).delete();
|
|
18
|
+
return db.doc(this.collection, this.id).write(this.value);
|
|
38
19
|
}
|
|
39
20
|
}
|
|
40
21
|
/**
|
|
41
|
-
* Set of
|
|
22
|
+
* Set of writes that can be applied to documents in a database.
|
|
42
23
|
* - Sets of changes are predictable and repeatable, so unpredictable operations like `create()` and query operations are not supported.
|
|
43
24
|
* - Every change must be applied to a specific database document in a specific collection.
|
|
44
25
|
*/
|
|
45
|
-
export class
|
|
26
|
+
export class Writes extends Change {
|
|
46
27
|
constructor(...changes) {
|
|
47
28
|
super();
|
|
48
29
|
this.changes = changes;
|
|
49
30
|
}
|
|
50
|
-
|
|
51
|
-
|
|
52
|
-
|
|
31
|
+
static on(db, ...changes) {
|
|
32
|
+
return new Writes(...changes);
|
|
33
|
+
}
|
|
34
|
+
/** Return a new `Changes` instance with an additional `Write` instance in its changes list. */
|
|
35
|
+
set({ collection, id }, data) {
|
|
36
|
+
return { __proto__: Object.getPrototypeOf(this), ...this, changes: [...this.changes, new Write(collection, id, data)] };
|
|
53
37
|
}
|
|
54
|
-
/** Return a new `Changes` instance with an additional `
|
|
55
|
-
|
|
56
|
-
return { __proto__:
|
|
38
|
+
/** Return a new `Changes` instance with an additional `Write` instance in its changes list. */
|
|
39
|
+
delete({ collection, id }) {
|
|
40
|
+
return { __proto__: Object.getPrototypeOf(this), ...this, changes: [...this.changes, new Write(collection, id, undefined)] };
|
|
57
41
|
}
|
|
58
|
-
/** Return a new `Changes` instance with an additional `
|
|
59
|
-
|
|
60
|
-
return {
|
|
42
|
+
/** Return a new `Changes` instance with an additional `Write` instance in its changes list. */
|
|
43
|
+
update({ collection, id }, transforms) {
|
|
44
|
+
return {
|
|
45
|
+
__proto__: Object.getPrototypeOf(this),
|
|
46
|
+
...this,
|
|
47
|
+
changes: [...this.changes, new Write(collection, id, transforms instanceof Transform ? transforms : new DataTransform(transforms))],
|
|
48
|
+
};
|
|
61
49
|
}
|
|
62
|
-
|
|
63
|
-
const
|
|
64
|
-
for (const change of this.changes)
|
|
65
|
-
|
|
66
|
-
|
|
50
|
+
apply(db) {
|
|
51
|
+
const promises = [];
|
|
52
|
+
for (const change of this.changes) {
|
|
53
|
+
const applied = change.apply(db);
|
|
54
|
+
if (isAsync(applied))
|
|
55
|
+
promises.push(applied);
|
|
56
|
+
}
|
|
57
|
+
if (promises.length)
|
|
58
|
+
return Promise.all(promises).then(VOID);
|
|
67
59
|
}
|
|
68
60
|
}
|
|
69
61
|
/** Set of hydrations for all change classes. */
|
|
70
62
|
export const CHANGE_HYDRATIONS = {
|
|
71
|
-
|
|
72
|
-
|
|
73
|
-
update: UpdateChange,
|
|
74
|
-
delete: DeleteChange,
|
|
63
|
+
writes: Writes,
|
|
64
|
+
write: Write,
|
|
75
65
|
};
|
|
76
66
|
CHANGE_HYDRATIONS;
|
package/db/Database.d.ts
CHANGED
|
@@ -1,30 +1,178 @@
|
|
|
1
|
-
import
|
|
2
|
-
import
|
|
3
|
-
import {
|
|
4
|
-
import {
|
|
1
|
+
import { Dispatcher, Entry, Observable, Observer, Result, Unsubscriber, Datas, Results, Validatable, Validator, Validators, Key, Data, ImmutableMap } from "../util/index.js";
|
|
2
|
+
import { Transform, Transforms } from "../transform/index.js";
|
|
3
|
+
import type { Provider } from "../provider/Provider.js";
|
|
4
|
+
import { Filters, Sorts, Query } from "../query/index.js";
|
|
5
5
|
/**
|
|
6
|
-
*
|
|
6
|
+
* Combines a database model and a provider.
|
|
7
7
|
*
|
|
8
8
|
* @param documents Set of loci describing named documents at the root level of the database.
|
|
9
9
|
* @param collections Set of loci describing collections at the root level of the database.
|
|
10
10
|
* @param provider Provider that allows data to be read/written.
|
|
11
11
|
*/
|
|
12
|
-
export declare class Database<
|
|
13
|
-
|
|
14
|
-
readonly
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
|
|
12
|
+
export declare class Database<D extends Datas> {
|
|
13
|
+
readonly validators: Validators<D>;
|
|
14
|
+
readonly provider: Provider<D>;
|
|
15
|
+
constructor(validators: Validators<D>, provider: Provider<D>);
|
|
16
|
+
/** Create a query on a collection in this model. */
|
|
17
|
+
query<C extends Key<D>>(collection: C, filters?: Filters<D[C]>, sorts?: Sorts<D[C]>, limit?: number | null): DatabaseQuery<D, C>;
|
|
18
|
+
/** Reference a document in a collection in this model. */
|
|
19
|
+
doc<C extends Key<D>>(collection: C, id: string): DatabaseDocument<D, C>;
|
|
20
|
+
}
|
|
21
|
+
/** A documents reference within a specific database. */
|
|
22
|
+
export declare class DatabaseQuery<D extends Datas, C extends Key<D>> extends Query<D[C]> implements Observable<Results<D[C]>>, Validatable<Results<D[C]>>, Iterable<Entry<D[C]>> {
|
|
23
|
+
readonly db: Database<D>;
|
|
24
|
+
readonly validator: Validator<D[C]>;
|
|
25
|
+
readonly collection: C;
|
|
26
|
+
constructor(db: Database<D>, collection: C, filters?: Filters<D[C]>, sorts?: Sorts<D[C]>, limit?: number | null);
|
|
27
|
+
/** Reference a document in this query's collection. */
|
|
28
|
+
doc(id: string): DatabaseDocument<D, C>;
|
|
29
|
+
/**
|
|
30
|
+
* Create a new document with a random ID.
|
|
31
|
+
* - Created document is guaranteed to have a unique ID.
|
|
32
|
+
*
|
|
33
|
+
* @param data Complete data to set the document to.
|
|
34
|
+
* @return String ID for the created document (possibly promised).
|
|
35
|
+
*/
|
|
36
|
+
add(data: D[C]): string | Promise<string>;
|
|
37
|
+
/**
|
|
38
|
+
* Get an iterable that yields the results of this entry.
|
|
39
|
+
* @return Map containing the results.
|
|
40
|
+
*/
|
|
41
|
+
get results(): Results<D[C]> | Promise<Results<D[C]>>;
|
|
42
|
+
/**
|
|
43
|
+
* Read the results of this query into a map.
|
|
44
|
+
* @return Set of results in `id: data` format (possibly promised).
|
|
45
|
+
*/
|
|
46
|
+
get map(): ImmutableMap<D[C]> | Promise<ImmutableMap<D[C]>>;
|
|
47
|
+
/**
|
|
48
|
+
* Count the number of results of this set of documents.
|
|
49
|
+
* @return Number of documents in the collection (possibly promised).
|
|
50
|
+
*/
|
|
51
|
+
get count(): number | Promise<number>;
|
|
52
|
+
/**
|
|
53
|
+
* Subscribe to all matching documents.
|
|
54
|
+
* - `next()` is called once with the initial results, and again any time the results change.
|
|
55
|
+
*
|
|
56
|
+
* @param observer Observer with `next`, `error`, or `complete` methods that the document results are reported back to.
|
|
57
|
+
* @param next Callback that is called once initially and again whenever the results change.
|
|
58
|
+
* @param error Callback that is called if an error occurs.
|
|
59
|
+
* @param complete Callback that is called when the subscription is done.
|
|
60
|
+
*
|
|
61
|
+
* @return Function that ends the subscription.
|
|
62
|
+
*/
|
|
63
|
+
subscribe(next: Observer<Results<D[C]>> | Dispatcher<Results<D[C]>>, error?: Dispatcher<Error | unknown>, complete?: Dispatcher<void>): Unsubscriber;
|
|
64
|
+
/**
|
|
65
|
+
* Get an entry for the first document matching this query.
|
|
66
|
+
* @return Entry in `[id, data]` format for the first document, or `undefined` if there are no matching documents (possibly promised).
|
|
67
|
+
*/
|
|
68
|
+
get first(): Entry<D[C]> | undefined | Promise<Entry<D[C]> | undefined>;
|
|
69
|
+
/**
|
|
70
|
+
* Set all matching documents to the same exact value.
|
|
71
|
+
*
|
|
72
|
+
* @param data Complete data to set the document to.
|
|
73
|
+
* @return Nothing (possibly promised).
|
|
74
|
+
*/
|
|
75
|
+
set(data: D[C]): void | Promise<void>;
|
|
76
|
+
/**
|
|
77
|
+
* Update all matching documents with the same partial value.
|
|
78
|
+
*
|
|
79
|
+
* @param transform `Transform` instance or set of transforms to apply to every matching document.
|
|
80
|
+
* - Not all transforms may be supported by all providers.
|
|
81
|
+
*
|
|
82
|
+
* @return Nothing (possibly promised).
|
|
83
|
+
*/
|
|
84
|
+
update(transform: Transform<D[C]> | Transforms<D[C]>): void | Promise<void>;
|
|
85
|
+
/**
|
|
86
|
+
* Delete all matching documents.
|
|
87
|
+
* @return Nothing (possibly promised).
|
|
88
|
+
*/
|
|
89
|
+
delete(): void | Promise<void>;
|
|
90
|
+
/**
|
|
91
|
+
* Combine `set()`, `update()`, `delete()` into a single method.
|
|
92
|
+
* @return Nothing (possibly promised).
|
|
93
|
+
*/
|
|
94
|
+
write(value: Result<D[C]> | Transform<D[C]>): void | Promise<void>;
|
|
95
|
+
/** Iterate over the resuls (will throw `Promise` if the results are asynchronous). */
|
|
96
|
+
[Symbol.iterator](): Iterator<Entry<D[C]>, void>;
|
|
97
|
+
/** Validate a set of results for this query reference. */
|
|
98
|
+
validate(unsafeEntries: Results): Results<D[C]>;
|
|
99
|
+
toString(): string;
|
|
100
|
+
}
|
|
101
|
+
/** A document reference within a specific database. */
|
|
102
|
+
export declare class DatabaseDocument<D extends Datas, C extends Key<D>> implements Observable<Result<D[C]>>, Validatable<D[C]> {
|
|
103
|
+
readonly db: Database<D>;
|
|
104
|
+
readonly validator: Validator<D[C]>;
|
|
105
|
+
readonly collection: C;
|
|
106
|
+
readonly id: string;
|
|
107
|
+
constructor(db: Database<D>, collection: C, id: string);
|
|
108
|
+
/** Create a query on this document's collection. */
|
|
109
|
+
query(filters?: Filters<D[C]>, sorts?: Sorts<D[C]>, limit?: number | null): DatabaseQuery<D, C>;
|
|
110
|
+
/** Get an 'optional' reference to this document (uses a `ModelQuery` with an `id` filter). */
|
|
111
|
+
get optional(): DatabaseQuery<D, C>;
|
|
112
|
+
/**
|
|
113
|
+
* Does this document exist?
|
|
114
|
+
*
|
|
115
|
+
* @return Document's data, or `undefined` if the document doesn't exist (possibly promised).
|
|
116
|
+
*/
|
|
117
|
+
get exists(): boolean | Promise<boolean>;
|
|
118
|
+
/**
|
|
119
|
+
* Get the result of this document.
|
|
120
|
+
*
|
|
121
|
+
* @return Document's data, or `undefined` if the document doesn't exist (possibly promised).
|
|
122
|
+
*/
|
|
123
|
+
get result(): Result<D[C]> | Promise<Result<D[C]>>;
|
|
124
|
+
/**
|
|
125
|
+
* Get the data of this document.
|
|
126
|
+
* - Useful for destructuring, e.g. `{ name, title } = await documentThatMustExist.asyncData`
|
|
127
|
+
*
|
|
128
|
+
* @return Document's data (possibly promised).
|
|
129
|
+
* @throws RequiredError if the document's result was undefined.
|
|
130
|
+
*/
|
|
131
|
+
get data(): D[C] | Promise<D[C]>;
|
|
132
|
+
/**
|
|
133
|
+
* Subscribe to the result of this document (indefinitely).
|
|
134
|
+
* - `next()` is called once with the initial result, and again any time the result changes.
|
|
135
|
+
*
|
|
136
|
+
* @param observer Observer with `next`, `error`, or `complete` methods.
|
|
137
|
+
* @param next Callback that is called once initially and again whenever the result changes.
|
|
138
|
+
* @param error Callback that is called if an error occurs.
|
|
139
|
+
* @param complete Callback that is called when the subscription is done.
|
|
140
|
+
*
|
|
141
|
+
* @return Function that ends the subscription.
|
|
142
|
+
*/
|
|
143
|
+
subscribe(next: Observer<Result<D[C]>> | Dispatcher<Result<D[C]>>, error?: Dispatcher<Error | unknown>, complete?: Dispatcher<void>): Unsubscriber;
|
|
144
|
+
/**
|
|
145
|
+
* Set the complete data of this document.
|
|
146
|
+
*
|
|
147
|
+
* @param data Complete data to set the document to.
|
|
148
|
+
*
|
|
149
|
+
* @return Nothing (possibly promised).
|
|
150
|
+
*/
|
|
151
|
+
set(data: D[C]): void | Promise<void>;
|
|
152
|
+
/**
|
|
153
|
+
* Update this document with partial data.
|
|
154
|
+
* - If the document exists, merge the partial data into it.
|
|
155
|
+
* - If the document doesn't exist, throw an error.
|
|
156
|
+
*
|
|
157
|
+
* @param transforms `Transform` instance or set of transforms to apply to the existing document.
|
|
158
|
+
* - Not all transforms may be supported by all providers.
|
|
159
|
+
*
|
|
160
|
+
* @return Nothing (possibly promised).
|
|
161
|
+
* @throws Error If the document does not exist (ideally a `RequiredError` but may be provider-specific).
|
|
162
|
+
*/
|
|
163
|
+
update(transforms: Transform<D[C]> | Transforms<D[C]>): void | Promise<void>;
|
|
18
164
|
/**
|
|
19
|
-
*
|
|
20
|
-
*
|
|
21
|
-
*
|
|
165
|
+
* Delete this document.
|
|
166
|
+
* - Will not throw an error if the document doesn't exist.
|
|
167
|
+
*
|
|
168
|
+
* @return Nothing (possibly promised).
|
|
22
169
|
*/
|
|
23
|
-
|
|
170
|
+
delete(): void | Promise<void>;
|
|
24
171
|
/**
|
|
25
|
-
*
|
|
26
|
-
* @param name Document name, e.g. `fido`
|
|
27
|
-
* @example `db.doc("dogs", "fido").get()`
|
|
172
|
+
* Combine `set()`, `update()`, `delete()` into a single method.
|
|
28
173
|
*/
|
|
29
|
-
|
|
174
|
+
write(value: Result<D[C]> | Transform<D[C]>): void | Promise<void>;
|
|
175
|
+
/** Validate data for this query reference. */
|
|
176
|
+
validate(unsafeData: Data): D[C];
|
|
177
|
+
toString(): string;
|
|
30
178
|
}
|