@plusscommunities/pluss-maintenance-aws 2.1.45 → 2.1.46
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/createJob.js +201 -114
- package/createJobType.js +49 -49
- package/db/maintenance/addMaintenanceJob.js +100 -90
- package/db/maintenance/editMaintenanceJob.js +22 -12
- package/db/maintenance/getJobEmail.js +22 -22
- package/deleteJob.js +58 -58
- package/deleteJobType.js +40 -40
- package/editJob.js +126 -65
- package/editJobStatus.js +57 -57
- package/editJobType.js +61 -61
- package/editNote.js +117 -117
- package/feature.config.js +279 -270
- package/getData.js +48 -41
- package/getJob.js +4 -4
- package/getJobType.js +35 -35
- package/getJobTypes.js +66 -66
- package/getJobs.js +48 -48
- package/integration/IntegrationStrategy.js +52 -52
- package/integration/archibus/ArchibusStrategy.js +42 -28
- package/integration/index.js +19 -19
- package/jobChanged.js +88 -89
- package/jobTypesChanged.js +52 -39
- package/package.json +3 -3
- package/requests/assignRequest.js +81 -81
- package/requests/getAssignees.js +27 -27
- package/requests/getExternalSync.js +100 -100
- package/requests/getPropertyRequests.js +89 -0
- package/requests/getRequest.js +77 -77
- package/requests/helper/hasRequestPermission.js +12 -12
- package/requests/helper/isValidAssignee.js +10 -10
- package/requests/retrySync.js +90 -90
- package/requests/setExternalJobId.js +113 -113
- package/requests/updatePriority.js +33 -33
- package/scheduleJobImport.js +63 -63
- package/sendJobEmail.js +105 -104
- package/updateData.js +34 -34
- package/values.config.a.js +26 -25
- package/values.config.default.js +30 -28
- package/values.config.enquiry.js +222 -221
- package/values.config.feedback.js +194 -193
- package/values.config.food.js +29 -28
- package/values.config.forms.js +29 -28
- package/values.config.js +30 -28
- package/watchJobs.js +154 -154
package/editJobType.js
CHANGED
|
@@ -8,69 +8,69 @@ const getRef = require("@plusscommunities/pluss-core-aws/db/common/getRef");
|
|
|
8
8
|
const { values } = require("./values.config");
|
|
9
9
|
|
|
10
10
|
module.exports.editJobType = (event, context, callback) => {
|
|
11
|
-
|
|
12
|
-
|
|
11
|
+
init(config);
|
|
12
|
+
const data = getBody(event);
|
|
13
13
|
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
|
|
14
|
+
if (!data.site || !data.name || !data.email || !data.description) {
|
|
15
|
+
return callback(
|
|
16
|
+
null,
|
|
17
|
+
generateJsonResponse(422, { error: "No site, type or email attached" }),
|
|
18
|
+
);
|
|
19
|
+
}
|
|
20
20
|
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
|
|
24
|
-
|
|
25
|
-
|
|
26
|
-
|
|
27
|
-
|
|
28
|
-
|
|
29
|
-
|
|
30
|
-
|
|
31
|
-
|
|
21
|
+
validateMasterAuth(event, values.permissionMaintenanceTypes).then(
|
|
22
|
+
(authorised) => {
|
|
23
|
+
if (!authorised) {
|
|
24
|
+
console.error("Authorization not valid");
|
|
25
|
+
return callback(
|
|
26
|
+
null,
|
|
27
|
+
generateJsonResponse(422, {
|
|
28
|
+
error: { message: "Admin - Create User - not authorized." },
|
|
29
|
+
}),
|
|
30
|
+
);
|
|
31
|
+
}
|
|
32
32
|
|
|
33
|
-
|
|
34
|
-
|
|
35
|
-
|
|
36
|
-
|
|
37
|
-
|
|
38
|
-
|
|
39
|
-
|
|
40
|
-
|
|
41
|
-
|
|
42
|
-
|
|
33
|
+
const jobType = {
|
|
34
|
+
id: data.id,
|
|
35
|
+
email: data.email,
|
|
36
|
+
typeName: data.name,
|
|
37
|
+
description: data.description,
|
|
38
|
+
level: data.level,
|
|
39
|
+
site: data.site,
|
|
40
|
+
hasCustomFields: data.hasCustomFields ?? false,
|
|
41
|
+
customFields: data.customFields ?? [],
|
|
42
|
+
};
|
|
43
43
|
|
|
44
|
-
|
|
45
|
-
|
|
46
|
-
|
|
47
|
-
|
|
48
|
-
|
|
49
|
-
|
|
50
|
-
|
|
51
|
-
|
|
52
|
-
|
|
53
|
-
|
|
54
|
-
|
|
55
|
-
|
|
56
|
-
|
|
57
|
-
|
|
58
|
-
|
|
59
|
-
|
|
60
|
-
|
|
61
|
-
|
|
62
|
-
|
|
63
|
-
|
|
64
|
-
|
|
65
|
-
|
|
66
|
-
|
|
67
|
-
|
|
68
|
-
|
|
69
|
-
|
|
70
|
-
|
|
71
|
-
|
|
72
|
-
|
|
73
|
-
|
|
74
|
-
|
|
75
|
-
|
|
44
|
+
getRef(values.tableNameJobTypes, "id", data.id).then((result) => {
|
|
45
|
+
if (result.site !== data.site) {
|
|
46
|
+
return callback(
|
|
47
|
+
null,
|
|
48
|
+
generateJsonResponse(422, {
|
|
49
|
+
error: {
|
|
50
|
+
message: "Incorrect site.",
|
|
51
|
+
},
|
|
52
|
+
}),
|
|
53
|
+
);
|
|
54
|
+
}
|
|
55
|
+
editRef(values.tableNameJobTypes, "id", data.id, jobType)
|
|
56
|
+
.then((result) => {
|
|
57
|
+
return callback(
|
|
58
|
+
null,
|
|
59
|
+
generateJsonResponse(200, {
|
|
60
|
+
success: true,
|
|
61
|
+
jobType: result,
|
|
62
|
+
}),
|
|
63
|
+
);
|
|
64
|
+
})
|
|
65
|
+
.catch((error) => {
|
|
66
|
+
return callback(
|
|
67
|
+
null,
|
|
68
|
+
generateJsonResponse(422, {
|
|
69
|
+
error,
|
|
70
|
+
}),
|
|
71
|
+
);
|
|
72
|
+
});
|
|
73
|
+
});
|
|
74
|
+
},
|
|
75
|
+
);
|
|
76
76
|
};
|
package/editNote.js
CHANGED
|
@@ -13,124 +13,124 @@ const hasRequestPermission = require("./requests/helper/hasRequestPermission");
|
|
|
13
13
|
const { values } = require("./values.config");
|
|
14
14
|
|
|
15
15
|
module.exports.editNote = (event, context, callback) => {
|
|
16
|
-
|
|
17
|
-
|
|
16
|
+
init(config);
|
|
17
|
+
const data = getBody(event);
|
|
18
18
|
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
|
|
24
|
-
|
|
25
|
-
|
|
26
|
-
|
|
27
|
-
|
|
28
|
-
|
|
29
|
-
|
|
30
|
-
|
|
31
|
-
|
|
32
|
-
|
|
33
|
-
|
|
34
|
-
|
|
35
|
-
|
|
36
|
-
|
|
37
|
-
|
|
38
|
-
|
|
39
|
-
|
|
40
|
-
|
|
41
|
-
|
|
42
|
-
|
|
43
|
-
|
|
44
|
-
|
|
45
|
-
|
|
46
|
-
|
|
47
|
-
|
|
48
|
-
|
|
49
|
-
|
|
50
|
-
|
|
51
|
-
|
|
52
|
-
|
|
19
|
+
if (!data.action || !data.id) {
|
|
20
|
+
return callback(
|
|
21
|
+
null,
|
|
22
|
+
generateJsonResponse(422, { error: { message: "Incomplete data" } }),
|
|
23
|
+
);
|
|
24
|
+
}
|
|
25
|
+
switch (data.action) {
|
|
26
|
+
case "AddNote":
|
|
27
|
+
if (!data.note && !data.attachments && !data.images) {
|
|
28
|
+
return callback(
|
|
29
|
+
null,
|
|
30
|
+
generateJsonResponse(422, { error: { message: "Incomplete data" } }),
|
|
31
|
+
);
|
|
32
|
+
}
|
|
33
|
+
break;
|
|
34
|
+
case "DeleteNote":
|
|
35
|
+
if (!data.noteId) {
|
|
36
|
+
return callback(
|
|
37
|
+
null,
|
|
38
|
+
generateJsonResponse(422, { error: { message: "Incomplete data" } }),
|
|
39
|
+
);
|
|
40
|
+
}
|
|
41
|
+
break;
|
|
42
|
+
case "EditNote":
|
|
43
|
+
if ((!data.note && !data.attachments && !data.images) || !data.noteId) {
|
|
44
|
+
return callback(
|
|
45
|
+
null,
|
|
46
|
+
generateJsonResponse(422, { error: { message: "Incomplete data" } }),
|
|
47
|
+
);
|
|
48
|
+
}
|
|
49
|
+
break;
|
|
50
|
+
default:
|
|
51
|
+
break;
|
|
52
|
+
}
|
|
53
53
|
|
|
54
|
-
|
|
55
|
-
|
|
56
|
-
|
|
57
|
-
|
|
58
|
-
|
|
59
|
-
|
|
60
|
-
|
|
61
|
-
|
|
62
|
-
|
|
63
|
-
|
|
64
|
-
|
|
65
|
-
|
|
66
|
-
|
|
67
|
-
|
|
68
|
-
|
|
69
|
-
|
|
70
|
-
|
|
71
|
-
|
|
72
|
-
|
|
73
|
-
|
|
74
|
-
|
|
75
|
-
|
|
76
|
-
|
|
77
|
-
|
|
78
|
-
|
|
79
|
-
|
|
80
|
-
|
|
81
|
-
|
|
82
|
-
|
|
83
|
-
|
|
84
|
-
|
|
85
|
-
|
|
86
|
-
|
|
87
|
-
|
|
88
|
-
|
|
89
|
-
|
|
90
|
-
|
|
91
|
-
|
|
92
|
-
|
|
93
|
-
|
|
94
|
-
|
|
95
|
-
|
|
96
|
-
|
|
97
|
-
|
|
98
|
-
|
|
99
|
-
|
|
100
|
-
|
|
101
|
-
|
|
102
|
-
|
|
103
|
-
|
|
104
|
-
|
|
105
|
-
|
|
106
|
-
|
|
107
|
-
|
|
108
|
-
|
|
109
|
-
|
|
110
|
-
|
|
111
|
-
|
|
112
|
-
|
|
113
|
-
|
|
54
|
+
getRef(values.tableNameMaintenance, "id", data.id).then((job) => {
|
|
55
|
+
hasRequestPermission(event, job)
|
|
56
|
+
.then((authorised) => {
|
|
57
|
+
if (!authorised) {
|
|
58
|
+
console.error("Authorization not valid");
|
|
59
|
+
return callback(
|
|
60
|
+
null,
|
|
61
|
+
generateJsonResponse(403, {
|
|
62
|
+
error: { message: "not authorized." },
|
|
63
|
+
}),
|
|
64
|
+
);
|
|
65
|
+
}
|
|
66
|
+
getUserPreviewFromReq(event).then((user) => {
|
|
67
|
+
let activityAction = "";
|
|
68
|
+
switch (data.action) {
|
|
69
|
+
case "AddNote":
|
|
70
|
+
if (!job.Notes) {
|
|
71
|
+
job.Notes = [];
|
|
72
|
+
}
|
|
73
|
+
job.Notes.push({
|
|
74
|
+
Id: uuid.v4(),
|
|
75
|
+
Timestamp: moment.utc().valueOf(),
|
|
76
|
+
User: user,
|
|
77
|
+
Note: data.note,
|
|
78
|
+
Attachments: data.attachments,
|
|
79
|
+
Images: data.images,
|
|
80
|
+
});
|
|
81
|
+
activityAction = values.activityAddMaintenanceNote;
|
|
82
|
+
break;
|
|
83
|
+
case "DeleteNote":
|
|
84
|
+
job.Notes = _.filter(job.Notes, (n) => {
|
|
85
|
+
return n.Id !== data.noteId;
|
|
86
|
+
});
|
|
87
|
+
activityAction = values.activityDeleteMaintenanceNote;
|
|
88
|
+
break;
|
|
89
|
+
case "EditNote":
|
|
90
|
+
const note = _.find(job.Notes, (n) => {
|
|
91
|
+
return n.Id === data.noteId;
|
|
92
|
+
});
|
|
93
|
+
if (!note) {
|
|
94
|
+
return callback(
|
|
95
|
+
null,
|
|
96
|
+
generateJsonResponse(404, {
|
|
97
|
+
error: { message: "Note not found" },
|
|
98
|
+
}),
|
|
99
|
+
);
|
|
100
|
+
}
|
|
101
|
+
note.Note = data.note;
|
|
102
|
+
note.Attachments = data.attachments;
|
|
103
|
+
note.Images = data.images;
|
|
104
|
+
activityAction = values.activityEditMaintenanceNote;
|
|
105
|
+
break;
|
|
106
|
+
default:
|
|
107
|
+
break;
|
|
108
|
+
}
|
|
109
|
+
updateRef(values.tableNameMaintenance, job).then((result) => {
|
|
110
|
+
publishActivity(activityAction, result.site, result.id, user, {
|
|
111
|
+
title: result.title,
|
|
112
|
+
description: result.description,
|
|
113
|
+
});
|
|
114
114
|
|
|
115
|
-
|
|
116
|
-
|
|
117
|
-
|
|
118
|
-
|
|
119
|
-
|
|
120
|
-
|
|
121
|
-
|
|
122
|
-
|
|
123
|
-
|
|
124
|
-
|
|
125
|
-
|
|
126
|
-
|
|
127
|
-
|
|
128
|
-
|
|
129
|
-
|
|
130
|
-
|
|
131
|
-
|
|
132
|
-
|
|
133
|
-
|
|
134
|
-
|
|
135
|
-
|
|
115
|
+
return callback(
|
|
116
|
+
null,
|
|
117
|
+
generateJsonResponse(200, {
|
|
118
|
+
success: true,
|
|
119
|
+
job: result,
|
|
120
|
+
}),
|
|
121
|
+
);
|
|
122
|
+
});
|
|
123
|
+
});
|
|
124
|
+
})
|
|
125
|
+
.catch((error) => {
|
|
126
|
+
console.log("Fail on edit job authentication");
|
|
127
|
+
console.log(error);
|
|
128
|
+
return callback(
|
|
129
|
+
null,
|
|
130
|
+
generateJsonResponse(422, {
|
|
131
|
+
error,
|
|
132
|
+
}),
|
|
133
|
+
);
|
|
134
|
+
});
|
|
135
|
+
});
|
|
136
136
|
};
|