2
2
* Job Processor Service
3
3
*/
4
4
5
- const _ = require ( 'lodash' )
6
5
const Joi = require ( '@hapi/joi' )
7
6
const logger = require ( '../common/logger' )
8
7
const helper = require ( '../common/helper' )
@@ -51,7 +50,7 @@ async function processCreate (message, transactionId) {
51
50
index : config . get ( 'esConfig.ES_INDEX_JOB' ) ,
52
51
id : job . id ,
53
52
transactionId,
54
- body : _ . omit ( job , 'id' ) ,
53
+ body : job ,
55
54
refresh : constants . esRefreshOption
56
55
} )
57
56
await postMessageToZapier ( {
@@ -69,18 +68,20 @@ processCreate.schema = {
69
68
payload : Joi . object ( ) . keys ( {
70
69
id : Joi . string ( ) . uuid ( ) . required ( ) ,
71
70
projectId : Joi . number ( ) . integer ( ) . required ( ) ,
72
- externalId : Joi . string ( ) ,
73
- description : Joi . string ( ) ,
71
+ externalId : Joi . string ( ) . allow ( null ) ,
72
+ description : Joi . stringAllowEmpty ( ) . allow ( null ) ,
74
73
title : Joi . title ( ) . required ( ) ,
75
- startDate : Joi . date ( ) ,
76
- endDate : Joi . date ( ) ,
74
+ startDate : Joi . date ( ) . allow ( null ) ,
75
+ duration : Joi . number ( ) . integer ( ) . min ( 1 ) . allow ( null ) ,
77
76
numPositions : Joi . number ( ) . integer ( ) . min ( 1 ) . required ( ) ,
78
- resourceType : Joi . string ( ) ,
79
- rateType : Joi . rateType ( ) ,
80
- workload : Joi . workload ( ) ,
77
+ resourceType : Joi . stringAllowEmpty ( ) . allow ( null ) ,
78
+ rateType : Joi . rateType ( ) . allow ( null ) ,
79
+ workload : Joi . workload ( ) . allow ( null ) ,
81
80
skills : Joi . array ( ) . items ( Joi . string ( ) . uuid ( ) ) . required ( ) ,
82
81
createdAt : Joi . date ( ) . required ( ) ,
83
82
createdBy : Joi . string ( ) . uuid ( ) . required ( ) ,
83
+ updatedAt : Joi . date ( ) . allow ( null ) ,
84
+ updatedBy : Joi . string ( ) . uuid ( ) . allow ( null ) ,
84
85
status : Joi . jobStatus ( ) . required ( )
85
86
} ) . required ( )
86
87
} ) . required ( ) ,
@@ -99,7 +100,7 @@ async function processUpdate (message, transactionId) {
99
100
id : data . id ,
100
101
transactionId,
101
102
body : {
102
- doc : _ . omit ( data , [ 'id' ] )
103
+ doc : data
103
104
} ,
104
105
refresh : constants . esRefreshOption
105
106
} )
@@ -109,32 +110,7 @@ async function processUpdate (message, transactionId) {
109
110
} )
110
111
}
111
112
112
- processUpdate . schema = {
113
- message : Joi . object ( ) . keys ( {
114
- topic : Joi . string ( ) . required ( ) ,
115
- originator : Joi . string ( ) . required ( ) ,
116
- timestamp : Joi . date ( ) . required ( ) ,
117
- 'mime-type' : Joi . string ( ) . required ( ) ,
118
- payload : Joi . object ( ) . keys ( {
119
- id : Joi . string ( ) . uuid ( ) . required ( ) ,
120
- projectId : Joi . number ( ) . integer ( ) ,
121
- externalId : Joi . string ( ) ,
122
- description : Joi . string ( ) ,
123
- title : Joi . title ( ) ,
124
- startDate : Joi . date ( ) ,
125
- endDate : Joi . date ( ) ,
126
- numPositions : Joi . number ( ) . integer ( ) . min ( 1 ) ,
127
- resourceType : Joi . string ( ) ,
128
- rateType : Joi . rateType ( ) ,
129
- workload : Joi . workload ( ) ,
130
- skills : Joi . array ( ) . items ( Joi . string ( ) . uuid ( ) ) ,
131
- status : Joi . jobStatus ( ) ,
132
- updatedAt : Joi . date ( ) ,
133
- updatedBy : Joi . string ( ) . uuid ( )
134
- } ) . required ( )
135
- } ) . required ( ) ,
136
- transactionId : Joi . string ( ) . required ( )
137
- }
113
+ processUpdate . schema = processCreate . schema
138
114
139
115
/**
140
116
* Process delete entity message
0 commit comments