@nocobase/plugin-workflow 0.11.1-alpha.5 → 0.12.0-alpha.2

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 (537) hide show
  1. package/client.d.ts +2 -3
  2. package/client.js +1 -1
  3. package/dist/client/index.js +7802 -0
  4. package/{lib → dist}/client/nodes/aggregate.d.ts +1 -5
  5. package/{lib → dist}/client/nodes/create.d.ts +1 -2
  6. package/{lib → dist}/client/nodes/destroy.d.ts +1 -1
  7. package/{lib → dist}/client/nodes/query.d.ts +1 -2
  8. package/{lib → dist}/client/nodes/request.d.ts +1 -2
  9. package/{lib → dist}/client/nodes/update.d.ts +1 -1
  10. package/{lib → dist}/client/schemas/collection.d.ts +1 -2
  11. package/{lib → dist}/client/triggers/collection.d.ts +6 -7
  12. package/{lib → dist}/index.d.ts +1 -0
  13. package/dist/index.js +18 -0
  14. package/dist/locale/en-US.js +133 -0
  15. package/{lib → dist}/locale/es-ES.js +51 -54
  16. package/dist/locale/fr-FR.js +133 -0
  17. package/dist/locale/ja-JP.js +91 -0
  18. package/dist/locale/pt-BR.js +133 -0
  19. package/dist/locale/ru-RU.js +91 -0
  20. package/dist/locale/tr-TR.js +91 -0
  21. package/dist/locale/zh-CN.js +216 -0
  22. package/dist/node_modules/cron-parser/.eslintrc.json +15 -0
  23. package/dist/node_modules/cron-parser/.travis.yml +7 -0
  24. package/dist/node_modules/cron-parser/LICENSE +21 -0
  25. package/dist/node_modules/cron-parser/component.json +11 -0
  26. package/dist/node_modules/cron-parser/index.d.ts +1 -0
  27. package/dist/node_modules/cron-parser/lib/date.js +252 -0
  28. package/dist/node_modules/cron-parser/lib/expression.js +983 -0
  29. package/dist/node_modules/cron-parser/lib/field_compactor.js +70 -0
  30. package/dist/node_modules/cron-parser/lib/field_stringify.js +38 -0
  31. package/dist/node_modules/cron-parser/lib/parser.js +1 -0
  32. package/dist/node_modules/cron-parser/node_modules/luxon/build/amd/luxon.js +8489 -0
  33. package/dist/node_modules/cron-parser/node_modules/luxon/build/cjs-browser/luxon.js +8487 -0
  34. package/dist/node_modules/cron-parser/node_modules/luxon/build/global/luxon.js +8490 -0
  35. package/dist/node_modules/cron-parser/node_modules/luxon/build/global/luxon.min.js +1 -0
  36. package/dist/node_modules/cron-parser/node_modules/luxon/build/node/luxon.js +7522 -0
  37. package/dist/node_modules/cron-parser/node_modules/luxon/package.json +96 -0
  38. package/dist/node_modules/cron-parser/node_modules/luxon/src/datetime.js +2169 -0
  39. package/dist/node_modules/cron-parser/node_modules/luxon/src/duration.js +880 -0
  40. package/dist/node_modules/cron-parser/node_modules/luxon/src/errors.js +61 -0
  41. package/dist/node_modules/cron-parser/node_modules/luxon/src/impl/conversions.js +157 -0
  42. package/dist/node_modules/cron-parser/node_modules/luxon/src/impl/diff.js +80 -0
  43. package/dist/node_modules/cron-parser/node_modules/luxon/src/impl/digits.js +76 -0
  44. package/dist/node_modules/cron-parser/node_modules/luxon/src/impl/english.js +233 -0
  45. package/dist/node_modules/cron-parser/node_modules/luxon/src/impl/formats.js +191 -0
  46. package/dist/node_modules/cron-parser/node_modules/luxon/src/impl/formatter.js +386 -0
  47. package/dist/node_modules/cron-parser/node_modules/luxon/src/impl/invalid.js +14 -0
  48. package/dist/node_modules/cron-parser/node_modules/luxon/src/impl/locale.js +482 -0
  49. package/dist/node_modules/cron-parser/node_modules/luxon/src/impl/regexParser.js +335 -0
  50. package/dist/node_modules/cron-parser/node_modules/luxon/src/impl/tokenParser.js +424 -0
  51. package/dist/node_modules/cron-parser/node_modules/luxon/src/impl/util.js +292 -0
  52. package/dist/node_modules/cron-parser/node_modules/luxon/src/impl/zoneUtil.js +36 -0
  53. package/dist/node_modules/cron-parser/node_modules/luxon/src/info.js +193 -0
  54. package/dist/node_modules/cron-parser/node_modules/luxon/src/interval.js +602 -0
  55. package/dist/node_modules/cron-parser/node_modules/luxon/src/luxon.js +26 -0
  56. package/dist/node_modules/cron-parser/node_modules/luxon/src/luxonFilled.js +13 -0
  57. package/dist/node_modules/cron-parser/node_modules/luxon/src/settings.js +137 -0
  58. package/dist/node_modules/cron-parser/node_modules/luxon/src/zone.js +88 -0
  59. package/dist/node_modules/cron-parser/node_modules/luxon/src/zones/IANAZone.js +191 -0
  60. package/dist/node_modules/cron-parser/node_modules/luxon/src/zones/fixedOffsetZone.js +94 -0
  61. package/dist/node_modules/cron-parser/node_modules/luxon/src/zones/invalidZone.js +53 -0
  62. package/dist/node_modules/cron-parser/node_modules/luxon/src/zones/localZone.js +63 -0
  63. package/dist/node_modules/cron-parser/package.json +1 -0
  64. package/dist/node_modules/cron-parser/test/31_of_month.js +17 -0
  65. package/dist/node_modules/cron-parser/test/bug.js +29 -0
  66. package/dist/node_modules/cron-parser/test/crondate.js +16 -0
  67. package/dist/node_modules/cron-parser/test/crontab.example +7 -0
  68. package/dist/node_modules/cron-parser/test/empty_around_comma.js +22 -0
  69. package/dist/node_modules/cron-parser/test/expression.js +1489 -0
  70. package/dist/node_modules/cron-parser/test/field_compactor.js +250 -0
  71. package/dist/node_modules/cron-parser/test/field_stringify.js +84 -0
  72. package/dist/node_modules/cron-parser/test/fields.js +32 -0
  73. package/dist/node_modules/cron-parser/test/increment_on_first_iteration.js +22 -0
  74. package/dist/node_modules/cron-parser/test/index-ts3.test-d.ts +133 -0
  75. package/dist/node_modules/cron-parser/test/index.test-d.ts +138 -0
  76. package/dist/node_modules/cron-parser/test/leap_year.js +17 -0
  77. package/dist/node_modules/cron-parser/test/parser.js +46 -0
  78. package/dist/node_modules/cron-parser/test/parser_crondate_formats.js +145 -0
  79. package/dist/node_modules/cron-parser/test/parser_day_of_month.js +169 -0
  80. package/dist/node_modules/cron-parser/test/prev_date.js +32 -0
  81. package/dist/node_modules/cron-parser/test/stringify.js +402 -0
  82. package/dist/node_modules/cron-parser/test/timezone.js +422 -0
  83. package/dist/node_modules/cron-parser/types/common.d.ts +131 -0
  84. package/dist/node_modules/cron-parser/types/index.d.ts +45 -0
  85. package/dist/node_modules/cron-parser/types/ts3/index.d.ts +28 -0
  86. package/dist/node_modules/lru-cache/index-cjs.d.ts +7 -0
  87. package/dist/node_modules/lru-cache/index-cjs.js +1 -0
  88. package/dist/node_modules/lru-cache/index.d.ts +807 -0
  89. package/dist/node_modules/lru-cache/index.js +1334 -0
  90. package/dist/node_modules/lru-cache/index.min.js +2 -0
  91. package/dist/node_modules/lru-cache/package.json +1 -0
  92. package/dist/server/Plugin.js +297 -0
  93. package/{src/server/Processor.ts → dist/server/Processor.js} +80 -147
  94. package/dist/server/actions/index.js +49 -0
  95. package/{src/server/actions/nodes.ts → dist/server/actions/nodes.js} +55 -81
  96. package/{src/server/actions/workflows.ts → dist/server/actions/workflows.js} +60 -72
  97. package/dist/server/collections/executions.js +37 -0
  98. package/dist/server/collections/flow_nodes.js +56 -0
  99. package/dist/server/collections/jobs.js +33 -0
  100. package/dist/server/collections/workflows.js +90 -0
  101. package/{lib → dist}/server/constants.js +5 -8
  102. package/dist/server/fields/expression-field.js +11 -0
  103. package/dist/server/fields/index.js +11 -0
  104. package/dist/server/functions/index.js +13 -0
  105. package/dist/server/index.js +41 -0
  106. package/dist/server/instructions/aggregate.js +37 -0
  107. package/dist/server/instructions/calculation.js +34 -0
  108. package/dist/server/instructions/condition.js +123 -0
  109. package/{src/server/instructions/create.ts → dist/server/instructions/create.js} +17 -17
  110. package/dist/server/instructions/delay.js +87 -0
  111. package/dist/server/instructions/destroy.js +24 -0
  112. package/dist/server/instructions/index.js +40 -0
  113. package/{src/server/instructions/loop.ts → dist/server/instructions/loop.js} +21 -43
  114. package/{src/server/instructions/manual/actions.ts → dist/server/instructions/manual/actions.js} +18 -44
  115. package/dist/server/instructions/manual/collecions/jobs.js +21 -0
  116. package/dist/server/instructions/manual/collecions/users.js +19 -0
  117. package/dist/server/instructions/manual/collecions/users_jobs.js +52 -0
  118. package/{src/server/instructions/manual/forms/create.ts → dist/server/instructions/manual/forms/create.js} +8 -8
  119. package/dist/server/instructions/manual/forms/index.js +16 -0
  120. package/{src/server/instructions/manual/forms/update.ts → dist/server/instructions/manual/forms/update.js} +8 -8
  121. package/dist/server/instructions/manual/index.js +160 -0
  122. package/dist/server/instructions/parallel.js +105 -0
  123. package/dist/server/instructions/query.js +36 -0
  124. package/dist/server/instructions/request.js +69 -0
  125. package/dist/server/instructions/sql.js +26 -0
  126. package/dist/server/instructions/update.js +24 -0
  127. package/{src/server/migrations/20221129153547-calculation-variables.ts → dist/server/migrations/20221129153547-calculation-variables.js} +20 -19
  128. package/dist/server/migrations/20230221032941-change-request-body-type.js +71 -0
  129. package/dist/server/migrations/20230221071831-calculation-expression.js +94 -0
  130. package/dist/server/migrations/20230221121203-condition-calculation.js +41 -0
  131. package/dist/server/migrations/20230221162902-jsonb-to-json.js +52 -0
  132. package/dist/server/migrations/20230411034722-manual-multi-form.js +252 -0
  133. package/dist/server/migrations/20230612021134-manual-collection-block.js +126 -0
  134. package/dist/server/migrations/20230710115902-manual-action-values.js +74 -0
  135. package/{src/server/triggers/collection.ts → dist/server/triggers/collection.js} +34 -64
  136. package/dist/server/triggers/index.js +27 -0
  137. package/{src/server/triggers/schedule.ts → dist/server/triggers/schedule.js} +108 -220
  138. package/dist/server/types/Execution.js +8 -0
  139. package/dist/server/types/FlowNode.js +8 -0
  140. package/dist/server/types/Job.js +8 -0
  141. package/dist/server/types/Workflow.js +8 -0
  142. package/dist/server/types/index.js +2 -0
  143. package/{lib → dist}/server/utils.js +6 -8
  144. package/package.json +26 -37
  145. package/server.d.ts +2 -3
  146. package/server.js +1 -1
  147. package/lib/client/AddButton.js +0 -161
  148. package/lib/client/Branch.js +0 -50
  149. package/lib/client/CanvasContent.js +0 -51
  150. package/lib/client/ExecutionCanvas.js +0 -218
  151. package/lib/client/ExecutionLink.js +0 -48
  152. package/lib/client/ExecutionPage.js +0 -68
  153. package/lib/client/ExecutionResourceProvider.js +0 -48
  154. package/lib/client/FlowContext.js +0 -21
  155. package/lib/client/WorkflowCanvas.js +0 -300
  156. package/lib/client/WorkflowLink.js +0 -48
  157. package/lib/client/WorkflowPage.js +0 -70
  158. package/lib/client/WorkflowProvider.js +0 -100
  159. package/lib/client/components/CollectionBlockInitializer.js +0 -103
  160. package/lib/client/components/CollectionFieldset.js +0 -198
  161. package/lib/client/components/Duration.js +0 -72
  162. package/lib/client/components/DynamicExpression.js +0 -117
  163. package/lib/client/components/FieldsSelect.js +0 -72
  164. package/lib/client/components/FilterDynamicComponent.js +0 -34
  165. package/lib/client/components/NodeDescription.js +0 -73
  166. package/lib/client/components/NullRender.js +0 -9
  167. package/lib/client/components/OpenDrawer.js +0 -68
  168. package/lib/client/components/RadioWithTooltip.js +0 -65
  169. package/lib/client/components/ValueBlock.js +0 -103
  170. package/lib/client/components/renderEngineReference.js +0 -49
  171. package/lib/client/constants.js +0 -126
  172. package/lib/client/index.js +0 -121
  173. package/lib/client/interfaces/expression.js +0 -38
  174. package/lib/client/locale/index.js +0 -42
  175. package/lib/client/nodes/aggregate.js +0 -353
  176. package/lib/client/nodes/calculation.js +0 -292
  177. package/lib/client/nodes/condition.js +0 -531
  178. package/lib/client/nodes/create.js +0 -110
  179. package/lib/client/nodes/delay.js +0 -47
  180. package/lib/client/nodes/destroy.js +0 -49
  181. package/lib/client/nodes/index.js +0 -550
  182. package/lib/client/nodes/loop.js +0 -171
  183. package/lib/client/nodes/manual/AssigneesSelect.js +0 -56
  184. package/lib/client/nodes/manual/DetailsBlockProvider.js +0 -106
  185. package/lib/client/nodes/manual/FormBlockInitializer.js +0 -107
  186. package/lib/client/nodes/manual/FormBlockProvider.js +0 -113
  187. package/lib/client/nodes/manual/ModeConfig.js +0 -126
  188. package/lib/client/nodes/manual/SchemaConfig.js +0 -468
  189. package/lib/client/nodes/manual/WorkflowTodo.js +0 -642
  190. package/lib/client/nodes/manual/WorkflowTodoBlockInitializer.js +0 -60
  191. package/lib/client/nodes/manual/forms/create.js +0 -111
  192. package/lib/client/nodes/manual/forms/custom.js +0 -428
  193. package/lib/client/nodes/manual/forms/update.js +0 -168
  194. package/lib/client/nodes/manual/index.js +0 -168
  195. package/lib/client/nodes/manual/utils.js +0 -31
  196. package/lib/client/nodes/parallel.js +0 -162
  197. package/lib/client/nodes/query.js +0 -112
  198. package/lib/client/nodes/request.js +0 -225
  199. package/lib/client/nodes/sql.js +0 -61
  200. package/lib/client/nodes/update.js +0 -127
  201. package/lib/client/schemas/collection.js +0 -93
  202. package/lib/client/schemas/executions.js +0 -190
  203. package/lib/client/schemas/workflows.js +0 -397
  204. package/lib/client/style.js +0 -350
  205. package/lib/client/triggers/collection.js +0 -188
  206. package/lib/client/triggers/index.js +0 -356
  207. package/lib/client/triggers/schedule/EndsByField.js +0 -71
  208. package/lib/client/triggers/schedule/OnField.js +0 -117
  209. package/lib/client/triggers/schedule/RepeatField.js +0 -155
  210. package/lib/client/triggers/schedule/ScheduleConfig.js +0 -251
  211. package/lib/client/triggers/schedule/constants.js +0 -11
  212. package/lib/client/triggers/schedule/index.js +0 -101
  213. package/lib/client/triggers/schedule/locale/Cron.zh-CN.js +0 -48
  214. package/lib/client/utils.js +0 -59
  215. package/lib/client/variable.js +0 -319
  216. package/lib/index.js +0 -13
  217. package/lib/locale/en-US.js +0 -136
  218. package/lib/locale/fr-FR.js +0 -136
  219. package/lib/locale/ja-JP.js +0 -94
  220. package/lib/locale/pt-BR.js +0 -136
  221. package/lib/locale/ru-RU.js +0 -94
  222. package/lib/locale/tr-TR.js +0 -94
  223. package/lib/locale/zh-CN.js +0 -219
  224. package/lib/server/Plugin.js +0 -382
  225. package/lib/server/Processor.js +0 -394
  226. package/lib/server/actions/index.js +0 -30
  227. package/lib/server/actions/nodes.js +0 -269
  228. package/lib/server/actions/workflows.js +0 -273
  229. package/lib/server/collections/executions.js +0 -33
  230. package/lib/server/collections/flow_nodes.js +0 -53
  231. package/lib/server/collections/jobs.js +0 -30
  232. package/lib/server/collections/workflows.js +0 -76
  233. package/lib/server/fields/expression-field.js +0 -19
  234. package/lib/server/fields/index.js +0 -12
  235. package/lib/server/functions/index.js +0 -26
  236. package/lib/server/index.js +0 -55
  237. package/lib/server/instructions/aggregate.js +0 -57
  238. package/lib/server/instructions/calculation.js +0 -59
  239. package/lib/server/instructions/condition.js +0 -150
  240. package/lib/server/instructions/create.js +0 -60
  241. package/lib/server/instructions/delay.js +0 -118
  242. package/lib/server/instructions/destroy.js +0 -37
  243. package/lib/server/instructions/index.js +0 -44
  244. package/lib/server/instructions/loop.js +0 -107
  245. package/lib/server/instructions/manual/actions.js +0 -99
  246. package/lib/server/instructions/manual/collecions/jobs.js +0 -21
  247. package/lib/server/instructions/manual/collecions/users.js +0 -19
  248. package/lib/server/instructions/manual/collecions/users_jobs.js +0 -46
  249. package/lib/server/instructions/manual/forms/create.js +0 -52
  250. package/lib/server/instructions/manual/forms/index.js +0 -15
  251. package/lib/server/instructions/manual/forms/update.js +0 -53
  252. package/lib/server/instructions/manual/index.js +0 -174
  253. package/lib/server/instructions/parallel.js +0 -128
  254. package/lib/server/instructions/query.js +0 -53
  255. package/lib/server/instructions/request.js +0 -99
  256. package/lib/server/instructions/sql.js +0 -34
  257. package/lib/server/instructions/update.js +0 -38
  258. package/lib/server/migrations/20221129153547-calculation-variables.js +0 -92
  259. package/lib/server/migrations/20230221032941-change-request-body-type.js +0 -90
  260. package/lib/server/migrations/20230221071831-calculation-expression.js +0 -111
  261. package/lib/server/migrations/20230221121203-condition-calculation.js +0 -103
  262. package/lib/server/migrations/20230221162902-jsonb-to-json.js +0 -64
  263. package/lib/server/migrations/20230411034722-manual-multi-form.js +0 -297
  264. package/lib/server/migrations/20230612021134-manual-collection-block.js +0 -155
  265. package/lib/server/migrations/20230710115902-manual-action-values.js +0 -97
  266. package/lib/server/triggers/collection.js +0 -175
  267. package/lib/server/triggers/index.js +0 -46
  268. package/lib/server/triggers/schedule.js +0 -582
  269. package/lib/server/types/Execution.js +0 -15
  270. package/lib/server/types/FlowNode.js +0 -15
  271. package/lib/server/types/Job.js +0 -15
  272. package/lib/server/types/Workflow.js +0 -15
  273. package/lib/server/types/index.js +0 -5
  274. package/src/client/AddButton.tsx +0 -111
  275. package/src/client/Branch.tsx +0 -37
  276. package/src/client/CanvasContent.tsx +0 -25
  277. package/src/client/ExecutionCanvas.tsx +0 -166
  278. package/src/client/ExecutionLink.tsx +0 -16
  279. package/src/client/ExecutionPage.tsx +0 -45
  280. package/src/client/ExecutionResourceProvider.tsx +0 -21
  281. package/src/client/FlowContext.ts +0 -7
  282. package/src/client/WorkflowCanvas.tsx +0 -221
  283. package/src/client/WorkflowLink.tsx +0 -16
  284. package/src/client/WorkflowPage.tsx +0 -52
  285. package/src/client/WorkflowProvider.tsx +0 -84
  286. package/src/client/components/CollectionBlockInitializer.tsx +0 -71
  287. package/src/client/components/CollectionFieldset.tsx +0 -152
  288. package/src/client/components/Duration.tsx +0 -45
  289. package/src/client/components/DynamicExpression.tsx +0 -57
  290. package/src/client/components/FieldsSelect.tsx +0 -32
  291. package/src/client/components/FilterDynamicComponent.tsx +0 -15
  292. package/src/client/components/NodeDescription.tsx +0 -51
  293. package/src/client/components/NullRender.tsx +0 -3
  294. package/src/client/components/OpenDrawer.tsx +0 -24
  295. package/src/client/components/RadioWithTooltip.tsx +0 -38
  296. package/src/client/components/ValueBlock.tsx +0 -67
  297. package/src/client/components/renderEngineReference.tsx +0 -30
  298. package/src/client/constants.tsx +0 -91
  299. package/src/client/index.tsx +0 -51
  300. package/src/client/interfaces/expression.tsx +0 -25
  301. package/src/client/locale/index.ts +0 -18
  302. package/src/client/nodes/aggregate.tsx +0 -327
  303. package/src/client/nodes/calculation.tsx +0 -216
  304. package/src/client/nodes/condition.tsx +0 -463
  305. package/src/client/nodes/create.tsx +0 -85
  306. package/src/client/nodes/delay.tsx +0 -37
  307. package/src/client/nodes/destroy.tsx +0 -34
  308. package/src/client/nodes/index.tsx +0 -500
  309. package/src/client/nodes/loop.tsx +0 -144
  310. package/src/client/nodes/manual/AssigneesSelect.tsx +0 -33
  311. package/src/client/nodes/manual/DetailsBlockProvider.tsx +0 -80
  312. package/src/client/nodes/manual/FormBlockInitializer.tsx +0 -69
  313. package/src/client/nodes/manual/FormBlockProvider.tsx +0 -75
  314. package/src/client/nodes/manual/ModeConfig.tsx +0 -84
  315. package/src/client/nodes/manual/SchemaConfig.tsx +0 -509
  316. package/src/client/nodes/manual/WorkflowTodo.tsx +0 -607
  317. package/src/client/nodes/manual/WorkflowTodoBlockInitializer.tsx +0 -28
  318. package/src/client/nodes/manual/forms/create.tsx +0 -92
  319. package/src/client/nodes/manual/forms/custom.tsx +0 -392
  320. package/src/client/nodes/manual/forms/update.tsx +0 -134
  321. package/src/client/nodes/manual/index.tsx +0 -162
  322. package/src/client/nodes/manual/utils.ts +0 -28
  323. package/src/client/nodes/parallel.tsx +0 -138
  324. package/src/client/nodes/query.tsx +0 -88
  325. package/src/client/nodes/request.tsx +0 -185
  326. package/src/client/nodes/sql.tsx +0 -37
  327. package/src/client/nodes/update.tsx +0 -100
  328. package/src/client/schemas/collection.ts +0 -75
  329. package/src/client/schemas/executions.tsx +0 -169
  330. package/src/client/schemas/workflows.ts +0 -364
  331. package/src/client/style.tsx +0 -350
  332. package/src/client/triggers/collection.tsx +0 -190
  333. package/src/client/triggers/index.tsx +0 -311
  334. package/src/client/triggers/schedule/EndsByField.tsx +0 -40
  335. package/src/client/triggers/schedule/OnField.tsx +0 -64
  336. package/src/client/triggers/schedule/RepeatField.tsx +0 -116
  337. package/src/client/triggers/schedule/ScheduleConfig.tsx +0 -227
  338. package/src/client/triggers/schedule/constants.ts +0 -4
  339. package/src/client/triggers/schedule/index.tsx +0 -78
  340. package/src/client/triggers/schedule/locale/Cron.zh-CN.ts +0 -79
  341. package/src/client/utils.ts +0 -36
  342. package/src/client/variable.tsx +0 -318
  343. package/src/index.ts +0 -1
  344. package/src/locale/en-US.ts +0 -136
  345. package/src/locale/es-ES.ts +0 -129
  346. package/src/locale/fr-FR.ts +0 -137
  347. package/src/locale/ja-JP.ts +0 -90
  348. package/src/locale/pt-BR.ts +0 -136
  349. package/src/locale/ru-RU.ts +0 -90
  350. package/src/locale/tr-TR.ts +0 -90
  351. package/src/locale/zh-CN.ts +0 -248
  352. package/src/server/Plugin.ts +0 -355
  353. package/src/server/__tests__/Plugin.test.ts +0 -398
  354. package/src/server/__tests__/Processor.test.ts +0 -474
  355. package/src/server/__tests__/actions/workflows.test.ts +0 -419
  356. package/src/server/__tests__/collections/categories.ts +0 -27
  357. package/src/server/__tests__/collections/comments.ts +0 -24
  358. package/src/server/__tests__/collections/posts.ts +0 -42
  359. package/src/server/__tests__/collections/replies.ts +0 -9
  360. package/src/server/__tests__/collections/tags.ts +0 -15
  361. package/src/server/__tests__/index.ts +0 -89
  362. package/src/server/__tests__/instructions/aggregate.test.ts +0 -294
  363. package/src/server/__tests__/instructions/calculation.test.ts +0 -265
  364. package/src/server/__tests__/instructions/condition.test.ts +0 -434
  365. package/src/server/__tests__/instructions/create.test.ts +0 -129
  366. package/src/server/__tests__/instructions/delay.test.ts +0 -182
  367. package/src/server/__tests__/instructions/destroy.test.ts +0 -58
  368. package/src/server/__tests__/instructions/loop.test.ts +0 -331
  369. package/src/server/__tests__/instructions/manual.test.ts +0 -1173
  370. package/src/server/__tests__/instructions/parallel.test.ts +0 -445
  371. package/src/server/__tests__/instructions/query.test.ts +0 -359
  372. package/src/server/__tests__/instructions/request.test.ts +0 -247
  373. package/src/server/__tests__/instructions/sql.test.ts +0 -162
  374. package/src/server/__tests__/instructions/update.test.ts +0 -189
  375. package/src/server/__tests__/triggers/collection.test.ts +0 -333
  376. package/src/server/__tests__/triggers/schedule.test.ts +0 -369
  377. package/src/server/actions/index.ts +0 -25
  378. package/src/server/collections/executions.ts +0 -35
  379. package/src/server/collections/flow_nodes.ts +0 -54
  380. package/src/server/collections/jobs.ts +0 -31
  381. package/src/server/collections/workflows.ts +0 -88
  382. package/src/server/constants.ts +0 -26
  383. package/src/server/fields/expression-field.ts +0 -11
  384. package/src/server/fields/index.ts +0 -7
  385. package/src/server/functions/index.ts +0 -16
  386. package/src/server/index.ts +0 -6
  387. package/src/server/instructions/aggregate.ts +0 -42
  388. package/src/server/instructions/calculation.ts +0 -41
  389. package/src/server/instructions/condition.ts +0 -172
  390. package/src/server/instructions/delay.ts +0 -105
  391. package/src/server/instructions/destroy.ts +0 -23
  392. package/src/server/instructions/index.ts +0 -64
  393. package/src/server/instructions/manual/collecions/jobs.ts +0 -17
  394. package/src/server/instructions/manual/collecions/users.ts +0 -15
  395. package/src/server/instructions/manual/collecions/users_jobs.ts +0 -50
  396. package/src/server/instructions/manual/forms/index.ts +0 -12
  397. package/src/server/instructions/manual/index.ts +0 -184
  398. package/src/server/instructions/parallel.ts +0 -121
  399. package/src/server/instructions/query.ts +0 -42
  400. package/src/server/instructions/request.ts +0 -88
  401. package/src/server/instructions/sql.ts +0 -25
  402. package/src/server/instructions/update.ts +0 -24
  403. package/src/server/migrations/20230221032941-change-request-body-type.ts +0 -76
  404. package/src/server/migrations/20230221071831-calculation-expression.ts +0 -102
  405. package/src/server/migrations/20230221121203-condition-calculation.ts +0 -82
  406. package/src/server/migrations/20230221162902-jsonb-to-json.ts +0 -51
  407. package/src/server/migrations/20230411034722-manual-multi-form.ts +0 -282
  408. package/src/server/migrations/20230612021134-manual-collection-block.ts +0 -138
  409. package/src/server/migrations/20230710115902-manual-action-values.ts +0 -78
  410. package/src/server/triggers/index.ts +0 -22
  411. package/src/server/types/Execution.ts +0 -26
  412. package/src/server/types/FlowNode.ts +0 -21
  413. package/src/server/types/Job.ts +0 -18
  414. package/src/server/types/Workflow.ts +0 -36
  415. package/src/server/types/index.ts +0 -4
  416. package/src/server/utils.ts +0 -17
  417. /package/{lib → dist}/client/AddButton.d.ts +0 -0
  418. /package/{lib → dist}/client/Branch.d.ts +0 -0
  419. /package/{lib → dist}/client/CanvasContent.d.ts +0 -0
  420. /package/{lib → dist}/client/ExecutionCanvas.d.ts +0 -0
  421. /package/{lib → dist}/client/ExecutionLink.d.ts +0 -0
  422. /package/{lib → dist}/client/ExecutionPage.d.ts +0 -0
  423. /package/{lib → dist}/client/ExecutionResourceProvider.d.ts +0 -0
  424. /package/{lib → dist}/client/FlowContext.d.ts +0 -0
  425. /package/{lib → dist}/client/WorkflowCanvas.d.ts +0 -0
  426. /package/{lib → dist}/client/WorkflowLink.d.ts +0 -0
  427. /package/{lib → dist}/client/WorkflowPage.d.ts +0 -0
  428. /package/{lib → dist}/client/WorkflowProvider.d.ts +0 -0
  429. /package/{lib → dist}/client/components/CollectionBlockInitializer.d.ts +0 -0
  430. /package/{lib → dist}/client/components/CollectionFieldset.d.ts +0 -0
  431. /package/{lib → dist}/client/components/Duration.d.ts +0 -0
  432. /package/{lib → dist}/client/components/DynamicExpression.d.ts +0 -0
  433. /package/{lib → dist}/client/components/FieldsSelect.d.ts +0 -0
  434. /package/{lib → dist}/client/components/FilterDynamicComponent.d.ts +0 -0
  435. /package/{lib → dist}/client/components/NodeDescription.d.ts +0 -0
  436. /package/{lib → dist}/client/components/NullRender.d.ts +0 -0
  437. /package/{lib → dist}/client/components/OpenDrawer.d.ts +0 -0
  438. /package/{lib → dist}/client/components/RadioWithTooltip.d.ts +0 -0
  439. /package/{lib → dist}/client/components/ValueBlock.d.ts +0 -0
  440. /package/{lib → dist}/client/components/renderEngineReference.d.ts +0 -0
  441. /package/{lib → dist}/client/constants.d.ts +0 -0
  442. /package/{lib → dist}/client/index.d.ts +0 -0
  443. /package/{lib → dist}/client/interfaces/expression.d.ts +0 -0
  444. /package/{lib → dist}/client/locale/index.d.ts +0 -0
  445. /package/{lib → dist}/client/nodes/calculation.d.ts +0 -0
  446. /package/{lib → dist}/client/nodes/condition.d.ts +0 -0
  447. /package/{lib → dist}/client/nodes/delay.d.ts +0 -0
  448. /package/{lib → dist}/client/nodes/index.d.ts +0 -0
  449. /package/{lib → dist}/client/nodes/loop.d.ts +0 -0
  450. /package/{lib → dist}/client/nodes/manual/AssigneesSelect.d.ts +0 -0
  451. /package/{lib → dist}/client/nodes/manual/DetailsBlockProvider.d.ts +0 -0
  452. /package/{lib → dist}/client/nodes/manual/FormBlockInitializer.d.ts +0 -0
  453. /package/{lib → dist}/client/nodes/manual/FormBlockProvider.d.ts +0 -0
  454. /package/{lib → dist}/client/nodes/manual/ModeConfig.d.ts +0 -0
  455. /package/{lib → dist}/client/nodes/manual/SchemaConfig.d.ts +0 -0
  456. /package/{lib → dist}/client/nodes/manual/WorkflowTodo.d.ts +0 -0
  457. /package/{lib → dist}/client/nodes/manual/WorkflowTodoBlockInitializer.d.ts +0 -0
  458. /package/{lib → dist}/client/nodes/manual/forms/create.d.ts +0 -0
  459. /package/{lib → dist}/client/nodes/manual/forms/custom.d.ts +0 -0
  460. /package/{lib → dist}/client/nodes/manual/forms/update.d.ts +0 -0
  461. /package/{lib → dist}/client/nodes/manual/index.d.ts +0 -0
  462. /package/{lib → dist}/client/nodes/manual/utils.d.ts +0 -0
  463. /package/{lib → dist}/client/nodes/parallel.d.ts +0 -0
  464. /package/{lib → dist}/client/nodes/sql.d.ts +0 -0
  465. /package/{lib → dist}/client/schemas/executions.d.ts +0 -0
  466. /package/{lib → dist}/client/schemas/workflows.d.ts +0 -0
  467. /package/{lib → dist}/client/style.d.ts +0 -0
  468. /package/{lib → dist}/client/triggers/index.d.ts +0 -0
  469. /package/{lib → dist}/client/triggers/schedule/EndsByField.d.ts +0 -0
  470. /package/{lib → dist}/client/triggers/schedule/OnField.d.ts +0 -0
  471. /package/{lib → dist}/client/triggers/schedule/RepeatField.d.ts +0 -0
  472. /package/{lib → dist}/client/triggers/schedule/ScheduleConfig.d.ts +0 -0
  473. /package/{lib → dist}/client/triggers/schedule/constants.d.ts +0 -0
  474. /package/{lib → dist}/client/triggers/schedule/index.d.ts +0 -0
  475. /package/{lib → dist}/client/triggers/schedule/locale/Cron.zh-CN.d.ts +0 -0
  476. /package/{lib → dist}/client/utils.d.ts +0 -0
  477. /package/{lib → dist}/client/variable.d.ts +0 -0
  478. /package/{lib → dist}/locale/en-US.d.ts +0 -0
  479. /package/{lib → dist}/locale/es-ES.d.ts +0 -0
  480. /package/{lib → dist}/locale/fr-FR.d.ts +0 -0
  481. /package/{lib → dist}/locale/ja-JP.d.ts +0 -0
  482. /package/{lib → dist}/locale/pt-BR.d.ts +0 -0
  483. /package/{lib → dist}/locale/ru-RU.d.ts +0 -0
  484. /package/{lib → dist}/locale/tr-TR.d.ts +0 -0
  485. /package/{lib → dist}/locale/zh-CN.d.ts +0 -0
  486. /package/{lib → dist}/server/Plugin.d.ts +0 -0
  487. /package/{lib → dist}/server/Processor.d.ts +0 -0
  488. /package/{lib → dist}/server/actions/index.d.ts +0 -0
  489. /package/{lib → dist}/server/actions/nodes.d.ts +0 -0
  490. /package/{lib → dist}/server/actions/workflows.d.ts +0 -0
  491. /package/{lib → dist}/server/collections/executions.d.ts +0 -0
  492. /package/{lib → dist}/server/collections/flow_nodes.d.ts +0 -0
  493. /package/{lib → dist}/server/collections/jobs.d.ts +0 -0
  494. /package/{lib → dist}/server/collections/workflows.d.ts +0 -0
  495. /package/{lib → dist}/server/constants.d.ts +0 -0
  496. /package/{lib → dist}/server/fields/expression-field.d.ts +0 -0
  497. /package/{lib → dist}/server/fields/index.d.ts +0 -0
  498. /package/{lib → dist}/server/functions/index.d.ts +0 -0
  499. /package/{lib → dist}/server/index.d.ts +0 -0
  500. /package/{lib → dist}/server/instructions/aggregate.d.ts +0 -0
  501. /package/{lib → dist}/server/instructions/calculation.d.ts +0 -0
  502. /package/{lib → dist}/server/instructions/condition.d.ts +0 -0
  503. /package/{lib → dist}/server/instructions/create.d.ts +0 -0
  504. /package/{lib → dist}/server/instructions/delay.d.ts +0 -0
  505. /package/{lib → dist}/server/instructions/destroy.d.ts +0 -0
  506. /package/{lib → dist}/server/instructions/index.d.ts +0 -0
  507. /package/{lib → dist}/server/instructions/loop.d.ts +0 -0
  508. /package/{lib → dist}/server/instructions/manual/actions.d.ts +0 -0
  509. /package/{lib → dist}/server/instructions/manual/collecions/jobs.d.ts +0 -0
  510. /package/{lib → dist}/server/instructions/manual/collecions/users.d.ts +0 -0
  511. /package/{lib → dist}/server/instructions/manual/collecions/users_jobs.d.ts +0 -0
  512. /package/{lib → dist}/server/instructions/manual/forms/create.d.ts +0 -0
  513. /package/{lib → dist}/server/instructions/manual/forms/index.d.ts +0 -0
  514. /package/{lib → dist}/server/instructions/manual/forms/update.d.ts +0 -0
  515. /package/{lib → dist}/server/instructions/manual/index.d.ts +0 -0
  516. /package/{lib → dist}/server/instructions/parallel.d.ts +0 -0
  517. /package/{lib → dist}/server/instructions/query.d.ts +0 -0
  518. /package/{lib → dist}/server/instructions/request.d.ts +0 -0
  519. /package/{lib → dist}/server/instructions/sql.d.ts +0 -0
  520. /package/{lib → dist}/server/instructions/update.d.ts +0 -0
  521. /package/{lib → dist}/server/migrations/20221129153547-calculation-variables.d.ts +0 -0
  522. /package/{lib → dist}/server/migrations/20230221032941-change-request-body-type.d.ts +0 -0
  523. /package/{lib → dist}/server/migrations/20230221071831-calculation-expression.d.ts +0 -0
  524. /package/{lib → dist}/server/migrations/20230221121203-condition-calculation.d.ts +0 -0
  525. /package/{lib → dist}/server/migrations/20230221162902-jsonb-to-json.d.ts +0 -0
  526. /package/{lib → dist}/server/migrations/20230411034722-manual-multi-form.d.ts +0 -0
  527. /package/{lib → dist}/server/migrations/20230612021134-manual-collection-block.d.ts +0 -0
  528. /package/{lib → dist}/server/migrations/20230710115902-manual-action-values.d.ts +0 -0
  529. /package/{lib → dist}/server/triggers/collection.d.ts +0 -0
  530. /package/{lib → dist}/server/triggers/index.d.ts +0 -0
  531. /package/{lib → dist}/server/triggers/schedule.d.ts +0 -0
  532. /package/{lib → dist}/server/types/Execution.d.ts +0 -0
  533. /package/{lib → dist}/server/types/FlowNode.d.ts +0 -0
  534. /package/{lib → dist}/server/types/Job.d.ts +0 -0
  535. /package/{lib → dist}/server/types/Workflow.d.ts +0 -0
  536. /package/{lib → dist}/server/types/index.d.ts +0 -0
  537. /package/{lib → dist}/server/utils.d.ts +0 -0
