@shakerquiz/utilities 0.5.44 → 0.5.45

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.44",
4
+ "version": "0.5.45",
5
5
  "author": "yurkimus <yurkimus@gmail.com>",
6
6
  "license": "ISC",
7
7
  "scripts": {
@@ -13,6 +13,7 @@ export var Route = /** @type {const} */ ({
13
13
  'cities': 'cities',
14
14
  'city/venues': 'city/venues',
15
15
  'venue': 'venue',
16
+ 'venues': 'venues',
16
17
  'theme': 'theme',
17
18
  'themes': 'themes',
18
19
  'theme/cover': 'theme/cover',
@@ -20,6 +21,7 @@ export var Route = /** @type {const} */ ({
20
21
  'game': 'game',
21
22
  'games': 'games',
22
23
  'registration': 'registration',
24
+ 'registration/mailing': 'registration/mailing',
23
25
  'registrations': 'registrations',
24
26
  'mailing': 'mailing',
25
27
  })
@@ -41,6 +43,7 @@ export var RoutePathname = /** @type {const} */ ({
41
43
  [Route['cities']]: 'cities',
42
44
  [Route['city/venues']]: 'city/:city/venues',
43
45
  [Route['venue']]: 'venue/:venue',
46
+ [Route['venues']]: 'venues',
44
47
  [Route['theme']]: 'theme/:theme',
45
48
  [Route['themes']]: 'themes',
46
49
  [Route['theme/cover']]: 'theme/:theme/cover',
@@ -48,8 +51,67 @@ export var RoutePathname = /** @type {const} */ ({
48
51
  [Route['game']]: 'game/:game',
49
52
  [Route['games']]: 'games',
50
53
  [Route['registration']]: 'registration/:registration',
54
+ [Route['registration/mailing']]: 'registration/:registration/mailing',
51
55
  [Route['registrations']]: 'registrations',
52
56
  [Route['mailing']]: 'mailing/:mailing',
53
57
  })
54
58
 
55
59
  export var RoutePathnames = Object.values(RoutePathname)
60
+
61
+ export var RouteParams = /** @type {const} */ ({
62
+ [Route['role']]: [':role'],
63
+ [Route['user']]: [':user'],
64
+ [Route['user/password']]: [':user'],
65
+ [Route['user/role']]: [':user'],
66
+ [Route['user/cities']]: [':user'],
67
+ [Route['city']]: [':city'],
68
+ [Route['city/venues']]: [':city'],
69
+ [Route['venue']]: [':venue'],
70
+ [Route['theme']]: [':theme'],
71
+ [Route['theme/cover']]: [':theme'],
72
+ [Route['game']]: [':game'],
73
+ [Route['registration']]: [':registration'],
74
+ [Route['registration/mailing']]: [':registration'],
75
+ [Route['mailing']]: [':mailing'],
76
+ })
77
+
78
+ export var RouteService = {
79
+ [Route['role']]: 'Users',
80
+ [Route['roles']]: 'Users',
81
+ [Route['user']]: 'Users',
82
+ [Route['users']]: 'Users',
83
+ [Route['checkin']]: 'Checkin',
84
+ [Route['user/password']]: 'Users',
85
+ [Route['user/role']]: 'Users',
86
+ [Route['user/cities']]: 'Users',
87
+ [Route['users/role']]: 'Users',
88
+ [Route['users/cities']]: 'Users',
89
+ [Route['city']]: 'Cities',
90
+ [Route['cities']]: 'Cities',
91
+ [Route['city/venues']]: 'Cities',
92
+ [Route['venue']]: 'Venues',
93
+ [Route['venues']]: 'Venues',
94
+ [Route['theme']]: 'Themes',
95
+ [Route['themes']]: 'Themes',
96
+ [Route['theme/cover']]: 'Themes',
97
+ [Route['themes/covers']]: 'Themes',
98
+ [Route['game']]: 'Games',
99
+ [Route['games']]: 'Games',
100
+ [Route['registration']]: 'Games',
101
+ [Route['registration/mailing']]: 'Games',
102
+ [Route['registrations']]: 'Games',
103
+ [Route['mailing']]: 'Games',
104
+ }
105
+
106
+ /**
107
+ * @template {Route} R
108
+ * @template {typeof RouteParams[R]} P
109
+ *
110
+ * @param {R} route
111
+ * @param {Record<P[number] extends `:${infer Name}` ? Name : P[number], string>} params
112
+ */
113
+ export var hydrateRoutePathname = (route, params) =>
114
+ RouteParams[route].reduce(
115
+ (pathname, param) => pathname.replace(param, params[param.replace(':', '')]),
116
+ RoutePathname[route],
117
+ )
package/source/misc.d.ts CHANGED
@@ -60,3 +60,5 @@ type VenueStatus = keyof typeof import('./enumerations/entities/venue-status.js'
60
60
  type Icon = typeof import('./enumerations/misc/icons.js').Icons[number]
61
61
 
62
62
  type Phase = keyof typeof import('./enumerations/misc/phases.js').Phase
63
+
64
+ type Route = keyof typeof import('./enumerations/misc/routes.js').Route