@plusscommunities/pluss-maintenance-aws 2.0.5-auth.0 → 2.1.0-auth.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.
- package/createJob.js +25 -4
- package/deleteJob.js +3 -3
- package/editJob.js +45 -50
- package/editJobStatus.js +5 -9
- package/editNote.js +6 -6
- package/feature.config.js +23 -47
- package/getData.js +13 -86
- package/getJob.js +10 -4
- package/integration/IntegrationStrategy.js +35 -0
- package/integration/archibus/ArchibusStrategy.js +465 -0
- package/integration/index.js +22 -0
- package/jobChanged.js +36 -0
- package/package-lock.json +6180 -1898
- package/package.json +20 -8
- package/requests/assignRequest.js +100 -0
- package/requests/getAssignees.js +39 -0
- package/requests/getRequests.js +99 -0
- package/requests/helper/hasRequestPermission.js +24 -0
- package/requests/helper/isValidAssignee.js +18 -0
- package/scheduleJobImport.js +80 -0
- package/updateData.js +33 -0
- package/ticketing/addTicket.js +0 -87
- package/ticketing/deleteTicket.js +0 -50
- package/ticketing/editTicketStatus.js +0 -89
- package/ticketing/getTicket.js +0 -29
- package/ticketing/getTickets.js +0 -57
- package/ticketing/helper.js +0 -22
|
@@ -1,89 +0,0 @@
|
|
|
1
|
-
const moment = require("moment");
|
|
2
|
-
const _ = require("lodash");
|
|
3
|
-
const config = require("../config.json");
|
|
4
|
-
const { init } = require("@plusscommunities/pluss-core-aws/config");
|
|
5
|
-
const { getBody } = require("@plusscommunities/pluss-core-aws/helper");
|
|
6
|
-
const generateJsonResponse = require("@plusscommunities/pluss-core-aws/helper/generateJsonResponse");
|
|
7
|
-
const editRef = require("@plusscommunities/pluss-core-aws/db/common/editRef");
|
|
8
|
-
const getRef = require("@plusscommunities/pluss-core-aws/db/common/getRef");
|
|
9
|
-
const validateMasterAuth = require("@plusscommunities/pluss-core-aws/helper/auth/validateMasterAuth");
|
|
10
|
-
const getUserPreviewFromHeader = require("@plusscommunities/pluss-core-aws/helper/getUserPreviewFromHeader");
|
|
11
|
-
const publishActivity = require("@plusscommunities/pluss-core-aws/db/activity/publishActivity");
|
|
12
|
-
const { statusTypes } = require("./helper");
|
|
13
|
-
const {
|
|
14
|
-
statusChangeEmailTemplate,
|
|
15
|
-
} = require("@plusscommunities/pluss-core-aws/templates/supportTicketEmails");
|
|
16
|
-
const sendEmail = require("@plusscommunities/pluss-core-aws/helper/sendEmail");
|
|
17
|
-
|
|
18
|
-
const sendTicketEmail = (ticket) => {
|
|
19
|
-
getRef("users", "Id", ticket.User.id).then((user) => {
|
|
20
|
-
if (!_.isEmpty(user.email) && user.email !== "empty") {
|
|
21
|
-
const status = statusTypes[ticket.Status];
|
|
22
|
-
const subject = statusChangeEmailTemplate.subject.replace(
|
|
23
|
-
"___TITLE___",
|
|
24
|
-
ticket.Title
|
|
25
|
-
);
|
|
26
|
-
const content = statusChangeEmailTemplate.content
|
|
27
|
-
.replace("___LABELCOLOR___", status.color)
|
|
28
|
-
.replace("___STATUS___", status.text)
|
|
29
|
-
.replace("___TITLE___", ticket.Title)
|
|
30
|
-
.replace(
|
|
31
|
-
"___TEXT___",
|
|
32
|
-
ticket.Text ? ticket.Text.replace(/\n/g, " <br /> ") : ""
|
|
33
|
-
);
|
|
34
|
-
sendEmail(user.email, subject, content, true);
|
|
35
|
-
}
|
|
36
|
-
});
|
|
37
|
-
};
|
|
38
|
-
|
|
39
|
-
module.exports.editTicketStatus = (event, context, callback) => {
|
|
40
|
-
init(config);
|
|
41
|
-
const data = getBody(event);
|
|
42
|
-
|
|
43
|
-
validateMasterAuth(event, "master", "plussSpace", true).then((authorised) => {
|
|
44
|
-
if (!authorised) {
|
|
45
|
-
console.error("Authorization not valid");
|
|
46
|
-
callback(
|
|
47
|
-
null,
|
|
48
|
-
generateJsonResponse(422, {
|
|
49
|
-
error: {
|
|
50
|
-
message: "Authorization not valid.",
|
|
51
|
-
},
|
|
52
|
-
})
|
|
53
|
-
);
|
|
54
|
-
return;
|
|
55
|
-
}
|
|
56
|
-
getRef("supporttickets", "Id", data.id)
|
|
57
|
-
.then((ticket) => {
|
|
58
|
-
getUserPreviewFromHeader(event.headers.authkey).then((user) => {
|
|
59
|
-
// update the history
|
|
60
|
-
const updateTime = moment.utc().valueOf();
|
|
61
|
-
ticket.History.push({
|
|
62
|
-
Timestamp: updateTime,
|
|
63
|
-
Status: data.status,
|
|
64
|
-
User: user,
|
|
65
|
-
});
|
|
66
|
-
editRef("supporttickets", "Id", data.id, {
|
|
67
|
-
History: ticket.History,
|
|
68
|
-
Status: data.status,
|
|
69
|
-
LastUpdated: updateTime,
|
|
70
|
-
}).then((result) => {
|
|
71
|
-
publishActivity("TicketStatusChanged", result.Site, data.id, user, {
|
|
72
|
-
title: result.Title,
|
|
73
|
-
status: data.status,
|
|
74
|
-
});
|
|
75
|
-
sendTicketEmail(result);
|
|
76
|
-
callback(
|
|
77
|
-
null,
|
|
78
|
-
generateJsonResponse(200, { success: true, ticket: result })
|
|
79
|
-
);
|
|
80
|
-
return;
|
|
81
|
-
});
|
|
82
|
-
});
|
|
83
|
-
})
|
|
84
|
-
.catch((error) => {
|
|
85
|
-
callback(null, generateJsonResponse(422, { error }));
|
|
86
|
-
return;
|
|
87
|
-
});
|
|
88
|
-
});
|
|
89
|
-
};
|
package/ticketing/getTicket.js
DELETED
|
@@ -1,29 +0,0 @@
|
|
|
1
|
-
const config = require("../config.json");
|
|
2
|
-
const { init } = require("@plusscommunities/pluss-core-aws/config");
|
|
3
|
-
const generateJsonResponse = require("@plusscommunities/pluss-core-aws/helper/generateJsonResponse");
|
|
4
|
-
const getRef = require("@plusscommunities/pluss-core-aws/db/common/getRef");
|
|
5
|
-
const validateUserLoggedIn = require("@plusscommunities/pluss-core-aws/helper/auth/validateUserLoggedIn");
|
|
6
|
-
|
|
7
|
-
module.exports.getTicket = (event, context, callback) => {
|
|
8
|
-
init(config);
|
|
9
|
-
|
|
10
|
-
validateUserLoggedIn(event)
|
|
11
|
-
.then((authorised) => {
|
|
12
|
-
if (!authorised) {
|
|
13
|
-
return callback(
|
|
14
|
-
null,
|
|
15
|
-
generateJsonResponse(422, { fail: true, error: "not authorised" })
|
|
16
|
-
);
|
|
17
|
-
}
|
|
18
|
-
getRef("supporttickets", "Id", event.pathParameters.id)
|
|
19
|
-
.then((ev) => {
|
|
20
|
-
callback(null, generateJsonResponse(200, ev));
|
|
21
|
-
})
|
|
22
|
-
.catch((error) => {
|
|
23
|
-
callback(null, generateJsonResponse(400, { error }));
|
|
24
|
-
});
|
|
25
|
-
})
|
|
26
|
-
.catch((error) => {
|
|
27
|
-
callback(null, generateJsonResponse(422, { fail: true, error }));
|
|
28
|
-
});
|
|
29
|
-
};
|
package/ticketing/getTickets.js
DELETED
|
@@ -1,57 +0,0 @@
|
|
|
1
|
-
const config = require("../config.json");
|
|
2
|
-
const { init } = require("@plusscommunities/pluss-core-aws/config");
|
|
3
|
-
const generateJsonResponse = require("@plusscommunities/pluss-core-aws/helper/generateJsonResponse");
|
|
4
|
-
const { thisOrDefault } = require("@plusscommunities/pluss-core-aws/helper");
|
|
5
|
-
const indexQuery = require("@plusscommunities/pluss-core-aws/db/common/indexQuery");
|
|
6
|
-
const scanRef = require("@plusscommunities/pluss-core-aws/db/common/scanRef");
|
|
7
|
-
const validateSiteAccess = require("@plusscommunities/pluss-core-aws/helper/auth/validateSiteAccess");
|
|
8
|
-
|
|
9
|
-
const runQuery = (site) => {
|
|
10
|
-
if (site === "hq") {
|
|
11
|
-
console.log("scanning for all tickets");
|
|
12
|
-
return scanRef("supporttickets");
|
|
13
|
-
}
|
|
14
|
-
const query = {
|
|
15
|
-
IndexName: "TicketsSiteStatusIndex",
|
|
16
|
-
KeyConditionExpression: "Site = :site",
|
|
17
|
-
ExpressionAttributeValues: {
|
|
18
|
-
":site": site,
|
|
19
|
-
},
|
|
20
|
-
};
|
|
21
|
-
console.log("running query");
|
|
22
|
-
console.log(query);
|
|
23
|
-
return indexQuery("supporttickets", query);
|
|
24
|
-
};
|
|
25
|
-
|
|
26
|
-
module.exports.getTickets = (event, context, callback) => {
|
|
27
|
-
console.log("Getting tickets");
|
|
28
|
-
init(config);
|
|
29
|
-
|
|
30
|
-
const params = thisOrDefault(event.queryStringParameters, {});
|
|
31
|
-
const site = thisOrDefault(params.site, "newstead");
|
|
32
|
-
console.log(params);
|
|
33
|
-
|
|
34
|
-
validateSiteAccess(event, params.site)
|
|
35
|
-
.then((authorised) => {
|
|
36
|
-
if (!authorised) {
|
|
37
|
-
return callback(
|
|
38
|
-
null,
|
|
39
|
-
generateJsonResponse(422, { fail: true, error: "not authorised" })
|
|
40
|
-
);
|
|
41
|
-
}
|
|
42
|
-
runQuery(site)
|
|
43
|
-
.then((data) => {
|
|
44
|
-
console.log("successful query");
|
|
45
|
-
console.log(data);
|
|
46
|
-
callback(null, generateJsonResponse(200, data.Items));
|
|
47
|
-
})
|
|
48
|
-
.catch((error) => {
|
|
49
|
-
console.log("query failed");
|
|
50
|
-
console.log(error);
|
|
51
|
-
callback(null, generateJsonResponse(200, { error }));
|
|
52
|
-
});
|
|
53
|
-
})
|
|
54
|
-
.catch((error) => {
|
|
55
|
-
callback(null, generateJsonResponse(422, { fail: true, error }));
|
|
56
|
-
});
|
|
57
|
-
};
|
package/ticketing/helper.js
DELETED
|
@@ -1,22 +0,0 @@
|
|
|
1
|
-
module.exports.statusTypes = {
|
|
2
|
-
open: {
|
|
3
|
-
text: "Open",
|
|
4
|
-
order: 0,
|
|
5
|
-
color: "#5e9efc",
|
|
6
|
-
},
|
|
7
|
-
review: {
|
|
8
|
-
text: "Under Review",
|
|
9
|
-
order: 1,
|
|
10
|
-
color: "#8695b2",
|
|
11
|
-
},
|
|
12
|
-
progress: {
|
|
13
|
-
text: "In Progress",
|
|
14
|
-
order: 2,
|
|
15
|
-
color: "#f5c549",
|
|
16
|
-
},
|
|
17
|
-
closed: {
|
|
18
|
-
text: "Closed",
|
|
19
|
-
order: 3,
|
|
20
|
-
color: "#18cca2",
|
|
21
|
-
},
|
|
22
|
-
};
|