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.
- package/api/Resource.d.ts +1 -1
- package/api/Resource.js +6 -4
- package/constraint/Constraints.d.ts +1 -1
- package/constraint/Constraints.js +1 -1
- package/constraint/Filter.d.ts +4 -4
- package/constraint/Filter.js +5 -3
- package/constraint/Filters.d.ts +3 -2
- package/constraint/Filters.js +3 -3
- package/constraint/Sort.d.ts +3 -3
- package/constraint/Sort.js +3 -1
- package/constraint/Sorts.d.ts +4 -3
- package/constraint/Statement.d.ts +4 -2
- package/constraint/Statement.js +4 -4
- package/db/Change.d.ts +4 -4
- package/db/Collection.d.ts +5 -4
- package/db/Database.d.ts +7 -7
- package/db/Database.js +3 -3
- package/db/Item.d.ts +5 -5
- package/db/Item.js +1 -1
- package/db/ItemState.d.ts +3 -3
- package/db/ItemState.js +4 -4
- package/db/Query.d.ts +5 -5
- package/db/Query.js +2 -2
- package/db/QueryState.d.ts +3 -3
- package/db/QueryState.js +4 -4
- package/feedback/Feedback.d.ts +0 -4
- package/feedback/Feedback.js +0 -4
- package/feedback/Feedbacks.d.ts +2 -4
- package/feedback/Feedbacks.js +6 -5
- package/firestore/client/FirestoreClientProvider.d.ts +4 -4
- package/firestore/client/FirestoreClientProvider.js +7 -2
- package/firestore/lite/FirestoreLiteProvider.d.ts +4 -4
- package/firestore/lite/FirestoreLiteProvider.js +7 -2
- package/firestore/server/FirestoreServerProvider.d.ts +4 -4
- package/firestore/server/FirestoreServerProvider.js +7 -2
- package/markup/regexp.d.ts +2 -2
- package/markup/render.d.ts +1 -1
- package/markup/rule.d.ts +5 -5
- package/markup/rules.d.ts +3 -2
- package/markup/rules.js +1 -1
- package/package.json +3 -4
- package/provider/CacheProvider.d.ts +3 -3
- package/provider/DebugProvider.d.ts +3 -3
- package/provider/MemoryProvider.d.ts +3 -3
- package/provider/MemoryProvider.js +3 -3
- package/provider/Provider.d.ts +1 -1
- package/provider/ThroughProvider.d.ts +3 -3
- package/provider/ValidationProvider.d.ts +5 -5
- package/provider/ValidationProvider.js +4 -4
- package/react/createCache.js +1 -1
- package/react/useData.d.ts +1 -1
- package/react/useData.js +3 -3
- package/react/useLazy.d.ts +1 -1
- package/react/useState.d.ts +1 -1
- package/schema/AllowSchema.d.ts +3 -2
- package/schema/AllowSchema.js +2 -2
- package/schema/ArraySchema.d.ts +4 -3
- package/schema/ArraySchema.js +1 -1
- package/schema/BooleanSchema.d.ts +2 -1
- package/schema/DataSchema.d.ts +4 -3
- package/schema/DataSchema.js +1 -1
- package/schema/DateSchema.d.ts +3 -2
- package/schema/DateSchema.js +2 -2
- package/schema/DictionarySchema.d.ts +4 -3
- package/schema/DictionarySchema.js +1 -1
- package/schema/KeySchema.js +1 -1
- package/schema/LinkSchema.d.ts +2 -1
- package/schema/NumberSchema.d.ts +2 -1
- package/schema/NumberSchema.js +2 -2
- package/schema/OptionalSchema.d.ts +1 -1
- package/schema/PhoneSchema.js +1 -1
- package/schema/RequiredSchema.d.ts +1 -1
- package/schema/StringSchema.d.ts +2 -1
- package/schema/StringSchema.js +1 -1
- package/schema/ThroughSchema.d.ts +2 -1
- package/schema/TimeSchema.d.ts +4 -2
- package/schema/TimeSchema.js +1 -1
- package/state/ArrayState.d.ts +1 -1
- package/state/ArrayState.js +1 -1
- package/state/DataState.d.ts +2 -2
- package/state/DataState.js +1 -1
- package/state/DictionaryState.d.ts +2 -2
- package/state/DictionaryState.js +1 -1
- package/state/State.d.ts +1 -1
- package/state/State.js +1 -1
- package/test/basics.d.ts +1 -1
- package/test/basics.js +1 -1
- package/test/people.d.ts +1 -1
- package/test/util.d.ts +2 -2
- package/update/ArrayUpdate.d.ts +1 -1
- package/update/ArrayUpdate.js +1 -1
- package/update/DataUpdate.d.ts +3 -3
- package/update/DictionaryUpdate.d.ts +3 -3
- package/update/DictionaryUpdate.js +3 -3
- package/update/hydrations.d.ts +1 -1
- package/update/hydrations.js +3 -3
- package/util/activity.d.ts +1 -1
- package/util/array.d.ts +0 -4
- package/util/array.js +1 -8
- package/util/async.d.ts +1 -1
- package/util/class.d.ts +1 -1
- package/util/class.js +1 -1
- package/util/diff.d.ts +2 -2
- package/util/duration.d.ts +1 -1
- package/util/duration.js +1 -1
- package/util/entry.d.ts +3 -3
- package/util/equal.d.ts +3 -3
- package/util/equal.js +1 -1
- package/util/hydrate.d.ts +2 -2
- package/util/hydrate.js +1 -1
- package/util/iterate.d.ts +0 -4
- package/util/iterate.js +5 -7
- package/util/lazy.d.ts +1 -1
- package/util/map.d.ts +1 -1
- package/util/match.d.ts +6 -1
- package/util/match.js +13 -0
- package/util/merge.d.ts +2 -2
- package/util/object.d.ts +1 -1
- package/util/regexp.d.ts +2 -2
- package/util/sequence.d.ts +1 -1
- package/util/sort.d.ts +1 -1
- package/util/string.d.ts +1 -1
- package/util/string.js +2 -2
- package/util/template.d.ts +1 -1
- package/util/template.js +2 -2
- package/util/transform.d.ts +3 -3
- package/util/units.d.ts +4 -3
- package/util/units.js +2 -2
- package/util/validate.d.ts +3 -3
- 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.
|
|
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:
|
|
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 {
|
|
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 {
|
|
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 {
|
|
2
|
-
import type { ItemArray,
|
|
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.
|
package/provider/Provider.d.ts
CHANGED
|
@@ -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 {
|
|
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 {
|
|
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 {
|
|
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 (!
|
|
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 (!
|
|
122
|
+
if (!(thrown instanceof Feedback))
|
|
123
123
|
throw thrown;
|
|
124
124
|
invalid = true;
|
|
125
125
|
details[unsafeEntity.id] = thrown.message;
|
package/react/createCache.js
CHANGED
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import {
|
|
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. */
|
package/react/useData.d.ts
CHANGED
|
@@ -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 {
|
|
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) {
|
package/react/useLazy.d.ts
CHANGED
|
@@ -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).
|
package/react/useState.d.ts
CHANGED
package/schema/AllowSchema.d.ts
CHANGED
|
@@ -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
|
|
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>;
|
package/schema/AllowSchema.js
CHANGED
|
@@ -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 {
|
package/schema/ArraySchema.d.ts
CHANGED
|
@@ -1,6 +1,7 @@
|
|
|
1
|
-
import {
|
|
2
|
-
import {
|
|
3
|
-
import {
|
|
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;
|
package/schema/ArraySchema.js
CHANGED
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
import { Feedback } from "../feedback/Feedback.js";
|
|
2
|
-
import {
|
|
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 {
|
|
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;
|
package/schema/DataSchema.d.ts
CHANGED
|
@@ -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 {
|
|
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>;
|
package/schema/DataSchema.js
CHANGED
|
@@ -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. */
|
package/schema/DateSchema.d.ts
CHANGED
|
@@ -1,5 +1,6 @@
|
|
|
1
|
-
import {
|
|
2
|
-
import {
|
|
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;
|
package/schema/DateSchema.js
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
|
-
import { formatDate, getOptionalDate, getYMD } from "../util/date.js";
|
|
2
1
|
import { Feedback } from "../feedback/Feedback.js";
|
|
3
|
-
import {
|
|
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 {
|
|
2
|
-
import {
|
|
3
|
-
import {
|
|
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 {
|
package/schema/KeySchema.js
CHANGED
package/schema/LinkSchema.d.ts
CHANGED
|
@@ -1,4 +1,5 @@
|
|
|
1
|
-
import {
|
|
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;
|
package/schema/NumberSchema.d.ts
CHANGED
|
@@ -1,4 +1,5 @@
|
|
|
1
|
-
import {
|
|
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;
|
package/schema/NumberSchema.js
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
|
-
import { formatNumber, getOptionalNumber, roundStep } from "../util/number.js";
|
|
2
1
|
import { Feedback } from "../feedback/Feedback.js";
|
|
3
|
-
import {
|
|
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 }) {
|
package/schema/PhoneSchema.js
CHANGED
|
@@ -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> {
|
package/schema/StringSchema.d.ts
CHANGED
|
@@ -1,4 +1,5 @@
|
|
|
1
|
-
import {
|
|
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. */
|
package/schema/StringSchema.js
CHANGED
|
@@ -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
|
|
3
|
+
import { Schema } from "./Schema.js";
|
|
3
4
|
/** Allowed options for `ThroughSchama` */
|
|
4
5
|
export type ThroughSchemaOptions<T> = SchemaOptions & {
|
|
5
6
|
source: Schema<T>;
|
package/schema/TimeSchema.d.ts
CHANGED
|
@@ -1,5 +1,7 @@
|
|
|
1
|
-
import {
|
|
2
|
-
import {
|
|
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;
|
package/schema/TimeSchema.js
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
import { Feedback } from "../feedback/Feedback.js";
|
|
2
2
|
import { roundStep } from "../util/number.js";
|
|
3
|
-
import {
|
|
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 */
|
package/state/ArrayState.d.ts
CHANGED
|
@@ -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> {
|
package/state/ArrayState.js
CHANGED
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import { toggleArrayItems, withArrayItems
|
|
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 {
|
package/state/DataState.d.ts
CHANGED
|
@@ -1,5 +1,5 @@
|
|
|
1
|
-
import { Data, DataKey } from "../util/data.js";
|
|
2
|
-
import {
|
|
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> {
|
package/state/DataState.js
CHANGED
|
@@ -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>> {
|
package/state/DictionaryState.js
CHANGED
|
@@ -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
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
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;
|
package/update/ArrayUpdate.d.ts
CHANGED
|
@@ -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>> {
|
package/update/ArrayUpdate.js
CHANGED
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import {
|
|
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. */
|
package/update/DataUpdate.d.ts
CHANGED
|
@@ -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 {
|
|
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 {
|
|
2
|
+
import { isNullish } from "../util/null.js";
|
|
4
3
|
import { cloneObjectWith } from "../util/object.js";
|
|
5
|
-
import {
|
|
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. */
|
package/update/hydrations.d.ts
CHANGED
package/update/hydrations.js
CHANGED
|
@@ -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,
|