exupery-core-async 0.1.41 → 0.1.43

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.
Files changed (28) hide show
  1. package/dist/{procedure → algorithms/procedure}/initialize_guaranteed_procedure.d.ts +1 -1
  2. package/dist/{procedure → algorithms/procedure}/initialize_unguaranteed_procedure.d.ts +1 -1
  3. package/dist/{query → algorithms/query}/create_guaranteed_query.d.ts +1 -1
  4. package/dist/{query → algorithms/query}/create_unguaranteed_query.d.ts +1 -1
  5. package/dist/{query → algorithms/query}/merge_2_guaranteed_queries.d.ts +1 -1
  6. package/dist/index.d.ts +14 -14
  7. package/dist/index.js +14 -14
  8. package/dist/shorthands.d.ts +128 -0
  9. package/dist/shorthands.js +326 -0
  10. package/dist/types/Error_Handler.d.ts +1 -0
  11. package/dist/types/Guaranteed_Procedure.d.ts +4 -0
  12. package/dist/{query → types}/Guaranteed_Query.d.ts +5 -0
  13. package/dist/{procedure → types}/Unguaranteed_Procedure.d.ts +1 -1
  14. package/dist/{query → types}/Unguaranteed_Query.d.ts +5 -0
  15. package/dist/types/Unguaranteed_Query.js +2 -0
  16. package/package.json +1 -1
  17. package/dist/new.d.ts +0 -102
  18. package/dist/new.js +0 -307
  19. package/dist/procedure/Guaranteed_Procedure.d.ts +0 -4
  20. /package/dist/{procedure → algorithms/procedure}/initialize_guaranteed_procedure.js +0 -0
  21. /package/dist/{procedure → algorithms/procedure}/initialize_unguaranteed_procedure.js +0 -0
  22. /package/dist/{query → algorithms/query}/create_guaranteed_query.js +0 -0
  23. /package/dist/{query → algorithms/query}/create_unguaranteed_query.js +0 -0
  24. /package/dist/{query → algorithms/query}/merge_2_guaranteed_queries.js +0 -0
  25. /package/dist/{procedure/Guaranteed_Procedure.js → types/Error_Handler.js} +0 -0
  26. /package/dist/{procedure/Unguaranteed_Procedure.js → types/Guaranteed_Procedure.js} +0 -0
  27. /package/dist/{query → types}/Guaranteed_Query.js +0 -0
  28. /package/dist/{query/Unguaranteed_Query.js → types/Unguaranteed_Procedure.js} +0 -0
@@ -1,4 +1,4 @@
1
- import { Guaranteed_Procedure } from "./Guaranteed_Procedure";
1
+ import { Guaranteed_Procedure } from "../../types/Guaranteed_Procedure";
2
2
  type Executer = {
3
3
  'execute': (on_finished: () => void) => void;
4
4
  };