@@ -0,0 +1,1489 @@
1
+ var test = require('tap').test;
2
+ var CronExpression = require('../lib/expression');
3
+ var CronDate = require('../lib/date');
4
+
5
+ test('empty expression test', function(t) {
6
+ try {
7
+ var interval = CronExpression.parse('');
8
+ t.ok(interval, 'Interval parsed');
9
+
10
+ var date = new CronDate();
11
+ date.addMinute();
12
+
13
+ var next = interval.next();
14
+
15
+ t.ok(next, 'Found next scheduled interval');
16
+ t.equal(next.getMinutes(), date.getMinutes(), 'Schedule matches');
17
+
18
+ t.end();
19
+ } catch (err) {
20
+ t.error(err, 'Interval parse error');
21
+ }
22
+ });
23
+
24
+ test('default expression test', function(t) {
25
+ try {
26
+ var interval = CronExpression.parse('* * * * *');
27
+ t.ok(interval, 'Interval parsed');
28
+
29
+ var date = new CronDate();
30
+ date.addMinute();
31
+
32
+ var next = interval.next();
33
+
34
+ t.ok(next, 'Found next scheduled interval');
35
+ t.equal(next.getMinutes(), date.getMinutes(), 'Schedule matches');
36
+
37
+ } catch (err) {
38
+ t.error(err, 'Interval parse error');
39
+ }
40
+
41
+ t.end();
42
+ });
43
+
44
+ test('default expression (tab separate) test', function(t) {
45
+ try {
46
+ var interval = CronExpression.parse('* * * * *');
47
+ t.ok(interval, 'Interval parsed');
48
+
49
+ var date = new CronDate();
50
+ date.addMinute();
51
+
52
+ var next = interval.next();
53
+
54
+ t.ok(next, 'Found next scheduled interval');
55
+ t.equal(next.getMinutes(), date.getMinutes(), 'Schedule matches');
56
+
57
+ } catch (err) {
58
+ t.error(err, 'Interval parse error');
59
+ }
60
+
61
+ t.end();
62
+ });
63
+
64
+ test('default expression (multi-space separated) test 1', function(t) {
65
+ try {
66
+ var interval = CronExpression.parse('* \t*\t\t *\t * \t\t*');
67
+ t.ok(interval, 'Interval parsed');
68
+
69
+ var date = new CronDate();
70
+ date.addMinute();
71
+
72
+ var next = interval.next();
73
+
74
+ t.ok(next, 'Found next scheduled interval');
75
+ t.equal(next.getMinutes(), date.getMinutes(), 'Schedule matches');
76
+
77
+ } catch (err) {
78
+ t.error(err, 'Interval parse error');
79
+ }
80
+
81
+ t.end();
82
+ });
83
+
84
+
85
+ test('default expression (multi-space separated) test 1', function(t) {
86
+ try {
87
+ var interval = CronExpression.parse('* \t *\t \t * * \t \t *');
88
+ t.ok(interval, 'Interval parsed');
89
+
90
+ var date = new CronDate();
91
+ date.addMinute();
92
+
93
+ var next = interval.next();
94
+
95
+ t.ok(next, 'Found next scheduled interval');
96
+ t.equal(next.getMinutes(), date.getMinutes(), 'Schedule matches');
97
+
98
+ } catch (err) {
99
+ t.error(err, 'Interval parse error');
100
+ }
101
+
102
+ t.end();
103
+ });
104
+
105
+ test('value out of the range', function(t) {
106
+ t.throws(function() {
107
+ CronExpression.parse('61 * * * * *');
108
+ }, new Error('Constraint error, got value 61 expected range 0-59'));
109
+
110
+ t.end();
111
+ });
112
+
113
+ test('second value out of the range', function(t) {
114
+ t.throws(function() {
115
+ CronExpression.parse('-1 * * * * *');
116
+ }, new Error('Constraint error, got value -1 expected range 0-59'));
117
+
118
+ t.end();
119
+ });
120
+
121
+ test('invalid range', function(t) {
122
+ t.throws(function() {
123
+ CronExpression.parse('- * * * * *');
124
+ }, new Error('Invalid range: -'));
125
+
126
+ t.end();
127
+ });
128
+
129
+ test('minute value out of the range', function(t) {
130
+ t.throws(function() {
131
+ CronExpression.parse('* 32,72 * * * *');
132
+ }, new Error('Constraint error, got value 72 expected range 0-59'));
133
+
134
+ t.end();
135
+ });
136
+
137
+ test('hour value out of the range', function(t) {
138
+ t.throws(function() {
139
+ CronExpression.parse('* * 12-36 * * *');
140
+ }, new Error('Constraint error, got range 12-36 expected range 0-23'));
141
+
142
+ t.end();
143
+ });
144
+
145
+
146
+ test('day of the month value out of the range', function(t) {
147
+ t.throws(function() {
148
+ CronExpression.parse('* * * 10-15,40 * *');
149
+ }, ('Constraint error, got value 40 expected range 1-31'));
150
+
151
+ t.end();
152
+ });
153
+
154
+ test('month value out of the range', function(t) {
155
+ t.throws(function() {
156
+ CronExpression.parse('* * * * */10,12-13 *');
157
+ }, new Error('Constraint error, got range 12-13 expected range 1-12'));
158
+
159
+ t.end();
160
+ });
161
+
162
+ test('day of the week value out of the range', function(t) {
163
+ t.throws(function() {
164
+ CronExpression.parse('* * * * * 9');
165
+ }, new Error('Constraint error, got value 9 expected range 0-7'));
166
+
167
+ t.end();
168
+ });
169
+
170
+ test('invalid expression that contains too many fields', function (t) {
171
+ t.throws(function() {
172
+ CronExpression.parse('* * * * * * * *ASD');
173
+ }, new Error('Invalid cron expression'));
174
+
175
+ t.end();
176
+ });
177
+
178
+ test('invalid explicit day of month definition', function(t) {
179
+ t.throws(function() {
180
+ const iter = CronExpression.parse('0 0 31 4 *');
181
+ iter.next();
182
+ }, new Error('Invalid explicit day of month definition'));
183
+
184
+ t.end();
185
+ });
186
+
187
+ test('incremental minutes expression test', function(t) {
188
+ try {
189
+ var interval = CronExpression.parse('*/3 * * * *');
190
+ t.ok(interval, 'Interval parsed');
191
+
192
+ var next = interval.next();
193
+
194
+ t.ok(next, 'Found next scheduled interval');
195
+ t.equal(next.getMinutes() % 3, 0, 'Schedule matches');
196
+ } catch (err) {
197
+ t.error(err, 'Interval parse error');
198
+ }
199
+
200
+ t.end();
201
+ });
202
+
203
+ test('fixed expression test', function(t) {
204
+ try {
205
+ var interval = CronExpression.parse('10 2 12 8 0');
206
+ t.ok(interval, 'Interval parsed');
207
+
208
+ var next = interval.next();
209
+
210
+ t.ok(next, 'Found next scheduled interval');
211
+ t.ok(next.getDay() === 0 || next.getDate() === 12, 'Day or day of Month matches');
212
+ t.equal(next.getMonth(), 7, 'Month matches');
213
+ t.equal(next.getHours(), 2, 'Hour matches');
214
+ t.equal(next.getMinutes(), 10, 'Minute matches');
215
+ } catch (err) {
216
+ t.error(err, 'Interval parse error');
217
+ }
218
+
219
+ t.end();
220
+ });
221
+
222
+ test('invalid characters test - symbol', function(t) {
223
+ t.throws(function() {
224
+ CronExpression.parse('10 ! 12 8 0');
225
+ }, new Error('Invalid characters, got value: !'));
226
+
227
+ t.end();
228
+ });
229
+
230
+ test('invalid characters test - letter', function(t) {
231
+ t.throws(function() {
232
+ CronExpression.parse('10 x 12 8 0');
233
+ }, new Error('Invalid characters, got value: x'));
234
+
235
+ t.end();
236
+ });
237
+
238
+ test('invalid characters test - parentheses', function(t) {
239
+ t.throws(function() {
240
+ CronExpression.parse('10 ) 12 8 0');
241
+ }, new Error('Invalid characters, got value: )'));
242
+
243
+ t.end();
244
+ });
245
+
246
+ test('interval with invalid characters test', function(t) {
247
+ t.throws(function() {
248
+ CronExpression.parse('10 */A 12 8 0');
249
+ }, new Error('Invalid characters, got value: */A'));
250
+
251
+ t.end();
252
+ });
253
+
254
+ test('range with invalid characters test', function(t) {
255
+ t.throws(function() {
256
+ CronExpression.parse('10 0-z 12 8 0');
257
+ }, new Error('Invalid characters, got value: 0-z'));
258
+
259
+ t.end();
260
+ });
261
+
262
+ test('group with invalid characters test', function(t) {
263
+ t.throws(function() {
264
+ CronExpression.parse('10 0,1,z 12 8 0');
265
+ }, new Error('Invalid characters, got value: 0,1,z'));
266
+
267
+ t.end();
268
+ });
269
+
270
+ test('invalid expression which has repeat 0 times', function(t) {
271
+ t.throws(function() {
272
+ CronExpression.parse('0 */0 * * *');
273
+ }, new Error('Constraint error, cannot repeat at every 0 time.'));
274
+
275
+ t.end();
276
+ });
277
+
278
+ test('invalid expression which has repeat negative number times', function(t) {
279
+ t.throws(function() {
280
+ CronExpression.parse('0 */-5 * * *');
281
+ }, new Error('Constraint error, cannot repeat at every -5 time.'));
282
+
283
+ t.end();
284
+ });
285
+
286
+ test('range test with value and repeat (second)', function(t) {
287
+ var options = {
288
+ currentDate: new CronDate('Wed, 26 Dec 2012 14:38:53')
289
+ };
290
+ var interval = CronExpression.parse('0/30 * * * * ?', options);
291
+ t.ok(interval, 'Interval parsed');
292
+
293
+ var next = interval.next();
294
+ t.equal(next.getSeconds(), 0);
295
+
296
+ next = interval.next();
297
+ t.equal(next.getSeconds(), 30);
298
+
299
+ next = interval.next();
300
+ t.equal(next.getSeconds(), 0);
301
+
302
+ t.end();
303
+ });
304
+
305
+ test('range test with value and repeat (minute)', function(t) {
306
+ var options = {
307
+ currentDate: new CronDate('Wed, 26 Dec 2012 14:38:53')
308
+ };
309
+ var interval = CronExpression.parse('6/23 * * * *', options);
310
+ t.ok(interval, 'Interval parsed');
311
+
312
+ var next = interval.next();
313
+ t.equal(next.getMinutes(), 52);
314
+
315
+ next = interval.next();
316
+ t.equal(next.getMinutes(), 6);
317
+
318
+ next = interval.next();
319
+ t.equal(next.getMinutes(), 29);
320
+
321
+ next = interval.next();
322
+ t.equal(next.getMinutes(), 52);
323
+
324
+ t.end();
325
+ });
326
+
327
+ test('range test with iterator', function(t) {
328
+ try {
329
+ var interval = CronExpression.parse('10-30 2 12 8 0');
330
+ t.ok(interval, 'Interval parsed');
331
+
332
+ var intervals = interval.iterate(20);
333
+ t.ok(intervals, 'Found intervals');
334
+
335
+ for (var i = 0, c = intervals.length; i < c; i++) {
336
+ var next = intervals[i];
337
+
338
+ t.ok(next, 'Found next scheduled interval');
339
+ t.ok(next.getDay() === 0 || next.getDate() === 12, 'Day or day of month matches');
340
+ t.equal(next.getMonth(), 7, 'Month matches');
341
+ t.equal(next.getHours(), 2, 'Hour matches');
342
+ t.equal(next.getMinutes(), 10 + i, 'Minute matches');
343
+ }
344
+ } catch (err) {
345
+ t.error(err, 'Interval parse error');
346
+ }
347
+
348
+ t.end();
349
+ });
350
+
351
+ test('incremental range test with iterator', function(t) {
352
+ try {
353
+ var interval = CronExpression.parse('10-30/2 2 12 8 0');
354
+ t.ok(interval, 'Interval parsed');
355
+
356
+ var intervals = interval.iterate(10);
357
+ t.ok(intervals, 'Found intervals');
358
+
359
+ for (var i = 0, c = intervals.length; i < c; i++) {
360
+ var next = intervals[i];
361
+
362
+ t.ok(next, 'Found next scheduled interval');
363
+ t.ok(next.getDay() === 0 || next.getDate() === 12, 'Day or day of month matches');
364
+ t.equal(next.getMonth(), 7, 'Month matches');
365
+ t.equal(next.getHours(), 2, 'Hour matches');
366
+ t.equal(next.getMinutes(), 10 + (i * 2), 'Minute matches');
367
+ }
368
+ } catch (err) {
369
+ t.error(err, 'Interval parse error');
370
+ }
371
+
372
+ t.end();
373
+ });
374
+
375
+ test('predefined expression', function(t) {
376
+ try {
377
+ var interval = CronExpression.parse('@yearly');
378
+ t.ok(interval, 'Interval parsed');
379
+
380
+ var date = new CronDate();
381
+ date.addYear();
382
+
383
+ var next = interval.next();
384
+ t.ok(next, 'Found next scheduled interval');
385
+
386
+ t.equal(next.getFullYear(), date.getFullYear(), 'Year matches');
387
+ } catch (err) {
388
+ t.error(err, 'Interval parse error');
389
+ }
390
+
391
+ t.end();
392
+ });
393
+
394
+ test('expression limited with start and end date', function(t) {
395
+ try {
396
+ var options = {
397
+ currentDate: new CronDate('Wed, 26 Dec 2012 14:38:53'),
398
+ startDate: new CronDate('Wed, 26 Dec 2012 12:40:00'),
399
+ endDate: new CronDate('Wed, 26 Dec 2012 16:40:00')
400
+ };
401
+
402
+ var interval = CronExpression.parse('*/20 * * * *', options);
403
+ t.ok(interval, 'Interval parsed');
404
+
405
+ var dates = interval.iterate(10);
406
+ t.equal(dates.length, 7, 'Dates count matches for positive iteration');
407
+
408
+ interval.reset();
409
+
410
+ var dates = interval.iterate(-10);
411
+ t.equal(dates.length, 6, 'Dates count matches for negative iteration');
412
+
413
+ interval.reset();
414
+
415
+ // Forward iteration
416
+ var next = interval.next();
417
+ t.equal(next.getHours(), 14, 'Hour matches');
418
+ t.equal(next.getMinutes(), 40, 'Minute matches');
419
+
420
+ next = interval.next();
421
+ t.equal(next.getHours(), 15, 'Hour matches');
422
+ t.equal(next.getMinutes(), 0, 'Minute matches');
423
+
424
+ next = interval.next();
425
+ t.equal(next.getHours(), 15, 'Hour matches');
426
+ t.equal(next.getMinutes(), 20, 'Minute matches');
427
+
428
+ next = interval.next();
429
+ t.equal(next.getHours(), 15, 'Hour matches');
430
+ t.equal(next.getMinutes(), 40, 'Minute matches');
431
+
432
+ next = interval.next();
433
+ t.equal(next.getHours(), 16, 'Hour matches');
434
+ t.equal(next.getMinutes(), 0, 'Minute matches');
435
+
436
+ next = interval.next();
437
+ t.equal(next.getHours(), 16, 'Hour matches');
438
+ t.equal(next.getMinutes(), 20, 'Minute matches');
439
+
440
+ next = interval.next();
441
+ t.equal(next.getHours(), 16, 'Hour matches');
442
+ t.equal(next.getMinutes(), 40, 'Minute matches');
443
+
444
+ try {
445
+ interval.next();
446
+ t.ok(false, 'Should fail');
447
+ } catch (e) {
448
+ t.ok(true, 'Failed as expected');
449
+ }
450
+
451
+ next = interval.prev();
452
+ t.equal(next.getHours(), 16, 'Hour matches');
453
+ t.equal(next.getMinutes(), 20, 'Minute matches');
454
+
455
+ interval.reset();
456
+
457
+ // Backward iteration
458
+ var prev = interval.prev();
459
+ t.equal(prev.getHours(), 14, 'Hour matches');
460
+ t.equal(prev.getMinutes(), 20, 'Minute matches');
461
+
462
+ prev = interval.prev();
463
+ t.equal(prev.getHours(), 14, 'Hour matches');
464
+ t.equal(prev.getMinutes(), 0, 'Minute matches');
465
+
466
+ prev = interval.prev();
467
+ t.equal(prev.getHours(), 13, 'Hour matches');
468
+ t.equal(prev.getMinutes(), 40, 'Minute matches');
469
+
470
+ prev = interval.prev();
471
+ t.equal(prev.getHours(), 13, 'Hour matches');
472
+ t.equal(prev.getMinutes(), 20, 'Minute matches');
473
+
474
+ prev = interval.prev();
475
+ t.equal(prev.getHours(), 13, 'Hour matches');
476
+ t.equal(prev.getMinutes(), 0, 'Minute matches');
477
+
478
+ prev = interval.prev();
479
+ t.equal(prev.getHours(), 12, 'Hour matches');
480
+ t.equal(prev.getMinutes(), 40, 'Minute matches');
481
+
482
+ try {
483
+ interval.prev();
484
+ t.ok(false, 'Should fail');
485
+ } catch (e) {
486
+ t.ok(true, 'Failed as expected');
487
+ }
488
+ } catch (err) {
489
+ t.error(err, 'Interval parse error');
490
+ }
491
+
492
+ t.end();
493
+ });
494
+
495
+ test('reset to given date', function(t){
496
+ try {
497
+ var options = {
498
+ currentDate: new CronDate('Wed, 26 Dec 2012 14:38:53')
499
+ };
500
+
501
+ var interval = CronExpression.parse('*/20 * * * *', options);
502
+ t.ok(interval, 'Interval parsed');
503
+
504
+ // Forward iteration
505
+ var next = interval.next();
506
+ t.equal(next.getHours(), 14, 'Hour matches');
507
+ t.equal(next.getMinutes(), 40, 'Minute matches');
508
+
509
+ interval.reset(); // defaults to initial currentDate
510
+
511
+ next = interval.next();
512
+ t.equal(next.getHours(), 14, 'Hour matches');
513
+ t.equal(next.getMinutes(), 40, 'Minute matches');
514
+
515
+ interval.reset(new CronDate('Wed, 26 Dec 2012 17:23:53'));
516
+
517
+ next = interval.next();
518
+ t.equal(next.getHours(), 17, 'Hour matches');
519
+ t.equal(next.getMinutes(), 40, 'Minute matches');
520
+
521
+ next = interval.next();
522
+ t.equal(next.getHours(), 18, 'Hour matches');
523
+ t.equal(next.getMinutes(), 0, 'Minute matches');
524
+
525
+ interval.reset(new Date('2019-06-18T08:18:36.000'));
526
+
527
+ next = interval.prev();
528
+ t.equal(next.getDate(), 18, 'Date matches');
529
+ t.equal(next.getHours(), 8, 'Hour matches');
530
+ t.equal(next.getMinutes(), 0, 'Minute matches');
531
+
532
+ next = interval.prev();
533
+ t.equal(next.getDate(), 18, 'Date matches');
534
+ t.equal(next.getHours(), 7, 'Hour matches');
535
+ t.equal(next.getMinutes(), 40, 'Minute matches');
536
+
537
+ t.end();
538
+ } catch (err) {
539
+ t.error(err, 'Reset error');
540
+ }
541
+ });
542
+
543
+ test('parse expression as UTC', function(t) {
544
+ try {
545
+ var options = {
546
+ utc: true
547
+ };
548
+
549
+ var interval = CronExpression.parse('0 0 10 * * *', options);
550
+
551
+ var date = interval.next();
552
+ t.equal(date.getUTCHours(), 10, 'Correct UTC hour value');
553
+ t.equal(date.getHours(), 10, 'Correct UTC hour value');
554
+
555
+ interval = CronExpression.parse('0 */5 * * * *', options);
556
+
557
+ var date = interval.next(), now = new Date();
558
+ now.setMinutes(now.getMinutes() + 5 - (now.getMinutes() % 5));
559
+
560
+ t.equal(date.getHours(), now.getUTCHours(), 'Correct local time for 5 minute interval');
561
+
562
+ } catch (err) {
563
+ t.error(err, 'UTC parse error');
564
+ }
565
+
566
+ t.end();
567
+ });
568
+
569
+ test('expression using days of week strings', function(t) {
570
+ try {
571
+ var interval = CronExpression.parse('15 10 * * MON-TUE');
572
+ t.ok(interval, 'Interval parsed');
573
+
574
+ var intervals = interval.iterate(8);
575
+ t.ok(intervals, 'Found intervals');
576
+
577
+ for (var i = 0, c = intervals.length; i < c; i++) {
578
+ var next = intervals[i];
579
+ var day = next.getDay();
580
+
581
+
582
+ t.ok(next, 'Found next scheduled interval');
583
+ t.ok(day == 1 || day == 2, 'Day matches');
584
+ t.equal(next.getHours(), 10, 'Hour matches');
585
+ t.equal(next.getMinutes(), 15, 'Minute matches');
586
+ }
587
+ } catch (err) {
588
+ t.error(err, 'Interval parse error');
589
+ }
590
+
591
+ t.end();
592
+ });
593
+
594
+ test('expression using days of week strings - wrong alias', function(t) {
595
+ t.throws(function () {
596
+ CronExpression.parse('15 10 * * MON-TUR');
597
+ }, new Error('Validation error, cannot resolve alias "tur"'));
598
+
599
+ t.end();
600
+ });
601
+
602
+ test('expression using mixed days of week strings', function(t) {
603
+ try {
604
+ var options = {
605
+ currentDate: new CronDate('Wed, 26 Dec 2012 14:38:53')
606
+ };
607
+
608
+ var interval = CronExpression.parse('15 10 * jAn-FeB mOn-tUE', options);
609
+ t.ok(interval, 'Interval parsed');
610
+
611
+ var intervals = interval.iterate(8);
612
+ t.ok(intervals, 'Found intervals');
613
+
614
+ for (var i = 0, c = intervals.length; i < c; i++) {
615
+ var next = intervals[i];
616
+ var day = next.getDay();
617
+ var month = next.getMonth();
618
+
619
+ t.ok(next, 'Found next scheduled interval');
620
+ t.ok(month == 0 || month == 2, 'Month Matches');
621
+ t.ok(day == 1 || day == 2, 'Day matches');
622
+ t.equal(next.getHours(), 10, 'Hour matches');
623
+ t.equal(next.getMinutes(), 15, 'Minute matches');
624
+ }
625
+ } catch (err) {
626
+ t.error(err, 'Interval parse error');
627
+ }
628
+
629
+ t.end();
630
+ });
631
+
632
+ test('expression using non-standard second field (wildcard)', function(t) {
633
+ try {
634
+ var options = {
635
+ currentDate: new CronDate('Wed, 26 Dec 2012 14:38:00'),
636
+ endDate: new CronDate('Wed, 26 Dec 2012 15:40:00')
637
+ };
638
+
639
+ var interval = CronExpression.parse('* * * * * *', options);
640
+ t.ok(interval, 'Interval parsed');
641
+
642
+ var intervals = interval.iterate(10);
643
+ t.ok(intervals, 'Found intervals');
644
+
645
+ for (var i = 0, c = intervals.length; i < c; i++) {
646
+ var next = intervals[i];
647
+ t.ok(next, 'Found next scheduled interval');
648
+ t.equal(next.getSeconds(), i + 1, 'Second matches');
649
+ }
650
+ } catch (err) {
651
+ t.error(err, 'Interval parse error');
652
+ }
653
+
654
+ t.end();
655
+ });
656
+
657
+ test('expression using non-standard second field (step)', function(t) {
658
+ try {
659
+ var options = {
660
+ currentDate: new CronDate('Wed, 26 Dec 2012 14:38:00'),
661
+ endDate: new CronDate('Wed, 26 Dec 2012 15:40:00')
662
+ };
663
+
664
+ var interval = CronExpression.parse('*/20 * * * * *', options);
665
+ t.ok(interval, 'Interval parsed');
666
+
667
+ var intervals = interval.iterate(3);
668
+ t.ok(intervals, 'Found intervals');
669
+
670
+ t.equal(intervals[0].getSeconds(), 20, 'Second matches');
671
+ t.equal(intervals[1].getSeconds(), 40, 'Second matches');
672
+ t.equal(intervals[2].getSeconds(), 0, 'Second matches');
673
+ } catch (err) {
674
+ t.error(err, 'Interval parse error');
675
+ }
676
+
677
+ t.end();
678
+ });
679
+
680
+ test('expression using non-standard second field (range)', function(t) {
681
+ try {
682
+ var options = {
683
+ currentDate: new CronDate('Wed, 26 Dec 2012 14:38:00'),
684
+ endDate: new CronDate('Wed, 26 Dec 2012 15:40:00')
685
+ };
686
+
687
+ var interval = CronExpression.parse('20-40/10 * * * * *', options);
688
+ t.ok(interval, 'Interval parsed');
689
+
690
+ var intervals = interval.iterate(3);
691
+ t.ok(intervals, 'Found intervals');
692
+
693
+ for (var i = 0, c = intervals.length; i < c; i++) {
694
+ var next = intervals[i];
695
+
696
+ t.ok(next, 'Found next scheduled interval');
697
+ t.equal(next.getSeconds(), 20 + (i * 10), 'Second matches');
698
+ }
699
+ } catch (err) {
700
+ t.error(err, 'Interval parse error');
701
+ }
702
+
703
+ t.end();
704
+ });
705
+
706
+ test('expression using explicit month definition and */5 day of month step', function(t) {
707
+ var firstIterator = CronExpression.parse('0 12 */5 6 *', {
708
+ currentDate: '2019-06-01T11:00:00.000'
709
+ });
710
+
711
+ var firstExpectedDates = [
712
+ new CronDate('2019-06-01T12:00:00.000'),
713
+ new CronDate('2019-06-06T12:00:00.000'),
714
+ new CronDate('2019-06-11T12:00:00.000'),
715
+ new CronDate('2019-06-16T12:00:00.000'),
716
+ new CronDate('2019-06-21T12:00:00.000'),
717
+ new CronDate('2019-06-26T12:00:00.000'),
718
+ new CronDate('2020-06-01T12:00:00.000')
719
+ ];
720
+
721
+ firstExpectedDates.forEach(function(expectedDate) {
722
+ t.equal(expectedDate.toISOString(), firstIterator.next().toISOString());
723
+ });
724
+
725
+ var secondIterator = CronExpression.parse('0 15 */5 5 *', {
726
+ currentDate: '2019-05-01T11:00:00.000'
727
+ });
728
+
729
+ var secondExpectedDates = [
730
+ new CronDate('2019-05-01T15:00:00.000'),
731
+ new CronDate('2019-05-06T15:00:00.000'),
732
+ new CronDate('2019-05-11T15:00:00.000'),
733
+ new CronDate('2019-05-16T15:00:00.000'),
734
+ new CronDate('2019-05-21T15:00:00.000'),
735
+ new CronDate('2019-05-26T15:00:00.000'),
736
+ new CronDate('2019-05-31T15:00:00.000'),
737
+ new CronDate('2020-05-01T15:00:00.000')
738
+ ];
739
+
740
+ secondExpectedDates.forEach(function(expectedDate) {
741
+ t.equal(expectedDate.toISOString(), secondIterator.next().toISOString());
742
+ });
743
+
744
+ t.end();
745
+ });
746
+
747
+ test('day of month and week are both set', function(t) {
748
+ try {
749
+ var interval = CronExpression.parse('10 2 12 8 0');
750
+ t.ok(interval, 'Interval parsed');
751
+
752
+ var next = interval.next();
753
+
754
+ t.ok(next, 'Found next scheduled interval');
755
+ t.ok(next.getDay() === 0 || next.getDate() === 12, 'Day or day of month matches');
756
+ t.equal(next.getMonth(), 7, 'Month matches');
757
+
758
+ next = interval.next();
759
+
760
+ t.ok(next, 'Found next scheduled interval');
761
+ t.ok(next.getDay() === 0 || next.getDate() === 12, 'Day or day of month matches');
762
+ t.equal(next.getMonth(), 7, 'Month matches');
763
+
764
+ next = interval.next();
765
+
766
+ t.ok(next, 'Found next scheduled interval');
767
+ t.ok(next.getDay() === 0 || next.getDate() === 12, 'Day or day of month matches');
768
+ t.equal(next.getMonth(), 7, 'Month matches');
769
+
770
+ next = interval.next();
771
+
772
+ t.ok(next, 'Found next scheduled interval');
773
+ t.ok(next.getDay() === 0 || next.getDate() === 12, 'Day or day of month matches');
774
+ t.equal(next.getMonth(), 7, 'Month matches');
775
+ } catch (err) {
776
+ t.error(err, 'Interval parse error');
777
+ }
778
+
779
+ t.end();
780
+ });
781
+
782
+ test('day of month is unspecified', function(t) {
783
+ try {
784
+ var interval = CronExpression.parse('10 2 ? * 3');
785
+
786
+ t.ok(interval, 'Interval parsed');
787
+
788
+ var next = interval.next();
789
+ t.ok(next, 'Found next scheduled interal');
790
+ t.ok(next.getDay() === 3, 'day of week matches');
791
+
792
+ next = interval.next();
793
+ t.ok(next, 'Found next scheduled interal');
794
+ t.ok(next.getDay() === 3, 'day of week matches');
795
+
796
+ next = interval.next();
797
+ t.ok(next, 'Found next scheduled interal');
798
+ t.ok(next.getDay() === 3, 'day of week matches');
799
+
800
+ next = interval.next();
801
+ t.ok(next, 'Found next scheduled interal');
802
+ t.ok(next.getDay() === 3, 'day of week matches');
803
+
804
+ } catch (err) {
805
+ t.error(err, 'Interval parse error');
806
+ }
807
+
808
+ t.end();
809
+ });
810
+
811
+ test('day of week is unspecified', function(t) {
812
+ try {
813
+ var interval = CronExpression.parse('10 2 3,6 * ?');
814
+
815
+ t.ok(interval, 'Interval parsed');
816
+
817
+ var next = interval.next();
818
+ t.ok(next, 'Found next scheduled interal');
819
+ t.ok(next.getDate() === 3 || next.getDate() === 6, 'date matches');
820
+ var prevDate = next.getDate();
821
+
822
+ next = interval.next();
823
+ t.ok(next, 'Found next scheduled interal');
824
+ t.ok((next.getDate() === 3 || next.getDate() === 6) &&
825
+ next.getDate() !== prevDate, 'date matches and is not previous date');
826
+ prevDate = next.getDate();
827
+
828
+ next = interval.next();
829
+ t.ok(next, 'Found next scheduled interal');
830
+ t.ok((next.getDate() === 3 || next.getDate() === 6) &&
831
+ next.getDate() !== prevDate, 'date matches and is not previous date');
832
+ prevDate = next.getDate();
833
+
834
+ next = interval.next();
835
+ t.ok(next, 'Found next scheduled interal');
836
+ t.ok((next.getDate() === 3 || next.getDate() === 6) &&
837
+ next.getDate() !== prevDate, 'date matches and is not previous date');
838
+ } catch (err) {
839
+ t.error(err, 'Interval parse error');
840
+ }
841
+
842
+ t.end();
843
+ });
844
+
845
+ test('Summertime bug test', function(t) {
846
+ try {
847
+ var month = new CronDate().getMonth() + 1;
848
+ var interval = CronExpression.parse('0 0 0 1 '+month+' *');
849
+ t.ok(interval, 'Interval parsed');
850
+
851
+ var next = interval.next();
852
+
853
+ // Before fix the bug it was getting a timeout error if you are
854
+ // in a timezone that changes the DST to ST in the hour 00:00h.
855
+ t.ok(next, 'Found next scheduled interval');
856
+ } catch (err) {
857
+ t.error(err, 'Interval parse error');
858
+ }
859
+
860
+ t.end();
861
+ });
862
+
863
+
864
+ test('day of month and week are both set and dow is 7', function(t) {
865
+ try {
866
+ var interval = CronExpression.parse('10 2 12 8 7');
867
+ t.ok(interval, 'Interval parsed');
868
+
869
+ var next = interval.next();
870
+
871
+ t.ok(next, 'Found next scheduled interval');
872
+ t.ok(next.getDay() === 0 || next.getDate() === 12, 'Day or day of month matches');
873
+ t.equal(next.getMonth(), 7, 'Month matches');
874
+
875
+ next = interval.next();
876
+
877
+ t.ok(next, 'Found next scheduled interval');
878
+ t.ok(next.getDay() === 0 || next.getDate() === 12, 'Day or day of month matches');
879
+ t.equal(next.getMonth(), 7, 'Month matches');
880
+
881
+ next = interval.next();
882
+
883
+ t.ok(next, 'Found next scheduled interval');
884
+ t.ok(next.getDay() === 0 || next.getDate() === 12, 'Day or day of month matches');
885
+ t.equal(next.getMonth(), 7, 'Month matches');
886
+
887
+ next = interval.next();
888
+
889
+ t.ok(next, 'Found next scheduled interval');
890
+ t.ok(next.getDay() === 0 || next.getDate() === 12, 'Day or day of month matches');
891
+ t.equal(next.getMonth(), 7, 'Month matches');
892
+ } catch (err) {
893
+ t.error(err, 'Interval parse error');
894
+ }
895
+
896
+ t.end();
897
+ });
898
+
899
+ test('day of month is wildcard, month and day of week are both set', function(t) {
900
+ try {
901
+ var options = {
902
+ currentDate: new CronDate('Mon, 31 May 2021 12:00:00')
903
+ };
904
+ var interval = CronExpression.parse('0 0 * 6 2', options);
905
+ t.ok(interval, 'Interval parsed');
906
+
907
+ var expectedDayMatches = [1, 8, 15, 22, 29];
908
+ expectedDayMatches.forEach(function(dayOfMonth) {
909
+ var next = interval.next();
910
+ t.ok(next, 'Found next scheduled interval');
911
+ t.equal(next.getDay(), 2, 'Day of week matches');
912
+ t.equal(next.getDate(), dayOfMonth, 'Day of month matches');
913
+ t.equal(next.getMonth(), 5, 'Month matches');
914
+ });
915
+ } catch (err) {
916
+ t.error(err, 'Interval parse error');
917
+ }
918
+
919
+ t.end();
920
+ });
921
+
922
+ test('day of month contains multiple ranges and day of week is wildcard', function(t) {
923
+ try {
924
+ var options = {
925
+ currentDate: new CronDate('Sat, 1 Dec 2012 14:38:53')
926
+ };
927
+ var interval = CronExpression.parse('0 0 0 2-4,7-31 * *', options);
928
+ t.ok(interval, 'Interval parsed');
929
+
930
+ var next = interval.next();
931
+
932
+ t.ok(next, 'Found next scheduled interval');
933
+ t.ok(next.getDate() === 2, 'Day of month matches');
934
+ t.equal(next.getMonth(), 11, 'Month matches');
935
+
936
+ next = interval.next();
937
+
938
+ t.ok(next, 'Found next scheduled interval');
939
+ t.ok(next.getDate() === 3, 'Day of month matches');
940
+ t.equal(next.getMonth(), 11, 'Month matches');
941
+
942
+ next = interval.next();
943
+
944
+ t.ok(next, 'Found next scheduled interval');
945
+ t.ok(next.getDate() === 4, 'Day of month matches');
946
+ t.equal(next.getMonth(), 11, 'Month matches');
947
+
948
+ next = interval.next();
949
+
950
+ t.ok(next, 'Found next scheduled interval');
951
+ t.ok(next.getDate() === 7, 'Day of month matches');
952
+ t.equal(next.getMonth(), 11, 'Month matches');
953
+
954
+ next = interval.next();
955
+
956
+ t.ok(next, 'Found next scheduled interval');
957
+ t.ok(next.getDate() === 8, 'Day of month matches');
958
+ t.equal(next.getMonth(), 11, 'Month matches');
959
+
960
+ next = interval.next();
961
+ } catch (err) {
962
+ t.error(err, 'Interval parse error');
963
+ }
964
+
965
+ t.end();
966
+ });
967
+
968
+ test('day of month and week are both set and dow is 6,0', function(t) {
969
+ try {
970
+ var options = {
971
+ currentDate: new CronDate('Wed, 26 Dec 2012 14:38:53')
972
+ };
973
+ var interval = CronExpression.parse('10 2 12 8 6,0', options);
974
+ t.ok(interval, 'Interval parsed');
975
+
976
+ var next = interval.next();
977
+
978
+ t.ok(next, 'Found next scheduled interval');
979
+ t.ok(next.getDay() === 6 || next.getDate() === 12, 'Day or day of month matches');
980
+ t.equal(next.getMonth(), 7, 'Month matches');
981
+
982
+ next = interval.next();
983
+
984
+ t.ok(next, 'Found next scheduled interval');
985
+ t.ok(next.getDay() === 0 || next.getDate() === 12, 'Day or day of month matches');
986
+ t.equal(next.getMonth(), 7, 'Month matches');
987
+
988
+ next = interval.next();
989
+
990
+ t.ok(next, 'Found next scheduled interval');
991
+ t.ok(next.getDay() === 6 || next.getDate() === 12, 'Day or day of month matches');
992
+ t.equal(next.getMonth(), 7, 'Month matches');
993
+
994
+ next = interval.next();
995
+
996
+ t.ok(next, 'Found next scheduled interval');
997
+ t.ok(next.getDay() === 0 || next.getDate() === 12, 'Day or day of month matches');
998
+ t.equal(next.getMonth(), 7, 'Month matches');
999
+ } catch (err) {
1000
+ t.error(err, 'Interval parse error');
1001
+ }
1002
+
1003
+ t.end();
1004
+ });
1005
+
1006
+
1007
+ test('day of month and week are both set and dow is a range with value 6-7', function(t) {
1008
+ try {
1009
+ var options = {
1010
+ currentDate: new CronDate('Wed, 26 Dec 2012 14:38:53')
1011
+ };
1012
+ var interval = CronExpression.parse('10 2 12 8 6-7', options);
1013
+ t.ok(interval, 'Interval parsed');
1014
+
1015
+ var next = interval.next();
1016
+
1017
+ t.ok(next, 'Found next scheduled interval');
1018
+ t.ok(next.getDay() === 6 || next.getDate() === 12, 'Day or day of month matches');
1019
+ t.equal(next.getMonth(), 7, 'Month matches');
1020
+
1021
+ next = interval.next();
1022
+
1023
+ t.ok(next, 'Found next scheduled interval');
1024
+ t.ok(next.getDay() === 6 || next.getDate() === 12, 'Day or day of month matches');
1025
+ t.equal(next.getMonth(), 7, 'Month matches');
1026
+
1027
+ next = interval.next();
1028
+
1029
+ t.ok(next, 'Found next scheduled interval');
1030
+ t.ok(next.getDay() === 6 || next.getDate() === 12, 'Day or day of month matches');
1031
+ t.equal(next.getMonth(), 7, 'Month matches');
1032
+
1033
+ // next = interval.next();
1034
+
1035
+ t.ok(next, 'Found next scheduled interval');
1036
+ t.ok(next.getDay() === 6 || next.getDate() === 12, 'Day or day of month matches');
1037
+ t.equal(next.getMonth(), 7, 'Month matches');
1038
+ } catch (err) {
1039
+ t.error(err, 'Interval parse error');
1040
+ }
1041
+
1042
+ t.end();
1043
+ });
1044
+
1045
+ test('day of month validation should be ignored when day of month is wildcard and month is set', function (t) {
1046
+ try {
1047
+ var options = {
1048
+ currentDate: new CronDate('2020-05-01T15:00:00.000')
1049
+ };
1050
+ var interval = CronExpression.parse('* * * * 2 *', options);
1051
+ t.ok(interval, 'Interval parsed');
1052
+
1053
+ var next = interval.next();
1054
+
1055
+ t.ok(next, 'Found next scheduled interval');
1056
+ t.equal(next.getHours(), 0, 'Hours matches');
1057
+ t.equal(next.getDate(), 1, 'Day of month matches');
1058
+ t.equal(next.getMonth() + 1, 2, 'Month matches');
1059
+
1060
+ t.ok(next, 'Found next scheduled interval');
1061
+ } catch (err) {
1062
+ t.error(err, 'Interval parse error');
1063
+ }
1064
+
1065
+ t.end();
1066
+ });
1067
+
1068
+ test('day and date in week should matches', function(t){
1069
+ try {
1070
+ var interval = CronExpression.parse('0 1 1 1 * 1');
1071
+ t.ok(interval, 'Interval parsed');
1072
+
1073
+ var next = interval.next();
1074
+
1075
+ t.ok(next, 'Found next scheduled interval');
1076
+ t.equal(next.getHours(), 1, 'Hours matches');
1077
+ t.ok(next.getDay() === 1 || next.getDate() === 1, 'Day or day of month matches');
1078
+
1079
+ next = interval.next();
1080
+
1081
+ t.ok(next, 'Found next scheduled interval');
1082
+ t.equal(next.getHours(), 1, 'Hours matches');
1083
+ t.ok(next.getDay() === 1 || next.getDate() === 1, 'Day or day of month matches');
1084
+
1085
+ next = interval.next();
1086
+
1087
+ t.ok(next, 'Found next scheduled interval');
1088
+ t.equal(next.getHours(), 1, 'Hours matches');
1089
+ t.ok(next.getDay() === 1 || next.getDate() === 1, 'Day or day of month matches');
1090
+
1091
+ } catch (err) {
1092
+ t.error(err, 'Interval parse error');
1093
+ }
1094
+
1095
+ t.end();
1096
+ });
1097
+
1098
+ test('should sort ranges and values in ascending order', function(t) {
1099
+ var options = {
1100
+ currentDate: new CronDate('Wed, 26 Dec 2012 14:38:53')
1101
+ };
1102
+ var interval = CronExpression.parse('0 12,13,10,1-3 * * *', options);
1103
+ t.ok(interval, 'Interval parsed');
1104
+
1105
+ var hours = [ 1, 2, 3, 10, 12, 13 ];
1106
+ for (var i in hours) {
1107
+ next = interval.next();
1108
+
1109
+ t.ok(next, 'Found next scheduled interval');
1110
+ t.equal(next.getHours(), hours[i], 'Hours matches');
1111
+ }
1112
+
1113
+ t.end();
1114
+ });
1115
+
1116
+ test('valid ES6 iterator should be returned if iterator options is set to true', function(t) {
1117
+ try {
1118
+ var options = {
1119
+ currentDate: new CronDate('Wed, 26 Dec 2012 14:38:53'),
1120
+ endDate: new CronDate('Wed, 26 Dec 2012 15:40:00'),
1121
+ iterator: true
1122
+ };
1123
+
1124
+ var val = null;
1125
+ var interval = CronExpression.parse('*/25 * * * *', options);
1126
+ t.ok(interval, 'Interval parsed');
1127
+
1128
+ val = interval.next();
1129
+ t.ok(val, 'Next iteration resolved');
1130
+ t.ok(val.value, 'Iterator value is set');
1131
+ t.notOk(val.done, 'Iterator is not finished');
1132
+
1133
+ val = interval.next();
1134
+ t.ok(val, 'Next iteration resolved');
1135
+ t.ok(val.value, 'Iterator value is set');
1136
+ t.notOk(val.done, 'Iterator is not finished');
1137
+
1138
+ val = interval.next();
1139
+ t.ok(val, 'Next iteration resolved');
1140
+ t.ok(val.value, 'Iterator value is set');
1141
+ t.ok(val.done, 'Iterator is finished');
1142
+ } catch (err) {
1143
+ t.error(err, 'Interval parse error');
1144
+ }
1145
+
1146
+ t.end();
1147
+ });
1148
+
1149
+ test('dow 6,7 6,0 0,6 7,6 should be equivalent', function(t) {
1150
+ try {
1151
+ var options = {
1152
+ currentDate: new CronDate('Wed, 26 Dec 2012 14:38:53'),
1153
+ };
1154
+
1155
+ var expressions = [
1156
+ '30 16 * * 6,7',
1157
+ '30 16 * * 6,0',
1158
+ '30 16 * * 0,6',
1159
+ '30 16 * * 7,6'
1160
+ ];
1161
+
1162
+ expressions.forEach(function(expression) {
1163
+ var interval = CronExpression.parse(expression, options);
1164
+ t.ok(interval, 'Interval parsed');
1165
+
1166
+ var val = interval.next();
1167
+ t.equal(val.getDay(), 6, 'Day matches');
1168
+
1169
+ val = interval.next();
1170
+ t.equal(val.getDay(), 0, 'Day matches');
1171
+
1172
+ val = interval.next();
1173
+ t.equal(val.getDay(), 6, 'Day matches');
1174
+ });
1175
+ } catch (err) {
1176
+ t.error(err, 'Interval parse error');
1177
+ }
1178
+
1179
+ t.end();
1180
+ });
1181
+
1182
+ test('hour 0 9,11,1 * * * and 0 1,9,11 * * * should be equivalent', function(t) {
1183
+ try {
1184
+ var options = {
1185
+ currentDate: new CronDate('Wed, 26 Dec 2012 00:00:00'),
1186
+ };
1187
+
1188
+ var expressions = [
1189
+ '0 9,11,1 * * *',
1190
+ '0 1,9,11 * * *'
1191
+ ];
1192
+
1193
+ expressions.forEach(function(expression) {
1194
+ var interval = CronExpression.parse(expression, options);
1195
+ t.ok(interval, 'Interval parsed');
1196
+
1197
+ var val = interval.next();
1198
+ t.equal(val.getHours(), 1, 'Hour matches');
1199
+
1200
+ val = interval.next();
1201
+ t.equal(val.getHours(), 9, 'Hour matches');
1202
+
1203
+ val = interval.next();
1204
+ t.equal(val.getHours(), 11, 'Hour matches');
1205
+
1206
+ val = interval.next();
1207
+ t.equal(val.getHours(), 1, 'Hour matches');
1208
+
1209
+ val = interval.next();
1210
+ t.equal(val.getHours(), 9, 'Hour matches');
1211
+
1212
+ val = interval.next();
1213
+ t.equal(val.getHours(), 11, 'Hour matches');
1214
+ });
1215
+ } catch (err) {
1216
+ t.error(err, 'Interval parse error');
1217
+ }
1218
+
1219
+ t.end();
1220
+ });
1221
+
1222
+ test('it will work with #139 issue case', function(t) {
1223
+ var options = {
1224
+ currentDate : new Date('2018-11-15T16:15:33.522Z'),
1225
+ tz: 'Europe/Madrid'
1226
+ };
1227
+
1228
+ var interval = CronExpression.parse('0 0 0 1,2 * *', options);
1229
+ var date = interval.next();
1230
+
1231
+ t.equal(date.getFullYear(), 2018);
1232
+ t.equal(date.getDate(), 1);
1233
+ t.equal(date.getMonth(), 11);
1234
+
1235
+ t.end();
1236
+ });
1237
+
1238
+ test('should work for valid first/second/third/fourth/fifth occurence dayOfWeek (# char)', function(t) {
1239
+ try {
1240
+ var options = {
1241
+ currentDate: new CronDate('2019-04-30')
1242
+ };
1243
+
1244
+ var expectedFirstDates = [
1245
+ new CronDate('2019-05-05'),
1246
+ new CronDate('2019-06-02'),
1247
+ new CronDate('2019-07-07'),
1248
+ new CronDate('2019-08-04')
1249
+ ];
1250
+ var expectedSecondDates = [
1251
+ new CronDate('2019-05-12'),
1252
+ new CronDate('2019-06-09'),
1253
+ new CronDate('2019-07-14'),
1254
+ new CronDate('2019-08-11')
1255
+ ];
1256
+ var expectedThirdDates = [
1257
+ new CronDate('2019-05-19'),
1258
+ new CronDate('2019-06-16'),
1259
+ new CronDate('2019-07-21'),
1260
+ new CronDate('2019-08-18')
1261
+ ];
1262
+ var expectedFourthDates = [
1263
+ new CronDate('2019-05-26'),
1264
+ new CronDate('2019-06-23'),
1265
+ new CronDate('2019-07-28'),
1266
+ new CronDate('2019-08-25')
1267
+ ];
1268
+ var expectedFifthDates = [
1269
+ new CronDate('2019-06-30'),
1270
+ new CronDate('2019-09-29'),
1271
+ new CronDate('2019-12-29'),
1272
+ new CronDate('2020-03-29')
1273
+ ];
1274
+
1275
+ var allExpectedDates = [
1276
+ expectedFirstDates,
1277
+ expectedSecondDates,
1278
+ expectedThirdDates,
1279
+ expectedFourthDates,
1280
+ expectedFifthDates
1281
+ ];
1282
+ var expressions = [
1283
+ '0 0 0 ? * 0#1',
1284
+ '0 0 0 ? * 0#2',
1285
+ '0 0 0 ? * 0#3',
1286
+ '0 0 0 ? * 0#4',
1287
+ '0 0 0 ? * 0#5'
1288
+ ];
1289
+ expressions.forEach(function(expression, index) {
1290
+ var interval = CronExpression.parse(expression, options);
1291
+ var expectedDates = allExpectedDates[index];
1292
+
1293
+ expectedDates.forEach(function(expected) {
1294
+ var date = interval.next();
1295
+ t.equal(
1296
+ date.toISOString(),
1297
+ expected.toISOString(),
1298
+ 'Expression "' + expression + '" has next() that matches expected: ' + expected.toISOString()
1299
+ );
1300
+ });
1301
+ expectedDates
1302
+ .slice(0, expectedDates.length - 1)
1303
+ .reverse()
1304
+ .forEach(function(expected) {
1305
+ var date = interval.prev();
1306
+ t.equal(
1307
+ date.toISOString(),
1308
+ expected.toISOString(),
1309
+ 'Expression "' + expression + '" has prev() that matches expected: ' + expected.toISOString()
1310
+ );
1311
+ });
1312
+ });
1313
+ } catch (err) {
1314
+ t.error(err, 'Interval parse error');
1315
+ }
1316
+
1317
+ t.end();
1318
+ });
1319
+
1320
+ test('should work for valid second sunday in may', function(t) {
1321
+ try {
1322
+ var options = {
1323
+ currentDate: new CronDate('2019-01-30')
1324
+ };
1325
+ var expectedDates = [
1326
+ new CronDate('2019-05-12'),
1327
+ new CronDate('2020-05-10'),
1328
+ new CronDate('2021-05-09'),
1329
+ new CronDate('2022-05-08')
1330
+ ];
1331
+
1332
+ var interval = CronExpression.parse('0 0 0 ? MAY 0#2', options);
1333
+ expectedDates.forEach(function(expected) {
1334
+ var date = interval.next();
1335
+ t.equal(
1336
+ date.toISOString(),
1337
+ expected.toISOString(),
1338
+ 'Expression "0 0 0 ? MAY 0#2" has next() that matches expected: ' + expected.toISOString()
1339
+ );
1340
+ });
1341
+ expectedDates
1342
+ .slice(0, expectedDates.length - 1)
1343
+ .reverse()
1344
+ .forEach(function(expected) {
1345
+ var date = interval.prev();
1346
+ t.equal(
1347
+ date.toISOString(),
1348
+ expected.toISOString(),
1349
+ 'Expression "0 0 0 ? MAY 0#2" has prev() that matches expected: ' + expected.toISOString()
1350
+ );
1351
+ });
1352
+ } catch (err) {
1353
+ t.error(err, 'Interval parse error');
1354
+ }
1355
+
1356
+ t.end();
1357
+ });
1358
+
1359
+ test('should work for valid second sunday at noon in may', function(t) {
1360
+ try {
1361
+ var options = {
1362
+ currentDate: new CronDate('2019-05-12T11:59:00.000')
1363
+ };
1364
+ var expected = new CronDate('2019-05-12T12:00:00.000');
1365
+
1366
+ var interval = CronExpression.parse('0 0 12 ? MAY 0#2', options);
1367
+ var date = interval.next();
1368
+
1369
+ t.equal(
1370
+ date.toISOString(),
1371
+ expected.toISOString(),
1372
+ 'Expression "0 0 12 ? MAY 0#2" has next() that matches expected: ' + expected.toISOString()
1373
+ );
1374
+ } catch (err) {
1375
+ t.error(err, 'Interval parse error');
1376
+ }
1377
+
1378
+ t.end();
1379
+ });
1380
+
1381
+ test('should work for valid second sunday at noon in may (UTC+3)', function(t) {
1382
+ try {
1383
+ var options = {
1384
+ currentDate: new CronDate('2019-05-12T11:59:00.000', 'Europe/Sofia')
1385
+ };
1386
+ var expected = new CronDate('2019-05-12T12:00:00.000', 'Europe/Sofia');
1387
+
1388
+ var interval = CronExpression.parse('0 0 12 ? MAY 0#2', options);
1389
+ var date = interval.next();
1390
+
1391
+ t.equal(
1392
+ date.toISOString(),
1393
+ expected.toISOString(),
1394
+ 'Expression "0 0 12 ? MAY 0#2" has next() that matches expected: ' + expected.toISOString()
1395
+ );
1396
+ } catch (err) {
1397
+ t.error(err, 'Interval parse error');
1398
+ }
1399
+
1400
+ t.end();
1401
+ });
1402
+
1403
+ test('should work with both dayOfMonth and nth occurence of dayOfWeek', function(t) {
1404
+ try {
1405
+ var options = {
1406
+ currentDate: new CronDate('2019-04-01')
1407
+ };
1408
+
1409
+ var expectedDates = [
1410
+ new CronDate('2019-04-16'),
1411
+ new CronDate('2019-04-17'),
1412
+ new CronDate('2019-04-18'),
1413
+ new CronDate('2019-05-15'),
1414
+ new CronDate('2019-05-16'),
1415
+ new CronDate('2019-05-18'),
1416
+ ];
1417
+
1418
+ var interval = CronExpression.parse('0 0 0 16,18 * 3#3', options);
1419
+
1420
+ expectedDates.forEach(function(expected) {
1421
+ var date = interval.next();
1422
+ t.equal(
1423
+ date.toISOString(),
1424
+ expected.toISOString(),
1425
+ 'Expression "0 0 0 16,18 * 3#3" has next() that matches expected: ' + expected.toISOString()
1426
+ );
1427
+ });
1428
+ expectedDates
1429
+ .slice(0, expectedDates.length - 1)
1430
+ .reverse()
1431
+ .forEach(function(expected) {
1432
+ var date = interval.prev();
1433
+ t.equal(
1434
+ date.toISOString(),
1435
+ expected.toISOString(),
1436
+ 'Expression "0 0 0 16,18 * 3#3" has prev() that matches expected: ' + expected.toISOString()
1437
+ );
1438
+ });
1439
+ } catch (err) {
1440
+ t.error(err, 'Interval parse error');
1441
+ }
1442
+
1443
+ t.end();
1444
+ });
1445
+
1446
+ test('should error when passed invalid occurence value', function(t) {
1447
+ var expressions = [
1448
+ '0 0 0 ? * 1#',
1449
+ '0 0 0 ? * 1#0',
1450
+ '0 0 0 ? * 4#6',
1451
+ '0 0 0 ? * 0##4',
1452
+ ];
1453
+ expressions.forEach(function(expression) {
1454
+ t.throws(function() {
1455
+ CronExpression.parse(expression);
1456
+ }, new Error('Constraint error, invalid dayOfWeek occurrence number (#)'), expression);
1457
+ });
1458
+
1459
+ t.end();
1460
+ });
1461
+
1462
+ // The Quartz documentation says that if the # character is used then no other expression can be used in the dayOfWeek term: http://www.quartz-scheduler.org/api/2.3.0/index.html
1463
+ test('cannot combine `-` range and # occurrence special characters', function(t) {
1464
+ var expression = '0 0 0 ? * 2-4#2';
1465
+ t.throws(function() {
1466
+ CronExpression.parse(expression);
1467
+ }, new Error('Constraint error, invalid dayOfWeek `#` and `-` special characters are incompatible'));
1468
+
1469
+ t.end();
1470
+ });
1471
+
1472
+ test('cannot combine `/` repeat interval and # occurrence special characters', function(t) {
1473
+ var expression = '0 0 0 ? * 1/2#3';
1474
+ t.throws(function() {
1475
+ CronExpression.parse(expression);
1476
+ }, new Error('Constraint error, invalid dayOfWeek `#` and `/` special characters are incompatible'));
1477
+
1478
+ t.end();
1479
+ });
1480
+
1481
+ test('cannot combine `,` list and # occurrence special characters', function(t) {
1482
+ var expression = '0 0 0 ? * 0,6#4';
1483
+ t.throws(function() {
1484
+ CronExpression.parse(expression);
1485
+ }, new Error('Constraint error, invalid dayOfWeek `#` and `,` special characters are incompatible'));
1486
+
1487
+ t.end();
1488
+ });
1489
+