一键导入
setup-chain
create new actions, functions or workflows for logdna/setup-chain
用 Codex 或 Claude 帮你安装 复制这段 Prompt,粘贴到 Codex、Claude 或其他助手里,让它检查 Skill 页面并帮你完成安装。
菜单
create new actions, functions or workflows for logdna/setup-chain
用 Codex 或 Claude 帮你安装 复制这段 Prompt,粘贴到 Codex、Claude 或其他助手里,让它检查 Skill 页面并帮你完成安装。
基于 SOC 职业分类
| name | setup-chain |
| description | create new actions, functions or workflows for logdna/setup-chain |
| license | MIT |
| metadata | {"author":"Mezmo Inc,."} |
Adds new actions and functions to logdna setup-chain
node executable is installed on the host@logdna/setup-chain in dependencies or devDependenciesIf any of the above are not met, explain what is missing. Do not proceed with custom action creation.
Follow these steps to create and wire up a custom action:
Define the action function in an actions object
async functions or return a Promiseconst actions = {
myAction: async (opts) => {
return opts.value || 'default'
}
}
Create or extend SetupChain class
class MyChain extends SetupChain {
constructor(state) {
super(state, actions)
}
}
Use the action in your chain
await new MyChain().myAction({value: 'test'}, 'result').execute()
// state: {result: 'test'}
Validate your implementation works as expected
Only manually push this.tasks when action signature deviates from (opts, label):
class MyChain extends SetupChain {
constructor(state) {
super(state, yourActions)
}
customAction(arg1, arg2, label) {
this.tasks.push(['customAction', label, arg1, arg2])
return this
}
}
See create-action.md for detailed patterns and examples.
SetupChain implements chain-of-responsibility pattern. Actions are available as top level functions on a chain instance. Chain actions, execute, and results are stored in state.
const chain = new MyChain()
const state = await chain
.set('user', 'alice')
.map('#user', n => n * 2, 'doubled')
.execute()
// state: {user: 'alice', doubled: [2, 4, 6]}
Best practices:
.action1().action2().execute()new SetupChain(state2)const chain = new MyChain()
// test scenerio 1
chain
.account({}, 'account_one')
.user({account: '#account_one'}, 'user_one')
// test scenerio 1
chain
.account({}, 'account_two')
.user({account: '#account_two'}, 'user_two')
const state = await chain.execute()