@vyr/service-graph 0.0.1 → 0.0.3

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,23 +1 @@
1
- {
2
- "name": "@vyr/service-graph",
3
- "version": "0.0.1",
4
- "description": "",
5
- "main": "./src/index.ts",
6
- "author": "",
7
- "license": "MIT",
8
- "dependencies": {
9
- "vue": "3.5.22",
10
- "@vyr/locale": "0.0.1",
11
- "@vyr/engine": "0.0.1",
12
- "@vyr/service": "0.0.1",
13
- "jsondiffpatch": "^0.6.0",
14
- "@antv/x6": "^2.18.1",
15
- "@antv/x6-plugin-selection": "^2.2.2",
16
- "@antv/x6-plugin-stencil": "^2.1.5",
17
- "@antv/x6-plugin-history": "2.2.4"
18
- },
19
- "files": [
20
- "package.json",
21
- "src/"
22
- ]
23
- }
1
+ {"name":"@vyr/service-graph","version":"0.0.3","description":"","main":"./src/index.ts","author":"","license":"MIT","dependencies":{"vue":"3.5.22","@vyr/locale":"0.0.3","@vyr/engine":"0.0.3","@vyr/service":"0.0.3","jsondiffpatch":"^0.6.0","@antv/x6":"^2.18.1","@antv/x6-plugin-selection":"^2.2.2","@antv/x6-plugin-stencil":"^2.1.5","@antv/x6-plugin-history":"2.2.4"},"files":["package.json","src/"]}
@@ -1,8 +1,8 @@
1
1
  import { reactive, AsyncComponentLoader, defineAsyncComponent } from 'vue'
2
2
  import { Service } from "@vyr/service"
3
- import { DeserializationObject, InteractionInputCollection, ObjectUtils, RoutineDescriptor, RoutineMapper, RoutineNode } from '@vyr/engine'
3
+ import { DeserializationObject, InteractionInputCollection, ObjectUtils, InteractionDescriptor, InteractionNode, InteractionMapper } from '@vyr/engine'
4
4
  import { Unit } from './common/Unit'
5
- import { BranchUnit, ConditionUnit, ExecuteUnit, RoutineUnit as GraphRoutineUnit } from './common/RoutineUnit'
5
+ import { BranchUnit, ConditionUnit, ExecuteUnit, InteractionUnit } from './common/InteractionUnit'
6
6
  import { GraphDrawer } from './GraphDrawer'
7
7
 
