tabletcommand-backend-models 7.4.69 → 7.4.71
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/build/index.js +1 -0
- package/build/index.js.map +1 -1
- package/build/models/department.js +4 -0
- package/build/models/department.js.map +1 -1
- package/build/models/partner.js +90 -0
- package/build/models/partner.js.map +1 -0
- package/build/models/user.js +0 -14
- package/build/models/user.js.map +1 -1
- package/build/test/0index.js +1 -0
- package/build/test/0index.js.map +1 -1
- package/build/test/department.js +1 -0
- package/build/test/department.js.map +1 -1
- package/build/test/mock.js +13 -0
- package/build/test/mock.js.map +1 -1
- package/build/test/partner.js +38 -0
- package/build/test/partner.js.map +1 -0
- package/build/test/user.js +0 -16
- package/build/test/user.js.map +1 -1
- package/build/types/partner.js +3 -0
- package/build/types/partner.js.map +1 -0
- package/definitions/index.d.ts +6 -0
- package/definitions/index.d.ts.map +1 -1
- package/definitions/models/department.d.ts.map +1 -1
- package/definitions/models/partner.d.ts +13 -0
- package/definitions/models/partner.d.ts.map +1 -0
- package/definitions/models/user.d.ts.map +1 -1
- package/definitions/test/mock.d.ts +12 -0
- package/definitions/test/mock.d.ts.map +1 -1
- package/definitions/test/partner.d.ts +2 -0
- package/definitions/test/partner.d.ts.map +1 -0
- package/definitions/types/department.d.ts +1 -0
- package/definitions/types/department.d.ts.map +1 -1
- package/definitions/types/partner.d.ts +18 -0
- package/definitions/types/partner.d.ts.map +1 -0
- package/package.json +1 -1
- package/src/index.ts +2 -0
- package/src/models/department.ts +4 -0
- package/src/models/partner.ts +108 -0
- package/src/models/user.ts +0 -15
- package/src/test/0index.ts +1 -0
- package/src/test/department.ts +7 -6
- package/src/test/mock.ts +14 -0
- package/src/test/partner.ts +38 -0
- package/src/test/user.ts +0 -20
- package/src/types/department.ts +1 -0
- package/src/types/partner.ts +19 -0
package/src/test/0index.ts
CHANGED
|
@@ -61,6 +61,7 @@ describe(" Models", function() {
|
|
|
61
61
|
assert.isFunction(models.PersonnelImport, "Missing PersonnelImport");
|
|
62
62
|
assert.isFunction(models.PersonnelKnown, "Missing PersonnelKnown");
|
|
63
63
|
assert.isFunction(models.PersonnelRoster, "Missing PersonnelRoster");
|
|
64
|
+
assert.isFunction(models.Partner, "Missing Partner");
|
|
64
65
|
assert.isFunction(models.RateLimit, "Missing RateLimit");
|
|
65
66
|
assert.isFunction(models.ReleaseNote, "Missing ReleaseNote");
|
|
66
67
|
assert.isFunction(models.RemoteLog, "Missing RemoteLog");
|
package/src/test/department.ts
CHANGED
|
@@ -14,10 +14,10 @@ import {
|
|
|
14
14
|
ShareIncidentRuleTypeV2ReportNumber
|
|
15
15
|
} from "../types/department";
|
|
16
16
|
|
|
17
|
-
describe("Department", function() {
|
|
17
|
+
describe("Department", function () {
|
|
18
18
|
let models: m.BackendModels, mongoose: m.MongooseModule;
|
|
19
19
|
let testItem: Partial<m.Department>;
|
|
20
|
-
beforeEach(async function() {
|
|
20
|
+
beforeEach(async function () {
|
|
21
21
|
const c = await m.connect(config.url);
|
|
22
22
|
models = c.models;
|
|
23
23
|
mongoose = c.mongoose;
|
|
@@ -28,11 +28,11 @@ describe("Department", function() {
|
|
|
28
28
|
await mock.cleanup();
|
|
29
29
|
});
|
|
30
30
|
|
|
31
|
-
afterEach(async function() {
|
|
31
|
+
afterEach(async function () {
|
|
32
32
|
await mongoose.disconnect();
|
|
33
33
|
});
|
|
34
34
|
|
|
35
|
-
it("is saved", async function() {
|
|
35
|
+
it("is saved", async function () {
|
|
36
36
|
assert.isObject(testItem);
|
|
37
37
|
const item = new models.Department(testItem);
|
|
38
38
|
const sut = await item.save();
|
|
@@ -134,7 +134,7 @@ describe("Department", function() {
|
|
|
134
134
|
assert.equal(sut.webDisclaimer.enabled, testItem.webDisclaimer?.enabled);
|
|
135
135
|
});
|
|
136
136
|
|
|
137
|
-
it("saves SOAP forwarding connection properties", async function() {
|
|
137
|
+
it("saves SOAP forwarding connection properties", async function () {
|
|
138
138
|
// **Feature: eso-soap-incident-forwarding, Property 6: Configuration Validation**
|
|
139
139
|
// **Validates: Requirements 3.2, 6.5**
|
|
140
140
|
const soapConnection: m.ForwardingConnectionType = {
|
|
@@ -187,7 +187,7 @@ describe("Department", function() {
|
|
|
187
187
|
assert.equal(connection.customHeaders.get("SOAPAction"), "SubmitIncident");
|
|
188
188
|
});
|
|
189
189
|
|
|
190
|
-
it("saves shareIncident.rulesV2", async function() {
|
|
190
|
+
it("saves shareIncident.rulesV2", async function () {
|
|
191
191
|
const item = new models.Department(testItem);
|
|
192
192
|
const sut = await item.save();
|
|
193
193
|
assert.deepEqual(sut.shareIncident.rulesV2, []);
|
|
@@ -267,6 +267,7 @@ describe("Department", function() {
|
|
|
267
267
|
|
|
268
268
|
const sharedToDepartmentId = "6960c647c74ecd066a0a02c8";
|
|
269
269
|
const rule1: ShareIncidentRuleTypeV2 = {
|
|
270
|
+
name: "Rule 1",
|
|
270
271
|
accounts: [
|
|
271
272
|
{
|
|
272
273
|
name: "A",
|
package/src/test/mock.ts
CHANGED
|
@@ -1311,6 +1311,19 @@ export default function mockModule(dependencies: { mongoose: Mongoose; }) {
|
|
|
1311
1311
|
count: 8
|
|
1312
1312
|
};
|
|
1313
1313
|
|
|
1314
|
+
const partner = {
|
|
1315
|
+
_id: new mongoose.Types.ObjectId(),
|
|
1316
|
+
name: "Partner ABC - Conn 1",
|
|
1317
|
+
active: true,
|
|
1318
|
+
partnerKey: uuid.v4(),
|
|
1319
|
+
uuid: uuid.v4(),
|
|
1320
|
+
location: {
|
|
1321
|
+
enabled: true,
|
|
1322
|
+
departmentIds: [departmentId],
|
|
1323
|
+
includeVehicleStatus: false,
|
|
1324
|
+
},
|
|
1325
|
+
};
|
|
1326
|
+
|
|
1314
1327
|
const session = {
|
|
1315
1328
|
when: "2019-04-01T04:41:38.509Z",
|
|
1316
1329
|
user: "51c2dcca0c599704e400001f",
|
|
@@ -1583,6 +1596,7 @@ export default function mockModule(dependencies: { mongoose: Mongoose; }) {
|
|
|
1583
1596
|
monitor,
|
|
1584
1597
|
personnelImport,
|
|
1585
1598
|
rateLimit,
|
|
1599
|
+
partner,
|
|
1586
1600
|
releaseNote,
|
|
1587
1601
|
session,
|
|
1588
1602
|
saml,
|
|
@@ -0,0 +1,38 @@
|
|
|
1
|
+
import { assert } from "chai";
|
|
2
|
+
import "mocha";
|
|
3
|
+
import * as m from "../index";
|
|
4
|
+
import * as config from "./config";
|
|
5
|
+
import mockModule from "./mock";
|
|
6
|
+
|
|
7
|
+
describe("Partner", function() {
|
|
8
|
+
let models: m.BackendModels, mongoose: m.MongooseModule;
|
|
9
|
+
let testItem: Partial<m.Partner>;
|
|
10
|
+
beforeEach(async function() {
|
|
11
|
+
const c = await m.connect(config.url);
|
|
12
|
+
models = c.models;
|
|
13
|
+
mongoose = c.mongoose;
|
|
14
|
+
|
|
15
|
+
const mock = mockModule({
|
|
16
|
+
mongoose
|
|
17
|
+
});
|
|
18
|
+
testItem = mock.partner;
|
|
19
|
+
});
|
|
20
|
+
afterEach(async function() {
|
|
21
|
+
await mongoose.disconnect();
|
|
22
|
+
});
|
|
23
|
+
|
|
24
|
+
it("is saved", async function() {
|
|
25
|
+
const item = new models.Partner(testItem);
|
|
26
|
+
const sut = await item.save();
|
|
27
|
+
|
|
28
|
+
assert.isNotNull(testItem._id);
|
|
29
|
+
assert.equal(sut.name, testItem.name);
|
|
30
|
+
assert.equal(sut.active, testItem.active);
|
|
31
|
+
assert.equal(sut.partnerKey, testItem.partnerKey);
|
|
32
|
+
assert.isString(sut.uuid);
|
|
33
|
+
assert.equal(sut.location.enabled, testItem.location?.enabled);
|
|
34
|
+
assert.deepEqual(sut.location.departmentIds, testItem.location?.departmentIds);
|
|
35
|
+
assert.equal(sut.location.includeVehicleStatus, testItem.location?.includeVehicleStatus);
|
|
36
|
+
assert.isNumber(sut.modified_unix_date);
|
|
37
|
+
});
|
|
38
|
+
});
|
package/src/test/user.ts
CHANGED
|
@@ -49,24 +49,4 @@ describe("User", function () {
|
|
|
49
49
|
assert.equal(item.restrictedCommentsEnabled, true);
|
|
50
50
|
assert.isTrue(sut.canBlockIncidents);
|
|
51
51
|
});
|
|
52
|
-
|
|
53
|
-
it("filters out invalid agencyId in aggregate", async function () {
|
|
54
|
-
const validAgencyId = new mongoose.Types.ObjectId();
|
|
55
|
-
|
|
56
|
-
await models.User.collection.insertMany([
|
|
57
|
-
{ email: "valid@test.com", nick: "valid", departmentId: "d_aggregate", agencyId: validAgencyId },
|
|
58
|
-
{ email: "missing@test.com", nick: "missing", departmentId: "d_aggregate" },
|
|
59
|
-
{ email: "null1@test.com", nick: "null1", departmentId: "d_aggregate", agencyId: null },
|
|
60
|
-
{ email: "empty@test.com", nick: "empty", departmentId: "d_aggregate", agencyId: "" },
|
|
61
|
-
{ email: "null2@test.com", nick: "null2", departmentId: "d_aggregate", agencyId: "null" },
|
|
62
|
-
{ email: "undef@test.com", nick: "undef", departmentId: "d_aggregate", agencyId: "undefined" }
|
|
63
|
-
]);
|
|
64
|
-
|
|
65
|
-
const results = await models.User.aggregate([
|
|
66
|
-
{ $match: { departmentId: "d_aggregate" } }
|
|
67
|
-
]);
|
|
68
|
-
|
|
69
|
-
assert.equal(results.length, 1);
|
|
70
|
-
assert.equal(results[0].email, "valid@test.com");
|
|
71
|
-
});
|
|
72
52
|
});
|
package/src/types/department.ts
CHANGED
|
@@ -409,6 +409,7 @@ export type SharedToDestinationType = {
|
|
|
409
409
|
};
|
|
410
410
|
|
|
411
411
|
export interface ShareIncidentRuleTypeV2 {
|
|
412
|
+
name?: string,
|
|
412
413
|
accounts: SharedToDestinationType[],
|
|
413
414
|
rules: IncidentShareRuleTypeV2[],
|
|
414
415
|
// Temporary workaround until we add complex notification setup
|
|
@@ -0,0 +1,19 @@
|
|
|
1
|
+
import { Types } from "mongoose";
|
|
2
|
+
|
|
3
|
+
export interface PartnerLocationType {
|
|
4
|
+
enabled: boolean,
|
|
5
|
+
departmentIds: string[],
|
|
6
|
+
includeVehicleStatus: boolean,
|
|
7
|
+
}
|
|
8
|
+
|
|
9
|
+
export interface PartnerType {
|
|
10
|
+
_id: Types.ObjectId,
|
|
11
|
+
name: string,
|
|
12
|
+
active: boolean,
|
|
13
|
+
partnerKey: string,
|
|
14
|
+
uuid: string,
|
|
15
|
+
location: PartnerLocationType,
|
|
16
|
+
modified_unix_date: number,
|
|
17
|
+
modified: Date,
|
|
18
|
+
created: Date,
|
|
19
|
+
}
|