ywana-core8 0.0.647 → 0.0.648

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/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "ywana-core8",
3
- "version": "0.0.647",
3
+ "version": "0.0.648",
4
4
  "description": "ywana-core8",
5
5
  "homepage": "https://ywana.github.io/workspace",
6
6
  "author": "Ernesto Roldan Garcia",
@@ -431,7 +431,7 @@ export const TableEditor = (props) => {
431
431
  format: field.format,
432
432
  item: field.item ? field.item : [],
433
433
  onChange: field.id === "checked" ? checkOne : field.editable ? change : null, /* checked has it´s own handler */
434
- options
434
+ options,
435
435
  }
436
436
  }),
437
437
  rows: []
@@ -467,6 +467,7 @@ export const TableEditor = (props) => {
467
467
  return item
468
468
  })
469
469
 
470
+ table.columns.push({ id: "actions", label: ""})
470
471
  table.rows = rows
471
472
 
472
473
  return ({
@@ -0,0 +1,97 @@
1
+ const STATES = [
2
+
3
+ {
4
+ name: "created",
5
+ on: {
6
+ "INGEST": "ingesting",
7
+ }
8
+ },
9
+
10
+ {
11
+ name: "ingesting",
12
+ inputAction: (sm) => { console.log("execute ingest task") },
13
+ on: {
14
+ "INGESTED": "ingested",
15
+ }
16
+ },
17
+
18
+ {
19
+ name: "ingested",
20
+ on: {
21
+ "REJECT": "rejected",
22
+ "CATEGORIZE": "categorizing"
23
+ }
24
+ },
25
+
26
+ {
27
+ name: "categorizing",
28
+ inputAction: (sm) => { console.log("execute categorize task")},
29
+ on: {
30
+ "CATEGORIZED": "categorized"
31
+ }
32
+ },
33
+
34
+ {
35
+ name: "categorized",
36
+ on: {
37
+ }
38
+ },
39
+
40
+ {
41
+ name: "done",
42
+ on: {
43
+ "IMPORT": "importing"
44
+ }
45
+ },
46
+
47
+
48
+ {
49
+ name: "rejected",
50
+ },
51
+
52
+ {
53
+ name: "error",
54
+ on: {
55
+ "IMPORT": "importing"
56
+ }
57
+ },
58
+ ]
59
+
60
+ /**
61
+ * State Machine
62
+ */
63
+ const StateMachine = (states, resource) => {
64
+
65
+ const initialState = resource.state ? states[resource.state] : states[0];
66
+
67
+ const stateMachine = {
68
+ states: states,
69
+ state: initialState,
70
+ transition: async (event) => {
71
+ const nextState = stateMachine.state.on[event]
72
+ if (nextState) {
73
+ stateMachine.state = stateMachine.states.find(state => state.name === nextState)
74
+ if (stateMachine.state.inputAction) {
75
+ await stateMachine.state.inputAction(content, event, stateMachine)
76
+ }
77
+ return stateMachine.state
78
+ } else {
79
+ return null
80
+ }
81
+ },
82
+ isFinal: () => {
83
+ return stateMachine.state.on === undefined
84
+ }
85
+ }
86
+
87
+ return stateMachine
88
+
89
+ }
90
+
91
+ const import1 = {
92
+ state: "created"
93
+ }
94
+
95
+ const importSM = StateMachine(STATES, import1)
96
+ const next = importSM.transition("INGEST")
97
+