8
8
  class GraphState {
@@ -12,13 +12,13 @@ class GraphState {
12
12
  descriptor = ''
13
13
  event = ''
14
14
  inputs: InteractionInputCollection = {}
15
- routine: DeserializationObject<RoutineDescriptor> | null = null
15
+ interaction: DeserializationObject<InteractionDescriptor> | null = null
16
16
 
17
17
  reset() {
18
18
  this.descriptor = ''
19
19
  this.event = ''
20
20
  this.inputs = {}
21
- this.routine = null
21
+ this.interaction = null
22
22
  }
23
23
  }
24
24
 
@@ -37,34 +37,34 @@ class GraphService extends Service {
37
37
  return this._drawer
38
38
  }
39
39
  readonly state = reactive(new GraphState())
40
- routine: DeserializationObject<RoutineDescriptor> | null = null
40
+ interaction: DeserializationObject<InteractionDescriptor> | null = null
41
41
 
42
- private _doNodes(nodes: RoutineNode[]) {
42
+ private _doNodes(nodes: InteractionNode[]) {
43
43
  for (const node of nodes) {
44
- if (node.routine === 'Execute') {
44
+ if (node.interaction === 'Execute') {
45
45
  const cell = new ExecuteUnit({ ...node, drawer: this.drawer })
46
46
  this.drawer.graph.addCell(cell)
47
- } else if (node.routine === 'Condition') {
47
+ } else if (node.interaction === 'Condition') {
48
48
  this.drawer.graph.addCell(new ConditionUnit({ ...node, drawer: this.drawer }))
49
- } else if (node.routine === 'Branch') {
49
+ } else if (node.interaction === 'Branch') {
50
50
  this.drawer.graph.addCell(new BranchUnit({ ...node, drawer: this.drawer }))
51
51
  }
52
52
  }
53
53
 
54
54
  }
55
- private _doMappers(mappers: RoutineMapper[]) {
55
+ private _doMappers(mappers: InteractionMapper[]) {
56
56
  for (const mapper of mappers) {
57
57
  const edge = this.drawer.getEdgeOfMapper(mapper.source, mapper.target)
58
58
  this.drawer.graph.addEdge(edge)
59
59
  }
60
60
  }
61
61
 
62
- private _diff(cur: RoutineNode[], old: RoutineNode[]) {
63
- const addQueue: RoutineNode[] = []
64
- const removeQueue: RoutineNode[] = []
65
- const updateQueue: RoutineNode[] = []
62
+ private _diff(cur: InteractionNode[], old: InteractionNode[]) {
63
+ const addQueue: InteractionNode[] = []
64
+ const removeQueue: InteractionNode[] = []
65
+ const updateQueue: InteractionNode[] = []
66
66
 
67
- const temp = new Map<string, RoutineNode>()
67
+ const temp = new Map<string, InteractionNode>()
68
68
  for (const oldItem of old) {
69
69
  temp.set(oldItem.id, oldItem)
70
70
  }
@@ -88,17 +88,17 @@ class GraphService extends Service {
88
88
  }
89
89
  }
90
90
 
91
- render(routine: DeserializationObject<RoutineDescriptor>) {
92
- this.routine = routine
91
+ render(interaction: DeserializationObject<InteractionDescriptor>) {
92
+ this.interaction = interaction
93
93
 
94
94
  this.drawer.needTriggerChange = false
95
- this._doNodes(routine.nodes)
96
- this._doMappers(routine.mappers)
95
+ this._doNodes(interaction.nodes)
96
+ this._doMappers(interaction.mappers)
97
97
  this.drawer.needTriggerChange = true
98
98
  }
99
99
 
100
- update(curRoutine: DeserializationObject<RoutineDescriptor>) {
101
- if (this.routine === null) return
100
+ update(curInteraction: DeserializationObject<InteractionDescriptor>) {
101
+ if (this.interaction === null) return
102
102
 
103
103
  this.drawer.needTriggerChange = false
104
104
  this.drawer.selectEdge = ''
@@ -108,7 +108,7 @@ class GraphService extends Service {
108
108
  const edges = this.drawer.graph.getEdges()
109
109
  for (const edge of edges) this.drawer.remove(edge)
110
110
 
111
- const patch = this._diff(curRoutine.nodes, this.routine.nodes)
111
+ const patch = this._diff(curInteraction.nodes, this.interaction.nodes)
112
112
 
113
113
  let needCleanSelection = false
114
114
  for (const remove of patch.removeQueue) {
@@ -127,37 +127,37 @@ class GraphService extends Service {
127
127
  if (cell) cell.setVMeta(update)
128
128
  }
129
129
 
130
- this._doMappers(curRoutine.mappers)
130
+ this._doMappers(curInteraction.mappers)
131
131
  this.drawer.needTriggerChange = true
132
132
 
133
- this.routine = curRoutine
133
+ this.interaction = curInteraction
134
134
  }
135
135
 
136
136
  build() {
137
- const routine = new RoutineDescriptor()
137
+ const interaction = new InteractionDescriptor()
138
138
  const cells = this.drawer.graph.getCells()
139
139
 
140
140
  for (const cell of cells) {
141
- if (cell instanceof GraphRoutineUnit) {
141
+ if (cell instanceof InteractionUnit) {
142
142
  const node = {
143
143
  id: cell.id,
144
144
  label: cell.vMeta.label ?? '',
145
145
  url: cell.vMeta.url,
146
- routine: cell.vMeta.routine,
146
+ interaction: cell.vMeta.interaction,
147
147
  input: cell.vMeta.input,
148
148
  position: cell.getPosition(),
149
149
  }
150
- routine.nodes.push(node)
150
+ interaction.nodes.push(node)
151
151
  } else if (cell.isEdge()) {
152
152
  const mapper = this.drawer.getMapper(cell)
153
- if (mapper) routine.mappers.push(mapper)
153
+ if (mapper) interaction.mappers.push(mapper)
154
154
  }
155
155
  }
156
156
 
157
157
  const roots = this.drawer.graph.getRootNodes()
158
- for (const root of roots) routine.roots.push(root.id)
158
+ for (const root of roots) interaction.roots.push(root.id)
159
159
 
160
- return { ...routine, uuid: this.routine?.uuid }
160
+ return { ...interaction, uuid: this.interaction?.uuid }
161
161
  }
162
162
 
163
163
  get(id: string) {
@@ -2,25 +2,25 @@ import { Cell } from "@antv/x6";
2
2
  import { Descriptor } from "@vyr/engine";
3
3
  import { Unit, UnitMeta, UnitPartial, } from "./Unit";
4
4
 
5
- interface RoutineUnitMeta extends UnitMeta {
5
+ interface InteractionUnitMeta extends UnitMeta {
6
6
  url: string
7
- routine: string
7
+ interaction: string
8
8
  input: { [param: string]: any }
9
9
  }
10
10
 
11
- class RoutineUnit extends Unit {
12
- declare vMeta: RoutineUnitMeta
11
+ class InteractionUnit extends Unit {
12
+ declare vMeta: InteractionUnitMeta
13
13
 
14
- constructor(vMeta: UnitPartial<RoutineUnitMeta>) {
14
+ constructor(vMeta: UnitPartial<InteractionUnitMeta>) {
15
15
  super(vMeta)
16
16
  this.vMeta.input = vMeta.input ? Descriptor.deepClone(vMeta.input) : {}
17
17
  }
18
18
  }
19
19
 
20
- class ExecuteUnit extends RoutineUnit {
21
- constructor(vMeta: UnitPartial<RoutineUnitMeta>) {
20
+ class ExecuteUnit extends InteractionUnit {
21
+ constructor(vMeta: UnitPartial<InteractionUnitMeta>) {
22
22
  super({ ...vMeta, maxInCount: Infinity, icon: 'graphfont graph-execute' })
23
- this.vMeta.routine = 'Execute'
23
+ this.vMeta.interaction = 'Execute'
24
24
  this.vMeta.url = vMeta.url ?? ''
25
25
  }
26
26
 
@@ -30,11 +30,11 @@ class ExecuteUnit extends RoutineUnit {
30
30
  }
31
31
  }
32
32
 
33
- class BranchUnit extends RoutineUnit {
33
+ class BranchUnit extends InteractionUnit {
34
34
 
35
- constructor(vMeta: UnitPartial<RoutineUnitMeta>) {
35
+ constructor(vMeta: UnitPartial<InteractionUnitMeta>) {
36
36
  super({ ...vMeta, maxOutCount: Infinity, icon: 'graphfont graph-branch' })
37
- this.vMeta.routine = 'Branch'
37
+ this.vMeta.interaction = 'Branch'
38
38
  this.vMeta.url = vMeta.url ?? ''
39
39
  }
40
40
 
@@ -44,10 +44,10 @@ class BranchUnit extends RoutineUnit {
44
44
  }
45
45
  }
46
46
 
47
- class ConditionUnit extends RoutineUnit {
48
- constructor(vMeta: UnitPartial<RoutineUnitMeta>) {
47
+ class ConditionUnit extends InteractionUnit {
48
+ constructor(vMeta: UnitPartial<InteractionUnitMeta>) {
49
49
  super({ input: { value: { type: 'string', value: '' } }, ...vMeta, icon: 'graphfont graph-condition' })
50
- this.vMeta.routine = 'Condition'
50
+ this.vMeta.interaction = 'Condition'
51
51
  this.vMeta.url = vMeta.url ?? ''
52
52
  }
53
53
 
@@ -58,7 +58,7 @@ class ConditionUnit extends RoutineUnit {
58
58
  }
59
59
 
60
60
  export {
61
- RoutineUnit,
61
+ InteractionUnit,
62
62
  ExecuteUnit,
63
63
  BranchUnit,
64
64
  ConditionUnit,
package/src/index.ts CHANGED
@@ -2,6 +2,6 @@ import './asset/font/iconfont.css'
2
2
  import './asset/less/index.less'
3
3
  export * from './locale'
4
4
  export * from './common/Unit'
5
- export * from './common/RoutineUnit'
5
+ export * from './common/InteractionUnit'
6
6
  export * from './GraphDrawer'
7
7
  export * from './GraphService'