tabletcommand-backend-models 7.4.61 → 7.4.62

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.
@@ -2,12 +2,15 @@ import {
2
2
  MongooseModule,
3
3
  } from "../../helpers";
4
4
  import { EncryptedDataType } from "../../types/common";
5
- import { FireMapperAuthType } from "../../types/firemapper-auth";
5
+ import {
6
+ FireMapperAuthType,
7
+ FireMapperAuthV2Type,
8
+ } from "../../types/firemapper-auth";
6
9
 
7
- export default function FireMapperAuthSchema(mongoose: MongooseModule) {
10
+ export function FireMapperAuthSchema(mongoose: MongooseModule) {
8
11
  const { Schema } = mongoose;
9
12
 
10
- const FireMapperEncrypted = new Schema<EncryptedDataType>({
13
+ const EncryptedData = new Schema<EncryptedDataType>({
11
14
  iv: {
12
15
  type: String,
13
16
  default: "",
@@ -27,11 +30,53 @@ export default function FireMapperAuthSchema(mongoose: MongooseModule) {
27
30
  default: "",
28
31
  },
29
32
  encrypted: {
30
- type: FireMapperEncrypted,
33
+ type: EncryptedData,
31
34
  default: null,
32
35
  },
33
36
  encryptedAccessCode: {
34
- type: FireMapperEncrypted,
37
+ type: EncryptedData,
38
+ default: null,
39
+ },
40
+ }, {
41
+ _id: false,
42
+ id: false,
43
+ });
44
+
45
+ return FireMapperAuth;
46
+ }
47
+
48
+ export function FireMapperAuthV2Schema(mongoose: MongooseModule) {
49
+ const { Schema } = mongoose;
50
+
51
+ const EncryptedData = new Schema<EncryptedDataType>({
52
+ iv: {
53
+ type: String,
54
+ default: "",
55
+ },
56
+ encryptedData: {
57
+ type: String,
58
+ default: "",
59
+ },
60
+ }, {
61
+ _id: false,
62
+ id: false,
63
+ });
64
+
65
+ const FireMapperAuth = new Schema<FireMapperAuthV2Type>({
66
+ username: {
67
+ type: String,
68
+ default: "",
69
+ },
70
+ apiKeyReadOnly: {
71
+ type: EncryptedData,
72
+ default: null,
73
+ },
74
+ apiKeyManagement: {
75
+ type: EncryptedData,
76
+ default: null,
77
+ },
78
+ licenseCode: {
79
+ type: EncryptedData,
35
80
  default: null,
36
81
  },
37
82
  }, {
@@ -39,56 +39,22 @@ describe("Department", function() {
39
39
  await models.Department.findOne({ _id: testItem._id }).lean();
40
40
  assert.isNotNull(sut._id);
41
41
  assert.isNotNull(sut.id);
42
- assert.equal(sut.department, testItem.department);
43
42
  assert.equal(sut.addressDetails.city, testItem.addressDetails?.city);
44
43
  assert.isTrue(sut.active);
45
- assert.equal(sut.apikey, testItem.apikey);
46
- assert.equal(sut.partialApiKey, testItem.partialApiKey);
47
- assert.isTrue(sut.personnelStaffingEnabled);
48
- assert.isTrue(sut.rtsEnabled);
49
- assert.equal(sut.rtsChannelPrefix, testItem.rtsChannelPrefix);
50
- assert.equal(sut.pubNubV3.token, testItem.pubNubV3?.token);
51
- assert.equal(sut.pubNubV3.expireAt.toISOString(), testItem.pubNubV3?.expireAt.toISOString());
52
- assert.equal(sut.pubNubV3.runAt.toISOString(), testItem.pubNubV3?.runAt.toISOString());
53
- assert.equal(sut.pubNubV3.env, testItem.pubNubV3?.env);
54
- assert.equal(sut.signupKey, testItem.signupKey);
55
- assert.equal(sut.incidentTypes.length, 1);
44
+ assert.equal(sut.accountType, testItem.accountType);
56
45
  assert.equal(sut.agencyIds.length, 1);
57
46
  if (testItem.agencyIds?.length) {
58
47
  assert.equal(sut.agencyIds[0], testItem.agencyIds[0]);
59
48
  } else {
60
49
  assert.equal(testItem.agencyIds?.length, 1);
61
50
  }
62
- assert.equal(sut.safetyPriorityKeywords.length, 3);
63
- if (testItem.incidentTypes?.length) {
64
- assert.equal(sut.incidentTypes[0]?.name, testItem.incidentTypes[0]?.name);
65
- } else {
66
- assert.equal(testItem.incidentTypes?.length, 1);
67
- }
68
- assert.isFalse(sut.shareLocationPhones);
69
- assert.isTrue(sut.shareLocationTablets);
51
+ assert.equal(sut.apikey, testItem.apikey);
70
52
  assert.isFalse(sut.cadOneWayVehiclesEnabled);
71
53
  assert.isFalse(sut.cadGetLocationEnabled);
72
- assert.isTrue(sut.mowsEnabled);
73
- assert.isTrue(sut.shareAVL.enabled);
74
- assert.equal(sut.shareAVL.opAreaCode, testItem.shareAVL?.opAreaCode);
75
- assert.equal(sut.shareAVL.opAreaName, testItem.shareAVL?.opAreaName);
76
- assert.equal(sut.accountType, testItem.accountType);
77
- assert.equal(sut.timeZone, testItem.timeZone);
78
- assert.equal(sut.firstArrivingEnabled, testItem.firstArrivingEnabled);
79
- assert.equal(sut.simpleSense.token, testItem.simpleSense?.token);
80
- assert.equal(sut.firstArriving.token, testItem.firstArriving?.token);
81
- assert.equal(sut.simpleSenseEnabled, testItem.simpleSenseEnabled);
82
- assert.equal(sut.webDisclaimer.message, testItem.webDisclaimer?.message);
83
- assert.equal(sut.webDisclaimer.enabled, testItem.webDisclaimer?.enabled);
84
- assert.equal(JSON.stringify(sut.licensing), JSON.stringify(testItem.licensing));
85
- assert.equal(sut.externalNotificationsEnabled, testItem.externalNotificationsEnabled);
86
- assert.equal(sut.notificationEmails.length, testItem.notificationEmails?.length);
87
- assert.equal(sut.restrictedComments.callTypesAllowed.length, testItem.restrictedComments?.callTypesAllowed.length);
88
- assert.equal(sut.restrictedComments.statusesAllowed.length, testItem.restrictedComments?.statusesAllowed.length);
89
- assert.equal(sut.restrictedComments.restrictedFields.length, testItem.restrictedComments?.restrictedFields.length);
90
- assert.equal(sut.restrictedComments.restrictedMessage, testItem.restrictedComments?.restrictedMessage);
91
- assert.equal(sut.restrictedComments.enabled, testItem.restrictedComments?.enabled);
54
+ assert.equal(sut.callerLocation.enabled, testItem.callerLocation?.enabled);
55
+ const callerResolver = sut.callerLocation.resolvers.find(() => true);
56
+ assert.isObject(callerResolver);
57
+ assert.equal(callerResolver?.type, m.AccountCallerType.Dummy);
92
58
  if (testItem.customButtons?.length) {
93
59
  assert.equal(sut.customButtons[0]?.name, testItem.customButtons[0]?.name);
94
60
  assert.equal(sut.customButtons[0]?.url, testItem.customButtons[0]?.url);
@@ -100,15 +66,72 @@ describe("Department", function() {
100
66
  } else {
101
67
  assert.equal(testItem.customButtons?.length, 1);
102
68
  }
103
- assert.equal(sut.reportNumberEnabled, testItem.reportNumberEnabled);
104
- assert.equal(JSON.stringify(sut.samsara), JSON.stringify(testItem.samsara));
105
- assert.equal(sut.reportOdometer, "status");
69
+ assert.equal(sut.department, testItem.department);
70
+ assert.equal(sut.externalNotificationsEnabled, testItem.externalNotificationsEnabled);
71
+ assert.isTrue(sut.fireMapper.enabled);
72
+ assert.equal(sut.fireMapper?.auth?.username, testItem.fireMapper?.auth?.username);
73
+ assert.equal(sut.fireMapper?.auth?.apiKeyManagement?.encryptedData, testItem.fireMapper?.auth?.apiKeyManagement?.encryptedData);
74
+ assert.equal(sut.fireMapper?.auth?.apiKeyManagement?.iv, testItem.fireMapper?.auth?.apiKeyManagement?.iv);
75
+ assert.equal(sut.fireMapper?.auth?.apiKeyReadOnly?.encryptedData, testItem.fireMapper?.auth?.apiKeyReadOnly?.encryptedData);
76
+ assert.equal(sut.fireMapper?.auth?.apiKeyReadOnly?.iv, testItem.fireMapper?.auth?.apiKeyReadOnly?.iv);
77
+ assert.equal(sut.fireMapper?.auth?.licenseCode?.encryptedData, testItem.fireMapper?.auth?.licenseCode?.encryptedData);
78
+ assert.equal(sut.fireMapper?.auth?.licenseCode?.iv, testItem.fireMapper?.auth?.licenseCode?.iv);
79
+ assert.equal(sut.fireMapper.layerRefreshInterval, testItem.fireMapper?.layerRefreshInterval);
80
+ assert.equal(sut.fireMapper?.layer?.length, 1);
81
+ const fmLayer = sut.fireMapper?.layer?.find(() => true);
82
+ assert.isObject(fmLayer);
83
+ assert.equal(fmLayer?.name, "abc");
84
+ assert.equal(fmLayer?.pathname, "/a/b/c");
85
+ assert.equal(sut.fireMapper.proLicenseCount, testItem.fireMapper?.proLicenseCount);
86
+ assert.equal(sut.fireMapper?.staticLayer?.length, 1);
87
+ const stLayer = sut.fireMapper?.staticLayer?.find(() => true);
88
+ assert.isObject(stLayer);
89
+ assert.equal(stLayer?.uuid, "u1");
90
+ const stLayer1 = stLayer?.layer?.find(() => true);
91
+ assert.isObject(stLayer1);
92
+ assert.equal(stLayer1?.name, "sa");
93
+ assert.equal(stLayer1?.pathname, "s/a/b");
94
+ assert.equal(sut.firstArrivingEnabled, testItem.firstArrivingEnabled);
95
+ assert.equal(sut.firstArriving.token, testItem.firstArriving?.token);
96
+ assert.equal(sut.incidentTypes.length, 1);
97
+ if (testItem.incidentTypes?.length) {
98
+ assert.equal(sut.incidentTypes[0]?.name, testItem.incidentTypes[0]?.name);
99
+ } else {
100
+ assert.equal(testItem.incidentTypes?.length, 1);
101
+ }
102
+ assert.equal(JSON.stringify(sut.licensing), JSON.stringify(testItem.licensing));
103
+ assert.equal(sut.notificationEmails.length, testItem.notificationEmails?.length);
104
+ assert.isTrue(sut.mowsEnabled);
106
105
  assert.equal(sut.orientationMarkerColor.text, testItem.orientationMarkerColor?.text);
107
106
  assert.equal(sut.orientationMarkerColor.background, testItem.orientationMarkerColor?.background);
108
- assert.equal(sut.callerLocation.enabled, testItem.callerLocation?.enabled);
109
- const callerResolver = sut.callerLocation.resolvers.find(() => true);
110
- assert.isObject(callerResolver);
111
- assert.equal(callerResolver?.type, m.AccountCallerType.Dummy);
107
+ assert.equal(sut.partialApiKey, testItem.partialApiKey);
108
+ assert.isTrue(sut.personnelStaffingEnabled);
109
+ assert.equal(sut.pubNubV3.token, testItem.pubNubV3?.token);
110
+ assert.equal(sut.pubNubV3.expireAt.toISOString(), testItem.pubNubV3?.expireAt.toISOString());
111
+ assert.equal(sut.pubNubV3.runAt.toISOString(), testItem.pubNubV3?.runAt.toISOString());
112
+ assert.equal(sut.pubNubV3.env, testItem.pubNubV3?.env);
113
+ assert.equal(sut.restrictedComments.callTypesAllowed.length, testItem.restrictedComments?.callTypesAllowed.length);
114
+ assert.equal(sut.restrictedComments.statusesAllowed.length, testItem.restrictedComments?.statusesAllowed.length);
115
+ assert.equal(sut.restrictedComments.restrictedFields.length, testItem.restrictedComments?.restrictedFields.length);
116
+ assert.equal(sut.restrictedComments.restrictedMessage, testItem.restrictedComments?.restrictedMessage);
117
+ assert.equal(sut.restrictedComments.enabled, testItem.restrictedComments?.enabled);
118
+ assert.equal(sut.reportOdometer, "status");
119
+ assert.equal(sut.reportNumberEnabled, testItem.reportNumberEnabled);
120
+ assert.isTrue(sut.rtsEnabled);
121
+ assert.equal(sut.rtsChannelPrefix, testItem.rtsChannelPrefix);
122
+ assert.equal(sut.safetyPriorityKeywords.length, 3);
123
+ assert.equal(JSON.stringify(sut.samsara), JSON.stringify(testItem.samsara));
124
+ assert.equal(sut.signupKey, testItem.signupKey);
125
+ assert.isFalse(sut.shareLocationPhones);
126
+ assert.isTrue(sut.shareLocationTablets);
127
+ assert.isTrue(sut.shareAVL.enabled);
128
+ assert.equal(sut.shareAVL.opAreaCode, testItem.shareAVL?.opAreaCode);
129
+ assert.equal(sut.shareAVL.opAreaName, testItem.shareAVL?.opAreaName);
130
+ assert.equal(sut.simpleSense.token, testItem.simpleSense?.token);
131
+ assert.equal(sut.simpleSenseEnabled, testItem.simpleSenseEnabled);
132
+ assert.equal(sut.timeZone, testItem.timeZone);
133
+ assert.equal(sut.webDisclaimer.message, testItem.webDisclaimer?.message);
134
+ assert.equal(sut.webDisclaimer.enabled, testItem.webDisclaimer?.enabled);
112
135
  });
113
136
 
114
137
  it("saves SOAP forwarding connection properties", async function() {
@@ -141,10 +164,12 @@ describe("Department", function() {
141
164
  }
142
165
  };
143
166
 
144
- const testItemWithForwarding = testItem as m.Department;
145
- testItemWithForwarding.forwarding = {
146
- enabled: true,
147
- connections: [soapConnection]
167
+ const testItemWithForwarding: Partial<m.Department> = {
168
+ ...testItem,
169
+ forwarding: {
170
+ enabled: true,
171
+ connections: [soapConnection]
172
+ }
148
173
  };
149
174
 
150
175
  const item = new models.Department(testItemWithForwarding);
@@ -162,7 +187,7 @@ describe("Department", function() {
162
187
  assert.equal(connection.customHeaders.get("SOAPAction"), "SubmitIncident");
163
188
  });
164
189
 
165
- it("saves rules v2", async function() {
190
+ it("saves shareIncident.rulesV2", async function() {
166
191
  const item = new models.Department(testItem);
167
192
  const sut = await item.save();
168
193
  assert.deepEqual(sut.shareIncident.rulesV2, []);
package/src/test/mock.ts CHANGED
@@ -700,7 +700,8 @@ export default function mockModule(dependencies: { mongoose: Mongoose; }) {
700
700
 
701
701
  const department: Partial<Department> = {
702
702
  _id: new mongoose.Types.ObjectId(),
703
- department: "Test Department",
703
+ accountType: "production",
704
+ active: true,
704
705
  addressDetails: {
705
706
  city: "San Francisco",
706
707
  address: "",
@@ -708,50 +709,86 @@ export default function mockModule(dependencies: { mongoose: Mongoose; }) {
708
709
  zipCode: "",
709
710
  country: "",
710
711
  },
711
- active: true,
712
- apikey: "abcd",
713
- partialApiKey: "ab",
714
- personnelStaffingEnabled: true,
715
- rtsEnabled: true,
716
- rtsChannelPrefix: "CH_TEST",
717
- pubNubV3: {
718
- token: "CH_AUTH_TOKEN",
719
- expireAt: new Date("2021-09-10T23:25:02.196Z"),
720
- runAt: new Date("2021-09-10T08:25:02.196Z"),
721
- env: "qa",
722
- },
723
712
  agencyIds: [
724
713
  new mongoose.Types.ObjectId(agency._id)
725
714
  ],
726
- signupKey: "A1B2",
727
- incidentTypes: [{
728
- name: "Type",
729
- value: "type",
730
- allowPartialMatch: true,
731
- callTypeDescription: [],
732
- callType: [],
733
- }],
734
- shareLocationPhones: false,
735
- shareLocationTablets: true,
715
+ apikey: "abcd",
736
716
  cadOneWayVehiclesEnabled: false,
737
- mowsEnabled: true,
738
- shareAVL: {
717
+ callerLocation: {
739
718
  enabled: true,
740
- opAreaCode: "DAL",
741
- opAreaName: "Delta Operations",
742
- fadeZoomLevel: 1,
719
+ resolvers: [
720
+ {
721
+ type: AccountCallerType.Dummy,
722
+ opts: {},
723
+ }
724
+ ]
725
+ },
726
+ customButtons: [
727
+ {
728
+ name: "Button Custom",
729
+ url: "",
730
+ order: 1,
731
+ allowExternal: false,
732
+ defaultExternal: false,
733
+ allowFloating: false,
734
+ color: {
735
+ background: "#512e5f",
736
+ text: "#F8F9F9"
737
+ }
738
+ }
739
+ ],
740
+ department: "Test Department",
741
+ externalNotificationsEnabled: true,
742
+ fireMapper: {
743
+ enabled: true,
744
+ auth: {
745
+ username: "fm-user",
746
+ apiKeyManagement: {
747
+ iv: "iv-mgm",
748
+ encryptedData: "encrypted-nt",
749
+ },
750
+ apiKeyReadOnly: {
751
+ iv: "iv-read-only",
752
+ encryptedData: "encrypted-read-only",
753
+ },
754
+ licenseCode: {
755
+ iv: "iv-license",
756
+ encryptedData: "encrypted-license",
757
+ },
758
+ },
759
+ host: "",
760
+ layer: [
761
+ {
762
+ pathname: "/a/b/c",
763
+ name: "abc",
764
+ },
765
+ ],
766
+ layerRefreshInterval: 10,
767
+ proLicenseCount: 20,
768
+ staticLayer: [
769
+ {
770
+ uuid: "u1",
771
+ layer: [
772
+ {
773
+ name: "sa",
774
+ pathname: "s/a/b",
775
+ }
776
+ ]
777
+ }
778
+ ],
743
779
  },
744
- accountType: "production",
745
- timeZone: "America/Los_Angeles",
746
780
  firstArrivingEnabled: true,
747
781
  firstArriving: {
748
782
  token: "123",
749
783
  apiUrl: "",
750
784
  },
751
- simpleSenseEnabled: true,
752
- simpleSense: {
753
- token: "123"
754
- },
785
+ incidentTypes: [{
786
+ name: "Type",
787
+ value: "type",
788
+ allowPartialMatch: true,
789
+ callTypeDescription: [],
790
+ callType: [],
791
+ }],
755
792
  licensing: {
756
793
  tcPro2Way: 0,
757
794
  tcPro1Way: 0,
@@ -761,16 +798,21 @@ export default function mockModule(dependencies: { mongoose: Mongoose; }) {
761
798
  sendToCAD: 0,
762
799
  tcStreams: 0,
763
800
  },
764
- webDisclaimer: {
765
- message: "test",
766
- enabled: true
767
- },
801
+ mowsEnabled: true,
768
802
  notificationEmails: ["test@test.com"],
769
- externalNotificationsEnabled: true,
770
803
  orientationMarkerColor: {
771
804
  text: "a",
772
805
  background: "b",
773
806
  },
807
+ partialApiKey: "ab",
808
+ personnelStaffingEnabled: true,
809
+ pubNubV3: {
810
+ token: "CH_AUTH_TOKEN",
811
+ expireAt: new Date("2021-09-10T23:25:02.196Z"),
812
+ runAt: new Date("2021-09-10T08:25:02.196Z"),
813
+ env: "qa",
814
+ },
815
+ reportNumberEnabled: true,
774
816
  restrictedComments: {
775
817
  enabled: false,
776
818
  callTypesAllowed: [],
@@ -778,35 +820,31 @@ export default function mockModule(dependencies: { mongoose: Mongoose; }) {
778
820
  restrictedFields: [],
779
821
  restrictedMessage: "Restricted Message"
780
822
  },
781
- customButtons: [
782
- {
783
- name: "Button Custom",
784
- url: "",
785
- order: 1,
786
- allowExternal: false,
787
- defaultExternal: false,
788
- allowFloating: false,
789
- color: {
790
- background: "#512e5f",
791
- text: "#F8F9F9"
792
- }
793
- }
794
- ],
795
- reportNumberEnabled: true,
823
+ rtsEnabled: true,
824
+ rtsChannelPrefix: "CH_TEST",
796
825
  samsara: {
797
826
  enabled: false,
798
827
  token: "",
799
828
  },
800
- reportOdometer: "status",
801
- callerLocation: {
829
+ shareAVL: {
802
830
  enabled: true,
803
- resolvers: [
804
- {
805
- type: AccountCallerType.Dummy,
806
- opts: {},
807
- }
808
- ]
809
- }
831
+ opAreaCode: "DAL",
832
+ opAreaName: "Delta Operations",
833
+ fadeZoomLevel: 1,
834
+ },
835
+ shareLocationPhones: false,
836
+ shareLocationTablets: true,
837
+ signupKey: "A1B2",
838
+ simpleSenseEnabled: true,
839
+ simpleSense: {
840
+ token: "123"
841
+ },
842
+ reportOdometer: "status",
843
+ timeZone: "America/Los_Angeles",
844
+ webDisclaimer: {
845
+ message: "test",
846
+ enabled: true
847
+ },
810
848
  };
811
849
 
812
850
  const esriMap = {
@@ -1,6 +1,6 @@
1
1
  import { Types } from "mongoose";
2
2
  import { ColorSchemaType } from "./color";
3
- import { FireMapperAuthType } from "./firemapper-auth";
3
+ import { FireMapperAuthV2Type } from "./firemapper-auth";
4
4
  import { PubNubTokenSchemaType } from "./pubnub-token";
5
5
  import {
6
6
  AccountCallerType,
@@ -310,12 +310,12 @@ export interface USFTConfigurationType {
310
310
 
311
311
  export interface FireMapperConfigurationType {
312
312
  enabled: boolean,
313
- layerRefreshInterval: number,
314
- proLicenseCount: number,
313
+ auth: FireMapperAuthV2Type,
315
314
  host: string,
316
315
  layer: FireMapperLayerType[],
316
+ layerRefreshInterval: number,
317
+ proLicenseCount: number,
317
318
  staticLayer: FireMapperOutlineType[],
318
- auth: FireMapperAuthType,
319
319
  }
320
320
 
321
321
  export interface LicensingType {
@@ -5,3 +5,13 @@ export interface FireMapperAuthType {
5
5
  encrypted: EncryptedDataType,
6
6
  encryptedAccessCode: EncryptedDataType,
7
7
  }
8
+
9
+ export interface FireMapperAuthV2Type {
10
+ username: string,
11
+ // used by backend to create FM incidents
12
+ apiKeyManagement: EncryptedDataType | undefined,
13
+ // used by the iOS maps, and backend to check if map is active
14
+ apiKeyReadOnly: EncryptedDataType | undefined,
15
+ // used by the iOS link to
16
+ licenseCode: EncryptedDataType | undefined,
17
+ }