@plusscommunities/pluss-maintenance-aws 2.1.13 → 2.1.14-beta.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.
@@ -9,6 +9,7 @@ const updateRef = require("@plusscommunities/pluss-core-aws/db/common/updateRef"
9
9
  const indexQuery = require("@plusscommunities/pluss-core-aws/db/common/indexQuery");
10
10
  const publishNotifications = require("@plusscommunities/pluss-core-aws/db/notifications/publishNotifications");
11
11
  const getRef = require("@plusscommunities/pluss-core-aws/db/common/getRef");
12
+ const getString = require("@plusscommunities/pluss-core-aws/db/strings/getString");
12
13
  const { values } = require("../../values.config");
13
14
 
14
15
  class ArchibusStrategy extends IntegrationStrategy {
@@ -23,6 +24,7 @@ class ArchibusStrategy extends IntegrationStrategy {
23
24
 
24
25
  this.statusMap = config.StatusMap;
25
26
  this.siteMap = config.SiteMap ?? {};
27
+ this.buildingCodes = [];
26
28
  }
27
29
 
28
30
  /**
@@ -61,10 +63,48 @@ class ArchibusStrategy extends IntegrationStrategy {
61
63
  */
62
64
  createRequest = async (request, mockResponse = null) => {
63
65
  const logId = log("Archibus:CreateRequest", "Start", request);
64
- const siteId = this.siteMap[request.site];
66
+
67
+ let siteId = this.siteMap[request.site];
68
+ let buildingCode = null;
69
+ if (request.room) {
70
+ if (this.buildingCodes.length === 0) {
71
+ this.buildingCodes = await getString(
72
+ getRowId(request.site, `${values.serviceKey}buildingcodes`),
73
+ "plussSpace"
74
+ );
75
+ }
76
+ const building = this.buildingCodes.find((b) => {
77
+ const address = request.room.toLowerCase();
78
+ const search = b.SearchString.toLowerCase();
79
+ const name = b.BuildingName.toLowerCase();
80
+ return address.includes(search) || address.includes(name);
81
+ });
82
+
83
+ if (building?.SiteCode) siteId = building.SiteCode.toString();
84
+ buildingCode = building?.BuildingCode;
85
+ }
65
86
  if (!siteId) return false;
66
87
 
67
88
  try {
89
+ const data = {
90
+ prob_type: "1.ON-SITE|1. MAINTENANCE",
91
+ requestor: "PLUSS",
92
+ description: `${request.title}${
93
+ _.isEmpty(request.description) ? "" : `\n\n${request.description}`
94
+ }${_.isEmpty(request.room) ? "" : `\n\nLocation: ${request.room}`}${
95
+ _.isEmpty(request.userName) ? "" : `\n\nName: ${request.userName}`
96
+ }${_.isEmpty(request.phone) ? "" : `\n\nPhone: ${request.phone}`}${
97
+ _.isEmpty(request.type) ? "" : `\n\nJob Type: ${request.type}`
98
+ }${
99
+ _.isEmpty(request.images)
100
+ ? ""
101
+ : `\n\nImages: ${request.images.join("\n")}`
102
+ }`,
103
+ site_id: siteId,
104
+ };
105
+ if (buildingCode) data.bl_id = buildingCode;
106
+ log("Archibus:CreateRequest", "Request", data, logId);
107
+
68
108
  const response =
69
109
  mockResponse ??
70
110
  (await axios({
@@ -76,29 +116,9 @@ class ArchibusStrategy extends IntegrationStrategy {
76
116
  "Content-Type": "application/json",
77
117
  Host: this.host,
78
118
  },
79
- data: {
80
- prob_type: "1.ON-SITE|1. MAINTENANCE",
81
- requestor: "PLUSS",
82
- description: `${request.title}${
83
- _.isEmpty(request.description) ? "" : `\n\n${request.description}`
84
- }${_.isEmpty(request.room) ? "" : `\n\nLocation: ${request.room}`}${
85
- _.isEmpty(request.userName) ? "" : `\n\nName: ${request.userName}`
86
- }${_.isEmpty(request.phone) ? "" : `\n\nPhone: ${request.phone}`}${
87
- _.isEmpty(request.type) ? "" : `\n\nJob Type: ${request.type}`
88
- }${
89
- _.isEmpty(request.images)
90
- ? ""
91
- : `\n\nImages: ${request.images.join("\n")}`
92
- }`,
93
- site_id: siteId,
94
- },
119
+ data,
95
120
  }));
96
- log(
97
- "Archibus:CreateRequest",
98
- "Response",
99
- { data: response.data, siteId },
100
- logId
101
- );
121
+ log("Archibus:CreateRequest", "Response", response.data, logId);
102
122
 
103
123
  // Save the ID to external entities for future reference
104
124
  await updateRef("externalentities", {
package/package-lock.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@plusscommunities/pluss-maintenance-aws",
3
- "version": "2.1.13",
3
+ "version": "2.1.14-beta.0",
4
4
  "lockfileVersion": 1,
5
5
  "requires": true,
6
6
  "dependencies": {
@@ -1744,7 +1744,7 @@
1744
1744
  "asynckit": {
1745
1745
  "version": "0.4.0",
1746
1746
  "resolved": "https://registry.npmjs.org/asynckit/-/asynckit-0.4.0.tgz",
1747
- "integrity": "sha512-Oei9OH4tRh0YqU3GxhX79dM/mwVgvbZJaSNaRk+bshkj0S5cfHcgYakreBjrHwatXKbz+IoIdYLxrKim2MjW0Q=="
1747
+ "integrity": "sha1-x57Zf380y48robyXkLzDZkdLS3k="
1748
1748
  },
1749
1749
  "available-typed-arrays": {
1750
1750
  "version": "1.0.7",
@@ -2579,7 +2579,7 @@
2579
2579
  "delayed-stream": {
2580
2580
  "version": "1.0.0",
2581
2581
  "resolved": "https://registry.npmjs.org/delayed-stream/-/delayed-stream-1.0.0.tgz",
2582
- "integrity": "sha512-ZySD7Nf91aLB0RxL4KGrKHBXl7Eds1DAmEdcoVawXnLD7SDhpNgtuII2aAkg7a7QS41jxPSZ17p4VdGnMHk3MQ=="
2582
+ "integrity": "sha1-3zrhmayt+31ECqrgsp4icrJOxhk="
2583
2583
  },
2584
2584
  "detect-newline": {
2585
2585
  "version": "3.1.0",
@@ -3077,7 +3077,7 @@
3077
3077
  "events": {
3078
3078
  "version": "1.1.1",
3079
3079
  "resolved": "https://registry.npmjs.org/events/-/events-1.1.1.tgz",
3080
- "integrity": "sha512-kEcvvCBByWXGnZy6JUlgAp2gBIUjfCAV6P6TgT1/aaQKcmuAEC4OZTV1I4EWQLz2gxZw76atuVyvHhTxvi0Flw=="
3080
+ "integrity": "sha1-nr23Y1rQmccNzEwqH1AEKI6L2SQ="
3081
3081
  },
3082
3082
  "execa": {
3083
3083
  "version": "5.1.1",
@@ -6657,7 +6657,7 @@
6657
6657
  "querystring": {
6658
6658
  "version": "0.2.0",
6659
6659
  "resolved": "https://registry.npmjs.org/querystring/-/querystring-0.2.0.tgz",
6660
- "integrity": "sha512-X/xY82scca2tau62i9mDyU9K+I+djTMUsvwf7xnUX5GLvVzgJybOJf4Y6o9Zx3oJK/LSXg5tTZBjwzqVPaPO2g=="
6660
+ "integrity": "sha1-sgmEkgO7Jd+CDadW50cAWHhSFiA="
6661
6661
  },
6662
6662
  "querystringify": {
6663
6663
  "version": "2.2.0",
@@ -6808,7 +6808,7 @@
6808
6808
  "sax": {
6809
6809
  "version": "1.2.1",
6810
6810
  "resolved": "https://registry.npmjs.org/sax/-/sax-1.2.1.tgz",
6811
- "integrity": "sha512-8I2a3LovHTOpm7NV5yOyO8IHqgVsfK4+UuySrXU8YXkSRX7k6hCV9b3HrkKCr3nMpgj+0bmocaJJWpvp1oc7ZA=="
6811
+ "integrity": "sha1-e45lYZCyKOgaZq6nSEgNgozS03o="
6812
6812
  },
6813
6813
  "scmp": {
6814
6814
  "version": "2.1.0",
@@ -7308,7 +7308,7 @@
7308
7308
  "url": {
7309
7309
  "version": "0.10.3",
7310
7310
  "resolved": "https://registry.npmjs.org/url/-/url-0.10.3.tgz",
7311
- "integrity": "sha512-hzSUW2q06EqL1gKM/a+obYHLIO6ct2hwPuviqTTOcfFVc61UbfJ2Q32+uGL/HCPxKqrdGB5QUwIe7UqlDgwsOQ==",
7311
+ "integrity": "sha1-Ah5NnHcF8hu/N9A861h2dAJ3TGQ=",
7312
7312
  "requires": {
7313
7313
  "punycode": "1.3.2",
7314
7314
  "querystring": "0.2.0"
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@plusscommunities/pluss-maintenance-aws",
3
- "version": "2.1.13",
3
+ "version": "2.1.14-beta.0",
4
4
  "description": "Extension package to enable maintenance on Pluss Communities Platform",
5
5
  "scripts": {
6
6
  "gc": "node ../../tools/gc ./",