@wmfs/tymly-schedule-plugin 1.0.1 → 1.2.0

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.
Files changed (40) hide show
  1. package/.version +1 -1
  2. package/CHANGELOG.md +49 -0
  3. package/lib/blueprints/schedule-blueprint/card-templates/create-scheduled-task.json +97 -0
  4. package/lib/blueprints/schedule-blueprint/card-templates/view-all-scheduled-tasks.json +36 -0
  5. package/lib/blueprints/schedule-blueprint/card-templates/view-scheduled-task.json +148 -0
  6. package/lib/blueprints/schedule-blueprint/categories/schedule.json +8 -0
  7. package/lib/blueprints/schedule-blueprint/functions/generate-key.js +16 -0
  8. package/lib/blueprints/schedule-blueprint/functions/get-available-state-machines.js +18 -0
  9. package/lib/blueprints/schedule-blueprint/models/task.json +0 -14
  10. package/lib/blueprints/schedule-blueprint/state-machines/create-scheduled-task.json +66 -0
  11. package/lib/blueprints/schedule-blueprint/state-machines/modify-scheduled-task.json +74 -0
  12. package/lib/blueprints/schedule-blueprint/state-machines/start-task.json +36 -0
  13. package/lib/blueprints/schedule-blueprint/state-machines/stop-task.json +36 -0
  14. package/lib/blueprints/schedule-blueprint/state-machines/view-all-scheduled-tasks.json +69 -0
  15. package/lib/blueprints/schedule-blueprint/state-machines/view-scheduled-task.json +46 -0
  16. package/lib/blueprints/schedule-blueprint/template-roles/schedule-admin.json +4 -0
  17. package/lib/components/services/schedule/index.js +82 -24
  18. package/lib/components/services/schedule/utils/datetime-to-rule.js +1 -1
  19. package/lib/components/state-resources/create-scheduled-task/doc/example.json +8 -0
  20. package/lib/components/state-resources/create-scheduled-task/doc/index.js +4 -0
  21. package/lib/components/state-resources/create-scheduled-task/index.js +55 -0
  22. package/lib/components/state-resources/find-scheduled-executions/doc/example.json +8 -0
  23. package/lib/components/state-resources/find-scheduled-executions/doc/index.js +4 -0
  24. package/lib/components/state-resources/find-scheduled-executions/index.js +12 -0
  25. package/lib/components/state-resources/start-scheduled-task/doc/example.json +8 -0
  26. package/lib/components/state-resources/start-scheduled-task/doc/index.js +4 -0
  27. package/lib/components/state-resources/start-scheduled-task/index.js +12 -0
  28. package/lib/components/state-resources/stop-scheduled-task/doc/example.json +8 -0
  29. package/lib/components/state-resources/stop-scheduled-task/doc/index.js +4 -0
  30. package/lib/components/state-resources/stop-scheduled-task/index.js +12 -0
  31. package/lib/components/state-resources/update-scheduled-state-machine-config/doc/example.json +12 -0
  32. package/lib/components/state-resources/update-scheduled-state-machine-config/doc/index.js +4 -0
  33. package/lib/components/state-resources/update-scheduled-state-machine-config/index.js +35 -0
  34. package/lib/components/state-resources/update-scheduled-task/doc/example.json +13 -0
  35. package/lib/components/state-resources/update-scheduled-task/doc/index.js +4 -0
  36. package/lib/components/state-resources/update-scheduled-task/index.js +26 -0
  37. package/package.json +5 -6
  38. package/plugin.json +1 -1
  39. package/test/rule-to-datetime-tests.js +2 -2
  40. package/test/schedule-tests.js +17 -14
