exupery-core-async 0.3.6 → 0.3.8
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/index.d.ts +11 -0
- package/dist/index.js +13 -0
- package/dist/procedure/assert_async.d.ts +3 -0
- package/dist/procedure/assert_async.js +23 -0
- package/dist/procedure/assert_sync.d.ts +3 -0
- package/dist/procedure/assert_sync.js +18 -0
- package/dist/procedure/conditional_async.d.ts +4 -0
- package/dist/procedure/conditional_async.js +23 -0
- package/dist/procedure/conditional_multiple.d.ts +4 -0
- package/dist/procedure/conditional_multiple.js +32 -0
- package/dist/procedure/conditional_sync.d.ts +2 -0
- package/dist/procedure/conditional_sync.js +17 -0
- package/dist/procedure/sequence.d.ts +6 -0
- package/dist/procedure/sequence.js +61 -0
- package/dist/procedure/three_steps.d.ts +3 -0
- package/dist/procedure/three_steps.js +22 -0
- package/dist/procedure/two_steps.d.ts +3 -0
- package/dist/procedure/two_steps.js +18 -0
- package/dist/procedure/unguaranteed_procedure_dictionary.d.ts +2 -0
- package/dist/procedure/unguaranteed_procedure_dictionary.js +58 -0
- package/dist/query/transform_query.d.ts +3 -0
- package/dist/query/transform_query.js +16 -0
- package/dist/query/unguaranteed_query_dictionary.d.ts +3 -0
- package/dist/query/unguaranteed_query_dictionary.js +60 -0
- package/dist/shorthands.js +10 -10
- package/package.json +1 -1
package/dist/index.d.ts
CHANGED
|
@@ -7,6 +7,17 @@ export * from "./algorithms/query/create_unguaranteed_query";
|
|
|
7
7
|
export * from "./algorithms/procedure/initialize_guaranteed_procedure";
|
|
8
8
|
export * from "./algorithms/procedure/initialize_unguaranteed_procedure";
|
|
9
9
|
export * from "./shorthands";
|
|
10
|
+
export * from "./procedure/assert_async";
|
|
11
|
+
export * from "./procedure/assert_sync";
|
|
12
|
+
export * from "./procedure/conditional_async";
|
|
13
|
+
export * from "./procedure/conditional_multiple";
|
|
14
|
+
export * from "./procedure/conditional_sync";
|
|
15
|
+
export * from "./procedure/sequence";
|
|
16
|
+
export * from "./procedure/three_steps";
|
|
17
|
+
export * from "./procedure/two_steps";
|
|
18
|
+
export * from "./procedure/unguaranteed_procedure_dictionary";
|
|
19
|
+
export * from "./query/transform_query";
|
|
20
|
+
export * from "./query/unguaranteed_query_dictionary";
|
|
10
21
|
export declare const query: {
|
|
11
22
|
guaranteed: {
|
|
12
23
|
'create result': <T>($: T) => _et.Guaranteed_Query_Promise<T>;
|
package/dist/index.js
CHANGED
|
@@ -25,6 +25,19 @@ __exportStar(require("./algorithms/query/create_unguaranteed_query"), exports);
|
|
|
25
25
|
__exportStar(require("./algorithms/procedure/initialize_guaranteed_procedure"), exports);
|
|
26
26
|
__exportStar(require("./algorithms/procedure/initialize_unguaranteed_procedure"), exports);
|
|
27
27
|
__exportStar(require("./shorthands"), exports);
|
|
28
|
+
// procedure exports
|
|
29
|
+
__exportStar(require("./procedure/assert_async"), exports);
|
|
30
|
+
__exportStar(require("./procedure/assert_sync"), exports);
|
|
31
|
+
__exportStar(require("./procedure/conditional_async"), exports);
|
|
32
|
+
__exportStar(require("./procedure/conditional_multiple"), exports);
|
|
33
|
+
__exportStar(require("./procedure/conditional_sync"), exports);
|
|
34
|
+
__exportStar(require("./procedure/sequence"), exports);
|
|
35
|
+
__exportStar(require("./procedure/three_steps"), exports);
|
|
36
|
+
__exportStar(require("./procedure/two_steps"), exports);
|
|
37
|
+
__exportStar(require("./procedure/unguaranteed_procedure_dictionary"), exports);
|
|
38
|
+
// query exports
|
|
39
|
+
__exportStar(require("./query/transform_query"), exports);
|
|
40
|
+
__exportStar(require("./query/unguaranteed_query_dictionary"), exports);
|
|
28
41
|
const create_guaranteed_query_1 = require("./algorithms/query/create_guaranteed_query");
|
|
29
42
|
const create_unguaranteed_query_1 = require("./algorithms/query/create_unguaranteed_query");
|
|
30
43
|
exports.query = {
|
|
@@ -0,0 +1,3 @@
|
|
|
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.Unguaranteed_Query_Promise<boolean, Assertion_Error>, procedure: _et.Unguaranteed_Procedure_Promise<Procedure_Error>) => _et.Unguaranteed_Procedure_Promise<Assert_Async_Error<Assertion_Error, Procedure_Error>>;
|
|
@@ -0,0 +1,23 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.assert_async = void 0;
|
|
4
|
+
const initialize_unguaranteed_procedure_1 = require("../algorithms/procedure/initialize_unguaranteed_procedure");
|
|
5
|
+
const assert_async = (assertion, procedure) => {
|
|
6
|
+
return (0, initialize_unguaranteed_procedure_1.__create_unguaranteed_procedure)({
|
|
7
|
+
'execute': (on_success, on_exception) => {
|
|
8
|
+
assertion.__start(($) => {
|
|
9
|
+
if ($) {
|
|
10
|
+
procedure.__start(on_success, ($) => {
|
|
11
|
+
on_exception(['procedure error', $]);
|
|
12
|
+
});
|
|
13
|
+
}
|
|
14
|
+
else {
|
|
15
|
+
on_exception(['assertion failed', null]);
|
|
16
|
+
}
|
|
17
|
+
}, ($) => {
|
|
18
|
+
on_exception(['assertion error', $]);
|
|
19
|
+
});
|
|
20
|
+
}
|
|
21
|
+
});
|
|
22
|
+
};
|
|
23
|
+
exports.assert_async = assert_async;
|
|
@@ -0,0 +1,3 @@
|
|
|
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.Unguaranteed_Procedure_Promise<Procedure_Error>) => _et.Unguaranteed_Procedure_Promise<Assert_Sync_Error<Procedure_Error>>;
|
|
@@ -0,0 +1,18 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.assert_sync = void 0;
|
|
4
|
+
const initialize_unguaranteed_procedure_1 = require("../algorithms/procedure/initialize_unguaranteed_procedure");
|
|
5
|
+
const assert_sync = (assertion, procedure) => {
|
|
6
|
+
return (0, initialize_unguaranteed_procedure_1.__create_unguaranteed_procedure)({
|
|
7
|
+
'execute': (on_success, on_exception) => {
|
|
8
|
+
if (!assertion) {
|
|
9
|
+
on_exception(['assertion failed', null]);
|
|
10
|
+
return;
|
|
11
|
+
}
|
|
12
|
+
procedure.__start(on_success, ($) => {
|
|
13
|
+
on_exception(['procedure error', $]);
|
|
14
|
+
});
|
|
15
|
+
}
|
|
16
|
+
});
|
|
17
|
+
};
|
|
18
|
+
exports.assert_sync = assert_sync;
|
|
@@ -0,0 +1,4 @@
|
|
|
1
|
+
import * as _et from 'exupery-core-types';
|
|
2
|
+
import { Basic_Unguaranteed_Query_Promise } from '../types/Basic_Unguaranteed_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_Unguaranteed_Query_Promise<boolean, Precondition_Error>, procedure: _et.Unguaranteed_Procedure_Promise<Procedure_Error>) => _et.Unguaranteed_Procedure_Promise<Conditional_Async_Error<Precondition_Error, Procedure_Error>>;
|
|
@@ -0,0 +1,23 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.conditional_async = void 0;
|
|
4
|
+
const initialize_unguaranteed_procedure_1 = require("../algorithms/procedure/initialize_unguaranteed_procedure");
|
|
5
|
+
const conditional_async = (precondition, procedure) => {
|
|
6
|
+
return (0, initialize_unguaranteed_procedure_1.__create_unguaranteed_procedure)({
|
|
7
|
+
'execute': (on_success, on_exception) => {
|
|
8
|
+
precondition.__start(($) => {
|
|
9
|
+
if ($) {
|
|
10
|
+
procedure.__start(on_success, (e) => {
|
|
11
|
+
on_exception(['procedure', e]);
|
|
12
|
+
});
|
|
13
|
+
}
|
|
14
|
+
else {
|
|
15
|
+
on_success();
|
|
16
|
+
}
|
|
17
|
+
}, ($) => {
|
|
18
|
+
on_exception(['precondition', $]);
|
|
19
|
+
});
|
|
20
|
+
}
|
|
21
|
+
});
|
|
22
|
+
};
|
|
23
|
+
exports.conditional_async = conditional_async;
|
|
@@ -0,0 +1,4 @@
|
|
|
1
|
+
import * as _et from 'exupery-core-types';
|
|
2
|
+
import { Basic_Unguaranteed_Query_Promise } from '../types/Basic_Unguaranteed_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_Unguaranteed_Query_Promise<boolean, Precondition_Error>>, procedure: _et.Unguaranteed_Procedure_Promise<Procedure_Error>) => _et.Unguaranteed_Procedure_Promise<Conditional_Multiple_Error<Precondition_Error, Procedure_Error>>;
|
|
@@ -0,0 +1,32 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.conditional_multiple = void 0;
|
|
4
|
+
const unguaranteed_query_dictionary_1 = require("../query/unguaranteed_query_dictionary");
|
|
5
|
+
const initialize_unguaranteed_procedure_1 = require("../algorithms/procedure/initialize_unguaranteed_procedure");
|
|
6
|
+
const conditional_multiple = (preconditions, procedure) => {
|
|
7
|
+
return (0, initialize_unguaranteed_procedure_1.__create_unguaranteed_procedure)({
|
|
8
|
+
'execute': (on_success, on_exception) => {
|
|
9
|
+
(0, unguaranteed_query_dictionary_1.unguaranteed_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_exception(['procedure', e]);
|
|
20
|
+
});
|
|
21
|
+
}
|
|
22
|
+
else {
|
|
23
|
+
//the preconditions failed, so we are *successfully* skipping the procedure
|
|
24
|
+
on_success();
|
|
25
|
+
}
|
|
26
|
+
}, ($) => {
|
|
27
|
+
on_exception(['preconditions', $]);
|
|
28
|
+
});
|
|
29
|
+
}
|
|
30
|
+
});
|
|
31
|
+
};
|
|
32
|
+
exports.conditional_multiple = conditional_multiple;
|
|
@@ -0,0 +1,17 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.conditional_sync = void 0;
|
|
4
|
+
const initialize_unguaranteed_procedure_1 = require("../algorithms/procedure/initialize_unguaranteed_procedure");
|
|
5
|
+
const conditional_sync = (precondition, procedure) => {
|
|
6
|
+
return (0, initialize_unguaranteed_procedure_1.__create_unguaranteed_procedure)({
|
|
7
|
+
'execute': (on_success, on_exception) => {
|
|
8
|
+
if (precondition) {
|
|
9
|
+
procedure.__start(on_success, on_exception);
|
|
10
|
+
}
|
|
11
|
+
else {
|
|
12
|
+
on_success();
|
|
13
|
+
}
|
|
14
|
+
}
|
|
15
|
+
});
|
|
16
|
+
};
|
|
17
|
+
exports.conditional_sync = conditional_sync;
|
|
@@ -0,0 +1,6 @@
|
|
|
1
|
+
import * as _et from 'exupery-core-types';
|
|
2
|
+
export type Sequence_Error<Err> = {
|
|
3
|
+
'error': Err;
|
|
4
|
+
'step': string;
|
|
5
|
+
};
|
|
6
|
+
export declare const sequence: <Err>(steps: _et.Dictionary<_et.Unguaranteed_Procedure_Promise<Err>>) => _et.Unguaranteed_Procedure_Promise<Sequence_Error<Err>>;
|
|
@@ -0,0 +1,61 @@
|
|
|
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.sequence = void 0;
|
|
27
|
+
const _ei = __importStar(require("exupery-core-internals"));
|
|
28
|
+
const initialize_unguaranteed_procedure_1 = require("../algorithms/procedure/initialize_unguaranteed_procedure");
|
|
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 sequence = (steps) => {
|
|
37
|
+
return (0, initialize_unguaranteed_procedure_1.__create_unguaranteed_procedure)({
|
|
38
|
+
'execute': (on_success, on_exception) => {
|
|
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_exception({
|
|
49
|
+
'error': $,
|
|
50
|
+
'step': key,
|
|
51
|
+
});
|
|
52
|
+
});
|
|
53
|
+
}, () => {
|
|
54
|
+
on_success();
|
|
55
|
+
});
|
|
56
|
+
};
|
|
57
|
+
do_next();
|
|
58
|
+
}
|
|
59
|
+
});
|
|
60
|
+
};
|
|
61
|
+
exports.sequence = sequence;
|
|
@@ -0,0 +1,3 @@
|
|
|
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.Unguaranteed_Procedure_Promise<Step_1_Error>, step_2: _et.Unguaranteed_Procedure_Promise<Step_2_Error>, step_3: _et.Unguaranteed_Procedure_Promise<Step_3_Error>) => _et.Unguaranteed_Procedure_Promise<Three_Steps_Error<Step_1_Error, Step_2_Error, Step_3_Error>>;
|
|
@@ -0,0 +1,22 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.three_steps = void 0;
|
|
4
|
+
const initialize_unguaranteed_procedure_1 = require("../algorithms/procedure/initialize_unguaranteed_procedure");
|
|
5
|
+
const three_steps = (step_1, step_2, step_3) => {
|
|
6
|
+
return (0, initialize_unguaranteed_procedure_1.__create_unguaranteed_procedure)({
|
|
7
|
+
'execute': (on_success, on_exception) => {
|
|
8
|
+
step_1.__start(() => {
|
|
9
|
+
step_2.__start(() => {
|
|
10
|
+
step_3.__start(on_success, (error) => {
|
|
11
|
+
on_exception(['step3', error]);
|
|
12
|
+
});
|
|
13
|
+
}, (error) => {
|
|
14
|
+
on_exception(['step2', error]);
|
|
15
|
+
});
|
|
16
|
+
}, (error) => {
|
|
17
|
+
on_exception(['step1', error]);
|
|
18
|
+
});
|
|
19
|
+
}
|
|
20
|
+
});
|
|
21
|
+
};
|
|
22
|
+
exports.three_steps = three_steps;
|
|
@@ -0,0 +1,3 @@
|
|
|
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.Unguaranteed_Procedure_Promise<Step_1_Error>, step_2: _et.Unguaranteed_Procedure_Promise<Step_2_Error>) => _et.Unguaranteed_Procedure_Promise<Two_Steps_Error<Step_1_Error, Step_2_Error>>;
|
|
@@ -0,0 +1,18 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.two_steps = void 0;
|
|
4
|
+
const initialize_unguaranteed_procedure_1 = require("../algorithms/procedure/initialize_unguaranteed_procedure");
|
|
5
|
+
const two_steps = (step_1, step_2) => {
|
|
6
|
+
return (0, initialize_unguaranteed_procedure_1.__create_unguaranteed_procedure)({
|
|
7
|
+
'execute': (on_success, on_exception) => {
|
|
8
|
+
step_1.__start(() => {
|
|
9
|
+
step_2.__start(on_success, (error) => {
|
|
10
|
+
on_exception(['step2', error]);
|
|
11
|
+
});
|
|
12
|
+
}, (error) => {
|
|
13
|
+
on_exception(['step1', error]);
|
|
14
|
+
});
|
|
15
|
+
}
|
|
16
|
+
});
|
|
17
|
+
};
|
|
18
|
+
exports.two_steps = two_steps;
|
|
@@ -0,0 +1,58 @@
|
|
|
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.unguaranteed_procedure_dictionary = void 0;
|
|
27
|
+
const _ei = __importStar(require("exupery-core-internals"));
|
|
28
|
+
const initialize_unguaranteed_procedure_1 = require("../algorithms/procedure/initialize_unguaranteed_procedure");
|
|
29
|
+
const unguaranteed_procedure_dictionary = ($) => {
|
|
30
|
+
return (0, initialize_unguaranteed_procedure_1.__create_unguaranteed_procedure)({
|
|
31
|
+
'execute': (on_success, on_exception) => {
|
|
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_exception(_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.unguaranteed_procedure_dictionary = unguaranteed_procedure_dictionary;
|
|
@@ -0,0 +1,3 @@
|
|
|
1
|
+
import * as _et from 'exupery-core-types';
|
|
2
|
+
import { Basic_Unguaranteed_Query_Promise } from '../types/Basic_Unguaranteed_Query';
|
|
3
|
+
export declare const transform_query: <In, Out, Error>(query: Basic_Unguaranteed_Query_Promise<In, Error>, transform: ($: In) => Out) => _et.Unguaranteed_Query_Promise<Out, Error>;
|
|
@@ -0,0 +1,16 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.transform_query = void 0;
|
|
4
|
+
const create_unguaranteed_query_1 = require("../algorithms/query/create_unguaranteed_query");
|
|
5
|
+
const transform_query = (query, transform) => {
|
|
6
|
+
return (0, create_unguaranteed_query_1.__create_unguaranteed_query)({
|
|
7
|
+
'execute': (on_success, on_exception) => {
|
|
8
|
+
query.__start(($) => {
|
|
9
|
+
on_success(transform($));
|
|
10
|
+
}, (e) => {
|
|
11
|
+
on_exception(e);
|
|
12
|
+
});
|
|
13
|
+
}
|
|
14
|
+
});
|
|
15
|
+
};
|
|
16
|
+
exports.transform_query = transform_query;
|
|
@@ -0,0 +1,3 @@
|
|
|
1
|
+
import * as _et from 'exupery-core-types';
|
|
2
|
+
import { Basic_Unguaranteed_Query_Promise } from '../types/Basic_Unguaranteed_Query';
|
|
3
|
+
export declare const unguaranteed_query_dictionary: <Result, Error>($: _et.Dictionary<Basic_Unguaranteed_Query_Promise<Result, Error>>) => _et.Unguaranteed_Query_Promise<_et.Dictionary<Result>, _et.Dictionary<Error>>;
|
|
@@ -0,0 +1,60 @@
|
|
|
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.unguaranteed_query_dictionary = void 0;
|
|
27
|
+
const _ei = __importStar(require("exupery-core-internals"));
|
|
28
|
+
const create_unguaranteed_query_1 = require("../algorithms/query/create_unguaranteed_query");
|
|
29
|
+
const unguaranteed_query_dictionary = ($) => {
|
|
30
|
+
return (0, create_unguaranteed_query_1.__create_unguaranteed_query)({
|
|
31
|
+
'execute': (on_success, on_exception) => {
|
|
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_exception(_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.unguaranteed_query_dictionary = unguaranteed_query_dictionary;
|
package/dist/shorthands.js
CHANGED
|
@@ -34,7 +34,7 @@ const create_asynchronous_processes_monitor_1 = require("./create_asynchronous_p
|
|
|
34
34
|
*/
|
|
35
35
|
const eh = (action, error_transform, resources) => {
|
|
36
36
|
return ($) => {
|
|
37
|
-
action(error_transform($)
|
|
37
|
+
action(resources)(error_transform($)).__start(() => { });
|
|
38
38
|
};
|
|
39
39
|
};
|
|
40
40
|
exports.eh = eh;
|
|
@@ -52,7 +52,7 @@ var gp;
|
|
|
52
52
|
//run the query
|
|
53
53
|
query.__start((query_result) => {
|
|
54
54
|
//run the action
|
|
55
|
-
action(
|
|
55
|
+
action($r)(query_result).__start(on_finished);
|
|
56
56
|
});
|
|
57
57
|
}
|
|
58
58
|
};
|
|
@@ -83,7 +83,7 @@ var gq;
|
|
|
83
83
|
return {
|
|
84
84
|
__start: (on_finished) => {
|
|
85
85
|
parameters.__start((qr_in) => {
|
|
86
|
-
the_query(
|
|
86
|
+
the_query(resources)(qr_in).__start((result) => {
|
|
87
87
|
on_finished(result_transformation(result));
|
|
88
88
|
});
|
|
89
89
|
});
|
|
@@ -115,7 +115,7 @@ var up;
|
|
|
115
115
|
//run the query
|
|
116
116
|
query.__start((query_result) => {
|
|
117
117
|
//run the action
|
|
118
|
-
action(
|
|
118
|
+
action(resources)(query_result).__start(on_success, (error) => {
|
|
119
119
|
//transform the error
|
|
120
120
|
on_error(error);
|
|
121
121
|
});
|
|
@@ -212,10 +212,10 @@ var upi;
|
|
|
212
212
|
*
|
|
213
213
|
* @param action gpi
|
|
214
214
|
*/
|
|
215
|
-
upi.g = (action, $r) => ($) => {
|
|
215
|
+
upi.g = (action, $r) => () => ($) => {
|
|
216
216
|
return (0, initialize_unguaranteed_procedure_1.__create_unguaranteed_procedure)({
|
|
217
217
|
'execute': (on_succes, on_error) => {
|
|
218
|
-
action(
|
|
218
|
+
action($r)($).__start(on_succes);
|
|
219
219
|
}
|
|
220
220
|
});
|
|
221
221
|
};
|
|
@@ -223,10 +223,10 @@ var upi;
|
|
|
223
223
|
*
|
|
224
224
|
* @param action upi
|
|
225
225
|
*/
|
|
226
|
-
upi.u = (action, error_transform, error_handler) => (
|
|
226
|
+
upi.u = (action, error_transform, error_handler) => ($r) => ($) => {
|
|
227
227
|
return (0, initialize_unguaranteed_procedure_1.__create_unguaranteed_procedure)({
|
|
228
228
|
'execute': (on_succes, on_error) => {
|
|
229
|
-
action(
|
|
229
|
+
action($r)($).__start(on_succes, (error) => {
|
|
230
230
|
if (error_handler !== undefined) {
|
|
231
231
|
error_handler(error);
|
|
232
232
|
}
|
|
@@ -263,7 +263,7 @@ var uq;
|
|
|
263
263
|
return {
|
|
264
264
|
__start: (on_success, on_error) => {
|
|
265
265
|
parameters.__start((qr_in) => {
|
|
266
|
-
the_query(
|
|
266
|
+
the_query(resources)(qr_in).__start((result) => {
|
|
267
267
|
result_refinement(result).process((x) => on_success(x), on_error);
|
|
268
268
|
}, (error) => {
|
|
269
269
|
if (error_handler !== undefined) {
|
|
@@ -285,7 +285,7 @@ var uq;
|
|
|
285
285
|
return {
|
|
286
286
|
__start: (on_success, on_error) => {
|
|
287
287
|
parameters.__start((x) => {
|
|
288
|
-
the_query(
|
|
288
|
+
the_query(resources)(x).__start(($) => {
|
|
289
289
|
result_refinement($).process((x) => on_success(x), on_error);
|
|
290
290
|
});
|
|
291
291
|
}, on_error);
|