exupery-core-async 0.1.41 → 0.1.42

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 +83 -0
  9. package/dist/shorthands.js +281 -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,83 @@
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 a_my_action
13
+ * @param error_transform ($) => ....
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
+ const action: <Parameters>(action: Guaranteed_Procedure_Initializer<Parameters>, query: Guaranteed.Query_<Parameters>) => Guaranteed_Procedure;
18
+ }
19
+ export declare namespace gq {
20
+ const fixed: <Query_Result>(query_result: Query_Result) => Guaranteed.Query_<Query_Result>;
21
+ 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>;
22
+ }
23
+ export declare namespace gt {
24
+ const g: <In, Out>(the_transformation: _ei.Guaranteed_Transformation_Without_Parameters<In, Out>) => _ei.Guaranteed_Transformation_Without_Parameters<In, Out>;
25
+ }
26
+ export declare namespace up {
27
+ /**
28
+ *
29
+ * @param action u.a.*(...)
30
+ * @param query u.q.*(...)
31
+ */
32
+ const action: <Error, Parameters>(action: Unguaranteed_Procedure_Initializer<Parameters, Error>, query: Unguaranteed.Query<Parameters, Error>) => Unguaranteed_Procedure<Error>;
33
+ const sequence: <Error>(steps: Unguaranteed_Procedure<Error>[]) => Unguaranteed_Procedure<Error>;
34
+ 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>;
35
+ 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>;
36
+ }
37
+ export declare namespace upi {
38
+ /**
39
+ *
40
+ * @param action a_my_action
41
+ */
42
+ const g: <Parameters, Error>(action: Guaranteed_Procedure_Initializer<Parameters>) => Unguaranteed_Procedure_Initializer<Parameters, Error>;
43
+ /**
44
+ *
45
+ * @param action a_my_action
46
+ */
47
+ 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>;
48
+ }
49
+ export declare namespace uq {
50
+ const fixed: <Query_Result, Error>(query_result: Query_Result) => Unguaranteed.Query<Query_Result, Error>;
51
+ /**
52
+ * unguaranteed query
53
+ * @param the_query q_my_query
54
+ * @param parameters u.q.*(...)
55
+ * @param result_transformation u.t.*()
56
+ * @param error_transform ($) => ...
57
+ * @param error_handler eh(...)
58
+ * @returns
59
+ */
60
+ 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>;
61
+ /**
62
+ * guaranteed query
63
+ * @param the_query q_my_query
64
+ * @param parameters u.q.*()
65
+ * @param result_transformation ($) => ...
66
+ */
67
+ 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>;
68
+ }
69
+ export declare namespace ut {
70
+ /**
71
+ *
72
+ * @param the_transformation ($) => _ea.Unguaranteed_Transformation_Result
73
+ * @param error_transform ($) => ...
74
+ * @param error_handler eh()
75
+ * @returns
76
+ */
77
+ 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>;
78
+ /**
79
+ *
80
+ * @param the_transformation ($) => ...
81
+ */
82
+ const g: <In, Out, Error>(the_transformation: _ei.Guaranteed_Transformation_Without_Parameters<In, Out>) => _ei.Unguaranteed_Transformation_Without_Parameters<In, Out, Error>;
83
+ }
@@ -0,0 +1,281 @@
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 a_my_action
33
+ * @param error_transform ($) => ....
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
+ gp.action = (action, query) => {
44
+ return {
45
+ __start: (on_finished) => {
46
+ //run the query
47
+ query.__start((query_result) => {
48
+ //run the action
49
+ action(query_result).__start(on_finished);
50
+ });
51
+ }
52
+ };
53
+ };
54
+ })(gp || (exports.gp = gp = {}));
55
+ var gq;
56
+ (function (gq) {
57
+ gq.fixed = (query_result) => {
58
+ return {
59
+ __start: (on_finished) => {
60
+ on_finished(query_result);
61
+ }
62
+ };
63
+ };
64
+ gq.g = (the_query, parameters, result_transformation) => {
65
+ return {
66
+ __start: (on_finished) => {
67
+ parameters.__start((qr_in) => {
68
+ the_query(qr_in).__start((result) => {
69
+ on_finished(result_transformation(result));
70
+ });
71
+ });
72
+ }
73
+ };
74
+ };
75
+ })(gq || (exports.gq = gq = {}));
76
+ var gt;
77
+ (function (gt) {
78
+ gt.g = (the_transformation) => {
79
+ return ($) => the_transformation($);
80
+ };
81
+ })(gt || (exports.gt = gt = {}));
82
+ var up;
83
+ (function (up) {
84
+ /**
85
+ *
86
+ * @param action u.a.*(...)
87
+ * @param query u.q.*(...)
88
+ */
89
+ up.action = (action, query) => {
90
+ return {
91
+ __start: (on_success, on_error) => {
92
+ //run the query
93
+ query.__start((query_result) => {
94
+ //run the action
95
+ action(query_result).__start(on_success, (error) => {
96
+ //transform the error
97
+ on_error(error);
98
+ });
99
+ }, on_error);
100
+ }
101
+ };
102
+ };
103
+ up.sequence = (steps) => {
104
+ return {
105
+ __start: (on_success, on_error) => {
106
+ const length = _ei.array_literal(steps).__get_length();
107
+ const runStep = (index) => {
108
+ if (index >= length) {
109
+ on_success();
110
+ return;
111
+ }
112
+ steps[index].__start(() => runStep(index + 1), on_error);
113
+ };
114
+ runStep(0);
115
+ }
116
+ };
117
+ };
118
+ up.array = (the_array, aggregate_exceptions) => {
119
+ return {
120
+ __start: (on_success, on_error) => {
121
+ const exceptions = [];
122
+ (0, create_asynchronous_processes_monitor_1.create_asynchronous_processes_monitor)((monitor) => {
123
+ the_array.map(($) => {
124
+ monitor['report process started']();
125
+ $.__start(() => {
126
+ monitor['report process finished']();
127
+ }, (e) => {
128
+ exceptions.push(e);
129
+ monitor['report process finished']();
130
+ });
131
+ });
132
+ }, () => {
133
+ if (exceptions.length === 0) {
134
+ on_success();
135
+ }
136
+ else {
137
+ on_error(aggregate_exceptions(_ei.array_literal(exceptions)));
138
+ }
139
+ });
140
+ }
141
+ };
142
+ };
143
+ up.dictionary = (the_dictionary, aggregate_exceptions) => {
144
+ return {
145
+ __start: (on_success, on_error) => {
146
+ const exceptions = {};
147
+ (0, create_asynchronous_processes_monitor_1.create_asynchronous_processes_monitor)((monitor) => {
148
+ the_dictionary.map(($, key) => {
149
+ monitor['report process started']();
150
+ $.__start(() => {
151
+ monitor['report process finished']();
152
+ }, (e) => {
153
+ exceptions[key] = e;
154
+ monitor['report process finished']();
155
+ });
156
+ });
157
+ }, () => {
158
+ if (Object.keys(exceptions).length === 0) {
159
+ on_success();
160
+ }
161
+ else {
162
+ on_error(aggregate_exceptions(_ei.dictionary_literal(exceptions)));
163
+ }
164
+ });
165
+ }
166
+ };
167
+ };
168
+ })(up || (exports.up = up = {}));
169
+ var upi;
170
+ (function (upi) {
171
+ /**
172
+ *
173
+ * @param action a_my_action
174
+ */
175
+ upi.g = (action) => ($) => {
176
+ return (0, initialize_unguaranteed_procedure_1.__create_unguaranteed_procedure)({
177
+ 'execute': (on_succes, on_error) => {
178
+ action($).__start(on_succes);
179
+ }
180
+ });
181
+ };
182
+ /**
183
+ *
184
+ * @param action a_my_action
185
+ */
186
+ upi.u = (action, error_transform, error_handler) => ($) => {
187
+ return (0, initialize_unguaranteed_procedure_1.__create_unguaranteed_procedure)({
188
+ 'execute': (on_succes, on_error) => {
189
+ action($).__start(on_succes, (error) => {
190
+ if (error_handler !== undefined) {
191
+ error_handler(error);
192
+ }
193
+ on_error(error_transform(error));
194
+ });
195
+ }
196
+ });
197
+ };
198
+ })(upi || (exports.upi = upi = {}));
199
+ var uq;
200
+ (function (uq) {
201
+ uq.fixed = (query_result) => {
202
+ return {
203
+ __start: (on_success, on_error) => {
204
+ on_success(query_result);
205
+ }
206
+ };
207
+ };
208
+ /**
209
+ * unguaranteed query
210
+ * @param the_query q_my_query
211
+ * @param parameters u.q.*(...)
212
+ * @param result_transformation u.t.*()
213
+ * @param error_transform ($) => ...
214
+ * @param error_handler eh(...)
215
+ * @returns
216
+ */
217
+ uq.u = (the_query, parameters, result_transformation, error_transform, error_handler) => {
218
+ return {
219
+ __start: (on_success, on_error) => {
220
+ parameters.__start((qr_in) => {
221
+ the_query(qr_in).__start((result) => {
222
+ result_transformation(result).process((x) => on_success(x), on_error);
223
+ }, (error) => {
224
+ if (error_handler !== undefined) {
225
+ error_handler(error);
226
+ }
227
+ on_error(error_transform(error));
228
+ });
229
+ }, on_error);
230
+ }
231
+ };
232
+ };
233
+ /**
234
+ * guaranteed query
235
+ * @param the_query q_my_query
236
+ * @param parameters u.q.*()
237
+ * @param result_transformation ($) => ...
238
+ */
239
+ uq.g = (the_query, parameters, result_transformation) => {
240
+ return {
241
+ __start: (on_success, on_error) => {
242
+ parameters.__start((x) => {
243
+ the_query(x).__start(($) => {
244
+ result_transformation($).process((x) => on_success(x), on_error);
245
+ });
246
+ }, on_error);
247
+ }
248
+ };
249
+ };
250
+ })(uq || (exports.uq = uq = {}));
251
+ var ut;
252
+ (function (ut) {
253
+ /**
254
+ *
255
+ * @param the_transformation ($) => _ea.Unguaranteed_Transformation_Result
256
+ * @param error_transform ($) => ...
257
+ * @param error_handler eh()
258
+ * @returns
259
+ */
260
+ ut.u = (the_transformation, error_transform, error_handler) => {
261
+ return ($) => {
262
+ const result = the_transformation($);
263
+ return result.map((out) => out, (transformation_error) => {
264
+ //run the error handler
265
+ if (error_handler !== undefined) {
266
+ error_handler(transformation_error);
267
+ }
268
+ return error_transform(transformation_error);
269
+ });
270
+ };
271
+ };
272
+ /**
273
+ *
274
+ * @param the_transformation ($) => ...
275
+ */
276
+ ut.g = (the_transformation) => {
277
+ return ($) => {
278
+ return _ei.transformation.successful(the_transformation($));
279
+ };
280
+ };
281
+ })(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.42",
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