@shakerquiz/utilities 1.0.0 → 3.0.0

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.
Files changed (94) hide show
  1. package/dprint.json +4 -12
  2. package/jsconfig.json +13 -6
  3. package/package.json +9 -12
  4. package/source/enumerations/core/features.js +56 -0
  5. package/source/enumerations/core/methods.js +16 -0
  6. package/source/enumerations/core/networks.js +6 -0
  7. package/source/enumerations/core/runtimes.js +6 -0
  8. package/source/enumerations/entities/affilation.js +91 -0
  9. package/source/enumerations/entities/cities-mode.js +49 -0
  10. package/source/enumerations/entities/city/timezone-mode.js +44 -0
  11. package/source/enumerations/entities/city/venues-mode.js +60 -0
  12. package/source/enumerations/entities/game-status.js +130 -0
  13. package/source/enumerations/entities/password-mode.js +40 -0
  14. package/source/enumerations/entities/registration-attribute.js +83 -0
  15. package/source/enumerations/entities/registration-channel.js +26 -0
  16. package/source/enumerations/entities/registration-lineup.js +75 -0
  17. package/source/enumerations/entities/registration-mailing.js +24 -0
  18. package/source/enumerations/entities/registration-status.js +89 -0
  19. package/source/enumerations/entities/role-mode.js +40 -0
  20. package/source/enumerations/entities/role.js +82 -0
  21. package/source/enumerations/entities/venue/audience.js +100 -0
  22. package/source/enumerations/entities/venue/city-mode.js +44 -0
  23. package/source/enumerations/entities/venue/status.js +53 -0
  24. package/source/enumerations/entities/version.js +76 -0
  25. package/source/enumerations/{constants.js → misc/constants.js} +2 -2
  26. package/source/enumerations/misc/icons.js +655 -0
  27. package/source/enumerations/misc/keys.js +15 -0
  28. package/source/enumerations/misc/phases.js +42 -0
  29. package/source/enumerations/misc/regexps.js +5 -0
  30. package/source/enumerations/misc/routes.js +610 -0
  31. package/source/functions/tag.d.ts +1 -0
  32. package/source/functions/tag.js +5 -0
  33. package/source/index.js +34 -11
  34. package/source/schemas/PATCH/city/admin.json +126 -0
  35. package/source/schemas/PATCH/city/currency/admin.json +173 -0
  36. package/source/schemas/PATCH/city/timezone/admin.json +501 -0
  37. package/source/schemas/PATCH/game/admin.json +30 -0
  38. package/source/schemas/PATCH/game/organizer.json +30 -0
  39. package/source/schemas/PATCH/registration/admin.json +43 -0
  40. package/source/schemas/PATCH/registration/cancellation/default.json +12 -0
  41. package/source/schemas/PATCH/registration/channel/default.json +22 -0
  42. package/source/schemas/PATCH/registration/confirmation/default.json +12 -0
  43. package/source/schemas/PATCH/registration/default.json +10 -0
  44. package/source/schemas/PATCH/registration/organizer.json +43 -0
  45. package/source/schemas/PATCH/theme/admin.json +19 -0
  46. package/source/schemas/PATCH/user/admin.json +30 -0
  47. package/source/schemas/PATCH/user/cities/admin.json +17 -0
  48. package/source/schemas/PATCH/user/password/admin.json +12 -0
  49. package/source/schemas/PATCH/user/role/admin.json +13 -0
  50. package/source/schemas/PATCH/venue/admin.json +44 -0
  51. package/source/schemas/PATCH/venue/organizer.json +44 -0
  52. package/source/schemas/POST/checkin/default.json +16 -0
  53. package/source/schemas/POST/city/admin.json +696 -0
  54. package/source/schemas/POST/game/admin.json +27 -0
  55. package/source/schemas/POST/game/organizer.json +27 -0
  56. package/source/schemas/POST/game/registrations/export/admin.json +17 -0
  57. package/source/schemas/POST/game/registrations/export/organizer.json +17 -0
  58. package/source/schemas/POST/registration/default.json +125 -0
  59. package/source/schemas/POST/registration/mailing/admin.json +16 -0
  60. package/source/schemas/POST/registration/mailing/organizer.json +16 -0
  61. package/source/schemas/POST/registrations/export/admin.json +17 -0
  62. package/source/schemas/POST/registrations/export/organizer.json +17 -0
  63. package/source/schemas/POST/theme/admin.json +24 -0
  64. package/source/schemas/POST/user/admin.json +12 -0
  65. package/source/schemas/POST/user/cities/admin.json +17 -0
  66. package/source/schemas/POST/user/password/admin.json +12 -0
  67. package/source/schemas/POST/user/role/admin.json +13 -0
  68. package/source/schemas/POST/venue/admin.json +38 -0
  69. package/source/schemas/POST/venue/organizer.json +38 -0
  70. package/source/enumerations/constants.d.ts +0 -3
  71. package/source/enumerations/cookies.d.ts +0 -5
  72. package/source/enumerations/cookies.js +0 -5
  73. package/source/enumerations/features.d.ts +0 -58
  74. package/source/enumerations/features.js +0 -49
  75. package/source/enumerations/game-statuses.d.ts +0 -39
  76. package/source/enumerations/game-statuses.js +0 -39
  77. package/source/enumerations/kinds.d.ts +0 -4
  78. package/source/enumerations/kinds.js +0 -4
  79. package/source/enumerations/methods.d.ts +0 -7
  80. package/source/enumerations/methods.js +0 -7
  81. package/source/enumerations/networks.d.ts +0 -4
  82. package/source/enumerations/networks.js +0 -4
  83. package/source/enumerations/phases.d.ts +0 -7
  84. package/source/enumerations/phases.js +0 -7
  85. package/source/enumerations/regexps.d.ts +0 -4
  86. package/source/enumerations/regexps.js +0 -6
  87. package/source/enumerations/roles.d.ts +0 -5
  88. package/source/enumerations/roles.js +0 -5
  89. package/source/functions/request.d.ts +0 -131
  90. package/source/functions/request.js +0 -202
  91. package/source/globals.d.ts +0 -14
  92. package/source/index.d.ts +0 -15
  93. package/source/results.d.ts +0 -137
  94. package/source/rows.d.ts +0 -533
