@shakerquiz/utilities 0.5.222 → 0.6.1

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 (70) hide show
  1. package/package.json +2 -4
  2. package/source/entities/blend.js +5 -0
  3. package/source/entities/cardinality-routes.js +82 -0
  4. package/source/entities/cardinality.js +8 -0
  5. package/source/entities/category.js +4 -0
  6. package/source/entities/city-affilation.js +16 -0
  7. package/source/entities/city-chatapp-version.js +9 -0
  8. package/source/entities/game-status.js +110 -0
  9. package/source/{enumerations → entities}/gender.js +7 -0
  10. package/source/entities/icon.js +654 -0
  11. package/source/entities/method.js +22 -0
  12. package/source/entities/mode.js +14 -0
  13. package/source/entities/network.js +9 -0
  14. package/source/entities/numerosity.js +5 -0
  15. package/source/entities/phase.js +23 -0
  16. package/source/entities/quantifier.js +41 -0
  17. package/source/entities/registration-attribute.js +68 -0
  18. package/source/entities/registration-channel.js +17 -0
  19. package/source/entities/registration-lineup.js +19 -0
  20. package/source/entities/registration-mailing.js +20 -0
  21. package/source/{enumerations/registration/status.js → entities/registration-status.js} +1 -13
  22. package/source/entities/role.js +25 -0
  23. package/source/entities/route-cardinality-route.js +112 -0
  24. package/source/entities/route-cardinality.js +175 -0
  25. package/source/entities/route-pathname-params.js +12 -0
  26. package/source/entities/route-pathname.js +70 -0
  27. package/source/entities/route-service.js +65 -0
  28. package/source/entities/route.js +70 -0
  29. package/source/entities/service-routes.js +107 -0
  30. package/source/entities/service-runtime.js +21 -0
  31. package/source/entities/service.js +21 -0
  32. package/source/entities/theme-status.js +14 -0
  33. package/source/entities/venue-audience.js +14 -0
  34. package/source/entities/venue-status.js +15 -0
  35. package/source/helpers/hydrate-route-pathname.js +32 -0
  36. package/source/helpers/string-tag.js +7 -0
  37. package/source/helpers/tag.js +37 -0
  38. package/source/index.js +41 -38
  39. package/source/prototypes/reflection.js +53 -0
  40. package/source/enumerations/blend.js +0 -11
  41. package/source/enumerations/cardinality.js +0 -13
  42. package/source/enumerations/category.js +0 -9
  43. package/source/enumerations/entities/affilation.js +0 -29
  44. package/source/enumerations/entities/game-status.js +0 -122
  45. package/source/enumerations/entities/registration-attribute.js +0 -83
  46. package/source/enumerations/entities/registration-channel.js +0 -26
  47. package/source/enumerations/entities/registration-mailing.js +0 -24
  48. package/source/enumerations/entities/role.js +0 -40
  49. package/source/enumerations/entities/version.js +0 -23
  50. package/source/enumerations/icon.js +0 -655
  51. package/source/enumerations/method.js +0 -31
  52. package/source/enumerations/mode.js +0 -48
  53. package/source/enumerations/network.js +0 -9
  54. package/source/enumerations/numerosity.js +0 -5
  55. package/source/enumerations/phase.js +0 -31
  56. package/source/enumerations/quantifier.js +0 -87
  57. package/source/enumerations/registration/lineup.js +0 -33
  58. package/source/enumerations/route.js +0 -515
  59. package/source/enumerations/service.js +0 -62
  60. package/source/enumerations/theme/status.js +0 -27
  61. package/source/enumerations/venue/audience.js +0 -27
  62. package/source/enumerations/venue/status.js +0 -27
  63. package/source/functions/hydrate-route-params.js +0 -18
  64. package/source/functions/hydrate-route-pathname.js +0 -26
  65. package/source/functions/string-tag.js +0 -5
  66. package/source/functions/tag.js +0 -37
  67. /package/source/{enumerations → entities}/constants.js +0 -0
  68. /package/source/{enumerations → entities}/display.js +0 -0
  69. /package/source/{enumerations → entities}/pattern.js +0 -0
  70. /package/source/{enumerations → entities}/runtime.js +0 -0