@@ -18,9 +18,7 @@ describe('Tymly schedule tests', function () {
18
18
 
19
19
  let tymlyService
20
20
  let scheduleService
21
- // let statebox
22
21
  let catStatsModel
23
- // let executionsModel
24
22
  let taskModel
25
23
  let client
26
24
 
@@ -34,17 +32,16 @@ describe('Tymly schedule tests', function () {
34
32
  ],
35
33
  pluginPaths: [
36
34
  path.resolve(__dirname, '..'),
37
- require.resolve('@wmfs/tymly-pg-plugin')
35
+ require.resolve('@wmfs/tymly-pg-plugin'),
36
+ require.resolve('@wmfs/tymly-test-helpers/plugins/mock-users-plugin')
38
37
  ]
39
38
  }
40
39
  )
41
40
 
42
41
  tymlyService = tymlyServices.tymly
43
42
  scheduleService = tymlyServices.schedule
44
- // statebox = tymlyServices.statebox
45
43
  taskModel = tymlyServices.storage.models.schedule_task
46
44
  catStatsModel = tymlyServices.storage.models.tymlyTest_catStats
47
- // executionsModel = tymlyServices.storage.models.tymly_execution
48
45
  client = tymlyServices.storage.client
49
46
 
50
47
  const catStats = await catStatsModel.find({})
@@ -74,9 +71,8 @@ describe('Tymly schedule tests', function () {
74
71
  expect(tasks[0].datetime).to.eql(null)
75
72
  expect(tasks[0].status).to.eql('STOPPED')
76
73
 
77
- const { totalRunCount } = tasks[0]
78
-
79
- lastRunCount = totalRunCount
74
+ const executions = await scheduleService.findScheduledExecutions(scheduleKey)
75
+ lastRunCount = executions.length
80
76
 
81
77
  // Waited 10 seconds and runs every 2 seconds so can be 5 or 6
82
78
  expect(lastRunCount).to.be.greaterThanOrEqual(5)
@@ -96,7 +92,8 @@ describe('Tymly schedule tests', function () {
96
92
  expect(tasks[0].datetime).to.eql(null)
97
93
  expect(tasks[0].status).to.eql('STOPPED')
98
94
 
99
- expect(tasks[0].totalRunCount).to.eql(lastRunCount)
95
+ const executions = await scheduleService.findScheduledExecutions(scheduleKey)
96
+ expect(executions.length).to.eql(lastRunCount)
100
97
 
101
98
  const catStats = await catStatsModel.find({})
102
99
  expect(catStats.length).to.eql(lastRunCount)
@@ -131,9 +128,11 @@ describe('Tymly schedule tests', function () {
131
128
  expect(tasks[0].interval).to.eql(null)
132
129
  expect(tasks[0].datetime).to.not.eql(null)
133
130
  expect(tasks[0].scheduleType).to.eql('datetime')
134
- expect(tasks[0].totalRunCount).to.eql(lastRunCount)
135
131
  expect(tasks[0].status).to.eql('STARTED')
136
132
 
133
+ const executions = await scheduleService.findScheduledExecutions(scheduleKey)
134
+ expect(executions.length).to.eql(lastRunCount)
135
+
137
136
  const catStats = await catStatsModel.find({})
138
137
  expect(catStats.length).to.eql(lastRunCount)
139
138
  })
@@ -145,7 +144,8 @@ describe('Tymly schedule tests', function () {
145
144
  expect(tasks.length).to.eql(1)
146
145
  expect(tasks[0].status).to.eql('STARTED')
147
146
 
148
- expect(tasks[0].totalRunCount).to.eql(lastRunCount)
147
+ const executions = await scheduleService.findScheduledExecutions(scheduleKey)
148
+ expect(executions.length).to.eql(lastRunCount)
149
149
 
150
150
  const catStats = await catStatsModel.find({})
151
151
  expect(catStats.length).to.eql(lastRunCount)
@@ -163,7 +163,8 @@ describe('Tymly schedule tests', function () {
163
163
  ],
164
164
  pluginPaths: [
165
165
  path.resolve(__dirname, '..'),
166
- require.resolve('@wmfs/tymly-pg-plugin')
166
+ require.resolve('@wmfs/tymly-pg-plugin'),
167
+ require.resolve('@wmfs/tymly-test-helpers/plugins/mock-users-plugin')
167
168
  ]
168
169
  }
169
170
  )
@@ -182,8 +183,10 @@ describe('Tymly schedule tests', function () {
182
183
  expect(tasks[0].stateMachineName).to.eql('tymlyTest_sendCatUpdate')
183
184
  expect(tasks[0].scheduleType).to.eql('datetime')
184
185
  expect(tasks[0].interval).to.eql(null)
185
- expect(tasks[0].status).to.eql('STARTED')
186
- expect(tasks[0].totalRunCount).to.eql(lastRunCount)
186
+ expect(tasks[0].status).to.eql('STOPPED')
187
+
188
+ const executions = await scheduleService.findScheduledExecutions(scheduleKey)
189
+ expect(executions.length).to.eql(lastRunCount)
187
190
  })
188
191
 
189
192
  it('clean up data', async () => {