package/dprint.json CHANGED
@@ -6,27 +6,19 @@
6
6
  "useTabs": false,
7
7
  "useBraces": "maintain",
8
8
  "arrowFunction.useParentheses": "preferNone",
9
- "lineWidth": 80
9
+ "lineWidth": 120,
10
+ "importDeclaration.forceSingleLine": true
10
11
  },
11
-
12
12
  "json": {},
13
-
14
13
  "markdown": {},
15
-
16
14
  "dockerfile": {},
17
-
18
15
  "yaml": {},
19
-
20
16
  "excludes": [
21
17
  "**/node_modules",
22
18
  "**/*-lock.json"
23
19
  ],
24
-
25
20
  "plugins": [
26
21
  "https://plugins.dprint.dev/typescript-0.93.0.wasm",
27
- "https://plugins.dprint.dev/json-0.19.3.wasm",
28
- "https://plugins.dprint.dev/markdown-0.17.8.wasm",
29
- "https://plugins.dprint.dev/dockerfile-0.3.2.wasm",
30
- "https://plugins.dprint.dev/g-plane/pretty_yaml-v0.5.0.wasm"
22
+ "https://plugins.dprint.dev/json-0.19.3.wasm"
31
23
  ]
32
- }
24
+ }
package/jsconfig.json CHANGED
@@ -1,11 +1,18 @@
1
1
  {
2
2
  "compilerOptions": {
3
3
  "baseUrl": ".",
4
-
5
4
  "module": "NodeNext",
6
5
  "moduleResolution": "nodenext",
7
-
8
- "strictBindCallApply": true,
9
- "allowArbitraryExtensions": true
10
- }
11
- }
6
+ "allowJs": true,
7
+ "emitDeclarationOnly": true,
8
+ "declaration": true,
9
+ "paths": {
10
+ "source/": [
11
+ "./source/*"
12
+ ]
13
+ }
14
+ },
15
+ "include": [
16
+ "source/**/*"
17
+ ]
18
+ }
package/package.json CHANGED
@@ -1,20 +1,17 @@
1
1
  {
2
+ "type": "module",
2
3
  "name": "@shakerquiz/utilities",
3
- "version": "1.0.0",
4
+ "version": "3.0.0",
4
5
  "author": "yurkimus <yurkimus@gmail.com>",
5
6
  "license": "ISC",
7
+ "repository": {
8
+ "type": "git",
9
+ "url": "https://github.com/shaker-quiz/utilities.git"
10
+ },
6
11
  "exports": {
7
12
  ".": {
8
- "types": "./source/index.d.ts",
9
- "import": "./source/index.js",
10
- "edge-light": "./source/index.js"
11
- }
12
- },
13
- "dependencies": {
14
- "@yurkimus/cookies": "0.0.7",
15
- "@yurkimus/errors": "0.1.3",
16
- "@yurkimus/message": "0.0.13",
17
- "@yurkimus/response-status": "0.1.0",
18
- "@yurkimus/url": "0.2.7"
13
+ "default": "./source/index.js"
14
+ },
15
+ "./schemas/*.json": "./source/schemas/*.json"
19
16
  }
