tabletcommand-backend-models 5.17.28 → 5.17.29
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/.eslintrc.js +1 -3
- package/build/models/arcgis-group.js +1 -1
- package/build/models/esri.js +3 -3
- package/build/models/esri.js.map +1 -1
- package/build/models/location.js +6 -1
- package/build/models/location.js.map +1 -1
- package/build/test/arcgis-group.js +95 -0
- package/build/test/arcgis-group.js.map +1 -0
- package/build/test/config.js +12 -0
- package/build/test/config.js.map +1 -0
- package/build/test/mock.js +974 -0
- package/build/test/mock.js.map +1 -0
- package/definitions/models/esri.d.ts +4 -4
- package/definitions/models/location.d.ts.map +1 -1
- package/definitions/test/arcgis-group.d.ts +2 -0
- package/definitions/test/arcgis-group.d.ts.map +1 -0
- package/definitions/test/config.d.ts +3 -0
- package/definitions/test/config.d.ts.map +1 -0
- package/definitions/test/mock.d.ts +39 -0
- package/definitions/test/mock.d.ts.map +1 -0
- package/package.json +4 -3
- package/src/models/esri.ts +3 -3
- package/src/models/location.ts +10 -4
- package/src/test/arcgis-group.ts +107 -0
- package/src/test/config.ts +10 -0
- package/src/test/mock.ts +982 -0
- package/src/tsconfig.json +5 -0
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"mock.js","sourceRoot":"","sources":["../../src/test/mock.ts"],"names":[],"mappings":";;AAIA,qCAA+C;AAC/C,IAAA,4BAAmB,GAAE,CAAC;AAEtB,SAAwB,UAAU,CAAC,WAElC;IAEC,KAAK,UAAU,OAAO;QACpB,OAAO,EAAE,CAAC;IACZ,CAAC;IAED,MAAM,WAAW,GAAG;QAClB,MAAM,EAAE,SAAS;QACjB,iBAAiB,EAAE;YACjB;gBACE,UAAU,EAAE,0BAA0B;gBACtC,YAAY,EAAE,0BAA0B;gBACxC,YAAY,EAAE,WAAW;gBACzB,SAAS,EAAE,IAAI;gBACf,aAAa,EAAE,0BAA0B;gBACzC,UAAU,EAAE,IAAI;gBAChB,K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;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;EAk5BE"}
|
|
@@ -171,9 +171,9 @@ export declare function EsriSchema(mongoose: MongooseModule): import("mongoose")
|
|
|
171
171
|
};
|
|
172
172
|
default: null;
|
|
173
173
|
};
|
|
174
|
-
|
|
175
|
-
type: StringConstructor;
|
|
176
|
-
default:
|
|
174
|
+
arcGISGroupIds: {
|
|
175
|
+
type: StringConstructor[];
|
|
176
|
+
default: never[];
|
|
177
177
|
};
|
|
178
178
|
arcGISAuth: {
|
|
179
179
|
type: import("mongoose").Schema<any> & {
|
|
@@ -543,7 +543,7 @@ export declare function EsriModule(mongoose: MongooseModule): Promise<import("mo
|
|
|
543
543
|
default: null;
|
|
544
544
|
};
|
|
545
545
|
}>;
|
|
546
|
-
|
|
546
|
+
arcGISGroupIds: string[];
|
|
547
547
|
arcGISAuth: import("../helpers").MongooseInterface<{
|
|
548
548
|
username: {
|
|
549
549
|
type: StringConstructor;
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"location.d.ts","sourceRoot":"","sources":["../../src/models/location.ts"],"names":[],"mappings":";AACA,OAAO,EAKL,8BAA8B,EAC9B,+BAA+B,EAE/B,cAAc,EACd,sBAAsB,EACvB,MAAM,YAAY,CAAC;AAKpB,wBAAsB,cAAc,CAAC,QAAQ,EAAE,cAAc;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
|
|
1
|
+
{"version":3,"file":"location.d.ts","sourceRoot":"","sources":["../../src/models/location.ts"],"names":[],"mappings":";AACA,OAAO,EAKL,8BAA8B,EAC9B,+BAA+B,EAE/B,cAAc,EACd,sBAAsB,EACvB,MAAM,YAAY,CAAC;AAKpB,wBAAsB,cAAc,CAAC,QAAQ,EAAE,cAAc;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;GAmK5D;AAED,MAAM,WAAW,QAAS,SAAQ,8BAA8B,CAAC,OAAO,cAAc,CAAC;CAAI;AAC3F,MAAM,WAAW,aAAc,SAAQ,+BAA+B,CAAC,QAAQ,CAAC;CAAI;;AACpF,wBAA8F"}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"arcgis-group.d.ts","sourceRoot":"","sources":["../../src/test/arcgis-group.ts"],"names":[],"mappings":"AAEA,OAAO,OAAO,CAAC"}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"config.d.ts","sourceRoot":"","sources":["../../src/test/config.ts"],"names":[],"mappings":"AAEA,eAAO,MAAM,GAAG,QAAoE,CAAC;AAErF,wBAAgB,mBAAmB,SAKlC"}
|
|
@@ -0,0 +1,39 @@
|
|
|
1
|
+
export default function MockModule(dependecies: {
|
|
2
|
+
models: unknown;
|
|
3
|
+
}): {
|
|
4
|
+
cleanup: () => Promise<string>;
|
|
5
|
+
arcGISGroup: {
|
|
6
|
+
access: string;
|
|
7
|
+
linkedDepartments: {
|
|
8
|
+
department: string;
|
|
9
|
+
departmentId: string;
|
|
10
|
+
authUsername: string;
|
|
11
|
+
authError: null;
|
|
12
|
+
tokenUsername: string;
|
|
13
|
+
tokenError: null;
|
|
14
|
+
users: {
|
|
15
|
+
username: string;
|
|
16
|
+
email: string;
|
|
17
|
+
userId: string;
|
|
18
|
+
}[];
|
|
19
|
+
}[];
|
|
20
|
+
externalOrgIds: string[];
|
|
21
|
+
groupId: string;
|
|
22
|
+
outsiders: {
|
|
23
|
+
fullName: string;
|
|
24
|
+
memberType: string;
|
|
25
|
+
orgId: string;
|
|
26
|
+
username: string;
|
|
27
|
+
}[];
|
|
28
|
+
owner: string;
|
|
29
|
+
protected: boolean;
|
|
30
|
+
title: string;
|
|
31
|
+
users: {
|
|
32
|
+
fullName: string;
|
|
33
|
+
memberType: string;
|
|
34
|
+
orgId: string;
|
|
35
|
+
username: string;
|
|
36
|
+
}[];
|
|
37
|
+
};
|
|
38
|
+
};
|
|
39
|
+
//# sourceMappingURL=mock.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"mock.d.ts","sourceRoot":"","sources":["../../src/test/mock.ts"],"names":[],"mappings":"AAOA,MAAM,CAAC,OAAO,UAAU,UAAU,CAAC,WAAW,EAAE;IAC9C,MAAM,EAAE,OAAO,CAAC;CACjB;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;EAwDA"}
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "tabletcommand-backend-models",
|
|
3
|
-
"version": "5.17.
|
|
3
|
+
"version": "5.17.29",
|
|
4
4
|
"description": "Tablet Command Backend Models",
|
|
5
5
|
"scripts": {
|
|
6
6
|
"test": "gulp",
|
|
@@ -32,8 +32,8 @@
|
|
|
32
32
|
"@types/mongodb": "^3.6.20",
|
|
33
33
|
"@types/mongoose": "~5.10.5",
|
|
34
34
|
"@types/uuid": "~8.3.4",
|
|
35
|
-
"@typescript-eslint/eslint-plugin": "
|
|
36
|
-
"@typescript-eslint/parser": "
|
|
35
|
+
"@typescript-eslint/eslint-plugin": "~5.14.0",
|
|
36
|
+
"@typescript-eslint/parser": "~5.14.0",
|
|
37
37
|
"chai": "^4.3.6",
|
|
38
38
|
"del": "^6.0.0",
|
|
39
39
|
"eslint": "^8.10.0",
|
|
@@ -41,6 +41,7 @@
|
|
|
41
41
|
"gulp-mocha": "^8.0.0",
|
|
42
42
|
"gulp-shell": "^0.8.0",
|
|
43
43
|
"mocha": "^9.2.1",
|
|
44
|
+
"ts-node": "^10.7.0",
|
|
44
45
|
"typescript": "^4.6.2",
|
|
45
46
|
"yargs-parser": ">=21.0.1"
|
|
46
47
|
}
|
package/src/models/esri.ts
CHANGED
|
@@ -86,9 +86,9 @@ export function EsriSchema(mongoose: MongooseModule) {
|
|
|
86
86
|
},
|
|
87
87
|
|
|
88
88
|
// Link to ArcGISGroup
|
|
89
|
-
|
|
90
|
-
type: String,
|
|
91
|
-
default:
|
|
89
|
+
arcGISGroupIds: {
|
|
90
|
+
type: [String],
|
|
91
|
+
default: [],
|
|
92
92
|
},
|
|
93
93
|
// ArcGIS user used for fallback when a new user has no ArcGIS account yet
|
|
94
94
|
arcGISAuth: {
|
package/src/models/location.ts
CHANGED
|
@@ -144,23 +144,29 @@ export async function LocationModule(mongoose: MongooseModule) {
|
|
|
144
144
|
versionKey: false,
|
|
145
145
|
});
|
|
146
146
|
|
|
147
|
-
modelSchema.virtual("id").get(function(this: MongooseDocument) {
|
|
147
|
+
modelSchema.virtual("id").get(function (this: MongooseDocument) {
|
|
148
148
|
return this._id.toHexString();
|
|
149
149
|
});
|
|
150
150
|
|
|
151
|
-
modelSchema.virtual("location").get(function(this: { locationGeoJSON: { coordinates: number[] }} | null | undefined) {
|
|
151
|
+
modelSchema.virtual("location").get(function (this: { locationGeoJSON: { coordinates: number[] } } | null | undefined) {
|
|
152
152
|
const location = {
|
|
153
153
|
latitude: 0,
|
|
154
154
|
longitude: 0
|
|
155
155
|
};
|
|
156
|
-
if (this && this.locationGeoJSON &&
|
|
156
|
+
if (this && this.locationGeoJSON &&
|
|
157
|
+
this.locationGeoJSON.coordinates &&
|
|
158
|
+
this.locationGeoJSON.coordinates[0] &&
|
|
159
|
+
Number.isFinite(this.locationGeoJSON.coordinates[0]) &&
|
|
160
|
+
this.locationGeoJSON.coordinates[1] &&
|
|
161
|
+
Number.isFinite(this.locationGeoJSON.coordinates[1])
|
|
162
|
+
) {
|
|
157
163
|
location.longitude = this.locationGeoJSON.coordinates[0];
|
|
158
164
|
location.latitude = this.locationGeoJSON.coordinates[1];
|
|
159
165
|
}
|
|
160
166
|
return location;
|
|
161
167
|
});
|
|
162
168
|
|
|
163
|
-
|
|
169
|
+
// Create GeoJSON index
|
|
164
170
|
modelSchema.index({
|
|
165
171
|
locationGeoJSON: "2dsphere",
|
|
166
172
|
shared: 1,
|
|
@@ -0,0 +1,107 @@
|
|
|
1
|
+
|
|
2
|
+
import { assert } from "chai";
|
|
3
|
+
import "mocha";
|
|
4
|
+
import * as _ from "lodash";
|
|
5
|
+
|
|
6
|
+
import { url as mongoURL } from "./config";
|
|
7
|
+
|
|
8
|
+
import { connect } from "..";
|
|
9
|
+
import MockModule from "./mock";
|
|
10
|
+
|
|
11
|
+
describe("ArcGISGroup", function () {
|
|
12
|
+
let models,
|
|
13
|
+
mongoose: typeof import("mongoose"),
|
|
14
|
+
mock;
|
|
15
|
+
|
|
16
|
+
beforeEach(async function () {
|
|
17
|
+
const result = await connect(mongoURL);
|
|
18
|
+
console.log(result);
|
|
19
|
+
// models = result.models;
|
|
20
|
+
// mongoose = result.mongoose;
|
|
21
|
+
|
|
22
|
+
// mock = MockModule({
|
|
23
|
+
// models,
|
|
24
|
+
// });
|
|
25
|
+
// await mock.cleanup();
|
|
26
|
+
|
|
27
|
+
// console.log("x", result);
|
|
28
|
+
console.log(mongoURL);
|
|
29
|
+
});
|
|
30
|
+
|
|
31
|
+
afterEach(async function() {
|
|
32
|
+
// await mongoose.disconnect();
|
|
33
|
+
});
|
|
34
|
+
|
|
35
|
+
it("is saved", async function () {
|
|
36
|
+
assert.isTrue(true);
|
|
37
|
+
});
|
|
38
|
+
});
|
|
39
|
+
|
|
40
|
+
|
|
41
|
+
/*
|
|
42
|
+
|
|
43
|
+
const m = require("..");
|
|
44
|
+
|
|
45
|
+
describe("ArcGISGroup", function() {
|
|
46
|
+
let models, mongoose, mock;
|
|
47
|
+
|
|
48
|
+
beforeEach(async function() {
|
|
49
|
+
const c = await m.connect(config.url);
|
|
50
|
+
models = c.models;
|
|
51
|
+
mongoose = c.mongoose;
|
|
52
|
+
mock = require("./mock")({
|
|
53
|
+
models,
|
|
54
|
+
mongoose,
|
|
55
|
+
});
|
|
56
|
+
await mock.cleanup();
|
|
57
|
+
});
|
|
58
|
+
|
|
59
|
+
afterEach(function() {
|
|
60
|
+
mongoose.disconnect();
|
|
61
|
+
});
|
|
62
|
+
|
|
63
|
+
it("is saved", async function() {
|
|
64
|
+
const testItem = mock.arcGISGroup;
|
|
65
|
+
assert.isObject(testItem);
|
|
66
|
+
const item = new models.ArcGISGroup(testItem);
|
|
67
|
+
const sut = await item.save();
|
|
68
|
+
|
|
69
|
+
assert.isNotNull(sut._id);
|
|
70
|
+
assert.isNotNull(sut.modified);
|
|
71
|
+
|
|
72
|
+
assert.equal(sut.groupId, testItem.groupId);
|
|
73
|
+
assert.equal(sut.title, testItem.title);
|
|
74
|
+
assert.deepEqual(sut.externalOrgIds, testItem.externalOrgIds);
|
|
75
|
+
assert.equal(sut.access, testItem.access);
|
|
76
|
+
assert.equal(sut.owner, testItem.owner);
|
|
77
|
+
assert.equal(sut.protected, testItem.protected);
|
|
78
|
+
|
|
79
|
+
assert.equal(sut.linkedDepartments.length, 1);
|
|
80
|
+
const dept = _.first(sut.linkedDepartments);
|
|
81
|
+
assert.equal(dept.department, "Demo RTS Fire Department");
|
|
82
|
+
assert.equal(dept.departmentId, "558365a198b2fa4278000053");
|
|
83
|
+
assert.equal(dept.authUsername, "tabletcmd");
|
|
84
|
+
assert.equal(dept.tokenUsername, "tc_ContraCostaCountyFire");
|
|
85
|
+
|
|
86
|
+
assert.equal(dept.users.length, 1);
|
|
87
|
+
const deptUser = _.first(dept.users);
|
|
88
|
+
assert.equal(deptUser.username, "tc_someone");
|
|
89
|
+
assert.equal(deptUser.email, "hello@tc.com");
|
|
90
|
+
assert.equal(deptUser.userId, "558365a198a2aa42780000aa");
|
|
91
|
+
|
|
92
|
+
assert.equal(sut.outsiders.length, 1);
|
|
93
|
+
const outsider = _.first(sut.outsiders);
|
|
94
|
+
assert.equal(outsider.username, "Michael_Kallum");
|
|
95
|
+
assert.equal(outsider.fullName, "Michael Kallum");
|
|
96
|
+
assert.equal(outsider.memberType, "member");
|
|
97
|
+
assert.equal(outsider.orgId, "MyTOuXKXZoizaaa");
|
|
98
|
+
|
|
99
|
+
assert.equal(sut.users.length, 1);
|
|
100
|
+
const user = _.first(sut.users);
|
|
101
|
+
assert.equal(user.username, "jane_tabletcommand");
|
|
102
|
+
assert.equal(user.fullName, "Jane Serrano");
|
|
103
|
+
assert.equal(user.memberType, "admin");
|
|
104
|
+
assert.equal(user.orgId, "zGXMcUaDlMGoAAAg");
|
|
105
|
+
});
|
|
106
|
+
});
|
|
107
|
+
*/
|
|
@@ -0,0 +1,10 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
|
|
3
|
+
export const url = process.env.NODE_MONGO_URL || "mongodb://127.0.0.1/incident-test";
|
|
4
|
+
|
|
5
|
+
export function checkIfTestDatabase() {
|
|
6
|
+
if (!/massive-test/i.exec(url)) {
|
|
7
|
+
console.log(`Not a test database: ${url}? Expecting database: massive-test.`);
|
|
8
|
+
process.exit(1);
|
|
9
|
+
}
|
|
10
|
+
}
|