@devp0nt/error0 1.0.0-next.45 → 1.0.0-next.47
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 +80 -64
- package/dist/cjs/index.cjs.map +1 -1
- package/dist/cjs/index.d.cts +32 -22
- package/dist/cjs/plugins/cause-serialize.cjs +38 -0
- package/dist/cjs/plugins/cause-serialize.cjs.map +1 -0
- package/dist/cjs/plugins/cause-serialize.d.cts +5 -0
- package/dist/cjs/plugins/expected.cjs +49 -0
- package/dist/cjs/plugins/expected.cjs.map +1 -0
- package/dist/cjs/plugins/expected.d.cts +5 -0
- package/dist/cjs/plugins/message-merge.cjs +36 -0
- package/dist/cjs/plugins/message-merge.cjs.map +1 -0
- package/dist/cjs/plugins/message-merge.d.cts +5 -0
- package/dist/cjs/plugins/meta.cjs +73 -0
- package/dist/cjs/plugins/meta.cjs.map +1 -0
- package/dist/cjs/plugins/meta.d.cts +5 -0
- package/dist/cjs/plugins/stack-merge.cjs +39 -0
- package/dist/cjs/plugins/stack-merge.cjs.map +1 -0
- package/dist/cjs/plugins/stack-merge.d.cts +5 -0
- package/dist/cjs/plugins/tags.cjs +48 -0
- package/dist/cjs/plugins/tags.cjs.map +1 -0
- package/dist/cjs/plugins/tags.d.cts +5 -0
- package/dist/esm/index.d.ts +32 -22
- package/dist/esm/index.js +80 -64
- package/dist/esm/index.js.map +1 -1
- package/dist/esm/plugins/cause-serialize.d.ts +5 -0
- package/dist/esm/plugins/cause-serialize.js +14 -0
- package/dist/esm/plugins/cause-serialize.js.map +1 -0
- package/dist/esm/plugins/expected.d.ts +5 -0
- package/dist/esm/plugins/expected.js +25 -0
- package/dist/esm/plugins/expected.js.map +1 -0
- package/dist/esm/plugins/message-merge.d.ts +5 -0
- package/dist/esm/plugins/message-merge.js +12 -0
- package/dist/esm/plugins/message-merge.js.map +1 -0
- package/dist/esm/plugins/meta.d.ts +5 -0
- package/dist/esm/plugins/meta.js +49 -0
- package/dist/esm/plugins/meta.js.map +1 -0
- package/dist/esm/plugins/stack-merge.d.ts +5 -0
- package/dist/esm/plugins/stack-merge.js +15 -0
- package/dist/esm/plugins/stack-merge.js.map +1 -0
- package/dist/esm/plugins/tags.d.ts +5 -0
- package/dist/esm/plugins/tags.js +24 -0
- package/dist/esm/plugins/tags.js.map +1 -0
- package/package.json +9 -1
- package/src/index.test.ts +77 -100
- package/src/index.ts +173 -120
- package/src/plugins/cause-serialize.test.ts +51 -0
- package/src/plugins/cause-serialize.ts +11 -0
- package/src/plugins/expected.test.ts +47 -0
- package/src/plugins/expected.ts +25 -0
- package/src/plugins/message-merge.test.ts +32 -0
- package/src/plugins/message-merge.ts +15 -0
- package/src/plugins/meta.test.ts +32 -0
- package/src/plugins/meta.ts +53 -0
- package/src/plugins/stack-merge.test.ts +64 -0
- package/src/plugins/stack-merge.ts +16 -0
- package/src/plugins/tags.test.ts +22 -0
- package/src/plugins/tags.ts +21 -0
package/dist/cjs/index.d.cts
CHANGED
|
@@ -34,18 +34,30 @@ type ErrorPluginPropOptions<TInputValue = undefined, TOutputValue = unknown, TEr
|
|
|
34
34
|
type ErrorPluginMethodFn<TOutputValue, TArgs extends unknown[] = unknown[], TError extends Error0 = Error0> = (error: TError, ...args: TArgs) => TOutputValue;
|
|
35
35
|
type ErrorPluginAdaptResult<TOutputProps extends Record<string, unknown>> = Partial<TOutputProps> | undefined;
|
|
36
36
|
type ErrorPluginAdaptFn<TError extends Error0 = Error0, TOutputProps extends Record<string, unknown> = Record<never, never>> = ((error: TError) => void) | ((error: TError) => ErrorPluginAdaptResult<TOutputProps>);
|
|
37
|
-
type ErrorPluginStackSerialize<TError extends Error0> = (
|
|
37
|
+
type ErrorPluginStackSerialize<TError extends Error0> = (options: {
|
|
38
38
|
value: string | undefined;
|
|
39
39
|
error: TError;
|
|
40
40
|
isPublic: boolean;
|
|
41
|
-
}) => unknown
|
|
42
|
-
type ErrorPluginStack<TError extends Error0 = Error0> =
|
|
43
|
-
|
|
41
|
+
}) => unknown;
|
|
42
|
+
type ErrorPluginStack<TError extends Error0 = Error0> = {
|
|
43
|
+
serialize: ErrorPluginStackSerialize<TError>;
|
|
44
|
+
};
|
|
45
|
+
type ErrorPluginCauseSerialize<TError extends Error0> = (options: {
|
|
44
46
|
value: unknown;
|
|
45
47
|
error: TError;
|
|
46
48
|
isPublic: boolean;
|
|
47
|
-
}) => unknown
|
|
48
|
-
type ErrorPluginCause<TError extends Error0 = Error0> =
|
|
49
|
+
}) => unknown;
|
|
50
|
+
type ErrorPluginCause<TError extends Error0 = Error0> = {
|
|
51
|
+
serialize: ErrorPluginCauseSerialize<TError>;
|
|
52
|
+
};
|
|
53
|
+
type ErrorPluginMessageSerialize<TError extends Error0> = (options: {
|
|
54
|
+
value: string;
|
|
55
|
+
error: TError;
|
|
56
|
+
isPublic: boolean;
|
|
57
|
+
}) => unknown;
|
|
58
|
+
type ErrorPluginMessage<TError extends Error0 = Error0> = {
|
|
59
|
+
serialize: ErrorPluginMessageSerialize<TError>;
|
|
60
|
+
};
|
|
49
61
|
type ErrorMethodRecord = {
|
|
50
62
|
args: unknown[];
|
|
51
63
|
output: unknown;
|
|
@@ -62,6 +74,7 @@ type ErrorPlugin<TProps extends ErrorPluginProps = Record<never, never>, TMethod
|
|
|
62
74
|
adapt?: Array<ErrorPluginAdaptFn<Error0, PluginOutputProps<TProps>>>;
|
|
63
75
|
stack?: ErrorPluginStack;
|
|
64
76
|
cause?: ErrorPluginCause;
|
|
77
|
+
message?: ErrorPluginMessage;
|
|
65
78
|
};
|
|
66
79
|
type AddPropToPluginProps<TProps extends ErrorPluginProps, TKey extends string, TInputValue, TOutputValue, TResolveValue extends TOutputValue | undefined = TOutputValue | undefined> = TProps & Record<TKey, ErrorPluginPropOptions<TInputValue, TOutputValue, Error0, TResolveValue>>;
|
|
67
80
|
type AddMethodToPluginMethods<TMethods extends ErrorPluginMethods, TKey extends string, TArgs extends unknown[], TOutputValue> = TMethods & Record<TKey, ErrorPluginMethodFn<TOutputValue, TArgs>>;
|
|
@@ -148,9 +161,7 @@ type PluginsMapOf<TClass> = TClass extends {
|
|
|
148
161
|
__pluginsMap?: infer TPluginsMap;
|
|
149
162
|
} ? TPluginsMap extends ErrorPluginsMap ? TPluginsMap : EmptyPluginsMap : EmptyPluginsMap;
|
|
150
163
|
type PluginsMapOfInstance<TInstance> = TInstance extends {
|
|
151
|
-
|
|
152
|
-
__pluginsMap?: infer TPluginsMap;
|
|
153
|
-
};
|
|
164
|
+
__pluginsMap?: infer TPluginsMap;
|
|
154
165
|
} ? TPluginsMap extends ErrorPluginsMap ? TPluginsMap : EmptyPluginsMap : EmptyPluginsMap;
|
|
155
166
|
type PluginsMapFromParts<TProps extends ErrorPluginProps, TMethods extends ErrorPluginMethods> = ErrorPluginsMapOfPlugin<ErrorPlugin<TProps, TMethods>>;
|
|
156
167
|
type ErrorInstanceOfMap<TMap extends ErrorPluginsMap> = Error0 & ErrorResolved<TMap>;
|
|
@@ -168,17 +179,23 @@ declare class PluginError0<TProps extends ErrorPluginProps = Record<never, never
|
|
|
168
179
|
adapt(value: ErrorPluginAdaptFn<BuilderError0<TProps, TMethods>, PluginOutputProps<TProps>>): PluginError0<TProps, TMethods>;
|
|
169
180
|
stack(value: ErrorPluginStack<BuilderError0<TProps, TMethods>>): PluginError0<TProps, TMethods>;
|
|
170
181
|
cause(value: ErrorPluginCause<BuilderError0<TProps, TMethods>>): PluginError0<TProps, TMethods>;
|
|
182
|
+
message(value: ErrorPluginMessage<BuilderError0<TProps, TMethods>>): PluginError0<TProps, TMethods>;
|
|
171
183
|
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>;
|
|
172
184
|
use<TKey extends string, TArgs extends unknown[], TOutputValue>(kind: 'method', key: TKey, value: ErrorPluginMethodFn<TOutputValue, TArgs, BuilderError0<TProps, TMethods>>): PluginError0<TProps, AddMethodToPluginMethods<TMethods, TKey, TArgs, TOutputValue>>;
|
|
173
185
|
use(kind: 'adapt', value: ErrorPluginAdaptFn<BuilderError0<TProps, TMethods>, PluginOutputProps<TProps>>): PluginError0<TProps, TMethods>;
|
|
174
186
|
use(kind: 'stack', value: ErrorPluginStack<BuilderError0<TProps, TMethods>>): PluginError0<TProps, TMethods>;
|
|
175
187
|
use(kind: 'cause', value: ErrorPluginCause<BuilderError0<TProps, TMethods>>): PluginError0<TProps, TMethods>;
|
|
188
|
+
use(kind: 'message', value: ErrorPluginMessage<BuilderError0<TProps, TMethods>>): PluginError0<TProps, TMethods>;
|
|
176
189
|
}
|
|
177
190
|
type ClassError0<TPluginsMap extends ErrorPluginsMap = EmptyPluginsMap> = {
|
|
178
|
-
new (message: string, input?: ErrorInput<TPluginsMap>): Error0 & ErrorResolved<TPluginsMap> & ErrorOwnMethods<TPluginsMap> & ErrorResolveMethods<TPluginsMap
|
|
191
|
+
new (message: string, input?: ErrorInput<TPluginsMap>): Error0 & ErrorResolved<TPluginsMap> & ErrorOwnMethods<TPluginsMap> & ErrorResolveMethods<TPluginsMap> & {
|
|
192
|
+
readonly __pluginsMap?: TPluginsMap;
|
|
193
|
+
};
|
|
179
194
|
new (input: {
|
|
180
195
|
message: string;
|
|
181
|
-
} & ErrorInput<TPluginsMap>): Error0 & ErrorResolved<TPluginsMap> & ErrorOwnMethods<TPluginsMap> & ErrorResolveMethods<TPluginsMap
|
|
196
|
+
} & ErrorInput<TPluginsMap>): Error0 & ErrorResolved<TPluginsMap> & ErrorOwnMethods<TPluginsMap> & ErrorResolveMethods<TPluginsMap> & {
|
|
197
|
+
readonly __pluginsMap?: TPluginsMap;
|
|
198
|
+
};
|
|
182
199
|
readonly __pluginsMap?: TPluginsMap;
|
|
183
200
|
from: (error: unknown) => Error0 & ErrorResolved<TPluginsMap> & ErrorOwnMethods<TPluginsMap> & ErrorResolveMethods<TPluginsMap>;
|
|
184
201
|
resolve: (error: unknown) => ErrorResolvedProps<TPluginsMap>;
|
|
@@ -188,11 +205,6 @@ type ClassError0<TPluginsMap extends ErrorPluginsMap = EmptyPluginsMap> = {
|
|
|
188
205
|
<TKey extends keyof TPluginsMap['props'] & string>(error: object, key: TKey): ErrorOwnProps<TPluginsMap>[TKey];
|
|
189
206
|
};
|
|
190
207
|
flow: <TKey extends keyof TPluginsMap['props'] & string>(error: object, key: TKey) => Array<ErrorOwnProps<TPluginsMap>[TKey]>;
|
|
191
|
-
prop: <TKey extends string, TInputValue = undefined, TOutputValue = unknown, TResolveValue extends TOutputValue | undefined = TOutputValue | undefined>(key: TKey, value: ErrorPluginPropOptions<TInputValue, TOutputValue, ErrorInstanceOfMap<TPluginsMap>, TResolveValue>) => ClassError0<ExtendErrorPluginsMapWithProp<TPluginsMap, TKey, TInputValue, TOutputValue, TResolveValue>>;
|
|
192
|
-
method: <TKey extends string, TArgs extends unknown[], TOutputValue>(key: TKey, value: ErrorPluginMethodFn<TOutputValue, TArgs, ErrorInstanceOfMap<TPluginsMap>>) => ClassError0<ExtendErrorPluginsMapWithMethod<TPluginsMap, TKey, TArgs, TOutputValue>>;
|
|
193
|
-
adapt: (value: ErrorPluginAdaptFn<ErrorInstanceOfMap<TPluginsMap>, ErrorResolvedProps<TPluginsMap>>) => ClassError0<TPluginsMap>;
|
|
194
|
-
stack: (value: ErrorPluginStack<ErrorInstanceOfMap<TPluginsMap>>) => ClassError0<TPluginsMap>;
|
|
195
|
-
cause: (value: ErrorPluginCause<ErrorInstanceOfMap<TPluginsMap>>) => ClassError0<TPluginsMap>;
|
|
196
208
|
use: {
|
|
197
209
|
<TBuilder extends PluginError0>(plugin: TBuilder): ClassError0<ExtendErrorPluginsMap<TPluginsMap, PluginOfBuilder<TBuilder>>>;
|
|
198
210
|
<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>>;
|
|
@@ -200,11 +212,13 @@ type ClassError0<TPluginsMap extends ErrorPluginsMap = EmptyPluginsMap> = {
|
|
|
200
212
|
(kind: 'adapt', value: ErrorPluginAdaptFn<ErrorInstanceOfMap<TPluginsMap>, ErrorResolvedProps<TPluginsMap>>): ClassError0<TPluginsMap>;
|
|
201
213
|
(kind: 'stack', value: ErrorPluginStack<ErrorInstanceOfMap<TPluginsMap>>): ClassError0<TPluginsMap>;
|
|
202
214
|
(kind: 'cause', value: ErrorPluginCause<ErrorInstanceOfMap<TPluginsMap>>): ClassError0<TPluginsMap>;
|
|
215
|
+
(kind: 'message', value: ErrorPluginMessage<ErrorInstanceOfMap<TPluginsMap>>): ClassError0<TPluginsMap>;
|
|
203
216
|
};
|
|
204
217
|
plugin: () => PluginError0;
|
|
205
218
|
} & ErrorStaticMethods<TPluginsMap>;
|
|
206
219
|
declare class Error0 extends Error {
|
|
207
220
|
static readonly __pluginsMap?: EmptyPluginsMap;
|
|
221
|
+
readonly __pluginsMap?: EmptyPluginsMap;
|
|
208
222
|
protected static _plugins: ErrorPlugin[];
|
|
209
223
|
private static readonly _emptyPlugin;
|
|
210
224
|
private static _getResolvedPlugin;
|
|
@@ -240,20 +254,16 @@ declare class Error0 extends Error {
|
|
|
240
254
|
private static _extractMessage;
|
|
241
255
|
private static _useWithPlugin;
|
|
242
256
|
private static _pluginFromBuilder;
|
|
243
|
-
static prop<TThis extends typeof Error0, TKey extends string, TInputValue = undefined, TOutputValue = unknown, TResolveValue extends TOutputValue | undefined = TOutputValue | undefined>(this: TThis, key: TKey, value: ErrorPluginPropOptions<TInputValue, TOutputValue, ErrorInstanceOfMap<PluginsMapOf<TThis>>, TResolveValue>): ClassError0<ExtendErrorPluginsMapWithProp<PluginsMapOf<TThis>, TKey, TInputValue, TOutputValue, TResolveValue>>;
|
|
244
|
-
static method<TThis extends typeof Error0, TKey extends string, TArgs extends unknown[], TOutputValue>(this: TThis, key: TKey, value: ErrorPluginMethodFn<TOutputValue, TArgs, ErrorInstanceOfMap<PluginsMapOf<TThis>>>): ClassError0<ExtendErrorPluginsMapWithMethod<PluginsMapOf<TThis>, TKey, TArgs, TOutputValue>>;
|
|
245
|
-
static adapt<TThis extends typeof Error0>(this: TThis, value: ErrorPluginAdaptFn<ErrorInstanceOfMap<PluginsMapOf<TThis>>, ErrorResolvedProps<PluginsMapOf<TThis>>>): ClassError0<PluginsMapOf<TThis>>;
|
|
246
|
-
static stack<TThis extends typeof Error0>(this: TThis, value: ErrorPluginStack<ErrorInstanceOfMap<PluginsMapOf<TThis>>>): ClassError0<PluginsMapOf<TThis>>;
|
|
247
|
-
static cause<TThis extends typeof Error0>(this: TThis, value: ErrorPluginCause<ErrorInstanceOfMap<PluginsMapOf<TThis>>>): ClassError0<PluginsMapOf<TThis>>;
|
|
248
257
|
static use<TThis extends typeof Error0, TBuilder extends PluginError0>(this: TThis, plugin: TBuilder): ClassError0<ExtendErrorPluginsMap<PluginsMapOf<TThis>, PluginOfBuilder<TBuilder>>>;
|
|
249
258
|
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>>;
|
|
250
259
|
static use<TThis extends typeof Error0, TKey extends string, TArgs extends unknown[], TOutputValue>(this: TThis, kind: 'method', key: TKey, value: ErrorPluginMethodFn<TOutputValue, TArgs, ErrorInstanceOfMap<PluginsMapOf<TThis>>>): ClassError0<ExtendErrorPluginsMapWithMethod<PluginsMapOf<TThis>, TKey, TArgs, TOutputValue>>;
|
|
251
260
|
static use<TThis extends typeof Error0>(this: TThis, kind: 'adapt', value: ErrorPluginAdaptFn<ErrorInstanceOfMap<PluginsMapOf<TThis>>, ErrorResolvedProps<PluginsMapOf<TThis>>>): ClassError0<PluginsMapOf<TThis>>;
|
|
252
261
|
static use<TThis extends typeof Error0>(this: TThis, kind: 'stack', value: ErrorPluginStack<ErrorInstanceOfMap<PluginsMapOf<TThis>>>): ClassError0<PluginsMapOf<TThis>>;
|
|
253
262
|
static use<TThis extends typeof Error0>(this: TThis, kind: 'cause', value: ErrorPluginCause<ErrorInstanceOfMap<PluginsMapOf<TThis>>>): ClassError0<PluginsMapOf<TThis>>;
|
|
263
|
+
static use<TThis extends typeof Error0>(this: TThis, kind: 'message', value: ErrorPluginMessage<ErrorInstanceOfMap<PluginsMapOf<TThis>>>): ClassError0<PluginsMapOf<TThis>>;
|
|
254
264
|
static plugin(): PluginError0;
|
|
255
265
|
static serialize(error: unknown, isPublic?: boolean): Record<string, unknown>;
|
|
256
266
|
serialize(isPublic?: boolean): Record<string, unknown>;
|
|
257
267
|
}
|
|
258
268
|
|
|
259
|
-
export { type ClassError0, Error0, type ErrorInput, type ErrorInputBase, type ErrorPlugin, type ErrorPluginAdaptFn, type ErrorPluginAdaptResult, type ErrorPluginCause, type ErrorPluginCauseSerialize, type ErrorPluginMethodFn, type ErrorPluginMethods, type ErrorPluginPropOptions, type ErrorPluginProps, type ErrorPluginStack, type ErrorPluginStackSerialize, type ErrorPluginsMap, type ErrorResolved, type IsEmptyObject, PluginError0 };
|
|
269
|
+
export { type ClassError0, Error0, type ErrorInput, type ErrorInputBase, type ErrorPlugin, type ErrorPluginAdaptFn, type ErrorPluginAdaptResult, type ErrorPluginCause, type ErrorPluginCauseSerialize, type ErrorPluginMessage, type ErrorPluginMessageSerialize, type ErrorPluginMethodFn, type ErrorPluginMethods, type ErrorPluginPropOptions, type ErrorPluginProps, type ErrorPluginStack, type ErrorPluginStackSerialize, type ErrorPluginsMap, type ErrorResolved, type IsEmptyObject, PluginError0 };
|
|
@@ -0,0 +1,38 @@
|
|
|
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 cause_serialize_exports = {};
|
|
20
|
+
__export(cause_serialize_exports, {
|
|
21
|
+
causeSerializePlugin: () => causeSerializePlugin
|
|
22
|
+
});
|
|
23
|
+
module.exports = __toCommonJS(cause_serialize_exports);
|
|
24
|
+
var import__ = require('../index.cjs');
|
|
25
|
+
const causeSerializePlugin = import__.Error0.plugin().use("cause", {
|
|
26
|
+
serialize: ({ value, error, isPublic }) => {
|
|
27
|
+
const ctor = error.constructor;
|
|
28
|
+
if (ctor.is(value)) {
|
|
29
|
+
return ctor.serialize(value, isPublic);
|
|
30
|
+
}
|
|
31
|
+
return void 0;
|
|
32
|
+
}
|
|
33
|
+
});
|
|
34
|
+
// Annotate the CommonJS export names for ESM import in node:
|
|
35
|
+
0 && (module.exports = {
|
|
36
|
+
causeSerializePlugin
|
|
37
|
+
});
|
|
38
|
+
//# sourceMappingURL=cause-serialize.cjs.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"sources":["../../../src/plugins/cause-serialize.ts"],"sourcesContent":["import { Error0 } from '../index.js'\n\nexport const causeSerializePlugin = Error0.plugin().use('cause', {\n serialize: ({ value, error, isPublic }) => {\n const ctor = error.constructor as typeof Error0\n if (ctor.is(value)) {\n return ctor.serialize(value, isPublic)\n }\n return undefined\n },\n})\n"],"mappings":";;;;;;;;;;;;;;;;;;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA,eAAuB;AAEhB,MAAM,uBAAuB,gBAAO,OAAO,EAAE,IAAI,SAAS;AAAA,EAC/D,WAAW,CAAC,EAAE,OAAO,OAAO,SAAS,MAAM;AACzC,UAAM,OAAO,MAAM;AACnB,QAAI,KAAK,GAAG,KAAK,GAAG;AAClB,aAAO,KAAK,UAAU,OAAO,QAAQ;AAAA,IACvC;AACA,WAAO;AAAA,EACT;AACF,CAAC;","names":[]}
|
|
@@ -0,0 +1,49 @@
|
|
|
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 expected_exports = {};
|
|
20
|
+
__export(expected_exports, {
|
|
21
|
+
expectedPlugin: () => expectedPlugin
|
|
22
|
+
});
|
|
23
|
+
module.exports = __toCommonJS(expected_exports);
|
|
24
|
+
var import__ = require('../index.cjs');
|
|
25
|
+
const isExpected = (flow) => {
|
|
26
|
+
let expected = false;
|
|
27
|
+
for (const value of flow) {
|
|
28
|
+
if (value === false) {
|
|
29
|
+
return false;
|
|
30
|
+
}
|
|
31
|
+
if (value === true) {
|
|
32
|
+
expected = true;
|
|
33
|
+
}
|
|
34
|
+
}
|
|
35
|
+
return expected;
|
|
36
|
+
};
|
|
37
|
+
const expectedPlugin = import__.Error0.plugin().use("prop", "expected", {
|
|
38
|
+
init: (input) => input,
|
|
39
|
+
resolve: ({ flow }) => isExpected(flow),
|
|
40
|
+
serialize: ({ value }) => value,
|
|
41
|
+
deserialize: ({ value }) => typeof value === "boolean" ? value : void 0
|
|
42
|
+
}).use("method", "isExpected", (error) => {
|
|
43
|
+
return isExpected(error.flow("expected"));
|
|
44
|
+
});
|
|
45
|
+
// Annotate the CommonJS export names for ESM import in node:
|
|
46
|
+
0 && (module.exports = {
|
|
47
|
+
expectedPlugin
|
|
48
|
+
});
|
|
49
|
+
//# sourceMappingURL=expected.cjs.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"sources":["../../../src/plugins/expected.ts"],"sourcesContent":["import { Error0 } from '../index.js'\n\nconst isExpected = (flow: unknown[]) => {\n let expected = false\n for (const value of flow) {\n if (value === false) {\n return false\n }\n if (value === true) {\n expected = true\n }\n }\n return expected\n}\n\nexport const expectedPlugin = Error0.plugin()\n .use('prop', 'expected', {\n init: (input: boolean) => input,\n resolve: ({ flow }) => isExpected(flow),\n serialize: ({ value }) => value,\n deserialize: ({ value }) => (typeof value === 'boolean' ? value : undefined),\n })\n .use('method', 'isExpected', (error) => {\n return isExpected(error.flow('expected'))\n })\n"],"mappings":";;;;;;;;;;;;;;;;;;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA,eAAuB;AAEvB,MAAM,aAAa,CAAC,SAAoB;AACtC,MAAI,WAAW;AACf,aAAW,SAAS,MAAM;AACxB,QAAI,UAAU,OAAO;AACnB,aAAO;AAAA,IACT;AACA,QAAI,UAAU,MAAM;AAClB,iBAAW;AAAA,IACb;AAAA,EACF;AACA,SAAO;AACT;AAEO,MAAM,iBAAiB,gBAAO,OAAO,EACzC,IAAI,QAAQ,YAAY;AAAA,EACvB,MAAM,CAAC,UAAmB;AAAA,EAC1B,SAAS,CAAC,EAAE,KAAK,MAAM,WAAW,IAAI;AAAA,EACtC,WAAW,CAAC,EAAE,MAAM,MAAM;AAAA,EAC1B,aAAa,CAAC,EAAE,MAAM,MAAO,OAAO,UAAU,YAAY,QAAQ;AACpE,CAAC,EACA,IAAI,UAAU,cAAc,CAAC,UAAU;AACtC,SAAO,WAAW,MAAM,KAAK,UAAU,CAAC;AAC1C,CAAC;","names":[]}
|
|
@@ -0,0 +1,5 @@
|
|
|
1
|
+
import { PluginError0, ErrorPluginPropOptions, Error0, ErrorPluginMethodFn } from '../index.cjs';
|
|
2
|
+
|
|
3
|
+
declare const expectedPlugin: PluginError0<Record<never, never> & Record<"expected", ErrorPluginPropOptions<boolean, boolean, Error0, boolean>>, Record<never, never> & Record<"isExpected", ErrorPluginMethodFn<boolean, [], Error0>>>;
|
|
4
|
+
|
|
5
|
+
export { expectedPlugin };
|
|
@@ -0,0 +1,36 @@
|
|
|
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 message_merge_exports = {};
|
|
20
|
+
__export(message_merge_exports, {
|
|
21
|
+
messageMergePlugin: () => messageMergePlugin
|
|
22
|
+
});
|
|
23
|
+
module.exports = __toCommonJS(message_merge_exports);
|
|
24
|
+
var import__ = require('../index.cjs');
|
|
25
|
+
const messageMergePlugin = import__.Error0.plugin().use("message", {
|
|
26
|
+
serialize: ({ error }) => {
|
|
27
|
+
return error.causes().map((cause) => {
|
|
28
|
+
return cause instanceof Error ? cause.message : void 0;
|
|
29
|
+
}).filter((value) => typeof value === "string").join(": ") || "Unknown error";
|
|
30
|
+
}
|
|
31
|
+
});
|
|
32
|
+
// Annotate the CommonJS export names for ESM import in node:
|
|
33
|
+
0 && (module.exports = {
|
|
34
|
+
messageMergePlugin
|
|
35
|
+
});
|
|
36
|
+
//# sourceMappingURL=message-merge.cjs.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"sources":["../../../src/plugins/message-merge.ts"],"sourcesContent":["import { Error0 } from '../index.js'\n\nexport const messageMergePlugin = Error0.plugin().use('message', {\n serialize: ({ error }) => {\n return (\n error\n .causes()\n .map((cause) => {\n return cause instanceof Error ? cause.message : undefined\n })\n .filter((value): value is string => typeof value === 'string')\n .join(': ') || 'Unknown error'\n )\n },\n})\n"],"mappings":";;;;;;;;;;;;;;;;;;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA,eAAuB;AAEhB,MAAM,qBAAqB,gBAAO,OAAO,EAAE,IAAI,WAAW;AAAA,EAC/D,WAAW,CAAC,EAAE,MAAM,MAAM;AACxB,WACE,MACG,OAAO,EACP,IAAI,CAAC,UAAU;AACd,aAAO,iBAAiB,QAAQ,MAAM,UAAU;AAAA,IAClD,CAAC,EACA,OAAO,CAAC,UAA2B,OAAO,UAAU,QAAQ,EAC5D,KAAK,IAAI,KAAK;AAAA,EAErB;AACF,CAAC;","names":[]}
|
|
@@ -0,0 +1,73 @@
|
|
|
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 meta_exports = {};
|
|
20
|
+
__export(meta_exports, {
|
|
21
|
+
metaPlugin: () => metaPlugin
|
|
22
|
+
});
|
|
23
|
+
module.exports = __toCommonJS(meta_exports);
|
|
24
|
+
var import__ = require('../index.cjs');
|
|
25
|
+
const toJsonSafe = (input) => {
|
|
26
|
+
if (input === null) {
|
|
27
|
+
return null;
|
|
28
|
+
}
|
|
29
|
+
if (typeof input === "string" || typeof input === "number" || typeof input === "boolean") {
|
|
30
|
+
return input;
|
|
31
|
+
}
|
|
32
|
+
if (Array.isArray(input)) {
|
|
33
|
+
return input.map((value) => toJsonSafe(value));
|
|
34
|
+
}
|
|
35
|
+
if (typeof input === "object") {
|
|
36
|
+
const output = {};
|
|
37
|
+
for (const [key, value] of Object.entries(input)) {
|
|
38
|
+
const jsonValue = toJsonSafe(value);
|
|
39
|
+
if (jsonValue !== void 0) {
|
|
40
|
+
output[key] = jsonValue;
|
|
41
|
+
}
|
|
42
|
+
}
|
|
43
|
+
return output;
|
|
44
|
+
}
|
|
45
|
+
return void 0;
|
|
46
|
+
};
|
|
47
|
+
const isMetaRecord = (value) => typeof value === "object" && value !== null && !Array.isArray(value);
|
|
48
|
+
const metaPlugin = import__.Error0.plugin().use("prop", "meta", {
|
|
49
|
+
init: (input) => input,
|
|
50
|
+
resolve: ({ flow }) => {
|
|
51
|
+
const values = flow.filter(isMetaRecord);
|
|
52
|
+
if (values.length === 0) {
|
|
53
|
+
return void 0;
|
|
54
|
+
}
|
|
55
|
+
const merged = {};
|
|
56
|
+
for (const value of [...values].reverse()) {
|
|
57
|
+
Object.assign(merged, value);
|
|
58
|
+
}
|
|
59
|
+
return merged;
|
|
60
|
+
},
|
|
61
|
+
serialize: ({ value, isPublic }) => isPublic ? void 0 : toJsonSafe(value),
|
|
62
|
+
deserialize: ({ value }) => {
|
|
63
|
+
if (!isMetaRecord(value)) {
|
|
64
|
+
return void 0;
|
|
65
|
+
}
|
|
66
|
+
return value;
|
|
67
|
+
}
|
|
68
|
+
});
|
|
69
|
+
// Annotate the CommonJS export names for ESM import in node:
|
|
70
|
+
0 && (module.exports = {
|
|
71
|
+
metaPlugin
|
|
72
|
+
});
|
|
73
|
+
//# sourceMappingURL=meta.cjs.map
|
|
@@ -0,0 +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 = Error0.plugin().use('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: ({ value, isPublic }) => (isPublic ? undefined : toJsonSafe(value)),\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,gBAAO,OAAO,EAAE,IAAI,QAAQ,QAAQ;AAAA,EAC5D,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,OAAO,SAAS,MAAO,WAAW,SAAY,WAAW,KAAK;AAAA,EAC5E,aAAa,CAAC,EAAE,MAAM,MAAM;AAC1B,QAAI,CAAC,aAAa,KAAK,GAAG;AACxB,aAAO;AAAA,IACT;AACA,WAAO;AAAA,EACT;AACF,CAAC;","names":[]}
|
|
@@ -0,0 +1,5 @@
|
|
|
1
|
+
import { PluginError0, ErrorPluginPropOptions, Error0 } from '../index.cjs';
|
|
2
|
+
|
|
3
|
+
declare const metaPlugin: PluginError0<Record<never, never> & Record<"meta", ErrorPluginPropOptions<Record<string, unknown>, Record<string, unknown>, Error0, Record<string, unknown> | undefined>>, Record<never, never>>;
|
|
4
|
+
|
|
5
|
+
export { metaPlugin };
|
|
@@ -0,0 +1,39 @@
|
|
|
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 stack_merge_exports = {};
|
|
20
|
+
__export(stack_merge_exports, {
|
|
21
|
+
stackMergePlugin: () => stackMergePlugin
|
|
22
|
+
});
|
|
23
|
+
module.exports = __toCommonJS(stack_merge_exports);
|
|
24
|
+
var import__ = require('../index.cjs');
|
|
25
|
+
const stackMergePlugin = import__.Error0.plugin().use("stack", {
|
|
26
|
+
serialize: ({ error, isPublic }) => {
|
|
27
|
+
if (isPublic) {
|
|
28
|
+
return void 0;
|
|
29
|
+
}
|
|
30
|
+
return error.causes().map((cause) => {
|
|
31
|
+
return cause instanceof Error ? cause.stack : void 0;
|
|
32
|
+
}).filter((value) => typeof value === "string").join("\n");
|
|
33
|
+
}
|
|
34
|
+
});
|
|
35
|
+
// Annotate the CommonJS export names for ESM import in node:
|
|
36
|
+
0 && (module.exports = {
|
|
37
|
+
stackMergePlugin
|
|
38
|
+
});
|
|
39
|
+
//# sourceMappingURL=stack-merge.cjs.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"sources":["../../../src/plugins/stack-merge.ts"],"sourcesContent":["import { Error0 } from '../index.js'\n\nexport const stackMergePlugin = Error0.plugin().use('stack', {\n serialize: ({ error, isPublic }) => {\n if (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('\\n')\n },\n})\n"],"mappings":";;;;;;;;;;;;;;;;;;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA,eAAuB;AAEhB,MAAM,mBAAmB,gBAAO,OAAO,EAAE,IAAI,SAAS;AAAA,EAC3D,WAAW,CAAC,EAAE,OAAO,SAAS,MAAM;AAClC,QAAI,UAAU;AACZ,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,IAAI;AAAA,EACd;AACF,CAAC;","names":[]}
|
|
@@ -0,0 +1,48 @@
|
|
|
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 tags_exports = {};
|
|
20
|
+
__export(tags_exports, {
|
|
21
|
+
tagsPlugin: () => tagsPlugin
|
|
22
|
+
});
|
|
23
|
+
module.exports = __toCommonJS(tags_exports);
|
|
24
|
+
var import__ = require('../index.cjs');
|
|
25
|
+
const tagsPlugin = import__.Error0.plugin().use("prop", "tags", {
|
|
26
|
+
init: (input) => input,
|
|
27
|
+
resolve: ({ flow }) => {
|
|
28
|
+
const merged = [];
|
|
29
|
+
for (const value of flow) {
|
|
30
|
+
if (Array.isArray(value)) {
|
|
31
|
+
merged.push(...value.filter((item) => typeof item === "string"));
|
|
32
|
+
}
|
|
33
|
+
}
|
|
34
|
+
return merged.length > 0 ? Array.from(new Set(merged)) : void 0;
|
|
35
|
+
},
|
|
36
|
+
serialize: ({ value, isPublic }) => isPublic ? void 0 : value,
|
|
37
|
+
deserialize: ({ value }) => {
|
|
38
|
+
if (!Array.isArray(value)) {
|
|
39
|
+
return void 0;
|
|
40
|
+
}
|
|
41
|
+
return value.filter((item) => typeof item === "string");
|
|
42
|
+
}
|
|
43
|
+
});
|
|
44
|
+
// Annotate the CommonJS export names for ESM import in node:
|
|
45
|
+
0 && (module.exports = {
|
|
46
|
+
tagsPlugin
|
|
47
|
+
});
|
|
48
|
+
//# sourceMappingURL=tags.cjs.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"sources":["../../../src/plugins/tags.ts"],"sourcesContent":["import { Error0 } from '../index.js'\n\nexport const tagsPlugin = Error0.plugin().use('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.filter((item): item is string => typeof item === 'string'))\n }\n }\n return merged.length > 0 ? Array.from(new Set(merged)) : undefined\n },\n serialize: ({ value, isPublic }) => (isPublic ? undefined : value),\n deserialize: ({ value }) => {\n if (!Array.isArray(value)) {\n return undefined\n }\n return value.filter((item): item is string => typeof item === 'string')\n },\n})\n"],"mappings":";;;;;;;;;;;;;;;;;;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA,eAAuB;AAEhB,MAAM,aAAa,gBAAO,OAAO,EAAE,IAAI,QAAQ,QAAQ;AAAA,EAC5D,MAAM,CAAC,UAAoB;AAAA,EAC3B,SAAS,CAAC,EAAE,KAAK,MAAM;AACrB,UAAM,SAAmB,CAAC;AAC1B,eAAW,SAAS,MAAM;AACxB,UAAI,MAAM,QAAQ,KAAK,GAAG;AACxB,eAAO,KAAK,GAAG,MAAM,OAAO,CAAC,SAAyB,OAAO,SAAS,QAAQ,CAAC;AAAA,MACjF;AAAA,IACF;AACA,WAAO,OAAO,SAAS,IAAI,MAAM,KAAK,IAAI,IAAI,MAAM,CAAC,IAAI;AAAA,EAC3D;AAAA,EACA,WAAW,CAAC,EAAE,OAAO,SAAS,MAAO,WAAW,SAAY;AAAA,EAC5D,aAAa,CAAC,EAAE,MAAM,MAAM;AAC1B,QAAI,CAAC,MAAM,QAAQ,KAAK,GAAG;AACzB,aAAO;AAAA,IACT;AACA,WAAO,MAAM,OAAO,CAAC,SAAyB,OAAO,SAAS,QAAQ;AAAA,EACxE;AACF,CAAC;","names":[]}
|
|
@@ -0,0 +1,5 @@
|
|
|
1
|
+
import { PluginError0, ErrorPluginPropOptions, Error0 } from '../index.cjs';
|
|
2
|
+
|
|
3
|
+
declare const tagsPlugin: PluginError0<Record<never, never> & Record<"tags", ErrorPluginPropOptions<string[], string[], Error0, string[] | undefined>>, Record<never, never>>;
|
|
4
|
+
|
|
5
|
+
export { tagsPlugin };
|