clientlinker 13.1.4 → 14.0.0
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/README.md +38 -22
- package/dist/index.d.ts +8 -0
- package/dist/index.js +7 -0
- package/dist/lib/client.d.ts +18 -0
- package/dist/lib/client.js +51 -0
- package/dist/lib/flow.d.ts +11 -0
- package/dist/lib/flow.js +22 -0
- package/dist/lib/linker.d.ts +47 -0
- package/dist/lib/linker.js +157 -0
- package/dist/lib/main.d.ts +9 -0
- package/dist/lib/main.js +35 -0
- package/dist/lib/runtime/client_runtime.d.ts +37 -0
- package/dist/lib/runtime/client_runtime.js +98 -0
- package/dist/lib/runtime/flow_runtime.d.ts +15 -0
- package/dist/lib/runtime/flow_runtime.js +44 -0
- package/dist/lib/runtime/flows_runtime.d.ts +16 -0
- package/dist/lib/runtime/flows_runtime.js +63 -0
- package/dist/lib/utils.d.ts +11 -0
- package/dist/lib/utils.js +23 -0
- package/package.json +13 -9
- package/.istanbul.yml +0 -7
- package/index.js +0 -4
- package/lib/client.js +0 -51
- package/lib/flow.js +0 -19
- package/lib/linker.js +0 -196
- package/lib/main.js +0 -49
- package/lib/runtime/client_runtime.js +0 -122
- package/lib/runtime/flow_runtime.js +0 -42
- package/lib/runtime/flows_runtime.js +0 -83
- package/lib/utils.js +0 -23
|
@@ -1,83 +0,0 @@
|
|
|
1
|
-
const debug = require('debug')('clientlinker:flows_runtime');
|
|
2
|
-
const { FlowRuntime } = require('./flow_runtime');
|
|
3
|
-
const utils = require('../utils');
|
|
4
|
-
|
|
5
|
-
class FlowsRuntime {
|
|
6
|
-
constructor(runtime) {
|
|
7
|
-
this.runtime = runtime;
|
|
8
|
-
this.runned = [];
|
|
9
|
-
this.lastRunner = null;
|
|
10
|
-
}
|
|
11
|
-
|
|
12
|
-
getFlowRuntime(name) {
|
|
13
|
-
const list = this.runned;
|
|
14
|
-
let index = list.length;
|
|
15
|
-
while (index--) {
|
|
16
|
-
if (
|
|
17
|
-
list[index] &&
|
|
18
|
-
list[index].flow &&
|
|
19
|
-
list[index].flow.name == name
|
|
20
|
-
) {
|
|
21
|
-
return list[index];
|
|
22
|
-
}
|
|
23
|
-
}
|
|
24
|
-
}
|
|
25
|
-
|
|
26
|
-
run() {
|
|
27
|
-
const runner = this.nextRunner();
|
|
28
|
-
|
|
29
|
-
if (!runner) {
|
|
30
|
-
const runtime = this.runtime;
|
|
31
|
-
debug('flow out: %s', runtime.action);
|
|
32
|
-
return Promise.reject(utils.newNotFoundError('CLIENT NO FLOWS', runtime));
|
|
33
|
-
}
|
|
34
|
-
|
|
35
|
-
// const client = runtime.client;
|
|
36
|
-
// const clientFlows = client.options.flows;
|
|
37
|
-
// debug(
|
|
38
|
-
// 'run %s.%s flow:%s(%d/%d)',
|
|
39
|
-
// client.name,
|
|
40
|
-
// runtime.method,
|
|
41
|
-
// runner.flow.name,
|
|
42
|
-
// this.runned.length,
|
|
43
|
-
// clientFlows.length
|
|
44
|
-
// );
|
|
45
|
-
|
|
46
|
-
return runner.run();
|
|
47
|
-
}
|
|
48
|
-
|
|
49
|
-
nextRunner() {
|
|
50
|
-
let flow;
|
|
51
|
-
const client = this.runtime.client;
|
|
52
|
-
|
|
53
|
-
for (
|
|
54
|
-
let flowName,
|
|
55
|
-
clientFlows = client.options.flows,
|
|
56
|
-
index = this.runned.length;
|
|
57
|
-
(flowName = clientFlows[index]);
|
|
58
|
-
index++
|
|
59
|
-
) {
|
|
60
|
-
flow = client.linker.flows[flowName];
|
|
61
|
-
if (flow) break;
|
|
62
|
-
this.runned.push(null);
|
|
63
|
-
}
|
|
64
|
-
|
|
65
|
-
if (!flow) return;
|
|
66
|
-
|
|
67
|
-
const runner = new FlowRuntime(flow, this);
|
|
68
|
-
this.runned.push(runner);
|
|
69
|
-
this.lastRunner = runner;
|
|
70
|
-
|
|
71
|
-
return runner;
|
|
72
|
-
}
|
|
73
|
-
|
|
74
|
-
toJSON() {
|
|
75
|
-
return {
|
|
76
|
-
runned: this.runned.map(item => {
|
|
77
|
-
return item.toJSON();
|
|
78
|
-
}),
|
|
79
|
-
};
|
|
80
|
-
}
|
|
81
|
-
}
|
|
82
|
-
|
|
83
|
-
exports.FlowsRuntime = FlowsRuntime;
|
package/lib/utils.js
DELETED
|
@@ -1,23 +0,0 @@
|
|
|
1
|
-
exports.newNotFoundError = newNotFoundError;
|
|
2
|
-
function newNotFoundError(type, runtime) {
|
|
3
|
-
const err = new Error('CLIENTLINKER:NotFound,' + runtime.action);
|
|
4
|
-
err.CLIENTLINKER_TYPE = type;
|
|
5
|
-
return err;
|
|
6
|
-
}
|
|
7
|
-
|
|
8
|
-
exports.parseActionCache = {};
|
|
9
|
-
exports.parseAction = parseAction;
|
|
10
|
-
function parseAction(action) {
|
|
11
|
-
let cache = exports.parseActionCache[action];
|
|
12
|
-
if (!cache) {
|
|
13
|
-
const arr = action.split(/\.|:/);
|
|
14
|
-
const clientName = arr.shift();
|
|
15
|
-
|
|
16
|
-
cache = exports.parseActionCache[action] = {
|
|
17
|
-
clientName: clientName,
|
|
18
|
-
method: arr.join('.')
|
|
19
|
-
};
|
|
20
|
-
}
|
|
21
|
-
|
|
22
|
-
return cache;
|
|
23
|
-
}
|