@plusscommunities/pluss-maintenance-aws 2.0.6-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.
@@ -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
- };
@@ -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
- };
@@ -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
- };