| 1234567891011121314151617181920212223242526272829 |
- /** 语句:schedule 定时执行(解析在此,执行在 sequence-runner) */
- const { assertStrictKeys } = require('../action-schema.js')
- const types = ['schedule']
- function parse (action, parseContext) {
- const path = parseContext.actionPath || 'schedule'
- assertStrictKeys(action, ['type', 'condition', 'interval'], path)
- if (action.condition == null || typeof action.condition !== 'object' || Array.isArray(action.condition)) {
- throw new Error(`${path}: schedule 须包含对象 condition`)
- }
- if (!Array.isArray(action.interval)) {
- throw new Error(`${path}: schedule 须包含数组 interval`)
- }
- const condition = { ...action.condition }
- if (condition.repeat === 'forever' || condition.repeat === 'Forever') {
- condition.repeat = -1
- }
- return {
- type: 'schedule',
- condition,
- interval: parseContext.parseActions(action.interval, 'interval'),
- }
- }
- async function execute() {
- return { success: true }
- }
- module.exports = { types, parse, execute }
|