elections-types 1.0.29 → 1.0.31
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/dist/src/index.d.ts +1 -0
- package/dist/src/index.js +1 -0
- package/dist/src/types/User.d.ts +1 -1
- package/dist/src/types/User.js +1 -1
- package/dist/src/types/UserElection.d.ts +9 -0
- package/dist/src/types/UserElection.js +24 -0
- package/package.json +1 -1
- package/src/index.ts +1 -0
- package/src/types/User.ts +2 -2
- package/src/types/UserElection.ts +31 -0
package/dist/src/index.d.ts
CHANGED
package/dist/src/index.js
CHANGED
package/dist/src/types/User.d.ts
CHANGED
|
@@ -4,7 +4,7 @@ export declare class User {
|
|
|
4
4
|
readonly admin: boolean;
|
|
5
5
|
readonly premium: boolean;
|
|
6
6
|
readonly email: string;
|
|
7
|
-
readonly email_settings: Record<LongFormTypeID | "NEWS",
|
|
7
|
+
readonly email_settings: Record<LongFormTypeID | "NEWS", number>;
|
|
8
8
|
constructor(user: any);
|
|
9
9
|
static is(user: any): user is User;
|
|
10
10
|
}
|
package/dist/src/types/User.js
CHANGED
|
@@ -24,6 +24,6 @@ export class User {
|
|
|
24
24
|
typeof user.email === "string" &&
|
|
25
25
|
Array.isArray(user.scout_ids) &&
|
|
26
26
|
typeof user.email_settings === "object" &&
|
|
27
|
-
Object.entries(user.email_settings).every(([key, value]) => (is_long_form_type_id(key) || key === "NEWS") && typeof value === "
|
|
27
|
+
Object.entries(user.email_settings).every(([key, value]) => (is_long_form_type_id(key) || key === "NEWS") && typeof value === "number"));
|
|
28
28
|
}
|
|
29
29
|
}
|
|
@@ -0,0 +1,9 @@
|
|
|
1
|
+
import { ElectionID } from "./Election.js";
|
|
2
|
+
export declare class UserElection {
|
|
3
|
+
readonly user_id: string;
|
|
4
|
+
readonly election_id: ElectionID;
|
|
5
|
+
readonly candidate_display: Record<string, number>;
|
|
6
|
+
readonly notify: boolean;
|
|
7
|
+
constructor(user_election: any);
|
|
8
|
+
static is(user_election: any): user_election is UserElection;
|
|
9
|
+
}
|
|
@@ -0,0 +1,24 @@
|
|
|
1
|
+
import { is_election_id } from "./Election.js";
|
|
2
|
+
export class UserElection {
|
|
3
|
+
user_id;
|
|
4
|
+
election_id;
|
|
5
|
+
candidate_display;
|
|
6
|
+
notify;
|
|
7
|
+
// readonly [x : string] : any
|
|
8
|
+
constructor(user_election) {
|
|
9
|
+
if (!UserElection.is(user_election)) {
|
|
10
|
+
throw Error("Invalid Input.");
|
|
11
|
+
}
|
|
12
|
+
this.user_id = user_election.user_id;
|
|
13
|
+
this.election_id = user_election.election_id;
|
|
14
|
+
this.candidate_display = user_election.candidate_display;
|
|
15
|
+
this.notify = user_election.notify;
|
|
16
|
+
}
|
|
17
|
+
static is(user_election) {
|
|
18
|
+
return (user_election !== undefined &&
|
|
19
|
+
typeof user_election.user_id === "string" &&
|
|
20
|
+
is_election_id(user_election.election_id) &&
|
|
21
|
+
Object.entries(user_election.candidate_display).every(([key, value]) => (typeof key === "string" && typeof value === "number")) &&
|
|
22
|
+
typeof user_election.notify === "boolean");
|
|
23
|
+
}
|
|
24
|
+
}
|
package/package.json
CHANGED
package/src/index.ts
CHANGED
package/src/types/User.ts
CHANGED
|
@@ -5,7 +5,7 @@ export class User {
|
|
|
5
5
|
readonly admin : boolean
|
|
6
6
|
readonly premium : boolean
|
|
7
7
|
readonly email : string
|
|
8
|
-
readonly email_settings : Record<LongFormTypeID | "NEWS",
|
|
8
|
+
readonly email_settings : Record<LongFormTypeID | "NEWS", number>
|
|
9
9
|
// readonly [x : string] : any
|
|
10
10
|
|
|
11
11
|
constructor(user : any) {
|
|
@@ -28,7 +28,7 @@ export class User {
|
|
|
28
28
|
typeof user.email === "string" &&
|
|
29
29
|
Array.isArray(user.scout_ids) &&
|
|
30
30
|
typeof user.email_settings === "object" &&
|
|
31
|
-
Object.entries(user.email_settings).every(([key, value]) => (is_long_form_type_id(key) || key === "NEWS") && typeof value === "
|
|
31
|
+
Object.entries(user.email_settings).every(([key, value]) => (is_long_form_type_id(key) || key === "NEWS") && typeof value === "number")
|
|
32
32
|
)
|
|
33
33
|
}
|
|
34
34
|
}
|
|
@@ -0,0 +1,31 @@
|
|
|
1
|
+
import { ElectionID, is_election_id } from "./Election"
|
|
2
|
+
import { is_long_form_type_id, LongFormTypeID } from "./FormTypeID"
|
|
3
|
+
|
|
4
|
+
export class UserElection {
|
|
5
|
+
readonly user_id : string
|
|
6
|
+
readonly election_id : ElectionID
|
|
7
|
+
readonly candidate_display : Record<string, number>
|
|
8
|
+
readonly notify : boolean
|
|
9
|
+
|
|
10
|
+
// readonly [x : string] : any
|
|
11
|
+
|
|
12
|
+
constructor(user_election : any) {
|
|
13
|
+
if (!UserElection.is(user_election)) {
|
|
14
|
+
throw Error("Invalid Input.")
|
|
15
|
+
}
|
|
16
|
+
this.user_id = user_election.user_id
|
|
17
|
+
this.election_id = user_election.election_id
|
|
18
|
+
this.candidate_display = user_election.candidate_display
|
|
19
|
+
this.notify = user_election.notify
|
|
20
|
+
}
|
|
21
|
+
|
|
22
|
+
static is(user_election : any) : user_election is UserElection {
|
|
23
|
+
return (
|
|
24
|
+
user_election !== undefined &&
|
|
25
|
+
typeof user_election.user_id === "string" &&
|
|
26
|
+
is_election_id(user_election.election_id) &&
|
|
27
|
+
Object.entries(user_election.candidate_display).every(([key, value]) => (typeof key === "string" && typeof value === "number")) &&
|
|
28
|
+
typeof user_election.notify === "boolean"
|
|
29
|
+
)
|
|
30
|
+
}
|
|
31
|
+
}
|