@@ -1,4 +1,4 @@
1
- import { Unguaranteed_Procedure } from "./Unguaranteed_Procedure";
1
+ import { Unguaranteed_Procedure } from "../../types/Unguaranteed_Procedure";
2
2
  /**
3
3
  * this function contains the body in which the async value or exception is executed
4
4
  * after the execution, either the on_value or on_exception callback will be called
@@ -1,4 +1,4 @@
1
- import { _Guaranteed_Query } from "./Guaranteed_Query";
1
+ import { _Guaranteed_Query } from "../../types/Guaranteed_Query";
2
2
  type Executer<T> = {
3
3
  'execute': (on_value: ($: T) => void) => void;
4
4
  };
@@ -1,4 +1,4 @@
1
- import { _Unguaranteed_Query } from "./Unguaranteed_Query";
1
+ import { _Unguaranteed_Query } from "../../types/Unguaranteed_Query";
2
2
  /**
3
3
  * this function contains the body in which the async value or exception is executed
4
4
  * after the execution, either the on_value or on_exception callback will be called
@@ -1,4 +1,4 @@
1
- import { _Guaranteed_Query } from "./Guaranteed_Query";
1
+ import { _Guaranteed_Query } from "../../types/Guaranteed_Query";
2
2
  export type Sync_Tuple_2<T1, T2> = {
3
3
  readonly 'first': T1;
4
4
  readonly 'second': T2;
package/dist/index.d.ts CHANGED
@@ -1,17 +1,17 @@
1
- export * from "./procedure/Guaranteed_Procedure";
2
- export * from "./procedure/Unguaranteed_Procedure";
3
- export * from "./query/Unguaranteed_Query";
4
- export * from "./query/Guaranteed_Query";
5
- export * from "./query/merge_2_guaranteed_queries";
6
- export * from "./query/create_guaranteed_query";
7
- export * from "./query/create_unguaranteed_query";
8
- export * from "./procedure/initialize_guaranteed_procedure";
9
- export * from "./procedure/initialize_unguaranteed_procedure";
10
- export * from "./new";
11
- import { Guaranteed_Procedure } from "./procedure/Guaranteed_Procedure";
12
- import { Unguaranteed_Procedure } from "./procedure/Unguaranteed_Procedure";
13
- import { _Guaranteed_Query } from "./query/Guaranteed_Query";
14
- import { _Unguaranteed_Query } from "./query/Unguaranteed_Query";
1
+ export * from "./types/Guaranteed_Procedure";
2
+ export * from "./types/Unguaranteed_Procedure";
3
+ export * from "./types/Unguaranteed_Query";
4
+ export * from "./types/Guaranteed_Query";
5
+ export * from "./algorithms/query/merge_2_guaranteed_queries";
6
+ export * from "./algorithms/query/create_guaranteed_query";
7
+ export * from "./algorithms/query/create_unguaranteed_query";
8
+ export * from "./algorithms/procedure/initialize_guaranteed_procedure";
9
+ export * from "./algorithms/procedure/initialize_unguaranteed_procedure";
10
+ export * from "./shorthands";
11
+ import { Guaranteed_Procedure } from "./types/Guaranteed_Procedure";
12
+ import { Unguaranteed_Procedure } from "./types/Unguaranteed_Procedure";
13
+ import { _Guaranteed_Query } from "./types/Guaranteed_Query";
14
+ import { _Unguaranteed_Query } from "./types/Unguaranteed_Query";
15
15
  export declare const query: {
16
16
  guaranteed: {
17
17
  'create result': <T>($: T) => _Guaranteed_Query<T>;
package/dist/index.js CHANGED
@@ -16,21 +16,21 @@ var __exportStar = (this && this.__exportStar) || function(m, exports) {
16
16
  Object.defineProperty(exports, "__esModule", { value: true });
17
17
  exports.command = exports.query = void 0;
18
18
  //types
19
- __exportStar(require("./procedure/Guaranteed_Procedure"), exports);
20
- __exportStar(require("./procedure/Unguaranteed_Procedure"), exports);
21
- __exportStar(require("./query/Unguaranteed_Query"), exports);
22
- __exportStar(require("./query/Guaranteed_Query"), exports);
19
+ __exportStar(require("./types/Guaranteed_Procedure"), exports);
20
+ __exportStar(require("./types/Unguaranteed_Procedure"), exports);
21
+ __exportStar(require("./types/Unguaranteed_Query"), exports);
22
+ __exportStar(require("./types/Guaranteed_Query"), exports);
23
23
  //functions
24
- __exportStar(require("./query/merge_2_guaranteed_queries"), exports);
25
- __exportStar(require("./query/create_guaranteed_query"), exports);
26
- __exportStar(require("./query/create_unguaranteed_query"), exports);
27
- __exportStar(require("./procedure/initialize_guaranteed_procedure"), exports);
28
- __exportStar(require("./procedure/initialize_unguaranteed_procedure"), exports);
29
- __exportStar(require("./new"), exports);
30
- const initialize_guaranteed_procedure_1 = require("./procedure/initialize_guaranteed_procedure");
31
- const initialize_unguaranteed_procedure_1 = require("./procedure/initialize_unguaranteed_procedure");
32
- const create_guaranteed_query_1 = require("./query/create_guaranteed_query");
33
- const create_unguaranteed_query_1 = require("./query/create_unguaranteed_query");
24
+ __exportStar(require("./algorithms/query/merge_2_guaranteed_queries"), exports);
25
+ __exportStar(require("./algorithms/query/create_guaranteed_query"), exports);
26
+ __exportStar(require("./algorithms/query/create_unguaranteed_query"), exports);
27
+ __exportStar(require("./algorithms/procedure/initialize_guaranteed_procedure"), exports);
28
+ __exportStar(require("./algorithms/procedure/initialize_unguaranteed_procedure"), exports);
29
+ __exportStar(require("./shorthands"), exports);
30
+ const initialize_guaranteed_procedure_1 = require("./algorithms/procedure/initialize_guaranteed_procedure");
31
+ const initialize_unguaranteed_procedure_1 = require("./algorithms/procedure/initialize_unguaranteed_procedure");
32
+ const create_guaranteed_query_1 = require("./algorithms/query/create_guaranteed_query");
33
+ const create_unguaranteed_query_1 = require("./algorithms/query/create_unguaranteed_query");
34
34
  exports.query = {
35
35
  'guaranteed': {
36
36
  'create result': ($) => {
@@ -0,0 +1,128 @@
1
+ import * as _ei from 'exupery-core-internals';
2
+ import * as _et from 'exupery-core-types';
3
+ import { Unguaranteed } from "./types/Unguaranteed_Query";
4
+ import { Guaranteed } from "./types/Guaranteed_Query";
5
+ import { Guaranteed_Procedure, Guaranteed_Procedure_Initializer } from "./types/Guaranteed_Procedure";
6
+ import { Unguaranteed_Procedure_Initializer, Unguaranteed_Procedure } from "./types/Unguaranteed_Procedure";
7
+ import { Unguaranteed_Query_Initializer } from "./types/Unguaranteed_Query";
8
+ import { Guaranteed_Query_Initializer } from "./types/Guaranteed_Query";
9
+ import { Error_Handler } from "./types/Error_Handler";
10
+ /**
11
+ *
12
+ * @param action gpi
13
+ * @param error_transform gt
14
+ */
15
+ export declare const eh: <Parameters, Error>(action: Guaranteed_Procedure_Initializer<Parameters>, error_transform: _ei.Guaranteed_Transformation_Without_Parameters<Error, Parameters>) => Error_Handler<Error>;
16
+ export declare namespace gp {
17
+ /**
18
+ *
19
+ * @param action gpi
20
+ * @param query g.q
21
+ * @returns
22
+ */
23
+ const action: <Parameters>(action: Guaranteed_Procedure_Initializer<Parameters>, query: Guaranteed.Query_<Parameters>) => Guaranteed_Procedure;
24
+ }
25
+ export declare namespace gq {
26
+ /**
27
+ *
28
+ * @param query_result qr
29
+ * @returns
30
+ */
31
+ const fixed: <Query_Result>(query_result: Query_Result) => Guaranteed.Query_<Query_Result>;
32
+ /**
33
+ *
34
+ * @param the_query gqi
35
+ * @param parameters g.q
36
+ * @param result_transformation gt
37
+ * @returns
38
+ */
39
+ const g: <Result_After_Transformation, Parameters, Query_Result>(the_query: Guaranteed_Query_Initializer<Parameters, Query_Result>, parameters: Guaranteed.Query_<Parameters>, result_transformation: _ei.Guaranteed_Transformation_Without_Parameters<Query_Result, Result_After_Transformation>) => Guaranteed.Query_<Result_After_Transformation>;
40
+ }
41
+ export declare namespace gt {
42
+ /**
43
+ *
44
+ * @param the_transformation gt
45
+ * @returns
46
+ */
47
+ const g: <In, Out>(the_transformation: _ei.Guaranteed_Transformation_Without_Parameters<In, Out>) => _ei.Guaranteed_Transformation_Without_Parameters<In, Out>;
48
+ }
49
+ export declare namespace up {
50
+ /**
51
+ *
52
+ * @param action upi
53
+ * @param query u.q
54
+ */
55
+ const action: <Error, Parameters>(action: Unguaranteed_Procedure_Initializer<Parameters, Error>, query: Unguaranteed.Query<Parameters, Error>) => Unguaranteed_Procedure<Error>;
56
+ /**
57
+ *
58
+ * @param steps up[]
59
+ * @returns
60
+ */
61
+ const sequence: <Error>(steps: Unguaranteed_Procedure<Error>[]) => Unguaranteed_Procedure<Error>;
62
+ /**
63
+ *
64
+ * @param the_array up[]
65
+ * @param aggregate_exceptions gt
66
+ * @returns
67
+ */
68
+ const array: <Error, Element_Error>(the_array: _et.Array<Unguaranteed_Procedure<Element_Error>>, aggregate_exceptions: _ei.Guaranteed_Transformation_Without_Parameters<_et.Array<Element_Error>, Error>) => Unguaranteed_Procedure<Error>;
69
+ /**
70
+ *
71
+ * @param the_dictionary dict<up>
72
+ * @param aggregate_exceptions gt
73
+ * @returns
74
+ */
75
+ const dictionary: <Error, Element_Error>(the_dictionary: _et.Dictionary<Unguaranteed_Procedure<Element_Error>>, aggregate_exceptions: _ei.Guaranteed_Transformation_Without_Parameters<_et.Dictionary<Element_Error>, Error>) => Unguaranteed_Procedure<Error>;
76
+ }
77
+ export declare namespace upi {
78
+ /**
79
+ *
80
+ * @param action gpi
81
+ */
82
+ const g: <Parameters, Error>(action: Guaranteed_Procedure_Initializer<Parameters>) => Unguaranteed_Procedure_Initializer<Parameters, Error>;
83
+ /**
84
+ *
85
+ * @param action upi
86
+ */
87
+ const u: <Parameters, Error, Action_Error>(action: Unguaranteed_Procedure_Initializer<Parameters, Action_Error>, error_transform: _ei.Guaranteed_Transformation_Without_Parameters<Action_Error, Error>, error_handler?: Error_Handler<Action_Error>) => Unguaranteed_Procedure_Initializer<Parameters, Error>;
88
+ }
89
+ export declare namespace uq {
90
+ /**
91
+ *
92
+ * @param query_result qr
93
+ * @returns
94
+ */
95
+ const fixed: <Query_Result, Error>(query_result: Query_Result) => Unguaranteed.Query<Query_Result, Error>;
96
+ /**
97
+ * unguaranteed query
98
+ * @param the_query uqi
99
+ * @param parameters u.q
100
+ * @param result_transformation ut
101
+ * @param error_transform gt
102
+ * @param error_handler eh
103
+ * @returns
104
+ */
105
+ const u: <Result_After_Transformation, Error, Parameters, Query_Result, Query_Error>(the_query: Unguaranteed_Query_Initializer<Parameters, Query_Result, Query_Error>, parameters: Unguaranteed.Query<Parameters, Error>, result_transformation: _ei.Unguaranteed_Transformation_Without_Parameters<Query_Result, Result_After_Transformation, Error>, error_transform: _ei.Guaranteed_Transformation_Without_Parameters<Query_Error, Error>, error_handler?: Error_Handler<Query_Error>) => Unguaranteed.Query<Result_After_Transformation, Error>;
106
+ /**
107
+ * guaranteed query
108
+ * @param the_query gqi
109
+ * @param parameters u.q
110
+ * @param result_transformation ut
111
+ */
112
+ const g: <Result_After_Transformation, Error, Parameters, Query_Result>(the_query: Guaranteed_Query_Initializer<Parameters, Query_Result>, parameters: Unguaranteed.Query<Parameters, Error>, result_transformation: _ei.Unguaranteed_Transformation_Without_Parameters<Query_Result, Result_After_Transformation, Error>) => Unguaranteed.Query<Result_After_Transformation, Error>;
113
+ }
114
+ export declare namespace ut {
115
+ /**
116
+ *
117
+ * @param the_transformation ut
118
+ * @param error_transform gt
119
+ * @param error_handler eh
120
+ * @returns
121
+ */
122
+ const u: <In, Out, Error, Transformation_Error>(the_transformation: _ei.Unguaranteed_Transformation_Without_Parameters<In, Out, Transformation_Error>, error_transform: _ei.Guaranteed_Transformation_Without_Parameters<Transformation_Error, Error>, error_handler?: Error_Handler<Transformation_Error>) => _ei.Unguaranteed_Transformation_Without_Parameters<In, Out, Error>;
123
+ /**
124
+ *
125
+ * @param the_transformation gt
126
+ */
127
+ const g: <In, Out, Error>(the_transformation: _ei.Guaranteed_Transformation_Without_Parameters<In, Out>) => _ei.Unguaranteed_Transformation_Without_Parameters<In, Out, Error>;
128
+ }
@@ -0,0 +1,326 @@
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.ut = exports.uq = exports.upi = exports.up = exports.gt = exports.gq = exports.gp = exports.eh = void 0;
27
+ const _ei = __importStar(require("exupery-core-internals"));
28
+ const initialize_unguaranteed_procedure_1 = require("./algorithms/procedure/initialize_unguaranteed_procedure");
29
+ const create_asynchronous_processes_monitor_1 = require("./create_asynchronous_processes_monitor");
30
+ /**
31
+ *
32
+ * @param action gpi
33
+ * @param error_transform gt
34
+ */
35
+ const eh = (action, error_transform) => {
36
+ return ($) => {
37
+ action(error_transform($)).__start(() => { });
38
+ };
39
+ };
40
+ exports.eh = eh;
41
+ var gp;
42
+ (function (gp) {
43
+ /**
44
+ *
45
+ * @param action gpi
46
+ * @param query g.q
47
+ * @returns
48
+ */
49
+ gp.action = (action, query) => {
50
+ return {
51
+ __start: (on_finished) => {
52
+ //run the query
53
+ query.__start((query_result) => {
54
+ //run the action
55
+ action(query_result).__start(on_finished);
56
+ });
57
+ }
58
+ };
59
+ };
60
+ })(gp || (exports.gp = gp = {}));
61
+ var gq;
62
+ (function (gq) {
63
+ /**
64
+ *
65
+ * @param query_result qr
66
+ * @returns
67
+ */
68
+ gq.fixed = (query_result) => {
69
+ return {
70
+ __start: (on_finished) => {
71
+ on_finished(query_result);
72
+ }
73
+ };
74
+ };
75
+ /**
76
+ *
77
+ * @param the_query gqi
78
+ * @param parameters g.q
79
+ * @param result_transformation gt
80
+ * @returns
81
+ */
82
+ gq.g = (the_query, parameters, result_transformation) => {
83
+ return {
84
+ __start: (on_finished) => {
85
+ parameters.__start((qr_in) => {
86
+ the_query(qr_in).__start((result) => {
87
+ on_finished(result_transformation(result));
88
+ });
89
+ });
90
+ }
91
+ };
92
+ };
93
+ })(gq || (exports.gq = gq = {}));
94
+ var gt;
95
+ (function (gt) {
96
+ /**
97
+ *
98
+ * @param the_transformation gt
99
+ * @returns
100
+ */
101
+ gt.g = (the_transformation) => {
102
+ return ($) => the_transformation($);
103
+ };
104
+ })(gt || (exports.gt = gt = {}));
105
+ var up;
106
+ (function (up) {
107
+ /**
108
+ *
109
+ * @param action upi
110
+ * @param query u.q
111
+ */
112
+ up.action = (action, query) => {
113
+ return {
114
+ __start: (on_success, on_error) => {
115
+ //run the query
116
+ query.__start((query_result) => {
117
+ //run the action
118
+ action(query_result).__start(on_success, (error) => {
119
+ //transform the error
120
+ on_error(error);
121
+ });
122
+ }, on_error);
123
+ }
124
+ };
125
+ };
126
+ /**
127
+ *
128
+ * @param steps up[]
129
+ * @returns
130
+ */
131
+ up.sequence = (steps) => {
132
+ return {
133
+ __start: (on_success, on_error) => {
134
+ const length = _ei.array_literal(steps).__get_length();
135
+ const runStep = (index) => {
136
+ if (index >= length) {
137
+ on_success();
138
+ return;
139
+ }
140
+ steps[index].__start(() => runStep(index + 1), on_error);
141
+ };
142
+ runStep(0);
143
+ }
144
+ };
145
+ };
146
+ /**
147
+ *
148
+ * @param the_array up[]
149
+ * @param aggregate_exceptions gt
150
+ * @returns
151
+ */
152
+ up.array = (the_array, aggregate_exceptions) => {
153
+ return {
154
+ __start: (on_success, on_error) => {
155
+ const exceptions = [];
156
+ (0, create_asynchronous_processes_monitor_1.create_asynchronous_processes_monitor)((monitor) => {
157
+ the_array.map(($) => {
158
+ monitor['report process started']();
159
+ $.__start(() => {
160
+ monitor['report process finished']();
161
+ }, (e) => {
162
+ exceptions.push(e);
163
+ monitor['report process finished']();
164
+ });
165
+ });
166
+ }, () => {
167
+ if (exceptions.length === 0) {
168
+ on_success();
169
+ }
170
+ else {
171
+ on_error(aggregate_exceptions(_ei.array_literal(exceptions)));
172
+ }
173
+ });
174
+ }
175
+ };
176
+ };
177
+ /**
178
+ *
179
+ * @param the_dictionary dict<up>
180
+ * @param aggregate_exceptions gt
181
+ * @returns
182
+ */
183
+ up.dictionary = (the_dictionary, aggregate_exceptions) => {
184
+ return {
185
+ __start: (on_success, on_error) => {
186
+ const exceptions = {};
187
+ (0, create_asynchronous_processes_monitor_1.create_asynchronous_processes_monitor)((monitor) => {
188
+ the_dictionary.map(($, key) => {
189
+ monitor['report process started']();
190
+ $.__start(() => {
191
+ monitor['report process finished']();
192
+ }, (e) => {
193
+ exceptions[key] = e;
194
+ monitor['report process finished']();
195
+ });
196
+ });
197
+ }, () => {
198
+ if (Object.keys(exceptions).length === 0) {
199
+ on_success();
200
+ }
201
+ else {
202
+ on_error(aggregate_exceptions(_ei.dictionary_literal(exceptions)));
203
+ }
204
+ });
205
+ }
206
+ };
207
+ };
208
+ })(up || (exports.up = up = {}));
209
+ var upi;
210
+ (function (upi) {
211
+ /**
212
+ *
213
+ * @param action gpi
214
+ */
215
+ upi.g = (action) => ($) => {
216
+ return (0, initialize_unguaranteed_procedure_1.__create_unguaranteed_procedure)({
217
+ 'execute': (on_succes, on_error) => {
218
+ action($).__start(on_succes);
219
+ }
220
+ });
221
+ };
222
+ /**
223
+ *
224
+ * @param action upi
225
+ */
226
+ upi.u = (action, error_transform, error_handler) => ($) => {
227
+ return (0, initialize_unguaranteed_procedure_1.__create_unguaranteed_procedure)({
228
+ 'execute': (on_succes, on_error) => {
229
+ action($).__start(on_succes, (error) => {
230
+ if (error_handler !== undefined) {
231
+ error_handler(error);
232
+ }
233
+ on_error(error_transform(error));
234
+ });
235
+ }
236
+ });
237
+ };
238
+ })(upi || (exports.upi = upi = {}));
239
+ var uq;
240
+ (function (uq) {
241
+ /**
242
+ *
243
+ * @param query_result qr
244
+ * @returns
245
+ */
246
+ uq.fixed = (query_result) => {
247
+ return {
248
+ __start: (on_success, on_error) => {
249
+ on_success(query_result);
250
+ }
251
+ };
252
+ };
253
+ /**
254
+ * unguaranteed query
255
+ * @param the_query uqi
256
+ * @param parameters u.q
257
+ * @param result_transformation ut
258
+ * @param error_transform gt
259
+ * @param error_handler eh
260
+ * @returns
261
+ */
262
+ uq.u = (the_query, parameters, result_transformation, error_transform, error_handler) => {
263
+ return {
264
+ __start: (on_success, on_error) => {
265
+ parameters.__start((qr_in) => {
266
+ the_query(qr_in).__start((result) => {
267
+ result_transformation(result).process((x) => on_success(x), on_error);
268
+ }, (error) => {
269
+ if (error_handler !== undefined) {
270
+ error_handler(error);
271
+ }
272
+ on_error(error_transform(error));
273
+ });
274
+ }, on_error);
275
+ }
276
+ };
277
+ };
278
+ /**
279
+ * guaranteed query
280
+ * @param the_query gqi
281
+ * @param parameters u.q
282
+ * @param result_transformation ut
283
+ */
284
+ uq.g = (the_query, parameters, result_transformation) => {
285
+ return {
286
+ __start: (on_success, on_error) => {
287
+ parameters.__start((x) => {
288
+ the_query(x).__start(($) => {
289
+ result_transformation($).process((x) => on_success(x), on_error);
290
+ });
291
+ }, on_error);
292
+ }
293
+ };
294
+ };
295
+ })(uq || (exports.uq = uq = {}));
296
+ var ut;
297
+ (function (ut) {
298
+ /**
299
+ *
300
+ * @param the_transformation ut
301
+ * @param error_transform gt
302
+ * @param error_handler eh
303
+ * @returns
304
+ */
305
+ ut.u = (the_transformation, error_transform, error_handler) => {
306
+ return ($) => {
307
+ const result = the_transformation($);
308
+ return result.map((out) => out, (transformation_error) => {
309
+ //run the error handler
310
+ if (error_handler !== undefined) {
311
+ error_handler(transformation_error);
312
+ }
313
+ return error_transform(transformation_error);
314
+ });
315
+ };
316
+ };
317
+ /**
318
+ *
319
+ * @param the_transformation gt
320
+ */
321
+ ut.g = (the_transformation) => {
322
+ return ($) => {
323
+ return _ei.transformation.successful(the_transformation($));
324
+ };
325
+ };
326
+ })(ut || (exports.ut = ut = {}));
@@ -0,0 +1 @@
1
+ export type Error_Handler<Error> = (error: Error) => void;
@@ -0,0 +1,4 @@
1
+ export type Guaranteed_Procedure_Initializer<Parameters> = ($: Parameters) => Guaranteed_Procedure;
2
+ export interface Guaranteed_Procedure {
3
+ __start: (on_finished: () => void) => void;
4
+ }
@@ -15,3 +15,8 @@ export interface _Guaranteed_Query<T> {
15
15
  __start(on_value: ($: T) => void): void;
16
16
  }
