shelving 1.83.1 → 1.83.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.
@@ -1,4 +1,4 @@
1
- import type { ImmutableDictionary } from "../util/dictionary.js";
1
+ import { Entry } from "../util/entry.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.
@@ -21,7 +21,7 @@ export declare class Feedback<T = unknown> {
21
21
  /** Is an unknown value a `Feedback` object. */
22
22
  export declare const isFeedback: <T extends Feedback<unknown>>(v: unknown) => v is Feedback<unknown>;
23
23
  /**
24
- * Get an object of sub-messages in `{ key: message }` format from a feedback's value.
24
+ * Yield the sub-messages in `[key: string, message: string]` format from a feedback's value.
25
25
  * - Takes the `.value` property from a `Feedback` instance and looks for keyed `Feedback` instances in either `{ key: Feedback }`. `Feedback[]`, or `Map<key, Feedback>` formats.
26
26
  */
27
- export declare const getFeedbackMessages: ({ value }: Feedback) => ImmutableDictionary<string>;
27
+ export declare function getFeedbackMessages({ value }: Feedback): Iterable<Entry<string, string>>;
@@ -31,11 +31,10 @@ __decorate([
31
31
  /** Is an unknown value a `Feedback` object. */
32
32
  export const isFeedback = (v) => isObject(v) && typeof v.name === "string" && v.name.endsWith("Feedback") && typeof v.message === "string";
33
33
  /**
34
- * Get an object of sub-messages in `{ key: message }` format from a feedback's value.
34
+ * Yield the sub-messages in `[key: string, message: string]` format from a feedback's value.
35
35
  * - Takes the `.value` property from a `Feedback` instance and looks for keyed `Feedback` instances in either `{ key: Feedback }`. `Feedback[]`, or `Map<key, Feedback>` formats.
36
36
  */
37
- export const getFeedbackMessages = ({ value }) => Object.fromEntries(_yieldFeedbackMessages(value));
38
- function* _yieldFeedbackMessages(value) {
37
+ export function* getFeedbackMessages({ value }) {
39
38
  if (isObject(value))
40
39
  for (const [k, v] of getEntries(value))
41
40
  if (isFeedback(v))
package/package.json CHANGED
@@ -11,7 +11,7 @@
11
11
  "state-management",
12
12
  "query-builder"
13
13
  ],
14
- "version": "1.83.1",
14
+ "version": "1.83.2",
15
15
  "repository": "https://github.com/dhoulb/shelving",
16
16
  "author": "Dave Houlbrooke <dave@shax.com>",
17
17
  "license": "0BSD",
@@ -15,13 +15,13 @@ export declare type SchemaOptions = {
15
15
  */
16
16
  export declare abstract class Schema<T extends unknown = unknown> implements Validatable<T> {
17
17
  /** Title, e.g. for showing in fields. */
18
- readonly title: string;
18
+ readonly title?: string;
19
19
  /** Description, e.g. for showing in fields. */
20
- readonly description: string;
20
+ readonly description?: string;
21
21
  /** Placeholder, e.g. for showing in fields. */
22
- readonly placeholder: string;
22
+ readonly placeholder?: string;
23
23
  /** Default value. */
24
- readonly value: unknown;
24
+ readonly value?: unknown;
25
25
  constructor({ title, description, placeholder }: SchemaOptions);
26
26
  /** Every schema must implement a `validate()` method. */
27
27
  abstract validate(unsafeValue: unknown): T;
@@ -24,11 +24,11 @@ export declare type Validator<T = unknown> = Validatable<T> | Validate<T>;
24
24
  export declare type ValidatorType<X> = X extends Validator<infer Y> ? Y : never;
25
25
  /** A set of named validators in `{ name: Validator }` format. */
26
26
  export declare type Validators<T extends Data = Data> = {
27
- [K in keyof T]: Validator<T[K]>;
27
+ readonly [K in keyof T]: Validator<T[K]>;
28
28
  };
29
29
  /** Extract the type from a set of validators. */
30
30
  export declare type ValidatorsType<T> = {
31
- [K in keyof T]: ValidatorType<T[K]>;
31
+ readonly [K in keyof T]: ValidatorType<T[K]>;
32
32
  };
33
33
  /** Validate an unknown value with a validator. */
34
34
  export declare function validate<T>(unsafeValue: unknown, validator: Validator<T>): T;