shelving 1.91.0 → 1.91.2

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 (130) hide show
  1. package/api/Resource.d.ts +1 -1
  2. package/api/Resource.js +6 -4
  3. package/constraint/Constraints.d.ts +1 -1
  4. package/constraint/Constraints.js +1 -1
  5. package/constraint/Filter.d.ts +4 -4
  6. package/constraint/Filter.js +5 -3
  7. package/constraint/Filters.d.ts +3 -2
  8. package/constraint/Filters.js +3 -3
  9. package/constraint/Sort.d.ts +3 -3
  10. package/constraint/Sort.js +3 -1
  11. package/constraint/Sorts.d.ts +4 -3
  12. package/constraint/Statement.d.ts +4 -2
  13. package/constraint/Statement.js +4 -4
  14. package/db/Change.d.ts +4 -4
  15. package/db/Collection.d.ts +5 -4
  16. package/db/Database.d.ts +7 -7
  17. package/db/Database.js +3 -3
  18. package/db/Item.d.ts +5 -5
  19. package/db/Item.js +1 -1
  20. package/db/ItemState.d.ts +3 -3
  21. package/db/ItemState.js +4 -4
  22. package/db/Query.d.ts +5 -5
  23. package/db/Query.js +2 -2
  24. package/db/QueryState.d.ts +3 -3
  25. package/db/QueryState.js +4 -4
  26. package/feedback/Feedback.d.ts +0 -4
  27. package/feedback/Feedback.js +0 -4
  28. package/feedback/Feedbacks.d.ts +2 -4
  29. package/feedback/Feedbacks.js +6 -5
  30. package/firestore/client/FirestoreClientProvider.d.ts +4 -4
  31. package/firestore/client/FirestoreClientProvider.js +7 -2
  32. package/firestore/lite/FirestoreLiteProvider.d.ts +4 -4
  33. package/firestore/lite/FirestoreLiteProvider.js +7 -2
  34. package/firestore/server/FirestoreServerProvider.d.ts +4 -4
  35. package/firestore/server/FirestoreServerProvider.js +7 -2
  36. package/markup/regexp.d.ts +2 -2
  37. package/markup/render.d.ts +1 -1
  38. package/markup/rule.d.ts +5 -5
  39. package/markup/rules.d.ts +3 -2
  40. package/markup/rules.js +1 -1
  41. package/package.json +3 -4
  42. package/provider/CacheProvider.d.ts +3 -3
  43. package/provider/DebugProvider.d.ts +3 -3
  44. package/provider/MemoryProvider.d.ts +3 -3
  45. package/provider/MemoryProvider.js +3 -3
  46. package/provider/Provider.d.ts +1 -1
  47. package/provider/ThroughProvider.d.ts +3 -3
  48. package/provider/ValidationProvider.d.ts +5 -5
  49. package/provider/ValidationProvider.js +4 -4
  50. package/react/createCache.js +1 -1
  51. package/react/useData.d.ts +1 -1
  52. package/react/useData.js +3 -3
  53. package/react/useLazy.d.ts +1 -1
  54. package/react/useState.d.ts +1 -1
  55. package/schema/AllowSchema.d.ts +3 -2
  56. package/schema/AllowSchema.js +2 -2
  57. package/schema/ArraySchema.d.ts +4 -3
  58. package/schema/ArraySchema.js +1 -1
  59. package/schema/BooleanSchema.d.ts +2 -1
  60. package/schema/DataSchema.d.ts +4 -3
  61. package/schema/DataSchema.js +1 -1
  62. package/schema/DateSchema.d.ts +3 -2
  63. package/schema/DateSchema.js +2 -2
  64. package/schema/DictionarySchema.d.ts +4 -3
  65. package/schema/DictionarySchema.js +1 -1
  66. package/schema/KeySchema.js +1 -1
  67. package/schema/LinkSchema.d.ts +2 -1
  68. package/schema/NumberSchema.d.ts +2 -1
  69. package/schema/NumberSchema.js +2 -2
  70. package/schema/OptionalSchema.d.ts +1 -1
  71. package/schema/PhoneSchema.js +1 -1
  72. package/schema/RequiredSchema.d.ts +1 -1
  73. package/schema/StringSchema.d.ts +2 -1
  74. package/schema/StringSchema.js +1 -1
  75. package/schema/ThroughSchema.d.ts +2 -1
  76. package/schema/TimeSchema.d.ts +4 -2
  77. package/schema/TimeSchema.js +1 -1
  78. package/state/ArrayState.d.ts +1 -1
  79. package/state/ArrayState.js +1 -1
  80. package/state/DataState.d.ts +2 -2
  81. package/state/DataState.js +1 -1
  82. package/state/DictionaryState.d.ts +2 -2
  83. package/state/DictionaryState.js +1 -1
  84. package/state/State.d.ts +1 -1
  85. package/state/State.js +1 -1
  86. package/test/basics.d.ts +1 -1
  87. package/test/basics.js +1 -1
  88. package/test/people.d.ts +1 -1
  89. package/test/util.d.ts +2 -2
  90. package/update/ArrayUpdate.d.ts +1 -1
  91. package/update/ArrayUpdate.js +1 -1
  92. package/update/DataUpdate.d.ts +3 -3
  93. package/update/DictionaryUpdate.d.ts +3 -3
  94. package/update/DictionaryUpdate.js +3 -3
  95. package/update/hydrations.d.ts +1 -1
  96. package/update/hydrations.js +3 -3
  97. package/util/activity.d.ts +1 -1
  98. package/util/array.d.ts +0 -4
  99. package/util/array.js +1 -8
  100. package/util/async.d.ts +1 -1
  101. package/util/class.d.ts +1 -1
  102. package/util/class.js +1 -1
  103. package/util/diff.d.ts +2 -2
  104. package/util/duration.d.ts +1 -1
  105. package/util/duration.js +1 -1
  106. package/util/entry.d.ts +3 -3
  107. package/util/equal.d.ts +3 -3
  108. package/util/equal.js +1 -1
  109. package/util/hydrate.d.ts +2 -2
  110. package/util/hydrate.js +1 -1
  111. package/util/iterate.d.ts +0 -4
  112. package/util/iterate.js +5 -7
  113. package/util/lazy.d.ts +1 -1
  114. package/util/map.d.ts +1 -1
  115. package/util/match.d.ts +6 -1
  116. package/util/match.js +13 -0
  117. package/util/merge.d.ts +2 -2
  118. package/util/object.d.ts +1 -1
  119. package/util/regexp.d.ts +2 -2
  120. package/util/sequence.d.ts +1 -1
  121. package/util/sort.d.ts +1 -1
  122. package/util/string.d.ts +1 -1
  123. package/util/string.js +2 -2
  124. package/util/template.d.ts +1 -1
  125. package/util/template.js +2 -2
  126. package/util/transform.d.ts +3 -3
  127. package/util/units.d.ts +4 -3
  128. package/util/units.js +2 -2
  129. package/util/validate.d.ts +3 -3
  130. package/util/validate.js +7 -7
