@fgv/ts-utils 3.0.1-alpha.4 → 3.0.1-alpha.5
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/ts-utils.d.ts +1221 -1116
- package/lib/packlets/base/index.d.ts +1 -0
- package/lib/packlets/base/index.d.ts.map +1 -1
- package/lib/packlets/base/index.js +1 -0
- package/lib/packlets/base/index.js.map +1 -1
- package/lib/packlets/base/mapResults.d.ts +8 -8
- package/lib/packlets/base/mapResults.d.ts.map +1 -1
- package/lib/packlets/base/mapResults.js +6 -6
- package/lib/packlets/base/mapResults.js.map +1 -1
- package/lib/packlets/base/messageAggregator.d.ts +56 -0
- package/lib/packlets/base/messageAggregator.d.ts.map +1 -0
- package/lib/packlets/base/messageAggregator.js +108 -0
- package/lib/packlets/base/messageAggregator.js.map +1 -0
- package/lib/packlets/base/result.d.ts +49 -0
- package/lib/packlets/base/result.d.ts.map +1 -1
- package/lib/packlets/base/result.js +13 -0
- package/lib/packlets/base/result.js.map +1 -1
- package/package.json +1 -1
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../../src/packlets/base/index.ts"],"names":[],"mappings":"AAsBA,OAAO,KAAK,OAAO,MAAM,UAAU,CAAC;AAEpC,cAAc,SAAS,CAAC;AACxB,cAAc,cAAc,CAAC;AAC7B,OAAO,EAAE,UAAU,EAAE,MAAM,aAAa,CAAC;AACzC,cAAc,UAAU,CAAC;AACzB,cAAc,SAAS,CAAC;AACxB,OAAO,EAAE,OAAO,EAAE,CAAC"}
|
|
1
|
+
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../../src/packlets/base/index.ts"],"names":[],"mappings":"AAsBA,OAAO,KAAK,OAAO,MAAM,UAAU,CAAC;AAEpC,cAAc,SAAS,CAAC;AACxB,cAAc,cAAc,CAAC;AAC7B,cAAc,qBAAqB,CAAC;AACpC,OAAO,EAAE,UAAU,EAAE,MAAM,aAAa,CAAC;AACzC,cAAc,UAAU,CAAC;AACzB,cAAc,SAAS,CAAC;AACxB,OAAO,EAAE,OAAO,EAAE,CAAC"}
|
|
@@ -52,6 +52,7 @@ const Logging = __importStar(require("./logger"));
|
|
|
52
52
|
exports.Logging = Logging;
|
|
53
53
|
__exportStar(require("./brand"), exports);
|
|
54
54
|
__exportStar(require("./mapResults"), exports);
|
|
55
|
+
__exportStar(require("./messageAggregator"), exports);
|
|
55
56
|
var normalize_1 = require("./normalize");
|
|
56
57
|
Object.defineProperty(exports, "Normalizer", { enumerable: true, get: function () { return normalize_1.Normalizer; } });
|
|
57
58
|
__exportStar(require("./result"), exports);
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.js","sourceRoot":"","sources":["../../../src/packlets/base/index.ts"],"names":[],"mappings":";AAAA;;;;;;;;;;;;;;;;;;;;GAoBG;;;;;;;;;;;;;;;;;;;;;;;;;;;;;AAEH,kDAAoC;
|
|
1
|
+
{"version":3,"file":"index.js","sourceRoot":"","sources":["../../../src/packlets/base/index.ts"],"names":[],"mappings":";AAAA;;;;;;;;;;;;;;;;;;;;GAoBG;;;;;;;;;;;;;;;;;;;;;;;;;;;;;AAEH,kDAAoC;AAQ3B,0BAAO;AANhB,0CAAwB;AACxB,+CAA6B;AAC7B,sDAAoC;AACpC,yCAAyC;AAAhC,uGAAA,UAAU,OAAA;AACnB,2CAAyB;AACzB,0CAAwB","sourcesContent":["/*\n * Copyright (c) 2020 Erik Fortune\n *\n * Permission is hereby granted, free of charge, to any person obtaining a copy\n * of this software and associated documentation files (the \"Software\"), to deal\n * in the Software without restriction, including without limitation the rights\n * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell\n * copies of the Software, and to permit persons to whom the Software is\n * furnished to do so, subject to the following conditions:\n *\n * The above copyright notice and this permission notice shall be included in all\n * copies or substantial portions of the Software.\n *\n * THE SOFTWARE IS PROVIDED \"AS IS\", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR\n * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,\n * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE\n * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER\n * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,\n * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE\n * SOFTWARE.\n */\n\nimport * as Logging from './logger';\n\nexport * from './brand';\nexport * from './mapResults';\nexport * from './messageAggregator';\nexport { Normalizer } from './normalize';\nexport * from './result';\nexport * from './utils';\nexport { Logging };\n"]}
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import { DetailedResult, Result } from './result';
|
|
1
|
+
import { DetailedResult, IMessageAggregator, Result } from './result';
|
|
2
2
|
/**
|
|
3
3
|
* Aggregates successful result values from a collection of {@link Result | Result<T>}.
|
|
4
4
|
* @param results - The collection of {@link Result | Result<T>} to be mapped.
|
|
@@ -9,7 +9,7 @@ import { DetailedResult, Result } from './result';
|
|
|
9
9
|
* {@link Failure} with a concatenated summary of all error messages.
|
|
10
10
|
* @public
|
|
11
11
|
*/
|
|
12
|
-
export declare function mapResults<T>(results: Iterable<Result<T>>, aggregatedErrors?:
|
|
12
|
+
export declare function mapResults<T>(results: Iterable<Result<T>>, aggregatedErrors?: IMessageAggregator): Result<T[]>;
|
|
13
13
|
/**
|
|
14
14
|
* Aggregates successful results from a collection of {@link DetailedResult | DetailedResult<T, TD>},
|
|
15
15
|
* optionally ignoring certain error details.
|
|
@@ -23,7 +23,7 @@ export declare function mapResults<T>(results: Iterable<Result<T>>, aggregatedEr
|
|
|
23
23
|
* error messages.
|
|
24
24
|
* @public
|
|
25
25
|
*/
|
|
26
|
-
export declare function mapDetailedResults<T, TD>(results: Iterable<DetailedResult<T, TD>>, ignore: TD[], aggregatedErrors?:
|
|
26
|
+
export declare function mapDetailedResults<T, TD>(results: Iterable<DetailedResult<T, TD>>, ignore: TD[], aggregatedErrors?: IMessageAggregator): Result<T[]>;
|
|
27
27
|
/**
|
|
28
28
|
* Aggregates successful results from a a collection of {@link Result | Result<T>}.
|
|
29
29
|
* @param results - An `Iterable` of {@link Result | Result<T>} from which success
|
|
@@ -35,7 +35,7 @@ export declare function mapDetailedResults<T, TD>(results: Iterable<DetailedResu
|
|
|
35
35
|
* summary of all error messages.
|
|
36
36
|
* @public
|
|
37
37
|
*/
|
|
38
|
-
export declare function mapSuccess<T>(results: Iterable<Result<T>>, aggregatedErrors?:
|
|
38
|
+
export declare function mapSuccess<T>(results: Iterable<Result<T>>, aggregatedErrors?: IMessageAggregator): Result<T[]>;
|
|
39
39
|
/**
|
|
40
40
|
* Aggregates error messages from a collection of {@link Result | Result<T>}.
|
|
41
41
|
* @param results - An iterable collection of {@link Result | Result<T>} for which
|
|
@@ -47,7 +47,7 @@ export declare function mapSuccess<T>(results: Iterable<Result<T>>, aggregatedEr
|
|
|
47
47
|
* results and returns an empty array if there were no errors.
|
|
48
48
|
* @public
|
|
49
49
|
*/
|
|
50
|
-
export declare function mapFailures<T>(results: Iterable<Result<T>>, aggregatedErrors?:
|
|
50
|
+
export declare function mapFailures<T>(results: Iterable<Result<T>>, aggregatedErrors?: IMessageAggregator): string[];
|
|
51
51
|
/**
|
|
52
52
|
* Determines if an iterable collection of {@link Result | Result<T>} were all successful.
|
|
53
53
|
* @param results - The collection of {@link Result | Result<T>} to be tested.
|
|
@@ -59,7 +59,7 @@ export declare function mapFailures<T>(results: Iterable<Result<T>>, aggregatedE
|
|
|
59
59
|
* messages from all failed elements.
|
|
60
60
|
* @public
|
|
61
61
|
*/
|
|
62
|
-
export declare function allSucceed<T>(results: Iterable<Result<unknown>>, successValue: T, aggregatedErrors?:
|
|
62
|
+
export declare function allSucceed<T>(results: Iterable<Result<unknown>>, successValue: T, aggregatedErrors?: IMessageAggregator): Result<T>;
|
|
63
63
|
/**
|
|
64
64
|
* String-keyed record of initialization functions to be passed to {@link (populateObject:1)}
|
|
65
65
|
* or {@link (populateObject:2)}.
|
|
@@ -102,7 +102,7 @@ export interface PopulateObjectOptions<T> {
|
|
|
102
102
|
* {@label WITH_OPTIONS}
|
|
103
103
|
* @public
|
|
104
104
|
*/
|
|
105
|
-
export declare function populateObject<T>(initializers: FieldInitializers<T>, options?: PopulateObjectOptions<T>, aggregatedErrors?:
|
|
105
|
+
export declare function populateObject<T>(initializers: FieldInitializers<T>, options?: PopulateObjectOptions<T>, aggregatedErrors?: IMessageAggregator): Result<T>;
|
|
106
106
|
/**
|
|
107
107
|
* Populates an an object based on a prototype full of field initializers that return {@link Result | Result<T[key]>}.
|
|
108
108
|
* Returns {@link Success} with the populated object if all initializers succeed, or {@link Failure} with a
|
|
@@ -116,5 +116,5 @@ export declare function populateObject<T>(initializers: FieldInitializers<T>, op
|
|
|
116
116
|
* {@label WITH_ORDER}
|
|
117
117
|
* @deprecated Pass {@link PopulateObjectOptions} instead.
|
|
118
118
|
*/
|
|
119
|
-
export declare function populateObject<T>(initializers: FieldInitializers<T>, order: (keyof T)[] | undefined, aggregatedErrors?:
|
|
119
|
+
export declare function populateObject<T>(initializers: FieldInitializers<T>, order: (keyof T)[] | undefined, aggregatedErrors?: IMessageAggregator): Result<T>;
|
|
120
120
|
//# sourceMappingURL=mapResults.d.ts.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"mapResults.d.ts","sourceRoot":"","sources":["../../../src/packlets/base/mapResults.ts"],"names":[],"mappings":"AAsBA,OAAO,EAAE,cAAc,EAAE,MAAM,EAAiB,MAAM,UAAU,CAAC;
|
|
1
|
+
{"version":3,"file":"mapResults.d.ts","sourceRoot":"","sources":["../../../src/packlets/base/mapResults.ts"],"names":[],"mappings":"AAsBA,OAAO,EAAE,cAAc,EAAE,kBAAkB,EAAE,MAAM,EAAiB,MAAM,UAAU,CAAC;AAErF;;;;;;;;;GASG;AACH,wBAAgB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AAC,CAAC;IACtC;;;;;OAKG;IACH,KAAK,CAAC,EAAE,CAAC,MAAM,CAAC,CAAC,EAAE,CAAC;IAEpB;;;;;;OAMG;IACH,iBAAiB,CAAC,EAAE,OAAO,GAAG,CAAC,MAAM,CAAC,CAAC,EAAE,CAAC;CAC3C;AAED;;;;;;;;;;;;GAYG;AACH,wBAAgB,cAAc,CAAC,CAAC,EAC9B,YAAY,EAAE,iBAAiB,CAAC,CAAC,CAAC,EAClC,OAAO,CAAC,EAAE,qBAAqB,CAAC,CAAC,CAAC,EAClC,gBAAgB,CAAC,EAAE,kBAAkB,GACpC,MAAM,CAAC,CAAC,CAAC,CAAC;AAEb;;;;;;;;;;;;GAYG;AACH,wBAAgB,cAAc,CAAC,CAAC,EAC9B,YAAY,EAAE,iBAAiB,CAAC,CAAC,CAAC,EAClC,KAAK,EAAE,CAAC,MAAM,CAAC,CAAC,EAAE,GAAG,SAAS,EAC9B,gBAAgB,CAAC,EAAE,kBAAkB,GACpC,MAAM,CAAC,CAAC,CAAC,CAAC"}
|
|
@@ -45,7 +45,7 @@ function mapResults(results, aggregatedErrors) {
|
|
|
45
45
|
}
|
|
46
46
|
}
|
|
47
47
|
if (errors.length > 0) {
|
|
48
|
-
aggregatedErrors === null || aggregatedErrors === void 0 ? void 0 : aggregatedErrors.
|
|
48
|
+
aggregatedErrors === null || aggregatedErrors === void 0 ? void 0 : aggregatedErrors.addMessages(errors);
|
|
49
49
|
return (0, result_1.fail)(errors.join('\n'));
|
|
50
50
|
}
|
|
51
51
|
return (0, result_1.succeed)(elements);
|
|
@@ -76,7 +76,7 @@ function mapDetailedResults(results, ignore, aggregatedErrors) {
|
|
|
76
76
|
}
|
|
77
77
|
}
|
|
78
78
|
if (errors.length > 0) {
|
|
79
|
-
aggregatedErrors === null || aggregatedErrors === void 0 ? void 0 : aggregatedErrors.
|
|
79
|
+
aggregatedErrors === null || aggregatedErrors === void 0 ? void 0 : aggregatedErrors.addMessages(errors);
|
|
80
80
|
return (0, result_1.fail)(errors.join('\n'));
|
|
81
81
|
}
|
|
82
82
|
return (0, result_1.succeed)(elements);
|
|
@@ -105,7 +105,7 @@ function mapSuccess(results, aggregatedErrors) {
|
|
|
105
105
|
}
|
|
106
106
|
}
|
|
107
107
|
if (elements.length === 0 && errors.length > 0) {
|
|
108
|
-
aggregatedErrors === null || aggregatedErrors === void 0 ? void 0 : aggregatedErrors.
|
|
108
|
+
aggregatedErrors === null || aggregatedErrors === void 0 ? void 0 : aggregatedErrors.addMessages(errors);
|
|
109
109
|
return (0, result_1.fail)(errors.join('\n'));
|
|
110
110
|
}
|
|
111
111
|
return (0, result_1.succeed)(elements);
|
|
@@ -127,7 +127,7 @@ function mapFailures(results, aggregatedErrors) {
|
|
|
127
127
|
for (const result of results) {
|
|
128
128
|
if (result.isFailure()) {
|
|
129
129
|
errors.push(result.message);
|
|
130
|
-
aggregatedErrors === null || aggregatedErrors === void 0 ? void 0 : aggregatedErrors.
|
|
130
|
+
aggregatedErrors === null || aggregatedErrors === void 0 ? void 0 : aggregatedErrors.addMessage(result.message);
|
|
131
131
|
}
|
|
132
132
|
}
|
|
133
133
|
return errors;
|
|
@@ -154,7 +154,7 @@ function allSucceed(results, successValue, aggregatedErrors) {
|
|
|
154
154
|
}
|
|
155
155
|
}
|
|
156
156
|
if (errors.length > 0) {
|
|
157
|
-
aggregatedErrors === null || aggregatedErrors === void 0 ? void 0 : aggregatedErrors.
|
|
157
|
+
aggregatedErrors === null || aggregatedErrors === void 0 ? void 0 : aggregatedErrors.addMessages(errors);
|
|
158
158
|
return (0, result_1.fail)(errors.join('\n'));
|
|
159
159
|
}
|
|
160
160
|
return (0, result_1.succeed)(successValue);
|
|
@@ -199,7 +199,7 @@ function populateObject(initializers, optionsOrOrder, aggregatedErrors) {
|
|
|
199
199
|
}
|
|
200
200
|
}
|
|
201
201
|
if (errors.length > 0) {
|
|
202
|
-
aggregatedErrors === null || aggregatedErrors === void 0 ? void 0 : aggregatedErrors.
|
|
202
|
+
aggregatedErrors === null || aggregatedErrors === void 0 ? void 0 : aggregatedErrors.addMessages(errors);
|
|
203
203
|
return (0, result_1.fail)(errors.join('\n'));
|
|
204
204
|
}
|
|
205
205
|
return (0, result_1.succeed)(state);
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"mapResults.js","sourceRoot":"","sources":["../../../src/packlets/base/mapResults.ts"],"names":[],"mappings":";AAAA;;;;;;;;;;;;;;;;;;;;GAoBG;;;AAEH,qCAAiE;AAEjE;;;;;;;;;GASG;AACH,SAAgB,UAAU,CAAI,OAA4B,EAAE,gBAA2B;IACrF,MAAM,MAAM,GAAa,EAAE,CAAC;IAC5B,MAAM,QAAQ,GAAQ,EAAE,CAAC;IAEzB,KAAK,MAAM,MAAM,IAAI,OAAO,EAAE,CAAC;QAC7B,IAAI,MAAM,CAAC,SAAS,EAAE,EAAE,CAAC;YACvB,QAAQ,CAAC,IAAI,CAAC,MAAM,CAAC,KAAK,CAAC,CAAC;QAC9B,CAAC;aAAM,CAAC;YACN,MAAM,CAAC,IAAI,CAAC,MAAM,CAAC,OAAO,CAAC,CAAC;QAC9B,CAAC;IACH,CAAC;IAED,IAAI,MAAM,CAAC,MAAM,GAAG,CAAC,EAAE,CAAC;QACtB,gBAAgB,aAAhB,gBAAgB,uBAAhB,gBAAgB,CAAE,IAAI,CAAC,GAAG,MAAM,CAAC,CAAC;QAClC,OAAO,IAAA,aAAI,EAAC,MAAM,CAAC,IAAI,CAAC,IAAI,CAAC,CAAC,CAAC;IACjC,CAAC;IACD,OAAO,IAAA,gBAAO,EAAC,QAAQ,CAAC,CAAC;AAC3B,CAAC;AAjBD,gCAiBC;AAED;;;;;;;;;;;;GAYG;AACH,SAAgB,kBAAkB,CAChC,OAAwC,EACxC,MAAY,EACZ,gBAA2B;IAE3B,MAAM,MAAM,GAAa,EAAE,CAAC;IAC5B,MAAM,QAAQ,GAAQ,EAAE,CAAC;IAEzB,KAAK,MAAM,MAAM,IAAI,OAAO,EAAE,CAAC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AK,CAAC,GAAG,CAAC,GAAG,MAAM,CAAC,KAAK,CAAC;YAC5B,CAAC;iBAAM,CAAC;gBACN,MAAM,CAAC,IAAI,CAAC,MAAM,CAAC,OAAO,CAAC,CAAC;YAC9B,CAAC;QACH,CAAC;aAAM,CAAC;YACN,MAAM,CAAC,IAAI,CAAC,uBAAuB,MAAM,CAAC,GAAG,CAAC,oCAAoC,CAAC,CAAC;QACtF,CAAC;IACH,CAAC;IAED,IAAI,MAAM,CAAC,MAAM,GAAG,CAAC,EAAE,CAAC;QACtB,gBAAgB,aAAhB,gBAAgB,uBAAhB,gBAAgB,CAAE,IAAI,CAAC,GAAG,MAAM,CAAC,CAAC;QAClC,OAAO,IAAA,aAAI,EAAC,MAAM,CAAC,IAAI,CAAC,IAAI,CAAC,CAAC,CAAC;IACjC,CAAC;IACD,OAAO,IAAA,gBAAO,EAAC,KAAU,CAAC,CAAC;AAC7B,CAAC;AAjDD,wCAiDC","sourcesContent":["/*\n * Copyright (c) 2020 Erik Fortune\n *\n * Permission is hereby granted, free of charge, to any person obtaining a copy\n * of this software and associated documentation files (the \"Software\"), to deal\n * in the Software without restriction, including without limitation the rights\n * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell\n * copies of the Software, and to permit persons to whom the Software is\n * furnished to do so, subject to the following conditions:\n *\n * The above copyright notice and this permission notice shall be included in all\n * copies or substantial portions of the Software.\n *\n * THE SOFTWARE IS PROVIDED \"AS IS\", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR\n * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,\n * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE\n * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER\n * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,\n * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE\n * SOFTWARE.\n */\n\nimport { DetailedResult, Result, fail, succeed } from './result';\n\n/**\n * Aggregates successful result values from a collection of {@link Result | Result<T>}.\n * @param results - The collection of {@link Result | Result<T>} to be mapped.\n * @param aggregatedErrors - Optional string array to which any error messages will be\n * appended. Each error is appended as an individual string.\n * @returns If all {@link Result | results} are successful, returns {@link Success} with an\n * array containing all returned values. If any {@link Result | results} failed, returns\n * {@link Failure} with a concatenated summary of all error messages.\n * @public\n */\nexport function mapResults<T>(results: Iterable<Result<T>>, aggregatedErrors?: string[]): Result<T[]> {\n const errors: string[] = [];\n const elements: T[] = [];\n\n for (const result of results) {\n if (result.isSuccess()) {\n elements.push(result.value);\n } else {\n errors.push(result.message);\n }\n }\n\n if (errors.length > 0) {\n aggregatedErrors?.push(...errors);\n return fail(errors.join('\\n'));\n }\n return succeed(elements);\n}\n\n/**\n * Aggregates successful results from a collection of {@link DetailedResult | DetailedResult<T, TD>},\n * optionally ignoring certain error details.\n * @param results - The collection of {@link DetailedResult | DetailedResult<T, TD>} to be mapped.\n * @param ignore - An array of error detail values (of type `<TD>`) that should be ignored.\n * @param aggregatedErrors - Optional string array to which any non-ignorable error messages will be\n * appended. Each error is appended as an individual string.\n * @returns {@link Success} with an array containing all successful results if all results either\n * succeeded or returned error details listed in `ignore`. If any results failed with details\n * that cannot be ignored, returns {@link Failure} with an concatenated summary of all non-ignorable\n * error messages.\n * @public\n */\nexport function mapDetailedResults<T, TD>(\n results: Iterable<DetailedResult<T, TD>>,\n ignore: TD[],\n aggregatedErrors?: string[]\n): Result<T[]> {\n const errors: string[] = [];\n const elements: T[] = [];\n\n for (const result of results) {\n if (result.isSuccess()) {\n elements.push(result.value);\n } else if (!ignore.includes(result.detail)) {\n errors.push(result.message);\n }\n }\n\n if (errors.length > 0) {\n aggregatedErrors?.push(...errors);\n return fail(errors.join('\\n'));\n }\n return succeed(elements);\n}\n\n/**\n * Aggregates successful results from a a collection of {@link Result | Result<T>}.\n * @param results - An `Iterable` of {@link Result | Result<T>} from which success\n * results are to be aggregated.\n * @param aggregatedErrors - Optional string array to which any returned error messages will be\n * appended. Each error is appended as an individual string.\n * @returns {@link Success} with an array of `<T>` if any results were successful. If\n * all {@link Result | results} failed, returns {@link Failure} with a concatenated\n * summary of all error messages.\n * @public\n */\nexport function mapSuccess<T>(results: Iterable<Result<T>>, aggregatedErrors?: string[]): Result<T[]> {\n const errors: string[] = [];\n const elements: T[] = [];\n\n for (const result of results) {\n if (result.isSuccess()) {\n elements.push(result.value);\n } else {\n errors.push(result.message);\n }\n }\n\n if (elements.length === 0 && errors.length > 0) {\n aggregatedErrors?.push(...errors);\n return fail(errors.join('\\n'));\n }\n return succeed(elements);\n}\n\n/**\n * Aggregates error messages from a collection of {@link Result | Result<T>}.\n * @param results - An iterable collection of {@link Result | Result<T>} for which\n * error messages are aggregated.\n * @param aggregatedErrors - Optional string array to which any returned error messages will be\n * appended. Each error is appended as an individual string.\n * @returns An array of strings consisting of all error messages returned by\n * {@link Result | results} in the source collection. Ignores {@link Success}\n * results and returns an empty array if there were no errors.\n * @public\n */\nexport function mapFailures<T>(results: Iterable<Result<T>>, aggregatedErrors?: string[]): string[] {\n const errors: string[] = [];\n for (const result of results) {\n if (result.isFailure()) {\n errors.push(result.message);\n aggregatedErrors?.push(result.message);\n }\n }\n return errors;\n}\n\n/**\n * Determines if an iterable collection of {@link Result | Result<T>} were all successful.\n * @param results - The collection of {@link Result | Result<T>} to be tested.\n * @param successValue - The value to be returned if results are successful.\n * @param aggregatedErrors - Optional string array to which any returned error messages will be\n * appended. Each error is appended as an individual string.\n * @returns Returns {@link Success} with `successValue` if all {@link Result | results} are successful.\n * If any are unsuccessful, returns {@link Failure} with a concatenated summary of the error\n * messages from all failed elements.\n * @public\n */\nexport function allSucceed<T>(\n results: Iterable<Result<unknown>>,\n successValue: T,\n aggregatedErrors?: string[]\n): Result<T> {\n const errors: string[] = [];\n\n if (results !== undefined) {\n for (const result of results) {\n if (result.isFailure()) {\n errors.push(result.message);\n }\n }\n }\n\n if (errors.length > 0) {\n aggregatedErrors?.push(...errors);\n return fail(errors.join('\\n'));\n }\n return succeed(successValue);\n}\n\n/**\n * String-keyed record of initialization functions to be passed to {@link (populateObject:1)}\n * or {@link (populateObject:2)}.\n * @public\n */\nexport type FieldInitializers<T> = { [key in keyof T]: (state: Partial<T>) => Result<T[key]> };\n\n/**\n * Options for the {@link (populateObject:1)} function.\n * @public\n */\n// eslint-disable-next-line @typescript-eslint/naming-convention\nexport interface PopulateObjectOptions<T> {\n /**\n * If present, specifies the order in which property values should\n * be evaluated. Any keys not listed are evaluated after all listed\n * keys in indeterminate order. If 'order' is not present, keys\n * are evaluated in indeterminate order.\n */\n order?: (keyof T)[];\n\n /**\n * Specify handling of `undefined` values. By default, successful\n * `undefined` results are written to the result object. If this value\n * is `true` then `undefined` results are suppressed for all properties.\n * If this value is an array of property keys then `undefined` results\n * are suppressed for those properties only.\n */\n suppressUndefined?: boolean | (keyof T)[];\n}\n\n/**\n * Populates an an object based on a prototype full of field initializers that return {@link Result | Result<T[key]>}.\n * Returns {@link Success} with the populated object if all initializers succeed, or {@link Failure} with a\n * concatenated list of all error messages.\n * @param initializers - An object with the shape of the target but with initializer functions for\n * each property.\n * @param options - An optional {@link PopulateObjectOptions | set of options} which\n * modify the behavior of this call.\n * @param aggregatedErrors - Optional string array to which any returned error messages will be\n * appended. Each error is appended as an individual string.\n * {@label WITH_OPTIONS}\n * @public\n */\nexport function populateObject<T>(\n initializers: FieldInitializers<T>,\n options?: PopulateObjectOptions<T>,\n aggregatedErrors?: string[]\n): Result<T>;\n\n/**\n * Populates an an object based on a prototype full of field initializers that return {@link Result | Result<T[key]>}.\n * Returns {@link Success} with the populated object if all initializers succeed, or {@link Failure} with a\n * concatenated list of all error messages.\n * @param initializers - An object with the shape of the target but with initializer functions for\n * each property.\n * @param order - Optional order in which keys should be written.\n * @param aggregatedErrors - Optional string array to which any returned error messages will be\n * appended. Each error is appended as an individual string.\n * @public\n * {@label WITH_ORDER}\n * @deprecated Pass {@link PopulateObjectOptions} instead.\n */\nexport function populateObject<T>(\n initializers: FieldInitializers<T>,\n order: (keyof T)[] | undefined,\n aggregatedErrors?: string[]\n): Result<T>;\nexport function populateObject<T>(\n initializers: FieldInitializers<T>,\n optionsOrOrder?: PopulateObjectOptions<T> | (keyof T)[],\n aggregatedErrors?: string[]\n): Result<T> {\n const options: PopulateObjectOptions<T> = optionsOrOrder\n ? Array.isArray(optionsOrOrder)\n ? { order: optionsOrOrder }\n : optionsOrOrder\n : {};\n const state = {} as { [key in keyof T]: T[key] };\n const errors: string[] = [];\n const keys: (keyof T)[] = Array.from(options.order ?? []);\n const foundKeys = new Set<keyof T>(options.order);\n\n // start with the supplied order then append anything else we find\n for (const key in initializers) {\n if (!foundKeys.has(key)) {\n keys.push(key);\n foundKeys.add(key);\n }\n }\n\n for (const key of keys) {\n if (initializers[key]) {\n const result = initializers[key](state);\n if (result.isSuccess()) {\n if (result.value === undefined) {\n if (\n options.suppressUndefined === true ||\n (Array.isArray(options.suppressUndefined) && options.suppressUndefined.includes(key))\n ) {\n continue;\n }\n }\n state[key] = result.value;\n } else {\n errors.push(result.message);\n }\n } else {\n errors.push(`populateObject: Key ${String(key)} is present but has no initializer`);\n }\n }\n\n if (errors.length > 0) {\n aggregatedErrors?.push(...errors);\n return fail(errors.join('\\n'));\n }\n return succeed(state as T);\n}\n"]}
|
|
1
|
+
{"version":3,"file":"mapResults.js","sourceRoot":"","sources":["../../../src/packlets/base/mapResults.ts"],"names":[],"mappings":";AAAA;;;;;;;;;;;;;;;;;;;;GAoBG;;;AAEH,qCAAqF;AAErF;;;;;;;;;GASG;AACH,SAAgB,UAAU,CACxB,OAA4B,EAC5B,gBAAqC;IAErC,MAAM,MAAM,GAAa,EAAE,CAAC;IAC5B,MAAM,QAAQ,GAAQ,EAAE,CAAC;IAEzB,KAAK,MAAM,MAAM,IAAI,OAAO,EAAE,CAAC;QAC7B,IAAI,MAAM,CAAC,SAA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,CAAC;AAC7B,CAAC;AAjDD,wCAiDC","sourcesContent":["/*\n * Copyright (c) 2020 Erik Fortune\n *\n * Permission is hereby granted, free of charge, to any person obtaining a copy\n * of this software and associated documentation files (the \"Software\"), to deal\n * in the Software without restriction, including without limitation the rights\n * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell\n * copies of the Software, and to permit persons to whom the Software is\n * furnished to do so, subject to the following conditions:\n *\n * The above copyright notice and this permission notice shall be included in all\n * copies or substantial portions of the Software.\n *\n * THE SOFTWARE IS PROVIDED \"AS IS\", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR\n * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,\n * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE\n * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER\n * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,\n * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE\n * SOFTWARE.\n */\n\nimport { DetailedResult, IMessageAggregator, Result, fail, succeed } from './result';\n\n/**\n * Aggregates successful result values from a collection of {@link Result | Result<T>}.\n * @param results - The collection of {@link Result | Result<T>} to be mapped.\n * @param aggregatedErrors - Optional string array to which any error messages will be\n * appended. Each error is appended as an individual string.\n * @returns If all {@link Result | results} are successful, returns {@link Success} with an\n * array containing all returned values. If any {@link Result | results} failed, returns\n * {@link Failure} with a concatenated summary of all error messages.\n * @public\n */\nexport function mapResults<T>(\n results: Iterable<Result<T>>,\n aggregatedErrors?: IMessageAggregator\n): Result<T[]> {\n const errors: string[] = [];\n const elements: T[] = [];\n\n for (const result of results) {\n if (result.isSuccess()) {\n elements.push(result.value);\n } else {\n errors.push(result.message);\n }\n }\n\n if (errors.length > 0) {\n aggregatedErrors?.addMessages(errors);\n return fail(errors.join('\\n'));\n }\n return succeed(elements);\n}\n\n/**\n * Aggregates successful results from a collection of {@link DetailedResult | DetailedResult<T, TD>},\n * optionally ignoring certain error details.\n * @param results - The collection of {@link DetailedResult | DetailedResult<T, TD>} to be mapped.\n * @param ignore - An array of error detail values (of type `<TD>`) that should be ignored.\n * @param aggregatedErrors - Optional string array to which any non-ignorable error messages will be\n * appended. Each error is appended as an individual string.\n * @returns {@link Success} with an array containing all successful results if all results either\n * succeeded or returned error details listed in `ignore`. If any results failed with details\n * that cannot be ignored, returns {@link Failure} with an concatenated summary of all non-ignorable\n * error messages.\n * @public\n */\nexport function mapDetailedResults<T, TD>(\n results: Iterable<DetailedResult<T, TD>>,\n ignore: TD[],\n aggregatedErrors?: IMessageAggregator\n): Result<T[]> {\n const errors: string[] = [];\n const elements: T[] = [];\n\n for (const result of results) {\n if (result.isSuccess()) {\n elements.push(result.value);\n } else if (!ignore.includes(result.detail)) {\n errors.push(result.message);\n }\n }\n\n if (errors.length > 0) {\n aggregatedErrors?.addMessages(errors);\n return fail(errors.join('\\n'));\n }\n return succeed(elements);\n}\n\n/**\n * Aggregates successful results from a a collection of {@link Result | Result<T>}.\n * @param results - An `Iterable` of {@link Result | Result<T>} from which success\n * results are to be aggregated.\n * @param aggregatedErrors - Optional string array to which any returned error messages will be\n * appended. Each error is appended as an individual string.\n * @returns {@link Success} with an array of `<T>` if any results were successful. If\n * all {@link Result | results} failed, returns {@link Failure} with a concatenated\n * summary of all error messages.\n * @public\n */\nexport function mapSuccess<T>(\n results: Iterable<Result<T>>,\n aggregatedErrors?: IMessageAggregator\n): Result<T[]> {\n const errors: string[] = [];\n const elements: T[] = [];\n\n for (const result of results) {\n if (result.isSuccess()) {\n elements.push(result.value);\n } else {\n errors.push(result.message);\n }\n }\n\n if (elements.length === 0 && errors.length > 0) {\n aggregatedErrors?.addMessages(errors);\n return fail(errors.join('\\n'));\n }\n return succeed(elements);\n}\n\n/**\n * Aggregates error messages from a collection of {@link Result | Result<T>}.\n * @param results - An iterable collection of {@link Result | Result<T>} for which\n * error messages are aggregated.\n * @param aggregatedErrors - Optional string array to which any returned error messages will be\n * appended. Each error is appended as an individual string.\n * @returns An array of strings consisting of all error messages returned by\n * {@link Result | results} in the source collection. Ignores {@link Success}\n * results and returns an empty array if there were no errors.\n * @public\n */\nexport function mapFailures<T>(\n results: Iterable<Result<T>>,\n aggregatedErrors?: IMessageAggregator\n): string[] {\n const errors: string[] = [];\n for (const result of results) {\n if (result.isFailure()) {\n errors.push(result.message);\n aggregatedErrors?.addMessage(result.message);\n }\n }\n return errors;\n}\n\n/**\n * Determines if an iterable collection of {@link Result | Result<T>} were all successful.\n * @param results - The collection of {@link Result | Result<T>} to be tested.\n * @param successValue - The value to be returned if results are successful.\n * @param aggregatedErrors - Optional string array to which any returned error messages will be\n * appended. Each error is appended as an individual string.\n * @returns Returns {@link Success} with `successValue` if all {@link Result | results} are successful.\n * If any are unsuccessful, returns {@link Failure} with a concatenated summary of the error\n * messages from all failed elements.\n * @public\n */\nexport function allSucceed<T>(\n results: Iterable<Result<unknown>>,\n successValue: T,\n aggregatedErrors?: IMessageAggregator\n): Result<T> {\n const errors: string[] = [];\n\n if (results !== undefined) {\n for (const result of results) {\n if (result.isFailure()) {\n errors.push(result.message);\n }\n }\n }\n\n if (errors.length > 0) {\n aggregatedErrors?.addMessages(errors);\n return fail(errors.join('\\n'));\n }\n return succeed(successValue);\n}\n\n/**\n * String-keyed record of initialization functions to be passed to {@link (populateObject:1)}\n * or {@link (populateObject:2)}.\n * @public\n */\nexport type FieldInitializers<T> = { [key in keyof T]: (state: Partial<T>) => Result<T[key]> };\n\n/**\n * Options for the {@link (populateObject:1)} function.\n * @public\n */\n// eslint-disable-next-line @typescript-eslint/naming-convention\nexport interface PopulateObjectOptions<T> {\n /**\n * If present, specifies the order in which property values should\n * be evaluated. Any keys not listed are evaluated after all listed\n * keys in indeterminate order. If 'order' is not present, keys\n * are evaluated in indeterminate order.\n */\n order?: (keyof T)[];\n\n /**\n * Specify handling of `undefined` values. By default, successful\n * `undefined` results are written to the result object. If this value\n * is `true` then `undefined` results are suppressed for all properties.\n * If this value is an array of property keys then `undefined` results\n * are suppressed for those properties only.\n */\n suppressUndefined?: boolean | (keyof T)[];\n}\n\n/**\n * Populates an an object based on a prototype full of field initializers that return {@link Result | Result<T[key]>}.\n * Returns {@link Success} with the populated object if all initializers succeed, or {@link Failure} with a\n * concatenated list of all error messages.\n * @param initializers - An object with the shape of the target but with initializer functions for\n * each property.\n * @param options - An optional {@link PopulateObjectOptions | set of options} which\n * modify the behavior of this call.\n * @param aggregatedErrors - Optional string array to which any returned error messages will be\n * appended. Each error is appended as an individual string.\n * {@label WITH_OPTIONS}\n * @public\n */\nexport function populateObject<T>(\n initializers: FieldInitializers<T>,\n options?: PopulateObjectOptions<T>,\n aggregatedErrors?: IMessageAggregator\n): Result<T>;\n\n/**\n * Populates an an object based on a prototype full of field initializers that return {@link Result | Result<T[key]>}.\n * Returns {@link Success} with the populated object if all initializers succeed, or {@link Failure} with a\n * concatenated list of all error messages.\n * @param initializers - An object with the shape of the target but with initializer functions for\n * each property.\n * @param order - Optional order in which keys should be written.\n * @param aggregatedErrors - Optional string array to which any returned error messages will be\n * appended. Each error is appended as an individual string.\n * @public\n * {@label WITH_ORDER}\n * @deprecated Pass {@link PopulateObjectOptions} instead.\n */\nexport function populateObject<T>(\n initializers: FieldInitializers<T>,\n order: (keyof T)[] | undefined,\n aggregatedErrors?: IMessageAggregator\n): Result<T>;\n\nexport function populateObject<T>(\n initializers: FieldInitializers<T>,\n optionsOrOrder?: PopulateObjectOptions<T> | (keyof T)[],\n aggregatedErrors?: IMessageAggregator\n): Result<T> {\n const options: PopulateObjectOptions<T> = optionsOrOrder\n ? Array.isArray(optionsOrOrder)\n ? { order: optionsOrOrder }\n : optionsOrOrder\n : {};\n const state = {} as { [key in keyof T]: T[key] };\n const errors: string[] = [];\n const keys: (keyof T)[] = Array.from(options.order ?? []);\n const foundKeys = new Set<keyof T>(options.order);\n\n // start with the supplied order then append anything else we find\n for (const key in initializers) {\n if (!foundKeys.has(key)) {\n keys.push(key);\n foundKeys.add(key);\n }\n }\n\n for (const key of keys) {\n if (initializers[key]) {\n const result = initializers[key](state);\n if (result.isSuccess()) {\n if (result.value === undefined) {\n if (\n options.suppressUndefined === true ||\n (Array.isArray(options.suppressUndefined) && options.suppressUndefined.includes(key))\n ) {\n continue;\n }\n }\n state[key] = result.value;\n } else {\n errors.push(result.message);\n }\n } else {\n errors.push(`populateObject: Key ${String(key)} is present but has no initializer`);\n }\n }\n\n if (errors.length > 0) {\n aggregatedErrors?.addMessages(errors);\n return fail(errors.join('\\n'));\n }\n return succeed(state as T);\n}\n"]}
|
|
@@ -0,0 +1,56 @@
|
|
|
1
|
+
import { IMessageAggregator, Result } from './result';
|
|
2
|
+
/**
|
|
3
|
+
* A simple error aggregator to simplify collecting and reporting all errors in
|
|
4
|
+
* a flow.
|
|
5
|
+
* @public
|
|
6
|
+
*/
|
|
7
|
+
export declare class MessageAggregator implements IMessageAggregator {
|
|
8
|
+
private readonly _messages;
|
|
9
|
+
/**
|
|
10
|
+
* Constructs a new {@link MessageAggregator | ErrorAggregator} with an
|
|
11
|
+
* optionally specified initial set of error messages.
|
|
12
|
+
* @param errors - optional array of errors to be included
|
|
13
|
+
* in the aggregation.
|
|
14
|
+
*/
|
|
15
|
+
constructor(errors?: string[]);
|
|
16
|
+
/**
|
|
17
|
+
* {@inheritdoc IMessageAggregator.hasMessages}
|
|
18
|
+
*/
|
|
19
|
+
get hasMessages(): boolean;
|
|
20
|
+
/**
|
|
21
|
+
* {@inheritdoc IMessageAggregator.messages}
|
|
22
|
+
*/
|
|
23
|
+
get messages(): string[];
|
|
24
|
+
/**
|
|
25
|
+
* {@inheritdoc IMessageAggregator.addMessage}
|
|
26
|
+
*/
|
|
27
|
+
addMessage(message: string | undefined): this;
|
|
28
|
+
/**
|
|
29
|
+
* {@inheritdoc IMessageAggregator.addMessages}
|
|
30
|
+
*/
|
|
31
|
+
addMessages(messages: string[] | undefined): this;
|
|
32
|
+
/**
|
|
33
|
+
* {@inheritdoc IMessageAggregator.toString}
|
|
34
|
+
*/
|
|
35
|
+
toString(separator?: string): string;
|
|
36
|
+
/**
|
|
37
|
+
* If any error messages have been aggregated, returns
|
|
38
|
+
* {@link Failure | Failure<T>} with the aggregated
|
|
39
|
+
* messages concatenated using the optionally-supplied
|
|
40
|
+
* separator, or newline. If the supplied {@link Result | Result<T>}
|
|
41
|
+
* contains an error message that has not already been aggregated,
|
|
42
|
+
* it will be included in the aggregated messages.
|
|
43
|
+
*
|
|
44
|
+
* If no error messages have been aggregated, returns
|
|
45
|
+
* the supplied {@link Result | Result<T>}.
|
|
46
|
+
* @param result - The {@link Result | Result<T>} to be returned
|
|
47
|
+
* if no messages have been aggregated.
|
|
48
|
+
* @param separator - Optional string separator used to construct
|
|
49
|
+
* the error message.
|
|
50
|
+
* @returns {@link Failure | Failure<T>} with an aggregated message
|
|
51
|
+
* if any error messages were collected, the supplied
|
|
52
|
+
* {@link Result | Result<T>} otherwise.
|
|
53
|
+
*/
|
|
54
|
+
returnOrReport<T>(result: Result<T>, separator?: string): Result<T>;
|
|
55
|
+
}
|
|
56
|
+
//# sourceMappingURL=messageAggregator.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"messageAggregator.d.ts","sourceRoot":"","sources":["../../../src/packlets/base/messageAggregator.ts"],"names":[],"mappings":"AAsBA,OAAO,EAAE,kBAAkB,EAAE,MAAM,EAAQ,MAAM,UAAU,CAAC;AAE5D;;;;GAIG;AACH,qBAAa,iBAAkB,YAAW,kBAAkB;IAC1D,OAAO,CAAC,QAAQ,CAAC,SAAS,CAAW;IAErC;;;;;OAKG;gBACgB,MAAM,CAAC,EAAE,MAAM,EAAE;IAIpC;;OAEG;IACH,IAAW,WAAW,IAAI,OAAO,CAEhC;IAED;;OAEG;IACH,IAAW,QAAQ,IAAI,MAAM,EAAE,CAE9B;IAED;;OAEG;IACI,UAAU,CAAC,OAAO,EAAE,MAAM,GAAG,SAAS,GAAG,IAAI;IAOpD;;OAEG;IACI,WAAW,CAAC,QAAQ,EAAE,MAAM,EAAE,GAAG,SAAS,GAAG,IAAI;IAOxD;;OAEG;IACI,QAAQ,CAAC,SAAS,CAAC,EAAE,MAAM,GAAG,MAAM;IAI3C;;;;;;;;;;;;;;;;;OAiBG;IACI,cAAc,CAAC,CAAC,EAAE,MAAM,EAAE,MAAM,CAAC,CAAC,CAAC,EAAE,SAAS,CAAC,EAAE,MAAM,GAAG,MAAM,CAAC,CAAC,CAAC;CAW3E"}
|
|
@@ -0,0 +1,108 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
/*
|
|
3
|
+
* Copyright (c) 2024 Erik Fortune
|
|
4
|
+
*
|
|
5
|
+
* Permission is hereby granted, free of charge, to any person obtaining a copy
|
|
6
|
+
* of this software and associated documentation files (the "Software"), to deal
|
|
7
|
+
* in the Software without restriction, including without limitation the rights
|
|
8
|
+
* to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
|
|
9
|
+
* copies of the Software, and to permit persons to whom the Software is
|
|
10
|
+
* furnished to do so, subject to the following conditions:
|
|
11
|
+
*
|
|
12
|
+
* The above copyright notice and this permission notice shall be included in all
|
|
13
|
+
* copies or substantial portions of the Software.
|
|
14
|
+
*
|
|
15
|
+
* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
|
|
16
|
+
* IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
|
|
17
|
+
* FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
|
|
18
|
+
* AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
|
|
19
|
+
* LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
|
|
20
|
+
* OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
|
|
21
|
+
* SOFTWARE.
|
|
22
|
+
*/
|
|
23
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
24
|
+
exports.MessageAggregator = void 0;
|
|
25
|
+
const result_1 = require("./result");
|
|
26
|
+
/**
|
|
27
|
+
* A simple error aggregator to simplify collecting and reporting all errors in
|
|
28
|
+
* a flow.
|
|
29
|
+
* @public
|
|
30
|
+
*/
|
|
31
|
+
class MessageAggregator {
|
|
32
|
+
/**
|
|
33
|
+
* Constructs a new {@link MessageAggregator | ErrorAggregator} with an
|
|
34
|
+
* optionally specified initial set of error messages.
|
|
35
|
+
* @param errors - optional array of errors to be included
|
|
36
|
+
* in the aggregation.
|
|
37
|
+
*/
|
|
38
|
+
constructor(errors) {
|
|
39
|
+
this._messages = errors ? Array.from(errors) : [];
|
|
40
|
+
}
|
|
41
|
+
/**
|
|
42
|
+
* {@inheritdoc IMessageAggregator.hasMessages}
|
|
43
|
+
*/
|
|
44
|
+
get hasMessages() {
|
|
45
|
+
return this._messages.length > 0;
|
|
46
|
+
}
|
|
47
|
+
/**
|
|
48
|
+
* {@inheritdoc IMessageAggregator.messages}
|
|
49
|
+
*/
|
|
50
|
+
get messages() {
|
|
51
|
+
return this._messages;
|
|
52
|
+
}
|
|
53
|
+
/**
|
|
54
|
+
* {@inheritdoc IMessageAggregator.addMessage}
|
|
55
|
+
*/
|
|
56
|
+
addMessage(message) {
|
|
57
|
+
if (message) {
|
|
58
|
+
this._messages.push(message);
|
|
59
|
+
}
|
|
60
|
+
return this;
|
|
61
|
+
}
|
|
62
|
+
/**
|
|
63
|
+
* {@inheritdoc IMessageAggregator.addMessages}
|
|
64
|
+
*/
|
|
65
|
+
addMessages(messages) {
|
|
66
|
+
if (messages && messages.length > 0) {
|
|
67
|
+
this._messages.push(...messages);
|
|
68
|
+
}
|
|
69
|
+
return this;
|
|
70
|
+
}
|
|
71
|
+
/**
|
|
72
|
+
* {@inheritdoc IMessageAggregator.toString}
|
|
73
|
+
*/
|
|
74
|
+
toString(separator) {
|
|
75
|
+
return this._messages.join(separator !== null && separator !== void 0 ? separator : '\n');
|
|
76
|
+
}
|
|
77
|
+
/**
|
|
78
|
+
* If any error messages have been aggregated, returns
|
|
79
|
+
* {@link Failure | Failure<T>} with the aggregated
|
|
80
|
+
* messages concatenated using the optionally-supplied
|
|
81
|
+
* separator, or newline. If the supplied {@link Result | Result<T>}
|
|
82
|
+
* contains an error message that has not already been aggregated,
|
|
83
|
+
* it will be included in the aggregated messages.
|
|
84
|
+
*
|
|
85
|
+
* If no error messages have been aggregated, returns
|
|
86
|
+
* the supplied {@link Result | Result<T>}.
|
|
87
|
+
* @param result - The {@link Result | Result<T>} to be returned
|
|
88
|
+
* if no messages have been aggregated.
|
|
89
|
+
* @param separator - Optional string separator used to construct
|
|
90
|
+
* the error message.
|
|
91
|
+
* @returns {@link Failure | Failure<T>} with an aggregated message
|
|
92
|
+
* if any error messages were collected, the supplied
|
|
93
|
+
* {@link Result | Result<T>} otherwise.
|
|
94
|
+
*/
|
|
95
|
+
returnOrReport(result, separator) {
|
|
96
|
+
if (!this.hasMessages) {
|
|
97
|
+
return result;
|
|
98
|
+
}
|
|
99
|
+
if (!result.success) {
|
|
100
|
+
if (!this._messages.find((s) => s === result.message)) {
|
|
101
|
+
return (0, result_1.fail)([...this._messages, result.message].join(separator !== null && separator !== void 0 ? separator : '\n'));
|
|
102
|
+
}
|
|
103
|
+
}
|
|
104
|
+
return (0, result_1.fail)(this.toString(separator));
|
|
105
|
+
}
|
|
106
|
+
}
|
|
107
|
+
exports.MessageAggregator = MessageAggregator;
|
|
108
|
+
//# sourceMappingURL=messageAggregator.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"messageAggregator.js","sourceRoot":"","sources":["../../../src/packlets/base/messageAggregator.ts"],"names":[],"mappings":";AAAA;;;;;;;;;;;;;;;;;;;;GAoBG;;;AAEH,qCAA4D;AAE5D;;;;GAIG;AACH,M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E,CAAC;gBACtD,OAAO,IAAA,aAAI,EAAC,CAAC,GAAG,IAAI,CAAC,SAAS,EAAE,MAAM,CAAC,OAAO,CAAC,CAAC,IAAI,CAAC,SAAS,aAAT,SAAS,cAAT,SAAS,GAAI,IAAI,CAAC,CAAC,CAAC;YAC3E,CAAC;QACH,CAAC;QACD,OAAO,IAAA,aAAI,EAAC,IAAI,CAAC,QAAQ,CAAC,SAAS,CAAC,CAAC,CAAC;IACxC,CAAC;CACF;AAnFD,8CAmFC","sourcesContent":["/*\n * Copyright (c) 2024 Erik Fortune\n *\n * Permission is hereby granted, free of charge, to any person obtaining a copy\n * of this software and associated documentation files (the \"Software\"), to deal\n * in the Software without restriction, including without limitation the rights\n * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell\n * copies of the Software, and to permit persons to whom the Software is\n * furnished to do so, subject to the following conditions:\n *\n * The above copyright notice and this permission notice shall be included in all\n * copies or substantial portions of the Software.\n *\n * THE SOFTWARE IS PROVIDED \"AS IS\", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR\n * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,\n * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE\n * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER\n * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,\n * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE\n * SOFTWARE.\n */\n\nimport { IMessageAggregator, Result, fail } from './result';\n\n/**\n * A simple error aggregator to simplify collecting and reporting all errors in\n * a flow.\n * @public\n */\nexport class MessageAggregator implements IMessageAggregator {\n private readonly _messages: string[];\n\n /**\n * Constructs a new {@link MessageAggregator | ErrorAggregator} with an\n * optionally specified initial set of error messages.\n * @param errors - optional array of errors to be included\n * in the aggregation.\n */\n public constructor(errors?: string[]) {\n this._messages = errors ? Array.from(errors) : [];\n }\n\n /**\n * {@inheritdoc IMessageAggregator.hasMessages}\n */\n public get hasMessages(): boolean {\n return this._messages.length > 0;\n }\n\n /**\n * {@inheritdoc IMessageAggregator.messages}\n */\n public get messages(): string[] {\n return this._messages;\n }\n\n /**\n * {@inheritdoc IMessageAggregator.addMessage}\n */\n public addMessage(message: string | undefined): this {\n if (message) {\n this._messages.push(message);\n }\n return this;\n }\n\n /**\n * {@inheritdoc IMessageAggregator.addMessages}\n */\n public addMessages(messages: string[] | undefined): this {\n if (messages && messages.length > 0) {\n this._messages.push(...messages);\n }\n return this;\n }\n\n /**\n * {@inheritdoc IMessageAggregator.toString}\n */\n public toString(separator?: string): string {\n return this._messages.join(separator ?? '\\n');\n }\n\n /**\n * If any error messages have been aggregated, returns\n * {@link Failure | Failure<T>} with the aggregated\n * messages concatenated using the optionally-supplied\n * separator, or newline. If the supplied {@link Result | Result<T>}\n * contains an error message that has not already been aggregated,\n * it will be included in the aggregated messages.\n *\n * If no error messages have been aggregated, returns\n * the supplied {@link Result | Result<T>}.\n * @param result - The {@link Result | Result<T>} to be returned\n * if no messages have been aggregated.\n * @param separator - Optional string separator used to construct\n * the error message.\n * @returns {@link Failure | Failure<T>} with an aggregated message\n * if any error messages were collected, the supplied\n * {@link Result | Result<T>} otherwise.\n */\n public returnOrReport<T>(result: Result<T>, separator?: string): Result<T> {\n if (!this.hasMessages) {\n return result;\n }\n if (!result.success) {\n if (!this._messages.find((s) => s === result.message)) {\n return fail([...this._messages, result.message].join(separator ?? '\\n'));\n }\n }\n return fail(this.toString(separator));\n }\n}\n"]}
|
|
@@ -34,6 +34,40 @@ export interface IResultLogger {
|
|
|
34
34
|
*/
|
|
35
35
|
error(message: string): void;
|
|
36
36
|
}
|
|
37
|
+
/**
|
|
38
|
+
* Simple error aggregator to simplify collecting all errors in
|
|
39
|
+
* a flow.
|
|
40
|
+
* @public
|
|
41
|
+
*/
|
|
42
|
+
export interface IMessageAggregator {
|
|
43
|
+
/**
|
|
44
|
+
* Indicates whether any messages have been aggregated.
|
|
45
|
+
*/
|
|
46
|
+
readonly hasMessages: boolean;
|
|
47
|
+
/**
|
|
48
|
+
* The aggregated messages.
|
|
49
|
+
*/
|
|
50
|
+
readonly messages: ReadonlyArray<string>;
|
|
51
|
+
/**
|
|
52
|
+
* Adds a message to the aggregator, if defined.
|
|
53
|
+
* @param message - The message to add - pass `undefined`
|
|
54
|
+
* or the empty string to continue without adding a message.
|
|
55
|
+
*/
|
|
56
|
+
addMessage(message: string | undefined): this;
|
|
57
|
+
/**
|
|
58
|
+
* Adds multiple messages to the aggregator.
|
|
59
|
+
* @param messages - the messages to add.
|
|
60
|
+
*/
|
|
61
|
+
addMessages(messages: string[] | undefined): this;
|
|
62
|
+
/**
|
|
63
|
+
* Returns all messages as a single string joined
|
|
64
|
+
* using the optionally-supplied `separator`, or
|
|
65
|
+
* newline if no separator is specified.
|
|
66
|
+
* @param separator - The optional separator used
|
|
67
|
+
* to join strings.
|
|
68
|
+
*/
|
|
69
|
+
toString(separator?: string): string;
|
|
70
|
+
}
|
|
37
71
|
/**
|
|
38
72
|
* Represents the result of some operation of sequence of operations.
|
|
39
73
|
* @remarks
|
|
@@ -155,6 +189,13 @@ export interface IResult<T> {
|
|
|
155
189
|
* appropriate added detail.
|
|
156
190
|
*/
|
|
157
191
|
withDetail<TD>(detail: TD, successDetail?: TD): DetailedResult<T, TD>;
|
|
192
|
+
/**
|
|
193
|
+
* Propagates interior result, appending any error message to the
|
|
194
|
+
* supplied errors array.
|
|
195
|
+
* @param errors - {@link IMessageAggregator | Error aggregator} in which
|
|
196
|
+
* errors will be aggregated.
|
|
197
|
+
*/
|
|
198
|
+
aggregateError(errors: IMessageAggregator): this;
|
|
158
199
|
}
|
|
159
200
|
/**
|
|
160
201
|
* Reports a successful {@link IResult | result} from some operation and the
|
|
@@ -225,6 +266,10 @@ export declare class Success<T> implements IResult<T> {
|
|
|
225
266
|
* {@inheritdoc IResult.withDetail}
|
|
226
267
|
*/
|
|
227
268
|
withDetail<TD>(detail: TD, successDetail?: TD): DetailedResult<T, TD>;
|
|
269
|
+
/**
|
|
270
|
+
* {@inheritdoc IResult.aggregateError}
|
|
271
|
+
*/
|
|
272
|
+
aggregateError(errors: IMessageAggregator): this;
|
|
228
273
|
}
|
|
229
274
|
/**
|
|
230
275
|
* Reports a failed {@link IResult | result} from some operation, with an error message.
|
|
@@ -294,6 +339,10 @@ export declare class Failure<T> implements IResult<T> {
|
|
|
294
339
|
* {@inheritdoc IResult.withDetail}
|
|
295
340
|
*/
|
|
296
341
|
withDetail<TD>(detail: TD, __successDetail?: TD): DetailedResult<T, TD>;
|
|
342
|
+
/**
|
|
343
|
+
* {@inheritdoc IResult.aggregateError}
|
|
344
|
+
*/
|
|
345
|
+
aggregateError(errors: IMessageAggregator): this;
|
|
297
346
|
/**
|
|
298
347
|
* Get a 'friendly' string representation of this object.
|
|
299
348
|
* @remarks
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"result.d.ts","sourceRoot":"","sources":["../../../src/packlets/base/result.ts"],"names":[],"mappings":"AAuBA;;;;;;GAMG;AACH,MAAM,MAAM,MAAM,CAAC,CAAC,IAAI,OAAO,CAAC,CAAC,CAAC,GAAG,OAAO,CAAC,CAAC,CAAC,CAAC;AAChD;;;;GAIG;AACH,MAAM,MAAM,mBAAmB,CAAC,CAAC,EAAE,EAAE,IAAI,CAAC,KAAK,EAAE,CAAC,KAAK,MAAM,CAAC,EAAE,CAAC,CAAC;AAClE;;;;GAIG;AACH,MAAM,MAAM,mBAAmB,CAAC,CAAC,IAAI,CAAC,OAAO,EAAE,MAAM,KAAK,MAAM,CAAC,CAAC,CAAC,CAAC;AACpE;;;GAGG;AACH,MAAM,MAAM,eAAe,CAAC,CAAC,IAAI,CAAC,SAAS,MAAM,CAAC,MAAM,EAAE,CAAC,GAAG,EAAE,GAAG,KAAK,CAAC;AAEzE;;;GAGG;AACH,MAAM,WAAW,aAAa;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E,OAAO,EAAE,MAAM,EAAE,MAAM,EAAE,EAAE,GAAG,eAAe,CAAC,CAAC,EAAE,EAAE,CAAC,CAEzF;AAED;;;;;;;;;;GAUG;AACH,wBAAgB,mBAAmB,CAAC,CAAC,EAAE,EAAE,EACvC,MAAM,EAAE,MAAM,CAAC,CAAC,CAAC,EACjB,MAAM,EAAE,EAAE,EACV,aAAa,CAAC,EAAE,EAAE,GACjB,cAAc,CAAC,CAAC,EAAE,EAAE,CAAC,CAIvB;AAED;;;;;;;;GAQG;AACH,wBAAgB,aAAa,CAAC,CAAC,EAAE,IAAI,EAAE,MAAM,CAAC,GAAG,MAAM,CAAC,CAAC,CAAC,CAMzD"}
|
|
@@ -106,6 +106,12 @@ class Success {
|
|
|
106
106
|
withDetail(detail, successDetail) {
|
|
107
107
|
return succeedWithDetail(this.value, successDetail !== null && successDetail !== void 0 ? successDetail : detail);
|
|
108
108
|
}
|
|
109
|
+
/**
|
|
110
|
+
* {@inheritdoc IResult.aggregateError}
|
|
111
|
+
*/
|
|
112
|
+
aggregateError(errors) {
|
|
113
|
+
return this;
|
|
114
|
+
}
|
|
109
115
|
}
|
|
110
116
|
exports.Success = Success;
|
|
111
117
|
/**
|
|
@@ -195,6 +201,13 @@ class Failure {
|
|
|
195
201
|
withDetail(detail, __successDetail) {
|
|
196
202
|
return failWithDetail(this.message, detail);
|
|
197
203
|
}
|
|
204
|
+
/**
|
|
205
|
+
* {@inheritdoc IResult.aggregateError}
|
|
206
|
+
*/
|
|
207
|
+
aggregateError(errors) {
|
|
208
|
+
errors.addMessage(this.message);
|
|
209
|
+
return this;
|
|
210
|
+
}
|
|
198
211
|
/**
|
|
199
212
|
* Get a 'friendly' string representation of this object.
|
|
200
213
|
* @remarks
|