chelys 2.3.1 → 2.3.2

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.
@@ -25,6 +25,7 @@ export interface Constitution {
25
25
  export declare const EMPTY_CONSTITUTION: Constitution;
26
26
  export declare function canModifySongs(constitution: Constitution): boolean;
27
27
  export declare function canModifyVotes(constitution: Constitution): boolean;
28
+ export declare function areResultsPublic(constitution: Constitution): boolean;
28
29
  export interface CstReqGet {
29
30
  ids: string[];
30
31
  }
@@ -1,7 +1,8 @@
1
1
  "use strict";
2
2
  // TYPE / CONST
3
3
  Object.defineProperty(exports, "__esModule", { value: true });
4
- exports.canModifyVotes = exports.canModifySongs = exports.EMPTY_CONSTITUTION = exports.AnonymousLevel = exports.ConstitutionType = exports.OWNER_INDEX = void 0;
4
+ exports.areResultsPublic = exports.canModifyVotes = exports.canModifySongs = exports.EMPTY_CONSTITUTION = exports.AnonymousLevel = exports.ConstitutionType = exports.OWNER_INDEX = void 0;
5
+ var _1 = require(".");
5
6
  exports.OWNER_INDEX = 0;
6
7
  var ConstitutionType;
7
8
  (function (ConstitutionType) {
@@ -31,7 +32,7 @@ exports.EMPTY_CONSTITUTION = {
31
32
  // FUNCTION
32
33
  function canModifySongs(constitution) {
33
34
  switch (constitution.type) {
34
- case ConstitutionType.GRADE: return constitution.state === 0; // TODO : Magic Number
35
+ case ConstitutionType.GRADE: return constitution.state === _1.GradeState.SONG_ADD;
35
36
  default:
36
37
  return false;
37
38
  }
@@ -39,9 +40,17 @@ function canModifySongs(constitution) {
39
40
  exports.canModifySongs = canModifySongs;
40
41
  function canModifyVotes(constitution) {
41
42
  switch (constitution.type) {
42
- case ConstitutionType.GRADE: return constitution.state < 1; // TODO : Magic Number
43
+ case ConstitutionType.GRADE: return constitution.state <= _1.GradeState.VOTING;
43
44
  default:
44
45
  return false;
45
46
  }
46
47
  }
47
48
  exports.canModifyVotes = canModifyVotes;
49
+ function areResultsPublic(constitution) {
50
+ switch (constitution.type) {
51
+ case ConstitutionType.GRADE: return constitution.state === _1.GradeState.RESULTS;
52
+ default:
53
+ return false;
54
+ }
55
+ }
56
+ exports.areResultsPublic = areResultsPublic;
package/dist/grade.d.ts CHANGED
@@ -10,6 +10,11 @@ export interface GradeSummary {
10
10
  voteCount: number;
11
11
  userCount: Map<string, number>;
12
12
  }
13
+ export declare enum GradeState {
14
+ SONG_ADD = 0,
15
+ VOTING = 1,
16
+ RESULTS = 2
17
+ }
13
18
  export interface KGradeUserData {
14
19
  uid: string;
15
20
  values: Record<string, unknown>;
package/dist/grade.js CHANGED
@@ -1,3 +1,10 @@
1
1
  "use strict";
2
2
  // TYPE / CONST
3
3
  Object.defineProperty(exports, "__esModule", { value: true });
4
+ exports.GradeState = void 0;
5
+ var GradeState;
6
+ (function (GradeState) {
7
+ GradeState[GradeState["SONG_ADD"] = 0] = "SONG_ADD";
8
+ GradeState[GradeState["VOTING"] = 1] = "VOTING";
9
+ GradeState[GradeState["RESULTS"] = 2] = "RESULTS";
10
+ })(GradeState = exports.GradeState || (exports.GradeState = {}));
package/package.json CHANGED
@@ -1,33 +1,33 @@
1
1
  {
2
- "name": "chelys",
3
- "version": "2.3.1",
4
- "description": "Common code between Yatga and Kalimba",
5
- "main": "dist/index.js",
6
- "scripts": {
7
- "test": "echo \"Error: no test specified\" && exit 1",
8
- "build": "tsc"
9
- },
10
- "repository": {
11
- "type": "git",
12
- "url": "git+https://github.com/TableauBits/Chelys.git"
13
- },
14
- "keywords": [
15
- "matbay"
16
- ],
17
- "author": "tableaubits",
18
- "license": "ISC",
19
- "bugs": {
20
- "url": "https://github.com/TableauBits/Chelys/issues"
21
- },
22
- "homepage": "https://github.com/TableauBits/Chelys#readme",
23
- "dependencies": {},
24
- "files": [
25
- "dist/"
26
- ],
27
- "types": "dist/index.d.ts",
28
- "devDependencies": {
29
- "@types/node": "^16.10.1",
30
- "eslint": "^7.32.0",
31
- "typescript": "^4.4.3"
32
- }
2
+ "name": "chelys",
3
+ "version": "2.3.2",
4
+ "description": "Common code between Yatga and Kalimba",
5
+ "main": "dist/index.js",
6
+ "scripts": {
7
+ "test": "echo \"Error: no test specified\" && exit 1",
8
+ "build": "tsc"
9
+ },
10
+ "repository": {
11
+ "type": "git",
12
+ "url": "git+https://github.com/TableauBits/Chelys.git"
13
+ },
14
+ "keywords": [
15
+ "matbay"
16
+ ],
17
+ "author": "tableaubits",
18
+ "license": "ISC",
19
+ "bugs": {
20
+ "url": "https://github.com/TableauBits/Chelys/issues"
21
+ },
22
+ "homepage": "https://github.com/TableauBits/Chelys#readme",
23
+ "dependencies": {},
24
+ "files": [
25
+ "dist/"
26
+ ],
27
+ "types": "dist/index.d.ts",
28
+ "devDependencies": {
29
+ "@types/node": "^16.10.1",
30
+ "eslint": "^7.32.0",
31
+ "typescript": "^4.4.3"
32
+ }
33
33
  }