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.
Files changed (176) hide show
  1. package/api/Resource.d.ts +1 -1
  2. package/api/Resource.js +4 -3
  3. package/api/errors.d.ts +2 -2
  4. package/api/errors.js +1 -1
  5. package/db/Database.d.ts +4 -2
  6. package/db/Database.js +2 -1
  7. package/db/Operation.d.ts +7 -9
  8. package/db/Operation.js +3 -3
  9. package/db/PaginationState.d.ts +4 -2
  10. package/db/PaginationState.js +9 -4
  11. package/db/Reference.d.ts +12 -4
  12. package/db/Reference.js +13 -5
  13. package/db/errors.d.ts +4 -3
  14. package/db/errors.js +2 -1
  15. package/db/index.d.ts +1 -1
  16. package/db/index.js +1 -1
  17. package/db/{helpers.d.ts → util.d.ts} +5 -3
  18. package/db/{helpers.js → util.js} +5 -3
  19. package/error/AssertionError.js +1 -1
  20. package/error/ValidationError.d.ts +1 -1
  21. package/feedback/Feedback.d.ts +1 -1
  22. package/feedback/Feedback.js +2 -1
  23. package/feedback/hydrations.d.ts +2 -12
  24. package/feedback/hydrations.js +0 -1
  25. package/firestore/client/FirestoreClientProvider.d.ts +6 -1
  26. package/firestore/client/FirestoreClientProvider.js +7 -1
  27. package/firestore/lite/FirestoreLiteProvider.d.ts +7 -2
  28. package/firestore/lite/FirestoreLiteProvider.js +6 -1
  29. package/firestore/server/FirestoreServerProvider.d.ts +7 -2
  30. package/firestore/server/FirestoreServerProvider.js +10 -4
  31. package/markup/render.d.ts +1 -1
  32. package/markup/render.js +1 -1
  33. package/markup/rules.js +2 -1
  34. package/markup/types.d.ts +1 -1
  35. package/package.json +10 -8
  36. package/provider/BatchProvider.d.ts +5 -2
  37. package/provider/BatchProvider.js +4 -2
  38. package/provider/CacheProvider.d.ts +5 -3
  39. package/provider/CacheProvider.js +1 -1
  40. package/provider/ErrorProvider.d.ts +5 -3
  41. package/provider/ErrorProvider.js +2 -1
  42. package/provider/MemoryProvider.d.ts +5 -3
  43. package/provider/MemoryProvider.js +4 -2
  44. package/provider/Provider.d.ts +5 -3
  45. package/provider/ThroughProvider.d.ts +6 -3
  46. package/provider/ThroughProvider.js +1 -1
  47. package/provider/ValidationProvider.d.ts +5 -3
  48. package/provider/ValidationProvider.js +4 -2
  49. package/query/Filter.d.ts +23 -2
  50. package/query/Filter.js +2 -2
  51. package/query/Filters.d.ts +20 -3
  52. package/query/Filters.js +1 -1
  53. package/query/Query.d.ts +29 -4
  54. package/query/Query.js +3 -2
  55. package/query/Rule.d.ts +3 -1
  56. package/query/Rules.d.ts +2 -1
  57. package/query/Rules.js +1 -1
  58. package/query/Sort.d.ts +10 -2
  59. package/query/Sort.js +2 -2
  60. package/query/Sorts.d.ts +12 -3
  61. package/query/Sorts.js +2 -2
  62. package/query/index.d.ts +1 -2
  63. package/query/index.js +1 -2
  64. package/query/{helpers.d.ts → util.d.ts} +2 -2
  65. package/query/{helpers.js → util.js} +1 -1
  66. package/react/useCompare.d.ts +1 -1
  67. package/react/useDocument.d.ts +5 -3
  68. package/react/useDocument.js +7 -3
  69. package/react/useFetch.d.ts +2 -1
  70. package/react/useFetch.js +3 -1
  71. package/react/useInstance.d.ts +1 -1
  72. package/react/useInstance.js +1 -1
  73. package/react/useLazy.d.ts +1 -1
  74. package/react/useLazy.js +2 -1
  75. package/react/usePagination.d.ts +3 -1
  76. package/react/usePagination.js +4 -2
  77. package/react/usePureEffect.d.ts +2 -1
  78. package/react/usePureState.d.ts +1 -1
  79. package/react/usePureState.js +2 -1
  80. package/react/useQuery.d.ts +3 -1
  81. package/react/useQuery.js +9 -3
  82. package/react/useReduce.d.ts +1 -1
  83. package/react/useState.d.ts +10 -2
  84. package/react/useState.js +7 -2
  85. package/react/useSubscribe.d.ts +1 -1
  86. package/react/useSubscribe.js +3 -2
  87. package/schema/AllowSchema.js +5 -2
  88. package/schema/ArraySchema.d.ts +2 -1
  89. package/schema/ArraySchema.js +3 -2
  90. package/schema/DataSchema.d.ts +3 -2
  91. package/schema/DataSchema.js +4 -3
  92. package/schema/DateSchema.d.ts +1 -1
  93. package/schema/DateSchema.js +2 -2
  94. package/schema/LinkSchema.js +2 -2
  95. package/schema/MapSchema.d.ts +2 -1
  96. package/schema/MapSchema.js +3 -2
  97. package/schema/NumberSchema.js +2 -2
  98. package/schema/ObjectSchema.d.ts +2 -1
  99. package/schema/ObjectSchema.js +3 -2
  100. package/schema/RequiredSchema.js +1 -1
  101. package/schema/Schema.d.ts +1 -1
  102. package/schema/SlugSchema.js +1 -1
  103. package/schema/StringSchema.js +2 -2
  104. package/schema/ThroughSchema.d.ts +1 -1
  105. package/schema/ThroughSchema.js +1 -1
  106. package/stream/ArrayState.d.ts +1 -1
  107. package/stream/ArrayState.js +1 -1
  108. package/stream/DataState.d.ts +2 -1
  109. package/stream/DataState.js +5 -2
  110. package/stream/LastStream.js +2 -1
  111. package/stream/LazyState.d.ts +1 -1
  112. package/stream/LazyState.js +1 -1
  113. package/stream/LazyStream.d.ts +1 -1
  114. package/stream/ObjectState.d.ts +2 -1
  115. package/stream/ObjectState.js +1 -1
  116. package/stream/State.d.ts +5 -3
  117. package/stream/State.js +7 -5
  118. package/stream/Stream.d.ts +4 -1
  119. package/stream/Stream.js +3 -2
  120. package/test/basics.d.ts +3 -3
  121. package/test/basics.js +5 -1
  122. package/test/people.d.ts +1 -1
  123. package/test/people.js +3 -1
  124. package/test/util.d.ts +1 -1
  125. package/test/util.js +1 -1
  126. package/update/ArrayUpdate.d.ts +1 -1
  127. package/update/ArrayUpdate.js +1 -1
  128. package/update/DataUpdate.d.ts +3 -1
  129. package/update/DataUpdate.js +2 -1
  130. package/update/ObjectUpdate.d.ts +6 -3
  131. package/update/ObjectUpdate.js +3 -1
  132. package/update/Update.d.ts +1 -1
  133. package/update/hydrations.d.ts +2 -10
  134. package/update/hydrations.js +0 -1
  135. package/update/util.d.ts +4 -2
  136. package/update/util.js +5 -2
  137. package/util/array.d.ts +10 -2
  138. package/util/array.js +12 -4
  139. package/util/assert.d.ts +2 -51
  140. package/util/assert.js +7 -106
  141. package/util/async.d.ts +11 -3
  142. package/util/async.js +20 -2
  143. package/util/boolean.d.ts +10 -0
  144. package/util/boolean.js +26 -0
  145. package/util/class.d.ts +5 -1
  146. package/util/class.js +10 -1
  147. package/util/color.js +1 -1
  148. package/util/data.js +1 -1
  149. package/util/date.d.ts +2 -39
  150. package/util/date.js +7 -69
  151. package/util/function.d.ts +2 -0
  152. package/util/function.js +6 -0
  153. package/util/hydrate.js +1 -1
  154. package/util/index.d.ts +1 -1
  155. package/util/index.js +1 -1
  156. package/util/iterate.js +2 -2
  157. package/util/null.d.ts +10 -7
  158. package/util/null.js +21 -6
  159. package/util/number.d.ts +8 -0
  160. package/util/number.js +22 -3
  161. package/util/object.d.ts +8 -0
  162. package/util/object.js +17 -1
  163. package/util/{observable.d.ts → observe.d.ts} +12 -12
  164. package/util/{observable.js → observe.js} +20 -29
  165. package/util/serialise.js +1 -1
  166. package/util/string.d.ts +2 -2
  167. package/util/string.js +6 -2
  168. package/util/undefined.d.ts +5 -6
  169. package/util/undefined.js +10 -5
  170. package/util/units.d.ts +45 -0
  171. package/util/units.js +73 -2
  172. package/util/url.d.ts +2 -0
  173. package/util/url.js +7 -3
  174. package/util/validate.js +2 -1
  175. package/query/types.d.ts +0 -74
  176. package/query/types.js +0 -1
