tabletcommand-backend-models 7.0.11 → 7.0.12
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/models/session.js
CHANGED
@@ -5,9 +5,9 @@ const oauth_1 = require("./schema/oauth");
|
|
5
5
|
async function SessionModule(mongoose) {
|
6
6
|
const Schema = mongoose.Schema;
|
7
7
|
const OAuthToken = (0, oauth_1.default)(mongoose);
|
8
|
-
function requiredButAllowEmptyString() {
|
8
|
+
function requiredButAllowEmptyString(value) {
|
9
9
|
// Workaround to set required, and allow empty id
|
10
|
-
return typeof
|
10
|
+
return typeof value === "string";
|
11
11
|
}
|
12
12
|
const modelSchema = new Schema({
|
13
13
|
_id: {
|
@@ -32,7 +32,10 @@ async function SessionModule(mongoose) {
|
|
32
32
|
departmentId: {
|
33
33
|
type: String,
|
34
34
|
default: "",
|
35
|
-
|
35
|
+
validate: {
|
36
|
+
validator: requiredButAllowEmptyString,
|
37
|
+
message: "departmentId is required",
|
38
|
+
},
|
36
39
|
index: true,
|
37
40
|
},
|
38
41
|
why: {
|
@@ -1 +1 @@
|
|
1
|
-
{"version":3,"file":"session.js","sourceRoot":"","sources":["../../src/models/session.ts"],"names":[],"mappings":";;AAGA,6BAA6B;AAE7B,0CAAyC;AAM1B,KAAK,UAAU,aAAa,CAAC,QAAwB;IAClE,MAAM,MAAM,GAAG,QAAQ,CAAC,MAAM,CAAC;IAC/B,MAAM,UAAU,GAAG,IAAA,eAAW,EAAC,QAAQ,CAAC,CAAC;IAEzC,SAAS,2BAA2B;
|
1
|
+
{"version":3,"file":"session.js","sourceRoot":"","sources":["../../src/models/session.ts"],"names":[],"mappings":";;AAGA,6BAA6B;AAE7B,0CAAyC;AAM1B,KAAK,UAAU,aAAa,CAAC,QAAwB;IAClE,MAAM,MAAM,GAAG,QAAQ,CAAC,MAAM,CAAC;IAC/B,MAAM,UAAU,GAAG,IAAA,eAAW,EAAC,QAAQ,CAAC,CAAC;IAEzC,SA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WAAW,EAAE,KAAK,CAAC,CAAC;IAEpC,WAAW,CAAC,GAAG,CAAC,MAAM,EAAE,UAAS,IAAI;QACnC,IAAI,CAAC,GAAG,GAAG,IAAI,CAAC,GAAG,CAAC,OAAO,CAAC,CAAC,CAAC,sBAAsB;QACpD,IAAI,EAAE,CAAC;IACT,CAAC,CAAC,CAAC;IACH,WAAW,CAAC,OAAO,CAAC,IAAI,CAAC,CAAC,GAAG,CAAC;QAC5B,OAAO,IAAI,CAAC,GAAG,CAAC,QAAQ,EAAE,CAAC;IAC7B,CAAC,CAAC,CAAC;IAEH,WAAW,CAAC,GAAG,CAAC,QAAQ,EAAE;QACxB,QAAQ,EAAE,IAAI;QACd,UAAU,EAAE,KAAK;KAClB,CAAC,CAAC;IAGH,OAAO,QAAQ,CAAC,KAAK,CAAU,SAAS,EAAE,WAAW,EAAE,WAAW,EAAE,EAAE,eAAe,EAAE,IAAI,EAAE,CAAC,CAAC;AACjG,CAAC;AApFD,gCAoFC"}
|
@@ -1 +1 @@
|
|
1
|
-
{"version":3,"file":"session.d.ts","sourceRoot":"","sources":["../../src/models/session.ts"],"names":[],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;AAAA,OAAO,EACL,cAAc,EACf,MAAM,YAAY,CAAC;AAIpB,OAAO,EAAE,KAAK,EAAE,MAAM,UAAU,CAAC;AACjC,OAAO,EAAE,WAAW,EAAE,MAAM,kBAAkB,CAAC;AAE/C,MAAM,WAAW,OAAQ,SAAQ,WAAW;CAAI;AAEhD,wBAA8B,aAAa,CAAC,QAAQ,EAAE,cAAc;;
|
1
|
+
{"version":3,"file":"session.d.ts","sourceRoot":"","sources":["../../src/models/session.ts"],"names":[],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;AAAA,OAAO,EACL,cAAc,EACf,MAAM,YAAY,CAAC;AAIpB,OAAO,EAAE,KAAK,EAAE,MAAM,UAAU,CAAC;AACjC,OAAO,EAAE,WAAW,EAAE,MAAM,kBAAkB,CAAC;AAE/C,MAAM,WAAW,OAAQ,SAAQ,WAAW;CAAI;AAEhD,wBAA8B,aAAa,CAAC,QAAQ,EAAE,cAAc;;UAoFnE;AAED,MAAM,WAAW,YAAa,SAAQ,KAAK,CAAC,OAAO,CAAC;CAAI"}
|
package/package.json
CHANGED
package/src/models/session.ts
CHANGED
@@ -13,9 +13,9 @@ export default async function SessionModule(mongoose: MongooseModule) {
|
|
13
13
|
const Schema = mongoose.Schema;
|
14
14
|
const OAuthToken = OAuthSchema(mongoose);
|
15
15
|
|
16
|
-
function requiredButAllowEmptyString(
|
16
|
+
function requiredButAllowEmptyString(value: unknown) {
|
17
17
|
// Workaround to set required, and allow empty id
|
18
|
-
return typeof
|
18
|
+
return typeof value === "string";
|
19
19
|
}
|
20
20
|
|
21
21
|
const modelSchema = new Schema<SessionType>({
|
@@ -41,7 +41,10 @@ export default async function SessionModule(mongoose: MongooseModule) {
|
|
41
41
|
departmentId: {
|
42
42
|
type: String,
|
43
43
|
default: "",
|
44
|
-
|
44
|
+
validate: {
|
45
|
+
validator: requiredButAllowEmptyString,
|
46
|
+
message: "departmentId is required",
|
47
|
+
},
|
45
48
|
index: true,
|
46
49
|
},
|
47
50
|
why: {
|
package/test/session.js
CHANGED
@@ -30,7 +30,6 @@ describe("Session", function() {
|
|
30
30
|
assert.equal(sut.user, testItem.user);
|
31
31
|
assert.equal(sut.email, testItem.email);
|
32
32
|
assert.equal(sut.nick, testItem.nick);
|
33
|
-
assert.equal(sut.departmentId, testItem.departmentId);
|
34
33
|
assert.isFalse(sut.active);
|
35
34
|
assert.equal(sut.deviceId, testItem.deviceId);
|
36
35
|
assert.equal(sut.remoteAddress, testItem.remoteAddress);
|