17
17
  export type Guaranteed_Query_Initializer<Parameters, Result> = ($: Parameters) => _Guaranteed_Query<Result>;
18
+ export declare namespace Guaranteed {
19
+ type Query_<Result> = {
20
+ __start: (on_finished: (result: Result) => void) => void;
21
+ };
22
+ }
@@ -1,4 +1,4 @@
1
- export type Unguaranteed_Procedure_Initializer<Params, Error> = ($: Params) => Unguaranteed_Procedure<Error>;
1
+ export type Unguaranteed_Procedure_Initializer<Parameters, Error> = ($: Parameters) => Unguaranteed_Procedure<Error>;
2
2
  export interface Unguaranteed_Procedure<Error> {
3
3
  __start: (on_success: () => void, on_error: (error: Error) => void) => void;
4
4
  }
@@ -8,3 +8,8 @@ export interface _Unguaranteed_Query<T, E> {
8
8
  __start(on_value: ($: T) => void, on_exception: ($: E) => void): void;
9
9
  }
10
10
  export type Unguaranteed_Query_Initializer<Parameters, Result, Error> = ($: Parameters) => _Unguaranteed_Query<Result, Error>;
11
+ export declare namespace Unguaranteed {
12
+ type Query<Result, Error> = {
13
+ __start: (on_success: (result: Result) => void, on_error: (error: Error) => void) => void;
14
+ };
15
+ }
@@ -0,0 +1,2 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "exupery-core-async",
3
- "version": "0.1.41",
3
+ "version": "0.1.43",
4
4
  "license": "Apache-2.0",
