screwdriver-api 7.0.229 → 7.0.230

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/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "screwdriver-api",
3
- "version": "7.0.229",
3
+ "version": "7.0.230",
4
4
  "description": "API server for the Screwdriver.cd service",
5
5
  "main": "index.js",
6
6
  "scripts": {
@@ -110,12 +110,19 @@ Query Params:
110
110
  * `sortBy` - *Optional* Field to sort by
111
111
  * `type` - *Optional* Get pipeline or pr events (default `pipeline`)
112
112
  * `prNum` - *Optional* Return only PR events of specified PR number
113
- * `sha` - *Optional* Search `sha` and `configPipelineSha` for events
114
113
  * `groupEventId` - *Optional* Return only events with a specified groupEventId
115
114
  * `id` - *Optional* Fetch specific event ID; alternatively can use greater than(`gt:`) or less than(`lt:`) prefix
115
+ * `sha` - *Optional* Search `sha` and `configPipelineSha` for events
116
+ * `author` - *Optional* Search commit author `username` and `name` for events
117
+ * `creator` - *Optional* Search creator `username` and `name` for events
118
+ * `message` - *Optional* Search commit `message` for events
119
+
120
+ _Caveats_: Only one of the search fields can be used at one time (sha, author, creator, or message).
116
121
 
117
122
  `GET /pipelines/{id}/events?page={pageNumber}&count={countNumber}&sort={sort}&type={type}&prNum={prNumber}&sha={sha}`
118
123
 
124
+ `GET /pipelines/{id}/events?message={message}`
125
+
119
126
  `GET /pipelines/{id}/events?id=gt:{eventId}&count={countNumber}` (greater than eventId)
120
127
 
121
128
  `GET /pipelines/{id}/events?id=lt:{eventId}&count={countNumber}&sort=ascending` (less than eventId)
@@ -34,7 +34,7 @@ module.exports = () => ({
34
34
 
35
35
  handler: async (request, h) => {
36
36
  const factory = request.server.app.pipelineFactory;
37
- const { page, count, sha, prNum, id, sort, sortBy, groupEventId } = request.query;
37
+ const { page, count, sha, prNum, id, sort, sortBy, groupEventId, message, author, creator } = request.query;
38
38
 
39
39
  return factory
40
40
  .get(request.params.id)
@@ -62,13 +62,18 @@ module.exports = () => ({
62
62
  config.params.prNum = prNum;
63
63
  }
64
64
 
65
+ // Do a search
66
+ // See https://www.w3schools.com/sql/sql_like.asp for syntax
65
67
  if (sha) {
66
- config.search = {
67
- field: ['sha', 'configPipelineSha'],
68
- // Do a search for sha
69
- // See https://www.w3schools.com/sql/sql_like.asp for syntax
70
- keyword: `${sha}%`
71
- };
68
+ config.search = { field: ['sha', 'configPipelineSha'], keyword: `${sha}%` };
69
+ } else if (message) {
70
+ config.search = { field: ['commit'], keyword: `%"message":"${message}%` };
71
+ } else if (author) {
72
+ // searches name and username
73
+ config.search = { field: ['commit'], keyword: `%name":"${author}%` };
74
+ } else if (creator) {
75
+ // searches name and username
76
+ config.search = { field: ['creator'], keyword: `%name":"${creator}%` };
72
77
  }
73
78
 
74
79
  if (groupEventId) {
@@ -95,15 +100,24 @@ module.exports = () => ({
95
100
  id: pipelineIdSchema
96
101
  }),
97
102
  query: schema.api.pagination.concat(
98
- joi.object({
99
- type: typeSchema,
100
- prNum: prNumSchema,
101
- sha: shaSchema,
102
- id: queryIdSchema,
103
- groupEventId: pipelineIdSchema,
104
- search: joi.forbidden(), // we don't support search for Pipeline list events
105
- getCount: joi.forbidden() // we don't support getCount for Pipeline list events
106
- })
103
+ joi
104
+ .object({
105
+ type: typeSchema,
106
+ prNum: prNumSchema,
107
+ sha: shaSchema,
108
+ message: joi.string().label('Commit message').example('fix: Typo'),
109
+ author: joi.string().label('Author Name').example('Dao Lam'),
110
+ creator: joi.string().label('Creator Name').example('Dao Lam'),
111
+ id: queryIdSchema,
112
+ groupEventId: pipelineIdSchema,
113
+ search: joi.forbidden(), // we don't support search for Pipeline list events
114
+ getCount: joi.forbidden() // we don't support getCount for Pipeline list events
115
+ })
116
+ // https://joi.dev/api/?v=17.13.3#objectoxorpeers-options
117
+ .oxor('sha', 'message', 'author', 'creator')
118
+ .messages({
119
+ 'object.oxor': 'You can only specify one search parameter: sha, message, author, or creator.'
120
+ })
107
121
  )
108
122
  }
109
123
  }