@@ -0,0 +1,65 @@
1
+ import { Route } from './route.js'
2
+ import { Service } from './service.js'
3
+
4
+ export const RouteService = Object.freeze({
5
+ [Route['user']]: Service['Users'],
6
+ [Route['user/cities']]: Service['Users'],
7
+ [Route['user/password']]: Service['Users'],
8
+ [Route['user/role']]: Service['Users'],
9
+ [Route['users']]: Service['Users'],
10
+ [Route['users/cities']]: Service['Users'],
11
+ [Route['users/role']]: Service['Users'],
12
+ [Route['role']]: Service['Roles'],
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'],
21
+ [Route['cities']]: Service['Cities'],
22
+ [Route['cities/country']]: Service['Cities'],
23
+ [Route['cities/currency']]: Service['Cities'],
24
+ [Route['cities/timezone']]: Service['Cities'],
25
+ [Route['cities/venues']]: Service['Cities'],
26
+ [Route['city']]: Service['Cities'],
27
+ [Route['city/country']]: Service['Cities'],
28
+ [Route['city/currency']]: Service['Cities'],
29
+ [Route['city/timezone']]: Service['Cities'],
30
+ [Route['city/venues']]: Service['Cities'],
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'],
39
+ [Route['game']]: Service['Games'],
40
+ [Route['game/city']]: Service['Games'],
41
+ [Route['game/registrations']]: Service['Games'],
42
+ [Route['game/registrations/export']]: Service['Games'],
43
+ [Route['game/summary']]: Service['Games'],
44
+ [Route['game/theme']]: Service['Games'],
45
+ [Route['game/venue']]: Service['Games'],
46
+ [Route['games']]: Service['Games'],
47
+ [Route['games/city']]: Service['Games'],
48
+ [Route['games/registrations']]: Service['Games'],
49
+ [Route['games/registrations/export']]: Service['Games'],
50
+ [Route['games/summary']]: Service['Games'],
51
+ [Route['games/theme']]: Service['Games'],
52
+ [Route['games/venue']]: Service['Games'],
53
+ [Route['registration']]: Service['Registrations'],
54
+ [Route['registration/cancellation']]: Service['Registrations'],
55
+ [Route['registration/channel']]: Service['Registrations'],
56
+ [Route['registration/confirmation']]: Service['Registrations'],
57
+ [Route['registration/city']]: Service['Registrations'],
58
+ [Route['registration/game']]: Service['Registrations'],
59
+ [Route['registration/mailing']]: Service['Registrations'],
60
+ [Route['registrations']]: Service['Registrations'],
61
+ [Route['registrations/city']]: Service['Registrations'],
62
+ [Route['registrations/game']]: Service['Registrations'],
63
+ [Route['registrations/game/theme']]: Service['Registrations'],
64
+ [Route['registrations/export']]: Service['Registrations'],
65
+ })
@@ -0,0 +1,70 @@
1
+ export const Route = Object.freeze({
2
+ 'checkin': 'checkin',
3
+ 'cities': 'cities',
4
+ 'cities/country': 'cities/country',
5
+ 'cities/currency': 'cities/currency',
6
+ 'cities/timezone': 'cities/timezone',
7
+ 'cities/venues': 'cities/venues',
8
+ 'city': 'city',
9
+ 'city/country': 'city/country',
10
+ 'city/currency': 'city/currency',
11
+ 'city/timezone': 'city/timezone',
12
+ 'city/venue': 'city/venue',
13
+ 'city/venues': 'city/venues',
14
+ 'countries': 'countries',
15
+ 'country': 'country',
16
+ 'currencies': 'currencies',
17
+ 'currency': 'currency',
18
+ 'game': 'game',
19
+ 'game/city': 'game/city',
20
+ 'game/registration': 'game/registration',
21
+ 'game/registrations': 'game/registrations',
22
+ 'game/registrations/export': 'game/registrations/export',
23
+ 'game/summary': 'game/summary',
24
+ 'game/theme': 'game/theme',
25
+ 'game/venue': 'game/venue',
26
+ 'games': 'games',
27
+ 'games/city': 'games/city',
28
+ 'games/registrations': 'games/registrations',
29
+ 'games/registrations/export': 'games/registrations/export',
30
+ 'games/summary': 'games/summary',
31
+ 'games/theme': 'games/theme',
32
+ 'games/venue': 'games/venue',
33
+ 'registration': 'registration',
34
+ 'registration/cancellation': 'registration/cancellation',
35
+ 'registration/channel': 'registration/channel',
36
+ 'registration/confirmation': 'registration/confirmation',
37
+ 'registration/export': 'registration/export',
38
+ 'registration/city': 'registration/city',
39
+ 'registration/game': 'registration/game',
40
+ 'registration/game/theme': 'registration/game/theme',
41
+ 'registration/mailing': 'registration/mailing',
42
+ 'registrations': 'registrations',
43
+ 'registrations/city': 'registrations/city',
44
+ 'registrations/game': 'registrations/game',
45
+ 'registrations/game/theme': 'registrations/game/theme',
46
+ 'registrations/export': 'registrations/export',
47
+ 'role': 'role',
48
+ 'roles': 'roles',
49
+ 'theme': 'theme',
50
+ 'theme/cover': 'theme/cover',
51
+ 'themes': 'themes',
52
+ 'themes/cover': 'themes/cover',
53
+ 'timezone': 'timezone',
54
+ 'timezones': 'timezones',
55
+ 'user': 'user',
56
+ 'user/cities': 'user/cities',
57
+ 'user/city': 'user/city',
58
+ 'user/password': 'user/password',
59
+ 'user/role': 'user/role',
60
+ 'users': 'users',
61
+ 'users/cities': 'users/cities',
62
+ 'users/password': 'users/password',
63
+ 'users/role': 'users/role',
64
+ 'venue': 'venue',
65
+ 'venue/city': 'venue/city',
66
+ 'venues': 'venues',
67
+ 'venues/city': 'venues/city',
68
+ })
69
+
70
+ export const Routes = Object.freeze(Object.values(Route))
@@ -0,0 +1,107 @@
1
+ import { Route } from './route.js'
2
+ import { Service } from './service.js'
3
+
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
+ })
@@ -0,0 +1,21 @@
1
+ import { Runtime } from './runtime.js'
2
+ import { Service } from './service.js'
3
+
4
+ export const ServiceRuntime = Object.freeze({
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'],
21
+ })
@@ -0,0 +1,21 @@
1
+ export const Service = Object.freeze({
2
+ 'Users': 'Users',
3
+ 'Roles': 'Roles',
4
+ 'Checkin': 'Checkin',
5
+ 'Locations': 'Locations',
6
+ 'Cities': 'Cities',
7
+ 'Venues': 'Venues',
8
+ 'Themes': 'Themes',
9
+ 'Games': 'Games',
10
+ 'Registrations': 'Registrations',
11
+ 'Files': 'Files',
12
+ 'Procedures': 'Procedures',
13
+ 'Integrations': 'Integrations',
14
+ 'Updates': 'Updates',
15
+ 'Hub': 'Hub',
16
+ 'Landing': 'Landing',
17
+ 'Vkma': 'Vkma',
18
+ 'Minio': 'Minio',
19
+ })
20
+
21
+ export const Services = Object.freeze(Object.values(Service))
@@ -0,0 +1,14 @@
1
+ export const ThemeStatus = Object.freeze({
2
+ 'Active': 'Active',
3
+ 'Archive': 'Archive',
4
+ })
5
+
6
+ export const ThemeStatuses = Object.freeze([
7
+ 'Active',
8
+ 'Archive',
9
+ ])
10
+
11
+ export const ThemeStatusIcon = Object.freeze({
12
+ 'Active': 'hero/outline/check',
13
+ 'Archive': 'hero/outline/archive-box',
14
+ })
@@ -0,0 +1,14 @@
1
+ export const VenueAudience = Object.freeze({
2
+ 'Open': 'Open',
3
+ 'Adults': 'Adults',
4
+ })
5
+
6
+ export const VenueAudiences = Object.freeze([
7
+ 'Open',
8
+ 'Adults',
9
+ ])
10
+
11
+ export const VenueAudienceIcon = Object.freeze({
12
+ 'Open': 'hero/outline/lock-open',
13
+ 'Adults': 'hero/outline/lock-closed',
14
+ })
@@ -0,0 +1,15 @@
1
+ export const VenueStatus = Object.freeze({
2
+ 'Active': 'Active',
3
+ 'Archive': 'Archive',
4
+ })
5
+
6
+ export const VenueStatuses = Object.freeze([
7
+ 'Active',
8
+ 'Archive',
9
+ ])
10
+
11
+ /** @satisfies {Record<keyof typeof VenueStatus, string>} */
12
+ export const VenueStatusIcon = Object.freeze({
13
+ 'Active': 'hero/outline/check',
14
+ 'Archive': 'hero/outline/archive-box',
15
+ })
@@ -0,0 +1,32 @@
1
+ import { checkRoute } from '../application/route.js'
2
+ import { inferRouteParams, inferRoutePathname } from '../system/route.js'
3
+
4
+ export const hydrateRoutePathname = Object.freeze(
5
+ /**
6
+ * @template {keyof typeof import('../system/route.js').Route} RouteTemplate
7
+ *
8
+ * @param {RouteTemplate} route
9
+ * @param {any[]} params
10
+ */
11
+ (route, params) => {
12
+ if (!Array.isArray(params))
13
+ throw TypeError(`Parameter 'params' must be 'Array'.`)
14
+
15
+ var $route = checkRoute(route)
16
+
17
+ var $routePathname = inferRoutePathname($route)
18
+
19
+ if ($routePathname === 'Unknown')
20
+ throw TypeError(`Could not infer route pathname of: '${$route}'.`)
21
+
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
+ )
31
+ },
32
+ )
@@ -0,0 +1,7 @@
1
+ export const toStringTag = Object.freeze(
2
+ x => Object.prototype.toString.call(x).slice(8, -1),
3
+ )
4
+
5
+ export const isStringTag = Object.freeze(
6
+ (tag, x) => tag === Object.prototype.toString.call(x).slice(8, -1),
7
+ )
@@ -0,0 +1,37 @@
1
+ import { inferMethod } from '../system/method.js'
2
+
3
+ import { hydrateRoutePathname } from './hydrate-route-pathname.js'
4
+
5
+ export const tag = Object.freeze(
6
+ /**
7
+ * @template {keyof typeof import('../system/method.js').Method} MethodTemplate
8
+ * @template {keyof typeof import('../system/route.js').Route} RouteTemplate
9
+ * @template {typeof import('../system/route.js').RoutePathname[RouteTemplate]} RoutePathnameTemplate
10
+ *
11
+ * @param {MethodTemplate} method
12
+ * @param {RouteTemplate} route
13
+ * @param {any[]} params
14
+ *
15
+ * @returns {`${MethodTemplate}/${RoutePathnameTemplate}`}
16
+ */
17
+ (method, route, params) => {
18
+ var m = inferMethod(method)
19
+
20
+ if (m === 'Unknown')
21
+ throw TypeError(`Could not infer method of: '${method}'.`)
22
+
23
+ return m + '/' + hydrateRoutePathname(route, params)
24
+ },
25
+ )
26
+
27
+ export const tagexp = Object.freeze(
28
+ /**
29
+ * @template {keyof typeof import('../system/method.js').Method} MethodTemplate
30
+ * @template {keyof typeof import('../system/route.js').Route} RouteTemplate
31
+ *
32
+ * @param {MethodTemplate} method
33
+ * @param {RouteTemplate} route
34
+ * @param {any[]} params
35
+ */
36
+ (method, route, params) => new RegExp(`^${tag(method, route, params)}$`),
37
+ )
package/source/index.js CHANGED
@@ -1,38 +1,41 @@
1
- export * from './enumerations/blend.js'
2
- export * from './enumerations/cardinality.js'
3
- export * from './enumerations/category.js'
4
- export * from './enumerations/constants.js'
5
- export * from './enumerations/display.js'
6
- export * from './enumerations/gender.js'
7
- export * from './enumerations/icon.js'
8
- export * from './enumerations/method.js'
9
- export * from './enumerations/mode.js'
10
- export * from './enumerations/network.js'
11
- export * from './enumerations/numerosity.js'
12
- export * from './enumerations/pattern.js'
13
- export * from './enumerations/phase.js'
14
- export * from './enumerations/quantifier.js'
15
- export * from './enumerations/route.js'
16
- export * from './enumerations/runtime.js'
17
- export * from './enumerations/service.js'
18
-
19
- export * from './enumerations/entities/affilation.js'
20
- export * from './enumerations/entities/game-status.js'
21
- export * from './enumerations/entities/registration-attribute.js'
22
- export * from './enumerations/entities/registration-channel.js'
23
- export * from './enumerations/entities/registration-mailing.js'
24
- export * from './enumerations/entities/role.js'
25
- export * from './enumerations/entities/version.js'
26
-
27
- export * from './enumerations/venue/audience.js'
28
- export * from './enumerations/venue/status.js'
29
-
30
- export * from './enumerations/theme/status.js'
31
-
32
- export * from './enumerations/registration/lineup.js'
33
- export * from './enumerations/registration/status.js'
34
-
35
- export * from './functions/hydrate-route-params.js'
36
- export * from './functions/hydrate-route-pathname.js'
37
- export * from './functions/string-tag.js'
38
- export * from './functions/tag.js'
1
+ export * from './entities/blend.js'
2
+ export * from './entities/cardinality-routes.js'
3
+ export * from './entities/cardinality.js'
4
+ export * from './entities/category.js'
5
+ export * from './entities/city-affilation.js'
6
+ export * from './entities/city-chatapp-version.js'
7
+ export * from './entities/constants.js'
8
+ export * from './entities/display.js'
9
+ export * from './entities/game-status.js'
10
+ export * from './entities/gender.js'
11
+ export * from './entities/icon.js'
12
+ export * from './entities/method.js'
13
+ export * from './entities/mode.js'
14
+ export * from './entities/network.js'
15
+ export * from './entities/numerosity.js'
16
+ export * from './entities/pattern.js'
17
+ export * from './entities/phase.js'
18
+ export * from './entities/quantifier.js'
19
+ export * from './entities/registration-attribute.js'
20
+ export * from './entities/registration-channel.js'
21
+ export * from './entities/registration-lineup.js'
22
+ export * from './entities/registration-mailing.js'
23
+ export * from './entities/registration-status.js'
24
+ export * from './entities/role.js'
25
+ export * from './entities/route-cardinality-route.js'
26
+ export * from './entities/route-cardinality.js'
27
+ export * from './entities/route-pathname-params.js'
28
+ export * from './entities/route-pathname.js'
29
+ export * from './entities/route-service.js'
30
+ export * from './entities/route.js'
31
+ export * from './entities/runtime.js'
32
+ export * from './entities/service-routes.js'
33
+ export * from './entities/service-runtime.js'
34
+ export * from './entities/service.js'
35
+ export * from './entities/theme-status.js'
36
+ export * from './entities/venue-audience.js'
37
+ export * from './entities/venue-status.js'
38
+ export * from './helpers/hydrate-route-pathname.js'
39
+ export * from './helpers/string-tag.js'
40
+ export * from './helpers/tag.js'
41
+ export * from './prototypes/reflection.js'
@@ -0,0 +1,53 @@
1
+ /**
2
+ * @template {*} Value
3
+ *
4
+ * @param {Value} value
5
+ */
6
+ export function Relation(value) {
7
+ this.value = value
8
+ }
9
+
10
+ /**
11
+ * @template {*} Value
12
+ *
13
+ * @param {Value} value
14
+ */
15
+ Relation.of = function(value) {
16
+ return new Relation(value)
17
+ }
18
+
19
+ /**
20
+ * @template {keyof Value} Key
21
+ *
22
+ * @this {Relation<Value>}
23
+ *
24
+ * @param {*} key
25
+ *
26
+ * @returns {Value[Key] | 'Unknown'}
27
+ */
28
+ Relation.prototype.expect = function(key) {
29
+ if (Object.hasOwn(this.value, key))
30
+ return this.value[key]
31
+ else
32
+ return 'Unknown'
33
+ }
34
+
35
+ /**
36
+ * @template {keyof Value} Key
37
+ *
38
+ * @this {Relation<Value>}
39
+ *
40
+ * @param {*} key
41
+ *
42
+ * @returns {Value[Key]}
43
+ *
44
+ * @throws {TypeError}
45
+ */
46
+ Relation.prototype.require = function(key) {
47
+ if (Object.hasOwn(this.value, key))
48
+ return this.value[key]
49
+ else
50
+ throw TypeError(`Could not require key '${key}' from Relation '${JSON.stringify(this.value)}'.`)
51
+ }
52
+
53
+ Relation.prototype[Symbol.toStringTag] = 'Relation'
@@ -1,11 +0,0 @@
1
- export const Blend = Object.freeze({
2
- 'Unset': 'Unset',
3
- 'Domain': 'Domain',
4
- 'System': 'System',
5
- 'Indifferent': 'Indifferent',
6
- })
7
-
8
- export const inferBlend = Object.freeze(
9
- /** @returns {typeof Blend[keyof typeof Blend]} */
10
- value => Blend[value] ?? 'Unset',
11
- )
@@ -1,13 +0,0 @@
1
- export const Cardinality = Object.freeze({
2
- '1': '1',
3
- '1-1': '1-1',
4
- '1-N': '1-N',
5
- 'N': 'N',
6
- 'N-1': 'N-1',
7
- 'N-N': 'N-N',
8
- })
9
-
10
- export const inferCardinality = Object.freeze(
11
- /** @returns {keyof typeof Cardinality | 'Unknown'} */
12
- x => Cardinality[x] ?? 'Unknown',
13
- )
@@ -1,9 +0,0 @@
1
- export const Category = Object.freeze({
2
- 'Active': 'Active',
3
- 'Rest': 'Rest',
4
- })
5
-
6
- export const CategoryTitle = Object.freeze({
7
- [Category['Active']]: 'Активные',
8
- [Category['Rest']]: 'Остальное',
9
- })
@@ -1,29 +0,0 @@
1
- export const Affilation = Object.freeze({
2
- 'Branch': 'Branch',
3
- 'Franchise': 'Franchise',
4
- })
5
-
6
- /** @satisfies {Array<keyof typeof Affilation>} */
7
- export const Affilations = Object.freeze([
8
- 'Branch',
9
- 'Franchise',
10
- ])
11
-
12
- /** @satisfies {Record<keyof typeof Affilation, string>} */
13
- export const AffilationTitle = Object.freeze({
14
- 'Branch': 'Филиал',
15
- 'Franchise': 'Франшиза',
16
- })
17
-
18
- /** @satisfies {Record<keyof typeof Affilation, string>} */
19
- export const AffilationIcon = Object.freeze({
20
- 'Branch': 'hero/outline/building-office-2',
21
- 'Franchise': 'hero/outline/building-storefront',
22
- })
23
-
24
- /** @returns {keyof typeof Affilation | 'Unknown'} */
25
- export const inferAffilation = Object.freeze(value =>
26
- Affilation[value?.affilation]
27
- ?? Affilation[value]
28
- ?? 'Unknown'
29
- )