exupery-core-async 0.3.26 → 0.3.28
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
|
});
|
|
@@ -1,27 +1,22 @@
|
|
|
1
1
|
import * as _et from 'exupery-core-types';
|
|
2
2
|
export type Assert_Async_Error<Assertion_Error, Procedure_Error> = ['assertion error', Assertion_Error] | ['assertion failed', null] | ['procedure error', Procedure_Error];
|
|
3
3
|
export type Assert_Sync_Error<Procedure_Error> = ['assertion failed', null] | ['procedure error', Procedure_Error];
|
|
4
|
-
export type Conditional_Async_Error<Precondition_Error, Procedure_Error> = ['precondition', Precondition_Error] | ['procedure', Procedure_Error];
|
|
5
4
|
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> = {
|
|
5
|
+
export type Dictionary_Serie_Error<Err> = {
|
|
9
6
|
'error': Err;
|
|
10
7
|
'step': string;
|
|
11
8
|
};
|
|
12
9
|
export declare namespace p {
|
|
13
|
-
const
|
|
10
|
+
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
|
+
const array_serie: <Error>(array: _et.Array<_et.Procedure_Promise<Error>>) => _et.Procedure_Promise<Error>;
|
|
14
12
|
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
13
|
const assert_sync: <Assertion_Error, Procedure_Error>(assertion: boolean, procedure: _et.Procedure_Promise<Procedure_Error>) => _et.Procedure_Promise<Assert_Sync_Error<Procedure_Error>>;
|
|
16
|
-
const conditional_async: <
|
|
14
|
+
const conditional_async: <Error>(precondition: _et.Query_Promise<boolean, Error>, procedure: _et.Procedure_Promise<Error>) => _et.Procedure_Promise<Error>;
|
|
17
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>>;
|
|
18
|
-
const conditional_sync: <
|
|
19
|
-
const
|
|
20
|
-
const
|
|
21
|
-
const
|
|
16
|
+
const conditional_sync: <Error>(precondition: boolean, procedure: _et.Procedure_Promise<Error>) => _et.Procedure_Promise<Error>;
|
|
17
|
+
const dictionary_serie: <Err>(dictionary: _et.Dictionary<_et.Procedure_Promise<Err>>) => _et.Procedure_Promise<Dictionary_Serie_Error<Err>>;
|
|
18
|
+
const dictionary_parallel_without_error_aggregation: <Error>(dictionary: _et.Dictionary<_et.Procedure_Promise<Error>>) => _et.Procedure_Promise<_et.Dictionary<Error>>;
|
|
19
|
+
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
20
|
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>>;
|
|
21
|
+
const sequence: <Error>(steps: _et.Procedure_Promise<Error>[]) => _et.Procedure_Promise<Error>;
|
|
27
22
|
}
|
|
@@ -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) => {
|
|
@@ -91,23 +109,19 @@ var p;
|
|
|
91
109
|
'execute': (on_success, on_error) => {
|
|
92
110
|
precondition.__start(($) => {
|
|
93
111
|
if ($) {
|
|
94
|
-
procedure.__start(on_success,
|
|
95
|
-
on_error(['procedure', e]);
|
|
96
|
-
});
|
|
112
|
+
procedure.__start(on_success, on_error);
|
|
97
113
|
}
|
|
98
114
|
else {
|
|
99
115
|
on_success();
|
|
100
116
|
}
|
|
101
|
-
},
|
|
102
|
-
on_error(['precondition', $]);
|
|
103
|
-
});
|
|
117
|
+
}, on_error);
|
|
104
118
|
}
|
|
105
119
|
});
|
|
106
120
|
};
|
|
107
121
|
p.conditional_multiple = (preconditions, procedure) => {
|
|
108
122
|
return (0, create_procedure_promise_1.__create_procedure_promise)({
|
|
109
123
|
'execute': (on_success, on_error) => {
|
|
110
|
-
query_1.q.
|
|
124
|
+
query_1.q.dictionary_parallel_without_error_aggregation(preconditions).__start(($) => {
|
|
111
125
|
let has_errors = false;
|
|
112
126
|
$.map(($) => {
|
|
113
127
|
if (!$) {
|
|
@@ -142,7 +156,7 @@ var p;
|
|
|
142
156
|
}
|
|
143
157
|
});
|
|
144
158
|
};
|
|
145
|
-
p.
|
|
159
|
+
p.dictionary_serie = (dictionary) => {
|
|
146
160
|
return (0, create_procedure_promise_1.__create_procedure_promise)({
|
|
147
161
|
'execute': (on_success, on_error) => {
|
|
148
162
|
const op_dictionary_to_list_based_on_insertion_order = (dict) => {
|
|
@@ -152,7 +166,7 @@ var p;
|
|
|
152
166
|
});
|
|
153
167
|
return _ei.array_literal(temp);
|
|
154
168
|
};
|
|
155
|
-
const as_list = op_dictionary_to_list_based_on_insertion_order(
|
|
169
|
+
const as_list = op_dictionary_to_list_based_on_insertion_order(dictionary);
|
|
156
170
|
let current = 0;
|
|
157
171
|
const do_next = () => {
|
|
158
172
|
as_list.__get_element_at(current).transform(($) => {
|
|
@@ -174,10 +188,10 @@ var p;
|
|
|
174
188
|
}
|
|
175
189
|
});
|
|
176
190
|
};
|
|
177
|
-
p.
|
|
191
|
+
p.dictionary_parallel_without_error_aggregation = (dictionary) => {
|
|
178
192
|
return (0, create_procedure_promise_1.__create_procedure_promise)({
|
|
179
193
|
'execute': (on_success, on_error) => {
|
|
180
|
-
let count_down =
|
|
194
|
+
let count_down = dictionary.__get_number_of_entries();
|
|
181
195
|
let has_errors = false;
|
|
182
196
|
const errors = {};
|
|
183
197
|
const decrement_and_wrap_up_if_done = () => {
|
|
@@ -191,7 +205,7 @@ var p;
|
|
|
191
205
|
}
|
|
192
206
|
}
|
|
193
207
|
};
|
|
194
|
-
|
|
208
|
+
dictionary.map(($, key) => {
|
|
195
209
|
$.__start(() => {
|
|
196
210
|
decrement_and_wrap_up_if_done();
|
|
197
211
|
}, (e) => {
|
|
@@ -203,12 +217,12 @@ var p;
|
|
|
203
217
|
}
|
|
204
218
|
});
|
|
205
219
|
};
|
|
206
|
-
p.
|
|
220
|
+
p.dictionary_parallel = (dictionary, aggregate_errors) => {
|
|
207
221
|
return (0, create_procedure_promise_1.__create_procedure_promise)({
|
|
208
222
|
'execute': (on_success, on_error) => {
|
|
209
223
|
const errors = {};
|
|
210
224
|
(0, create_asynchronous_processes_monitor_1.create_asynchronous_processes_monitor)((monitor) => {
|
|
211
|
-
|
|
225
|
+
dictionary.map(($, key) => {
|
|
212
226
|
monitor['report process started']();
|
|
213
227
|
$.__start(() => {
|
|
214
228
|
monitor['report process finished']();
|
|
@@ -232,30 +246,12 @@ var p;
|
|
|
232
246
|
return (0, create_procedure_promise_1.__create_procedure_promise)({
|
|
233
247
|
'execute': (on_success, on_error) => {
|
|
234
248
|
query.__start((query_result) => {
|
|
235
|
-
procedure[
|
|
249
|
+
procedure['execute with synchronous data without error transformation'](query_result).__start(on_success, on_error);
|
|
236
250
|
}, on_error);
|
|
237
251
|
}
|
|
238
252
|
});
|
|
239
253
|
};
|
|
240
254
|
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
255
|
return (0, create_procedure_promise_1.__create_procedure_promise)({
|
|
260
256
|
'execute': (on_success, on_error) => {
|
|
261
257
|
const length = _ei.array_literal(steps).__get_number_of_elements();
|
|
@@ -270,34 +266,4 @@ var p;
|
|
|
270
266
|
}
|
|
271
267
|
});
|
|
272
268
|
};
|
|
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
269
|
})(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();
|