screwdriver-data-schema 24.0.2 → 24.2.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
|
@@ -0,0 +1,21 @@
|
|
|
1
|
+
/* eslint-disable new-cap */
|
|
2
|
+
|
|
3
|
+
'use strict';
|
|
4
|
+
|
|
5
|
+
const prefix = process.env.DATASTORE_SEQUELIZE_PREFIX || '';
|
|
6
|
+
const table = `${prefix}builds`;
|
|
7
|
+
|
|
8
|
+
module.exports = {
|
|
9
|
+
up: async (queryInterface, Sequelize) => {
|
|
10
|
+
await queryInterface.sequelize.transaction(async transaction => {
|
|
11
|
+
await queryInterface.addColumn(
|
|
12
|
+
table,
|
|
13
|
+
'statusMessageType',
|
|
14
|
+
{
|
|
15
|
+
type: Sequelize.STRING(10)
|
|
16
|
+
},
|
|
17
|
+
{ transaction }
|
|
18
|
+
);
|
|
19
|
+
});
|
|
20
|
+
}
|
|
21
|
+
};
|
|
@@ -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(
|
|
51
|
-
'
|
|
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(
|
|
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/models/build.js
CHANGED
|
@@ -22,6 +22,7 @@ const STATUSES = [
|
|
|
22
22
|
'COLLAPSED', // when the build is collapsed
|
|
23
23
|
'FROZEN' // when the build is frozen due to freeze window
|
|
24
24
|
];
|
|
25
|
+
const STATUS_MESSAGE_TYPES = ['ERROR', 'WARN', 'INFO'];
|
|
25
26
|
|
|
26
27
|
const MODEL = {
|
|
27
28
|
id: Joi.number().integer().positive().description('Identifier of this build').example(123345),
|
|
@@ -85,6 +86,12 @@ const MODEL = {
|
|
|
85
86
|
.description('Status message to describe status of the build')
|
|
86
87
|
.example('Build failed due to infrastructure error'),
|
|
87
88
|
|
|
89
|
+
statusMessageType: Joi.string()
|
|
90
|
+
.valid(...STATUS_MESSAGE_TYPES)
|
|
91
|
+
.max(10)
|
|
92
|
+
.description('Severity of the status message')
|
|
93
|
+
.example('WARN'),
|
|
94
|
+
|
|
88
95
|
stats: Joi.object()
|
|
89
96
|
.keys({
|
|
90
97
|
queueEnterTime: Joi.string().isoDate().description('When this build enters queue'),
|
|
@@ -158,6 +165,7 @@ module.exports = {
|
|
|
158
165
|
'eventId',
|
|
159
166
|
'environment',
|
|
160
167
|
'statusMessage',
|
|
168
|
+
'statusMessageType',
|
|
161
169
|
'stats',
|
|
162
170
|
'buildClusterName',
|
|
163
171
|
'templateId',
|
|
@@ -172,7 +180,9 @@ module.exports = {
|
|
|
172
180
|
* @property update
|
|
173
181
|
* @type {Joi}
|
|
174
182
|
*/
|
|
175
|
-
update: Joi.object(mutate(MODEL, [], ['status', 'meta', 'statusMessage', 'stats'])).label(
|
|
183
|
+
update: Joi.object(mutate(MODEL, [], ['status', 'meta', 'statusMessage', 'statusMessageType', 'stats'])).label(
|
|
184
|
+
'Update Build'
|
|
185
|
+
),
|
|
176
186
|
|
|
177
187
|
/**
|
|
178
188
|
* Properties for Build that will be passed during a CREATE request
|
|
@@ -223,6 +233,14 @@ module.exports = {
|
|
|
223
233
|
*/
|
|
224
234
|
allKeys: Object.keys(MODEL),
|
|
225
235
|
|
|
236
|
+
/**
|
|
237
|
+
* All the available status message type
|
|
238
|
+
*
|
|
239
|
+
* @property allStatusMessageTypes
|
|
240
|
+
* @type {Array}
|
|
241
|
+
*/
|
|
242
|
+
allStatusMessageTypes: STATUS_MESSAGE_TYPES,
|
|
243
|
+
|
|
226
244
|
/**
|
|
227
245
|
* Tablename to be used in the datastore
|
|
228
246
|
*
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "screwdriver-data-schema",
|
|
3
|
-
"version": "24.0
|
|
3
|
+
"version": "24.2.0",
|
|
4
4
|
"description": "Internal Data Schema of Screwdriver",
|
|
5
5
|
"main": "index.js",
|
|
6
6
|
"scripts": {
|
|
@@ -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.
|
|
55
|
-
"sequelize-cli": "^6.
|
|
56
|
-
"sqlite3": "^5.1.
|
|
54
|
+
"sequelize": "^6.37.5",
|
|
55
|
+
"sequelize-cli": "^6.6.2",
|
|
56
|
+
"sqlite3": "^5.1.7"
|
|
57
57
|
},
|
|
58
58
|
"dependencies": {
|
|
59
59
|
"cron-parser": "^4.7.0",
|
|
60
|
-
"joi": "^17.
|
|
60
|
+
"joi": "^17.13.3"
|
|
61
61
|
}
|
|
62
62
|
}
|