@shakerquiz/utilities 0.5.132 → 0.5.134

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 (32) hide show
  1. package/package.json +1 -1
  2. package/source/enumerations/display.js +4 -0
  3. package/source/enumerations/entities/registration-attribute.js +2 -2
  4. package/source/enumerations/entities/role.js +7 -7
  5. package/source/enumerations/method.js +44 -0
  6. package/source/enumerations/{entities/mode.js → mode.js} +4 -2
  7. package/source/enumerations/networks.js +31 -0
  8. package/source/enumerations/phases.js +31 -0
  9. package/source/enumerations/{misc/regexps.js → regexps.js} +0 -1
  10. package/source/enumerations/{misc/routes.js → routes.js} +360 -409
  11. package/source/enumerations/service.js +37 -0
  12. package/source/functions/hydrate-route-pathname.js +18 -0
  13. package/source/functions/route-key.js +17 -0
  14. package/source/functions/tag.js +3 -2
  15. package/source/index.js +22 -23
  16. package/source/enumerations/core/features.js +0 -56
  17. package/source/enumerations/core/methods.js +0 -16
  18. package/source/enumerations/core/networks.js +0 -6
  19. package/source/enumerations/entities/render-context.js +0 -8
  20. package/source/enumerations/misc/phases.js +0 -42
  21. package/source/functions/tag.d.ts +0 -1
  22. /package/source/enumerations/{entities/city → city}/timezone-mode.js +0 -0
  23. /package/source/enumerations/{entities/city → city}/venues-mode.js +0 -0
  24. /package/source/enumerations/{misc/constants.js → constants.js} +0 -0
  25. /package/source/enumerations/{entities/gender.js → gender.js} +0 -0
  26. /package/source/enumerations/{misc/icons.js → icons.js} +0 -0
  27. /package/source/enumerations/{misc/keys.js → keys.js} +0 -0
  28. /package/source/enumerations/{entities/numerosity.js → numerosity.js} +0 -0
  29. /package/source/enumerations/{core/runtimes.js → runtimes.js} +0 -0
  30. /package/source/enumerations/{entities/venue → venue}/audience.js +0 -0
  31. /package/source/enumerations/{entities/venue → venue}/city-mode.js +0 -0
  32. /package/source/enumerations/{entities/venue → venue}/status.js +0 -0
