screwdriver-data-schema 24.1.0 → 24.3.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.
@@ -0,0 +1,36 @@
1
+ /* eslint-disable new-cap */
2
+
3
+ 'use strict';
4
+
5
+ const prefix = process.env.DATASTORE_SEQUELIZE_PREFIX || '';
6
+ const table = `${prefix}banners`;
7
+
8
+ module.exports = {
9
+ up: async (queryInterface, Sequelize) => {
10
+ await queryInterface.sequelize.transaction(async transaction => {
11
+ await queryInterface.addColumn(
12
+ table,
13
+ 'scope',
14
+ {
15
+ type: Sequelize.STRING(15),
16
+ defaultValue: 'GLOBAL',
17
+ allowNull: false
18
+ },
19
+ { transaction }
20
+ );
21
+ await queryInterface.addColumn(
22
+ table,
23
+ 'scopeId',
24
+ {
25
+ type: Sequelize.INTEGER.UNSIGNED
26
+ },
27
+ { transaction }
28
+ );
29
+ await queryInterface.addIndex(table, {
30
+ name: `${table}_scope_and_scopeId`,
31
+ fields: ['scope', 'scopeId'],
32
+ transaction
33
+ });
34
+ });
35
+ }
36
+ };
package/models/banner.js CHANGED
@@ -3,6 +3,8 @@
3
3
  const Joi = require('joi');
4
4
  const mutate = require('../lib/mutate');
5
5
 
6
+ const SCOPES = ['GLOBAL', 'PIPELINE', 'BUILD'];
7
+
6
8
  const MODEL = {
7
9
  id: Joi.number().integer().positive(),
8
10
 
@@ -21,7 +23,26 @@ const MODEL = {
21
23
 
22
24
  createdBy: Joi.string().max(128).description('Username of user creating the banner').example('batman123'),
23
25
 
24
- type: Joi.string().valid('info', 'warn').max(32).description('Type/Severity of the banner message').example('info')
26
+ type: Joi.string().valid('info', 'warn').max(32).description('Type/Severity of the banner message').example('info'),
27
+
28
+ scope: Joi.string()
29
+ .max(16)
30
+ .valid(...SCOPES)
31
+ .description('Scope of the banner')
32
+ .example('GLOBAL')
33
+ .default('GLOBAL')
34
+ .required(),
35
+
36
+ scopeId: Joi.number()
37
+ .integer()
38
+ .positive()
39
+ .description('Identifier to pipelineId for PIPELINE, buildId for BUILD, or null for GLOBAL')
40
+ .when('scope', {
41
+ is: Joi.valid('GLOBAL'),
42
+ then: Joi.allow(null).optional(),
43
+ otherwise: Joi.required()
44
+ })
45
+ .example(1234)
25
46
  };
26
47
 
27
48
  module.exports = {
@@ -47,9 +68,9 @@ module.exports = {
47
68
  * @property get
48
69
  * @type {Joi}
49
70
  */
50
- get: Joi.object(mutate(MODEL, ['id', 'message', 'type', 'isActive', 'createdBy', 'createTime'], [])).label(
51
- 'Get Banner'
52
- ),
71
+ get: Joi.object(
72
+ mutate(MODEL, ['id', 'message', 'type', 'isActive', 'scope', 'scopeId', 'createdBy', 'createTime'], [])
73
+ ).label('Get Banner'),
53
74
 
54
75
  /**
55
76
  * Properties for Banners that will be passed during a CREATE request
@@ -57,7 +78,7 @@ module.exports = {
57
78
  * @property create
58
79
  * @type {Joi}
59
80
  */
60
- create: Joi.object(mutate(MODEL, ['message'], ['type', 'isActive'])).label('Create Banner'),
81
+ create: Joi.object(mutate(MODEL, ['message'], ['type', 'isActive', 'scope', 'scopeId'])).label('Create Banner'),
61
82
 
62
83
  /**
63
84
  * Properties for Banners that will be passed during a UPDATE request
@@ -72,7 +93,11 @@ module.exports = {
72
93
  * The LIST request will list all banners
73
94
  */
74
95
  list: Joi.array()
75
- .items(Joi.object(mutate(MODEL, ['id', 'message', 'type', 'isActive', 'createdBy', 'createTime'], [])))
96
+ .items(
97
+ Joi.object(
98
+ mutate(MODEL, ['id', 'message', 'type', 'isActive', 'scope', 'scopeId', 'createdBy', 'createTime'], [])
99
+ )
100
+ )
76
101
  .label('List Banners'),
77
102
 
78
103
  /**
@@ -81,7 +106,7 @@ module.exports = {
81
106
  * @property keys
82
107
  * @type {Array}
83
108
  */
84
- keys: ['message', 'type', 'createTime'],
109
+ keys: ['message', 'type', 'createTime', 'scope', 'scopeId'],
85
110
 
86
111
  /**
87
112
  * List of all fields in the model
@@ -104,5 +129,5 @@ module.exports = {
104
129
  * @property indexes
105
130
  * @type {Array}
106
131
  */
107
- indexes: [{ fields: ['isActive'] }]
132
+ indexes: [{ fields: ['isActive'] }, { fields: ['scope', 'scopeId'] }]
108
133
  };
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "screwdriver-data-schema",
3
- "version": "24.1.0",
3
+ "version": "24.3.0",
4
4
  "description": "Internal Data Schema of Screwdriver",
5
5
  "main": "index.js",
6
6
  "scripts": {
@@ -41,8 +41,8 @@
41
41
  },
42
42
  "devDependencies": {
43
43
  "chai": "^4.3.7",
44
- "eslint": "^8.28.0",
45
- "eslint-config-screwdriver": "^7.0.0",
44
+ "eslint": "^8.57.0",
45
+ "eslint-config-screwdriver": "^8.0.0",
46
46
  "js-yaml": "^4.1.0",
47
47
  "mocha": "^10.1.0",
48
48
  "mocha-multi-reporters": "^1.5.1",
@@ -51,12 +51,12 @@
51
51
  "npx": "^3.0.0",
52
52
  "nyc": "^15.1.0",
53
53
  "pg": "^7.18.2",
54
- "sequelize": "^6.25.8",
55
- "sequelize-cli": "^6.5.2",
56
- "sqlite3": "^5.1.2"
54
+ "sequelize": "^6.37.5",
55
+ "sequelize-cli": "^6.6.2",
56
+ "sqlite3": "^5.1.7"
57
57
  },
58
58
  "dependencies": {
59
- "cron-parser": "^4.7.0",
60
- "joi": "^17.7.0"
59
+ "cron-parser": "^4.9.0",
60
+ "joi": "^17.13.3"
61
61
  }
62
62
  }