exupery-core-async 0.3.26 → 0.3.27
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.
|
@@ -4,17 +4,17 @@ exports.__create_procedure_primed_with_resources = void 0;
|
|
|
4
4
|
const create_procedure_promise_1 = require("./create_procedure_promise");
|
|
5
5
|
const __create_procedure_primed_with_resources = (handler) => {
|
|
6
6
|
return {
|
|
7
|
-
'execute with synchronous data': handler,
|
|
8
|
-
'execute with synchronous data
|
|
7
|
+
'execute with synchronous data without error transformation': handler,
|
|
8
|
+
'execute with synchronous data': (parameters, transform_error) => {
|
|
9
9
|
return (0, create_procedure_promise_1.__create_procedure_promise)({
|
|
10
10
|
'execute': (on_success, on_error) => {
|
|
11
11
|
handler(parameters).__start(on_success, (error) => {
|
|
12
|
-
on_error(
|
|
12
|
+
on_error(transform_error(error));
|
|
13
13
|
});
|
|
14
14
|
}
|
|
15
15
|
});
|
|
16
16
|
},
|
|
17
|
-
'execute with asynchronous data': (query) => {
|
|
17
|
+
'execute with asynchronous data without error transformation': (query) => {
|
|
18
18
|
return (0, create_procedure_promise_1.__create_procedure_promise)({
|
|
19
19
|
'execute': (on_success, on_error) => {
|
|
20
20
|
query.__start(($) => {
|
|
@@ -23,15 +23,15 @@ const __create_procedure_primed_with_resources = (handler) => {
|
|
|
23
23
|
}
|
|
24
24
|
});
|
|
25
25
|
},
|
|
26
|
-
'execute with asynchronous data
|
|
26
|
+
'execute with asynchronous data': (query, transform_error) => {
|
|
27
27
|
return (0, create_procedure_promise_1.__create_procedure_promise)({
|
|
28
28
|
'execute': (on_success, on_error) => {
|
|
29
29
|
query.__start(($) => {
|
|
30
30
|
handler($).__start(on_success, (error) => {
|
|
31
|
-
on_error(
|
|
31
|
+
on_error(transform_error(error));
|
|
32
32
|
});
|
|
33
33
|
}, (error) => {
|
|
34
|
-
on_error(
|
|
34
|
+
on_error(transform_error(error));
|
|
35
35
|
});
|
|
36
36
|
}
|
|
37
37
|
});
|
|
@@ -3,25 +3,21 @@ export type Assert_Async_Error<Assertion_Error, Procedure_Error> = ['assertion e
|
|
|
3
3
|
export type Assert_Sync_Error<Procedure_Error> = ['assertion failed', null] | ['procedure error', Procedure_Error];
|
|
4
4
|
export type Conditional_Async_Error<Precondition_Error, Procedure_Error> = ['precondition', Precondition_Error] | ['procedure', Procedure_Error];
|
|
5
5
|
export type Conditional_Multiple_Error<Precondition_Error, Procedure_Error> = ['preconditions', _et.Dictionary<Precondition_Error>] | ['procedure', Procedure_Error];
|
|
6
|
-
export type
|
|
7
|
-
export type Two_Steps_Error<Step_1_Error, Step_2_Error> = ['step1', Step_1_Error] | ['step2', Step_2_Error];
|
|
8
|
-
export type Sequence_Error<Err> = {
|
|
6
|
+
export type Dictionary_Serie_Error<Err> = {
|
|
9
7
|
'error': Err;
|
|
10
8
|
'step': string;
|
|
11
9
|
};
|
|
12
10
|
export declare namespace p {
|
|
13
|
-
const
|
|
11
|
+
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>;
|
|
12
|
+
const array_serie: <Error>(array: _et.Array<_et.Procedure_Promise<Error>>) => _et.Procedure_Promise<Error>;
|
|
14
13
|
const assert_async: <Assertion_Error, Procedure_Error>(assertion: _et.Query_Promise<boolean, Assertion_Error>, procedure: _et.Procedure_Promise<Procedure_Error>) => _et.Procedure_Promise<Assert_Async_Error<Assertion_Error, Procedure_Error>>;
|
|
15
14
|
const assert_sync: <Assertion_Error, Procedure_Error>(assertion: boolean, procedure: _et.Procedure_Promise<Procedure_Error>) => _et.Procedure_Promise<Assert_Sync_Error<Procedure_Error>>;
|
|
16
15
|
const conditional_async: <Precondition_Error, Procedure_Error>(precondition: _et.Query_Promise<boolean, Precondition_Error>, procedure: _et.Procedure_Promise<Procedure_Error>) => _et.Procedure_Promise<Conditional_Async_Error<Precondition_Error, Procedure_Error>>;
|
|
17
16
|
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>>;
|
|
18
17
|
const conditional_sync: <Procedure_Error>(precondition: boolean, procedure: _et.Procedure_Promise<Procedure_Error>) => _et.Procedure_Promise<Procedure_Error>;
|
|
19
|
-
const
|
|
20
|
-
const
|
|
21
|
-
const
|
|
18
|
+
const dictionary_serie: <Err>(dictionary: _et.Dictionary<_et.Procedure_Promise<Err>>) => _et.Procedure_Promise<Dictionary_Serie_Error<Err>>;
|
|
19
|
+
const dictionary_parallel_without_error_aggregation: <Error>(dictionary: _et.Dictionary<_et.Procedure_Promise<Error>>) => _et.Procedure_Promise<_et.Dictionary<Error>>;
|
|
20
|
+
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>;
|
|
22
21
|
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>;
|
|
23
|
-
const sequence: <Error>(steps: _et.
|
|
24
|
-
const sequence_2: <Error>(steps: _et.Procedure_Promise<Error>[]) => _et.Procedure_Promise<Error>;
|
|
25
|
-
const three_steps: <Step_1_Error, Step_2_Error, Step_3_Error>(step_1: _et.Procedure_Promise<Step_1_Error>, step_2: _et.Procedure_Promise<Step_2_Error>, step_3: _et.Procedure_Promise<Step_3_Error>) => _et.Procedure_Promise<Three_Steps_Error<Step_1_Error, Step_2_Error, Step_3_Error>>;
|
|
26
|
-
const two_steps: <Step_1_Error, Step_2_Error>(step_1: _et.Procedure_Promise<Step_1_Error>, step_2: _et.Procedure_Promise<Step_2_Error>) => _et.Procedure_Promise<Two_Steps_Error<Step_1_Error, Step_2_Error>>;
|
|
22
|
+
const sequence: <Error>(steps: _et.Procedure_Promise<Error>[]) => _et.Procedure_Promise<Error>;
|
|
27
23
|
}
|
|
@@ -30,7 +30,7 @@ const query_1 = require("./query");
|
|
|
30
30
|
const create_asynchronous_processes_monitor_1 = require("../create_asynchronous_processes_monitor");
|
|
31
31
|
var p;
|
|
32
32
|
(function (p) {
|
|
33
|
-
p.
|
|
33
|
+
p.array_parallel = (the_array, aggregate_errors) => {
|
|
34
34
|
return (0, create_procedure_promise_1.__create_procedure_promise)({
|
|
35
35
|
'execute': (on_success, on_error) => {
|
|
36
36
|
const errors = [];
|
|
@@ -55,6 +55,24 @@ var p;
|
|
|
55
55
|
}
|
|
56
56
|
});
|
|
57
57
|
};
|
|
58
|
+
p.array_serie = (array) => {
|
|
59
|
+
return (0, create_procedure_promise_1.__create_procedure_promise)({
|
|
60
|
+
'execute': (on_success, on_error) => {
|
|
61
|
+
let current = 0;
|
|
62
|
+
const do_next = () => {
|
|
63
|
+
array.__get_element_at(current).transform(($) => {
|
|
64
|
+
current += 1;
|
|
65
|
+
$.__start(() => {
|
|
66
|
+
do_next();
|
|
67
|
+
}, on_error);
|
|
68
|
+
}, () => {
|
|
69
|
+
on_success();
|
|
70
|
+
});
|
|
71
|
+
};
|
|
72
|
+
do_next();
|
|
73
|
+
}
|
|
74
|
+
});
|
|
75
|
+
};
|
|
58
76
|
p.assert_async = (assertion, procedure) => {
|
|
59
77
|
return (0, create_procedure_promise_1.__create_procedure_promise)({
|
|
60
78
|
'execute': (on_success, on_error) => {
|
|
@@ -107,7 +125,7 @@ var p;
|
|
|
107
125
|
p.conditional_multiple = (preconditions, procedure) => {
|
|
108
126
|
return (0, create_procedure_promise_1.__create_procedure_promise)({
|
|
109
127
|
'execute': (on_success, on_error) => {
|
|
110
|
-
query_1.q.
|
|
128
|
+
query_1.q.dictionary_parallel_without_error_aggregation(preconditions).__start(($) => {
|
|
111
129
|
let has_errors = false;
|
|
112
130
|
$.map(($) => {
|
|
113
131
|
if (!$) {
|
|
@@ -142,7 +160,7 @@ var p;
|
|
|
142
160
|
}
|
|
143
161
|
});
|
|
144
162
|
};
|
|
145
|
-
p.
|
|
163
|
+
p.dictionary_serie = (dictionary) => {
|
|
146
164
|
return (0, create_procedure_promise_1.__create_procedure_promise)({
|
|
147
165
|
'execute': (on_success, on_error) => {
|
|
148
166
|
const op_dictionary_to_list_based_on_insertion_order = (dict) => {
|
|
@@ -152,7 +170,7 @@ var p;
|
|
|
152
170
|
});
|
|
153
171
|
return _ei.array_literal(temp);
|
|
154
172
|
};
|
|
155
|
-
const as_list = op_dictionary_to_list_based_on_insertion_order(
|
|
173
|
+
const as_list = op_dictionary_to_list_based_on_insertion_order(dictionary);
|
|
156
174
|
let current = 0;
|
|
157
175
|
const do_next = () => {
|
|
158
176
|
as_list.__get_element_at(current).transform(($) => {
|
|
@@ -174,10 +192,10 @@ var p;
|
|
|
174
192
|
}
|
|
175
193
|
});
|
|
176
194
|
};
|
|
177
|
-
p.
|
|
195
|
+
p.dictionary_parallel_without_error_aggregation = (dictionary) => {
|
|
178
196
|
return (0, create_procedure_promise_1.__create_procedure_promise)({
|
|
179
197
|
'execute': (on_success, on_error) => {
|
|
180
|
-
let count_down =
|
|
198
|
+
let count_down = dictionary.__get_number_of_entries();
|
|
181
199
|
let has_errors = false;
|
|
182
200
|
const errors = {};
|
|
183
201
|
const decrement_and_wrap_up_if_done = () => {
|
|
@@ -191,7 +209,7 @@ var p;
|
|
|
191
209
|
}
|
|
192
210
|
}
|
|
193
211
|
};
|
|
194
|
-
|
|
212
|
+
dictionary.map(($, key) => {
|
|
195
213
|
$.__start(() => {
|
|
196
214
|
decrement_and_wrap_up_if_done();
|
|
197
215
|
}, (e) => {
|
|
@@ -203,12 +221,12 @@ var p;
|
|
|
203
221
|
}
|
|
204
222
|
});
|
|
205
223
|
};
|
|
206
|
-
p.
|
|
224
|
+
p.dictionary_parallel = (dictionary, aggregate_errors) => {
|
|
207
225
|
return (0, create_procedure_promise_1.__create_procedure_promise)({
|
|
208
226
|
'execute': (on_success, on_error) => {
|
|
209
227
|
const errors = {};
|
|
210
228
|
(0, create_asynchronous_processes_monitor_1.create_asynchronous_processes_monitor)((monitor) => {
|
|
211
|
-
|
|
229
|
+
dictionary.map(($, key) => {
|
|
212
230
|
monitor['report process started']();
|
|
213
231
|
$.__start(() => {
|
|
214
232
|
monitor['report process finished']();
|
|
@@ -232,30 +250,12 @@ var p;
|
|
|
232
250
|
return (0, create_procedure_promise_1.__create_procedure_promise)({
|
|
233
251
|
'execute': (on_success, on_error) => {
|
|
234
252
|
query.__start((query_result) => {
|
|
235
|
-
procedure[
|
|
253
|
+
procedure['execute with synchronous data without error transformation'](query_result).__start(on_success, on_error);
|
|
236
254
|
}, on_error);
|
|
237
255
|
}
|
|
238
256
|
});
|
|
239
257
|
};
|
|
240
258
|
p.sequence = (steps) => {
|
|
241
|
-
return (0, create_procedure_promise_1.__create_procedure_promise)({
|
|
242
|
-
'execute': (on_success, on_error) => {
|
|
243
|
-
let current = 0;
|
|
244
|
-
const do_next = () => {
|
|
245
|
-
steps.__get_element_at(current).transform(($) => {
|
|
246
|
-
current += 1;
|
|
247
|
-
$.__start(() => {
|
|
248
|
-
do_next();
|
|
249
|
-
}, on_error);
|
|
250
|
-
}, () => {
|
|
251
|
-
on_success();
|
|
252
|
-
});
|
|
253
|
-
};
|
|
254
|
-
do_next();
|
|
255
|
-
}
|
|
256
|
-
});
|
|
257
|
-
};
|
|
258
|
-
p.sequence_2 = (steps) => {
|
|
259
259
|
return (0, create_procedure_promise_1.__create_procedure_promise)({
|
|
260
260
|
'execute': (on_success, on_error) => {
|
|
261
261
|
const length = _ei.array_literal(steps).__get_number_of_elements();
|
|
@@ -270,34 +270,4 @@ var p;
|
|
|
270
270
|
}
|
|
271
271
|
});
|
|
272
272
|
};
|
|
273
|
-
p.three_steps = (step_1, step_2, step_3) => {
|
|
274
|
-
return (0, create_procedure_promise_1.__create_procedure_promise)({
|
|
275
|
-
'execute': (on_success, on_error) => {
|
|
276
|
-
step_1.__start(() => {
|
|
277
|
-
step_2.__start(() => {
|
|
278
|
-
step_3.__start(on_success, (error) => {
|
|
279
|
-
on_error(['step3', error]);
|
|
280
|
-
});
|
|
281
|
-
}, (error) => {
|
|
282
|
-
on_error(['step2', error]);
|
|
283
|
-
});
|
|
284
|
-
}, (error) => {
|
|
285
|
-
on_error(['step1', error]);
|
|
286
|
-
});
|
|
287
|
-
}
|
|
288
|
-
});
|
|
289
|
-
};
|
|
290
|
-
p.two_steps = (step_1, step_2) => {
|
|
291
|
-
return (0, create_procedure_promise_1.__create_procedure_promise)({
|
|
292
|
-
'execute': (on_success, on_error) => {
|
|
293
|
-
step_1.__start(() => {
|
|
294
|
-
step_2.__start(on_success, (error) => {
|
|
295
|
-
on_error(['step2', error]);
|
|
296
|
-
});
|
|
297
|
-
}, (error) => {
|
|
298
|
-
on_error(['step1', error]);
|
|
299
|
-
});
|
|
300
|
-
}
|
|
301
|
-
});
|
|
302
|
-
};
|
|
303
273
|
})(p || (exports.p = p = {}));
|
|
@@ -1,6 +1,7 @@
|
|
|
1
1
|
import * as _et from 'exupery-core-types';
|
|
2
2
|
export declare namespace q {
|
|
3
|
-
const
|
|
3
|
+
const dictionary_parallel: <Result, Error, Entry_Error>(dictionary: _et.Dictionary<_et.Query_Promise<Result, Entry_Error>>, aggregate_errors: _et.Transformer_Without_Parameters<_et.Dictionary<Entry_Error>, Error>) => _et.Query_Promise<_et.Dictionary<Result>, Error>;
|
|
4
|
+
const dictionary_parallel_without_error_aggregation: <Result, Error>($: _et.Dictionary<_et.Query_Promise<Result, Error>>) => _et.Query_Promise<_et.Dictionary<Result>, _et.Dictionary<Error>>;
|
|
4
5
|
const fixed: <Query_Result, Error>(query_result: Query_Result) => _et.Query_Promise<Query_Result, Error>;
|
|
5
6
|
const transform: <In, Out, Error>(query: _et.Query_Promise<In, Error>, transform: ($: In) => Out) => _et.Query_Promise<Out, Error>;
|
|
6
7
|
}
|
|
@@ -28,7 +28,38 @@ const _ei = __importStar(require("exupery-core-internals"));
|
|
|
28
28
|
const create_query_promise_1 = require("../algorithms/query/create_query_promise");
|
|
29
29
|
var q;
|
|
30
30
|
(function (q) {
|
|
31
|
-
q.
|
|
31
|
+
q.dictionary_parallel = (dictionary, aggregate_errors) => {
|
|
32
|
+
return (0, create_query_promise_1.__create_query_promise)({
|
|
33
|
+
'execute': (on_success, on_error) => {
|
|
34
|
+
let count_down = dictionary.__get_number_of_entries();
|
|
35
|
+
let has_errors = false;
|
|
36
|
+
const errors = {};
|
|
37
|
+
const results = {};
|
|
38
|
+
const decrement_and_wrap_up_if_done = () => {
|
|
39
|
+
count_down -= 1;
|
|
40
|
+
if (count_down === 0) {
|
|
41
|
+
if (has_errors) {
|
|
42
|
+
on_error(aggregate_errors(_ei.dictionary_literal(errors)));
|
|
43
|
+
}
|
|
44
|
+
else {
|
|
45
|
+
on_success(_ei.dictionary_literal(results));
|
|
46
|
+
}
|
|
47
|
+
}
|
|
48
|
+
};
|
|
49
|
+
dictionary.map(($, key) => {
|
|
50
|
+
$.__start(($) => {
|
|
51
|
+
results[key] = $;
|
|
52
|
+
decrement_and_wrap_up_if_done();
|
|
53
|
+
}, ($) => {
|
|
54
|
+
has_errors = true;
|
|
55
|
+
errors[key] = $;
|
|
56
|
+
decrement_and_wrap_up_if_done();
|
|
57
|
+
});
|
|
58
|
+
});
|
|
59
|
+
}
|
|
60
|
+
});
|
|
61
|
+
};
|
|
62
|
+
q.dictionary_parallel_without_error_aggregation = ($) => {
|
|
32
63
|
return (0, create_query_promise_1.__create_query_promise)({
|
|
33
64
|
'execute': (on_success, on_error) => {
|
|
34
65
|
let count_down = $.__get_number_of_entries();
|