@wmfs/tymly-schedule-plugin 1.5.0 → 1.6.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.
@@ -10,7 +10,7 @@ jobs:
10
10
  TZ: "Europe/London"
11
11
  PG_CONNECTION_STRING: postgres://postgres:postgres@localhost:5432/circle_test
12
12
  TIMEOUT: 15000
13
- - image: cimg/postgres:15.1-postgis
13
+ - image: cimg/postgres:15.2-postgis
14
14
  auth:
15
15
  username: $DOCKERHUB_USERNAME
16
16
  password: $DOCKERHUB_PASSWORD
package/.version CHANGED
@@ -1 +1 @@
1
- VERSION=1.5.0
1
+ VERSION=1.6.0
package/CHANGELOG.md CHANGED
@@ -1,3 +1,32 @@
1
+ # [1.6.0](https://github.com/wmfs/tymly-schedule-plugin/compare/v1.5.0...v1.6.0) (2023-06-06)
2
+
3
+
4
+ ### ✨ Features
5
+
6
+ * updated schema for cardscript files ([02156dc](https://github.com/wmfs/tymly-schedule-plugin/commit/02156dc4efbc13795523ed130de1ad3144e932fe))
7
+
8
+
9
+ ### 🐛 Bug Fixes
10
+
11
+ * fixed bug with scheduling an event at a timestamp, to account for timezone offset ([a4b561b](https://github.com/wmfs/tymly-schedule-plugin/commit/a4b561b5592f3bb59b1f1399ac95d87b47b1dc3d))
12
+ * moved moment dep from dev dependencies to main dependencies as serice class uses it ([0d39fca](https://github.com/wmfs/tymly-schedule-plugin/commit/0d39fcad9274c68a04251c98184439d8403b2230))
13
+
14
+
15
+ ### 🛠 Builds
16
+
17
+ * **deps-dev:** update dependency [@semantic-release](https://github.com/semantic-release)/changelog to v6.0.3 ([b36f0c4](https://github.com/wmfs/tymly-schedule-plugin/commit/b36f0c4fbcc3c1d3a5f5c614f74c0640e1196791))
18
+ * **deps-dev:** update dependency [@wmfs](https://github.com/wmfs)/tymly-pg-plugin to v1.277.0 ([1af6de4](https://github.com/wmfs/tymly-schedule-plugin/commit/1af6de41da845a565a656b8facd31874fc1ee6d1))
19
+ * **deps-dev:** update dependency [@wmfs](https://github.com/wmfs)/tymly-pg-plugin to v1.278.0 ([befcf37](https://github.com/wmfs/tymly-schedule-plugin/commit/befcf37d7a756e0ca9a19393c4d1870fc8857e53))
20
+ * **deps-dev:** update dependency [@wmfs](https://github.com/wmfs)/tymly-pg-plugin to v1.282.0 ([a9dc578](https://github.com/wmfs/tymly-schedule-plugin/commit/a9dc5789864b9fab522d7a44d830f4679bb93af8))
21
+ * **deps-dev:** update dependency semantic-release to v20.1.1 ([c825925](https://github.com/wmfs/tymly-schedule-plugin/commit/c8259255193dde8730188686542f8da785f319a0))
22
+ * **deps-dev:** update dependency semantic-release to v20.1.3 ([eb9d5ee](https://github.com/wmfs/tymly-schedule-plugin/commit/eb9d5eec5a10356ffefebb0837800aa7d752cbfe))
23
+ * **deps-dev:** update dependency semantic-release to v21 ([cbe91b5](https://github.com/wmfs/tymly-schedule-plugin/commit/cbe91b5118564c1cbb9f43854a611934efc60289))
24
+
25
+
26
+ ### ⚙️ Continuous Integrations
27
+
28
+ * **circle:** update postgres to 15.2-postgis [sc-19693] ([a7e5b6c](https://github.com/wmfs/tymly-schedule-plugin/commit/a7e5b6cc54612947118887e15647caf62174e172))
29
+
1
30
  # [1.5.0](https://github.com/wmfs/tymly-schedule-plugin/compare/v1.4.0...v1.5.0) (2023-02-17)
2
31
 
3
32
 
@@ -4,19 +4,6 @@
4
4
  "title": "Configure a Scheduled State Machine",
5
5
  "category": "schedule"
6
6
  },
7
- "hooks": {
8
- "afterSubmit": {
9
- "actions": [
10
- {
11
- "type": "Action.PushCard",
12
- "stateMachineName": "schedule_viewScheduledTask_1_0",
13
- "input": {
14
- "key": "$.key"
15
- }
16
- }
17
- ]
18
- }
19
- },
20
7
  "type": "AdaptiveCard",
21
8
  "body": [
22
9
  {
@@ -92,6 +79,19 @@
92
79
  "title": "Submit"
93
80
  }
94
81
  ],
95
- "$schema": "http://adaptivecards.io/schemas/adaptive-card.json",
82
+ "hooks": {
83
+ "afterSubmit": {
84
+ "actions": [
85
+ {
86
+ "type": "Action.PushCard",
87
+ "stateMachineName": "schedule_viewScheduledTask_1_0",
88
+ "input": {
89
+ "key": "$.key"
90
+ }
91
+ }
92
+ ]
93
+ }
94
+ },
95
+ "$schema": "https://raw.githubusercontent.com/wmfs/cardscript-schema/master/lib/schema.json",
96
96
  "version": "1.0"
97
97
  }
@@ -31,6 +31,6 @@
31
31
  ]
32
32
  }
33
33
  ],
34
- "$schema": "http://adaptivecards.io/schemas/adaptive-card.json",
34
+ "$schema": "https://raw.githubusercontent.com/wmfs/cardscript-schema/master/lib/schema.json",
35
35
  "version": "1.0"
36
36
  }
@@ -143,6 +143,6 @@
143
143
  ]
144
144
  }
145
145
  ],
146
- "$schema": "http://adaptivecards.io/schemas/adaptive-card.json",
146
+ "$schema": "https://raw.githubusercontent.com/wmfs/cardscript-schema/master/lib/schema.json",
147
147
  "version": "1.0"
148
148
  }
@@ -1,6 +1,8 @@
1
+ const moment = require('moment')
2
+
1
3
  module.exports = function (rule = {}) {
2
4
  const now = new Date()
3
- return new Date(
5
+ const date = new Date(
4
6
  isNaN(rule.year) ? now.getFullYear() : rule.year,
5
7
  isNaN(rule.month) ? now.getMonth() : rule.month,
6
8
  isNaN(rule.date) ? now.getDate() : rule.date,
@@ -8,4 +10,9 @@ module.exports = function (rule = {}) {
8
10
  isNaN(rule.minute) ? now.getMinutes() : rule.minute,
9
11
  isNaN(rule.second) ? now.getSeconds() : rule.second
10
12
  )
13
+ // note that rule does not specify a timezone, so we have to assume that
14
+ // the timestamp provided is a local timestamp - as such, we have to convert
15
+ // to UTC. note that in British Summer Time (for example, on the 5th June),
16
+ // now.getTimezoneOffset() will return -60.
17
+ return moment(date).add(now.getTimezoneOffset(), 'minutes').toDate()
11
18
  }
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@wmfs/tymly-schedule-plugin",
3
- "version": "1.5.0",
3
+ "version": "1.6.0",
4
4
  "description": "Provides state machine scheduling for the Tymly framework",
5
5
  "homepage": "https://github.com/wmfs/tymly-schedule-plugin#readme",
6
6
  "author": "West Midlands Fire Service",
@@ -23,14 +23,15 @@
23
23
  "main": "./lib/index.js",
24
24
  "dependencies": {
25
25
  "node-schedule": "2.1.1",
26
- "uuid": "^9.0.0"
26
+ "uuid": "^9.0.0",
27
+ "moment": "2.29.4"
27
28
  },
28
29
  "devDependencies": {
29
- "@semantic-release/changelog": "6.0.2",
30
+ "@semantic-release/changelog": "6.0.3",
30
31
  "@semantic-release/exec": "6.0.3",
31
32
  "@semantic-release/git": "10.0.1",
32
33
  "@wmfs/tymly": "1.242.0",
33
- "@wmfs/tymly-pg-plugin": "1.276.0",
34
+ "@wmfs/tymly-pg-plugin": "1.282.0",
34
35
  "@wmfs/tymly-test-helpers": "1.22.2",
35
36
  "chai": "4.3.7",
36
37
  "codecov": "3.8.3",
@@ -38,9 +39,8 @@
38
39
  "cz-conventional-changelog": "3.3.0",
39
40
  "dirty-chai": "2.0.1",
40
41
  "mocha": "10.2.0",
41
- "moment": "2.29.4",
42
42
  "nyc": "15.1.0",
43
- "semantic-release": "20.1.0",
43
+ "semantic-release": "21.0.0",
44
44
  "standard": "17.0.0"
45
45
  },
46
46
  "scripts": {
package/plugin.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "schedule-plugin",
3
- "version": "1.5.0",
3
+ "version": "1.6.0",
4
4
  "label": "Tymly Schedule Plugin",
5
5
  "author": "WMFS",
6
6
  "organisation": "West Midlands Fire Service",
@@ -7,8 +7,9 @@ const ruleToDatetime = require('../lib/components/services/schedule/utils/rule-t
7
7
  const datetimeToRule = require('../lib/components/services/schedule/utils/datetime-to-rule')
8
8
 
9
9
  describe('Rule to datetime tests', function () {
10
- it('No options, should default to now', () => {
11
- const now = new Date()
10
+ it('No options, should default to now (UTC)', () => {
11
+ let now = new Date()
12
+ now = moment(now).add(now.getTimezoneOffset(), 'minutes').toDate()
12
13
  const datetime = ruleToDatetime()
13
14
 
14
15
  expect(datetime.getFullYear()).to.eql(now.getFullYear())
@@ -20,7 +21,8 @@ describe('Rule to datetime tests', function () {
20
21
  })
21
22
 
22
23
  it('Year only, the rest defaults to now', () => {
23
- const now = new Date()
24
+ let now = new Date()
25
+ now = moment(now).add(now.getTimezoneOffset(), 'minutes').toDate()
24
26
  const year = now.getFullYear() + 2
25
27
 
26
28
  const datetime = ruleToDatetime({ year })
@@ -34,43 +36,49 @@ describe('Rule to datetime tests', function () {
34
36
  })
35
37
 
36
38
  it('All options passed in as integers', () => {
39
+ const now = new Date()
37
40
  const rule = {
38
- year: 2020,
39
- month: 1,
40
- date: 2,
41
- hour: 12,
42
- minute: 30,
43
- second: 0
41
+ year: now.getFullYear(),
42
+ month: now.getMonth(),
43
+ date: now.getDate(),
44
+ hour: now.getHours(),
45
+ minute: now.getMinutes(),
46
+ second: now.getSeconds()
44
47
  }
45
48
 
46
49
  const datetime = ruleToDatetime(rule)
47
50
 
48
- expect(datetime.getFullYear()).to.eql(rule.year)
49
- expect(datetime.getMonth()).to.eql(rule.month)
50
- expect(datetime.getDate()).to.eql(rule.date)
51
- expect(datetime.getHours()).to.eql(rule.hour)
52
- expect(datetime.getMinutes()).to.eql(rule.minute)
53
- expect(datetime.getSeconds()).to.eql(rule.second)
51
+ const utcTimestamp = moment(now).add(now.getTimezoneOffset(), 'minutes').toDate()
52
+
53
+ expect(datetime.getFullYear()).to.eql(utcTimestamp.getFullYear())
54
+ expect(datetime.getMonth()).to.eql(utcTimestamp.getMonth())
55
+ expect(datetime.getDate()).to.eql(utcTimestamp.getDate())
56
+ expect(datetime.getHours()).to.eql(utcTimestamp.getHours())
57
+ expect(datetime.getMinutes()).to.eql(utcTimestamp.getMinutes())
58
+ expect(datetime.getSeconds()).to.eql(utcTimestamp.getSeconds())
54
59
  })
55
60
 
56
61
  it('All options passed in as strings', () => {
62
+ const now = new Date()
57
63
  const rule = {
58
- year: '2020',
59
- month: '1',
60
- date: '2',
61
- hour: '12',
62
- minute: '30',
63
- second: '0'
64
+ year: '' + now.getFullYear(),
65
+ month: '' + now.getMonth(),
66
+ date: '' + now.getDate(),
67
+ hour: '' + now.getHours(),
68
+ minute: '' + now.getMinutes(),
69
+ second: '' + now.getSeconds()
64
70
  }
65
71
 
66
72
  const datetime = ruleToDatetime(rule)
67
73
 
68
- expect(datetime.getFullYear().toString()).to.eql(rule.year)
69
- expect(datetime.getMonth().toString()).to.eql(rule.month)
70
- expect(datetime.getDate().toString()).to.eql(rule.date)
71
- expect(datetime.getHours().toString()).to.eql(rule.hour)
72
- expect(datetime.getMinutes().toString()).to.eql(rule.minute)
73
- expect(datetime.getSeconds().toString()).to.eql(rule.second)
74
+ const utcTimestamp = moment(now).add(now.getTimezoneOffset(), 'minutes').toDate()
75
+
76
+ expect(datetime.getFullYear()).to.eql(utcTimestamp.getFullYear())
77
+ expect(datetime.getMonth()).to.eql(utcTimestamp.getMonth())
78
+ expect(datetime.getDate()).to.eql(utcTimestamp.getDate())
79
+ expect(datetime.getHours()).to.eql(utcTimestamp.getHours())
80
+ expect(datetime.getMinutes()).to.eql(utcTimestamp.getMinutes())
81
+ expect(datetime.getSeconds()).to.eql(utcTimestamp.getSeconds())
74
82
  })
75
83
  })
76
84