@live-change/dao 0.4.9 → 0.4.10
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/lib/Path.js +4 -3
- package/package.json +2 -2
- package/tests/path.js +3 -2
package/lib/Path.js
CHANGED
|
@@ -71,16 +71,17 @@ class Path {
|
|
|
71
71
|
}
|
|
72
72
|
return new Path(this.what, newMore, this.to, this.actions)
|
|
73
73
|
}
|
|
74
|
-
action(paramsFunc) {
|
|
74
|
+
action(name, paramsFunc) {
|
|
75
75
|
let newActions = this.actions ? this.actions.slice() : []
|
|
76
76
|
const source = sourceProxy()
|
|
77
|
-
const actionObject = paramsFunc(source)
|
|
77
|
+
const actionObject = (paramsFunc || to)(source)
|
|
78
78
|
const path = actionObject.slice(0, -1)
|
|
79
79
|
const params = actionObject[actionObject.length - 1]
|
|
80
80
|
let processedParams = processParams(params)
|
|
81
81
|
const action = {
|
|
82
|
+
name: paramsFunc ? name : undefined,
|
|
82
83
|
path,
|
|
83
|
-
params: { object: processedParams }
|
|
84
|
+
params: { object: processedParams },
|
|
84
85
|
}
|
|
85
86
|
newActions.push(action)
|
|
86
87
|
return new Path(this.what, this.more, this.to, newActions)
|
package/package.json
CHANGED
package/tests/path.js
CHANGED
|
@@ -49,9 +49,10 @@ test("Path", t => {
|
|
|
49
49
|
|
|
50
50
|
t.test("tasks with delete actions", t => {
|
|
51
51
|
t.plan(1)
|
|
52
|
-
const path = tasks({ }).action(task => deleteTask({ task: task.id }))
|
|
52
|
+
const path = tasks({ }).action('delete', task => deleteTask({ task: task.id }))
|
|
53
|
+
console.log(JSON.stringify(path))
|
|
53
54
|
t.deepEqual(clean(path), {"what":["tasks",{}],"actions":[
|
|
54
|
-
{"path":["tasks"],"params":{"object":{"task":{"property":"id"}}}}
|
|
55
|
+
{"name":"delete","path":["tasks"],"params":{"object":{"task":{"property":"id"}}}}
|
|
55
56
|
]})
|
|
56
57
|
})
|
|
57
58
|
|