@shakerquiz/utilities 0.6.0 → 0.6.2

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.6.0",
4
+ "version": "0.6.2",
5
5
  "author": "yurkimus <yurkimus@gmail.com>",
6
6
  "license": "ISC",
7
7
  "repository": {
@@ -11,4 +11,4 @@
11
11
  "exports": {
12
12
  "default": "./source/index.js"
13
13
  }
14
- }
14
+ }
@@ -1,8 +1,7 @@
1
1
  import { Route } from './route.js'
2
2
  import { Service } from './service.js'
3
3
 
4
- export const DefaultRouteService = Object.freeze({
5
- [Route['checkin']]: Service['Checkin'],
4
+ export const RouteService = Object.freeze({
6
5
  [Route['user']]: Service['Users'],
7
6
  [Route['user/cities']]: Service['Users'],
8
7
  [Route['user/password']]: Service['Users'],
@@ -12,6 +11,13 @@ export const DefaultRouteService = Object.freeze({
12
11
  [Route['users/role']]: Service['Users'],
13
12
  [Route['role']]: Service['Roles'],
14
13
  [Route['roles']]: Service['Roles'],
14
+ [Route['checkin']]: Service['Checkin'],
15
+ [Route['countries']]: Service['Locations'],
16
+ [Route['country']]: Service['Locations'],
17
+ [Route['currencies']]: Service['Locations'],
18
+ [Route['currency']]: Service['Locations'],
19
+ [Route['timezone']]: Service['Locations'],
20
+ [Route['timezones']]: Service['Locations'],
15
21
  [Route['cities']]: Service['Cities'],
16
22
  [Route['cities/country']]: Service['Cities'],
17
23
  [Route['cities/currency']]: Service['Cities'],
@@ -22,10 +28,14 @@ export const DefaultRouteService = Object.freeze({
22
28
  [Route['city/currency']]: Service['Cities'],
23
29
  [Route['city/timezone']]: Service['Cities'],
24
30
  [Route['city/venues']]: Service['Cities'],
25
- [Route['countries']]: Service['Locations'],
26
- [Route['country']]: Service['Locations'],
27
- [Route['currencies']]: Service['Locations'],
28
- [Route['currency']]: Service['Locations'],
31
+ [Route['venue']]: Service['Venues'],
32
+ [Route['venue/city']]: Service['Venues'],
33
+ [Route['venues']]: Service['Venues'],
34
+ [Route['venues/city']]: Service['Venues'],
35
+ [Route['theme']]: Service['Themes'],
36
+ [Route['theme/cover']]: Service['Themes'],
37
+ [Route['themes']]: Service['Themes'],
38
+ [Route['themes/cover']]: Service['Themes'],
29
39
  [Route['game']]: Service['Games'],
30
40
  [Route['game/city']]: Service['Games'],
31
41
  [Route['game/registrations']]: Service['Games'],
@@ -52,14 +62,4 @@ export const DefaultRouteService = Object.freeze({
52
62
  [Route['registrations/game']]: Service['Registrations'],
53
63
  [Route['registrations/game/theme']]: Service['Registrations'],
54
64
  [Route['registrations/export']]: Service['Registrations'],
55
- [Route['theme']]: Service['Themes'],
56
- [Route['theme/cover']]: Service['Themes'],
57
- [Route['themes']]: Service['Themes'],
58
- [Route['themes/cover']]: Service['Themes'],
59
- [Route['timezone']]: Service['Locations'],
60
- [Route['timezones']]: Service['Locations'],
61
- [Route['venue']]: Service['Venues'],
62
- [Route['venue/city']]: Service['Venues'],
63
- [Route['venues']]: Service['Venues'],
64
- [Route['venues/city']]: Service['Venues'],
65
65
  })
@@ -1,34 +1,107 @@
1
- import { DefaultRouteService } from './route-service.js'
1
+ import { Route } from './route.js'
2
2
  import { Service } from './service.js'
3
3
 
4
- export let ServiceRoutes = (() => {
5
- let object = {}
6
-
7
- for (const service in Service)
8
- object[service] = []
9
-
10
- for (const route in DefaultRouteService)
11
- object[DefaultRouteService[route]].push(route)
12
-
13
- return Object.freeze(object)
14
- })()
15
-
16
- export let ServiceRoutes = {
17
- 'Checkin': [
18
- 'checkin',
19
- ],
20
-
21
- 'Users': [
22
- 'user',
23
- 'user/cities',
24
- 'user/password',
25
- 'user/role',
26
- 'users',
27
- 'users/cities',
28
- 'users/role',
29
- ],
30
-
31
- 'Landing': [
32
- ''
33
- ],
34
- }
4
+ export const ServiceRoutes = Object.freeze({
5
+ [Service['Users']]: Object.freeze([
6
+ Route['user'],
7
+ Route['user/cities'],
8
+ Route['user/password'],
9
+ Route['user/role'],
10
+ Route['users'],
11
+ Route['users/cities'],
12
+ Route['users/role'],
13
+ ]),
14
+
15
+ [Service['Roles']]: Object.freeze([
16
+ Route['role'],
17
+ Route['roles'],
18
+ ]),
19
+
20
+ [Service['Checkin']]: Object.freeze([
21
+ Route['checkin'],
22
+ ]),
23
+
24
+ [Service['Locations']]: Object.freeze([
25
+ Route['countries'],
26
+ Route['country'],
27
+ Route['currencies'],
28
+ Route['currency'],
29
+ Route['timezone'],
30
+ Route['timezones'],
31
+ ]),
32
+
33
+ [Service['Cities']]: Object.freeze([
34
+ Route['cities'],
35
+ Route['cities/country'],
36
+ Route['cities/currency'],
37
+ Route['cities/timezone'],
38
+ Route['cities/venues'],
39
+ Route['city'],
40
+ Route['city/country'],
41
+ Route['city/currency'],
42
+ Route['city/timezone'],
43
+ Route['city/venues'],
44
+ ]),
45
+
46
+ [Service['Venues']]: Object.freeze([
47
+ Route['venue'],
48
+ Route['venue/city'],
49
+ Route['venues'],
50
+ Route['venues/city'],
51
+ ]),
52
+
53
+ [Service['Themes']]: Object.freeze([
54
+ Route['theme'],
55
+ Route['theme/cover'],
56
+ Route['themes'],
57
+ Route['themes/cover'],
58
+ ]),
59
+
60
+ [Service['Games']]: Object.freeze([
61
+ Route['game'],
62
+ Route['game/city'],
63
+ Route['game/registrations'],
64
+ Route['game/registrations/export'],
65
+ Route['game/summary'],
66
+ Route['game/theme'],
67
+ Route['game/venue'],
68
+ Route['games'],
69
+ Route['games/city'],
70
+ Route['games/registrations'],
71
+ Route['games/registrations/export'],
72
+ Route['games/summary'],
73
+ Route['games/theme'],
74
+ Route['games/venue'],
75
+ ]),
76
+
77
+ [Service['Registrations']]: Object.freeze([
78
+ Route['registration'],
79
+ Route['registration/cancellation'],
80
+ Route['registration/channel'],
81
+ Route['registration/confirmation'],
82
+ Route['registration/city'],
83
+ Route['registration/game'],
84
+ Route['registration/mailing'],
85
+ Route['registrations'],
86
+ Route['registrations/city'],
87
+ Route['registrations/game'],
88
+ Route['registrations/game/theme'],
89
+ Route['registrations/export'],
90
+ ]),
91
+
92
+ [Service['Files']]: Object.freeze([]),
93
+
94
+ [Service['Procedures']]: Object.freeze([]),
95
+
96
+ [Service['Integrations']]: Object.freeze([]),
97
+
98
+ [Service['Updates']]: Object.freeze([]),
99
+
100
+ [Service['Hub']]: Object.freeze([]),
101
+
102
+ [Service['Landing']]: Object.freeze([]),
103
+
104
+ [Service['Vkma']]: Object.freeze([]),
105
+
106
+ [Service['Minio']]: Object.freeze([]),
107
+ })
@@ -1,22 +1,21 @@
1
- import { Mode } from './mode.js'
2
1
  import { Runtime } from './runtime.js'
2
+ import { Service } from './service.js'
3
3
 
4
4
  export const ServiceRuntime = Object.freeze({
5
- 'Users': Runtime['Deno'],
6
- 'Roles': Runtime['Deno'],
7
- 'Checkin': Runtime['Deno'],
8
- 'Locations': Runtime['Deno'],
9
- 'Cities': Runtime['Deno'],
10
- 'Venues': Runtime['Deno'],
11
- 'Themes': Runtime['Deno'],
12
- 'Games': Runtime['Deno'],
13
- 'Registrations': Runtime['Deno'],
14
- 'Files': Runtime['Bun'],
15
- 'Procedures': Runtime['Bun'],
16
- 'Integrations': Runtime['Bun'],
17
- 'Updates': Runtime['Bun'],
18
- 'Hub': Runtime['Node'],
19
- 'Landing': Runtime['Node'],
20
- 'Vkma': Runtime['Vite'],
21
- 'Minio': Mode['Unknown'],
5
+ [Service['Users']]: Runtime['Deno'],
6
+ [Service['Roles']]: Runtime['Deno'],
7
+ [Service['Checkin']]: Runtime['Deno'],
8
+ [Service['Locations']]: Runtime['Deno'],
9
+ [Service['Cities']]: Runtime['Deno'],
10
+ [Service['Venues']]: Runtime['Deno'],
11
+ [Service['Themes']]: Runtime['Deno'],
12
+ [Service['Games']]: Runtime['Deno'],
13
+ [Service['Registrations']]: Runtime['Deno'],
14
+ [Service['Files']]: Runtime['Bun'],
15
+ [Service['Procedures']]: Runtime['Bun'],
16
+ [Service['Integrations']]: Runtime['Bun'],
17
+ [Service['Updates']]: Runtime['Bun'],
18
+ [Service['Hub']]: Runtime['Node'],
19
+ [Service['Landing']]: Runtime['Node'],
20
+ [Service['Vkma']]: Runtime['Vite'],
22
21
  })
@@ -18,22 +18,4 @@ export const Service = Object.freeze({
18
18
  'Minio': 'Minio',
19
19
  })
20
20
 
21
- export const Services = Object.freeze([
22
- 'Users',
23
- 'Roles',
24
- 'Checkin',
25
- 'Locations',
26
- 'Cities',
27
- 'Venues',
28
- 'Themes',
29
- 'Games',
30
- 'Registrations',
31
- 'Files',
32
- 'Procedures',
33
- 'Integrations',
34
- 'Updates',
35
- 'Hub',
36
- 'Landing',
37
- 'Vkma',
38
- 'Minio',
39
- ])
21
+ export const Services = Object.freeze(Object.values(Service))
@@ -1,5 +1,7 @@
1
- import { checkRoute } from '../application/route.js'
2
- import { inferRouteParams, inferRoutePathname } from '../system/route.js'
1
+ import { RoutePathnameParams } from '../entities/route-pathname-params.js'
2
+ import { RoutePathname } from '../entities/route-pathname.js'
3
+ import { Route } from '../entities/route.js'
4
+ import { Relation } from '../prototypes/relation.js'
3
5
 
4
6
  export const hydrateRoutePathname = Object.freeze(
5
7
  /**
@@ -12,21 +14,18 @@ export const hydrateRoutePathname = Object.freeze(
12
14
  if (!Array.isArray(params))
13
15
  throw TypeError(`Parameter 'params' must be 'Array'.`)
14
16
 
15
- var $route = checkRoute(route)
17
+ var r = Relation
18
+ .of(Route)
19
+ .require(route)
16
20
 
17
- var $routePathname = inferRoutePathname($route)
21
+ var rp = Relation
22
+ .of(RoutePathname)
23
+ .require(r)
18
24
 
19
- if ($routePathname === 'Unknown')
20
- throw TypeError(`Could not infer route pathname of: '${$route}'.`)
25
+ var rpp = Relation
26
+ .of(RoutePathnameParams)
27
+ .require(r)
21
28
 
22
- var rpm = inferRouteParams($route)
23
-
24
- if (rpm === 'Unknown')
25
- throw TypeError(`Could not infer route params of: '${$route}'.`)
26
-
27
- return rpm.reduce(
28
- (pathname, param, index) => pathname.replace(param, params[index]),
29
- $routePathname,
30
- )
29
+ return rpp.reduce((rp, rpp, i) => rp.replace(rpp, params[i]), rp)
31
30
  },
32
31
  )
@@ -1,5 +1,5 @@
1
- import { inferMethod } from '../system/method.js'
2
-
1
+ import { Method } from '../entities/mode.js'
2
+ import { Relation } from '../prototypes/relation.js'
3
3
  import { hydrateRoutePathname } from './hydrate-route-pathname.js'
4
4
 
5
5
  export const tag = Object.freeze(
@@ -15,10 +15,9 @@ export const tag = Object.freeze(
15
15
  * @returns {`${MethodTemplate}/${RoutePathnameTemplate}`}
16
16
  */
17
17
  (method, route, params) => {
18
- var m = inferMethod(method)
19
-
20
- if (m === 'Unknown')
21
- throw TypeError(`Could not infer method of: '${method}'.`)
18
+ var m = Relation
19
+ .of(Method)
20
+ .require(method)
22
21
 
23
22
  return m + '/' + hydrateRoutePathname(route, params)
24
23
  },
package/source/index.js CHANGED
@@ -38,4 +38,4 @@ export * from './entities/venue-status.js'
38
38
  export * from './helpers/hydrate-route-pathname.js'
39
39
  export * from './helpers/string-tag.js'
40
40
  export * from './helpers/tag.js'
41
- export * from './prototypes/reflection.js'
41
+ export * from './prototypes/relation.js'