20
17
  }
@@ -0,0 +1,56 @@
1
+ export var Feature = /** @type {const} */ ({
2
+ 'role': 'role',
3
+ 'roles': 'roles',
4
+ 'user': 'user',
5
+ 'users': 'users',
6
+ 'checkin': 'checkin',
7
+ 'checkins': 'checkins',
8
+ 'country': 'country',
9
+ 'countries': 'countries',
10
+ 'currency': 'currency',
11
+ 'currencies': 'currencies',
12
+ 'timezone': 'timezone',
13
+ 'timezones': 'timezones',
14
+ 'city': 'city',
15
+ 'cities': 'cities',
16
+ 'venue': 'venue',
17
+ 'venues': 'venues',
18
+ 'theme': 'theme',
19
+ 'themes': 'themes',
20
+ 'game': 'game',
21
+ 'games': 'games',
22
+ 'registration': 'registration',
23
+ 'registrations': 'registrations',
24
+ 'mailing': 'mailing',
25
+ 'mailings': 'mailings',
26
+ })
27
+
28
+ export var Features = Object.values(Feature)
29
+
30
+ /** @type {Record<Feature, Icon>} */
31
+ export var FeatureIcon = {
32
+ [Feature.role]: 'hero/solid/identification',
33
+ [Feature.roles]: 'hero/solid/identification',
34
+ [Feature.user]: 'hero/solid/users',
35
+ [Feature.users]: 'hero/solid/users',
36
+ [Feature.checkin]: 'arrow-right-end-on-rectangle',
37
+ [Feature.checkins]: 'arrow-right-end-on-rectangle',
38
+ [Feature.country]: 'hero/outline/no-symbol',
39
+ [Feature.countries]: 'hero/outline/no-symbol',
40
+ [Feature.currency]: 'hero/outline/banknotes',
41
+ [Feature.currencies]: 'hero/outline/banknotes',
42
+ [Feature.timezone]: 'hero/outline/no-symbol',
43
+ [Feature.timezones]: 'hero/outline/no-symbol',
44
+ [Feature.city]: 'hero/outline/building-office',
45
+ [Feature.cities]: 'hero/outline/building-office',
46
+ [Feature.venue]: 'hero/outline/map-pin',
47
+ [Feature.venues]: 'hero/outline/map-pin',
48
+ [Feature.theme]: 'hero/outline/document-text',
49
+ [Feature.themes]: 'hero/outline/document-text',
50
+ [Feature.game]: 'hero/outline/newspaper',
51
+ [Feature.games]: 'hero/outline/newspaper',
52
+ [Feature.registration]: 'hero/outline/user-group',
53
+ [Feature.registrations]: 'hero/outline/user-group',
54
+ [Feature.mailing]: 'hero/outline/envelope',
55
+ [Feature.mailings]: 'hero/outline/envelope',
56
+ }
@@ -0,0 +1,16 @@
1
+ /**
2
+ * Related specifications:
3
+ * - HTTP/1.1 (Core Methods): {@link https://datatracker.ietf.org/doc/html/rfc7231#section-4.3}
4
+ * - PATCH: {@link https://datatracker.ietf.org/doc/html/rfc5789}
5
+ * - CONNECT: {@link https://datatracker.ietf.org/doc/html/rfc9110}
6
+ * - WebDAV Extensions {@link https://datatracker.ietf.org/doc/html/rfc4918}
7
+ */
8
+ export var Method = /** @type {const} */ ({
9
+ 'DELETE': 'DELETE',
10
+ 'GET': 'GET',
11
+ 'OPTIONS': 'OPTIONS',
12
+ 'PATCH': 'PATCH',
13
+ 'POST': 'POST',
14
+ })
15
+
16
+ export var Methods = Object.values(Method)
@@ -0,0 +1,6 @@
1
+ export var Network = /** @type {const} */ ({
2
+ 'Docker': 'Docker',
3
+ 'Public': 'Public',
4
+ })
5
+
6
+ export var Networks = Object.values(Network)
@@ -0,0 +1,6 @@
1
+ export var Runtime = /** @type {const} */ ({
2
+ 'Next': 'Next',
3
+ 'React': 'React',
4
+ })
5
+
6
+ export var Runtimes = Object.values(Runtime)
@@ -0,0 +1,91 @@
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
+ if (value === null)
74
+ return Affilation['Unknown']
75
+
76
+ switch (typeof value) {
77
+ case 'object':
78
+ return AffilationShapes
79
+ .find(([, object]) => object.is_franchise === value.is_franchise)
80
+ ?.at(0)
81
+ ?? Affilation['Unknown']
82
+
83
+ case 'string':
84
+ return value in AffilationShape
85
+ ? AffilationShape[value]
86
+ : AffilationShape[Affilation['Unknown']]
87
+
88
+ default:
89
+ return Affilation['Unknown']
90
+ }
91
+ }
@@ -0,0 +1,49 @@
1
+ export var CitiesMode = /** @type {const} */ ({
2
+ 'all': 'all',
3
+ 'many': 'many',
4
+ 'single': 'single',
5
+ 'none': 'none',
6
+ 'unknown': 'unknown',
7
+ })
8
+
9
+ export var CitiesModes = Object.values(CitiesMode)
10
+
11
+ export var CitiesModeTitle = {
12
+ [CitiesMode.all]: 'Все',
13
+ [CitiesMode.many]: 'Несколько',
14
+ [CitiesMode.single]: 'Один',
15
+ [CitiesMode.none]: 'Пусто',
16
+ [CitiesMode.unknown]: 'Не назначено',
17
+ }
18
+
19
+ export var CitiesModeWeigth = {
20
+ [CitiesMode.all]: 0,
21
+ [CitiesMode.many]: 1,
22
+ [CitiesMode.single]: 2,
23
+ [CitiesMode.none]: 3,
24
+ [CitiesMode.unknown]: 4,
25
+ }
26
+
27
+ /**
28
+ * @param {keyof typeof CitiesMode} value
29
+ */
30
+ var getter = value =>
31
+ value in CitiesMode
32
+ ? value
33
+ : CitiesMode['unknown']
34
+
35
+ export var getCitiesMode = value => {
36
+ if (value === null)
37
+ return getter(undefined)
38
+
39
+ switch (typeof value) {
40
+ case 'string':
41
+ return getter(value)
42
+
43
+ case 'object':
44
+ return getter(value?.mode)
45
+
46
+ default:
47
+ return getter(undefined)
48
+ }
49
+ }
@@ -0,0 +1,44 @@
1
+ export var CityTimezoneMode = /** @type {const} */ ({
2
+ 'Any': 'Any',
3
+ 'Known': 'Known',
4
+ 'Unknown': 'Unknown',
5
+ })
6
+
7
+ export var CityTimezoneModes = [
8
+ CityTimezoneMode['Any'],
9
+ CityTimezoneMode['Known'],
10
+ CityTimezoneMode['Unknown'],
11
+ ]
12
+
13
+ export var CityTimezoneModeTitle = {
14
+ [CityTimezoneMode['Any']]: 'Любой',
15
+ [CityTimezoneMode['Known']]: 'Назначено',
16
+ [CityTimezoneMode['Unknown']]: 'Неизвестно',
17
+ }
18
+
19
+ export var CityTimezoneModeIcon = {
20
+ [CityTimezoneMode['Any']]: 'hero/outline/square-2-stack',
21
+ [CityTimezoneMode['Known']]: 'hero/outline/check',
22
+ [CityTimezoneMode['Unknown']]: 'hero/outline/no-symbol',
23
+ }
24
+
25
+ /**
26
+ * @returns {keyof typeof CityTimezoneMode} value
27
+ */
28
+ var inferString = value =>
29
+ value in CityTimezoneMode
30
+ ? value
31
+ : CityTimezoneMode['Unknown']
32
+
33
+ export var inferCityTimezoneMode = value => {
34
+ switch (typeof value) {
35
+ case 'string':
36
+ return inferString(value)
37
+
38
+ case 'object':
39
+ return inferString(value?.mode)
40
+
41
+ default:
42
+ return CityTimezoneMode['Unknown']
43
+ }
44
+ }
@@ -0,0 +1,60 @@
1
+ export var CityVenuesMode = /** @type {const} */ ({
2
+ 'Any': 'Any',
3
+ 'None': 'None',
4
+ 'Single': 'Single',
5
+ 'Many': 'Many',
6
+ 'Unknown': 'Unknown',
7
+ })
8
+
9
+ export var CityVenuesModes = [
10
+ CityVenuesMode['Any'],
11
+ CityVenuesMode['None'],
12
+ CityVenuesMode['Single'],
13
+ CityVenuesMode['Many'],
14
+ CityVenuesMode['Unknown'],
15
+ ]
16
+
17
+ export var CityVenuesModeTitle = {
18
+ [CityVenuesMode['None']]: 'Любые',
19
+ [CityVenuesMode['None']]: 'Пусто',
20
+ [CityVenuesMode['Single']]: 'Одно',
21
+ [CityVenuesMode['Many']]: 'Несколько',
22
+ [CityVenuesMode['Unknown']]: 'Неизвестно',
23
+ }
24
+
25
+ export var CityVenuesModeIcon = {
26
+ [CityVenuesMode['Any']]: 'hero/outline/square-2-stack',
27
+ [CityVenuesMode['None']]: 'hero/outline/no-symbol',
28
+ [CityVenuesMode['Single']]: 'hero/outline/no-symbol',
29
+ [CityVenuesMode['Many']]: 'hero/outline/no-symbol',
30
+ [CityVenuesMode['Unknown']]: 'hero/outline/no-symbol',
31
+ }
32
+
33
+ /**
34
+ * @returns {keyof typeof CityVenuesMode} value
35
+ */
36
+ var fromString = value =>
37
+ value in CityVenuesMode
38
+ ? value
39
+ : CityVenuesMode['Unknown']
40
+
41
+ /**
42
+ * @returns {keyof typeof CityVenuesMode} value
43
+ */
44
+ var fromObject = value =>
45
+ value?.mode in CityVenuesMode
46
+ ? value.mode
47
+ : CityVenuesMode['Unknown']
48
+
49
+ export var inferCityVenuesMode = value => {
50
+ switch (typeof value) {
51
+ case 'string':
52
+ return fromString(value)
53
+
54
+ case 'object':
55
+ return fromObject(value)
56
+
57
+ default:
58
+ return CityVenuesMode['Unknown']
59
+ }
60
+ }
@@ -0,0 +1,130 @@
1
+ import { Role } from './role.js'
2
+
3
+ export var GameStatus = /** @type {const} */ ({
4
+ 'REJECTED': 'REJECTED',
5
+ 'MODERATION': 'MODERATION',
6
+ 'APPROVED': 'APPROVED',
7
+ 'CLOSED': 'CLOSED',
8
+ 'FORINVITES': 'FORINVITES',
9
+ 'PUBLISHED': 'PUBLISHED',
10
+ 'IS_RESERVE': 'IS_RESERVE',
11
+ 'FINISHED': 'FINISHED',
12
+ 'ARCHIVE': 'ARCHIVE',
13
+ })
14
+
15
+ export var GameStatuses = Object.values(GameStatus)
16
+
17
+ export var GameStatusWeight = {
18
+ [GameStatus.REJECTED]: 0,
19
+ [GameStatus.MODERATION]: 1,
20
+ [GameStatus.APPROVED]: 2,
21
+ [GameStatus.CLOSED]: 3,
22
+ [GameStatus.FORINVITES]: 4,
23
+ [GameStatus.PUBLISHED]: 5,
24
+ [GameStatus.IS_RESERVE]: 6,
25
+ [GameStatus.FINISHED]: 7,
26
+ [GameStatus.ARCHIVE]: 8,
27
+ }
28
+
29
+ export var GameStatusTitle = {
30
+ [GameStatus.REJECTED]: 'Отклонено',
31
+ [GameStatus.MODERATION]: 'На проверке',
32
+ [GameStatus.APPROVED]: 'Одобрено',
33
+ [GameStatus.CLOSED]: 'Закрыта',
34
+ [GameStatus.FORINVITES]: 'По приглашению',
35
+ [GameStatus.PUBLISHED]: 'Опубликовано',
36
+ [GameStatus.IS_RESERVE]: 'В резерве',
37
+ [GameStatus.FINISHED]: 'Завершено',
38
+ [GameStatus.ARCHIVE]: 'В архиве',
39
+ }
40
+
41
+ export var GameStatusColor = {
42
+ [GameStatus.REJECTED]: 'danger',
43
+ [GameStatus.MODERATION]: 'primary',
44
+ [GameStatus.APPROVED]: 'success',
45
+ [GameStatus.CLOSED]: 'warning',
46
+ [GameStatus.FORINVITES]: 'current',
47
+ [GameStatus.PUBLISHED]: 'secondary',
48
+ [GameStatus.IS_RESERVE]: 'blue-900',
49
+ [GameStatus.FINISHED]: 'success',
50
+ [GameStatus.ARCHIVE]: 'current',
51
+ }
52
+
53
+ export var GameStatusTextColor = {
54
+ [GameStatus.REJECTED]: 'text-danger',
55
+ [GameStatus.MODERATION]: 'text-primary',
56
+ [GameStatus.APPROVED]: 'text-success',
57
+ [GameStatus.CLOSED]: 'text-warning',
58
+ [GameStatus.FORINVITES]: 'text-current',
59
+ [GameStatus.PUBLISHED]: 'text-secondary',
60
+ [GameStatus.IS_RESERVE]: 'text-blue-900',
61
+ [GameStatus.FINISHED]: 'text-success',
62
+ [GameStatus.ARCHIVE]: 'text-current',
63
+ }
64
+
65
+ /** @type {Record<GameStatus, Icon>} */
66
+ export var GameStatusIcon = {
67
+ [GameStatus.REJECTED]: 'hero/outline/x-mark',
68
+ [GameStatus.MODERATION]: 'hero/outline/clock',
69
+ [GameStatus.APPROVED]: 'hero/outline/hand-thumb-up',
70
+ [GameStatus.CLOSED]: 'hero/outline/exclamation-triangle',
71
+ [GameStatus.FORINVITES]: 'hero/outline/lock-closed',
72
+ [GameStatus.PUBLISHED]: 'hero/outline/check-circle',
73
+ [GameStatus.IS_RESERVE]: 'hero/outline/user-plus',
74
+ [GameStatus.FINISHED]: 'hero/outline/check',
75
+ [GameStatus.ARCHIVE]: 'hero/outline/archive-box',
76
+ }
77
+
78
+ /** @type {{ [Key in Role]: Partial<Record<GameStatus, GameStatus[]>> }} */
79
+ export var RoleGameStatusGameStatuses = {
80
+ [Role.admin]: {},
81
+
82
+ [Role.organizer]: {
83
+ [GameStatus.APPROVED]: [
84
+ GameStatus.APPROVED,
85
+ GameStatus.CLOSED,
86
+ GameStatus.FORINVITES,
87
+ GameStatus.PUBLISHED,
88
+ GameStatus.IS_RESERVE,
89
+ GameStatus.FINISHED,
90
+ GameStatus.ARCHIVE,
91
+ ],
92
+
93
+ [GameStatus.MODERATION]: [
94
+ GameStatus.MODERATION,
95
+ ],
96
+
97
+ [GameStatus.REJECTED]: [
98
+ GameStatus.REJECTED,
99
+ GameStatus.MODERATION,
100
+ ],
101
+ },
102
+
103
+ [Role.default]: {},
104
+ }
105
+
106
+ /** @type {{ [Key in Role]: GameStatus[] }} */
107
+ export var RoleDefaultGameStatuses = {
108
+ [Role.admin]: [
109
+ 'APPROVED',
110
+ 'ARCHIVE',
111
+ 'CLOSED',
112
+ 'FINISHED',
113
+ 'FORINVITES',
114
+ 'IS_RESERVE',
115
+ 'MODERATION',
116
+ 'PUBLISHED',
117
+ 'REJECTED',
118
+ ],
119
+
120
+ [Role.organizer]: [
121
+ 'ARCHIVE',
122
+ 'CLOSED',
123
+ 'FINISHED',
124
+ 'FORINVITES',
125
+ 'IS_RESERVE',
126
+ 'PUBLISHED',
127
+ ],
128
+
129
+ [Role.default]: [],
130
+ }
@@ -0,0 +1,40 @@
1
+ export var PasswordMode = /** @type {const} */ ({
2
+ 'known': 'known',
3
+ 'unknown': 'unknown',
4
+ })
5
+
6
+ export var PasswordModes = Object.values(PasswordMode)
7
+
8
+ export var PasswordModeTitle = {
9
+ [PasswordMode.known]: 'Назначен',
10
+ [PasswordMode.unknown]: 'Неизвестно',
11
+ }
12
+
13
+ export var PasswordModeWeight = {
14
+ [PasswordMode.known]: 0,
15
+ [PasswordMode.unknown]: 1,
16
+ }
17
+
18
+ /**
19
+ * @param {keyof typeof PasswordMode} value
20
+ */
21
+ var getter = value =>
22
+ value in PasswordMode
23
+ ? value
24
+ : PasswordMode['unknown']
25
+
26
+ export var getPasswordMode = value => {
27
+ if (value === null)
28
+ return getter(undefined)
29
+
30
+ switch (typeof value) {
31
+ case 'string':
32
+ return getter(value)
33
+
34
+ case 'object':
35
+ return getter(value?.mode)
36
+
37
+ default:
38
+ return getter(undefined)
39
+ }
40
+ }
@@ -0,0 +1,83 @@
1
+ import { getTag } from '../../functions/tag.js'
2
+
3
+ export var RegistrationAttribute = /** @type {const} */ ({
4
+ 'Alone': 'Alone',
5
+ 'Newcomer': 'Newcomer',
6
+ 'Birthday': 'Birthday',
7
+ 'Public': 'Public',
8
+ })
9
+
10
+ export var RegistrationAttributes = Object.values(RegistrationAttribute)
11
+
12
+ export var RegistrationAttributeWeight = {
13
+ [RegistrationAttribute.Alone]: 0,
14
+ [RegistrationAttribute.Newcomer]: 1,
15
+ [RegistrationAttribute.Birthday]: 2,
16
+ [RegistrationAttribute.Public]: 3,
17
+ }
18
+
19
+ export var RegistrationAttributeTitle = {
20
+ [RegistrationAttribute.Alone]: 'Без команды',
21
+ [RegistrationAttribute.Newcomer]: 'Новичок',
22
+ [RegistrationAttribute.Birthday]: 'День рождения',
23
+ [RegistrationAttribute.Public]: 'Принимаем людей',
24
+ }
25
+
26
+ /** @type {Record<RegistrationAttribute, Icon>} */
27
+ export var RegistrationAttributeIcon = {
28
+ [RegistrationAttribute.Alone]: 'hero/outline/user',
29
+ [RegistrationAttribute.Newcomer]: 'hero/outline/sparkles',
30
+ [RegistrationAttribute.Birthday]: 'hero/outline/cake',
31
+ [RegistrationAttribute.Public]: 'hero/outline/user-plus',
32
+ }
33
+
34
+ export var RegistrationAttributeEmoji = {
35
+ [RegistrationAttribute.Alone]: '👤',
36
+ [RegistrationAttribute.Newcomer]: '✨',
37
+ [RegistrationAttribute.Birthday]: '🎂',
38
+ [RegistrationAttribute.Public]: '🫂',
39
+ }
40
+
41
+ export var RegistrationAttributeRegistrationProperty = /** @type {const} */ ({
42
+ [RegistrationAttribute.Alone]: 'is_alone',
43
+ [RegistrationAttribute.Newcomer]: 'is_first',
44
+ [RegistrationAttribute.Birthday]: 'is_birthday',
45
+ [RegistrationAttribute.Public]: 'is_extensible',
46
+ })
47
+
48
+ export var RegistrationAttributeRegistrationProperties = Object.values(RegistrationAttributeRegistrationProperty)
49
+
50
+ export var RegistrationPropertyRegistrationAttribute = {
51
+ [RegistrationAttributeRegistrationProperty[RegistrationAttribute.Alone]]: RegistrationAttribute.Alone,
52
+ [RegistrationAttributeRegistrationProperty[RegistrationAttribute.Newcomer]]: RegistrationAttribute.Newcomer,
53
+ [RegistrationAttributeRegistrationProperty[RegistrationAttribute.Birthday]]: RegistrationAttribute.Birthday,
54
+ [RegistrationAttributeRegistrationProperty[RegistrationAttribute.Public]]: RegistrationAttribute.Public,
55
+ }
56
+
57
+ /**
58
+ * @param {RegistrationAttribute[] | Partial<Pick<RegistrationTable, 'is_alone' | 'is_birthday' | 'is_extensible' | 'is_first'>>} value
59
+ */
60
+ export var getRegistrationAttributes = value => {
61
+ switch (getTag(value)) {
62
+ case 'Object':
63
+ return RegistrationAttributeRegistrationProperties
64
+ .map(property => value[property] ? RegistrationPropertyRegistrationAttribute[property] : '')
65
+ .filter(Boolean)
66
+
67
+ case 'Array':
68
+ if (!value.every(attribute => RegistrationAttributes.includes(attribute)))
69
+ throw TypeError(
70
+ `[Function: getRegistrationAttributes] Parameter 'value': '${value}' of type 'Array' must include only members of 'RegistrationAttributes'.`,
71
+ )
72
+
73
+ return value.reduce((attributes, attribute) => {
74
+ attributes[RegistrationAttributeRegistrationProperty[attribute]] = true
75
+ return attributes
76
+ }, {})
77
+
78
+ default:
79
+ throw TypeError(
80
+ `[Function: getRegistrationAttributes] Parameter 'value': '${value}' must be of types: 'Object', 'Array'.`,
81
+ )
82
+ }
83
+ }