exupery-core-async 0.3.22 → 0.3.24
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/algorithms/procedure/create_procedure_promise.d.ts +1 -1
- package/dist/algorithms/query/create_query_primed_with_resources.js +8 -6
- package/dist/algorithms/query/create_query_promise.d.ts +4 -4
- package/dist/algorithms/query/create_query_promise.js +72 -12
- package/dist/index.d.ts +1 -1
- package/dist/index.js +1 -1
- package/dist/shorthands.d.ts +4 -4
- package/dist/shorthands.js +13 -13
- package/package.json +1 -1
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
import * as _et from "exupery-core-types";
|
|
2
2
|
/**
|
|
3
|
-
* this function contains the body in which the async value or
|
|
3
|
+
* this function contains the body in which the async value or error is executed
|
|
4
4
|
* after the execution, either the on_value or on_error callback will be called
|
|
5
5
|
* @param on_value the callback to call when a value is produced
|
|
6
6
|
* @param on_error the callback to call when an error is produced
|
|
@@ -3,12 +3,14 @@ Object.defineProperty(exports, "__esModule", { value: true });
|
|
|
3
3
|
exports.__create_query_primed_with_resources = void 0;
|
|
4
4
|
const create_query_promise_1 = require("./create_query_promise");
|
|
5
5
|
const __create_query_primed_with_resources = (handler) => {
|
|
6
|
-
return
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
|
|
6
|
+
return {
|
|
7
|
+
'execute': (parameters) => {
|
|
8
|
+
return (0, create_query_promise_1.__create_query_promise)({
|
|
9
|
+
'execute': (on_success, on_error) => {
|
|
10
|
+
handler(parameters).__start(on_success, on_error);
|
|
11
|
+
}
|
|
12
|
+
});
|
|
13
|
+
}
|
|
12
14
|
};
|
|
13
15
|
};
|
|
14
16
|
exports.__create_query_primed_with_resources = __create_query_primed_with_resources;
|
|
@@ -1,12 +1,12 @@
|
|
|
1
1
|
import * as _et from "exupery-core-types";
|
|
2
2
|
/**
|
|
3
|
-
* this function contains the body in which the async value or
|
|
4
|
-
* after the execution, either the
|
|
5
|
-
* @param
|
|
3
|
+
* this function contains the body in which the async value or error is executed
|
|
4
|
+
* after the execution, either the on_result or on_error callback will be called
|
|
5
|
+
* @param on_result the callback to call when a value is produced
|
|
6
6
|
* @param on_error the callback to call when an error is produced
|
|
7
7
|
*/
|
|
8
8
|
type Executer<T, E> = {
|
|
9
|
-
'execute': (
|
|
9
|
+
'execute': (on_result: ($: T) => void, on_error: ($: E) => void) => void;
|
|
10
10
|
};
|
|
11
11
|
/**
|
|
12
12
|
* returns an {@link Async_Value }
|
|
@@ -5,35 +5,95 @@ class Query_Result_Promise_Class {
|
|
|
5
5
|
constructor(executer) {
|
|
6
6
|
this.executer = executer;
|
|
7
7
|
}
|
|
8
|
-
|
|
8
|
+
query_with_result(query) {
|
|
9
9
|
return new Query_Result_Promise_Class({
|
|
10
|
-
'execute': (
|
|
10
|
+
'execute': (on_result, on_error) => {
|
|
11
11
|
this.executer.execute(($) => {
|
|
12
|
-
|
|
12
|
+
query.execute($).__start(on_result, on_error);
|
|
13
13
|
}, on_error);
|
|
14
14
|
}
|
|
15
15
|
});
|
|
16
16
|
}
|
|
17
|
-
|
|
17
|
+
query_with_error(query) {
|
|
18
18
|
return new Query_Result_Promise_Class({
|
|
19
|
-
'execute': (
|
|
20
|
-
this.executer.execute(
|
|
21
|
-
|
|
19
|
+
'execute': (on_result, on_error) => {
|
|
20
|
+
this.executer.execute(on_result, ($) => {
|
|
21
|
+
query.execute($).__start(on_result, on_error);
|
|
22
22
|
});
|
|
23
23
|
}
|
|
24
24
|
});
|
|
25
25
|
}
|
|
26
|
-
|
|
26
|
+
query(queries) {
|
|
27
27
|
return new Query_Result_Promise_Class({
|
|
28
|
-
'execute': (
|
|
28
|
+
'execute': (on_result, on_error) => {
|
|
29
29
|
this.executer.execute(($) => {
|
|
30
|
-
|
|
30
|
+
queries.result.execute($).__start(on_result, on_error);
|
|
31
|
+
}, ($) => {
|
|
32
|
+
queries.error.execute($).__start(on_result, on_error);
|
|
33
|
+
});
|
|
34
|
+
}
|
|
35
|
+
});
|
|
36
|
+
}
|
|
37
|
+
process_result(processor) {
|
|
38
|
+
return new Query_Result_Promise_Class({
|
|
39
|
+
'execute': (on_result, on_error) => {
|
|
40
|
+
this.executer.execute(($) => {
|
|
41
|
+
processor($).__extract_data(on_result, on_error);
|
|
42
|
+
}, on_error);
|
|
43
|
+
}
|
|
44
|
+
});
|
|
45
|
+
}
|
|
46
|
+
process_error(processor) {
|
|
47
|
+
return new Query_Result_Promise_Class({
|
|
48
|
+
'execute': (on_result, on_error) => {
|
|
49
|
+
this.executer.execute(on_result, ($) => {
|
|
50
|
+
processor($).__extract_data(on_result, on_error);
|
|
51
|
+
});
|
|
52
|
+
}
|
|
53
|
+
});
|
|
54
|
+
}
|
|
55
|
+
process(processors) {
|
|
56
|
+
return new Query_Result_Promise_Class({
|
|
57
|
+
'execute': (on_result, on_error) => {
|
|
58
|
+
this.executer.execute(($) => {
|
|
59
|
+
processors.result($).__extract_data(on_result, on_error);
|
|
60
|
+
}, ($) => {
|
|
61
|
+
processors.error($).__extract_data(on_result, on_error);
|
|
62
|
+
});
|
|
63
|
+
}
|
|
64
|
+
});
|
|
65
|
+
}
|
|
66
|
+
transform_result(transformer) {
|
|
67
|
+
return new Query_Result_Promise_Class({
|
|
68
|
+
'execute': (on_result, on_error) => {
|
|
69
|
+
this.executer.execute(($) => {
|
|
70
|
+
on_result(transformer($));
|
|
31
71
|
}, on_error);
|
|
32
72
|
}
|
|
33
73
|
});
|
|
34
74
|
}
|
|
35
|
-
|
|
36
|
-
|
|
75
|
+
transform_error(transformer) {
|
|
76
|
+
return new Query_Result_Promise_Class({
|
|
77
|
+
'execute': (on_result, on_error) => {
|
|
78
|
+
this.executer.execute(on_result, ($) => {
|
|
79
|
+
on_error(transformer($));
|
|
80
|
+
});
|
|
81
|
+
}
|
|
82
|
+
});
|
|
83
|
+
}
|
|
84
|
+
transform(transformers) {
|
|
85
|
+
return new Query_Result_Promise_Class({
|
|
86
|
+
'execute': (on_result, on_error) => {
|
|
87
|
+
this.executer.execute(($) => {
|
|
88
|
+
on_result(transformers.result($));
|
|
89
|
+
}, ($) => {
|
|
90
|
+
on_error(transformers.error($));
|
|
91
|
+
});
|
|
92
|
+
}
|
|
93
|
+
});
|
|
94
|
+
}
|
|
95
|
+
__start(on_result, on_error) {
|
|
96
|
+
this.executer.execute(on_result, on_error);
|
|
37
97
|
}
|
|
38
98
|
}
|
|
39
99
|
/**
|
package/dist/index.d.ts
CHANGED
|
@@ -22,5 +22,5 @@ export * from "./query/transform_query";
|
|
|
22
22
|
export * from "./query/query_dictionary";
|
|
23
23
|
export declare const query: {
|
|
24
24
|
'create result': <T, E>($: T) => _et.Query_Promise<T, E>;
|
|
25
|
-
'raise
|
|
25
|
+
'raise error': <T, E>($: E) => _et.Query_Promise<T, E>;
|
|
26
26
|
};
|
package/dist/index.js
CHANGED
package/dist/shorthands.d.ts
CHANGED
|
@@ -17,17 +17,17 @@ export declare namespace p {
|
|
|
17
17
|
/**
|
|
18
18
|
*
|
|
19
19
|
* @param the_array up[]
|
|
20
|
-
* @param
|
|
20
|
+
* @param aggregate_errors gt
|
|
21
21
|
* @returns
|
|
22
22
|
*/
|
|
23
|
-
const array: <Error, Element_Error>(the_array: _et.Array<_et.Procedure_Promise<Element_Error>>,
|
|
23
|
+
const array: <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>;
|
|
24
24
|
/**
|
|
25
25
|
*
|
|
26
26
|
* @param the_dictionary dict<up>
|
|
27
|
-
* @param
|
|
27
|
+
* @param aggregate_errors gt
|
|
28
28
|
* @returns
|
|
29
29
|
*/
|
|
30
|
-
const dictionary: <Error, Element_Error>(the_dictionary: _et.Dictionary<_et.Procedure_Promise<Element_Error>>,
|
|
30
|
+
const dictionary: <Error, Element_Error>(the_dictionary: _et.Dictionary<_et.Procedure_Promise<Element_Error>>, aggregate_errors: _et.Transformer_Without_Parameters<_et.Dictionary<Element_Error>, Error>) => _et.Procedure_Promise<Error>;
|
|
31
31
|
}
|
|
32
32
|
export declare namespace q {
|
|
33
33
|
/**
|
package/dist/shorthands.js
CHANGED
|
@@ -71,29 +71,29 @@ var p;
|
|
|
71
71
|
/**
|
|
72
72
|
*
|
|
73
73
|
* @param the_array up[]
|
|
74
|
-
* @param
|
|
74
|
+
* @param aggregate_errors gt
|
|
75
75
|
* @returns
|
|
76
76
|
*/
|
|
77
|
-
p.array = (the_array,
|
|
77
|
+
p.array = (the_array, aggregate_errors) => {
|
|
78
78
|
return (0, create_procedure_promise_1.__create_procedure_promise)({
|
|
79
79
|
'execute': (on_success, on_error) => {
|
|
80
|
-
const
|
|
80
|
+
const errors = [];
|
|
81
81
|
(0, create_asynchronous_processes_monitor_1.create_asynchronous_processes_monitor)((monitor) => {
|
|
82
82
|
the_array.map(($) => {
|
|
83
83
|
monitor['report process started']();
|
|
84
84
|
$.__start(() => {
|
|
85
85
|
monitor['report process finished']();
|
|
86
86
|
}, (e) => {
|
|
87
|
-
|
|
87
|
+
errors.push(e);
|
|
88
88
|
monitor['report process finished']();
|
|
89
89
|
});
|
|
90
90
|
});
|
|
91
91
|
}, () => {
|
|
92
|
-
if (
|
|
92
|
+
if (errors.length === 0) {
|
|
93
93
|
on_success();
|
|
94
94
|
}
|
|
95
95
|
else {
|
|
96
|
-
on_error(
|
|
96
|
+
on_error(aggregate_errors(_ei.array_literal(errors)));
|
|
97
97
|
}
|
|
98
98
|
});
|
|
99
99
|
}
|
|
@@ -102,29 +102,29 @@ var p;
|
|
|
102
102
|
/**
|
|
103
103
|
*
|
|
104
104
|
* @param the_dictionary dict<up>
|
|
105
|
-
* @param
|
|
105
|
+
* @param aggregate_errors gt
|
|
106
106
|
* @returns
|
|
107
107
|
*/
|
|
108
|
-
p.dictionary = (the_dictionary,
|
|
108
|
+
p.dictionary = (the_dictionary, aggregate_errors) => {
|
|
109
109
|
return (0, create_procedure_promise_1.__create_procedure_promise)({
|
|
110
110
|
'execute': (on_success, on_error) => {
|
|
111
|
-
const
|
|
111
|
+
const errors = {};
|
|
112
112
|
(0, create_asynchronous_processes_monitor_1.create_asynchronous_processes_monitor)((monitor) => {
|
|
113
113
|
the_dictionary.map(($, key) => {
|
|
114
114
|
monitor['report process started']();
|
|
115
115
|
$.__start(() => {
|
|
116
116
|
monitor['report process finished']();
|
|
117
117
|
}, (e) => {
|
|
118
|
-
|
|
118
|
+
errors[key] = e;
|
|
119
119
|
monitor['report process finished']();
|
|
120
120
|
});
|
|
121
121
|
});
|
|
122
122
|
}, () => {
|
|
123
|
-
if (Object.keys(
|
|
123
|
+
if (Object.keys(errors).length === 0) {
|
|
124
124
|
on_success();
|
|
125
125
|
}
|
|
126
126
|
else {
|
|
127
|
-
on_error(
|
|
127
|
+
on_error(aggregate_errors(_ei.dictionary_literal(errors)));
|
|
128
128
|
}
|
|
129
129
|
});
|
|
130
130
|
}
|
|
@@ -158,7 +158,7 @@ var q;
|
|
|
158
158
|
return {
|
|
159
159
|
__start: (on_success, on_error) => {
|
|
160
160
|
parameters.__start((qr_in) => {
|
|
161
|
-
the_query(resources)(qr_in).__start((result) => {
|
|
161
|
+
the_query(resources).execute(qr_in).__start((result) => {
|
|
162
162
|
result_refinement(result).process((x) => on_success(x), on_error);
|
|
163
163
|
}, (error) => {
|
|
164
164
|
if (error_handler !== undefined) {
|