shelving 1.91.0 → 1.91.1

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
package/api/Resource.js CHANGED
@@ -1,6 +1,6 @@
1
1
  import { validate } from "../util/validate.js";
2
2
  import { getUndefined } from "../util/undefined.js";
3
- import { isFeedback } from "../feedback/Feedback.js";
3
+ import { Feedback } from "../feedback/Feedback.js";
4
4
  import { ValidationError } from "../error/ValidationError.js";
5
5
  /**
6
6
  * An abstract API resource definition, used to specify types for e.g. serverless functions..
@@ -33,7 +33,9 @@ export class Resource {
33
33
  return validate(unsafeResult, this.result);
34
34
  }
35
35
  catch (thrown) {
36
- throw isFeedback(thrown) ? new ValidationError(`Invalid result for resource`, thrown) : thrown;
36
+ if (thrown instanceof Feedback)
37
+ throw new ValidationError(`Invalid result for resource`, thrown);
38
+ throw thrown;
37
39
  }
38
40
  }
39
41
  }
@@ -14,7 +14,5 @@ export declare class Feedback {
14
14
  constructor(feedback: string, value?: unknown);
15
15
  toString(): string;
16
16
  }
17
- /** Is an unknown value a `Feedback` object. */
18
- export declare const isFeedback: <T extends Feedback>(value: unknown) => value is T;
19
17
  /** Get the message from a feedback. */
20
18
  export declare const getFeedbackMessage: ({ message }: Feedback) => string;
@@ -15,7 +15,5 @@ export class Feedback {
15
15
  return this.message;
16
16
  }
17
17
  }
18
- /** Is an unknown value a `Feedback` object. */
19
- export const isFeedback = (value) => value instanceof Feedback;
20
18
  /** Get the message from a feedback. */
21
19
  export const getFeedbackMessage = ({ message }) => message;
@@ -6,7 +6,5 @@ export declare class Feedbacks extends Feedback {
6
6
  readonly feedbacks: ImmutableDictionary<Feedback>;
7
7
  constructor(feedbacks: ImmutableDictionary<Feedback>, value?: unknown);
8
8
  }
9
- /** Is an unknown value a `Feedbacks` object. */
10
- export declare const isFeedbacks: <T extends Feedbacks>(value: unknown) => value is T;
11
9
  /** Get the messages from a feedbacks' sub-feedbacks. */
12
10
  export declare const getFeedbackMessages: ({ feedbacks }: Feedbacks) => ImmutableDictionary<string>;
@@ -7,7 +7,5 @@ export class Feedbacks extends Feedback {
7
7
  this.feedbacks = feedbacks;
8
8
  }
9
9
  }
10
- /** Is an unknown value a `Feedbacks` object. */
11
- export const isFeedbacks = (value) => value instanceof Feedbacks;
12
10
  /** Get the messages from a feedbacks' sub-feedbacks. */
13
11
  export const getFeedbackMessages = ({ feedbacks }) => mapDictionary(feedbacks, getFeedbackMessage);
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.1",
15
15
  "repository": "https://github.com/dhoulb/shelving",
16
16
  "author": "Dave Houlbrooke <dave@shax.com>",
17
17
  "license": "0BSD",
@@ -1,7 +1,7 @@
1
1
  import type { DataKey, Datas } from "../util/data.js";
2
2
  import type { ItemArray, ItemValue, ItemStatement } from "../db/Item.js";
3
3
  import type { DataSchemas, DataSchema } from "../schema/DataSchema.js";
4
- import { Updates } from "../update/DataUpdate.js";
4
+ import type { Updates } from "../update/DataUpdate.js";
5
5
  import { Sourceable } from "../util/source.js";
6
6
  import { Provider, AsyncProvider } from "./Provider.js";
7
7
  /** Validate a source provider (source can have any type because validation guarantees the type). */
@@ -1,5 +1,5 @@
1
1
  import { validate, validateWithContext } from "../util/validate.js";
2
- import { isFeedback } from "../feedback/Feedback.js";
2
+ import { Feedback } from "../feedback/Feedback.js";
3
3
  import { ValidationError } from "../error/ValidationError.js";
4
4
  import { transformObject } from "../util/transform.js";
5
5
  // Constants.
@@ -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;
package/util/validate.js CHANGED
@@ -1,4 +1,4 @@
1
- import { isFeedback } from "../feedback/Feedback.js";
1
+ import { Feedback } from "../feedback/Feedback.js";
2
2
  import { Feedbacks } from "../feedback/Feedbacks.js";
3
3
  import { getDictionaryItems } from "./dictionary.js";
4
4
  import { getDataProps } from "./data.js";
@@ -24,7 +24,7 @@ export function* validateItems(unsafeItems, validator) {
24
24
  yield validate(unsafeItem, validator);
25
25
  }
26
26
  catch (thrown) {
27
- if (!isFeedback(thrown))
27
+ if (!(thrown instanceof Feedback))
28
28
  throw thrown;
29
29
  feedbacks[index] = thrown;
30
30
  valid = false;
@@ -55,7 +55,7 @@ export function validateArray(unsafeArray, validator) {
55
55
  changed = true;
56
56
  }
57
57
  catch (thrown) {
58
- if (!isFeedback(thrown))
58
+ if (!(thrown instanceof Feedback))
59
59
  throw thrown;
60
60
  feedbacks[index] = thrown;
61
61
  valid = false;
@@ -85,7 +85,7 @@ export function validateDictionary(unsafeDictionary, validator) {
85
85
  changed = true;
86
86
  }
87
87
  catch (thrown) {
88
- if (!isFeedback(thrown))
88
+ if (!(thrown instanceof Feedback))
89
89
  throw thrown;
90
90
  feedbacks[key] = thrown;
91
91
  valid = false;
@@ -121,7 +121,7 @@ export function validateData(unsafeData, validators) {
121
121
  changed = true;
122
122
  }
123
123
  catch (thrown) {
124
- if (!isFeedback(thrown))
124
+ if (!(thrown instanceof Feedback))
125
125
  throw thrown;
126
126
  feedbacks[key] = thrown;
127
127
  valid = false;