@bluedot-innovation/models 10.12.1 → 10.12.3

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.
package/CHANGELOG.md CHANGED
@@ -1,3 +1,9 @@
1
+ ## 10.12.3
2
+ - Allow a Push notification campaign has no zones when campaign status is draft.
3
+
4
+ ## 10.12.2
5
+ - Fix APNs environment enum: change 'sandbox' to 'development' to match Apple's APNs environment values
6
+
1
7
  ## 10.12.1
2
8
  - Add Push Notification Campaign schemas (Campaign, CampaignNotification, CampaignZone)
3
9
  - Add Push Configuration schemas (PushConfiguration, ApnsConfiguration, FcmConfiguration)
@@ -1196,6 +1196,13 @@ describe('Project', () => {
1196
1196
  assert.notExists(res)
1197
1197
  }
1198
1198
  })
1199
+ it('should allow empty zones when campaign status is draft', async () => {
1200
+ project.campaigns[0].status = 'draft'
1201
+ project.campaigns[0].zones = []
1202
+ let Project = new ProjectModel(project)
1203
+ const res = await Project.validate()
1204
+ assert.notExists(res)
1205
+ })
1199
1206
  })
1200
1207
 
1201
1208
  describe('Invalid Campaigns', () => {
@@ -1361,8 +1368,8 @@ describe('Project', () => {
1361
1368
  assert.notExists(res)
1362
1369
  })
1363
1370
 
1364
- it('should validate APNs with sandbox environment', async () => {
1365
- project.push.apns.environment = 'sandbox'
1371
+ it('should validate APNs with development environment', async () => {
1372
+ project.push.apns.environment = 'development'
1366
1373
  let Project = new ProjectModel(project)
1367
1374
  const res = await Project.validate()
1368
1375
  assert.notExists(res)
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@bluedot-innovation/models",
3
- "version": "10.12.1",
3
+ "version": "10.12.3",
4
4
  "main": "Models.js",
5
5
  "scripts": {
6
6
  "lint": "./node_modules/.bin/eslint -c .eslintrc.js ./models/*.js ./__tests__/**/*.js ./__tests__/**/**/*.js ./schemas/*.js",
@@ -4,7 +4,7 @@ let ApnsConfigurationSchema = new mongoose.Schema({
4
4
  environment: {
5
5
  type: String,
6
6
  required: [true, 'APNs environment is required'],
7
- enum: ['production', 'sandbox']
7
+ enum: ['production', 'development']
8
8
  },
9
9
  teamId: {
10
10
  type: String,
@@ -22,7 +22,10 @@ let CampaignSchema = new mongoose.Schema({
22
22
  required: [true, 'campaign zones are required'],
23
23
  validate: {
24
24
  validator: function(zones) {
25
- return zones && zones.length > 0
25
+ if (this.status === 'active' || this.status === 'paused') {
26
+ return zones && zones.length > 0
27
+ }
28
+ return true
26
29
  },
27
30
  msg: 'campaign must have at least one zone'
28
31
  }