exupery-core-async 0.3.24 → 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/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
|
@@ -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>>;
|
|
@@ -1,23 +0,0 @@
|
|
|
1
|
-
"use strict";
|
|
2
|
-
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
-
exports.assert_async = void 0;
|
|
4
|
-
const create_procedure_promise_1 = require("../algorithms/procedure/create_procedure_promise");
|
|
5
|
-
const assert_async = (assertion, procedure) => {
|
|
6
|
-
return (0, create_procedure_promise_1.__create_procedure_promise)({
|
|
7
|
-
'execute': (on_success, on_error) => {
|
|
8
|
-
assertion.__start(($) => {
|
|
9
|
-
if ($) {
|
|
10
|
-
procedure.__start(on_success, ($) => {
|
|
11
|
-
on_error(['procedure error', $]);
|
|
12
|
-
});
|
|
13
|
-
}
|
|
14
|
-
else {
|
|
15
|
-
on_error(['assertion failed', null]);
|
|
16
|
-
}
|
|
17
|
-
}, ($) => {
|
|
18
|
-
on_error(['assertion error', $]);
|
|
19
|
-
});
|
|
20
|
-
}
|
|
21
|
-
});
|
|
22
|
-
};
|
|
23
|
-
exports.assert_async = assert_async;
|
|
@@ -1,3 +0,0 @@
|
|
|
1
|
-
import * as _et from 'exupery-core-types';
|
|
2
|
-
export type Assert_Sync_Error<Procedure_Error> = ['assertion failed', null] | ['procedure error', Procedure_Error];
|
|
3
|
-
export declare const assert_sync: <Assertion_Error, Procedure_Error>(assertion: boolean, procedure: _et.Procedure_Promise<Procedure_Error>) => _et.Procedure_Promise<Assert_Sync_Error<Procedure_Error>>;
|
|
@@ -1,18 +0,0 @@
|
|
|
1
|
-
"use strict";
|
|
2
|
-
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
-
exports.assert_sync = void 0;
|
|
4
|
-
const create_procedure_promise_1 = require("../algorithms/procedure/create_procedure_promise");
|
|
5
|
-
const assert_sync = (assertion, procedure) => {
|
|
6
|
-
return (0, create_procedure_promise_1.__create_procedure_promise)({
|
|
7
|
-
'execute': (on_success, on_error) => {
|
|
8
|
-
if (!assertion) {
|
|
9
|
-
on_error(['assertion failed', null]);
|
|
10
|
-
return;
|
|
11
|
-
}
|
|
12
|
-
procedure.__start(on_success, ($) => {
|
|
13
|
-
on_error(['procedure error', $]);
|
|
14
|
-
});
|
|
15
|
-
}
|
|
16
|
-
});
|
|
17
|
-
};
|
|
18
|
-
exports.assert_sync = assert_sync;
|
|
@@ -1,4 +0,0 @@
|
|
|
1
|
-
import * as _et from 'exupery-core-types';
|
|
2
|
-
import { Basic_Query_Promise } from '../types/Basic_Query';
|
|
3
|
-
export type Conditional_Async_Error<Precondition_Error, Procedure_Error> = ['precondition', Precondition_Error] | ['procedure', Procedure_Error];
|
|
4
|
-
export declare const conditional_async: <Precondition_Error, Procedure_Error>(precondition: Basic_Query_Promise<boolean, Precondition_Error>, procedure: _et.Procedure_Promise<Procedure_Error>) => _et.Procedure_Promise<Conditional_Async_Error<Precondition_Error, Procedure_Error>>;
|
|
@@ -1,23 +0,0 @@
|
|
|
1
|
-
"use strict";
|
|
2
|
-
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
-
exports.conditional_async = void 0;
|
|
4
|
-
const create_procedure_promise_1 = require("../algorithms/procedure/create_procedure_promise");
|
|
5
|
-
const conditional_async = (precondition, procedure) => {
|
|
6
|
-
return (0, create_procedure_promise_1.__create_procedure_promise)({
|
|
7
|
-
'execute': (on_success, on_error) => {
|
|
8
|
-
precondition.__start(($) => {
|
|
9
|
-
if ($) {
|
|
10
|
-
procedure.__start(on_success, (e) => {
|
|
11
|
-
on_error(['procedure', e]);
|
|
12
|
-
});
|
|
13
|
-
}
|
|
14
|
-
else {
|
|
15
|
-
on_success();
|
|
16
|
-
}
|
|
17
|
-
}, ($) => {
|
|
18
|
-
on_error(['precondition', $]);
|
|
19
|
-
});
|
|
20
|
-
}
|
|
21
|
-
});
|
|
22
|
-
};
|
|
23
|
-
exports.conditional_async = conditional_async;
|
|
@@ -1,4 +0,0 @@
|
|
|
1
|
-
import * as _et from 'exupery-core-types';
|
|
2
|
-
import { Basic_Query_Promise } from '../types/Basic_Query';
|
|
3
|
-
export type Conditional_Multiple_Error<Precondition_Error, Procedure_Error> = ['preconditions', _et.Dictionary<Precondition_Error>] | ['procedure', Procedure_Error];
|
|
4
|
-
export declare const conditional_multiple: <Precondition_Error, Procedure_Error>(preconditions: _et.Dictionary<Basic_Query_Promise<boolean, Precondition_Error>>, procedure: _et.Procedure_Promise<Procedure_Error>) => _et.Procedure_Promise<Conditional_Multiple_Error<Precondition_Error, Procedure_Error>>;
|
|
@@ -1,32 +0,0 @@
|
|
|
1
|
-
"use strict";
|
|
2
|
-
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
-
exports.conditional_multiple = void 0;
|
|
4
|
-
const query_dictionary_1 = require("../query/query_dictionary");
|
|
5
|
-
const create_procedure_promise_1 = require("../algorithms/procedure/create_procedure_promise");
|
|
6
|
-
const conditional_multiple = (preconditions, procedure) => {
|
|
7
|
-
return (0, create_procedure_promise_1.__create_procedure_promise)({
|
|
8
|
-
'execute': (on_success, on_error) => {
|
|
9
|
-
(0, query_dictionary_1.query_dictionary)(preconditions).__start(($) => {
|
|
10
|
-
let has_errors = false;
|
|
11
|
-
$.map(($) => {
|
|
12
|
-
if (!$) {
|
|
13
|
-
has_errors = true;
|
|
14
|
-
}
|
|
15
|
-
});
|
|
16
|
-
if (!has_errors) {
|
|
17
|
-
// all preconditions passed
|
|
18
|
-
procedure.__start(on_success, (e) => {
|
|
19
|
-
on_error(['procedure', e]);
|
|
20
|
-
});
|
|
21
|
-
}
|
|
22
|
-
else {
|
|
23
|
-
//the preconditions failed, so we are *successfully* skipping the procedure
|
|
24
|
-
on_success();
|
|
25
|
-
}
|
|
26
|
-
}, ($) => {
|
|
27
|
-
on_error(['preconditions', $]);
|
|
28
|
-
});
|
|
29
|
-
}
|
|
30
|
-
});
|
|
31
|
-
};
|
|
32
|
-
exports.conditional_multiple = conditional_multiple;
|
|
@@ -1,17 +0,0 @@
|
|
|
1
|
-
"use strict";
|
|
2
|
-
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
-
exports.conditional_sync = void 0;
|
|
4
|
-
const create_procedure_promise_1 = require("../algorithms/procedure/create_procedure_promise");
|
|
5
|
-
const conditional_sync = (precondition, procedure) => {
|
|
6
|
-
return (0, create_procedure_promise_1.__create_procedure_promise)({
|
|
7
|
-
'execute': (on_success, on_error) => {
|
|
8
|
-
if (precondition) {
|
|
9
|
-
procedure.__start(on_success, on_error);
|
|
10
|
-
}
|
|
11
|
-
else {
|
|
12
|
-
on_success();
|
|
13
|
-
}
|
|
14
|
-
}
|
|
15
|
-
});
|
|
16
|
-
};
|
|
17
|
-
exports.conditional_sync = conditional_sync;
|
|
@@ -1,61 +0,0 @@
|
|
|
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.dictionary_sequence = void 0;
|
|
27
|
-
const _ei = __importStar(require("exupery-core-internals"));
|
|
28
|
-
const create_procedure_promise_1 = require("../algorithms/procedure/create_procedure_promise");
|
|
29
|
-
const op_dictionary_to_list_based_on_insertion_order = (dict) => {
|
|
30
|
-
const temp = [];
|
|
31
|
-
dict.map(($, key) => {
|
|
32
|
-
temp.push({ key, value: $ });
|
|
33
|
-
});
|
|
34
|
-
return _ei.array_literal(temp);
|
|
35
|
-
};
|
|
36
|
-
const dictionary_sequence = (steps) => {
|
|
37
|
-
return (0, create_procedure_promise_1.__create_procedure_promise)({
|
|
38
|
-
'execute': (on_success, on_error) => {
|
|
39
|
-
const as_list = op_dictionary_to_list_based_on_insertion_order(steps);
|
|
40
|
-
let current = 0;
|
|
41
|
-
const do_next = () => {
|
|
42
|
-
as_list.__get_element_at(current).transform(($) => {
|
|
43
|
-
const key = $.key;
|
|
44
|
-
current += 1;
|
|
45
|
-
$.value.__start(() => {
|
|
46
|
-
do_next();
|
|
47
|
-
}, ($) => {
|
|
48
|
-
on_error({
|
|
49
|
-
'error': $,
|
|
50
|
-
'step': key,
|
|
51
|
-
});
|
|
52
|
-
});
|
|
53
|
-
}, () => {
|
|
54
|
-
on_success();
|
|
55
|
-
});
|
|
56
|
-
};
|
|
57
|
-
do_next();
|
|
58
|
-
}
|
|
59
|
-
});
|
|
60
|
-
};
|
|
61
|
-
exports.dictionary_sequence = dictionary_sequence;
|
|
@@ -1,14 +0,0 @@
|
|
|
1
|
-
"use strict";
|
|
2
|
-
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
-
exports.execute_with_async_data = void 0;
|
|
4
|
-
const create_procedure_promise_1 = require("../algorithms/procedure/create_procedure_promise");
|
|
5
|
-
const execute_with_async_data = (procedure, query) => {
|
|
6
|
-
return (0, create_procedure_promise_1.__create_procedure_promise)({
|
|
7
|
-
'execute': (on_success, on_error) => {
|
|
8
|
-
query.__start((query_result) => {
|
|
9
|
-
procedure["execute with synchronous data"](query_result).__start(on_success, on_error);
|
|
10
|
-
}, on_error);
|
|
11
|
-
}
|
|
12
|
-
});
|
|
13
|
-
};
|
|
14
|
-
exports.execute_with_async_data = execute_with_async_data;
|
|
@@ -1,58 +0,0 @@
|
|
|
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.procedure_dictionary = void 0;
|
|
27
|
-
const _ei = __importStar(require("exupery-core-internals"));
|
|
28
|
-
const create_procedure_promise_1 = require("../algorithms/procedure/create_procedure_promise");
|
|
29
|
-
const procedure_dictionary = ($) => {
|
|
30
|
-
return (0, create_procedure_promise_1.__create_procedure_promise)({
|
|
31
|
-
'execute': (on_success, on_error) => {
|
|
32
|
-
let count_down = $.__get_number_of_entries();
|
|
33
|
-
let has_errors = false;
|
|
34
|
-
const errors = {};
|
|
35
|
-
const decrement_and_wrap_up_if_done = () => {
|
|
36
|
-
count_down -= 1;
|
|
37
|
-
if (count_down === 0) {
|
|
38
|
-
if (has_errors) {
|
|
39
|
-
on_error(_ei.dictionary_literal(errors));
|
|
40
|
-
}
|
|
41
|
-
else {
|
|
42
|
-
on_success();
|
|
43
|
-
}
|
|
44
|
-
}
|
|
45
|
-
};
|
|
46
|
-
$.map(($, key) => {
|
|
47
|
-
$.__start(() => {
|
|
48
|
-
decrement_and_wrap_up_if_done();
|
|
49
|
-
}, (e) => {
|
|
50
|
-
has_errors = true;
|
|
51
|
-
errors[key] = e;
|
|
52
|
-
decrement_and_wrap_up_if_done();
|
|
53
|
-
});
|
|
54
|
-
});
|
|
55
|
-
}
|
|
56
|
-
});
|
|
57
|
-
};
|
|
58
|
-
exports.procedure_dictionary = procedure_dictionary;
|
|
@@ -1,23 +0,0 @@
|
|
|
1
|
-
"use strict";
|
|
2
|
-
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
-
exports.sequence = void 0;
|
|
4
|
-
const create_procedure_promise_1 = require("../algorithms/procedure/create_procedure_promise");
|
|
5
|
-
const sequence = (steps) => {
|
|
6
|
-
return (0, create_procedure_promise_1.__create_procedure_promise)({
|
|
7
|
-
'execute': (on_success, on_error) => {
|
|
8
|
-
let current = 0;
|
|
9
|
-
const do_next = () => {
|
|
10
|
-
steps.__get_element_at(current).transform(($) => {
|
|
11
|
-
current += 1;
|
|
12
|
-
$.__start(() => {
|
|
13
|
-
do_next();
|
|
14
|
-
}, on_error);
|
|
15
|
-
}, () => {
|
|
16
|
-
on_success();
|
|
17
|
-
});
|
|
18
|
-
};
|
|
19
|
-
do_next();
|
|
20
|
-
}
|
|
21
|
-
});
|
|
22
|
-
};
|
|
23
|
-
exports.sequence = sequence;
|
|
@@ -1,3 +0,0 @@
|
|
|
1
|
-
import * as _et from 'exupery-core-types';
|
|
2
|
-
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];
|
|
3
|
-
export declare 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>>;
|
|
@@ -1,22 +0,0 @@
|
|
|
1
|
-
"use strict";
|
|
2
|
-
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
-
exports.three_steps = void 0;
|
|
4
|
-
const create_procedure_promise_1 = require("../algorithms/procedure/create_procedure_promise");
|
|
5
|
-
const three_steps = (step_1, step_2, step_3) => {
|
|
6
|
-
return (0, create_procedure_promise_1.__create_procedure_promise)({
|
|
7
|
-
'execute': (on_success, on_error) => {
|
|
8
|
-
step_1.__start(() => {
|
|
9
|
-
step_2.__start(() => {
|
|
10
|
-
step_3.__start(on_success, (error) => {
|
|
11
|
-
on_error(['step3', error]);
|
|
12
|
-
});
|
|
13
|
-
}, (error) => {
|
|
14
|
-
on_error(['step2', error]);
|
|
15
|
-
});
|
|
16
|
-
}, (error) => {
|
|
17
|
-
on_error(['step1', error]);
|
|
18
|
-
});
|
|
19
|
-
}
|
|
20
|
-
});
|
|
21
|
-
};
|
|
22
|
-
exports.three_steps = three_steps;
|
|
@@ -1,3 +0,0 @@
|
|
|
1
|
-
import * as _et from 'exupery-core-types';
|
|
2
|
-
export type Two_Steps_Error<Step_1_Error, Step_2_Error> = ['step1', Step_1_Error] | ['step2', Step_2_Error];
|
|
3
|
-
export declare 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>>;
|
|
@@ -1,18 +0,0 @@
|
|
|
1
|
-
"use strict";
|
|
2
|
-
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
-
exports.two_steps = void 0;
|
|
4
|
-
const create_procedure_promise_1 = require("../algorithms/procedure/create_procedure_promise");
|
|
5
|
-
const two_steps = (step_1, step_2) => {
|
|
6
|
-
return (0, create_procedure_promise_1.__create_procedure_promise)({
|
|
7
|
-
'execute': (on_success, on_error) => {
|
|
8
|
-
step_1.__start(() => {
|
|
9
|
-
step_2.__start(on_success, (error) => {
|
|
10
|
-
on_error(['step2', error]);
|
|
11
|
-
});
|
|
12
|
-
}, (error) => {
|
|
13
|
-
on_error(['step1', error]);
|
|
14
|
-
});
|
|
15
|
-
}
|
|
16
|
-
});
|
|
17
|
-
};
|
|
18
|
-
exports.two_steps = two_steps;
|
|
@@ -1,3 +0,0 @@
|
|
|
1
|
-
import * as _et from 'exupery-core-types';
|
|
2
|
-
import { Basic_Query_Promise } from '../types/Basic_Query';
|
|
3
|
-
export declare const query_dictionary: <Result, Error>($: _et.Dictionary<Basic_Query_Promise<Result, Error>>) => _et.Query_Promise<_et.Dictionary<Result>, _et.Dictionary<Error>>;
|
|
@@ -1,60 +0,0 @@
|
|
|
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.query_dictionary = void 0;
|
|
27
|
-
const _ei = __importStar(require("exupery-core-internals"));
|
|
28
|
-
const create_query_promise_1 = require("../algorithms/query/create_query_promise");
|
|
29
|
-
const query_dictionary = ($) => {
|
|
30
|
-
return (0, create_query_promise_1.__create_query_promise)({
|
|
31
|
-
'execute': (on_success, on_error) => {
|
|
32
|
-
let count_down = $.__get_number_of_entries();
|
|
33
|
-
let has_errors = false;
|
|
34
|
-
const errors = {};
|
|
35
|
-
const results = {};
|
|
36
|
-
const decrement_and_wrap_up_if_done = () => {
|
|
37
|
-
count_down -= 1;
|
|
38
|
-
if (count_down === 0) {
|
|
39
|
-
if (has_errors) {
|
|
40
|
-
on_error(_ei.dictionary_literal(errors));
|
|
41
|
-
}
|
|
42
|
-
else {
|
|
43
|
-
on_success(_ei.dictionary_literal(results));
|
|
44
|
-
}
|
|
45
|
-
}
|
|
46
|
-
};
|
|
47
|
-
$.map(($, key) => {
|
|
48
|
-
$.__start(($) => {
|
|
49
|
-
results[key] = $;
|
|
50
|
-
decrement_and_wrap_up_if_done();
|
|
51
|
-
}, ($) => {
|
|
52
|
-
has_errors = true;
|
|
53
|
-
errors[key] = $;
|
|
54
|
-
decrement_and_wrap_up_if_done();
|
|
55
|
-
});
|
|
56
|
-
});
|
|
57
|
-
}
|
|
58
|
-
});
|
|
59
|
-
};
|
|
60
|
-
exports.query_dictionary = query_dictionary;
|
|
@@ -1,16 +0,0 @@
|
|
|
1
|
-
"use strict";
|
|
2
|
-
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
-
exports.transform_query = void 0;
|
|
4
|
-
const create_query_promise_1 = require("../algorithms/query/create_query_promise");
|
|
5
|
-
const transform_query = (query, transform) => {
|
|
6
|
-
return (0, create_query_promise_1.__create_query_promise)({
|
|
7
|
-
'execute': (on_success, on_error) => {
|
|
8
|
-
query.__start(($) => {
|
|
9
|
-
on_success(transform($));
|
|
10
|
-
}, (e) => {
|
|
11
|
-
on_error(e);
|
|
12
|
-
});
|
|
13
|
-
}
|
|
14
|
-
});
|
|
15
|
-
};
|
|
16
|
-
exports.transform_query = transform_query;
|
package/dist/shorthands.d.ts
DELETED
|
@@ -1,64 +0,0 @@
|
|
|
1
|
-
import * as _et from 'exupery-core-types';
|
|
2
|
-
import { Basic_Query_Promise } from "./types/Basic_Query";
|
|
3
|
-
import { Error_Handler } from "./types/Error_Handler";
|
|
4
|
-
export declare namespace p {
|
|
5
|
-
/**
|
|
6
|
-
*
|
|
7
|
-
* @param action upi
|
|
8
|
-
* @param query u.q
|
|
9
|
-
*/
|
|
10
|
-
const action: <Error, Parameters, Resources>(action: _et.Procedure<Parameters, Error, Resources>, query: Basic_Query_Promise<Parameters, Error>, resources: Resources) => _et.Procedure_Promise<Error>;
|
|
11
|
-
/**
|
|
12
|
-
*
|
|
13
|
-
* @param steps up[]
|
|
14
|
-
* @returns
|
|
15
|
-
*/
|
|
16
|
-
const sequence: <Error>(steps: _et.Procedure_Promise<Error>[]) => _et.Procedure_Promise<Error>;
|
|
17
|
-
/**
|
|
18
|
-
*
|
|
19
|
-
* @param the_array up[]
|
|
20
|
-
* @param aggregate_errors gt
|
|
21
|
-
* @returns
|
|
22
|
-
*/
|
|
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
|
-
/**
|
|
25
|
-
*
|
|
26
|
-
* @param the_dictionary dict<up>
|
|
27
|
-
* @param aggregate_errors gt
|
|
28
|
-
* @returns
|
|
29
|
-
*/
|
|
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
|
-
}
|
|
32
|
-
export declare namespace q {
|
|
33
|
-
/**
|
|
34
|
-
*
|
|
35
|
-
* @param query_result qr
|
|
36
|
-
* @returns
|
|
37
|
-
*/
|
|
38
|
-
const fixed: <Query_Result, Error>(query_result: Query_Result) => Basic_Query_Promise<Query_Result, Error>;
|
|
39
|
-
/**
|
|
40
|
-
* query
|
|
41
|
-
* @param the_query uqi
|
|
42
|
-
* @param parameters u.q
|
|
43
|
-
* @param result_refinement ut
|
|
44
|
-
* @param error_transform gt
|
|
45
|
-
* @param error_handler eh
|
|
46
|
-
* @returns
|
|
47
|
-
*/
|
|
48
|
-
const u: <Result_After_Transformation, Error, Parameters, Query_Result, Query_Error, Resources>(the_query: _et.Query<Parameters, Query_Result, Query_Error, Resources>, parameters: Basic_Query_Promise<Parameters, Error>, resources: Resources, result_refinement: _et.Refiner_Without_Parameters<Query_Result, Result_After_Transformation, Error>, error_transform: _et.Transformer_Without_Parameters<Query_Error, Error>, error_handler?: Error_Handler<Query_Error>) => Basic_Query_Promise<Result_After_Transformation, Error>;
|
|
49
|
-
}
|
|
50
|
-
export declare namespace t {
|
|
51
|
-
/**
|
|
52
|
-
*
|
|
53
|
-
* @param the_refinement ut
|
|
54
|
-
* @param error_transform gt
|
|
55
|
-
* @param error_handler eh
|
|
56
|
-
* @returns
|
|
57
|
-
*/
|
|
58
|
-
const u: <In, Out, Error, Transformation_Error>(the_refinement: _et.Refiner_Without_Parameters<In, Out, Transformation_Error>, error_transform: _et.Transformer_Without_Parameters<Transformation_Error, Error>, error_handler?: Error_Handler<Transformation_Error>) => _et.Refiner_Without_Parameters<In, Out, Error>;
|
|
59
|
-
/**
|
|
60
|
-
*
|
|
61
|
-
* @param the_transformation gt
|
|
62
|
-
*/
|
|
63
|
-
const g: <In, Out, Error>(the_transformation: _et.Transformer_Without_Parameters<In, Out>) => _et.Refiner_Without_Parameters<In, Out, Error>;
|
|
64
|
-
}
|
package/dist/shorthands.js
DELETED
|
@@ -1,204 +0,0 @@
|
|
|
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.t = exports.q = 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 create_asynchronous_processes_monitor_1 = require("./create_asynchronous_processes_monitor");
|
|
30
|
-
var p;
|
|
31
|
-
(function (p) {
|
|
32
|
-
/**
|
|
33
|
-
*
|
|
34
|
-
* @param action upi
|
|
35
|
-
* @param query u.q
|
|
36
|
-
*/
|
|
37
|
-
p.action = (action, query, resources) => {
|
|
38
|
-
return (0, create_procedure_promise_1.__create_procedure_promise)({
|
|
39
|
-
'execute': (on_success, on_error) => {
|
|
40
|
-
//run the query
|
|
41
|
-
query.__start((query_result) => {
|
|
42
|
-
//run the action
|
|
43
|
-
action(resources)['execute with synchronous data'](query_result).__start(on_success, (error) => {
|
|
44
|
-
//transform the error
|
|
45
|
-
on_error(error);
|
|
46
|
-
});
|
|
47
|
-
}, on_error);
|
|
48
|
-
}
|
|
49
|
-
});
|
|
50
|
-
};
|
|
51
|
-
/**
|
|
52
|
-
*
|
|
53
|
-
* @param steps up[]
|
|
54
|
-
* @returns
|
|
55
|
-
*/
|
|
56
|
-
p.sequence = (steps) => {
|
|
57
|
-
return (0, create_procedure_promise_1.__create_procedure_promise)({
|
|
58
|
-
'execute': (on_success, on_error) => {
|
|
59
|
-
const length = _ei.array_literal(steps).__get_number_of_elements();
|
|
60
|
-
const runStep = (index) => {
|
|
61
|
-
if (index >= length) {
|
|
62
|
-
on_success();
|
|
63
|
-
return;
|
|
64
|
-
}
|
|
65
|
-
steps[index].__start(() => runStep(index + 1), on_error);
|
|
66
|
-
};
|
|
67
|
-
runStep(0);
|
|
68
|
-
}
|
|
69
|
-
});
|
|
70
|
-
};
|
|
71
|
-
/**
|
|
72
|
-
*
|
|
73
|
-
* @param the_array up[]
|
|
74
|
-
* @param aggregate_errors gt
|
|
75
|
-
* @returns
|
|
76
|
-
*/
|
|
77
|
-
p.array = (the_array, aggregate_errors) => {
|
|
78
|
-
return (0, create_procedure_promise_1.__create_procedure_promise)({
|
|
79
|
-
'execute': (on_success, on_error) => {
|
|
80
|
-
const errors = [];
|
|
81
|
-
(0, create_asynchronous_processes_monitor_1.create_asynchronous_processes_monitor)((monitor) => {
|
|
82
|
-
the_array.map(($) => {
|
|
83
|
-
monitor['report process started']();
|
|
84
|
-
$.__start(() => {
|
|
85
|
-
monitor['report process finished']();
|
|
86
|
-
}, (e) => {
|
|
87
|
-
errors.push(e);
|
|
88
|
-
monitor['report process finished']();
|
|
89
|
-
});
|
|
90
|
-
});
|
|
91
|
-
}, () => {
|
|
92
|
-
if (errors.length === 0) {
|
|
93
|
-
on_success();
|
|
94
|
-
}
|
|
95
|
-
else {
|
|
96
|
-
on_error(aggregate_errors(_ei.array_literal(errors)));
|
|
97
|
-
}
|
|
98
|
-
});
|
|
99
|
-
}
|
|
100
|
-
});
|
|
101
|
-
};
|
|
102
|
-
/**
|
|
103
|
-
*
|
|
104
|
-
* @param the_dictionary dict<up>
|
|
105
|
-
* @param aggregate_errors gt
|
|
106
|
-
* @returns
|
|
107
|
-
*/
|
|
108
|
-
p.dictionary = (the_dictionary, aggregate_errors) => {
|
|
109
|
-
return (0, create_procedure_promise_1.__create_procedure_promise)({
|
|
110
|
-
'execute': (on_success, on_error) => {
|
|
111
|
-
const errors = {};
|
|
112
|
-
(0, create_asynchronous_processes_monitor_1.create_asynchronous_processes_monitor)((monitor) => {
|
|
113
|
-
the_dictionary.map(($, key) => {
|
|
114
|
-
monitor['report process started']();
|
|
115
|
-
$.__start(() => {
|
|
116
|
-
monitor['report process finished']();
|
|
117
|
-
}, (e) => {
|
|
118
|
-
errors[key] = e;
|
|
119
|
-
monitor['report process finished']();
|
|
120
|
-
});
|
|
121
|
-
});
|
|
122
|
-
}, () => {
|
|
123
|
-
if (Object.keys(errors).length === 0) {
|
|
124
|
-
on_success();
|
|
125
|
-
}
|
|
126
|
-
else {
|
|
127
|
-
on_error(aggregate_errors(_ei.dictionary_literal(errors)));
|
|
128
|
-
}
|
|
129
|
-
});
|
|
130
|
-
}
|
|
131
|
-
});
|
|
132
|
-
};
|
|
133
|
-
})(p || (exports.p = p = {}));
|
|
134
|
-
var q;
|
|
135
|
-
(function (q) {
|
|
136
|
-
/**
|
|
137
|
-
*
|
|
138
|
-
* @param query_result qr
|
|
139
|
-
* @returns
|
|
140
|
-
*/
|
|
141
|
-
q.fixed = (query_result) => {
|
|
142
|
-
return {
|
|
143
|
-
__start: (on_success, on_error) => {
|
|
144
|
-
on_success(query_result);
|
|
145
|
-
}
|
|
146
|
-
};
|
|
147
|
-
};
|
|
148
|
-
/**
|
|
149
|
-
* query
|
|
150
|
-
* @param the_query uqi
|
|
151
|
-
* @param parameters u.q
|
|
152
|
-
* @param result_refinement ut
|
|
153
|
-
* @param error_transform gt
|
|
154
|
-
* @param error_handler eh
|
|
155
|
-
* @returns
|
|
156
|
-
*/
|
|
157
|
-
q.u = (the_query, parameters, resources, result_refinement, error_transform, error_handler) => {
|
|
158
|
-
return {
|
|
159
|
-
__start: (on_success, on_error) => {
|
|
160
|
-
parameters.__start((qr_in) => {
|
|
161
|
-
the_query(resources).execute(qr_in).__start((result) => {
|
|
162
|
-
result_refinement(result).process((x) => on_success(x), on_error);
|
|
163
|
-
}, (error) => {
|
|
164
|
-
if (error_handler !== undefined) {
|
|
165
|
-
error_handler(error);
|
|
166
|
-
}
|
|
167
|
-
on_error(error_transform(error));
|
|
168
|
-
});
|
|
169
|
-
}, on_error);
|
|
170
|
-
}
|
|
171
|
-
};
|
|
172
|
-
};
|
|
173
|
-
})(q || (exports.q = q = {}));
|
|
174
|
-
var t;
|
|
175
|
-
(function (t) {
|
|
176
|
-
/**
|
|
177
|
-
*
|
|
178
|
-
* @param the_refinement ut
|
|
179
|
-
* @param error_transform gt
|
|
180
|
-
* @param error_handler eh
|
|
181
|
-
* @returns
|
|
182
|
-
*/
|
|
183
|
-
t.u = (the_refinement, error_transform, error_handler) => {
|
|
184
|
-
return ($) => {
|
|
185
|
-
const result = the_refinement($);
|
|
186
|
-
return result.map((out) => out, (transformation_error) => {
|
|
187
|
-
//run the error handler
|
|
188
|
-
if (error_handler !== undefined) {
|
|
189
|
-
error_handler(transformation_error);
|
|
190
|
-
}
|
|
191
|
-
return error_transform(transformation_error);
|
|
192
|
-
});
|
|
193
|
-
};
|
|
194
|
-
};
|
|
195
|
-
/**
|
|
196
|
-
*
|
|
197
|
-
* @param the_transformation gt
|
|
198
|
-
*/
|
|
199
|
-
t.g = (the_transformation) => {
|
|
200
|
-
return ($) => {
|
|
201
|
-
return _ei.refinement.successful(the_transformation($));
|
|
202
|
-
};
|
|
203
|
-
};
|
|
204
|
-
})(t || (exports.t = t = {}));
|