package/package.json CHANGED
@@ -1,7 +1,7 @@
1
1
  {
2
2
  "type": "module",
3
3
  "name": "@shakerquiz/utilities",
4
- "version": "0.5.132",
4
+ "version": "0.5.134",
5
5
  "author": "yurkimus <yurkimus@gmail.com>",
6
6
  "license": "ISC",
7
7
  "repository": {
@@ -0,0 +1,4 @@
1
+ export var Display = /** @type {const} */ ({
2
+ 'Tag': 'Tag',
3
+ 'Chip': 'Chip',
4
+ })
@@ -1,4 +1,4 @@
1
- import { getTag } from '../../functions/tag.js'
1
+ import { inferTag } from '../../functions/tag.js'
2
2
 
3
3
  export var RegistrationAttribute = /** @type {const} */ ({
4
4
  'Alone': 'Alone',
@@ -58,7 +58,7 @@ export var RegistrationPropertyRegistrationAttribute = {
58
58
  * @param {RegistrationAttribute[] | Partial<Pick<RegistrationTable, 'is_alone' | 'is_birthday' | 'is_extensible' | 'is_first'>>} value
59
59
  */
60
60
  export var getRegistrationAttributes = value => {
61
- switch (getTag(value)) {
61
+ switch (inferTag(value)) {
62
62
  case 'Object':
63
63
  return RegistrationAttributeRegistrationProperties
64
64
  .map(property => value[property] ? RegistrationPropertyRegistrationAttribute[property] : '')
@@ -1,3 +1,5 @@
1
+ import { Mode } from '../mode.js'
2
+
1
3
  export var Role = /** @type {const} */ ({
2
4
  'admin': 'admin',
3
5
  'organizer': 'organizer',
@@ -5,7 +7,6 @@ export var Role = /** @type {const} */ ({
5
7
  'player': 'player',
6
8
  'user': 'user',
7
9
  'manager': 'manager',
8
- 'default': 'default',
9
10
  })
10
11
 
11
12
  export var Roles = [
@@ -15,7 +16,6 @@ export var Roles = [
15
16
  Role['player'],
16
17
  Role['user'],
17
18
  Role['manager'],
18
- Role['default'],
19
19
  ]
20
20
 
21
21
  export var RoleTitle = {
@@ -25,7 +25,6 @@ export var RoleTitle = {
25
25
  [Role['player']]: 'Игрок',
26
26
  [Role['user']]: 'Пользователь',
27
27
  [Role['manager']]: 'Менеджер',
28
- [Role['default']]: 'Гость',
29
28
  }
30
29
 
31
30
  export var RoleIcon = {
@@ -35,21 +34,22 @@ export var RoleIcon = {
35
34
  [Role['player']]: 'hero/outline/user',
36
35
  [Role['user']]: 'hero/outline/user',
37
36
  [Role['manager']]: 'hero/outline/user',
38
- [Role['default']]: 'hero/outline/user',
39
37
  }
40
38
 
41
39
  /**
42
- * @returns {keyof typeof Role}
40
+ * @returns {keyof typeof Role | typeof Mode['Unknown']}
43
41
  */
44
42
  export var inferRole = value => {
45
43
  switch (typeof value) {
46
44
  case 'string':
47
- return value in Role ? Role[value] : Role['default']
45
+ return value in Role
46
+ ? Role[value]
47
+ : Mode['Unknown']
48
48
 
49
49
  case 'object':
50
50
  return inferRole(value?.role?.name)
51
51
 
52
52
  default:
53
- return Role['default']
53
+ return Mode['Unknown']
54
54
  }
55
55
  }
@@ -0,0 +1,44 @@
1
+ import { Mode } from './mode.js'
2
+
3
+ /**
4
+ * Related specifications:
5
+ * - HTTP/1.1 (Core Methods): {@link https://datatracker.ietf.org/doc/html/rfc7231#section-4.3}
6
+ * - PATCH: {@link https://datatracker.ietf.org/doc/html/rfc5789}
7
+ */
8
+ export var Method = /** @type {const} */ ({
9
+ 'OPTIONS': 'OPTIONS',
10
+ 'GET': 'GET',
11
+ 'POST': 'POST',
12
+ 'PUT': 'PUT',
13
+ 'PATCH': 'PATCH',
14
+ 'DELETE': 'DELETE',
15
+ })
16
+
17
+ export var Methods = [
18
+ Method['OPTIONS'],
19
+ Method['GET'],
20
+ Method['POST'],
21
+ Method['PUT'],
22
+ Method['PATCH'],
23
+ Method['DELETE'],
24
+ ]
25
+
26
+ /**
27
+ * @returns {typeof Method[keyof typeof Method] | typeof Mode['Unknown']}
28
+ */
29
+ export var inferMethod = value =>
30
+ value in Method
31
+ ? Method[value]
32
+ : Mode['Unknown']
33
+
34
+ /**
35
+ * @throws {TypeError}
36
+ */
37
+ export var guardMethod = value => {
38
+ var method = inferMethod(value)
39
+
40
+ if (method === Mode['Unknown'])
41
+ throw TypeError(`Cannot infer Method for '${value}'.`)
42
+
43
+ return method
44
+ }
@@ -114,12 +114,14 @@ export var ModeTitle = {
114
114
  }
115
115
 
116
116
  /**
117
- * @returns {keyof typeof Mode}
117
+ * @returns {typeof Mode[keyof typeof Mode]}
118
118
  */
119
119
  export var inferMode = value => {
120
120
  switch (typeof value) {
121
121
  case 'string':
122
- return value in Mode ? Mode[value] : Mode['Unknown']
122
+ return value in Mode
123
+ ? Mode[value]
124
+ : Mode['Unknown']
123
125
 
124
126
  case 'object':
125
127
  return inferMode(value?.mode)
@@ -0,0 +1,31 @@
1
+ import { Mode } from './mode.js'
2
+
3
+ export var Network = /** @type {const} */ ({
4
+ 'Docker': 'Docker',
5
+ 'Public': 'Public',
6
+ })
7
+
8
+ export var Networks = [
9
+ Network['Docker'],
10
+ Network['Public'],
11
+ ]
12
+
13
+ /**
14
+ * @returns {typeof Network[keyof typeof Network] | typeof Mode['Unknown']}
15
+ */
16
+ export var inferNetwork = value =>
17
+ value in Method
18
+ ? Method[value]
19
+ : Mode['Unknown']
20
+
21
+ /**
22
+ * @throws {TypeError}
23
+ */
24
+ export var guardNetwork = value => {
25
+ var network = inferNetwork(value)
26
+
27
+ if (network === Mode['Unknown'])
28
+ throw TypeError(`Cannot infer Network for '${value}'.`)
29
+
30
+ return network
31
+ }
@@ -0,0 +1,31 @@
1
+ export var Phase = /** @type {const} */ ({
2
+ 'Idle': 'Idle',
3
+ 'Loading': 'Loading',
4
+ 'Loaded': 'Loaded',
5
+ 'Aborted': 'Aborted',
6
+ 'Failed': 'Failed',
7
+ })
8
+
9
+ export var Phases = [
10
+ Phase['Idle'],
11
+ Phase['Loading'],
12
+ Phase['Loaded'],
13
+ Phase['Aborted'],
14
+ Phase['Failed'],
15
+ ]
16
+
17
+ export var PhaseTitle = {
18
+ [Phase['Idle']]: 'Простой',
19
+ [Phase['Loading']]: 'В процессе',
20
+ [Phase['Loaded']]: 'Завершено',
21
+ [Phase['Aborted']]: 'Оборвано',
22
+ [Phase['Failed']]: 'Ошибка',
23
+ }
24
+
25
+ export var PhaseIcon = {
26
+ [Phase['Idle']]: 'hero/outline/clock',
27
+ [Phase['Loading']]: 'hero/outline/clock',
28
+ [Phase['Loaded']]: 'hero/outline/check',
29
+ [Phase['Aborted']]: 'hero/outline/signal-slash',
30
+ [Phase['Failed']]: 'hero/outline/x-mark',
31
+ }
@@ -1,5 +1,4 @@
1
1
  export var RegExps = {
2
2
  Uuid: /[0-9a-f]{8}-[0-9a-f]{4}-[0-9a-f]{4}-[0-9a-f]{4}-[0-9a-f]{12}/,
3
- ElementId: /\d+:[0-9a-f]{8}-[0-9a-f]{4}-[0-9a-f]{4}-[0-9a-f]{4}-[0-9a-f]{12}:\d+/,
4
3
  Jwt: /^[A-Za-z0-9-_=]+\.[A-Za-z0-9-_=]+\.?[A-Za-z0-9-_.+/=]*$/,
5
4
  }