package/package.json CHANGED
@@ -11,7 +11,7 @@
11
11
  "state-management",
12
12
  "query-builder"
13
13
  ],
14
- "version": "1.91.0",
14
+ "version": "1.91.2",
15
15
  "repository": "https://github.com/dhoulb/shelving",
16
16
  "author": "Dave Houlbrooke <dave@shax.com>",
17
17
  "license": "0BSD",
@@ -49,11 +49,10 @@
49
49
  "fix": "npm run fix:prettier && npm run fix:eslint",
50
50
  "fix:prettier": "prettier --write './**/*.{md,json}'",
51
51
  "fix:eslint": "eslint --cache --fix './**/*.{ts,tsx}'",
52
- "test": "npm run test:prettier && npm run test:eslint && npm run test:dpdm && npm run test:typescript && npm run test:jest",
52
+ "test": "npm run test:prettier && npm run test:eslint && npm run test:typescript && npm run test:jest",
53
53
  "test:prettier": "prettier --check './**/*.{md,json}'",
54
54
  "test:eslint": "eslint --cache './**/*.{ts,tsx}'",
55
55
  "test:typescript": "tsc --noEmit",
56
- "test:dpdm": "dpdm ./modules/index.ts --transform --tree=false --warning=false --exit-code circular:1",
57
56
  "test:jest": "jest --detectOpenHandles",
58
57
  "test:jest:watch": "jest --watchAll",
59
58
  "build": "npm run build:setup && npm run build:copy && npm run build:typescript && npm run build:check && npm run build:jest",
@@ -70,11 +69,11 @@
70
69
  "@types/react-dom": "^18.0.10",
71
70
  "@typescript-eslint/eslint-plugin": "^5.49.0",
72
71
  "@typescript-eslint/parser": "^5.49.0",
73
- "dpdm": "^3.11.0",
74
72
  "esbuild": "^0.17.12",
75
73
  "esbuild-jest": "^0.5.0",
76
74
  "eslint": "^8.33.0",
77
75
  "eslint-config-prettier": "^8.6.0",
76
+ "eslint-import-resolver-typescript": "^3.5.5",
78
77
  "eslint-plugin-import": "^2.27.5",
79
78
  "eslint-plugin-prettier": "^4.0.0",
80
79
  "firebase": "^9.16.0",
@@ -1,8 +1,8 @@
1
- import type { Data } from "../util/data.js";
2
- import type { ItemArray, ItemValue, ItemStatement } from "../db/Item.js";
3
- import type { Updates } from "../update/DataUpdate.js";
4
1
  import type { AsyncProvider } from "./Provider.js";
5
2
  import type { AsyncThroughProvider } from "./ThroughProvider.js";
3
+ import type { ItemArray, ItemStatement, ItemValue } from "../db/Item.js";
4
+ import type { Updates } from "../update/DataUpdate.js";
5
+ import type { Data } from "../util/data.js";
6
6
  import { MemoryProvider } from "./MemoryProvider.js";