5
5
  "author": "Corno",
6
6
  "description": "async types for Exupery",
package/dist/new.d.ts DELETED
@@ -1,102 +0,0 @@
1
- import * as _ei from 'exupery-core-internals';
2
- import * as _et from 'exupery-core-types';
3
- import { Guaranteed_Procedure, Guaranteed_Procedure_Initializer } from "./procedure/Guaranteed_Procedure";
4
- import { Unguaranteed_Procedure_Initializer, Unguaranteed_Procedure } from "./procedure/Unguaranteed_Procedure";
5
- import { Unguaranteed_Query_Initializer } from "./query/Unguaranteed_Query";
6
- import { Guaranteed_Query_Initializer } from "./query/Guaranteed_Query";
7
- export type Error_Handler<Error> = (error: Error) => void;
8
- export declare namespace Unguaranteed {
9
- type Query<Result, Error> = {
10
- __start: (on_success: (result: Result) => void, on_error: (error: Error) => void) => void;
11
- };
12
- }
13
- export declare namespace Guaranteed {
14
- type Query<Result> = {
15
- __start: (on_finished: (result: Result) => void) => void;
16
- };
17
- }
18
- export declare namespace ut {
19
- const u: <In, Out, Error>(the_transformation: _ei.Unguaranteed_Transformation_Without_Parameters<In, Out, Error>) => _ei.Unguaranteed_Transformation_Without_Parameters<In, Out, Error>;
20
- const g: <In, Out, Error>(the_transformation: _ei.Guaranteed_Transformation_Without_Parameters<In, Out>) => _ei.Unguaranteed_Transformation_Without_Parameters<In, Out, Error>;
21
- }
22
- export declare namespace gt {
23
- const g: <In, Out>(the_transformation: _ei.Guaranteed_Transformation_Without_Parameters<In, Out>) => _ei.Guaranteed_Transformation_Without_Parameters<In, Out>;
24
- }
25
- /**
26
- *
27
- * @param action a_my_action
28
- * @param error_transform ($) => ....
29
- */
30
- export declare const eh: <Parameters, Error>(action: Guaranteed_Procedure_Initializer<Parameters>, error_transform: _ei.Guaranteed_Transformation_Without_Parameters<Error, Parameters>) => Error_Handler<Error>;
31
- export declare namespace u {
32
- namespace a {
33
- /**
34
- *
35
- * @param action a_my_action
36
- */
37
- const g: <Parameters, Error>(action: Guaranteed_Procedure_Initializer<Parameters>) => Unguaranteed_Procedure_Initializer<Parameters, Error>;
38
- /**
39
- *
40
- * @param action a_my_action
41
- */
42
- const u: <Parameters, Error, Action_Error>(action: Unguaranteed_Procedure_Initializer<Parameters, Action_Error>, error_transform: _ei.Guaranteed_Transformation_Without_Parameters<Action_Error, Error>, error_handler?: Error_Handler<Action_Error>) => Unguaranteed_Procedure_Initializer<Parameters, Error>;
43
- }
44
- namespace q {
45
- const fixed: <Query_Result, Error>(query_result: Query_Result) => Unguaranteed.Query<Query_Result, Error>;
46
- /**
47
- * unguaranteed query
48
- * @param the_query q_my_query
49
- * @param parameters u.q.*(...)
50
- * @param result_transformation u.t.*()
51
- * @param error_transform ($) => ...
52
- * @param error_handler eh(...)
53
- * @returns
54
- */
55
- const u: <Result_After_Transformation, Error, Parameters, Query_Result, Query_Error>(the_query: Unguaranteed_Query_Initializer<Parameters, Query_Result, Query_Error>, parameters: Unguaranteed.Query<Parameters, Error>, result_transformation: _ei.Unguaranteed_Transformation_Without_Parameters<Query_Result, Result_After_Transformation, Error>, error_transform: _ei.Guaranteed_Transformation_Without_Parameters<Query_Error, Error>, error_handler?: Error_Handler<Query_Error>) => Unguaranteed.Query<Result_After_Transformation, Error>;
56
- /**
57
- * guaranteed query
58
- * @param the_query q_my_query
59
- * @param parameters u.q.*()
60
- * @param result_transformation ($) => ...
61
- */
62
- const g: <Result_After_Transformation, Error, Parameters, Query_Result>(the_query: Guaranteed_Query_Initializer<Parameters, Query_Result>, parameters: Unguaranteed.Query<Parameters, Error>, result_transformation: _ei.Unguaranteed_Transformation_Without_Parameters<Query_Result, Result_After_Transformation, Error>) => Unguaranteed.Query<Result_After_Transformation, Error>;
63
- }
64
- namespace t {
65
- /**
66
- *
67
- * @param the_transformation ($) => _ea.Unguaranteed_Transformation_Result
68
- * @param error_transform ($) => ...
69
- * @param error_handler eh()
70
- * @returns
71
- */
72
- const u: <In, Out, Error, Transformation_Error>(the_transformation: _ei.Unguaranteed_Transformation_Without_Parameters<In, Out, Transformation_Error>, error_transform: _ei.Guaranteed_Transformation_Without_Parameters<Transformation_Error, Error>, error_handler?: Error_Handler<Transformation_Error>) => _ei.Unguaranteed_Transformation_Without_Parameters<In, Out, Error>;
73
- /**
74
- *
75
- * @param the_transformation ($) => ...
76
- */
77
- const g: <In, Out, Error>(the_transformation: _ei.Guaranteed_Transformation_Without_Parameters<In, Out>) => _ei.Unguaranteed_Transformation_Without_Parameters<In, Out, Error>;
78
- }
79
- namespace p {
80
- /**
81
- *
82
- * @param action u.a.*(...)
83
- * @param query u.q.*(...)
84
- */
85
- const action: <Error, Parameters>(action: Unguaranteed_Procedure_Initializer<Parameters, Error>, query: Unguaranteed.Query<Parameters, Error>) => Unguaranteed_Procedure<Error>;
86
- const sequence: <Error>(steps: Unguaranteed_Procedure<Error>[]) => Unguaranteed_Procedure<Error>;
87
- const array: <Error, Element_Error>(the_array: _et.Array<Unguaranteed_Procedure<Element_Error>>, aggregate_exceptions: _ei.Guaranteed_Transformation_Without_Parameters<_et.Array<Element_Error>, Error>) => Unguaranteed_Procedure<Error>;
88
- const dictionary: <Error, Element_Error>(the_dictionary: _et.Dictionary<Unguaranteed_Procedure<Element_Error>>, aggregate_exceptions: _ei.Guaranteed_Transformation_Without_Parameters<_et.Dictionary<Element_Error>, Error>) => Unguaranteed_Procedure<Error>;
89
- }
90
- }
91
- export declare namespace g {
92
- namespace a {
93
- const g: <Parameters>(action: Guaranteed_Procedure_Initializer<Parameters>) => Guaranteed_Procedure_Initializer<Parameters>;
94
- }
95
- namespace q {
96
- const fixed: <Query_Result>(query_result: Query_Result) => Guaranteed.Query<Query_Result>;
97
- const g: <Result_After_Transformation, Parameters, Query_Result>(the_query: Guaranteed_Query_Initializer<Parameters, Query_Result>, parameters: Guaranteed.Query<Parameters>, result_transformation: _ei.Guaranteed_Transformation_Without_Parameters<Query_Result, Result_After_Transformation>) => Guaranteed.Query<Result_After_Transformation>;
98
- }
99
- namespace p {
100
- const action: <Parameters>(action: Guaranteed_Procedure_Initializer<Parameters>, query: Guaranteed.Query<Parameters>) => Guaranteed_Procedure;
101
- }
102
- }
package/dist/new.js DELETED
@@ -1,307 +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.g = exports.u = exports.eh = exports.gt = exports.ut = void 0;
27
- const _ei = __importStar(require("exupery-core-internals"));
28
- const initialize_unguaranteed_procedure_1 = require("./procedure/initialize_unguaranteed_procedure");
29
- const initialize_guaranteed_procedure_1 = require("./procedure/initialize_guaranteed_procedure");
30
- const create_asynchronous_processes_monitor_1 = require("./create_asynchronous_processes_monitor");
31
- var ut;
32
- (function (ut) {
33
- ut.u = (the_transformation) => {
34
- return the_transformation;
35
- };
36
- ut.g = (the_transformation) => {
37
- return ($) => _ei.transformation.successful(the_transformation($));
38
- };
39
- })(ut || (exports.ut = ut = {}));
40
- var gt;
41
- (function (gt) {
42
- gt.g = (the_transformation) => {
43
- return ($) => the_transformation($);
44
- };
45
- })(gt || (exports.gt = gt = {}));
46
- /**
47
- *
48
- * @param action a_my_action
49
- * @param error_transform ($) => ....
50
- */
51
- const eh = (action, error_transform) => {
52
- return ($) => {
53
- action(error_transform($)).__start(() => { });
54
- };
55
- };
56
- exports.eh = eh;
57
- var u;
58
- (function (u_1) {
59
- let a;
60
- (function (a) {
61
- /**
62
- *
63
- * @param action a_my_action
64
- */
65
- a.g = (action) => ($) => {
66
- return (0, initialize_unguaranteed_procedure_1.__create_unguaranteed_procedure)({
67
- 'execute': (on_succes, on_error) => {
68
- action($).__start(on_succes);
69
- }
70
- });
71
- };
72
- /**
73
- *
74
- * @param action a_my_action
75
- */
76
- a.u = (action, error_transform, error_handler) => ($) => {
77
- return (0, initialize_unguaranteed_procedure_1.__create_unguaranteed_procedure)({
78
- 'execute': (on_succes, on_error) => {
79
- action($).__start(on_succes, (error) => {
80
- if (error_handler !== undefined) {
81
- error_handler(error);
82
- }
83
- on_error(error_transform(error));
84
- });
85
- }
86
- });
87
- };
88
- })(a = u_1.a || (u_1.a = {}));
89
- let q;
90
- (function (q) {
91
- q.fixed = (query_result) => {
92
- return {
93
- __start: (on_success, on_error) => {
94
- on_success(query_result);
95
- }
96
- };
97
- };
98
- /**
99
- * unguaranteed query
100
- * @param the_query q_my_query
101
- * @param parameters u.q.*(...)
102
- * @param result_transformation u.t.*()
103
- * @param error_transform ($) => ...
104
- * @param error_handler eh(...)
105
- * @returns
106
- */
107
- q.u = (the_query, parameters, result_transformation, error_transform, error_handler) => {
108
- return {
109
- __start: (on_success, on_error) => {
110
- parameters.__start((qr_in) => {
111
- the_query(qr_in).__start((result) => {
112
- result_transformation(result).process((x) => on_success(x), on_error);
113
- }, (error) => {
114
- if (error_handler !== undefined) {
115
- error_handler(error);
116
- }
117
- on_error(error_transform(error));
118
- });
119
- }, on_error);
120
- }
121
- };
122
- };
123
- /**
124
- * guaranteed query
125
- * @param the_query q_my_query
126
- * @param parameters u.q.*()
127
- * @param result_transformation ($) => ...
128
- */
129
- q.g = (the_query, parameters, result_transformation) => {
130
- return {
131
- __start: (on_success, on_error) => {
132
- parameters.__start((x) => {
133
- the_query(x).__start(($) => {
134
- result_transformation($).process((x) => on_success(x), on_error);
135
- });
136
- }, on_error);
137
- }
138
- };
139
- };
140
- })(q = u_1.q || (u_1.q = {}));
141
- let t;
142
- (function (t) {
143
- /**
144
- *
145
- * @param the_transformation ($) => _ea.Unguaranteed_Transformation_Result
146
- * @param error_transform ($) => ...
147
- * @param error_handler eh()
148
- * @returns
149
- */
150
- t.u = (the_transformation, error_transform, error_handler) => {
151
- return ($) => {
152
- const result = the_transformation($);
153
- return result.map((out) => out, (transformation_error) => {
154
- //run the error handler
155
- if (error_handler !== undefined) {
156
- error_handler(transformation_error);
157
- }
158
- return error_transform(transformation_error);
159
- });
160
- };
161
- };
162
- /**
163
- *
164
- * @param the_transformation ($) => ...
165
- */
166
- t.g = (the_transformation) => {
167
- return ($) => {
168
- return _ei.transformation.successful(the_transformation($));
169
- };
170
- };
171
- })(t = u_1.t || (u_1.t = {}));
172
- let p;
173
- (function (p) {
174
- /**
175
- *
176
- * @param action u.a.*(...)
177
- * @param query u.q.*(...)
178
- */
179
- p.action = (action, query) => {
180
- return {
181
- __start: (on_success, on_error) => {
182
- //run the query
183
- query.__start((query_result) => {
184
- //run the action
185
- action(query_result).__start(on_success, (error) => {
186
- //transform the error
187
- on_error(error);
188
- });
189
- }, on_error);
190
- }
191
- };
192
- };
193
- p.sequence = (steps) => {
194
- return {
195
- __start: (on_success, on_error) => {
196
- const length = _ei.array_literal(steps).__get_length();
197
- const runStep = (index) => {
198
- if (index >= length) {
199
- on_success();
200
- return;
201
- }
202
- steps[index].__start(() => runStep(index + 1), on_error);
203
- };
204
- runStep(0);
205
- }
206
- };
207
- };
208
- p.array = (the_array, aggregate_exceptions) => {
209
- return {
210
- __start: (on_success, on_error) => {
211
- const exceptions = [];
212
- (0, create_asynchronous_processes_monitor_1.create_asynchronous_processes_monitor)((monitor) => {
213
- the_array.map(($) => {
214
- monitor['report process started']();
215
- $.__start(() => {
216
- monitor['report process finished']();
217
- }, (e) => {
218
- exceptions.push(e);
219
- monitor['report process finished']();
220
- });
221
- });
222
- }, () => {
223
- if (exceptions.length === 0) {
224
- on_success();
225
- }
226
- else {
227
- on_error(aggregate_exceptions(_ei.array_literal(exceptions)));
228
- }
229
- });
230
- }
231
- };
232
- };
233
- p.dictionary = (the_dictionary, aggregate_exceptions) => {
234
- return {
235
- __start: (on_success, on_error) => {
236
- const exceptions = {};
237
- (0, create_asynchronous_processes_monitor_1.create_asynchronous_processes_monitor)((monitor) => {
238
- the_dictionary.map(($, key) => {
239
- monitor['report process started']();
240
- $.__start(() => {
241
- monitor['report process finished']();
242
- }, (e) => {
243
- exceptions[key] = e;
244
- monitor['report process finished']();
245
- });
246
- });
247
- }, () => {
248
- if (Object.keys(exceptions).length === 0) {
249
- on_success();
250
- }
251
- else {
252
- on_error(aggregate_exceptions(_ei.dictionary_literal(exceptions)));
253
- }
254
- });
255
- }
256
- };
257
- };
258
- })(p = u_1.p || (u_1.p = {}));
259
- })(u || (exports.u = u = {}));
260
- var g;
261
- (function (g_1) {
262
- let a;
263
- (function (a) {
264
- a.g = (action) => ($) => {
265
- return (0, initialize_guaranteed_procedure_1.__create_guaranted_procedure)({
266
- 'execute': (on_finished) => {
267
- action($).__start(on_finished);
268
- }
269
- });
270
- };
271
- })(a = g_1.a || (g_1.a = {}));
272
- let q;
273
- (function (q) {
274
- q.fixed = (query_result) => {
275
- return {
276
- __start: (on_finished) => {
277
- on_finished(query_result);
278
- }
279
- };
280
- };
281
- q.g = (the_query, parameters, result_transformation) => {
282
- return {
283
- __start: (on_finished) => {
284
- parameters.__start((qr_in) => {
285
- the_query(qr_in).__start((result) => {
286
- on_finished(result_transformation(result));
287
- });
288
- });
289
- }
290
- };
291
- };
292
- })(q = g_1.q || (g_1.q = {}));
293
- let p;
294
- (function (p) {
295
- p.action = (action, query) => {
296
- return {
297
- __start: (on_finished) => {
298
- //run the query
299
- query.__start((query_result) => {
300
- //run the action
301
- action(query_result).__start(on_finished);
302
- });
303
- }
304
- };
305
- };
306
- })(p = g_1.p || (g_1.p = {}));
307
- })(g || (exports.g = g = {}));
@@ -1,4 +0,0 @@
1
- export type Guaranteed_Procedure_Initializer<Params> = ($: Params) => Guaranteed_Procedure;
2
- export interface Guaranteed_Procedure {
3
- __start: (on_finished: () => void) => void;
4
- }
File without changes