@cuecue/app 0.0.27 → 0.0.28
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.js +37 -22
- package/package.json +3 -3
package/dist/index.js
CHANGED
|
@@ -1,27 +1,40 @@
|
|
|
1
|
-
|
|
2
|
-
|
|
3
|
-
|
|
4
|
-
|
|
5
|
-
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
|
|
1
|
+
'use strict';
|
|
2
|
+
|
|
3
|
+
Object.defineProperty(exports, '__esModule', { value: true });
|
|
4
|
+
|
|
5
|
+
var StateMachine = require('javascript-state-machine');
|
|
6
|
+
var EventEmitter = require('wolfy87-eventemitter');
|
|
7
|
+
var createDebug = require('debug');
|
|
8
|
+
var dayjs = require('dayjs');
|
|
9
|
+
var uuid = require('uuid');
|
|
10
|
+
var matches = require('lodash/matches');
|
|
11
|
+
var isObject = require('lodash/isObject');
|
|
12
|
+
|
|
13
|
+
function _interopDefaultLegacy (e) { return e && typeof e === 'object' && 'default' in e ? e : { 'default': e }; }
|
|
14
|
+
|
|
15
|
+
var StateMachine__default = /*#__PURE__*/_interopDefaultLegacy(StateMachine);
|
|
16
|
+
var EventEmitter__default = /*#__PURE__*/_interopDefaultLegacy(EventEmitter);
|
|
17
|
+
var createDebug__default = /*#__PURE__*/_interopDefaultLegacy(createDebug);
|
|
18
|
+
var dayjs__default = /*#__PURE__*/_interopDefaultLegacy(dayjs);
|
|
19
|
+
var matches__default = /*#__PURE__*/_interopDefaultLegacy(matches);
|
|
20
|
+
var isObject__default = /*#__PURE__*/_interopDefaultLegacy(isObject);
|
|
21
|
+
|
|
22
|
+
class MemoryStore extends EventEmitter__default["default"] {
|
|
10
23
|
constructor(data = {}) {
|
|
11
24
|
super();
|
|
12
25
|
this.data = data || {};
|
|
13
|
-
this.debug =
|
|
26
|
+
this.debug = createDebug__default["default"]('cuecue:store:memory');
|
|
14
27
|
}
|
|
15
28
|
|
|
16
29
|
findItem(type, id) {
|
|
17
30
|
const items = this.data[type] || [];
|
|
18
|
-
return items.find(
|
|
31
|
+
return items.find(matches__default["default"](isObject__default["default"](id) ? id : {
|
|
19
32
|
id
|
|
20
33
|
})) || null;
|
|
21
34
|
}
|
|
22
35
|
|
|
23
36
|
addItem(type, data) {
|
|
24
|
-
const id = data.id || v4();
|
|
37
|
+
const id = data.id || uuid.v4();
|
|
25
38
|
const savedItem = { ...data,
|
|
26
39
|
id
|
|
27
40
|
};
|
|
@@ -59,34 +72,34 @@ class MemoryStore extends EventEmitter {
|
|
|
59
72
|
}
|
|
60
73
|
|
|
61
74
|
deleteItems(type, params = {}) {
|
|
62
|
-
const match =
|
|
75
|
+
const match = matches__default["default"](params);
|
|
63
76
|
this.data = { ...this.data,
|
|
64
77
|
[type]: (this.data[type] || []).filter(it => !match(it))
|
|
65
78
|
};
|
|
66
79
|
}
|
|
67
80
|
|
|
68
81
|
getItems(type, params = {}) {
|
|
69
|
-
const match =
|
|
82
|
+
const match = matches__default["default"](params);
|
|
70
83
|
return (this.data[type] || []).filter(it => match(it));
|
|
71
84
|
}
|
|
72
85
|
|
|
73
86
|
}
|
|
74
87
|
|
|
75
|
-
class Application extends
|
|
88
|
+
class Application extends EventEmitter__default["default"] {
|
|
76
89
|
constructor(definition, opts = {}) {
|
|
77
90
|
super();
|
|
78
91
|
this.definition = definition;
|
|
79
92
|
this.options = {
|
|
80
93
|
store: new MemoryStore(),
|
|
81
|
-
debugFunction:
|
|
82
|
-
getHandle: id => `${id}_${
|
|
94
|
+
debugFunction: createDebug__default["default"]('cuecue:app'),
|
|
95
|
+
getHandle: id => `${id}_${dayjs__default["default"]().format('YYYY_MM_DD')}_${Date.now().toString(36)}`,
|
|
83
96
|
validateCommand: command => ['start', 'end', 'cue', 'uncue', 'define', 'interact', 'reset', 'resetInteractions', 'restart', 'kill'].indexOf(command) !== -1,
|
|
84
97
|
...opts
|
|
85
98
|
};
|
|
86
99
|
const {
|
|
87
100
|
store
|
|
88
101
|
} = this.options;
|
|
89
|
-
this.debug =
|
|
102
|
+
this.debug = createDebug__default["default"]('cuecue:app');
|
|
90
103
|
this.store = store;
|
|
91
104
|
this.session = null;
|
|
92
105
|
this.statefulCue = null;
|
|
@@ -110,7 +123,7 @@ class Application extends EventEmitter {
|
|
|
110
123
|
this.onAfterTransition = this.onAfterTransition.bind(this);
|
|
111
124
|
this.onInvalidTransition = this.onInvalidTransition.bind(this);
|
|
112
125
|
this.onPendingTransition = this.onPendingTransition.bind(this);
|
|
113
|
-
this.state = new
|
|
126
|
+
this.state = new StateMachine__default["default"]({
|
|
114
127
|
transitions: [{
|
|
115
128
|
name: 'init',
|
|
116
129
|
from: 'none',
|
|
@@ -191,7 +204,7 @@ class Application extends EventEmitter {
|
|
|
191
204
|
|
|
192
205
|
async interact(data, interactionId = null) {
|
|
193
206
|
this.sendInteractToOutputs(data, interactionId);
|
|
194
|
-
const interaction = await this.ensureInteraction(data, interactionId || v4());
|
|
207
|
+
const interaction = await this.ensureInteraction(data, interactionId || uuid.v4());
|
|
195
208
|
this.sendInteractionToOutputs(interaction);
|
|
196
209
|
return interaction;
|
|
197
210
|
}
|
|
@@ -867,7 +880,7 @@ const terminate = (server = null, options = {
|
|
|
867
880
|
coredump: false,
|
|
868
881
|
timeout: 500
|
|
869
882
|
}) => {
|
|
870
|
-
const debug =
|
|
883
|
+
const debug = createDebug__default["default"]('cuecue:app:terminate');
|
|
871
884
|
|
|
872
885
|
const exit = code => {
|
|
873
886
|
if (options.coredump) {
|
|
@@ -899,4 +912,6 @@ var utils = {
|
|
|
899
912
|
terminate
|
|
900
913
|
};
|
|
901
914
|
|
|
902
|
-
|
|
915
|
+
exports.MemoryStore = MemoryStore;
|
|
916
|
+
exports["default"] = Application;
|
|
917
|
+
exports.utils = utils;
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@cuecue/app",
|
|
3
|
-
"version": "0.0.
|
|
3
|
+
"version": "0.0.28",
|
|
4
4
|
"description": "",
|
|
5
5
|
"keywords": [
|
|
6
6
|
"javascript"
|
|
@@ -40,7 +40,7 @@
|
|
|
40
40
|
},
|
|
41
41
|
"dependencies": {
|
|
42
42
|
"@babel/runtime": "^7.12.5",
|
|
43
|
-
"@cuecue/core": "^0.0.
|
|
43
|
+
"@cuecue/core": "^0.0.28",
|
|
44
44
|
"commander": "^7.0.0",
|
|
45
45
|
"dayjs": "^1.10.4",
|
|
46
46
|
"debug": "^4.3.1",
|
|
@@ -52,5 +52,5 @@
|
|
|
52
52
|
"publishConfig": {
|
|
53
53
|
"access": "public"
|
|
54
54
|
},
|
|
55
|
-
"gitHead": "
|
|
55
|
+
"gitHead": "f6865a82708bf09de192b9a6367729e9faeb1250"
|
|
56
56
|
}
|