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 +4 -2
- package/feedback/Feedback.d.ts +0 -2
- package/feedback/Feedback.js +0 -2
- package/feedback/Feedbacks.d.ts +0 -2
- package/feedback/Feedbacks.js +0 -2
- package/package.json +1 -1
- package/provider/ValidationProvider.d.ts +1 -1
- package/provider/ValidationProvider.js +3 -3
- package/util/validate.js +5 -5
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 {
|
|
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
|
-
|
|
36
|
+
if (thrown instanceof Feedback)
|
|
37
|
+
throw new ValidationError(`Invalid result for resource`, thrown);
|
|
38
|
+
throw thrown;
|
|
37
39
|
}
|
|
38
40
|
}
|
|
39
41
|
}
|
package/feedback/Feedback.d.ts
CHANGED
|
@@ -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;
|
package/feedback/Feedback.js
CHANGED
|
@@ -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;
|
package/feedback/Feedbacks.d.ts
CHANGED
|
@@ -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>;
|
package/feedback/Feedbacks.js
CHANGED
|
@@ -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
|
@@ -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 {
|
|
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 (!
|
|
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/util/validate.js
CHANGED
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import {
|
|
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 (!
|
|
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 (!
|
|
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 (!
|
|
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 (!
|
|
124
|
+
if (!(thrown instanceof Feedback))
|
|
125
125
|
throw thrown;
|
|
126
126
|
feedbacks[key] = thrown;
|
|
127
127
|
valid = false;
|