package/api/Resource.d.ts CHANGED
@@ -1,4 +1,4 @@
1
- import { Validator, Validatable } from "../util/index.js";
1
+ import { Validator, Validatable } from "../util/validate.js";
2
2
  /**
3
3
  * An abstract API resource definition, used to specify types for e.g. serverless functions..
4
4
  *
package/api/Resource.js CHANGED
@@ -1,5 +1,6 @@
1
- import { UNDEFINED, validate } from "../util/index.js";
2
- import { Feedback } from "../feedback/index.js";
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 = UNDEFINED, result = UNDEFINED) {
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/index.js";
2
- import { ValidationError } from "../error/index.js";
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
@@ -1,4 +1,4 @@
1
- import { ValidationError } from "../error/index.js";
1
+ import { ValidationError } from "../error/ValidationError.js";
2
2
  /** Thrown if an API `Resource` can't validate. */
3
3
  export class ResourceValidationError extends ValidationError {
4
4
  constructor(resource, feedback) {
package/db/Database.d.ts CHANGED
@@ -1,6 +1,8 @@
1
- import { Key, Datas, Validators, ValidatorType } from "../util/index.js";
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 { FilterProps, SortKeys } from "../query/index.js";
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
@@ -1,4 +1,5 @@
1
- import { Filters, Sorts } from "../query/index.js";
1
+ import { Filters } from "../query/Filters.js";
2
+ import { Sorts } from "../query/Sorts.js";
2
3
  import { DocumentReference, QueryReference } from "./Reference.js";
3
4
  /**
4
5
  * Combines a database model and a provider.
package/db/Operation.d.ts CHANGED
@@ -1,5 +1,9 @@
1
- import { PropUpdates, Update } from "../update/index.js";
2
- import { ImmutableArray, Nullish, Data, Key } from "../util/index.js";
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, notNullish, isNullish } from "../util/index.js";
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: Operations,
124
+ Operations,
124
125
  AddOperation,
125
126
  SetOperation,
126
127
  UpdateOperation,
127
128
  DeleteOperation,
128
129
  };
129
- OPERATION_HYDRATIONS;
@@ -1,5 +1,7 @@
1
- import { Results, Entry, Entries, Data } from "../util/index.js";
2
- import { BooleanState, State } from "../stream/index.js";
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.
@@ -1,6 +1,11 @@
1
- import { getLastItem, assertNumber, yieldMerged, getMap, LOADING, assertMax } from "../util/index.js";
2
- import { BooleanState, State } from "../stream/index.js";
3
- import { ConditionError } from "../index.js";
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 === LOADING;
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 { Entry, Observable, Observer, Result, Unsubscriber, Results, Validatable, Validator, Data, Entries, Dispatcher } from "../util/index.js";
2
- import { DataUpdate, PropUpdates } from "../update/index.js";
3
- import { Filters, Sorts, Query, FilterProps, SortKeys } from "../query/index.js";
4
- import { DocumentData, DocumentResult } from "./helpers.js";
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 { callAsync, throwAsync, validate, getMap, countItems, hasItems, ResultsObserver } from "../util/index.js";
2
- import { DataUpdate } from "../update/index.js";
3
- import { Feedback, InvalidFeedback } from "../feedback/index.js";
4
- import { Filters, Sorts, Query, Filter } from "../query/index.js";
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 "./helpers.js";
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/index.js";
2
- import { RequiredError, ValidationError } from "../error/index.js";
3
- import type { Feedback } from "../feedback/index.js";
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 { RequiredError, ValidationError } from "../error/index.js";
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
@@ -2,5 +2,5 @@ export * from "./Database.js";
2
2
  export * from "./Reference.js";
3
3
  export * from "./Operation.js";
4
4
  export * from "./PaginationState.js";
5
- export * from "./helpers.js";
5
+ export * from "./util.js";
6
6
  export * from "./errors.js";
package/db/index.js CHANGED
@@ -2,5 +2,5 @@ export * from "./Database.js";
2
2
  export * from "./Reference.js";
3
3
  export * from "./Operation.js";
4
4
  export * from "./PaginationState.js";
5
- export * from "./helpers.js";
5
+ export * from "./util.js";
6
6
  export * from "./errors.js";
@@ -1,4 +1,6 @@
1
- import { Data, Result, TransformerObserver, Observer, Entries } from "../util/index.js";
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 TransformerObserver<Result<T>, DocumentData<T>> {
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 TransformerObserver<Result<T>, DocumentResult<T>> {
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 { TransformerObserver, isData, getFirstItem } from "../util/index.js";
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 TransformerObserver {
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 TransformerObserver {
30
+ export class DocumentResultObserver extends TransformableObserver {
29
31
  constructor(target, ref) {
30
32
  super(target);
31
33
  this._ref = ref;
@@ -1,4 +1,4 @@
1
- import { debug } from "../util/index.js";
1
+ import { debug } from "../util/debug.js";
2
2
  /**
3
3
  * Thrown if the program receives a value it didn't expect.
4
4
  *
@@ -1,4 +1,4 @@
1
- import type { Feedback } from "../feedback/index.js";
1
+ import type { Feedback } from "../feedback/Feedback.js";
2
2
  /** Thrown if a value isn't valid. */
3
3
  export declare class ValidationError extends Error {
4
4
  readonly feedback: Feedback;
@@ -1,4 +1,4 @@
1
- import { ImmutableObject } from "../util/index.js";
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.
@@ -1,4 +1,5 @@
1
- import { debug, toTitle } from "../util/index.js";
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.
@@ -1,13 +1,3 @@
1
- import { Feedback } from "./Feedback.js";
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;
@@ -11,4 +11,3 @@ export const FEEDBACK_HYDRATIONS = {
11
11
  ErrorFeedback,
12
12
  Feedback,
13
13
  };
14
- FEEDBACK_HYDRATIONS;
@@ -1,5 +1,10 @@
1
1
  import type { Firestore } from "firebase/firestore";
2
- import { Entries, Provider, DocumentReference, QueryReference, Result, Observer, AsynchronousProvider, DataUpdate, Data, Unsubscriber } from "../../index.js";
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 { Provider, dispatchNext, dispatchError, ObjectUpdate, Increment, DataUpdate, ArrayUpdate, UnsupportedError, } from "../../index.js";
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 { Provider, DocumentReference, QueryReference, Result, Update, AsynchronousProvider, Data, DataUpdate, Entries, Unsubscriber } from "../../index.js";
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 | Update<T> | undefined): Promise<number>;
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 { Provider, ObjectUpdate, Increment, DataUpdate, ArrayUpdate, UnsupportedError, } from "../../index.js";
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 { Provider, DocumentReference, QueryReference, Observer, Result, Update, Data, AsynchronousProvider, DataUpdate, Entry, Entries, Unsubscriber } from "../../index.js";
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 | Update<T> | undefined): Promise<number>;
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 { Provider, dispatchNext, dispatchError, Update, Increment, DataUpdate, AssertionError, ArrayUpdate, UnsupportedError, ObjectUpdate, } from "../../index.js";
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 (!(update instanceof Update))
52
- yield [`${prefix}${key}`, update !== undefined ? update : FieldValue.delete()];
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
- throw new AssertionError("Unsupported transform", update);
72
+ yield [`${prefix}${key}`, update];
67
73
  }
