@shakerquiz/utilities 0.5.209 → 0.5.211

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.209",
4
+ "version": "0.5.211",
5
5
  "author": "yurkimus <yurkimus@gmail.com>",
6
6
  "license": "ISC",
7
7
  "repository": {
@@ -167,6 +167,11 @@ export const RouteRelation = Object.freeze({
167
167
  [Route['venues/city']]: Route['venue/city'],
168
168
  })
169
169
 
170
+ export const RouteItems = Object.freeze({
171
+ [Route['user/role']]: Route['roles'],
172
+ [Route['user/city']]: Route['cities'],
173
+ })
174
+
170
175
  export const RoutePathname = Object.freeze({
171
176
  [Route['checkin']]: 'checkin',
172
177
  [Route['cities']]: 'cities',
@@ -484,6 +489,11 @@ export const inferRouteRelation = Object.freeze(
484
489
  x => RouteRelation[x] ?? 'Unknown',
485
490
  )
486
491
 
492
+ export const inferRouteItems = Object.freeze(
493
+ /** @returns {typeof RouteItems[keyof typeof RouteItems] | 'Unknown'} */
494
+ x => RouteItems[x] ?? 'Unknown',
495
+ )
496
+
487
497
  export const inferRoutePathname = Object.freeze(
488
498
  /** @returns {typeof RoutePathname[keyof typeof RoutePathname] | 'Unknown'} */
489
499
  x => RoutePathname[x] ?? 'Unknown',
@@ -2,13 +2,33 @@ import { inferMethod } from '../enumerations/method.js'
2
2
 
3
3
  import { hydrateRoutePathname } from './hydrate-route-pathname.js'
4
4
 
5
- export const tag = Object.freeze((m, r, p) => {
6
- var method = inferMethod(m)
5
+ export const tag = Object.freeze(
6
+ /**
7
+ * @template {keyof typeof import('../enumerations/method.js').Method} M
8
+ * @template {keyof typeof import('../enumerations/route.js').Route} R
9
+ *
10
+ * @param {M} m
11
+ * @param {R} r
12
+ * @param {string[]} p
13
+ */
14
+ (m, r, p) => {
15
+ var method = inferMethod(m)
7
16
 
8
- if (method === 'Unknown')
9
- throw TypeError(`Could not infer method of: '${m}'.`)
17
+ if (method === 'Unknown')
18
+ throw TypeError(`Could not infer method of: '${m}'.`)
10
19
 
11
- return method + '/' + hydrateRoutePathname(r, p)
12
- })
20
+ return method + '/' + hydrateRoutePathname(r, p)
21
+ },
22
+ )
13
23
 
14
- export const tagexp = Object.freeze((m, r, p) => new RegExp(`^${tag(m, r, p)}$`))
24
+ export const tagexp = Object.freeze(
25
+ /**
26
+ * @template {keyof typeof import('../enumerations/method.js').Method} M
27
+ * @template {keyof typeof import('../enumerations/route.js').Route} R
28
+ *
29
+ * @param {M} m
30
+ * @param {R} r
31
+ * @param {string[]} p
32
+ */
33
+ (m, r, p) => new RegExp(`^${tag(m, r, p)}$`),
34
+ )