@shakerquiz/utilities 0.5.85 → 0.5.87

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/package.json CHANGED
@@ -1,7 +1,7 @@
1
1
  {
2
2
  "type": "module",
3
3
  "name": "@shakerquiz/utilities",
4
- "version": "0.5.85",
4
+ "version": "0.5.87",
5
5
  "author": "yurkimus <yurkimus@gmail.com>",
6
6
  "license": "ISC",
7
7
  "repository": {
@@ -0,0 +1,88 @@
1
+ export var Affilation = /** @type {const} */ ({
2
+ 'Branch': 'Branch',
3
+ 'Franchise': 'Franchise',
4
+ 'Unknown': 'Unknown',
5
+ })
6
+
7
+ export var Affilations = Object.values(Affilation)
8
+
9
+ export var AffilationWeight = {
10
+ [Affilation.Branch]: 0,
11
+ [Affilation.Franchise]: 1,
12
+ [Affilation.Unknown]: 2,
13
+ }
14
+
15
+ export var AffilationTitle = {
16
+ [Affilation.Branch]: 'Филиал',
17
+ [Affilation.Franchise]: 'Франшиза',
18
+ [Affilation.Unknown]: 'Неизвестно',
19
+ }
20
+
21
+ export var AffilationActionTitle = {
22
+ [Affilation.Branch]: '',
23
+ [Affilation.Franchise]: '',
24
+ [Affilation.Unknown]: '',
25
+ }
26
+
27
+ export var AffilationActionDescpription = {
28
+ [Affilation.Branch]: '',
29
+ [Affilation.Franchise]: '',
30
+ [Affilation.Unknown]: '',
31
+ }
32
+
33
+ export var AffilationColor = {
34
+ [Affilation.Branch]: 'primary',
35
+ [Affilation.Franchise]: 'secondary',
36
+ [Affilation.Unknown]: 'danger',
37
+ }
38
+
39
+ export var AffilationTextColor = {
40
+ [Affilation.Branch]: 'text-primary',
41
+ [Affilation.Franchise]: 'text-secondary',
42
+ [Affilation.Unknown]: 'text-danger',
43
+ }
44
+
45
+ /** @type {Record<Affilation, Icon>} */
46
+ export var AffilationIcon = {
47
+ [Affilation.Branch]: 'hero/outline/building-office-2',
48
+ [Affilation.Franchise]: 'hero/outline/building-storefront',
49
+ [Affilation.Unknown]: 'hero/outline/no-symbol',
50
+ }
51
+
52
+ /** @type {Record<Affilation, Pick<CityTable, 'is_franchise'>>} */
53
+ export var AffilationShape = {
54
+ [Affilation.Branch]: {
55
+ is_franchise: false,
56
+ },
57
+
58
+ [Affilation.Franchise]: {
59
+ is_franchise: true,
60
+ },
61
+
62
+ [Affilation.Unknown]: {
63
+ is_franchise: null,
64
+ },
65
+ }
66
+
67
+ export var AffilationShapes = Object.entries(AffilationShape)
68
+
69
+ /**
70
+ * @param {Affilation | typeof AffilationShape[Affilation]} value
71
+ */
72
+ export var getAffilation = value => {
73
+ switch (typeof value) {
74
+ case 'object':
75
+ return AffilationShapes
76
+ .find(([, object]) => object.is_franchise === value.is_franchise)
77
+ ?.at(0)
78
+ ?? Affilation['Unknown']
79
+
80
+ case 'string':
81
+ return value in AffilationShape
82
+ ? AffilationShape[value]
83
+ : AffilationShape[Affilation['Unknown']]
84
+
85
+ default:
86
+ return Affilation['Unknown']
87
+ }
88
+ }
package/source/index.js CHANGED
@@ -10,8 +10,8 @@ export * from './enumerations/misc/phases.js'
10
10
  export * from './enumerations/misc/regexps.js'
11
11
  export * from './enumerations/misc/routes.js'
12
12
 
13
+ export * from './enumerations/entities/affilation.js'
13
14
  export * from './enumerations/entities/cities-mode.js'
14
- export * from './enumerations/entities/city-affilation.js'
15
15
  export * from './enumerations/entities/game-status.js'
16
16
  export * from './enumerations/entities/password-mode.js'
17
17
  export * from './enumerations/entities/registration-attribute.js'
@@ -1,82 +0,0 @@
1
- export var CityAffilation = /** @type {const} */ ({
2
- 'Branch': 'Branch',
3
- 'Franchise': 'Franchise',
4
- })
5
-
6
- export var CityAffilations = Object.values(CityAffilation)
7
-
8
- export var CityAffilationWeight = {
9
- [CityAffilation.Branch]: 0,
10
- [CityAffilation.Franchise]: 1,
11
- }
12
-
13
- export var CityAffilationTitle = {
14
- [CityAffilation.Branch]: 'Филиал',
15
- [CityAffilation.Franchise]: 'Франшиза',
16
- }
17
-
18
- export var CityAffilationActionTitle = {
19
- [CityAffilation.Branch]: 'Назначить филиалом',
20
- [CityAffilation.Franchise]: 'Назначить франшизой',
21
- }
22
-
23
- export var CityAffilationActionDescpription = {
24
- [CityAffilation.Branch]: 'Изменить тип на: Филиал',
25
- [CityAffilation.Franchise]: 'Изменить тип на: Франшиза',
26
- }
27
-
28
- export var CityAffilationColor = {
29
- [CityAffilation.Branch]: 'primary',
30
- [CityAffilation.Franchise]: 'secondary',
31
- }
32
-
33
- export var CityAffilationTextColor = {
34
- [CityAffilation.Branch]: 'text-primary',
35
- [CityAffilation.Franchise]: 'text-secondary',
36
- }
37
-
38
- /** @type {Record<CityAffilation, Icon>} */
39
- export var CityAffilationIcon = {
40
- [CityAffilation.Branch]: 'hero/outline/building-office-2',
41
- [CityAffilation.Franchise]: 'hero/outline/building-storefront',
42
- }
43
-
44
- /** @type {Record<CityAffilation, Pick<CityTable, 'is_franchise'>>} */
45
- export var CityAffilationShape = {
46
- [CityAffilation.Branch]: {
47
- is_franchise: false,
48
- },
49
-
50
- [CityAffilation.Franchise]: {
51
- is_franchise: true,
52
- },
53
- }
54
-
55
- export var CityAffilationShapes = Object.entries(CityAffilationShape)
56
-
57
- /**
58
- * @param {CityAffilation | typeof CityAffilationShape[CityAffilation]} value
59
- */
60
- export var getCityAffilation = value => {
61
- switch (typeof value) {
62
- case 'object':
63
- let found = CityAffilationShapes
64
- .find(([, object]) => object.is_franchise === value.is_franchise)
65
- ?.at(0)
66
-
67
- if (!CityAffilations.includes(found))
68
- throw TypeError(
69
- `[Function: getCityAffilation] Parameter 'found': '${found}' must be a member of 'CityAffilations'.`,
70
- )
71
-
72
- return found
73
-
74
- case 'string':
75
- if (!CityAffilations.includes(value))
76
- throw TypeError(
77
- `[Function: getCityAffilation] Parameter 'value': '${value}' must be a member of 'CityAffilations'.`,
78
- )
79
-
80
- return CityAffilationShape[value]
81
- }
82
- }