68
74
  }
69
75
  /**
@@ -1,4 +1,4 @@
1
- import { JSXNode } from "../util/index.js";
1
+ import type { JSXNode } from "../util/jsx.js";
2
2
  import type { MarkupOptions } from "./types.js";
3
3
  /**
4
4
  * Parse a text string as Markdownish syntax and render it as a JSX node.
package/markup/render.js CHANGED
@@ -1,5 +1,5 @@
1
1
  /* eslint-disable no-param-reassign */
2
- import { sanitizeLines } from "../util/index.js";
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 { formatUrl, toURL, getLineRegExp, getBlockRegExp, MATCH_LINE, MATCH_BLOCK, getWrapRegExp } from "../util/index.js";
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
@@ -1,4 +1,4 @@
1
- import { JSXElement } from "../util/index.js";
1
+ import type { JSXElement } from "../util/jsx.js";
2
2
  /** A single markup parsing rule. */
3
3
  export declare type MarkupRule = {
4
4
  /** RegExp for matching this rule. */
package/package.json CHANGED
@@ -11,7 +11,7 @@
11
11
  "state-management",
12
12
  "query-builder"
13
13
  ],
14
- "version": "1.61.0",
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": "^17.0.45",
65
- "@types/react-dom": "^17.0.17",
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": "^27.5.1",
75
+ "jest": "^28.1.0",
74
76
  "jest-ts-webcompat-resolver": "^1.0.0",
75
77
  "prettier": "^2.6.2",
76
- "react": "^17.0.2",
77
- "react-dom": "^17.0.2",
78
- "ts-jest": "^27.1.4",
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, Result, Observer, Unsubscriber, Observable, Entries, Results, Data } from "../util/index.js";
2
- import type { DocumentReference, QueryReference } from "../db/index.js";
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 { isAsync, getMap, awaitNext, ResultsObserver } from "../util/index.js";
2
- import { LazyState } from "../stream/index.js";
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/index.js";
2
- import { DataUpdate } from "../update/index.js";
3
- import { Result, Unsubscriber, Observer, Entries, Data } from "../util/index.js";
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/index.js";
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 { DocumentReference, QueryReference } from "../db/index.js";
2
- import { Data, Result, Entries, Observer, Unsubscriber } from "../util/index.js";
3
- import { DataUpdate } from "../update/index.js";
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 { isAsync, ThroughObserver } from "../util/index.js";
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 {