@emoyly/problem 8.0.0 → 8.0.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/cjs/problem.d.ts +1 -1
- package/cjs/problem.js +7 -0
- package/cjs/tsconfig.tsbuildinfo +1 -1
- package/cjs/util/getProblems.d.ts +1 -1
- package/cjs/util/getProblems.js +3 -2
- package/cjs/util/version.d.ts +1 -1
- package/cjs/util/version.js +1 -1
- package/esm/problem.d.ts +1 -1
- package/esm/problem.js +7 -0
- package/esm/tsconfig.tsbuildinfo +1 -1
- package/esm/util/getProblems.d.ts +1 -1
- package/esm/util/getProblems.js +3 -2
- package/esm/util/version.d.ts +1 -1
- package/esm/util/version.js +1 -1
- package/package.json +1 -1
package/cjs/util/getProblems.js
CHANGED
|
@@ -9,7 +9,7 @@ const validation_js_1 = require("./validation.js");
|
|
|
9
9
|
function isJsonProblem(input) {
|
|
10
10
|
return (0, validation_js_1.validateBasicInput)(input) === true;
|
|
11
11
|
}
|
|
12
|
-
function createFromJson({ title, type, instance, detail, status, data: _data, ...extras }) {
|
|
12
|
+
function createFromJson({ title, type, instance, detail, status, data: _data, __problemVersion, source, errorObject, stack, ...extras }) {
|
|
13
13
|
let data;
|
|
14
14
|
const extraKeys = Object.keys(extras);
|
|
15
15
|
if /* No extras, just use data */ (extraKeys.length < 1) {
|
|
@@ -24,7 +24,8 @@ function createFromJson({ title, type, instance, detail, status, data: _data, ..
|
|
|
24
24
|
else {
|
|
25
25
|
data = { ...extras, ..._data };
|
|
26
26
|
}
|
|
27
|
-
|
|
27
|
+
// TODO: Validate that source, errorObject and stack should actually be passed through
|
|
28
|
+
return new problem_js_1.Problem({ title, type, instance, detail, status, data, source, errorObject, stack });
|
|
28
29
|
}
|
|
29
30
|
/**
|
|
30
31
|
* Get an array of Problems from any given input.
|
package/cjs/util/version.d.ts
CHANGED
|
@@ -1,2 +1,2 @@
|
|
|
1
|
-
export declare const version = "8.0.
|
|
1
|
+
export declare const version = "8.0.2";
|
|
2
2
|
export declare const major: number;
|
package/cjs/util/version.js
CHANGED
package/esm/problem.d.ts
CHANGED
|
@@ -6,7 +6,7 @@ export declare class Problem extends Error implements IProblem {
|
|
|
6
6
|
detail: string | undefined;
|
|
7
7
|
instance: string | undefined;
|
|
8
8
|
errorObject?: unknown;
|
|
9
|
-
readonly __problemVersion = "8.0.
|
|
9
|
+
readonly __problemVersion = "8.0.2";
|
|
10
10
|
data: unknown;
|
|
11
11
|
source?: string;
|
|
12
12
|
constructor(opts: ProblemOpts);
|
package/esm/problem.js
CHANGED
|
@@ -1,3 +1,4 @@
|
|
|
1
|
+
import { isJsonProblem } from './util/getProblems.js';
|
|
1
2
|
import { validateBasicInput } from './util/validation.js';
|
|
2
3
|
import { version } from './util/version.js';
|
|
3
4
|
export class Problem extends Error {
|
|
@@ -44,6 +45,12 @@ export class Problem extends Error {
|
|
|
44
45
|
}
|
|
45
46
|
if (opts.data)
|
|
46
47
|
this.data = opts.data;
|
|
48
|
+
if (opts.data && opts.data instanceof Problem) {
|
|
49
|
+
console.warn('@emoyly/problem -> Problem: Problem instance passed in "data" to new Problem. This probably means something went wrong.');
|
|
50
|
+
}
|
|
51
|
+
else if (opts.data && isJsonProblem(opts.data)) {
|
|
52
|
+
console.warn('@emoyly/problem -> Problem: Something which looks like a "JSON Problem" passed in "data" to new Problem. This probably means something went wrong.');
|
|
53
|
+
}
|
|
47
54
|
}
|
|
48
55
|
toObject = () => {
|
|
49
56
|
const out = {
|