exupery-core-async 0.3.28 → 0.3.30
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.
|
@@ -1,22 +1,14 @@
|
|
|
1
1
|
import * as _et from 'exupery-core-types';
|
|
2
|
-
export type Assert_Async_Error<Assertion_Error, Procedure_Error> = ['assertion error', Assertion_Error] | ['assertion failed', null] | ['procedure error', Procedure_Error];
|
|
3
|
-
export type Assert_Sync_Error<Procedure_Error> = ['assertion failed', null] | ['procedure error', Procedure_Error];
|
|
4
|
-
export type Conditional_Multiple_Error<Precondition_Error, Procedure_Error> = ['preconditions', _et.Dictionary<Precondition_Error>] | ['procedure', Procedure_Error];
|
|
5
|
-
export type Dictionary_Serie_Error<Err> = {
|
|
6
|
-
'error': Err;
|
|
7
|
-
'step': string;
|
|
8
|
-
};
|
|
9
2
|
export declare namespace p {
|
|
10
3
|
const array_parallel: <Error, Element_Error>(the_array: _et.Array<_et.Procedure_Promise<Element_Error>>, aggregate_errors: _et.Transformer_Without_Parameters<_et.Array<Element_Error>, Error>) => _et.Procedure_Promise<Error>;
|
|
11
4
|
const array_serie: <Error>(array: _et.Array<_et.Procedure_Promise<Error>>) => _et.Procedure_Promise<Error>;
|
|
12
|
-
const assert_async: <
|
|
13
|
-
const assert_sync: <
|
|
5
|
+
const assert_async: <Error>(assertion: _et.Query_Promise<boolean, Error>, error_if_failed: Error) => _et.Procedure_Promise<Error>;
|
|
6
|
+
const assert_sync: <Error>(assertion: boolean, error_if_failed: Error) => _et.Procedure_Promise<Error>;
|
|
14
7
|
const conditional_async: <Error>(precondition: _et.Query_Promise<boolean, Error>, procedure: _et.Procedure_Promise<Error>) => _et.Procedure_Promise<Error>;
|
|
15
|
-
const conditional_multiple: <Precondition_Error, Procedure_Error>(preconditions: _et.Dictionary<_et.Query_Promise<boolean, Precondition_Error>>, procedure: _et.Procedure_Promise<Procedure_Error>) => _et.Procedure_Promise<Conditional_Multiple_Error<Precondition_Error, Procedure_Error>>;
|
|
16
8
|
const conditional_sync: <Error>(precondition: boolean, procedure: _et.Procedure_Promise<Error>) => _et.Procedure_Promise<Error>;
|
|
17
|
-
const dictionary_serie: <
|
|
18
|
-
const dictionary_parallel_without_error_aggregation: <Error>(dictionary: _et.Dictionary<_et.Procedure_Promise<Error>>) => _et.Procedure_Promise<_et.Dictionary<Error>>;
|
|
9
|
+
const dictionary_serie: <Error, Entry_Error>(dictionary: _et.Dictionary<_et.Procedure_Promise<Entry_Error>>, transform_error: _et.Transformer_Without_Parameters<_et.Key_Value_Pair<Entry_Error>, Error>) => _et.Procedure_Promise<Error>;
|
|
19
10
|
const dictionary_parallel: <Error, Entry_Error>(dictionary: _et.Dictionary<_et.Procedure_Promise<Entry_Error>>, aggregate_errors: _et.Transformer_Without_Parameters<_et.Dictionary<Entry_Error>, Error>) => _et.Procedure_Promise<Error>;
|
|
11
|
+
const dictionary_parallel_without_transforming_the_error: <Error, Entry_Error>(dictionary: _et.Dictionary<_et.Procedure_Promise<Entry_Error>>) => _et.Procedure_Promise<_et.Dictionary<Entry_Error>>;
|
|
20
12
|
const execute_with_async_data: <Parameters, Error>(procedure: _et.Procedure_Primed_With_Resources<Parameters, Error>, query: _et.Query_Promise<Parameters, Error>) => _et.Procedure_Promise<Error>;
|
|
21
13
|
const sequence: <Error>(steps: _et.Procedure_Promise<Error>[]) => _et.Procedure_Promise<Error>;
|
|
22
14
|
}
|
|
@@ -26,7 +26,6 @@ Object.defineProperty(exports, "__esModule", { value: true });
|
|
|
26
26
|
exports.p = void 0;
|
|
27
27
|
const _ei = __importStar(require("exupery-core-internals"));
|
|
28
28
|
const create_procedure_promise_1 = require("../algorithms/procedure/create_procedure_promise");
|
|
29
|
-
const query_1 = require("./query");
|
|
30
29
|
const create_asynchronous_processes_monitor_1 = require("../create_asynchronous_processes_monitor");
|
|
31
30
|
var p;
|
|
32
31
|
(function (p) {
|
|
@@ -73,34 +72,30 @@ var p;
|
|
|
73
72
|
}
|
|
74
73
|
});
|
|
75
74
|
};
|
|
76
|
-
p.assert_async = (assertion,
|
|
75
|
+
p.assert_async = (assertion, error_if_failed) => {
|
|
77
76
|
return (0, create_procedure_promise_1.__create_procedure_promise)({
|
|
78
77
|
'execute': (on_success, on_error) => {
|
|
79
78
|
assertion.__start(($) => {
|
|
80
79
|
if ($) {
|
|
81
|
-
|
|
82
|
-
on_error(['procedure error', $]);
|
|
83
|
-
});
|
|
80
|
+
on_success();
|
|
84
81
|
}
|
|
85
82
|
else {
|
|
86
|
-
on_error(
|
|
83
|
+
on_error(error_if_failed);
|
|
87
84
|
}
|
|
88
85
|
}, ($) => {
|
|
89
|
-
on_error(
|
|
86
|
+
on_error($);
|
|
90
87
|
});
|
|
91
88
|
}
|
|
92
89
|
});
|
|
93
90
|
};
|
|
94
|
-
p.assert_sync = (assertion,
|
|
91
|
+
p.assert_sync = (assertion, error_if_failed) => {
|
|
95
92
|
return (0, create_procedure_promise_1.__create_procedure_promise)({
|
|
96
93
|
'execute': (on_success, on_error) => {
|
|
97
94
|
if (!assertion) {
|
|
98
|
-
on_error(
|
|
95
|
+
on_error(error_if_failed);
|
|
99
96
|
return;
|
|
100
97
|
}
|
|
101
|
-
|
|
102
|
-
on_error(['procedure error', $]);
|
|
103
|
-
});
|
|
98
|
+
on_success();
|
|
104
99
|
}
|
|
105
100
|
});
|
|
106
101
|
};
|
|
@@ -118,32 +113,6 @@ var p;
|
|
|
118
113
|
}
|
|
119
114
|
});
|
|
120
115
|
};
|
|
121
|
-
p.conditional_multiple = (preconditions, procedure) => {
|
|
122
|
-
return (0, create_procedure_promise_1.__create_procedure_promise)({
|
|
123
|
-
'execute': (on_success, on_error) => {
|
|
124
|
-
query_1.q.dictionary_parallel_without_error_aggregation(preconditions).__start(($) => {
|
|
125
|
-
let has_errors = false;
|
|
126
|
-
$.map(($) => {
|
|
127
|
-
if (!$) {
|
|
128
|
-
has_errors = true;
|
|
129
|
-
}
|
|
130
|
-
});
|
|
131
|
-
if (!has_errors) {
|
|
132
|
-
// all preconditions passed
|
|
133
|
-
procedure.__start(on_success, (e) => {
|
|
134
|
-
on_error(['procedure', e]);
|
|
135
|
-
});
|
|
136
|
-
}
|
|
137
|
-
else {
|
|
138
|
-
//the preconditions failed, so we are *successfully* skipping the procedure
|
|
139
|
-
on_success();
|
|
140
|
-
}
|
|
141
|
-
}, ($) => {
|
|
142
|
-
on_error(['preconditions', $]);
|
|
143
|
-
});
|
|
144
|
-
}
|
|
145
|
-
});
|
|
146
|
-
};
|
|
147
116
|
p.conditional_sync = (precondition, procedure) => {
|
|
148
117
|
return (0, create_procedure_promise_1.__create_procedure_promise)({
|
|
149
118
|
'execute': (on_success, on_error) => {
|
|
@@ -156,7 +125,7 @@ var p;
|
|
|
156
125
|
}
|
|
157
126
|
});
|
|
158
127
|
};
|
|
159
|
-
p.dictionary_serie = (dictionary) => {
|
|
128
|
+
p.dictionary_serie = (dictionary, transform_error) => {
|
|
160
129
|
return (0, create_procedure_promise_1.__create_procedure_promise)({
|
|
161
130
|
'execute': (on_success, on_error) => {
|
|
162
131
|
const op_dictionary_to_list_based_on_insertion_order = (dict) => {
|
|
@@ -175,10 +144,10 @@ var p;
|
|
|
175
144
|
$.value.__start(() => {
|
|
176
145
|
do_next();
|
|
177
146
|
}, ($) => {
|
|
178
|
-
on_error({
|
|
179
|
-
'
|
|
180
|
-
'
|
|
181
|
-
});
|
|
147
|
+
on_error(transform_error({
|
|
148
|
+
'value': $,
|
|
149
|
+
'key': key,
|
|
150
|
+
}));
|
|
182
151
|
});
|
|
183
152
|
}, () => {
|
|
184
153
|
on_success();
|
|
@@ -188,36 +157,32 @@ var p;
|
|
|
188
157
|
}
|
|
189
158
|
});
|
|
190
159
|
};
|
|
191
|
-
p.
|
|
160
|
+
p.dictionary_parallel = (dictionary, aggregate_errors) => {
|
|
192
161
|
return (0, create_procedure_promise_1.__create_procedure_promise)({
|
|
193
162
|
'execute': (on_success, on_error) => {
|
|
194
|
-
let count_down = dictionary.__get_number_of_entries();
|
|
195
|
-
let has_errors = false;
|
|
196
163
|
const errors = {};
|
|
197
|
-
|
|
198
|
-
|
|
199
|
-
|
|
200
|
-
|
|
201
|
-
|
|
202
|
-
}
|
|
203
|
-
|
|
204
|
-
|
|
205
|
-
}
|
|
206
|
-
}
|
|
207
|
-
};
|
|
208
|
-
dictionary.map(($, key) => {
|
|
209
|
-
$.__start(() => {
|
|
210
|
-
decrement_and_wrap_up_if_done();
|
|
211
|
-
}, (e) => {
|
|
212
|
-
has_errors = true;
|
|
213
|
-
errors[key] = e;
|
|
214
|
-
decrement_and_wrap_up_if_done();
|
|
164
|
+
(0, create_asynchronous_processes_monitor_1.create_asynchronous_processes_monitor)((monitor) => {
|
|
165
|
+
dictionary.map(($, key) => {
|
|
166
|
+
monitor['report process started']();
|
|
167
|
+
$.__start(() => {
|
|
168
|
+
monitor['report process finished']();
|
|
169
|
+
}, (e) => {
|
|
170
|
+
errors[key] = e;
|
|
171
|
+
monitor['report process finished']();
|
|
172
|
+
});
|
|
215
173
|
});
|
|
174
|
+
}, () => {
|
|
175
|
+
if (Object.keys(errors).length === 0) {
|
|
176
|
+
on_success();
|
|
177
|
+
}
|
|
178
|
+
else {
|
|
179
|
+
on_error(aggregate_errors(_ei.dictionary_literal(errors)));
|
|
180
|
+
}
|
|
216
181
|
});
|
|
217
182
|
}
|
|
218
183
|
});
|
|
219
184
|
};
|
|
220
|
-
p.
|
|
185
|
+
p.dictionary_parallel_without_transforming_the_error = (dictionary) => {
|
|
221
186
|
return (0, create_procedure_promise_1.__create_procedure_promise)({
|
|
222
187
|
'execute': (on_success, on_error) => {
|
|
223
188
|
const errors = {};
|
|
@@ -236,7 +201,7 @@ var p;
|
|
|
236
201
|
on_success();
|
|
237
202
|
}
|
|
238
203
|
else {
|
|
239
|
-
on_error(
|
|
204
|
+
on_error(_ei.dictionary_literal(errors));
|
|
240
205
|
}
|
|
241
206
|
});
|
|
242
207
|
}
|