exupery-core-async 0.3.23 → 0.3.25
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/query/create_query_primed_with_resources.js +8 -6
- package/dist/algorithms/query/create_query_promise.d.ts +3 -3
- package/dist/algorithms/query/create_query_promise.js +57 -17
- package/dist/expressions/procedure.d.ts +27 -0
- package/dist/expressions/procedure.js +303 -0
- package/dist/expressions/query.d.ts +6 -0
- package/dist/expressions/query.js +81 -0
- package/dist/index.d.ts +2 -15
- package/dist/index.js +2 -15
- package/package.json +1 -1
- package/dist/procedure/assert_async.d.ts +0 -3
- package/dist/procedure/assert_async.js +0 -23
- package/dist/procedure/assert_sync.d.ts +0 -3
- package/dist/procedure/assert_sync.js +0 -18
- package/dist/procedure/conditional_async.d.ts +0 -4
- package/dist/procedure/conditional_async.js +0 -23
- package/dist/procedure/conditional_multiple.d.ts +0 -4
- package/dist/procedure/conditional_multiple.js +0 -32
- package/dist/procedure/conditional_sync.d.ts +0 -2
- package/dist/procedure/conditional_sync.js +0 -17
- package/dist/procedure/dictionary_sequence.d.ts +0 -6
- package/dist/procedure/dictionary_sequence.js +0 -61
- package/dist/procedure/execute_with_async_data.d.ts +0 -2
- package/dist/procedure/execute_with_async_data.js +0 -14
- package/dist/procedure/procedure_dictionary.d.ts +0 -2
- package/dist/procedure/procedure_dictionary.js +0 -58
- package/dist/procedure/sequence.d.ts +0 -2
- package/dist/procedure/sequence.js +0 -23
- package/dist/procedure/three_steps.d.ts +0 -3
- package/dist/procedure/three_steps.js +0 -22
- package/dist/procedure/two_steps.d.ts +0 -3
- package/dist/procedure/two_steps.js +0 -18
- package/dist/query/query_dictionary.d.ts +0 -3
- package/dist/query/query_dictionary.js +0 -60
- package/dist/query/transform_query.d.ts +0 -3
- package/dist/query/transform_query.js +0 -16
- package/dist/shorthands.d.ts +0 -64
- package/dist/shorthands.js +0 -204
- package/dist/types/Basic_Query.d.ts +0 -3
- package/dist/types/Basic_Query.js +0 -2
|
@@ -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
3
|
* this function contains the body in which the async value or error is executed
|
|
4
|
-
* after the execution, either the
|
|
5
|
-
* @param
|
|
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,55 +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
|
+
});
|
|
23
|
+
}
|
|
24
|
+
});
|
|
25
|
+
}
|
|
26
|
+
query(queries) {
|
|
27
|
+
return new Query_Result_Promise_Class({
|
|
28
|
+
'execute': (on_result, on_error) => {
|
|
29
|
+
this.executer.execute(($) => {
|
|
30
|
+
queries.result.execute($).__start(on_result, on_error);
|
|
31
|
+
}, ($) => {
|
|
32
|
+
queries.error.execute($).__start(on_result, on_error);
|
|
22
33
|
});
|
|
23
34
|
}
|
|
24
35
|
});
|
|
25
36
|
}
|
|
26
37
|
process_result(processor) {
|
|
27
38
|
return new Query_Result_Promise_Class({
|
|
28
|
-
'execute': (
|
|
39
|
+
'execute': (on_result, on_error) => {
|
|
29
40
|
this.executer.execute(($) => {
|
|
30
|
-
processor($).__extract_data(
|
|
41
|
+
processor($).__extract_data(on_result, on_error);
|
|
31
42
|
}, on_error);
|
|
32
43
|
}
|
|
33
44
|
});
|
|
34
45
|
}
|
|
35
46
|
process_error(processor) {
|
|
36
47
|
return new Query_Result_Promise_Class({
|
|
37
|
-
'execute': (
|
|
38
|
-
this.executer.execute(
|
|
39
|
-
processor($).__extract_data(
|
|
48
|
+
'execute': (on_result, on_error) => {
|
|
49
|
+
this.executer.execute(on_result, ($) => {
|
|
50
|
+
processor($).__extract_data(on_result, on_error);
|
|
40
51
|
});
|
|
41
52
|
}
|
|
42
53
|
});
|
|
43
54
|
}
|
|
44
55
|
process(processors) {
|
|
45
56
|
return new Query_Result_Promise_Class({
|
|
46
|
-
'execute': (
|
|
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($));
|
|
71
|
+
}, on_error);
|
|
72
|
+
}
|
|
73
|
+
});
|
|
74
|
+
}
|
|
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) => {
|
|
47
87
|
this.executer.execute(($) => {
|
|
48
|
-
|
|
88
|
+
on_result(transformers.result($));
|
|
49
89
|
}, ($) => {
|
|
50
|
-
|
|
90
|
+
on_error(transformers.error($));
|
|
51
91
|
});
|
|
52
92
|
}
|
|
53
93
|
});
|
|
54
94
|
}
|
|
55
|
-
__start(
|
|
56
|
-
this.executer.execute(
|
|
95
|
+
__start(on_result, on_error) {
|
|
96
|
+
this.executer.execute(on_result, on_error);
|
|
57
97
|
}
|
|
58
98
|
}
|
|
59
99
|
/**
|
|
@@ -0,0 +1,27 @@
|
|
|
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_Async_Error<Precondition_Error, Procedure_Error> = ['precondition', Precondition_Error] | ['procedure', Procedure_Error];
|
|
5
|
+
export type Conditional_Multiple_Error<Precondition_Error, Procedure_Error> = ['preconditions', _et.Dictionary<Precondition_Error>] | ['procedure', Procedure_Error];
|
|
6
|
+
export type Three_Steps_Error<Step_1_Error, Step_2_Error, Step_3_Error> = ['step1', Step_1_Error] | ['step2', Step_2_Error] | ['step3', Step_3_Error];
|
|
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> = {
|
|
9
|
+
'error': Err;
|
|
10
|
+
'step': string;
|
|
11
|
+
};
|
|
12
|
+
export declare namespace p {
|
|
13
|
+
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>;
|
|
14
|
+
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
|
+
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: <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
|
+
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: <Procedure_Error>(precondition: boolean, procedure: _et.Procedure_Promise<Procedure_Error>) => _et.Procedure_Promise<Procedure_Error>;
|
|
19
|
+
const dictionary_sequence: <Err>(steps: _et.Dictionary<_et.Procedure_Promise<Err>>) => _et.Procedure_Promise<Sequence_Error<Err>>;
|
|
20
|
+
const dictionary: <Error>($: _et.Dictionary<_et.Procedure_Promise<Error>>) => _et.Procedure_Promise<_et.Dictionary<Error>>;
|
|
21
|
+
const dictionary_2: <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>;
|
|
22
|
+
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.Array<_et.Procedure_Promise<Error>>) => _et.Procedure_Promise<Error>;
|
|
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>>;
|
|
27
|
+
}
|
|
@@ -0,0 +1,303 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
var __createBinding = (this && this.__createBinding) || (Object.create ? (function(o, m, k, k2) {
|
|
3
|
+
if (k2 === undefined) k2 = k;
|
|
4
|
+
var desc = Object.getOwnPropertyDescriptor(m, k);
|
|
5
|
+
if (!desc || ("get" in desc ? !m.__esModule : desc.writable || desc.configurable)) {
|
|
6
|
+
desc = { enumerable: true, get: function() { return m[k]; } };
|
|
7
|
+
}
|
|
8
|
+
Object.defineProperty(o, k2, desc);
|
|
9
|
+
}) : (function(o, m, k, k2) {
|
|
10
|
+
if (k2 === undefined) k2 = k;
|
|
11
|
+
o[k2] = m[k];
|
|
12
|
+
}));
|
|
13
|
+
var __setModuleDefault = (this && this.__setModuleDefault) || (Object.create ? (function(o, v) {
|
|
14
|
+
Object.defineProperty(o, "default", { enumerable: true, value: v });
|
|
15
|
+
}) : function(o, v) {
|
|
16
|
+
o["default"] = v;
|
|
17
|
+
});
|
|
18
|
+
var __importStar = (this && this.__importStar) || function (mod) {
|
|
19
|
+
if (mod && mod.__esModule) return mod;
|
|
20
|
+
var result = {};
|
|
21
|
+
if (mod != null) for (var k in mod) if (k !== "default" && Object.prototype.hasOwnProperty.call(mod, k)) __createBinding(result, mod, k);
|
|
22
|
+
__setModuleDefault(result, mod);
|
|
23
|
+
return result;
|
|
24
|
+
};
|
|
25
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
26
|
+
exports.p = void 0;
|
|
27
|
+
const _ei = __importStar(require("exupery-core-internals"));
|
|
28
|
+
const create_procedure_promise_1 = require("../algorithms/procedure/create_procedure_promise");
|
|
29
|
+
const query_1 = require("./query");
|
|
30
|
+
const create_asynchronous_processes_monitor_1 = require("../create_asynchronous_processes_monitor");
|
|
31
|
+
var p;
|
|
32
|
+
(function (p) {
|
|
33
|
+
p.array = (the_array, aggregate_errors) => {
|
|
34
|
+
return (0, create_procedure_promise_1.__create_procedure_promise)({
|
|
35
|
+
'execute': (on_success, on_error) => {
|
|
36
|
+
const errors = [];
|
|
37
|
+
(0, create_asynchronous_processes_monitor_1.create_asynchronous_processes_monitor)((monitor) => {
|
|
38
|
+
the_array.map(($) => {
|
|
39
|
+
monitor['report process started']();
|
|
40
|
+
$.__start(() => {
|
|
41
|
+
monitor['report process finished']();
|
|
42
|
+
}, (e) => {
|
|
43
|
+
errors.push(e);
|
|
44
|
+
monitor['report process finished']();
|
|
45
|
+
});
|
|
46
|
+
});
|
|
47
|
+
}, () => {
|
|
48
|
+
if (errors.length === 0) {
|
|
49
|
+
on_success();
|
|
50
|
+
}
|
|
51
|
+
else {
|
|
52
|
+
on_error(aggregate_errors(_ei.array_literal(errors)));
|
|
53
|
+
}
|
|
54
|
+
});
|
|
55
|
+
}
|
|
56
|
+
});
|
|
57
|
+
};
|
|
58
|
+
p.assert_async = (assertion, procedure) => {
|
|
59
|
+
return (0, create_procedure_promise_1.__create_procedure_promise)({
|
|
60
|
+
'execute': (on_success, on_error) => {
|
|
61
|
+
assertion.__start(($) => {
|
|
62
|
+
if ($) {
|
|
63
|
+
procedure.__start(on_success, ($) => {
|
|
64
|
+
on_error(['procedure error', $]);
|
|
65
|
+
});
|
|
66
|
+
}
|
|
67
|
+
else {
|
|
68
|
+
on_error(['assertion failed', null]);
|
|
69
|
+
}
|
|
70
|
+
}, ($) => {
|
|
71
|
+
on_error(['assertion error', $]);
|
|
72
|
+
});
|
|
73
|
+
}
|
|
74
|
+
});
|
|
75
|
+
};
|
|
76
|
+
p.assert_sync = (assertion, procedure) => {
|
|
77
|
+
return (0, create_procedure_promise_1.__create_procedure_promise)({
|
|
78
|
+
'execute': (on_success, on_error) => {
|
|
79
|
+
if (!assertion) {
|
|
80
|
+
on_error(['assertion failed', null]);
|
|
81
|
+
return;
|
|
82
|
+
}
|
|
83
|
+
procedure.__start(on_success, ($) => {
|
|
84
|
+
on_error(['procedure error', $]);
|
|
85
|
+
});
|
|
86
|
+
}
|
|
87
|
+
});
|
|
88
|
+
};
|
|
89
|
+
p.conditional_async = (precondition, procedure) => {
|
|
90
|
+
return (0, create_procedure_promise_1.__create_procedure_promise)({
|
|
91
|
+
'execute': (on_success, on_error) => {
|
|
92
|
+
precondition.__start(($) => {
|
|
93
|
+
if ($) {
|
|
94
|
+
procedure.__start(on_success, (e) => {
|
|
95
|
+
on_error(['procedure', e]);
|
|
96
|
+
});
|
|
97
|
+
}
|
|
98
|
+
else {
|
|
99
|
+
on_success();
|
|
100
|
+
}
|
|
101
|
+
}, ($) => {
|
|
102
|
+
on_error(['precondition', $]);
|
|
103
|
+
});
|
|
104
|
+
}
|
|
105
|
+
});
|
|
106
|
+
};
|
|
107
|
+
p.conditional_multiple = (preconditions, procedure) => {
|
|
108
|
+
return (0, create_procedure_promise_1.__create_procedure_promise)({
|
|
109
|
+
'execute': (on_success, on_error) => {
|
|
110
|
+
query_1.q.dictionary(preconditions).__start(($) => {
|
|
111
|
+
let has_errors = false;
|
|
112
|
+
$.map(($) => {
|
|
113
|
+
if (!$) {
|
|
114
|
+
has_errors = true;
|
|
115
|
+
}
|
|
116
|
+
});
|
|
117
|
+
if (!has_errors) {
|
|
118
|
+
// all preconditions passed
|
|
119
|
+
procedure.__start(on_success, (e) => {
|
|
120
|
+
on_error(['procedure', e]);
|
|
121
|
+
});
|
|
122
|
+
}
|
|
123
|
+
else {
|
|
124
|
+
//the preconditions failed, so we are *successfully* skipping the procedure
|
|
125
|
+
on_success();
|
|
126
|
+
}
|
|
127
|
+
}, ($) => {
|
|
128
|
+
on_error(['preconditions', $]);
|
|
129
|
+
});
|
|
130
|
+
}
|
|
131
|
+
});
|
|
132
|
+
};
|
|
133
|
+
p.conditional_sync = (precondition, procedure) => {
|
|
134
|
+
return (0, create_procedure_promise_1.__create_procedure_promise)({
|
|
135
|
+
'execute': (on_success, on_error) => {
|
|
136
|
+
if (precondition) {
|
|
137
|
+
procedure.__start(on_success, on_error);
|
|
138
|
+
}
|
|
139
|
+
else {
|
|
140
|
+
on_success();
|
|
141
|
+
}
|
|
142
|
+
}
|
|
143
|
+
});
|
|
144
|
+
};
|
|
145
|
+
p.dictionary_sequence = (steps) => {
|
|
146
|
+
return (0, create_procedure_promise_1.__create_procedure_promise)({
|
|
147
|
+
'execute': (on_success, on_error) => {
|
|
148
|
+
const op_dictionary_to_list_based_on_insertion_order = (dict) => {
|
|
149
|
+
const temp = [];
|
|
150
|
+
dict.map(($, key) => {
|
|
151
|
+
temp.push({ key, value: $ });
|
|
152
|
+
});
|
|
153
|
+
return _ei.array_literal(temp);
|
|
154
|
+
};
|
|
155
|
+
const as_list = op_dictionary_to_list_based_on_insertion_order(steps);
|
|
156
|
+
let current = 0;
|
|
157
|
+
const do_next = () => {
|
|
158
|
+
as_list.__get_element_at(current).transform(($) => {
|
|
159
|
+
const key = $.key;
|
|
160
|
+
current += 1;
|
|
161
|
+
$.value.__start(() => {
|
|
162
|
+
do_next();
|
|
163
|
+
}, ($) => {
|
|
164
|
+
on_error({
|
|
165
|
+
'error': $,
|
|
166
|
+
'step': key,
|
|
167
|
+
});
|
|
168
|
+
});
|
|
169
|
+
}, () => {
|
|
170
|
+
on_success();
|
|
171
|
+
});
|
|
172
|
+
};
|
|
173
|
+
do_next();
|
|
174
|
+
}
|
|
175
|
+
});
|
|
176
|
+
};
|
|
177
|
+
p.dictionary = ($) => {
|
|
178
|
+
return (0, create_procedure_promise_1.__create_procedure_promise)({
|
|
179
|
+
'execute': (on_success, on_error) => {
|
|
180
|
+
let count_down = $.__get_number_of_entries();
|
|
181
|
+
let has_errors = false;
|
|
182
|
+
const errors = {};
|
|
183
|
+
const decrement_and_wrap_up_if_done = () => {
|
|
184
|
+
count_down -= 1;
|
|
185
|
+
if (count_down === 0) {
|
|
186
|
+
if (has_errors) {
|
|
187
|
+
on_error(_ei.dictionary_literal(errors));
|
|
188
|
+
}
|
|
189
|
+
else {
|
|
190
|
+
on_success();
|
|
191
|
+
}
|
|
192
|
+
}
|
|
193
|
+
};
|
|
194
|
+
$.map(($, key) => {
|
|
195
|
+
$.__start(() => {
|
|
196
|
+
decrement_and_wrap_up_if_done();
|
|
197
|
+
}, (e) => {
|
|
198
|
+
has_errors = true;
|
|
199
|
+
errors[key] = e;
|
|
200
|
+
decrement_and_wrap_up_if_done();
|
|
201
|
+
});
|
|
202
|
+
});
|
|
203
|
+
}
|
|
204
|
+
});
|
|
205
|
+
};
|
|
206
|
+
p.dictionary_2 = (the_dictionary, aggregate_errors) => {
|
|
207
|
+
return (0, create_procedure_promise_1.__create_procedure_promise)({
|
|
208
|
+
'execute': (on_success, on_error) => {
|
|
209
|
+
const errors = {};
|
|
210
|
+
(0, create_asynchronous_processes_monitor_1.create_asynchronous_processes_monitor)((monitor) => {
|
|
211
|
+
the_dictionary.map(($, key) => {
|
|
212
|
+
monitor['report process started']();
|
|
213
|
+
$.__start(() => {
|
|
214
|
+
monitor['report process finished']();
|
|
215
|
+
}, (e) => {
|
|
216
|
+
errors[key] = e;
|
|
217
|
+
monitor['report process finished']();
|
|
218
|
+
});
|
|
219
|
+
});
|
|
220
|
+
}, () => {
|
|
221
|
+
if (Object.keys(errors).length === 0) {
|
|
222
|
+
on_success();
|
|
223
|
+
}
|
|
224
|
+
else {
|
|
225
|
+
on_error(aggregate_errors(_ei.dictionary_literal(errors)));
|
|
226
|
+
}
|
|
227
|
+
});
|
|
228
|
+
}
|
|
229
|
+
});
|
|
230
|
+
};
|
|
231
|
+
p.execute_with_async_data = (procedure, query) => {
|
|
232
|
+
return (0, create_procedure_promise_1.__create_procedure_promise)({
|
|
233
|
+
'execute': (on_success, on_error) => {
|
|
234
|
+
query.__start((query_result) => {
|
|
235
|
+
procedure["execute with synchronous data"](query_result).__start(on_success, on_error);
|
|
236
|
+
}, on_error);
|
|
237
|
+
}
|
|
238
|
+
});
|
|
239
|
+
};
|
|
240
|
+
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
|
+
return (0, create_procedure_promise_1.__create_procedure_promise)({
|
|
260
|
+
'execute': (on_success, on_error) => {
|
|
261
|
+
const length = _ei.array_literal(steps).__get_number_of_elements();
|
|
262
|
+
const runStep = (index) => {
|
|
263
|
+
if (index >= length) {
|
|
264
|
+
on_success();
|
|
265
|
+
return;
|
|
266
|
+
}
|
|
267
|
+
steps[index].__start(() => runStep(index + 1), on_error);
|
|
268
|
+
};
|
|
269
|
+
runStep(0);
|
|
270
|
+
}
|
|
271
|
+
});
|
|
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
|
+
})(p || (exports.p = p = {}));
|
|
@@ -0,0 +1,6 @@
|
|
|
1
|
+
import * as _et from 'exupery-core-types';
|
|
2
|
+
export declare namespace q {
|
|
3
|
+
const dictionary: <Result, Error>($: _et.Dictionary<_et.Query_Promise<Result, Error>>) => _et.Query_Promise<_et.Dictionary<Result>, _et.Dictionary<Error>>;
|
|
4
|
+
const fixed: <Query_Result, Error>(query_result: Query_Result) => _et.Query_Promise<Query_Result, Error>;
|
|
5
|
+
const transform: <In, Out, Error>(query: _et.Query_Promise<In, Error>, transform: ($: In) => Out) => _et.Query_Promise<Out, Error>;
|
|
6
|
+
}
|
|
@@ -0,0 +1,81 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
var __createBinding = (this && this.__createBinding) || (Object.create ? (function(o, m, k, k2) {
|
|
3
|
+
if (k2 === undefined) k2 = k;
|
|
4
|
+
var desc = Object.getOwnPropertyDescriptor(m, k);
|
|
5
|
+
if (!desc || ("get" in desc ? !m.__esModule : desc.writable || desc.configurable)) {
|
|
6
|
+
desc = { enumerable: true, get: function() { return m[k]; } };
|
|
7
|
+
}
|
|
8
|
+
Object.defineProperty(o, k2, desc);
|
|
9
|
+
}) : (function(o, m, k, k2) {
|
|
10
|
+
if (k2 === undefined) k2 = k;
|
|
11
|
+
o[k2] = m[k];
|
|
12
|
+
}));
|
|
13
|
+
var __setModuleDefault = (this && this.__setModuleDefault) || (Object.create ? (function(o, v) {
|
|
14
|
+
Object.defineProperty(o, "default", { enumerable: true, value: v });
|
|
15
|
+
}) : function(o, v) {
|
|
16
|
+
o["default"] = v;
|
|
17
|
+
});
|
|
18
|
+
var __importStar = (this && this.__importStar) || function (mod) {
|
|
19
|
+
if (mod && mod.__esModule) return mod;
|
|
20
|
+
var result = {};
|
|
21
|
+
if (mod != null) for (var k in mod) if (k !== "default" && Object.prototype.hasOwnProperty.call(mod, k)) __createBinding(result, mod, k);
|
|
22
|
+
__setModuleDefault(result, mod);
|
|
23
|
+
return result;
|
|
24
|
+
};
|
|
25
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
26
|
+
exports.q = void 0;
|
|
27
|
+
const _ei = __importStar(require("exupery-core-internals"));
|
|
28
|
+
const create_query_promise_1 = require("../algorithms/query/create_query_promise");
|
|
29
|
+
var q;
|
|
30
|
+
(function (q) {
|
|
31
|
+
q.dictionary = ($) => {
|
|
32
|
+
return (0, create_query_promise_1.__create_query_promise)({
|
|
33
|
+
'execute': (on_success, on_error) => {
|
|
34
|
+
let count_down = $.__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(_ei.dictionary_literal(errors));
|
|
43
|
+
}
|
|
44
|
+
else {
|
|
45
|
+
on_success(_ei.dictionary_literal(results));
|
|
46
|
+
}
|
|
47
|
+
}
|
|
48
|
+
};
|
|
49
|
+
$.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.fixed = (query_result) => {
|
|
63
|
+
return (0, create_query_promise_1.__create_query_promise)({
|
|
64
|
+
'execute': (on_success, on_error) => {
|
|
65
|
+
on_success(query_result);
|
|
66
|
+
}
|
|
67
|
+
});
|
|
68
|
+
};
|
|
69
|
+
q.transform = (//probably better to use the method on the query itself
|
|
70
|
+
query, transform) => {
|
|
71
|
+
return (0, create_query_promise_1.__create_query_promise)({
|
|
72
|
+
'execute': (on_success, on_error) => {
|
|
73
|
+
query.__start(($) => {
|
|
74
|
+
on_success(transform($));
|
|
75
|
+
}, (e) => {
|
|
76
|
+
on_error(e);
|
|
77
|
+
});
|
|
78
|
+
}
|
|
79
|
+
});
|
|
80
|
+
};
|
|
81
|
+
})(q || (exports.q = q = {}));
|
package/dist/index.d.ts
CHANGED
|
@@ -1,25 +1,12 @@
|
|
|
1
1
|
import * as _et from "exupery-core-types";
|
|
2
|
-
export * from "./types/Basic_Query";
|
|
3
2
|
export * from "./algorithms/query/create_query_promise";
|
|
4
3
|
export * from "./algorithms/query/create_query_primed_with_resources";
|
|
5
4
|
export * from "./algorithms/query/create_query";
|
|
6
5
|
export * from "./algorithms/procedure/create_procedure";
|
|
7
6
|
export * from "./algorithms/procedure/create_procedure_promise";
|
|
8
7
|
export * from "./algorithms/procedure/create_procedure_primed_with_resources";
|
|
9
|
-
export * from "./
|
|
10
|
-
export * from "./
|
|
11
|
-
export * from "./procedure/assert_sync";
|
|
12
|
-
export * from "./procedure/execute_with_async_data";
|
|
13
|
-
export * from "./procedure/conditional_async";
|
|
14
|
-
export * from "./procedure/conditional_multiple";
|
|
15
|
-
export * from "./procedure/conditional_sync";
|
|
16
|
-
export * from "./procedure/dictionary_sequence";
|
|
17
|
-
export * from "./procedure/sequence";
|
|
18
|
-
export * from "./procedure/three_steps";
|
|
19
|
-
export * from "./procedure/two_steps";
|
|
20
|
-
export * from "./procedure/procedure_dictionary";
|
|
21
|
-
export * from "./query/transform_query";
|
|
22
|
-
export * from "./query/query_dictionary";
|
|
8
|
+
export * from "./expressions/procedure";
|
|
9
|
+
export * from "./expressions/query";
|
|
23
10
|
export declare const query: {
|
|
24
11
|
'create result': <T, E>($: T) => _et.Query_Promise<T, E>;
|
|
25
12
|
'raise error': <T, E>($: E) => _et.Query_Promise<T, E>;
|
package/dist/index.js
CHANGED
|
@@ -16,7 +16,6 @@ var __exportStar = (this && this.__exportStar) || function(m, exports) {
|
|
|
16
16
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
17
17
|
exports.query = void 0;
|
|
18
18
|
//types
|
|
19
|
-
__exportStar(require("./types/Basic_Query"), exports);
|
|
20
19
|
//functions
|
|
21
20
|
__exportStar(require("./algorithms/query/create_query_promise"), exports);
|
|
22
21
|
__exportStar(require("./algorithms/query/create_query_primed_with_resources"), exports);
|
|
@@ -24,22 +23,10 @@ __exportStar(require("./algorithms/query/create_query"), exports);
|
|
|
24
23
|
__exportStar(require("./algorithms/procedure/create_procedure"), exports);
|
|
25
24
|
__exportStar(require("./algorithms/procedure/create_procedure_promise"), exports);
|
|
26
25
|
__exportStar(require("./algorithms/procedure/create_procedure_primed_with_resources"), exports);
|
|
27
|
-
__exportStar(require("./shorthands"), exports);
|
|
28
26
|
// procedure exports
|
|
29
|
-
__exportStar(require("./procedure
|
|
30
|
-
__exportStar(require("./procedure/assert_sync"), exports);
|
|
31
|
-
__exportStar(require("./procedure/execute_with_async_data"), exports);
|
|
32
|
-
__exportStar(require("./procedure/conditional_async"), exports);
|
|
33
|
-
__exportStar(require("./procedure/conditional_multiple"), exports);
|
|
34
|
-
__exportStar(require("./procedure/conditional_sync"), exports);
|
|
35
|
-
__exportStar(require("./procedure/dictionary_sequence"), exports);
|
|
36
|
-
__exportStar(require("./procedure/sequence"), exports);
|
|
37
|
-
__exportStar(require("./procedure/three_steps"), exports);
|
|
38
|
-
__exportStar(require("./procedure/two_steps"), exports);
|
|
39
|
-
__exportStar(require("./procedure/procedure_dictionary"), exports);
|
|
27
|
+
__exportStar(require("./expressions/procedure"), exports);
|
|
40
28
|
// query exports
|
|
41
|
-
__exportStar(require("./query
|
|
42
|
-
__exportStar(require("./query/query_dictionary"), exports);
|
|
29
|
+
__exportStar(require("./expressions/query"), exports);
|
|
43
30
|
const create_query_promise_1 = require("./algorithms/query/create_query_promise");
|
|
44
31
|
exports.query = {
|
|
45
32
|
'create result': ($) => {
|
package/package.json
CHANGED
|
@@ -1,3 +0,0 @@
|
|
|
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 declare 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>>;
|