shelving 1.61.0 → 1.62.1
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 +1 -1
- package/api/Resource.js +4 -3
- package/api/errors.d.ts +2 -2
- package/api/errors.js +1 -1
- package/db/Database.d.ts +4 -2
- package/db/Database.js +2 -1
- package/db/Operation.d.ts +7 -9
- package/db/Operation.js +3 -3
- package/db/PaginationState.d.ts +4 -2
- package/db/PaginationState.js +9 -4
- package/db/Reference.d.ts +12 -4
- package/db/Reference.js +13 -5
- package/db/errors.d.ts +4 -3
- package/db/errors.js +2 -1
- package/db/index.d.ts +1 -1
- package/db/index.js +1 -1
- package/db/{helpers.d.ts → util.d.ts} +5 -3
- package/db/{helpers.js → util.js} +5 -3
- package/error/AssertionError.js +1 -1
- package/error/ValidationError.d.ts +1 -1
- package/feedback/Feedback.d.ts +1 -1
- package/feedback/Feedback.js +2 -1
- package/feedback/hydrations.d.ts +2 -12
- package/feedback/hydrations.js +0 -1
- package/firestore/client/FirestoreClientProvider.d.ts +6 -1
- package/firestore/client/FirestoreClientProvider.js +7 -1
- package/firestore/lite/FirestoreLiteProvider.d.ts +7 -2
- package/firestore/lite/FirestoreLiteProvider.js +6 -1
- package/firestore/server/FirestoreServerProvider.d.ts +7 -2
- package/firestore/server/FirestoreServerProvider.js +10 -4
- package/markup/render.d.ts +1 -1
- package/markup/render.js +1 -1
- package/markup/rules.js +2 -1
- package/markup/types.d.ts +1 -1
- package/package.json +10 -8
- package/provider/BatchProvider.d.ts +5 -2
- package/provider/BatchProvider.js +4 -2
- package/provider/CacheProvider.d.ts +5 -3
- package/provider/CacheProvider.js +1 -1
- package/provider/ErrorProvider.d.ts +5 -3
- package/provider/ErrorProvider.js +2 -1
- package/provider/MemoryProvider.d.ts +5 -3
- package/provider/MemoryProvider.js +4 -2
- package/provider/Provider.d.ts +5 -3
- package/provider/ThroughProvider.d.ts +6 -3
- package/provider/ThroughProvider.js +1 -1
- package/provider/ValidationProvider.d.ts +5 -3
- package/provider/ValidationProvider.js +4 -2
- package/query/Filter.d.ts +23 -2
- package/query/Filter.js +2 -2
- package/query/Filters.d.ts +20 -3
- package/query/Filters.js +1 -1
- package/query/Query.d.ts +29 -4
- package/query/Query.js +3 -2
- package/query/Rule.d.ts +3 -1
- package/query/Rules.d.ts +2 -1
- package/query/Rules.js +1 -1
- package/query/Sort.d.ts +10 -2
- package/query/Sort.js +2 -2
- package/query/Sorts.d.ts +12 -3
- package/query/Sorts.js +2 -2
- package/query/index.d.ts +1 -2
- package/query/index.js +1 -2
- package/query/{helpers.d.ts → util.d.ts} +2 -2
- package/query/{helpers.js → util.js} +1 -1
- package/react/useCompare.d.ts +1 -1
- package/react/useDocument.d.ts +5 -3
- package/react/useDocument.js +7 -3
- package/react/useFetch.d.ts +2 -1
- package/react/useFetch.js +3 -1
- package/react/useInstance.d.ts +1 -1
- package/react/useInstance.js +1 -1
- package/react/useLazy.d.ts +1 -1
- package/react/useLazy.js +2 -1
- package/react/usePagination.d.ts +3 -1
- package/react/usePagination.js +4 -2
- package/react/usePureEffect.d.ts +2 -1
- package/react/usePureState.d.ts +1 -1
- package/react/usePureState.js +2 -1
- package/react/useQuery.d.ts +3 -1
- package/react/useQuery.js +9 -3
- package/react/useReduce.d.ts +1 -1
- package/react/useState.d.ts +10 -2
- package/react/useState.js +7 -2
- package/react/useSubscribe.d.ts +1 -1
- package/react/useSubscribe.js +3 -2
- package/schema/AllowSchema.js +5 -2
- package/schema/ArraySchema.d.ts +2 -1
- package/schema/ArraySchema.js +3 -2
- package/schema/DataSchema.d.ts +3 -2
- package/schema/DataSchema.js +4 -3
- package/schema/DateSchema.d.ts +1 -1
- package/schema/DateSchema.js +2 -2
- package/schema/LinkSchema.js +2 -2
- package/schema/MapSchema.d.ts +2 -1
- package/schema/MapSchema.js +3 -2
- package/schema/NumberSchema.js +2 -2
- package/schema/ObjectSchema.d.ts +2 -1
- package/schema/ObjectSchema.js +3 -2
- package/schema/RequiredSchema.js +1 -1
- package/schema/Schema.d.ts +1 -1
- package/schema/SlugSchema.js +1 -1
- package/schema/StringSchema.js +2 -2
- package/schema/ThroughSchema.d.ts +1 -1
- package/schema/ThroughSchema.js +1 -1
- package/stream/ArrayState.d.ts +1 -1
- package/stream/ArrayState.js +1 -1
- package/stream/DataState.d.ts +2 -1
- package/stream/DataState.js +5 -2
- package/stream/LastStream.js +2 -1
- package/stream/LazyState.d.ts +1 -1
- package/stream/LazyState.js +1 -1
- package/stream/LazyStream.d.ts +1 -1
- package/stream/ObjectState.d.ts +2 -1
- package/stream/ObjectState.js +1 -1
- package/stream/State.d.ts +5 -3
- package/stream/State.js +7 -5
- package/stream/Stream.d.ts +4 -1
- package/stream/Stream.js +3 -2
- package/test/basics.d.ts +3 -3
- package/test/basics.js +5 -1
- package/test/people.d.ts +1 -1
- package/test/people.js +3 -1
- package/test/util.d.ts +1 -1
- package/test/util.js +1 -1
- package/update/ArrayUpdate.d.ts +1 -1
- package/update/ArrayUpdate.js +1 -1
- package/update/DataUpdate.d.ts +3 -1
- package/update/DataUpdate.js +2 -1
- package/update/ObjectUpdate.d.ts +6 -3
- package/update/ObjectUpdate.js +3 -1
- package/update/Update.d.ts +1 -1
- package/update/hydrations.d.ts +2 -10
- package/update/hydrations.js +0 -1
- package/update/util.d.ts +4 -2
- package/update/util.js +5 -2
- package/util/array.d.ts +10 -2
- package/util/array.js +12 -4
- package/util/assert.d.ts +2 -51
- package/util/assert.js +7 -106
- package/util/async.d.ts +11 -3
- package/util/async.js +20 -2
- package/util/boolean.d.ts +10 -0
- package/util/boolean.js +26 -0
- package/util/class.d.ts +5 -1
- package/util/class.js +10 -1
- package/util/color.js +1 -1
- package/util/data.js +1 -1
- package/util/date.d.ts +2 -39
- package/util/date.js +7 -69
- package/util/function.d.ts +2 -0
- package/util/function.js +6 -0
- package/util/hydrate.js +1 -1
- package/util/index.d.ts +1 -1
- package/util/index.js +1 -1
- package/util/iterate.js +2 -2
- package/util/null.d.ts +10 -7
- package/util/null.js +21 -6
- package/util/number.d.ts +8 -0
- package/util/number.js +22 -3
- package/util/object.d.ts +8 -0
- package/util/object.js +17 -1
- package/util/{observable.d.ts → observe.d.ts} +12 -12
- package/util/{observable.js → observe.js} +20 -29
- package/util/serialise.js +1 -1
- package/util/string.d.ts +2 -2
- package/util/string.js +6 -2
- package/util/undefined.d.ts +5 -6
- package/util/undefined.js +10 -5
- package/util/units.d.ts +45 -0
- package/util/units.js +73 -2
- package/util/url.d.ts +2 -0
- package/util/url.js +7 -3
- package/util/validate.js +2 -1
- package/query/types.d.ts +0 -74
- package/query/types.js +0 -1
package/api/Resource.d.ts
CHANGED
package/api/Resource.js
CHANGED
|
@@ -1,5 +1,6 @@
|
|
|
1
|
-
import {
|
|
2
|
-
import {
|
|
1
|
+
import { validate } from "../util/validate.js";
|
|
2
|
+
import { getUndefined } from "../util/undefined.js";
|
|
3
|
+
import { Feedback } from "../feedback/Feedback.js";
|
|
3
4
|
import { ResourceValidationError } from "./errors.js";
|
|
4
5
|
/**
|
|
5
6
|
* An abstract API resource definition, used to specify types for e.g. serverless functions..
|
|
@@ -37,6 +38,6 @@ export class Resource {
|
|
|
37
38
|
}
|
|
38
39
|
}
|
|
39
40
|
}
|
|
40
|
-
export function RESOURCE(payload =
|
|
41
|
+
export function RESOURCE(payload = getUndefined, result = getUndefined) {
|
|
41
42
|
return new Resource(payload, result);
|
|
42
43
|
}
|
package/api/errors.d.ts
CHANGED
|
@@ -1,5 +1,5 @@
|
|
|
1
|
-
import { Feedback } from "../feedback/
|
|
2
|
-
import { ValidationError } from "../error/
|
|
1
|
+
import type { Feedback } from "../feedback/Feedback.js";
|
|
2
|
+
import { ValidationError } from "../error/ValidationError.js";
|
|
3
3
|
import type { Resource } from "./Resource.js";
|
|
4
4
|
/** Thrown if an API `Resource` can't validate. */
|
|
5
5
|
export declare class ResourceValidationError<P, R> extends ValidationError {
|
package/api/errors.js
CHANGED
package/db/Database.d.ts
CHANGED
|
@@ -1,6 +1,8 @@
|
|
|
1
|
-
import {
|
|
1
|
+
import type { Validators, ValidatorType } from "../util/validate.js";
|
|
2
|
+
import type { Key, Datas } from "../util/data.js";
|
|
2
3
|
import type { Provider } from "../provider/Provider.js";
|
|
3
|
-
import {
|
|
4
|
+
import type { SortKeys } from "../query/Sort.js";
|
|
5
|
+
import type { FilterProps } from "../query/Filter.js";
|
|
4
6
|
import { DocumentReference, QueryReference } from "./Reference.js";
|
|
5
7
|
/**
|
|
6
8
|
* Combines a database model and a provider.
|
package/db/Database.js
CHANGED
package/db/Operation.d.ts
CHANGED
|
@@ -1,5 +1,9 @@
|
|
|
1
|
-
import { PropUpdates
|
|
2
|
-
import {
|
|
1
|
+
import type { PropUpdates } from "../update/DataUpdate.js";
|
|
2
|
+
import { Update } from "../update/Update.js";
|
|
3
|
+
import { ImmutableArray } from "../util/array.js";
|
|
4
|
+
import { Data, Key } from "../util/data.js";
|
|
5
|
+
import { Hydrations } from "../util/hydrate.js";
|
|
6
|
+
import { Nullish } from "../util/null.js";
|
|
3
7
|
import type { Database } from "./Database.js";
|
|
4
8
|
import type { DocumentReference, QueryReference } from "./Reference.js";
|
|
5
9
|
/** Represent a write operation on a database. */
|
|
@@ -72,10 +76,4 @@ export declare class DeleteOperation extends Operation {
|
|
|
72
76
|
run(db: Database): Promise<this>;
|
|
73
77
|
}
|
|
74
78
|
/** Set of hydrations for all change classes. */
|
|
75
|
-
export declare const OPERATION_HYDRATIONS:
|
|
76
|
-
Operations: typeof Operations;
|
|
77
|
-
AddOperation: typeof AddOperation;
|
|
78
|
-
SetOperation: typeof SetOperation;
|
|
79
|
-
UpdateOperation: typeof UpdateOperation;
|
|
80
|
-
DeleteOperation: typeof DeleteOperation;
|
|
81
|
-
};
|
|
79
|
+
export declare const OPERATION_HYDRATIONS: Hydrations;
|
package/db/Operation.js
CHANGED
|
@@ -1,4 +1,5 @@
|
|
|
1
|
-
import { callAsyncSeries
|
|
1
|
+
import { callAsyncSeries } from "../util/async.js";
|
|
2
|
+
import { isNullish, notNullish } from "../util/null.js";
|
|
2
3
|
/** Represent a write operation on a database. */
|
|
3
4
|
export class Operation {
|
|
4
5
|
}
|
|
@@ -120,10 +121,9 @@ export class DeleteOperation extends Operation {
|
|
|
120
121
|
}
|
|
121
122
|
/** Set of hydrations for all change classes. */
|
|
122
123
|
export const OPERATION_HYDRATIONS = {
|
|
123
|
-
Operations
|
|
124
|
+
Operations,
|
|
124
125
|
AddOperation,
|
|
125
126
|
SetOperation,
|
|
126
127
|
UpdateOperation,
|
|
127
128
|
DeleteOperation,
|
|
128
129
|
};
|
|
129
|
-
OPERATION_HYDRATIONS;
|
package/db/PaginationState.d.ts
CHANGED
|
@@ -1,5 +1,7 @@
|
|
|
1
|
-
import {
|
|
2
|
-
import {
|
|
1
|
+
import type { Entries, Entry } from "../util/entry.js";
|
|
2
|
+
import type { Data, Results } from "../util/data.js";
|
|
3
|
+
import { BooleanState } from "../stream/BooleanState.js";
|
|
4
|
+
import { State } from "../stream/State.js";
|
|
3
5
|
import { QueryReference } from "./Reference.js";
|
|
4
6
|
/**
|
|
5
7
|
* State that wraps a `Documents` reference to enable pagination.
|
package/db/PaginationState.js
CHANGED
|
@@ -1,6 +1,11 @@
|
|
|
1
|
-
import {
|
|
2
|
-
import { BooleanState
|
|
3
|
-
import {
|
|
1
|
+
import { ConditionError } from "../error/ConditionError.js";
|
|
2
|
+
import { BooleanState } from "../stream/BooleanState.js";
|
|
3
|
+
import { State } from "../stream/State.js";
|
|
4
|
+
import { getLastItem } from "../util/array.js";
|
|
5
|
+
import { NOVALUE } from "../util/constants.js";
|
|
6
|
+
import { yieldMerged } from "../util/iterate.js";
|
|
7
|
+
import { getMap } from "../util/map.js";
|
|
8
|
+
import { assertMax, assertNumber } from "../util/number.js";
|
|
4
9
|
/**
|
|
5
10
|
* State that wraps a `Documents` reference to enable pagination.
|
|
6
11
|
* - If you pass in initial values, it will use that as the first page.
|
|
@@ -22,7 +27,7 @@ export class PaginationState extends State {
|
|
|
22
27
|
this.busy.next(true);
|
|
23
28
|
if (!this.exists) {
|
|
24
29
|
// First set of results.
|
|
25
|
-
this._value ===
|
|
30
|
+
this._value === NOVALUE;
|
|
26
31
|
const next = await this.ref.results;
|
|
27
32
|
this.next(next);
|
|
28
33
|
if (next.size < this.limit)
|
package/db/Reference.d.ts
CHANGED
|
@@ -1,7 +1,15 @@
|
|
|
1
|
-
import {
|
|
2
|
-
import {
|
|
3
|
-
import {
|
|
4
|
-
import {
|
|
1
|
+
import type { Data, Result, Results } from "../util/data.js";
|
|
2
|
+
import type { Dispatcher } from "../util/function.js";
|
|
3
|
+
import type { SortKeys } from "../query/Sort.js";
|
|
4
|
+
import { Observable, Observer, Unsubscriber } from "../util/observe.js";
|
|
5
|
+
import { Validatable, Validator } from "../util/validate.js";
|
|
6
|
+
import { Query } from "../query/Query.js";
|
|
7
|
+
import { Entries, Entry } from "../util/entry.js";
|
|
8
|
+
import { Filters } from "../query/Filters.js";
|
|
9
|
+
import { Sorts } from "../query/Sorts.js";
|
|
10
|
+
import { DataUpdate, PropUpdates } from "../update/DataUpdate.js";
|
|
11
|
+
import { FilterProps } from "../query/Filter.js";
|
|
12
|
+
import { DocumentData, DocumentResult } from "./util.js";
|
|
5
13
|
import type { Database } from "./Database.js";
|
|
6
14
|
/** A refence to a location in a database. */
|
|
7
15
|
export interface Reference {
|
package/db/Reference.js
CHANGED
|
@@ -1,9 +1,17 @@
|
|
|
1
|
-
import {
|
|
2
|
-
import {
|
|
3
|
-
import {
|
|
4
|
-
import { Filters
|
|
1
|
+
import { ResultsObserver } from "../util/observe.js";
|
|
2
|
+
import { validate } from "../util/validate.js";
|
|
3
|
+
import { Query } from "../query/Query.js";
|
|
4
|
+
import { Filters } from "../query/Filters.js";
|
|
5
|
+
import { Sorts } from "../query/Sorts.js";
|
|
6
|
+
import { callAsync, throwAsync } from "../util/async.js";
|
|
7
|
+
import { getMap } from "../util/map.js";
|
|
8
|
+
import { countItems, hasItems } from "../util/iterate.js";
|
|
9
|
+
import { DataUpdate } from "../update/DataUpdate.js";
|
|
10
|
+
import { Feedback } from "../feedback/Feedback.js";
|
|
11
|
+
import { InvalidFeedback } from "../feedback/InvalidFeedback.js";
|
|
12
|
+
import { Filter } from "../query/Filter.js";
|
|
5
13
|
import { DocumentValidationError, QueryValidationError } from "./errors.js";
|
|
6
|
-
import { DocumentResultObserver, getDocumentData, getDocumentResult, getQueryData, getQueryResult } from "./
|
|
14
|
+
import { DocumentResultObserver, getDocumentData, getDocumentResult, getQueryData, getQueryResult } from "./util.js";
|
|
7
15
|
/** A query reference within a specific database. */
|
|
8
16
|
export class QueryReference extends Query {
|
|
9
17
|
constructor(db, validator, collection, filters, sorts, limit) {
|
package/db/errors.d.ts
CHANGED
|
@@ -1,6 +1,7 @@
|
|
|
1
|
-
import type { Data } from "../util/
|
|
2
|
-
import {
|
|
3
|
-
import
|
|
1
|
+
import type { Data } from "../util/data.js";
|
|
2
|
+
import type { Feedback } from "../feedback/Feedback.js";
|
|
3
|
+
import { ValidationError } from "../error/ValidationError.js";
|
|
4
|
+
import { RequiredError } from "../error/RequiredError.js";
|
|
4
5
|
import type { DocumentReference, QueryReference } from "./Reference.js";
|
|
5
6
|
/** Thrown if a document doesn't exist. */
|
|
6
7
|
export declare class DocumentRequiredError<T extends Data> extends RequiredError {
|
package/db/errors.js
CHANGED
|
@@ -1,4 +1,5 @@
|
|
|
1
|
-
import {
|
|
1
|
+
import { ValidationError } from "../error/ValidationError.js";
|
|
2
|
+
import { RequiredError } from "../error/RequiredError.js";
|
|
2
3
|
/** Thrown if a document doesn't exist. */
|
|
3
4
|
export class DocumentRequiredError extends RequiredError {
|
|
4
5
|
constructor(ref) {
|
package/db/index.d.ts
CHANGED
package/db/index.js
CHANGED
|
@@ -1,4 +1,6 @@
|
|
|
1
|
-
import {
|
|
1
|
+
import { TransformableObserver, Observer } from "../util/observe.js";
|
|
2
|
+
import { Data, Result } from "../util/data.js";
|
|
3
|
+
import type { Entries } from "../util/entry.js";
|
|
2
4
|
import type { DocumentReference, QueryReference, Reference } from "./Reference.js";
|
|
3
5
|
/** Database data embeds the corresponding `Document` instance and string ID into the data. */
|
|
4
6
|
export declare type DocumentData<T extends Data> = T & {
|
|
@@ -10,7 +12,7 @@ export declare function getDocumentData<T extends Data>(result: DocumentResult<T
|
|
|
10
12
|
/** Is an unknown value a DocumentResult. */
|
|
11
13
|
export declare const isDocumentData: <T extends Data>(v: unknown) => v is DocumentData<T>;
|
|
12
14
|
/** Oserver that transforms a result into a document result. */
|
|
13
|
-
export declare class DocumentDataObserver<T extends Data> extends
|
|
15
|
+
export declare class DocumentDataObserver<T extends Data> extends TransformableObserver<Result<T>, DocumentData<T>> {
|
|
14
16
|
protected _ref: DocumentReference<T>;
|
|
15
17
|
constructor(target: Observer<DocumentData<T>>, ref: DocumentReference<T>);
|
|
16
18
|
transform(result: Result<T>): DocumentData<T>;
|
|
@@ -22,7 +24,7 @@ export declare function getDocumentResult<T extends Data>(result: Result<T>, ref
|
|
|
22
24
|
/** Is an unknown value a DocumentResult. */
|
|
23
25
|
export declare const isDocumentResult: <T extends Data>(v: unknown) => v is DocumentResult<T>;
|
|
24
26
|
/** Oserver that transforms a set of entries into a results map. */
|
|
25
|
-
export declare class DocumentResultObserver<T extends Data> extends
|
|
27
|
+
export declare class DocumentResultObserver<T extends Data> extends TransformableObserver<Result<T>, DocumentResult<T>> {
|
|
26
28
|
protected _ref: DocumentReference<T>;
|
|
27
29
|
constructor(target: Observer<DocumentResult<T>>, ref: DocumentReference<T>);
|
|
28
30
|
transform(result: Result<T>): DocumentResult<T>;
|
|
@@ -1,4 +1,6 @@
|
|
|
1
|
-
import {
|
|
1
|
+
import { TransformableObserver } from "../util/observe.js";
|
|
2
|
+
import { isData } from "../util/data.js";
|
|
3
|
+
import { getFirstItem } from "../util/array.js";
|
|
2
4
|
import { DocumentRequiredError, QueryRequiredError } from "./errors.js";
|
|
3
5
|
/** Get the data for a document from a result for that document. */
|
|
4
6
|
export function getDocumentData(result, ref) {
|
|
@@ -9,7 +11,7 @@ export function getDocumentData(result, ref) {
|
|
|
9
11
|
/** Is an unknown value a DocumentResult. */
|
|
10
12
|
export const isDocumentData = (v) => isData(v) && "id" in v && "doc" in v;
|
|
11
13
|
/** Oserver that transforms a result into a document result. */
|
|
12
|
-
export class DocumentDataObserver extends
|
|
14
|
+
export class DocumentDataObserver extends TransformableObserver {
|
|
13
15
|
constructor(target, ref) {
|
|
14
16
|
super(target);
|
|
15
17
|
this._ref = ref;
|
|
@@ -25,7 +27,7 @@ export function getDocumentResult(result, ref) {
|
|
|
25
27
|
/** Is an unknown value a DocumentResult. */
|
|
26
28
|
export const isDocumentResult = (v) => isData(v) && "id" in v && "doc" in v;
|
|
27
29
|
/** Oserver that transforms a set of entries into a results map. */
|
|
28
|
-
export class DocumentResultObserver extends
|
|
30
|
+
export class DocumentResultObserver extends TransformableObserver {
|
|
29
31
|
constructor(target, ref) {
|
|
30
32
|
super(target);
|
|
31
33
|
this._ref = ref;
|
package/error/AssertionError.js
CHANGED
package/feedback/Feedback.d.ts
CHANGED
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import { ImmutableObject } from "../util/
|
|
1
|
+
import type { ImmutableObject } from "../util/object.js";
|
|
2
2
|
/**
|
|
3
3
|
* The `Feedback` class represents a feedback message that should be shown to the user.
|
|
4
4
|
* - Basic `Feedback` is neither good nor bad, `SuccessFeedback` indicates good news, and `ErrorFeedback` indicates bad news.
|
package/feedback/Feedback.js
CHANGED
|
@@ -1,4 +1,5 @@
|
|
|
1
|
-
import { debug
|
|
1
|
+
import { debug } from "../util/debug.js";
|
|
2
|
+
import { toTitle } from "../util/string.js";
|
|
2
3
|
/**
|
|
3
4
|
* The `Feedback` class represents a feedback message that should be shown to the user.
|
|
4
5
|
* - Basic `Feedback` is neither good nor bad, `SuccessFeedback` indicates good news, and `ErrorFeedback` indicates bad news.
|
package/feedback/hydrations.d.ts
CHANGED
|
@@ -1,13 +1,3 @@
|
|
|
1
|
-
import {
|
|
2
|
-
import { SuccessFeedback } from "./SuccessFeedback.js";
|
|
3
|
-
import { WarningFeedback } from "./WarningFeedback.js";
|
|
4
|
-
import { ErrorFeedback } from "./ErrorFeedback.js";
|
|
5
|
-
import { InvalidFeedback } from "./InvalidFeedback.js";
|
|
1
|
+
import type { Hydrations } from "../util/hydrate.js";
|
|
6
2
|
/** Set of hydrations for all feedback classes. */
|
|
7
|
-
export declare const FEEDBACK_HYDRATIONS:
|
|
8
|
-
SuccessFeedback: typeof SuccessFeedback;
|
|
9
|
-
WarningFeedback: typeof WarningFeedback;
|
|
10
|
-
InvalidFeedback: typeof InvalidFeedback;
|
|
11
|
-
ErrorFeedback: typeof ErrorFeedback;
|
|
12
|
-
Feedback: typeof Feedback;
|
|
13
|
-
};
|
|
3
|
+
export declare const FEEDBACK_HYDRATIONS: Hydrations;
|
package/feedback/hydrations.js
CHANGED
|
@@ -1,5 +1,10 @@
|
|
|
1
1
|
import type { Firestore } from "firebase/firestore";
|
|
2
|
-
import {
|
|
2
|
+
import type { DocumentReference, QueryReference } from "../../db/Reference.js";
|
|
3
|
+
import type { Data, Result } from "../../util/data.js";
|
|
4
|
+
import type { Entries } from "../../util/entry.js";
|
|
5
|
+
import { AsynchronousProvider, Provider } from "../../provider/Provider.js";
|
|
6
|
+
import { DataUpdate } from "../../update/DataUpdate.js";
|
|
7
|
+
import { Observer, Unsubscriber } from "../../util/observe.js";
|
|
3
8
|
/**
|
|
4
9
|
* Firestore client database provider.
|
|
5
10
|
* - Works with the Firebase JS SDK.
|
|
@@ -1,5 +1,11 @@
|
|
|
1
1
|
import { orderBy as firestoreOrderBy, where as firestoreWhere, limit as firestoreLimit, increment as firestoreIncrement, arrayUnion as firestoreArrayUnion, arrayRemove as firestoreArrayRemove, deleteField as firestoreDeleteField, collection as firestoreCollection, doc as firestoreDocument, query as firestoreQuery, onSnapshot, addDoc, setDoc, updateDoc, deleteDoc, getDoc, getDocs, } from "firebase/firestore";
|
|
2
|
-
import {
|
|
2
|
+
import { UnsupportedError } from "../../error/UnsupportedError.js";
|
|
3
|
+
import { Provider } from "../../provider/Provider.js";
|
|
4
|
+
import { ArrayUpdate } from "../../update/ArrayUpdate.js";
|
|
5
|
+
import { DataUpdate } from "../../update/DataUpdate.js";
|
|
6
|
+
import { Increment } from "../../update/Increment.js";
|
|
7
|
+
import { ObjectUpdate } from "../../update/ObjectUpdate.js";
|
|
8
|
+
import { dispatchError, dispatchNext } from "../../util/observe.js";
|
|
3
9
|
// Constants.
|
|
4
10
|
// const ID = "__name__"; // DH: `__name__` is the entire path of the document. `__id__` is just ID.
|
|
5
11
|
const ID = "__id__"; // Internal way Firestore Queries can reference the ID of the current document.
|
|
@@ -1,5 +1,10 @@
|
|
|
1
1
|
import type { Firestore } from "firebase/firestore/lite";
|
|
2
|
-
import {
|
|
2
|
+
import type { DocumentReference, QueryReference } from "../../db/Reference.js";
|
|
3
|
+
import type { Data, Result } from "../../util/data.js";
|
|
4
|
+
import type { Entries } from "../../util/entry.js";
|
|
5
|
+
import type { Unsubscriber } from "../../util/observe.js";
|
|
6
|
+
import { AsynchronousProvider, Provider } from "../../provider/Provider.js";
|
|
7
|
+
import { DataUpdate } from "../../update/DataUpdate.js";
|
|
3
8
|
/**
|
|
4
9
|
* Firestore Lite client database provider.
|
|
5
10
|
* - Works with the Firebase JS SDK.
|
|
@@ -17,7 +22,7 @@ export declare class FirestoreClientProvider extends Provider implements Asynchr
|
|
|
17
22
|
delete<T extends Data>(ref: DocumentReference<T>): Promise<void>;
|
|
18
23
|
getQuery<T extends Data>(ref: QueryReference<T>): Promise<Entries<T>>;
|
|
19
24
|
subscribeQuery(): Unsubscriber;
|
|
20
|
-
setQuery<T extends Data>(ref: QueryReference<T>, data: T
|
|
25
|
+
setQuery<T extends Data>(ref: QueryReference<T>, data: T): Promise<number>;
|
|
21
26
|
updateQuery<T extends Data>(ref: QueryReference<T>, update: DataUpdate<T>): Promise<number>;
|
|
22
27
|
deleteQuery<T extends Data>(ref: QueryReference<T>): Promise<number>;
|
|
23
28
|
}
|
|
@@ -1,5 +1,10 @@
|
|
|
1
1
|
import { orderBy as firestoreOrderBy, where as firestoreWhere, limit as firestoreLimit, increment as firestoreIncrement, arrayUnion as firestoreArrayUnion, arrayRemove as firestoreArrayRemove, deleteField as firestoreDeleteField, collection as firestoreCollection, doc as firestoreDocument, query as firestoreQuery, setDoc, addDoc, updateDoc, deleteDoc, getDoc, getDocs, } from "firebase/firestore/lite";
|
|
2
|
-
import {
|
|
2
|
+
import { UnsupportedError } from "../../error/UnsupportedError.js";
|
|
3
|
+
import { Provider } from "../../provider/Provider.js";
|
|
4
|
+
import { ArrayUpdate } from "../../update/ArrayUpdate.js";
|
|
5
|
+
import { DataUpdate } from "../../update/DataUpdate.js";
|
|
6
|
+
import { Increment } from "../../update/Increment.js";
|
|
7
|
+
import { ObjectUpdate } from "../../update/ObjectUpdate.js";
|
|
3
8
|
// Constants.
|
|
4
9
|
// const ID = "__name__"; // DH: `__name__` is the entire path of the document. `__id__` is just ID.
|
|
5
10
|
const ID = "__id__"; // Internal way Firestore Queries can reference the ID of the current document.
|
|
@@ -1,5 +1,10 @@
|
|
|
1
1
|
import { Firestore } from "@google-cloud/firestore";
|
|
2
|
-
import {
|
|
2
|
+
import type { DocumentReference, QueryReference } from "../../db/Reference.js";
|
|
3
|
+
import type { Data, Result } from "../../util/data.js";
|
|
4
|
+
import type { Entries, Entry } from "../../util/entry.js";
|
|
5
|
+
import { AsynchronousProvider, Provider } from "../../provider/Provider.js";
|
|
6
|
+
import { DataUpdate } from "../../update/DataUpdate.js";
|
|
7
|
+
import { Observer, Unsubscriber } from "../../util/observe.js";
|
|
3
8
|
/**
|
|
4
9
|
* Firestore server database provider.
|
|
5
10
|
* - Works with the Firebase Admin SDK for Node.JS
|
|
@@ -15,7 +20,7 @@ export declare class FirestoreServerProvider extends Provider implements Asynchr
|
|
|
15
20
|
delete<T extends Data>(ref: DocumentReference<T>): Promise<void>;
|
|
16
21
|
getQuery<T extends Data>(ref: QueryReference<T>): Promise<Iterable<Entry<T>>>;
|
|
17
22
|
subscribeQuery<T extends Data>(ref: QueryReference<T>, observer: Observer<Entries<T>>): Unsubscriber;
|
|
18
|
-
setQuery<T extends Data>(ref: QueryReference<T>, data: T
|
|
23
|
+
setQuery<T extends Data>(ref: QueryReference<T>, data: T): Promise<number>;
|
|
19
24
|
updateQuery<T extends Data>(ref: QueryReference<T>, update: DataUpdate<T>): Promise<number>;
|
|
20
25
|
deleteQuery<T extends Data>(ref: QueryReference<T>): Promise<number>;
|
|
21
26
|
}
|
|
@@ -1,5 +1,11 @@
|
|
|
1
1
|
import { Firestore, FieldValue } from "@google-cloud/firestore";
|
|
2
|
-
import {
|
|
2
|
+
import { UnsupportedError } from "../../error/UnsupportedError.js";
|
|
3
|
+
import { Provider } from "../../provider/Provider.js";
|
|
4
|
+
import { ArrayUpdate } from "../../update/ArrayUpdate.js";
|
|
5
|
+
import { DataUpdate } from "../../update/DataUpdate.js";
|
|
6
|
+
import { Increment } from "../../update/Increment.js";
|
|
7
|
+
import { ObjectUpdate } from "../../update/ObjectUpdate.js";
|
|
8
|
+
import { dispatchError, dispatchNext } from "../../util/observe.js";
|
|
3
9
|
// Constants.
|
|
4
10
|
// const ID = "__name__"; // DH: `__name__` is the entire path of the document. `__id__` is just ID.
|
|
5
11
|
const ID = "__id__"; // Internal way Firestore Queries can reference the ID of the current document.
|
|
@@ -48,8 +54,8 @@ function* getResults(snapshot) {
|
|
|
48
54
|
/** Convert `Update` instances into corresponding Firestore `FieldValue` instances. */
|
|
49
55
|
function* yieldFieldValues(updates, prefix = "") {
|
|
50
56
|
for (const [key, update] of updates) {
|
|
51
|
-
if (
|
|
52
|
-
yield [`${prefix}${key}`,
|
|
57
|
+
if (update === undefined)
|
|
58
|
+
yield [`${prefix}${key}`, FieldValue.delete()];
|
|
53
59
|
else if (update instanceof Increment)
|
|
54
60
|
yield [`${prefix}${key}`, FieldValue.increment(update.amount)];
|
|
55
61
|
else if (update instanceof DataUpdate || update instanceof ObjectUpdate)
|
|
@@ -63,7 +69,7 @@ function* yieldFieldValues(updates, prefix = "") {
|
|
|
63
69
|
yield [`${prefix}${key}`, FieldValue.arrayRemove(...update.deletes)];
|
|
64
70
|
}
|
|
65
71
|
else
|
|
66
|
-
|
|
72
|
+
yield [`${prefix}${key}`, update];
|
|
67
73
|
}
|
|
68
74
|
}
|
|
69
75
|
/**
|
package/markup/render.d.ts
CHANGED
package/markup/render.js
CHANGED
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
/* eslint-disable no-param-reassign */
|
|
2
|
-
import { sanitizeLines } from "../util/
|
|
2
|
+
import { sanitizeLines } from "../util/string.js";
|
|
3
3
|
import { MARKUP_RULES } from "./rules.js";
|
|
4
4
|
/** Convert a string into an array of React nodes using a set of rules. */
|
|
5
5
|
function renderString(content, options) {
|
package/markup/rules.js
CHANGED
|
@@ -1,4 +1,5 @@
|
|
|
1
|
-
import {
|
|
1
|
+
import { getBlockRegExp, getLineRegExp, getWrapRegExp, MATCH_BLOCK, MATCH_LINE } from "../util/search.js";
|
|
2
|
+
import { formatUrl, toURL } from "../util/url.js";
|
|
2
3
|
// Regular expression partials (`\` slashes must be escaped as `\\`).
|
|
3
4
|
const BULLETS = "-*•+"; // Anything that can be a bullet (used for unordered lists and horizontal rules).
|
|
4
5
|
// Regular expressions.
|
package/markup/types.d.ts
CHANGED
package/package.json
CHANGED
|
@@ -11,7 +11,7 @@
|
|
|
11
11
|
"state-management",
|
|
12
12
|
"query-builder"
|
|
13
13
|
],
|
|
14
|
-
"version": "1.
|
|
14
|
+
"version": "1.62.1",
|
|
15
15
|
"repository": "https://github.com/dhoulb/shelving",
|
|
16
16
|
"author": "Dave Houlbrooke <dave@shax.com>",
|
|
17
17
|
"license": "0BSD",
|
|
@@ -47,10 +47,11 @@
|
|
|
47
47
|
"fix": "npm run fix:prettier && npm run fix:eslint",
|
|
48
48
|
"fix:prettier": "prettier --write './**/*.{md,json}'",
|
|
49
49
|
"fix:eslint": "eslint --cache --fix './**/*.{ts,tsx}'",
|
|
50
|
-
"test": "npm run test:prettier && npm run test:eslint && npm run test:typescript && npm run test:jest",
|
|
50
|
+
"test": "npm run test:prettier && npm run test:eslint && npm run test:dpdm && npm run test:typescript && npm run test:jest",
|
|
51
51
|
"test:prettier": "prettier --check './**/*.{md,json}'",
|
|
52
52
|
"test:eslint": "eslint --cache './**/*.{ts,tsx}'",
|
|
53
53
|
"test:typescript": "tsc --noEmit",
|
|
54
|
+
"test:dpdm": "dpdm ./modules/index.ts --transform",
|
|
54
55
|
"test:jest": "jest",
|
|
55
56
|
"test:jest:watch": "jest --watchAll",
|
|
56
57
|
"build": "npm run build:typescript && npm run build:copy && npm run build:jest",
|
|
@@ -61,21 +62,22 @@
|
|
|
61
62
|
"devDependencies": {
|
|
62
63
|
"@google-cloud/firestore": "^5.0.2",
|
|
63
64
|
"@types/jest": "^27.5.1",
|
|
64
|
-
"@types/react": "^
|
|
65
|
-
"@types/react-dom": "^
|
|
65
|
+
"@types/react": "^18.0.9",
|
|
66
|
+
"@types/react-dom": "^18.0.4",
|
|
66
67
|
"@typescript-eslint/eslint-plugin": "^5.23.0",
|
|
67
68
|
"@typescript-eslint/parser": "^5.23.0",
|
|
69
|
+
"dpdm": "^3.9.0",
|
|
68
70
|
"eslint": "^8.15.0",
|
|
69
71
|
"eslint-config-prettier": "^8.5.0",
|
|
70
72
|
"eslint-plugin-import": "^2.26.0",
|
|
71
73
|
"eslint-plugin-prettier": "^4.0.0",
|
|
72
74
|
"firebase": "^9.8.1",
|
|
73
|
-
"jest": "^
|
|
75
|
+
"jest": "^28.1.0",
|
|
74
76
|
"jest-ts-webcompat-resolver": "^1.0.0",
|
|
75
77
|
"prettier": "^2.6.2",
|
|
76
|
-
"react": "^
|
|
77
|
-
"react-dom": "^
|
|
78
|
-
"ts-jest": "^
|
|
78
|
+
"react": "^18.1.0",
|
|
79
|
+
"react-dom": "^18.1.0",
|
|
80
|
+
"ts-jest": "^28.0.2",
|
|
79
81
|
"typescript": "^4.6.4"
|
|
80
82
|
},
|
|
81
83
|
"peerDependencies": {
|
|
@@ -1,5 +1,8 @@
|
|
|
1
|
-
import { MutableObject
|
|
2
|
-
import type {
|
|
1
|
+
import type { MutableObject } from "../util/object.js";
|
|
2
|
+
import type { Entries } from "../util/entry.js";
|
|
3
|
+
import type { DocumentReference, QueryReference } from "../db/Reference.js";
|
|
4
|
+
import { Observable, Observer, Unsubscriber } from "../util/observe.js";
|
|
5
|
+
import { Data, Result, Results } from "../util/data.js";
|
|
3
6
|
import { ThroughProvider } from "./ThroughProvider.js";
|
|
4
7
|
/**
|
|
5
8
|
* Provider that batches multiple database reads from a source provider together, for efficiency.
|
|
@@ -1,5 +1,7 @@
|
|
|
1
|
-
import {
|
|
2
|
-
import {
|
|
1
|
+
import { awaitNext, ResultsObserver } from "../util/observe.js";
|
|
2
|
+
import { getMap } from "../util/map.js";
|
|
3
|
+
import { isAsync } from "../util/async.js";
|
|
4
|
+
import { LazyState } from "../stream/LazyState.js";
|
|
3
5
|
import { ThroughProvider } from "./ThroughProvider.js";
|
|
4
6
|
/** How long to wait after all subscriptions have ended to close the source subscription. */
|
|
5
7
|
const STOP_DELAY = 2000;
|
|
@@ -1,6 +1,8 @@
|
|
|
1
|
-
import type { DocumentReference, QueryReference } from "../db/
|
|
2
|
-
import {
|
|
3
|
-
import {
|
|
1
|
+
import type { DocumentReference, QueryReference } from "../db/Reference.js";
|
|
2
|
+
import type { Data, Result } from "../util/data.js";
|
|
3
|
+
import { Observer, Unsubscriber } from "../util/observe.js";
|
|
4
|
+
import { DataUpdate } from "../update/DataUpdate.js";
|
|
5
|
+
import { Entries } from "../util/entry.js";
|
|
4
6
|
import type { Provider, AsynchronousProvider } from "./Provider.js";
|
|
5
7
|
import { MemoryProvider } from "./MemoryProvider.js";
|
|
6
8
|
import { ThroughProvider } from "./ThroughProvider.js";
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import { TransformObserver } from "../util/
|
|
1
|
+
import { TransformObserver } from "../util/observe.js";
|
|
2
2
|
import { MemoryProvider } from "./MemoryProvider.js";
|
|
3
3
|
import { ThroughProvider } from "./ThroughProvider.js";
|
|
4
4
|
/** Keep a copy of received data in a local cache. */
|
|
@@ -1,6 +1,8 @@
|
|
|
1
|
-
import {
|
|
2
|
-
import {
|
|
3
|
-
import {
|
|
1
|
+
import type { Data, Result } from "../util/data.js";
|
|
2
|
+
import type { Entries } from "../util/entry.js";
|
|
3
|
+
import type { DocumentReference, QueryReference } from "../db/Reference.js";
|
|
4
|
+
import type { DataUpdate } from "../update/DataUpdate.js";
|
|
5
|
+
import { Observer, Unsubscriber } from "../util/observe.js";
|
|
4
6
|
import { ThroughProvider } from "./ThroughProvider.js";
|
|
5
7
|
/** Provider that wraps errors thrown from deeper providers in `DatabaseReadError` and `DatabaseWriteError` etc to make it easier to see what read/write caused the error. */
|
|
6
8
|
export declare class ErrorProvider extends ThroughProvider {
|
|
@@ -1,4 +1,5 @@
|
|
|
1
|
-
import {
|
|
1
|
+
import { ThroughObserver } from "../util/observe.js";
|
|
2
|
+
import { isAsync } from "../util/async.js";
|
|
2
3
|
import { ThroughProvider } from "./ThroughProvider.js";
|
|
3
4
|
/** Provider that wraps errors thrown from deeper providers in `DatabaseReadError` and `DatabaseWriteError` etc to make it easier to see what read/write caused the error. */
|
|
4
5
|
export class ErrorProvider extends ThroughProvider {
|