7
7
  /** Keep a copy of asynchronous remote data in a local synchronous cache. */
8
8
  export declare class CacheProvider implements AsyncThroughProvider {
@@ -1,8 +1,8 @@
1
- import type { Data } from "../util/data.js";
1
+ import type { AsyncProvider, Provider } from "./Provider.js";
2
+ import type { AsyncThroughProvider, ThroughProvider } from "./ThroughProvider.js";
2
3
  import type { ItemArray, ItemStatement, ItemValue } from "../db/Item.js";
3
4
  import type { Updates } from "../update/DataUpdate.js";
4
- import { Provider, AsyncProvider } from "./Provider.js";
5
- import type { ThroughProvider, AsyncThroughProvider } from "./ThroughProvider.js";
5
+ import type { Data } from "../util/data.js";
6
6
  /** Provider that logs operations to a source provider to the console. */
7
7
  declare abstract class AbstractDebugProvider {
8
8
  abstract readonly source: Provider | AsyncProvider;
@@ -1,8 +1,8 @@
1
- import type { Data } from "../util/data.js";
2
- import type { ItemArray, ItemValue, ItemData, ItemStatement } from "../db/Item.js";
1
+ import type { Provider } from "./Provider.js";
2
+ import type { ItemArray, ItemData, ItemStatement, ItemValue } from "../db/Item.js";
3
3
  import type { Updates } from "../update/DataUpdate.js";
4
+ import type { Data } from "../util/data.js";
4
5
  import { DeferredSequence } from "../sequence/DeferredSequence.js";
5
- import type { Provider } from "./Provider.js";
6
6
  /**
7
7
  * Fast in-memory store for data.
8
8
  * - Extremely fast (ideal for caching!), but does not persist data after the browser window is closed.
@@ -1,10 +1,10 @@
1
1
  import { Statement } from "../constraint/Statement.js";
2
- import { getRandomKey } from "../util/random.js";
3
- import { isArrayEqual } from "../util/equal.js";
4
2
  import { RequiredError } from "../error/RequiredError.js";
3
+ import { DeferredSequence } from "../sequence/DeferredSequence.js";
5
4
  import { getArray } from "../util/array.js";
5
+ import { isArrayEqual } from "../util/equal.js";
6
+ import { getRandomKey } from "../util/random.js";
6
7
  import { transformObject } from "../util/transform.js";
7
- import { DeferredSequence } from "../sequence/DeferredSequence.js";
8
8
  /**
9
9
  * Fast in-memory store for data.
10
10
  * - Extremely fast (ideal for caching!), but does not persist data after the browser window is closed.
@@ -1,6 +1,6 @@
1
+ import type { ItemArray, ItemStatement, ItemValue } from "../db/Item.js";
1
2
  import type { Updates } from "../update/DataUpdate.js";
2
3
  import type { Data } from "../util/data.js";
3
- import type { ItemArray, ItemStatement, ItemValue } from "../db/Item.js";
4
4
  /** Provides access to data (e.g. IndexedDB, Firebase, or in-memory cache providers). */
5
5
  declare abstract class AbstractProvider {
6
6
  /**
@@ -1,8 +1,8 @@
1
- import type { Data } from "../util/data.js";
2
- import type { Sourceable } from "../util/source.js";
1
+ import type { AsyncProvider, Provider } from "./Provider.js";
3
2
  import type { ItemArray, ItemStatement, ItemValue } from "../db/Item.js";
4
3
  import type { Updates } from "../update/DataUpdate.js";
5
- import type { Provider, AsyncProvider } from "./Provider.js";
4
+ import type { Data } from "../util/data.js";
5
+ import type { Sourceable } from "../util/source.js";
6
6
  /** A provider that passes through to a synchronous source. */
7
7
  export declare class ThroughProvider implements Provider, Sourceable<Provider> {
8
8
  readonly source: Provider;
@@ -1,9 +1,9 @@
1
+ import type { AsyncProvider, Provider } from "./Provider.js";
2
+ import type { ItemArray, ItemStatement, ItemValue } from "../db/Item.js";
3
+ import type { DataSchema, DataSchemas } from "../schema/DataSchema.js";
4
+ import type { Updates } from "../update/DataUpdate.js";
1
5
  import type { DataKey, Datas } from "../util/data.js";
2
- import type { ItemArray, ItemValue, ItemStatement } from "../db/Item.js";
3
- import type { DataSchemas, DataSchema } from "../schema/DataSchema.js";
4
- import { Updates } from "../update/DataUpdate.js";
5
- import { Sourceable } from "../util/source.js";
6
- import { Provider, AsyncProvider } from "./Provider.js";
6
+ import type { Sourceable } from "../util/source.js";
7
7
  /** Validate a source provider (source can have any type because validation guarantees the type). */
8
8
  declare abstract class BaseValidationProvider<T extends Datas> {
9
9
  abstract source: Provider | AsyncProvider;
@@ -1,7 +1,7 @@
1
- import { validate, validateWithContext } from "../util/validate.js";
2
- import { isFeedback } from "../feedback/Feedback.js";
3
1
  import { ValidationError } from "../error/ValidationError.js";
2
+ import { Feedback } from "../feedback/Feedback.js";
4
3
  import { transformObject } from "../util/transform.js";
4
+ import { validate, validateWithContext } from "../util/validate.js";
5
5
  // Constants.
6
6
  const VALIDATION_CONTEXT_GET = { action: "get" };
7
7
  const VALIDATION_CONTEXT_ADD = { action: "add" };
@@ -102,7 +102,7 @@ function _validateItem(collection, unsafeEntity, schema) {
102
102
  return { ...validateWithContext(unsafeEntity, schema, VALIDATION_CONTEXT_GET), id: unsafeEntity.id };
103
103
  }
104
104
  catch (thrown) {
105
- if (!isFeedback(thrown))
105
+ if (!(thrown instanceof Feedback))
106
106
  throw thrown;
107
107
  throw new ValidationError(`Invalid data for "${collection}"`, unsafeEntity);
108
108
  }
@@ -119,7 +119,7 @@ function* _yieldValidItems(collection, unsafeEntities, schema) {
119
119
  yield { ...validateWithContext(unsafeEntity, schema, VALIDATION_CONTEXT_GET), id: unsafeEntity.id };
120
120
  }
121
121
  catch (thrown) {
122
- if (!isFeedback(thrown))
122
+ if (!(thrown instanceof Feedback))
123
123
  throw thrown;
124
124
  invalid = true;
125
125
  details[unsafeEntity.id] = thrown.message;
@@ -1,4 +1,4 @@
1
- import { useContext, createContext, createElement } from "react";
1
+ import { createContext, createElement, useContext } from "react";
2
2
  import { ConditionError } from "../error/ConditionError.js";
3
3
  import { useReduce } from "./useReduce.js";
4
4
  /** Reducer that gets an existing `Map` instance or creates a new one. */
@@ -1,8 +1,8 @@
1
1
  /// <reference types="react" />
2
+ import type { AsyncQuery } from "../db/Query.js";
2
3
  import type { ImmutableArray } from "../util/array.js";
3
4
  import { AsyncItem } from "../db/Item.js";
4
5
  import { ItemState } from "../db/ItemState.js";
5
- import { AsyncQuery } from "../db/Query.js";
6
6
  import { QueryState } from "../db/QueryState.js";
7
7
  type RefToState<T> = T extends undefined ? undefined : T extends AsyncItem<infer X> ? ItemState<X> : T extends AsyncQuery<infer X> ? QueryState<X> : never;
8
8
  /** Use one or more data items or queries. */
package/react/useData.js CHANGED
@@ -1,10 +1,10 @@
1
- import { setMapItem } from "../util/map.js";
2
- import { mapArray } from "../util/transform.js";
3
1
  import { AsyncItem } from "../db/Item.js";
4
2
  import { ItemState } from "../db/ItemState.js";
5
3
  import { QueryState } from "../db/QueryState.js";
6
- import { useState } from "./useState.js";
4
+ import { setMapItem } from "../util/map.js";
5
+ import { mapArray } from "../util/transform.js";
7
6
  import { createCache } from "./createCache.js";
7
+ import { useState } from "./useState.js";
8
8
  /** Create a cache. */
9
9
  const { Cache, useCache } = createCache();
10
10
  export function useData(...refs) {
@@ -1,5 +1,5 @@
1
1
  import type { Arguments } from "../util/function.js";
2
- import { Lazy } from "../util/lazy.js";
2
+ import type { Lazy } from "../util/lazy.js";
3
3
  /**
4
4
  * Use a memoised value with lazy initialisation.
5
5
  * - Returns `value` (if not a function) or the result of calling `value(...args)` (if a function).
@@ -1,5 +1,5 @@
1
1
  import type { AnyState } from "../state/State.js";
2
- import { ImmutableArray } from "../util/array.js";
2
+ import type { ImmutableArray } from "../util/array.js";
3
3
  /**
4
4
  * Subscribe to one or more `State` instances.
5
5
  *
@@ -1,6 +1,7 @@
1
+ import type { SchemaOptions } from "./Schema.js";
1
2
  import type { Entry } from "../util/entry.js";
2
- import { ImmutableMap, PossibleMap, PossibleStringMap } from "../util/map.js";
3
- import { Schema, SchemaOptions } from "./Schema.js";
3
+ import type { ImmutableMap, PossibleMap, PossibleStringMap } from "../util/map.js";
4
+ import { Schema } from "./Schema.js";
4
5
  /** Allowed options for `AllowSchama` */
5
6
  export type AllowSchemaOptions<K, T> = Omit<SchemaOptions, "value"> & {
6
7
  allow: PossibleMap<K, T>;
@@ -1,7 +1,7 @@
1
- import { getString } from "../util/string.js";
2
- import { getMap, isMapKey } from "../util/map.js";
3
1
  import { Feedback } from "../feedback/Feedback.js";
4
2
  import { getFirstItem } from "../util/array.js";
3
+ import { getMap, isMapKey } from "../util/map.js";
4
+ import { getString } from "../util/string.js";
5
5
  import { Schema } from "./Schema.js";
6
6
  /** Define a valid value from an allowed set of values. */
7
7
  export class AllowSchema extends Schema {
@@ -1,6 +1,7 @@
1
- import { ImmutableArray } from "../util/array.js";
2
- import { Validator } from "../util/validate.js";
3
- import { Schema, SchemaOptions } from "./Schema.js";
1
+ import type { SchemaOptions } from "./Schema.js";
2
+ import type { ImmutableArray } from "../util/array.js";
3
+ import type { Validator } from "../util/validate.js";
4
+ import { Schema } from "./Schema.js";
4
5
  /** Allowed options for `ArraySchema` */
5
6
  export type ArraySchemaOptions<T> = SchemaOptions & {
6
7
  readonly value?: ImmutableArray;
@@ -1,5 +1,5 @@
1
1
  import { Feedback } from "../feedback/Feedback.js";
2
- import { isArray, getUniqueArray } from "../util/array.js";
2
+ import { getUniqueArray, isArray } from "../util/array.js";
3
3
  import { validateArray } from "../util/validate.js";
4
4
  import { Schema } from "./Schema.js";
5
5
  /**
@@ -1,4 +1,5 @@
1
- import { Schema, SchemaOptions } from "./Schema.js";
1
+ import type { SchemaOptions } from "./Schema.js";
2
+ import { Schema } from "./Schema.js";
2
3
  /** Allowed options for `BooleanSchema` */
3
4
  export type BooleanSchemaOptions = SchemaOptions & {
4
5
  readonly value?: boolean | undefined;
@@ -1,7 +1,8 @@
1
+ import type { OptionalSchema } from "./OptionalSchema.js";
2
+ import type { SchemaOptions } from "./Schema.js";
1
3
  import type { Data, Datas } from "../util/data.js";
2
- import { Validators } from "../util/validate.js";
3
- import { OptionalSchema } from "./OptionalSchema.js";
4
- import { Schema, SchemaOptions } from "./Schema.js";
4
+ import type { Validators } from "../util/validate.js";
5
+ import { Schema } from "./Schema.js";
5
6
  /** Allowed options for `DataSchema` */
6
7
  export type DataSchemaOptions<T extends Data> = SchemaOptions & {
7
8
  readonly props: Validators<T>;
@@ -1,6 +1,6 @@
1
1
  import { Feedback } from "../feedback/Feedback.js";
2
- import { validateData } from "../util/validate.js";
3
2
  import { isData } from "../util/data.js";
3
+ import { validateData } from "../util/validate.js";
4
4
  import { OPTIONAL } from "./OptionalSchema.js";
5
5
  import { Schema } from "./Schema.js";
6
6
  /** Validate a data object. */
@@ -1,5 +1,6 @@
1
- import { PossibleDate, PossibleOptionalDate } from "../util/date.js";
2
- import { Schema, SchemaOptions } from "./Schema.js";
1
+ import type { SchemaOptions } from "./Schema.js";
2
+ import type { PossibleDate, PossibleOptionalDate } from "../util/date.js";
3
+ import { Schema } from "./Schema.js";
3
4
  /** Allowed options for `DateSchema` */
4
5
  export type DateSchemaOptions = SchemaOptions & {
5
6
  readonly value?: PossibleDate | undefined;
@@ -1,7 +1,7 @@
1
- import { formatDate, getOptionalDate, getYMD } from "../util/date.js";
2
1
  import { Feedback } from "../feedback/Feedback.js";
3
- import { Schema } from "./Schema.js";
2
+ import { formatDate, getOptionalDate, getYMD } from "../util/date.js";
4
3
  import { OPTIONAL } from "./OptionalSchema.js";
4
+ import { Schema } from "./Schema.js";
5
5
  /** Define a valid date in YMD format, e.g. `2005-09-12` */
6
6
  export class DateSchema extends Schema {
7
7
  constructor({ value = "now", min = null, max = null, ...options }) {
@@ -1,6 +1,7 @@
1
- import { ImmutableDictionary } from "../util/dictionary.js";
2
- import { Validator } from "../util/validate.js";
3
- import { Schema, SchemaOptions } from "./Schema.js";
1
+ import type { SchemaOptions } from "./Schema.js";
2
+ import type { ImmutableDictionary } from "../util/dictionary.js";
3
+ import type { Validator } from "../util/validate.js";
4
+ import { Schema } from "./Schema.js";
4
5
  /** Allowed options for `DictionarySchema` */
5
6
  export type DictionarySchemaOptions<T> = SchemaOptions & {
6
7
  readonly items: Validator<T>;
@@ -1,6 +1,6 @@
1
+ import { Feedback } from "../feedback/Feedback.js";
1
2
  import { isDictionary } from "../util/dictionary.js";
2
3
  import { validateDictionary } from "../util/validate.js";
3
- import { Feedback } from "../feedback/Feedback.js";
4
4
  import { Schema } from "./Schema.js";
5
5
  /** Validate a dictionary object (whose props are all the same with string keys). */
6
6
  export class DictionarySchema extends Schema {
@@ -1,5 +1,5 @@
1
- import { StringSchema } from "./StringSchema.js";
2
1
  import { OPTIONAL } from "./OptionalSchema.js";
2
+ import { StringSchema } from "./StringSchema.js";
3
3
  /**
4
4
  * Define a valid database key.
5
5
  *
@@ -1,4 +1,5 @@
1
- import { StringSchema, StringSchemaOptions } from "./StringSchema.js";
1
+ import type { StringSchemaOptions } from "./StringSchema.js";
2
+ import { StringSchema } from "./StringSchema.js";
2
3
  /** Allowed options for `LinkSchema` */
3
4
  export type LinkSchemaOptions = StringSchemaOptions & {
4
5
  readonly schemes?: string[] | undefined;
@@ -1,4 +1,5 @@
1
- import { Schema, SchemaOptions } from "./Schema.js";
1
+ import type { SchemaOptions } from "./Schema.js";
2
+ import { Schema } from "./Schema.js";
2
3
  /** Allowed options for `NumberSchema` */
3
4
  export type NumberSchemaOptions = SchemaOptions & {
4
5
  readonly value?: number | undefined;
@@ -1,7 +1,7 @@
1
- import { formatNumber, getOptionalNumber, roundStep } from "../util/number.js";
2
1
  import { Feedback } from "../feedback/Feedback.js";
3
- import { Schema } from "./Schema.js";
2
+ import { formatNumber, getOptionalNumber, roundStep } from "../util/number.js";
4
3
  import { OPTIONAL } from "./OptionalSchema.js";
4
+ import { Schema } from "./Schema.js";
5
5
  /** Schema that defines a valid number. */
6
6
  export class NumberSchema extends Schema {
7
7
  constructor({ value = 0, min = -Infinity, max = Infinity, step = null, ...rest }) {
@@ -1,4 +1,4 @@
1
- import { Schema } from "./Schema.js";
1
+ import type { Schema } from "./Schema.js";
2
2
  import { ThroughSchema } from "./ThroughSchema.js";
3
3
  /** Validate a value of a specific type or `null`. */
4
4
  export declare class OptionalSchema<T> extends ThroughSchema<T | null> {
@@ -1,5 +1,5 @@
1
- import { StringSchema } from "./StringSchema.js";
2
1
  import { OPTIONAL } from "./OptionalSchema.js";
2
+ import { StringSchema } from "./StringSchema.js";
3
3
  // Valid phone number is max 16 digits made up of:
4
4
  // - Country code (`+` plus character and 1-3 digits, e.g. `+44` or `+1`).
5
5
  // - Subscriber number (5-12 digits — the Solomon Islands have five-digit phone numbers apparently).
@@ -1,4 +1,4 @@
1
- import { Schema } from "./Schema.js";
1
+ import type { Schema } from "./Schema.js";
2
2
  import { ThroughSchema } from "./ThroughSchema.js";
3
3
  /** Validate a value of a specifed type, but return `Feedback` if the validated value is falsy. */
4
4
  export declare class RequiredSchema<T> extends ThroughSchema<T> {
@@ -1,4 +1,5 @@
1
- import { Schema, SchemaOptions } from "./Schema.js";
1
+ import type { SchemaOptions } from "./Schema.js";
2
+ import { Schema } from "./Schema.js";
2
3
  /** `type=""` prop for HTML `<input />` tags that are relevant for strings. */
3
4
  export type HtmlInputType = "text" | "password" | "color" | "date" | "email" | "number" | "tel" | "search" | "url";
4
5
  /** Function that sanitizes a string. */
@@ -1,5 +1,5 @@
1
- import { sanitizeLines, sanitizeString } from "../util/string.js";
2
1
  import { Feedback } from "../feedback/Feedback.js";
2
+ import { sanitizeLines, sanitizeString } from "../util/string.js";
3
3
  import { Schema } from "./Schema.js";
4
4
  /**
5
5
  * Schema that defines a valid string.
@@ -1,5 +1,6 @@
1
+ import type { SchemaOptions } from "./Schema.js";
1
2
  import type { Sourceable } from "../util/source.js";
2
- import { Schema, SchemaOptions } from "./Schema.js";
3
+ import { Schema } from "./Schema.js";
3
4
  /** Allowed options for `ThroughSchama` */
4
5
  export type ThroughSchemaOptions<T> = SchemaOptions & {
5
6
  source: Schema<T>;
@@ -1,5 +1,7 @@
1
- import { PossibleTime, Time, PossibleOptionalTime } from "../util/time.js";
2
- import { Schema, SchemaOptions } from "./Schema.js";
1
+ import type { SchemaOptions } from "./Schema.js";
2
+ import type { PossibleOptionalTime, PossibleTime } from "../util/time.js";
3
+ import { Time } from "../util/time.js";
4
+ import { Schema } from "./Schema.js";
3
5
  /** Allowed options for `TimeSchama` */
4
6
  export type TimeSchemaOptions = SchemaOptions & {
5
7
  readonly value?: PossibleTime | undefined;
@@ -1,6 +1,6 @@
1
1
  import { Feedback } from "../feedback/Feedback.js";
2
2
  import { roundStep } from "../util/number.js";
3
- import { getOptionalTime, Time } from "../util/time.js";
3
+ import { Time, getOptionalTime } from "../util/time.js";
4
4
  import { OPTIONAL } from "./OptionalSchema.js";
5
5
  import { Schema } from "./Schema.js";
6
6
  /** Define a valid time in 24h hh:mm:ss.fff format, e.g. `23:59` or `24:00 */
@@ -1,4 +1,4 @@
1
- import { ImmutableArray } from "../util/array.js";
1
+ import type { ImmutableArray } from "../util/array.js";
2
2
  import { State } from "./State.js";
3
3
  /** State that stores an array and has additional methods to help with that. */
4
4
  export declare class ArrayState<T> extends State<ImmutableArray<T>> implements Iterable<T> {
@@ -1,4 +1,4 @@
1
- import { toggleArrayItems, withArrayItems, omitArrayItems } from "../util/array.js";
1
+ import { omitArrayItems, toggleArrayItems, withArrayItems } from "../util/array.js";
2
2
  import { State } from "./State.js";
3
3
  /** State that stores an array and has additional methods to help with that. */
4
4
  export class ArrayState extends State {
@@ -1,5 +1,5 @@
1
- import { Data, DataKey } from "../util/data.js";
2
- import { Transformers, Transformer } from "../util/transform.js";
1
+ import type { Data, DataKey } from "../util/data.js";
2
+ import type { Transformer, Transformers } from "../util/transform.js";
3
3
  import { State } from "./State.js";
4
4
  /** State that stores a data object and has additional methods to help with that. */
5
5
  export declare class DataState<T extends Data> extends State<T> {
@@ -1,5 +1,5 @@
1
- import { withProp } from "../util/object.js";
2
1
  import { getData } from "../util/data.js";
2
+ import { withProp } from "../util/object.js";
3
3
  import { transform, transformObject } from "../util/transform.js";
4
4
  import { State } from "./State.js";
5
5
  /** State that stores a data object and has additional methods to help with that. */
@@ -1,5 +1,5 @@
1
- import { DictionaryItem, ImmutableDictionary } from "../util/dictionary.js";
2
- import { Transformer, Transformers } from "../util/transform.js";
1
+ import type { DictionaryItem, ImmutableDictionary } from "../util/dictionary.js";
2
+ import type { Transformer, Transformers } from "../util/transform.js";
3
3
  import { State } from "./State.js";
4
4
  /** State that stores a dictionary object and has additional methods to help with that. */
5
5
  export declare class DictionaryState<T> extends State<ImmutableDictionary<T>> implements Iterable<DictionaryItem<T>> {
@@ -1,5 +1,5 @@
1
- import { withProp } from "../util/object.js";
2
1
  import { omitDictionaryItems } from "../util/dictionary.js";
2
+ import { withProp } from "../util/object.js";
3
3
  import { transform, transformObject } from "../util/transform.js";
4
4
  import { State } from "./State.js";
5
5
  /** State that stores a dictionary object and has additional methods to help with that. */
package/state/State.d.ts CHANGED
@@ -1,5 +1,5 @@
1
+ import type { Dispatch, Handler, Stop } from "../util/function.js";
1
2
  import type { Validatable } from "../util/validate.js";
2
- import { Dispatch, Handler, Stop } from "../util/function.js";
3
3
  import { DeferredSequence } from "../sequence/DeferredSequence.js";
4
4
  /** Any `State` instance. */
5
5
  export type AnyState = State<any>;
package/state/State.js CHANGED
@@ -1,5 +1,5 @@
1
- import { runSequence } from "../util/sequence.js";
2
1
  import { DeferredSequence } from "../sequence/DeferredSequence.js";
2
+ import { runSequence } from "../util/sequence.js";
3
3
  /**
4
4
  * Stream that retains its most recent value
5
5
  * - Current value can be read at `state.value` and `state.data`
package/test/basics.d.ts CHANGED
@@ -1,4 +1,4 @@
1
- import { ItemData } from "../db/Item.js";
1
+ import type { ItemData } from "../db/Item.js";
2
2
  import type { ValidatorType } from "../util/validate.js";
3
3
  export declare const BASIC_SCHEMA: import("../schema/DataSchema.js").DataSchema<{
4
4
  str: string;
package/test/basics.js CHANGED
@@ -1,9 +1,9 @@
1
1
  import { ALLOW_STRING } from "../schema/AllowSchema.js";
2
2
  import { ARRAY } from "../schema/ArraySchema.js";
3
+ import { BOOLEAN } from "../schema/BooleanSchema.js";
3
4
  import { DATA } from "../schema/DataSchema.js";
4
5
  import { NUMBER } from "../schema/NumberSchema.js";
5
6
  import { STRING } from "../schema/StringSchema.js";
6
- import { BOOLEAN } from "../schema/BooleanSchema.js";
7
7
  export const BASIC_SCHEMA = DATA({
8
8
  str: STRING,
9
9
  num: NUMBER,
package/test/people.d.ts CHANGED
@@ -1,5 +1,5 @@
1
+ import type { ItemData } from "../db/Item.js";
1
2
  import type { ValidatorType } from "../util/validate.js";
2
- import { ItemData } from "../db/Item.js";
3
3
  export declare const PERSON_SCHEMA: import("../schema/DataSchema.js").DataSchema<{
4
4
  name: {
5
5
  first: any;
package/test/util.d.ts CHANGED
@@ -1,7 +1,7 @@
1
+ import type { ItemData } from "../db/Item.js";
1
2
  import type { Data } from "../util/data.js";
3
+ import type { AnyFunction } from "../util/function.js";
2
4
  import type { NotString } from "../util/string.js";
3
- import { ItemData } from "../db/Item.js";
4
- import { AnyFunction } from "../util/function.js";
5
5
  /** Match any `Promiselike` object. */
6
6
  export declare const PromiseLike: {
7
7
  asymmetricMatch(other: unknown): boolean;
@@ -1,4 +1,4 @@
1
- import { ImmutableArray } from "../util/array.js";
1
+ import type { ImmutableArray } from "../util/array.js";
2
2
  import { Update } from "./Update.js";
3
3
  /** Update that can be applied to an array to add/remove items. */
4
4
  export declare class ArrayUpdate<T> extends Update<ImmutableArray<T>> {
@@ -1,4 +1,4 @@
1
- import { withArrayItems, omitArrayItems } from "../util/array.js";
1
+ import { omitArrayItems, withArrayItems } from "../util/array.js";
2
2
  import { cloneObjectWith } from "../util/object.js";
3
3
  import { Update } from "./Update.js";
4
4
  /** Update that can be applied to an array to add/remove items. */
@@ -1,6 +1,6 @@
1
- import { Data, DataKey, DataProp } from "../util/data.js";
2
- import { Nullish } from "../util/null.js";
3
- import { Transformable } from "../util/transform.js";
1
+ import type { Data, DataKey, DataProp } from "../util/data.js";
2
+ import type { Nullish } from "../util/null.js";
3
+ import type { Transformable } from "../util/transform.js";
4
4
  import { Update } from "./Update.js";
5
5
  /**
6
6
  * Set of named updates for the props of a data object.
@@ -1,7 +1,7 @@
1
- import { Nullish } from "../util/null.js";
2
- import { DictionaryItem, ImmutableDictionary } from "../util/dictionary.js";
1
+ import type { Delete } from "./Delete.js";
2
+ import type { DictionaryItem, ImmutableDictionary } from "../util/dictionary.js";
3
+ import type { Nullish } from "../util/null.js";
3
4
  import { Update } from "./Update.js";
4
- import { Delete } from "./Delete.js";
5
5
  /** Update that can be applied to a dictionary object to add/remove/update its entries. */
6
6
  export declare class DictionaryUpdate<T> extends Update<ImmutableDictionary<T>> implements Iterable<DictionaryItem<T | Update<T> | Delete>> {
7
7
  /** Return a dictionary update with multiple items set. */
@@ -1,9 +1,9 @@
1
- import { isNullish } from "../util/null.js";
2
1
  import { getDictionaryItems } from "../util/dictionary.js";
3
- import { transformObject } from "../util/transform.js";
2
+ import { isNullish } from "../util/null.js";
4
3
  import { cloneObjectWith } from "../util/object.js";
5
- import { Update } from "./Update.js";
4
+ import { transformObject } from "../util/transform.js";
6
5
  import { DELETE } from "./Delete.js";
6
+ import { Update } from "./Update.js";
7
7
  /** Update that can be applied to a dictionary object to add/remove/update its entries. */
8
8
  export class DictionaryUpdate extends Update {
9
9
  /** Return a dictionary update with multiple items set. */
@@ -1,3 +1,3 @@
1
- import { Hydrations } from "../util/hydrate.js";
1
+ import type { Hydrations } from "../util/hydrate.js";
2
2
  /** Set of hydrations for all update classes. */
3
3
  export declare const UPDATE_HYDRATIONS: Hydrations;
@@ -1,8 +1,8 @@
1
- import { Delete } from "./Delete.js";
2
- import { Increment } from "./Increment.js";
3
1
  import { ArrayUpdate } from "./ArrayUpdate.js";
4
- import { DictionaryUpdate } from "./DictionaryUpdate.js";
5
2
  import { DataUpdate } from "./DataUpdate.js";
3
+ import { Delete } from "./Delete.js";
4
+ import { DictionaryUpdate } from "./DictionaryUpdate.js";
5
+ import { Increment } from "./Increment.js";
6
6
  /** Set of hydrations for all update classes. */
7
7
  export const UPDATE_HYDRATIONS = {
8
8
  Increment,