@devp0nt/error0 1.0.0-next.49 → 1.0.0-next.50
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/dist/cjs/index.cjs +5 -17
- package/dist/cjs/index.cjs.map +1 -1
- package/dist/cjs/index.d.cts +64 -21
- package/dist/cjs/plugins/cause-serialize.cjs +1 -1
- package/dist/cjs/plugins/cause-serialize.cjs.map +1 -1
- package/dist/cjs/plugins/code.cjs +38 -0
- package/dist/cjs/plugins/code.cjs.map +1 -0
- package/dist/cjs/plugins/code.d.cts +7 -0
- package/dist/cjs/plugins/expected.cjs +2 -2
- package/dist/cjs/plugins/expected.cjs.map +1 -1
- package/dist/cjs/plugins/expected.d.cts +31 -2
- package/dist/cjs/plugins/meta.cjs +1 -1
- package/dist/cjs/plugins/meta.cjs.map +1 -1
- package/dist/cjs/plugins/stack-merge.cjs +1 -1
- package/dist/cjs/plugins/stack-merge.cjs.map +1 -1
- package/dist/cjs/plugins/status.cjs +54 -0
- package/dist/cjs/plugins/status.cjs.map +1 -0
- package/dist/cjs/plugins/status.d.cts +8 -0
- package/dist/cjs/plugins/tags.cjs +41 -21
- package/dist/cjs/plugins/tags.cjs.map +1 -1
- package/dist/cjs/plugins/tags.d.cts +7 -2
- package/dist/esm/index.d.ts +64 -21
- package/dist/esm/index.js +5 -17
- package/dist/esm/index.js.map +1 -1
- package/dist/esm/plugins/cause-serialize.js +1 -1
- package/dist/esm/plugins/cause-serialize.js.map +1 -1
- package/dist/esm/plugins/code.d.ts +7 -0
- package/dist/esm/plugins/code.js +14 -0
- package/dist/esm/plugins/code.js.map +1 -0
- package/dist/esm/plugins/expected.d.ts +31 -2
- package/dist/esm/plugins/expected.js +2 -2
- package/dist/esm/plugins/expected.js.map +1 -1
- package/dist/esm/plugins/meta.js +1 -1
- package/dist/esm/plugins/meta.js.map +1 -1
- package/dist/esm/plugins/stack-merge.js +1 -1
- package/dist/esm/plugins/stack-merge.js.map +1 -1
- package/dist/esm/plugins/status.d.ts +8 -0
- package/dist/esm/plugins/status.js +30 -0
- package/dist/esm/plugins/status.js.map +1 -0
- package/dist/esm/plugins/tags.d.ts +7 -2
- package/dist/esm/plugins/tags.js +41 -21
- package/dist/esm/plugins/tags.js.map +1 -1
- package/package.json +1 -1
- package/src/index.test.ts +53 -7
- package/src/index.ts +107 -67
- package/src/plugins/cause-serialize.ts +1 -1
- package/src/plugins/code.test.ts +27 -0
- package/src/plugins/code.ts +12 -0
- package/src/plugins/expected.ts +2 -2
- package/src/plugins/meta.ts +1 -1
- package/src/plugins/stack-merge.ts +1 -1
- package/src/plugins/status.test.ts +54 -0
- package/src/plugins/status.ts +29 -0
- package/src/plugins/tags.test.ts +54 -2
- package/src/plugins/tags.ts +48 -24
|
@@ -1,7 +1,36 @@
|
|
|
1
|
-
import { PluginError0, ErrorPluginPropOptions, Error0
|
|
1
|
+
import { PluginError0, ErrorPluginPropOptions, Error0 } from '../index.cjs';
|
|
2
2
|
|
|
3
3
|
declare const expectedPlugin: ({ hideWhenPublic }?: {
|
|
4
4
|
hideWhenPublic?: boolean;
|
|
5
|
-
}) => PluginError0<Record<never, never> & Record<"expected", ErrorPluginPropOptions<boolean, boolean, Error0, boolean>>, Record<never, never> & Record<"isExpected",
|
|
5
|
+
}) => PluginError0<Record<never, never> & Record<"expected", ErrorPluginPropOptions<boolean, boolean, Error0, boolean>>, Record<never, never> & Record<"isExpected", (error: Error0 & {
|
|
6
|
+
expected: boolean;
|
|
7
|
+
} & {} & {
|
|
8
|
+
own: {
|
|
9
|
+
(): {
|
|
10
|
+
expected: boolean | undefined;
|
|
11
|
+
};
|
|
12
|
+
<TKey extends "expected">(key: TKey): {
|
|
13
|
+
expected: boolean | undefined;
|
|
14
|
+
}[TKey];
|
|
15
|
+
};
|
|
16
|
+
flow: <TKey extends "expected">(key: TKey) => {
|
|
17
|
+
expected: boolean | undefined;
|
|
18
|
+
}[TKey][];
|
|
19
|
+
} & {
|
|
20
|
+
resolve: () => {
|
|
21
|
+
expected: boolean;
|
|
22
|
+
};
|
|
23
|
+
} & {
|
|
24
|
+
readonly __pluginsMap?: {
|
|
25
|
+
props: {
|
|
26
|
+
expected: {
|
|
27
|
+
init: boolean | undefined;
|
|
28
|
+
output: boolean;
|
|
29
|
+
resolve: boolean;
|
|
30
|
+
};
|
|
31
|
+
};
|
|
32
|
+
methods: {};
|
|
33
|
+
} | undefined;
|
|
34
|
+
}) => boolean>>;
|
|
6
35
|
|
|
7
36
|
export { expectedPlugin };
|
|
@@ -45,7 +45,7 @@ const toJsonSafe = (input) => {
|
|
|
45
45
|
return void 0;
|
|
46
46
|
};
|
|
47
47
|
const isMetaRecord = (value) => typeof value === "object" && value !== null && !Array.isArray(value);
|
|
48
|
-
const metaPlugin = ({ hideWhenPublic = true } = {}) => import__.Error0.plugin().
|
|
48
|
+
const metaPlugin = ({ hideWhenPublic = true } = {}) => import__.Error0.plugin().prop("meta", {
|
|
49
49
|
init: (input) => input,
|
|
50
50
|
resolve: ({ flow }) => {
|
|
51
51
|
const values = flow.filter(isMetaRecord);
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"sources":["../../../src/plugins/meta.ts"],"sourcesContent":["import { Error0 } from '../index.js'\n\ntype Json = null | boolean | number | string | Json[] | { [key: string]: Json }\n\nconst toJsonSafe = (input: unknown): Json | undefined => {\n if (input === null) {\n return null\n }\n if (typeof input === 'string' || typeof input === 'number' || typeof input === 'boolean') {\n return input\n }\n if (Array.isArray(input)) {\n return input.map((value) => toJsonSafe(value)) as Json[]\n }\n if (typeof input === 'object') {\n const output: Record<string, Json> = {}\n for (const [key, value] of Object.entries(input as Record<string, unknown>)) {\n const jsonValue = toJsonSafe(value)\n if (jsonValue !== undefined) {\n output[key] = jsonValue\n }\n }\n return output\n }\n return undefined\n}\n\nconst isMetaRecord = (value: unknown): value is Record<string, unknown> =>\n typeof value === 'object' && value !== null && !Array.isArray(value)\n\nexport const metaPlugin = ({ hideWhenPublic = true }: { hideWhenPublic?: boolean } = {}) =>\n Error0.plugin().
|
|
1
|
+
{"version":3,"sources":["../../../src/plugins/meta.ts"],"sourcesContent":["import { Error0 } from '../index.js'\n\ntype Json = null | boolean | number | string | Json[] | { [key: string]: Json }\n\nconst toJsonSafe = (input: unknown): Json | undefined => {\n if (input === null) {\n return null\n }\n if (typeof input === 'string' || typeof input === 'number' || typeof input === 'boolean') {\n return input\n }\n if (Array.isArray(input)) {\n return input.map((value) => toJsonSafe(value)) as Json[]\n }\n if (typeof input === 'object') {\n const output: Record<string, Json> = {}\n for (const [key, value] of Object.entries(input as Record<string, unknown>)) {\n const jsonValue = toJsonSafe(value)\n if (jsonValue !== undefined) {\n output[key] = jsonValue\n }\n }\n return output\n }\n return undefined\n}\n\nconst isMetaRecord = (value: unknown): value is Record<string, unknown> =>\n typeof value === 'object' && value !== null && !Array.isArray(value)\n\nexport const metaPlugin = ({ hideWhenPublic = true }: { hideWhenPublic?: boolean } = {}) =>\n Error0.plugin().prop('meta', {\n init: (input: Record<string, unknown>) => input,\n resolve: ({ flow }) => {\n const values = flow.filter(isMetaRecord)\n if (values.length === 0) {\n return undefined\n }\n\n // Merge cause meta into the current error; nearer errors win on conflicts.\n const merged: Record<string, unknown> = {}\n for (const value of [...values].reverse()) {\n Object.assign(merged, value)\n }\n return merged\n },\n serialize: ({ resolved, isPublic }) => {\n if (hideWhenPublic && isPublic) {\n return undefined\n }\n return toJsonSafe(resolved)\n },\n deserialize: ({ value }) => {\n if (!isMetaRecord(value)) {\n return undefined\n }\n return value\n },\n })\n"],"mappings":";;;;;;;;;;;;;;;;;;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA,eAAuB;AAIvB,MAAM,aAAa,CAAC,UAAqC;AACvD,MAAI,UAAU,MAAM;AAClB,WAAO;AAAA,EACT;AACA,MAAI,OAAO,UAAU,YAAY,OAAO,UAAU,YAAY,OAAO,UAAU,WAAW;AACxF,WAAO;AAAA,EACT;AACA,MAAI,MAAM,QAAQ,KAAK,GAAG;AACxB,WAAO,MAAM,IAAI,CAAC,UAAU,WAAW,KAAK,CAAC;AAAA,EAC/C;AACA,MAAI,OAAO,UAAU,UAAU;AAC7B,UAAM,SAA+B,CAAC;AACtC,eAAW,CAAC,KAAK,KAAK,KAAK,OAAO,QAAQ,KAAgC,GAAG;AAC3E,YAAM,YAAY,WAAW,KAAK;AAClC,UAAI,cAAc,QAAW;AAC3B,eAAO,GAAG,IAAI;AAAA,MAChB;AAAA,IACF;AACA,WAAO;AAAA,EACT;AACA,SAAO;AACT;AAEA,MAAM,eAAe,CAAC,UACpB,OAAO,UAAU,YAAY,UAAU,QAAQ,CAAC,MAAM,QAAQ,KAAK;AAE9D,MAAM,aAAa,CAAC,EAAE,iBAAiB,KAAK,IAAkC,CAAC,MACpF,gBAAO,OAAO,EAAE,KAAK,QAAQ;AAAA,EAC3B,MAAM,CAAC,UAAmC;AAAA,EAC1C,SAAS,CAAC,EAAE,KAAK,MAAM;AACrB,UAAM,SAAS,KAAK,OAAO,YAAY;AACvC,QAAI,OAAO,WAAW,GAAG;AACvB,aAAO;AAAA,IACT;AAGA,UAAM,SAAkC,CAAC;AACzC,eAAW,SAAS,CAAC,GAAG,MAAM,EAAE,QAAQ,GAAG;AACzC,aAAO,OAAO,QAAQ,KAAK;AAAA,IAC7B;AACA,WAAO;AAAA,EACT;AAAA,EACA,WAAW,CAAC,EAAE,UAAU,SAAS,MAAM;AACrC,QAAI,kBAAkB,UAAU;AAC9B,aAAO;AAAA,IACT;AACA,WAAO,WAAW,QAAQ;AAAA,EAC5B;AAAA,EACA,aAAa,CAAC,EAAE,MAAM,MAAM;AAC1B,QAAI,CAAC,aAAa,KAAK,GAAG;AACxB,aAAO;AAAA,IACT;AACA,WAAO;AAAA,EACT;AACF,CAAC;","names":[]}
|
|
@@ -25,7 +25,7 @@ var import__ = require('../index.cjs');
|
|
|
25
25
|
const stackMergePlugin = ({
|
|
26
26
|
hideWhenPublic = true,
|
|
27
27
|
delimiter = "\n"
|
|
28
|
-
} = {}) => import__.Error0.plugin().
|
|
28
|
+
} = {}) => import__.Error0.plugin().stack({
|
|
29
29
|
serialize: ({ error, isPublic }) => {
|
|
30
30
|
if (hideWhenPublic && isPublic) {
|
|
31
31
|
return void 0;
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"sources":["../../../src/plugins/stack-merge.ts"],"sourcesContent":["import { Error0 } from '../index.js'\n\nexport const stackMergePlugin = ({\n hideWhenPublic = true,\n delimiter = '\\n',\n}: { hideWhenPublic?: boolean; delimiter?: string } = {}) =>\n Error0.plugin().
|
|
1
|
+
{"version":3,"sources":["../../../src/plugins/stack-merge.ts"],"sourcesContent":["import { Error0 } from '../index.js'\n\nexport const stackMergePlugin = ({\n hideWhenPublic = true,\n delimiter = '\\n',\n}: { hideWhenPublic?: boolean; delimiter?: string } = {}) =>\n Error0.plugin().stack({\n serialize: ({ error, isPublic }) => {\n if (hideWhenPublic && isPublic) {\n return undefined\n }\n return error\n .causes()\n .map((cause) => {\n return cause instanceof Error ? cause.stack : undefined\n })\n .filter((value): value is string => typeof value === 'string')\n .join(delimiter)\n },\n })\n"],"mappings":";;;;;;;;;;;;;;;;;;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA,eAAuB;AAEhB,MAAM,mBAAmB,CAAC;AAAA,EAC/B,iBAAiB;AAAA,EACjB,YAAY;AACd,IAAsD,CAAC,MACrD,gBAAO,OAAO,EAAE,MAAM;AAAA,EACpB,WAAW,CAAC,EAAE,OAAO,SAAS,MAAM;AAClC,QAAI,kBAAkB,UAAU;AAC9B,aAAO;AAAA,IACT;AACA,WAAO,MACJ,OAAO,EACP,IAAI,CAAC,UAAU;AACd,aAAO,iBAAiB,QAAQ,MAAM,QAAQ;AAAA,IAChD,CAAC,EACA,OAAO,CAAC,UAA2B,OAAO,UAAU,QAAQ,EAC5D,KAAK,SAAS;AAAA,EACnB;AACF,CAAC;","names":[]}
|
|
@@ -0,0 +1,54 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
var __defProp = Object.defineProperty;
|
|
3
|
+
var __getOwnPropDesc = Object.getOwnPropertyDescriptor;
|
|
4
|
+
var __getOwnPropNames = Object.getOwnPropertyNames;
|
|
5
|
+
var __hasOwnProp = Object.prototype.hasOwnProperty;
|
|
6
|
+
var __export = (target, all) => {
|
|
7
|
+
for (var name in all)
|
|
8
|
+
__defProp(target, name, { get: all[name], enumerable: true });
|
|
9
|
+
};
|
|
10
|
+
var __copyProps = (to, from, except, desc) => {
|
|
11
|
+
if (from && typeof from === "object" || typeof from === "function") {
|
|
12
|
+
for (let key of __getOwnPropNames(from))
|
|
13
|
+
if (!__hasOwnProp.call(to, key) && key !== except)
|
|
14
|
+
__defProp(to, key, { get: () => from[key], enumerable: !(desc = __getOwnPropDesc(from, key)) || desc.enumerable });
|
|
15
|
+
}
|
|
16
|
+
return to;
|
|
17
|
+
};
|
|
18
|
+
var __toCommonJS = (mod) => __copyProps(__defProp({}, "__esModule", { value: true }), mod);
|
|
19
|
+
var status_exports = {};
|
|
20
|
+
__export(status_exports, {
|
|
21
|
+
statusPlugin: () => statusPlugin
|
|
22
|
+
});
|
|
23
|
+
module.exports = __toCommonJS(status_exports);
|
|
24
|
+
var import__ = require('../index.cjs');
|
|
25
|
+
const statusPlugin = ({
|
|
26
|
+
statuses,
|
|
27
|
+
strict = false
|
|
28
|
+
} = {}) => {
|
|
29
|
+
const statusValues = statuses ? Object.values(statuses) : void 0;
|
|
30
|
+
const isStatusValue = (value) => typeof value === "number" && (!statusValues || !strict || statusValues.includes(value));
|
|
31
|
+
const normalizeStatusValue = (value) => {
|
|
32
|
+
return isStatusValue(value) ? value : void 0;
|
|
33
|
+
};
|
|
34
|
+
const convertStatusValue = (value) => {
|
|
35
|
+
if (typeof value === "number") {
|
|
36
|
+
return normalizeStatusValue(value);
|
|
37
|
+
}
|
|
38
|
+
if (statuses && value in statuses) {
|
|
39
|
+
return statuses[value];
|
|
40
|
+
}
|
|
41
|
+
return void 0;
|
|
42
|
+
};
|
|
43
|
+
return import__.Error0.plugin().prop("status", {
|
|
44
|
+
init: (status) => convertStatusValue(status),
|
|
45
|
+
resolve: ({ flow }) => flow.find(Boolean),
|
|
46
|
+
serialize: ({ resolved }) => resolved,
|
|
47
|
+
deserialize: ({ value }) => typeof value === "number" ? value : void 0
|
|
48
|
+
});
|
|
49
|
+
};
|
|
50
|
+
// Annotate the CommonJS export names for ESM import in node:
|
|
51
|
+
0 && (module.exports = {
|
|
52
|
+
statusPlugin
|
|
53
|
+
});
|
|
54
|
+
//# sourceMappingURL=status.cjs.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"sources":["../../../src/plugins/status.ts"],"sourcesContent":["import { Error0 } from '../index.js'\n\nexport const statusPlugin = <TStatuses extends Record<string, number> = Record<never, number>>({\n statuses,\n strict = false,\n}: { statuses?: TStatuses; strict?: boolean } = {}) => {\n const statusValues = statuses ? Object.values(statuses) : undefined\n const isStatusValue = (value: unknown): value is number =>\n typeof value === 'number' && (!statusValues || !strict || statusValues.includes(value))\n const normalizeStatusValue = (value: unknown): number | undefined => {\n return isStatusValue(value) ? value : undefined\n }\n const convertStatusValue = (value: number | string): number | undefined => {\n if (typeof value === 'number') {\n return normalizeStatusValue(value)\n }\n if (statuses && value in statuses) {\n return statuses[value as keyof TStatuses]\n }\n return undefined\n }\n\n return Error0.plugin().prop('status', {\n init: (status: number | Extract<keyof TStatuses, string>) => convertStatusValue(status),\n resolve: ({ flow }) => flow.find(Boolean),\n serialize: ({ resolved }) => resolved,\n deserialize: ({ value }) => (typeof value === 'number' ? value : undefined),\n })\n}\n"],"mappings":";;;;;;;;;;;;;;;;;;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA,eAAuB;AAEhB,MAAM,eAAe,CAAmE;AAAA,EAC7F;AAAA,EACA,SAAS;AACX,IAAgD,CAAC,MAAM;AACrD,QAAM,eAAe,WAAW,OAAO,OAAO,QAAQ,IAAI;AAC1D,QAAM,gBAAgB,CAAC,UACrB,OAAO,UAAU,aAAa,CAAC,gBAAgB,CAAC,UAAU,aAAa,SAAS,KAAK;AACvF,QAAM,uBAAuB,CAAC,UAAuC;AACnE,WAAO,cAAc,KAAK,IAAI,QAAQ;AAAA,EACxC;AACA,QAAM,qBAAqB,CAAC,UAA+C;AACzE,QAAI,OAAO,UAAU,UAAU;AAC7B,aAAO,qBAAqB,KAAK;AAAA,IACnC;AACA,QAAI,YAAY,SAAS,UAAU;AACjC,aAAO,SAAS,KAAwB;AAAA,IAC1C;AACA,WAAO;AAAA,EACT;AAEA,SAAO,gBAAO,OAAO,EAAE,KAAK,UAAU;AAAA,IACpC,MAAM,CAAC,WAAsD,mBAAmB,MAAM;AAAA,IACtF,SAAS,CAAC,EAAE,KAAK,MAAM,KAAK,KAAK,OAAO;AAAA,IACxC,WAAW,CAAC,EAAE,SAAS,MAAM;AAAA,IAC7B,aAAa,CAAC,EAAE,MAAM,MAAO,OAAO,UAAU,WAAW,QAAQ;AAAA,EACnE,CAAC;AACH;","names":[]}
|
|
@@ -0,0 +1,8 @@
|
|
|
1
|
+
import { PluginError0, ErrorPluginPropOptions, Error0 } from '../index.cjs';
|
|
2
|
+
|
|
3
|
+
declare const statusPlugin: <TStatuses extends Record<string, number> = Record<never, number>>({ statuses, strict, }?: {
|
|
4
|
+
statuses?: TStatuses;
|
|
5
|
+
strict?: boolean;
|
|
6
|
+
}) => PluginError0<Record<never, never> & Record<"status", ErrorPluginPropOptions<number | Extract<keyof TStatuses, string>, number | undefined, Error0, number | undefined>>, Record<never, never>>;
|
|
7
|
+
|
|
8
|
+
export { statusPlugin };
|
|
@@ -22,30 +22,50 @@ __export(tags_exports, {
|
|
|
22
22
|
});
|
|
23
23
|
module.exports = __toCommonJS(tags_exports);
|
|
24
24
|
var import__ = require('../index.cjs');
|
|
25
|
-
const tagsPlugin = ({
|
|
26
|
-
|
|
27
|
-
|
|
28
|
-
|
|
29
|
-
|
|
30
|
-
|
|
31
|
-
|
|
32
|
-
|
|
33
|
-
|
|
34
|
-
return merged.length > 0 ? Array.from(new Set(merged)) : void 0;
|
|
35
|
-
},
|
|
36
|
-
serialize: ({ resolved, isPublic }) => {
|
|
37
|
-
if (hideWhenPublic && isPublic) {
|
|
38
|
-
return void 0;
|
|
25
|
+
const tagsPlugin = ({
|
|
26
|
+
hideWhenPublic = true,
|
|
27
|
+
tags,
|
|
28
|
+
strict = true
|
|
29
|
+
} = {}) => {
|
|
30
|
+
function hasTag(error, tag, policy) {
|
|
31
|
+
const tags2 = error.tags;
|
|
32
|
+
if (!tags2) {
|
|
33
|
+
return false;
|
|
39
34
|
}
|
|
40
|
-
|
|
41
|
-
|
|
42
|
-
|
|
43
|
-
|
|
44
|
-
return
|
|
35
|
+
if (Array.isArray(tag)) {
|
|
36
|
+
if (policy === "every") {
|
|
37
|
+
return tag.every((item) => tags2.includes(item));
|
|
38
|
+
}
|
|
39
|
+
return tag.some((item) => tags2.includes(item));
|
|
45
40
|
}
|
|
46
|
-
return
|
|
41
|
+
return tags2.includes(tag);
|
|
47
42
|
}
|
|
48
|
-
|
|
43
|
+
const isTag = (value) => typeof value === "string" && (!tags || !strict || tags.includes(value));
|
|
44
|
+
return import__.Error0.plugin().prop("tags", {
|
|
45
|
+
init: (input) => input,
|
|
46
|
+
resolve: ({ flow }) => {
|
|
47
|
+
const merged = [];
|
|
48
|
+
for (const value of flow) {
|
|
49
|
+
if (Array.isArray(value)) {
|
|
50
|
+
merged.push(...value);
|
|
51
|
+
}
|
|
52
|
+
}
|
|
53
|
+
return merged.length > 0 ? Array.from(new Set(merged)) : void 0;
|
|
54
|
+
},
|
|
55
|
+
serialize: ({ resolved, isPublic }) => {
|
|
56
|
+
if (hideWhenPublic && isPublic) {
|
|
57
|
+
return void 0;
|
|
58
|
+
}
|
|
59
|
+
return resolved;
|
|
60
|
+
},
|
|
61
|
+
deserialize: ({ value }) => {
|
|
62
|
+
if (!Array.isArray(value)) {
|
|
63
|
+
return void 0;
|
|
64
|
+
}
|
|
65
|
+
return value.filter((item) => isTag(item));
|
|
66
|
+
}
|
|
67
|
+
}).method("hasTag", hasTag);
|
|
68
|
+
};
|
|
49
69
|
// Annotate the CommonJS export names for ESM import in node:
|
|
50
70
|
0 && (module.exports = {
|
|
51
71
|
tagsPlugin
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"sources":["../../../src/plugins/tags.ts"],"sourcesContent":["import { Error0 } from '../index.js'\n\nexport const tagsPlugin = ({
|
|
1
|
+
{"version":3,"sources":["../../../src/plugins/tags.ts"],"sourcesContent":["import { Error0 } from '../index.js'\n\nexport const tagsPlugin = <TTag extends string>({\n hideWhenPublic = true,\n tags,\n strict = true,\n}: { hideWhenPublic?: boolean; tags?: TTag[] | readonly TTag[]; strict?: boolean } = {}) => {\n function hasTag(error: Error0, tag: TTag): boolean\n function hasTag(error: Error0, tag: TTag[], policy: 'every' | 'some'): boolean\n function hasTag(error: Error0, tag: TTag | TTag[], policy?: 'every' | 'some'): boolean {\n const tags = (error as any).tags as string[] | undefined\n if (!tags) {\n return false\n }\n if (Array.isArray(tag)) {\n if (policy === 'every') {\n return tag.every((item) => tags.includes(item))\n }\n return tag.some((item) => tags.includes(item))\n }\n return tags.includes(tag)\n }\n const isTag = (value: unknown): value is TTag =>\n typeof value === 'string' && (!tags || !strict || tags.includes(value as TTag))\n return Error0.plugin()\n .prop('tags', {\n init: (input: string[]) => input,\n resolve: ({ flow }) => {\n const merged: string[] = []\n for (const value of flow) {\n if (Array.isArray(value)) {\n merged.push(...value)\n }\n }\n return merged.length > 0 ? Array.from(new Set(merged)) : undefined\n },\n serialize: ({ resolved, isPublic }) => {\n if (hideWhenPublic && isPublic) {\n return undefined\n }\n return resolved\n },\n deserialize: ({ value }) => {\n if (!Array.isArray(value)) {\n return undefined\n }\n return value.filter((item) => isTag(item))\n },\n })\n .method('hasTag', hasTag)\n}\n"],"mappings":";;;;;;;;;;;;;;;;;;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA,eAAuB;AAEhB,MAAM,aAAa,CAAsB;AAAA,EAC9C,iBAAiB;AAAA,EACjB;AAAA,EACA,SAAS;AACX,IAAqF,CAAC,MAAM;AAG1F,WAAS,OAAO,OAAe,KAAoB,QAAoC;AACrF,UAAMA,QAAQ,MAAc;AAC5B,QAAI,CAACA,OAAM;AACT,aAAO;AAAA,IACT;AACA,QAAI,MAAM,QAAQ,GAAG,GAAG;AACtB,UAAI,WAAW,SAAS;AACtB,eAAO,IAAI,MAAM,CAAC,SAASA,MAAK,SAAS,IAAI,CAAC;AAAA,MAChD;AACA,aAAO,IAAI,KAAK,CAAC,SAASA,MAAK,SAAS,IAAI,CAAC;AAAA,IAC/C;AACA,WAAOA,MAAK,SAAS,GAAG;AAAA,EAC1B;AACA,QAAM,QAAQ,CAAC,UACb,OAAO,UAAU,aAAa,CAAC,QAAQ,CAAC,UAAU,KAAK,SAAS,KAAa;AAC/E,SAAO,gBAAO,OAAO,EAClB,KAAK,QAAQ;AAAA,IACZ,MAAM,CAAC,UAAoB;AAAA,IAC3B,SAAS,CAAC,EAAE,KAAK,MAAM;AACrB,YAAM,SAAmB,CAAC;AAC1B,iBAAW,SAAS,MAAM;AACxB,YAAI,MAAM,QAAQ,KAAK,GAAG;AACxB,iBAAO,KAAK,GAAG,KAAK;AAAA,QACtB;AAAA,MACF;AACA,aAAO,OAAO,SAAS,IAAI,MAAM,KAAK,IAAI,IAAI,MAAM,CAAC,IAAI;AAAA,IAC3D;AAAA,IACA,WAAW,CAAC,EAAE,UAAU,SAAS,MAAM;AACrC,UAAI,kBAAkB,UAAU;AAC9B,eAAO;AAAA,MACT;AACA,aAAO;AAAA,IACT;AAAA,IACA,aAAa,CAAC,EAAE,MAAM,MAAM;AAC1B,UAAI,CAAC,MAAM,QAAQ,KAAK,GAAG;AACzB,eAAO;AAAA,MACT;AACA,aAAO,MAAM,OAAO,CAAC,SAAS,MAAM,IAAI,CAAC;AAAA,IAC3C;AAAA,EACF,CAAC,EACA,OAAO,UAAU,MAAM;AAC5B;","names":["tags"]}
|
|
@@ -1,7 +1,12 @@
|
|
|
1
1
|
import { PluginError0, ErrorPluginPropOptions, Error0 } from '../index.cjs';
|
|
2
2
|
|
|
3
|
-
declare const tagsPlugin: ({ hideWhenPublic }?: {
|
|
3
|
+
declare const tagsPlugin: <TTag extends string>({ hideWhenPublic, tags, strict, }?: {
|
|
4
4
|
hideWhenPublic?: boolean;
|
|
5
|
-
|
|
5
|
+
tags?: TTag[] | readonly TTag[];
|
|
6
|
+
strict?: boolean;
|
|
7
|
+
}) => PluginError0<Record<never, never> & Record<"tags", ErrorPluginPropOptions<string[], string[], Error0, string[] | undefined>>, Record<never, never> & Record<"hasTag", {
|
|
8
|
+
(error: Error0, tag: TTag): boolean;
|
|
9
|
+
(error: Error0, tag: TTag[], policy: "every" | "some"): boolean;
|
|
10
|
+
}>>;
|
|
6
11
|
|
|
7
12
|
export { tagsPlugin };
|
package/dist/esm/index.d.ts
CHANGED
|
@@ -36,6 +36,7 @@ type ErrorPluginPropOptionsWithoutInit<TOutputValue, TError extends Error0, TRes
|
|
|
36
36
|
};
|
|
37
37
|
type ErrorPluginPropOptions<TInputValue = undefined, TOutputValue = unknown, TError extends Error0 = Error0, TResolveValue extends TOutputValue | undefined = TOutputValue | undefined> = ErrorPluginPropOptionsWithInit<TInputValue, TOutputValue, TError, TResolveValue> | ErrorPluginPropOptionsWithoutInit<TOutputValue, TError, TResolveValue>;
|
|
38
38
|
type ErrorPluginMethodFn<TOutputValue, TArgs extends unknown[] = unknown[], TError extends Error0 = Error0> = (error: TError, ...args: TArgs) => TOutputValue;
|
|
39
|
+
type ErrorPluginAnyMethodFn = (error: any, ...args: any[]) => any;
|
|
39
40
|
type ErrorPluginAdaptResult<TOutputProps extends Record<string, unknown>> = Partial<TOutputProps> | undefined;
|
|
40
41
|
type ErrorPluginAdaptFn<TError extends Error0 = Error0, TOutputProps extends Record<string, unknown> = Record<never, never>> = ((error: TError) => void) | ((error: TError) => ErrorPluginAdaptResult<TOutputProps>);
|
|
41
42
|
type ErrorPluginStackSerialize<TError extends Error0> = (options: {
|
|
@@ -63,14 +64,13 @@ type ErrorPluginMessage<TError extends Error0 = Error0> = {
|
|
|
63
64
|
serialize: ErrorPluginMessageSerialize<TError>;
|
|
64
65
|
};
|
|
65
66
|
type ErrorMethodRecord = {
|
|
66
|
-
|
|
67
|
-
output: unknown;
|
|
67
|
+
fn: ErrorPluginAnyMethodFn;
|
|
68
68
|
};
|
|
69
69
|
type ErrorPluginProps = {
|
|
70
70
|
[key: string]: ErrorPluginPropOptions<any, any>;
|
|
71
71
|
};
|
|
72
72
|
type ErrorPluginMethods = {
|
|
73
|
-
[key: string]:
|
|
73
|
+
[key: string]: ErrorPluginAnyMethodFn;
|
|
74
74
|
};
|
|
75
75
|
type ErrorPlugin<TProps extends ErrorPluginProps = Record<never, never>, TMethods extends ErrorPluginMethods = Record<never, never>> = {
|
|
76
76
|
props?: TProps;
|
|
@@ -81,7 +81,7 @@ type ErrorPlugin<TProps extends ErrorPluginProps = Record<never, never>, TMethod
|
|
|
81
81
|
message?: ErrorPluginMessage;
|
|
82
82
|
};
|
|
83
83
|
type AddPropToPluginProps<TProps extends ErrorPluginProps, TKey extends string, TInputValue, TOutputValue, TResolveValue extends TOutputValue | undefined = TOutputValue | undefined> = TProps & Record<TKey, ErrorPluginPropOptions<TInputValue, TOutputValue, Error0, TResolveValue>>;
|
|
84
|
-
type AddMethodToPluginMethods<TMethods extends ErrorPluginMethods, TKey extends string,
|
|
84
|
+
type AddMethodToPluginMethods<TMethods extends ErrorPluginMethods, TKey extends string, TMethod extends ErrorPluginAnyMethodFn> = TMethods & Record<TKey, TMethod>;
|
|
85
85
|
type PluginOutputProps<TProps extends ErrorPluginProps> = {
|
|
86
86
|
[TKey in keyof TProps]: TProps[TKey] extends ErrorPluginPropOptions<any, any, any, infer TResolveValue> ? TResolveValue : never;
|
|
87
87
|
};
|
|
@@ -117,18 +117,62 @@ type ErrorOwnMethods<TPluginsMap extends ErrorPluginsMap> = {
|
|
|
117
117
|
type ErrorResolveMethods<TPluginsMap extends ErrorPluginsMap> = {
|
|
118
118
|
resolve: () => ErrorResolvedProps<TPluginsMap>;
|
|
119
119
|
};
|
|
120
|
+
type BindInstanceMethod<TMethod> = TMethod extends {
|
|
121
|
+
(error: any, ...args: infer TArgs1): infer TOutput1;
|
|
122
|
+
(error: any, ...args: infer TArgs2): infer TOutput2;
|
|
123
|
+
(error: any, ...args: infer TArgs3): infer TOutput3;
|
|
124
|
+
(error: any, ...args: infer TArgs4): infer TOutput4;
|
|
125
|
+
} ? {
|
|
126
|
+
(...args: TArgs1): TOutput1;
|
|
127
|
+
(...args: TArgs2): TOutput2;
|
|
128
|
+
(...args: TArgs3): TOutput3;
|
|
129
|
+
(...args: TArgs4): TOutput4;
|
|
130
|
+
} : TMethod extends {
|
|
131
|
+
(error: any, ...args: infer TArgs1): infer TOutput1;
|
|
132
|
+
(error: any, ...args: infer TArgs2): infer TOutput2;
|
|
133
|
+
(error: any, ...args: infer TArgs3): infer TOutput3;
|
|
134
|
+
} ? {
|
|
135
|
+
(...args: TArgs1): TOutput1;
|
|
136
|
+
(...args: TArgs2): TOutput2;
|
|
137
|
+
(...args: TArgs3): TOutput3;
|
|
138
|
+
} : TMethod extends {
|
|
139
|
+
(error: any, ...args: infer TArgs1): infer TOutput1;
|
|
140
|
+
(error: any, ...args: infer TArgs2): infer TOutput2;
|
|
141
|
+
} ? {
|
|
142
|
+
(...args: TArgs1): TOutput1;
|
|
143
|
+
(...args: TArgs2): TOutput2;
|
|
144
|
+
} : TMethod extends (error: any, ...args: infer TArgs) => infer TOutput ? (...args: TArgs) => TOutput : never;
|
|
145
|
+
type BindStaticMethod<TMethod> = TMethod extends {
|
|
146
|
+
(error: any, ...args: infer TArgs1): infer TOutput1;
|
|
147
|
+
(error: any, ...args: infer TArgs2): infer TOutput2;
|
|
148
|
+
(error: any, ...args: infer TArgs3): infer TOutput3;
|
|
149
|
+
(error: any, ...args: infer TArgs4): infer TOutput4;
|
|
150
|
+
} ? {
|
|
151
|
+
(error: unknown, ...args: TArgs1): TOutput1;
|
|
152
|
+
(error: unknown, ...args: TArgs2): TOutput2;
|
|
153
|
+
(error: unknown, ...args: TArgs3): TOutput3;
|
|
154
|
+
(error: unknown, ...args: TArgs4): TOutput4;
|
|
155
|
+
} : TMethod extends {
|
|
156
|
+
(error: any, ...args: infer TArgs1): infer TOutput1;
|
|
157
|
+
(error: any, ...args: infer TArgs2): infer TOutput2;
|
|
158
|
+
(error: any, ...args: infer TArgs3): infer TOutput3;
|
|
159
|
+
} ? {
|
|
160
|
+
(error: unknown, ...args: TArgs1): TOutput1;
|
|
161
|
+
(error: unknown, ...args: TArgs2): TOutput2;
|
|
162
|
+
(error: unknown, ...args: TArgs3): TOutput3;
|
|
163
|
+
} : TMethod extends {
|
|
164
|
+
(error: any, ...args: infer TArgs1): infer TOutput1;
|
|
165
|
+
(error: any, ...args: infer TArgs2): infer TOutput2;
|
|
166
|
+
} ? {
|
|
167
|
+
(error: unknown, ...args: TArgs1): TOutput1;
|
|
168
|
+
(error: unknown, ...args: TArgs2): TOutput2;
|
|
169
|
+
} : TMethod extends (error: any, ...args: infer TArgs) => infer TOutput ? (error: unknown, ...args: TArgs) => TOutput : never;
|
|
120
170
|
type ErrorMethods<TPluginsMap extends ErrorPluginsMap> = {
|
|
121
|
-
[TKey in keyof TPluginsMap['methods']]: TPluginsMap['methods'][TKey]
|
|
122
|
-
args: infer TArgs extends unknown[];
|
|
123
|
-
output: infer TOutput;
|
|
124
|
-
} ? (...args: TArgs) => TOutput : never;
|
|
171
|
+
[TKey in keyof TPluginsMap['methods']]: BindInstanceMethod<TPluginsMap['methods'][TKey]['fn']>;
|
|
125
172
|
};
|
|
126
173
|
type ErrorResolved<TPluginsMap extends ErrorPluginsMap> = ErrorResolvedProps<TPluginsMap> & ErrorMethods<TPluginsMap>;
|
|
127
174
|
type ErrorStaticMethods<TPluginsMap extends ErrorPluginsMap> = {
|
|
128
|
-
[TKey in keyof TPluginsMap['methods']]: TPluginsMap['methods'][TKey]
|
|
129
|
-
args: infer TArgs extends unknown[];
|
|
130
|
-
output: infer TOutput;
|
|
131
|
-
} ? (error: unknown, ...args: TArgs) => TOutput : never;
|
|
175
|
+
[TKey in keyof TPluginsMap['methods']]: BindStaticMethod<TPluginsMap['methods'][TKey]['fn']>;
|
|
132
176
|
};
|
|
133
177
|
type EmptyPluginsMap = {
|
|
134
178
|
props: Record<never, {
|
|
@@ -157,10 +201,9 @@ type PluginPropsMapOf<TPlugin extends ErrorPlugin> = {
|
|
|
157
201
|
} : never;
|
|
158
202
|
};
|
|
159
203
|
type PluginMethodsMapOf<TPlugin extends ErrorPlugin> = {
|
|
160
|
-
[TKey in keyof NonNullable<TPlugin['methods']>]:
|
|
161
|
-
|
|
162
|
-
|
|
163
|
-
} : never;
|
|
204
|
+
[TKey in keyof NonNullable<TPlugin['methods']>]: {
|
|
205
|
+
fn: NonNullable<TPlugin['methods']>[TKey] extends ErrorPluginAnyMethodFn ? NonNullable<TPlugin['methods']>[TKey] : never;
|
|
206
|
+
};
|
|
164
207
|
};
|
|
165
208
|
type ErrorPluginsMapOfPlugin<TPlugin extends ErrorPlugin> = {
|
|
166
209
|
props: PluginPropsMapOf<TPlugin>;
|
|
@@ -171,7 +214,7 @@ type ExtendErrorPluginsMap<TMap extends ErrorPluginsMap, TPlugin extends ErrorPl
|
|
|
171
214
|
methods: TMap['methods'] & ErrorPluginsMapOfPlugin<TPlugin>['methods'];
|
|
172
215
|
};
|
|
173
216
|
type ExtendErrorPluginsMapWithProp<TMap extends ErrorPluginsMap, TKey extends string, TInputValue, TOutputValue, TResolveValue extends TOutputValue | undefined = TOutputValue | undefined> = ExtendErrorPluginsMap<TMap, ErrorPlugin<Record<TKey, ErrorPluginPropOptions<TInputValue, TOutputValue, Error0, TResolveValue>>>>;
|
|
174
|
-
type ExtendErrorPluginsMapWithMethod<TMap extends ErrorPluginsMap, TKey extends string,
|
|
217
|
+
type ExtendErrorPluginsMapWithMethod<TMap extends ErrorPluginsMap, TKey extends string, TMethod extends ErrorPluginAnyMethodFn> = ExtendErrorPluginsMap<TMap, ErrorPlugin<Record<never, never>, Record<TKey, TMethod>>>;
|
|
175
218
|
type PluginsMapOf<TClass> = TClass extends {
|
|
176
219
|
__pluginsMap?: infer TPluginsMap;
|
|
177
220
|
} ? TPluginsMap extends ErrorPluginsMap ? TPluginsMap : EmptyPluginsMap : EmptyPluginsMap;
|
|
@@ -194,13 +237,13 @@ declare class PluginError0<TProps extends ErrorPluginProps = Record<never, never
|
|
|
194
237
|
};
|
|
195
238
|
constructor(plugin?: ErrorPlugin<ErrorPluginProps, ErrorPluginMethods>);
|
|
196
239
|
prop<TKey extends string, TInputValue = undefined, TOutputValue = unknown, TResolveValue extends TOutputValue | undefined = TOutputValue | undefined>(key: TKey, value: ErrorPluginPropOptions<TInputValue, TOutputValue, BuilderError0<TProps, TMethods>, TResolveValue>): PluginError0<AddPropToPluginProps<TProps, TKey, TInputValue, TOutputValue, TResolveValue>, TMethods>;
|
|
197
|
-
method<TKey extends string,
|
|
240
|
+
method<TKey extends string, TMethod extends (error: BuilderError0<TProps, TMethods>, ...args: any[]) => any>(key: TKey, value: TMethod): PluginError0<TProps, AddMethodToPluginMethods<TMethods, TKey, TMethod>>;
|
|
198
241
|
adapt(value: ErrorPluginAdaptFn<BuilderError0<TProps, TMethods>, PluginOutputProps<TProps>>): PluginError0<TProps, TMethods>;
|
|
199
242
|
stack(value: ErrorPluginStack<BuilderError0<TProps, TMethods>>): PluginError0<TProps, TMethods>;
|
|
200
243
|
cause(value: ErrorPluginCause<BuilderError0<TProps, TMethods>>): PluginError0<TProps, TMethods>;
|
|
201
244
|
message(value: ErrorPluginMessage<BuilderError0<TProps, TMethods>>): PluginError0<TProps, TMethods>;
|
|
202
245
|
use<TKey extends string, TInputValue = undefined, TOutputValue = unknown, TResolveValue extends TOutputValue | undefined = TOutputValue | undefined>(kind: 'prop', key: TKey, value: ErrorPluginPropOptions<TInputValue, TOutputValue, BuilderError0<TProps, TMethods>, TResolveValue>): PluginError0<AddPropToPluginProps<TProps, TKey, TInputValue, TOutputValue, TResolveValue>, TMethods>;
|
|
203
|
-
use<TKey extends string,
|
|
246
|
+
use<TKey extends string, TMethod extends (error: BuilderError0<TProps, TMethods>, ...args: any[]) => any>(kind: 'method', key: TKey, value: TMethod): PluginError0<TProps, AddMethodToPluginMethods<TMethods, TKey, TMethod>>;
|
|
204
247
|
use(kind: 'adapt', value: ErrorPluginAdaptFn<BuilderError0<TProps, TMethods>, PluginOutputProps<TProps>>): PluginError0<TProps, TMethods>;
|
|
205
248
|
use(kind: 'stack', value: ErrorPluginStack<BuilderError0<TProps, TMethods>>): PluginError0<TProps, TMethods>;
|
|
206
249
|
use(kind: 'cause', value: ErrorPluginCause<BuilderError0<TProps, TMethods>>): PluginError0<TProps, TMethods>;
|
|
@@ -233,7 +276,7 @@ type ClassError0<TPluginsMap extends ErrorPluginsMap = EmptyPluginsMap> = {
|
|
|
233
276
|
use: {
|
|
234
277
|
<TBuilder extends PluginError0>(plugin: TBuilder): ClassError0<ExtendErrorPluginsMap<TPluginsMap, PluginOfBuilder<TBuilder>>>;
|
|
235
278
|
<TKey extends string, TInputValue = undefined, TOutputValue = unknown, TResolveValue extends TOutputValue | undefined = TOutputValue | undefined>(kind: 'prop', key: TKey, value: ErrorPluginPropOptions<TInputValue, TOutputValue, ErrorInstanceOfMap<TPluginsMap>, TResolveValue>): ClassError0<ExtendErrorPluginsMapWithProp<TPluginsMap, TKey, TInputValue, TOutputValue, TResolveValue>>;
|
|
236
|
-
<TKey extends string,
|
|
279
|
+
<TKey extends string, TMethod extends (error: ErrorInstanceOfMap<TPluginsMap>, ...args: any[]) => any>(kind: 'method', key: TKey, value: TMethod): ClassError0<ExtendErrorPluginsMapWithMethod<TPluginsMap, TKey, TMethod>>;
|
|
237
280
|
(kind: 'adapt', value: ErrorPluginAdaptFn<ErrorInstanceOfMap<TPluginsMap>, ErrorResolvedProps<TPluginsMap>>): ClassError0<TPluginsMap>;
|
|
238
281
|
(kind: 'stack', value: ErrorPluginStack<ErrorInstanceOfMap<TPluginsMap>>): ClassError0<TPluginsMap>;
|
|
239
282
|
(kind: 'cause', value: ErrorPluginCause<ErrorInstanceOfMap<TPluginsMap>>): ClassError0<TPluginsMap>;
|
|
@@ -286,7 +329,7 @@ declare class Error0 extends Error {
|
|
|
286
329
|
private static _pluginFromBuilder;
|
|
287
330
|
static use<TThis extends typeof Error0, TBuilder extends PluginError0>(this: TThis, plugin: TBuilder): ClassError0<ExtendErrorPluginsMap<PluginsMapOf<TThis>, PluginOfBuilder<TBuilder>>>;
|
|
288
331
|
static use<TThis extends typeof Error0, TKey extends string, TInputValue = undefined, TOutputValue = unknown, TResolveValue extends TOutputValue | undefined = TOutputValue | undefined>(this: TThis, kind: 'prop', key: TKey, value: ErrorPluginPropOptions<TInputValue, TOutputValue, ErrorInstanceOfMap<PluginsMapOf<TThis>>, TResolveValue>): ClassError0<ExtendErrorPluginsMapWithProp<PluginsMapOf<TThis>, TKey, TInputValue, TOutputValue, TResolveValue>>;
|
|
289
|
-
static use<TThis extends typeof Error0, TKey extends string,
|
|
332
|
+
static use<TThis extends typeof Error0, TKey extends string, TMethod extends (error: ErrorInstanceOfMap<PluginsMapOf<TThis>>, ...args: any[]) => any>(this: TThis, kind: 'method', key: TKey, value: TMethod): ClassError0<ExtendErrorPluginsMapWithMethod<PluginsMapOf<TThis>, TKey, TMethod>>;
|
|
290
333
|
static use<TThis extends typeof Error0>(this: TThis, kind: 'adapt', value: ErrorPluginAdaptFn<ErrorInstanceOfMap<PluginsMapOf<TThis>>, ErrorResolvedProps<PluginsMapOf<TThis>>>): ClassError0<PluginsMapOf<TThis>>;
|
|
291
334
|
static use<TThis extends typeof Error0>(this: TThis, kind: 'stack', value: ErrorPluginStack<ErrorInstanceOfMap<PluginsMapOf<TThis>>>): ClassError0<PluginsMapOf<TThis>>;
|
|
292
335
|
static use<TThis extends typeof Error0>(this: TThis, kind: 'cause', value: ErrorPluginCause<ErrorInstanceOfMap<PluginsMapOf<TThis>>>): ClassError0<PluginsMapOf<TThis>>;
|
package/dist/esm/index.js
CHANGED
|
@@ -198,29 +198,17 @@ class Error0 extends Error {
|
|
|
198
198
|
}
|
|
199
199
|
static isOwnProperty = (object, key) => {
|
|
200
200
|
const ownStore = this._getOwnStore(object);
|
|
201
|
-
if (ownStore
|
|
202
|
-
return
|
|
203
|
-
}
|
|
204
|
-
const d = Object.getOwnPropertyDescriptor(object, key);
|
|
205
|
-
if (!d) return false;
|
|
206
|
-
if (typeof d.get === "function" || typeof d.set === "function") {
|
|
207
|
-
if ("name" in object && object.name === "Error0") {
|
|
208
|
-
return false;
|
|
209
|
-
} else {
|
|
210
|
-
return true;
|
|
211
|
-
}
|
|
201
|
+
if (ownStore) {
|
|
202
|
+
return Object.prototype.hasOwnProperty.call(ownStore, key);
|
|
212
203
|
}
|
|
213
|
-
return
|
|
204
|
+
return !!Object.getOwnPropertyDescriptor(object, key);
|
|
214
205
|
};
|
|
215
206
|
static _ownByKey(error, key) {
|
|
216
207
|
const ownStore = this._getOwnStore(error);
|
|
217
|
-
if (ownStore
|
|
208
|
+
if (ownStore) {
|
|
218
209
|
return ownStore[key];
|
|
219
210
|
}
|
|
220
|
-
|
|
221
|
-
return error[key];
|
|
222
|
-
}
|
|
223
|
-
return void 0;
|
|
211
|
+
return error[key];
|
|
224
212
|
}
|
|
225
213
|
static _flowByKey(error, key) {
|
|
226
214
|
const causes = this.causes(error, true);
|