@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.
Files changed (2) hide show
  1. package/dist/index.js +37 -22
  2. package/package.json +3 -3
package/dist/index.js CHANGED
@@ -1,27 +1,40 @@
1
- import StateMachine from 'javascript-state-machine';
2
- import EventEmitter from 'wolfy87-eventemitter';
3
- import createDebug from 'debug';
4
- import dayjs from 'dayjs';
5
- import { v4 } from 'uuid';
6
- import matches from 'lodash/matches';
7
- import isObject from 'lodash/isObject';
8
-
9
- class MemoryStore extends EventEmitter {
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 = createDebug('cuecue:store:memory');
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(matches(isObject(id) ? id : {
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 = matches(params);
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 = matches(params);
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 EventEmitter {
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: createDebug('cuecue:app'),
82
- getHandle: id => `${id}_${dayjs().format('YYYY_MM_DD')}_${Date.now().toString(36)}`,
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 = createDebug('cuecue:app');
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 StateMachine({
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 = createDebug('cuecue:app:terminate');
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
- export { MemoryStore, Application as default, utils };
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.27",
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.27",
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": "2c305c0d1c0b13469fe74e2b928c0b45744c8ac0"
55
+ "gitHead": "f6865a82708bf09de192b9a6367729e9faeb1250"
56
56
  }