@shakerquiz/utilities 3.0.0 → 4.0.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 (116) hide show
  1. package/.github/workflows/publish.yml +32 -0
  2. package/package.json +5 -5
  3. package/scripts/route-cardinality.js +23 -0
  4. package/scripts/route-parameter.js +29 -0
  5. package/scripts/route-pathname.js +37 -0
  6. package/scripts/route-relation.js +26 -0
  7. package/scripts/route-service.js +25 -0
  8. package/scripts/templates/route-cardinality.js +5 -0
  9. package/scripts/templates/route-parameter.js +5 -0
  10. package/scripts/templates/route-pathname.js +7 -0
  11. package/scripts/templates/route-relation.js +5 -0
  12. package/scripts/templates/route-service.js +7 -0
  13. package/source/entities/blend.js +5 -0
  14. package/source/entities/cardinality.js +4 -0
  15. package/source/entities/category.js +4 -0
  16. package/source/entities/city-affilation.js +10 -0
  17. package/source/entities/city-chatapp-version.js +9 -0
  18. package/source/{enumerations/misc → entities}/constants.js +1 -1
  19. package/source/entities/display.js +4 -0
  20. package/source/entities/game-status.js +98 -0
  21. package/source/entities/gender.js +13 -0
  22. package/source/entities/icon.js +654 -0
  23. package/source/entities/key.js +41 -0
  24. package/source/{enumerations/core/methods.js → entities/method.js} +10 -4
  25. package/source/entities/mode.js +9 -0
  26. package/source/entities/network.js +9 -0
  27. package/source/entities/numerosity.js +5 -0
  28. package/source/entities/pattern.js +7 -0
  29. package/source/entities/phase.js +15 -0
  30. package/source/entities/quantifier.js +41 -0
  31. package/source/entities/registration-attribute.js +61 -0
  32. package/source/entities/registration-channel.js +11 -0
  33. package/source/entities/registration-lineup.js +14 -0
  34. package/source/entities/registration-mailing.js +20 -0
  35. package/source/entities/registration-status.js +19 -0
  36. package/source/entities/role.js +16 -0
  37. package/source/entities/route-cardinality.js +151 -0
  38. package/source/entities/route-parameter.js +151 -0
  39. package/source/entities/route-pathname.js +226 -0
  40. package/source/entities/route-relation.js +151 -0
  41. package/source/entities/route-service.js +181 -0
  42. package/source/entities/route.js +83 -0
  43. package/source/entities/runtime.js +6 -0
  44. package/source/entities/segment.js +255 -0
  45. package/source/entities/service-runtime.js +22 -0
  46. package/source/entities/service.js +22 -0
  47. package/source/entities/theme-status.js +9 -0
  48. package/source/entities/venue-audience.js +9 -0
  49. package/source/entities/venue-status.js +9 -0
  50. package/source/helpers/access.js +161 -0
  51. package/source/helpers/hydrate-route-pathname.js +29 -0
  52. package/source/helpers/tag.js +35 -0
  53. package/source/index.js +40 -34
  54. package/source/enumerations/core/features.js +0 -56
  55. package/source/enumerations/core/networks.js +0 -6
  56. package/source/enumerations/core/runtimes.js +0 -6
  57. package/source/enumerations/entities/affilation.js +0 -91
  58. package/source/enumerations/entities/cities-mode.js +0 -49
  59. package/source/enumerations/entities/city/timezone-mode.js +0 -44
  60. package/source/enumerations/entities/city/venues-mode.js +0 -60
  61. package/source/enumerations/entities/game-status.js +0 -130
  62. package/source/enumerations/entities/password-mode.js +0 -40
  63. package/source/enumerations/entities/registration-attribute.js +0 -83
  64. package/source/enumerations/entities/registration-channel.js +0 -26
  65. package/source/enumerations/entities/registration-lineup.js +0 -75
  66. package/source/enumerations/entities/registration-mailing.js +0 -24
  67. package/source/enumerations/entities/registration-status.js +0 -89
  68. package/source/enumerations/entities/role-mode.js +0 -40
  69. package/source/enumerations/entities/role.js +0 -82
  70. package/source/enumerations/entities/venue/audience.js +0 -100
  71. package/source/enumerations/entities/venue/city-mode.js +0 -44
  72. package/source/enumerations/entities/venue/status.js +0 -53
  73. package/source/enumerations/entities/version.js +0 -76
  74. package/source/enumerations/misc/icons.js +0 -655
  75. package/source/enumerations/misc/keys.js +0 -15
  76. package/source/enumerations/misc/phases.js +0 -42
  77. package/source/enumerations/misc/regexps.js +0 -5
  78. package/source/enumerations/misc/routes.js +0 -610
  79. package/source/functions/tag.d.ts +0 -1
  80. package/source/functions/tag.js +0 -5
  81. package/source/schemas/PATCH/city/admin.json +0 -126
  82. package/source/schemas/PATCH/city/currency/admin.json +0 -173
  83. package/source/schemas/PATCH/city/timezone/admin.json +0 -501
  84. package/source/schemas/PATCH/game/admin.json +0 -30
  85. package/source/schemas/PATCH/game/organizer.json +0 -30
  86. package/source/schemas/PATCH/registration/admin.json +0 -43
  87. package/source/schemas/PATCH/registration/cancellation/default.json +0 -12
  88. package/source/schemas/PATCH/registration/channel/default.json +0 -22
  89. package/source/schemas/PATCH/registration/confirmation/default.json +0 -12
  90. package/source/schemas/PATCH/registration/default.json +0 -10
  91. package/source/schemas/PATCH/registration/organizer.json +0 -43
  92. package/source/schemas/PATCH/theme/admin.json +0 -19
  93. package/source/schemas/PATCH/user/admin.json +0 -30
  94. package/source/schemas/PATCH/user/cities/admin.json +0 -17
  95. package/source/schemas/PATCH/user/password/admin.json +0 -12
  96. package/source/schemas/PATCH/user/role/admin.json +0 -13
  97. package/source/schemas/PATCH/venue/admin.json +0 -44
  98. package/source/schemas/PATCH/venue/organizer.json +0 -44
  99. package/source/schemas/POST/checkin/default.json +0 -16
  100. package/source/schemas/POST/city/admin.json +0 -696
  101. package/source/schemas/POST/game/admin.json +0 -27
  102. package/source/schemas/POST/game/organizer.json +0 -27
  103. package/source/schemas/POST/game/registrations/export/admin.json +0 -17
  104. package/source/schemas/POST/game/registrations/export/organizer.json +0 -17
  105. package/source/schemas/POST/registration/default.json +0 -125
  106. package/source/schemas/POST/registration/mailing/admin.json +0 -16
  107. package/source/schemas/POST/registration/mailing/organizer.json +0 -16
  108. package/source/schemas/POST/registrations/export/admin.json +0 -17
  109. package/source/schemas/POST/registrations/export/organizer.json +0 -17
  110. package/source/schemas/POST/theme/admin.json +0 -24
  111. package/source/schemas/POST/user/admin.json +0 -12
  112. package/source/schemas/POST/user/cities/admin.json +0 -17
  113. package/source/schemas/POST/user/password/admin.json +0 -12
  114. package/source/schemas/POST/user/role/admin.json +0 -13
  115. package/source/schemas/POST/venue/admin.json +0 -38
  116. package/source/schemas/POST/venue/organizer.json +0 -38
@@ -0,0 +1,255 @@
1
+ import { Key } from './key.js'
2
+ import { Service } from './service.js'
3
+
4
+ export const Segments = Object.freeze(
5
+ /** @type {const} */ ([
6
+ Object.freeze(
7
+ /** @type {const} */ ({
8
+ key: Key['checkin'],
9
+ cardinality: '1',
10
+ relation: undefined,
11
+ service: Service['Checkin'],
12
+ }),
13
+ ),
14
+ Object.freeze(
15
+ /** @type {const} */ ({
16
+ key: Key['user'],
17
+ cardinality: '1',
18
+ relation: Key['users'],
19
+ service: Service['Users'],
20
+ }),
21
+ ),
22
+ Object.freeze(
23
+ /** @type {const} */ ({
24
+ key: Key['users'],
25
+ cardinality: 'n',
26
+ relation: Key['user'],
27
+ service: Service['Users'],
28
+ }),
29
+ ),
30
+ Object.freeze(
31
+ /** @type {const} */ ({
32
+ key: Key['role'],
33
+ cardinality: '1',
34
+ relation: Key['roles'],
35
+ service: Service['Roles'],
36
+ }),
37
+ ),
38
+ Object.freeze(
39
+ /** @type {const} */ ({
40
+ key: Key['roles'],
41
+ cardinality: 'n',
42
+ relation: Key['role'],
43
+ service: Service['Roles'],
44
+ }),
45
+ ),
46
+ Object.freeze(
47
+ /** @type {const} */ ({
48
+ key: Key['country'],
49
+ cardinality: '1',
50
+ relation: Key['countries'],
51
+ service: Service['Locations'],
52
+ }),
53
+ ),
54
+ Object.freeze(
55
+ /** @type {const} */ ({
56
+ key: Key['countries'],
57
+ cardinality: 'n',
58
+ relation: Key['country'],
59
+ service: Service['Locations'],
60
+ }),
61
+ ),
62
+ Object.freeze(
63
+ /** @type {const} */ ({
64
+ key: Key['currency'],
65
+ cardinality: '1',
66
+ relation: Key['currencies'],
67
+ service: Service['Locations'],
68
+ }),
69
+ ),
70
+ Object.freeze(
71
+ /** @type {const} */ ({
72
+ key: Key['currencies'],
73
+ cardinality: 'n',
74
+ relation: Key['currency'],
75
+ service: Service['Locations'],
76
+ }),
77
+ ),
78
+ Object.freeze(
79
+ /** @type {const} */ ({
80
+ key: Key['timezone'],
81
+ cardinality: '1',
82
+ relation: Key['timezones'],
83
+ service: Service['Locations'],
84
+ }),
85
+ ),
86
+ Object.freeze(
87
+ /** @type {const} */ ({
88
+ key: Key['timezones'],
89
+ cardinality: 'n',
90
+ relation: Key['timezone'],
91
+ service: Service['Locations'],
92
+ }),
93
+ ),
94
+ Object.freeze(
95
+ /** @type {const} */ ({
96
+ key: Key['city'],
97
+ cardinality: '1',
98
+ relation: Key['cities'],
99
+ service: Service['Cities'],
100
+ }),
101
+ ),
102
+ Object.freeze(
103
+ /** @type {const} */ ({
104
+ key: Key['cities'],
105
+ cardinality: 'n',
106
+ relation: Key['city'],
107
+ service: Service['Cities'],
108
+ }),
109
+ ),
110
+ Object.freeze(
111
+ /** @type {const} */ ({
112
+ key: Key['venue'],
113
+ cardinality: '1',
114
+ relation: Key['venues'],
115
+ service: Service['Venues'],
116
+ }),
117
+ ),
118
+ Object.freeze(
119
+ /** @type {const} */ ({
120
+ key: Key['venues'],
121
+ cardinality: 'n',
122
+ relation: Key['venue'],
123
+ service: Service['Venues'],
124
+ }),
125
+ ),
126
+ Object.freeze(
127
+ /** @type {const} */ ({
128
+ key: Key['theme'],
129
+ cardinality: '1',
130
+ relation: Key['themes'],
131
+ service: Service['Themes'],
132
+ }),
133
+ ),
134
+ Object.freeze(
135
+ /** @type {const} */ ({
136
+ key: Key['themes'],
137
+ cardinality: 'n',
138
+ relation: Key['theme'],
139
+ service: Service['Themes'],
140
+ }),
141
+ ),
142
+ Object.freeze(
143
+ /** @type {const} */ ({
144
+ key: Key['cover'],
145
+ cardinality: '1',
146
+ relation: undefined,
147
+ service: undefined,
148
+ }),
149
+ ),
150
+ Object.freeze(
151
+ /** @type {const} */ ({
152
+ key: Key['game'],
153
+ cardinality: '1',
154
+ relation: Key['games'],
155
+ service: Service['Games'],
156
+ }),
157
+ ),
158
+ Object.freeze(
159
+ /** @type {const} */ ({
160
+ key: Key['games'],
161
+ cardinality: 'n',
162
+ relation: Key['game'],
163
+ service: Service['Games'],
164
+ }),
165
+ ),
166
+ Object.freeze(
167
+ /** @type {const} */ ({
168
+ key: Key['registration'],
169
+ cardinality: '1',
170
+ relation: Key['registrations'],
171
+ service: Service['Registrations'],
172
+ }),
173
+ ),
174
+ Object.freeze(
175
+ /** @type {const} */ ({
176
+ key: Key['registrations'],
177
+ cardinality: 'n',
178
+ relation: Key['registration'],
179
+ service: Service['Registrations'],
180
+ }),
181
+ ),
182
+ Object.freeze(
183
+ /** @type {const} */ ({
184
+ key: Key['export'],
185
+ cardinality: '1',
186
+ relation: undefined,
187
+ service: undefined,
188
+ }),
189
+ ),
190
+ Object.freeze(
191
+ /** @type {const} */ ({
192
+ key: Key['password'],
193
+ cardinality: '1',
194
+ relation: undefined,
195
+ service: undefined,
196
+ }),
197
+ ),
198
+ Object.freeze(
199
+ /** @type {const} */ ({
200
+ key: Key['vk_group_token'],
201
+ cardinality: '1',
202
+ relation: undefined,
203
+ service: undefined,
204
+ }),
205
+ ),
206
+ Object.freeze(
207
+ /** @type {const} */ ({
208
+ key: Key['summary'],
209
+ cardinality: '1',
210
+ relation: undefined,
211
+ service: undefined,
212
+ }),
213
+ ),
214
+ Object.freeze(
215
+ /** @type {const} */ ({
216
+ key: Key['mailing'],
217
+ cardinality: '1',
218
+ relation: undefined,
219
+ service: undefined,
220
+ }),
221
+ ),
222
+ Object.freeze(
223
+ /** @type {const} */ ({
224
+ key: Key['channel'],
225
+ cardinality: '1',
226
+ relation: undefined,
227
+ service: undefined,
228
+ }),
229
+ ),
230
+ Object.freeze(
231
+ /** @type {const} */ ({
232
+ key: Key['confirmation'],
233
+ cardinality: '1',
234
+ relation: undefined,
235
+ service: undefined,
236
+ }),
237
+ ),
238
+ Object.freeze(
239
+ /** @type {const} */ ({
240
+ key: Key['cancellation'],
241
+ cardinality: '1',
242
+ relation: undefined,
243
+ service: undefined,
244
+ }),
245
+ ),
246
+ ]),
247
+ )
248
+
249
+ export const Segment = Object.freeze(
250
+ /** @type {{ [x in typeof Segments[number]['key']]: Extract<typeof Segments[number], { key: x }> }} */ (Segments
251
+ .reduce(
252
+ (o, x) => (o[x.key] = x, o),
253
+ {},
254
+ )),
255
+ )
@@ -0,0 +1,22 @@
1
+ import { Runtime } from './runtime.js'
2
+ import { Service } from './service.js'
3
+
4
+ export const ServiceRuntime = Object.freeze({
5
+ [Service['Users']]: Runtime['Bun'],
6
+ [Service['Roles']]: Runtime['Bun'],
7
+ [Service['Checkin']]: Runtime['Bun'],
8
+ [Service['Locations']]: Runtime['Bun'],
9
+ [Service['Cities']]: Runtime['Bun'],
10
+ [Service['Venues']]: Runtime['Bun'],
11
+ [Service['Themes']]: Runtime['Bun'],
12
+ [Service['Games']]: Runtime['Bun'],
13
+ [Service['Registrations']]: Runtime['Bun'],
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['Telegram']]: Runtime['Node'],
21
+ [Service['Vkma']]: Runtime['Vite'],
22
+ })
@@ -0,0 +1,22 @@
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
+ 'Telegram': 'Telegram',
18
+ 'Vkma': 'Vkma',
19
+ 'Minio': 'Minio',
20
+ })
21
+
22
+ export const Services = Object.freeze(Object.values(Service))
@@ -0,0 +1,9 @@
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
+ ])
@@ -0,0 +1,9 @@
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
+ ])
@@ -0,0 +1,9 @@
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
+ ])
@@ -0,0 +1,161 @@
1
+ import { Blend } from '../entities/blend.js'
2
+ import { Cardinality } from '../entities/cardinality.js'
3
+ import { Category } from '../entities/category.js'
4
+ import { CityAffilation } from '../entities/city-affilation.js'
5
+ import { CityChatappVersion } from '../entities/city-chatapp-version.js'
6
+ import { Constants } from '../entities/constants.js'
7
+ import { Display } from '../entities/display.js'
8
+ import { GameStatus } from '../entities/game-status.js'
9
+ import { Gender } from '../entities/gender.js'
10
+ import { Icon } from '../entities/icon.js'
11
+ import { Method } from '../entities/method.js'
12
+ import { Mode } from '../entities/mode.js'
13
+ import { Network } from '../entities/network.js'
14
+ import { Numerosity } from '../entities/numerosity.js'
15
+ import { Pattern } from '../entities/pattern.js'
16
+ import { Phase } from '../entities/phase.js'
17
+ import { Quantifier } from '../entities/quantifier.js'
18
+ import { RegistrationChannel } from '../entities/registration-channel.js'
19
+ import { RegistrationLineup } from '../entities/registration-lineup.js'
20
+ import { RegistrationMailing } from '../entities/registration-mailing.js'
21
+ import { RegistrationStatus } from '../entities/registration-status.js'
22
+ import { Role } from '../entities/role.js'
23
+ import { RouteCardinality } from '../entities/route-cardinality.js'
24
+ import { RouteParameter } from '../entities/route-parameter.js'
25
+ import { RoutePathname } from '../entities/route-pathname.js'
26
+ import { RouteService, ServiceRoutes } from '../entities/route-service.js'
27
+ import { Route } from '../entities/route.js'
28
+ import { Runtime } from '../entities/runtime.js'
29
+ import { ServiceRuntime } from '../entities/service-runtime.js'
30
+ import { Service } from '../entities/service.js'
31
+ import { ThemeStatus } from '../entities/theme-status.js'
32
+ import { VenueAudience } from '../entities/venue-audience.js'
33
+ import { VenueStatus } from '../entities/venue-status.js'
34
+
35
+ const Node = new Map([
36
+ [CityAffilation, 'city'],
37
+ [CityChatappVersion, 'city'],
38
+ [GameStatus, 'game'],
39
+ [RegistrationChannel, 'registration'],
40
+ [RegistrationLineup, 'registration'],
41
+ [RegistrationMailing, 'registration'],
42
+ [RegistrationStatus, 'registration'],
43
+ [Role, 'role'],
44
+ [ThemeStatus, 'theme'],
45
+ [VenueAudience, 'venue'],
46
+ [VenueStatus, 'venue'],
47
+ ])
48
+
49
+ const Prop = new Map([
50
+ [Blend, 'blend'],
51
+ [Cardinality, 'cardinality'],
52
+ [Category, 'category'],
53
+ [CityAffilation, 'affilation'],
54
+ [CityChatappVersion, 'version'],
55
+ [Constants, 'constants'],
56
+ [Display, 'display'],
57
+ [GameStatus, 'status'],
58
+ [Gender, 'gender'],
59
+ [Icon, 'icon'],
60
+ [Method, 'method'],
61
+ [Mode, 'mode'],
62
+ [Network, 'network'],
63
+ [Numerosity, 'numerosity'],
64
+ [Pattern, 'pattern'],
65
+ [Phase, 'phase'],
66
+ [Quantifier, 'quantifier'],
67
+ [RegistrationChannel, 'channel'],
68
+ [RegistrationLineup, 'lineup'],
69
+ [RegistrationMailing, 'mailing'],
70
+ [RegistrationStatus, 'status'],
71
+ [Role, 'name'],
72
+ [RouteCardinality, 'cardinality'],
73
+ [RouteParameter, 'parameter'],
74
+ [RoutePathname, 'pathname'],
75
+ [RouteService, 'service'],
76
+ [Route, 'route'],
77
+ [Runtime, 'runtime'],
78
+ [ServiceRoutes, 'routes'],
79
+ [ServiceRuntime, 'runtime'],
80
+ [Service, 'service'],
81
+ [ThemeStatus, 'status'],
82
+ [VenueAudience, 'audience'],
83
+ [VenueStatus, 'status'],
84
+ ])
85
+
86
+ const Tag = new Map([
87
+ [Blend, 'Blend'],
88
+ [Cardinality, 'Cardinality'],
89
+ [Category, 'Category'],
90
+ [CityAffilation, 'CityAffilation'],
91
+ [CityChatappVersion, 'CityChatappVersion'],
92
+ [Constants, 'Constants'],
93
+ [Display, 'Display'],
94
+ [GameStatus, 'GameStatus'],
95
+ [Gender, 'Gender'],
96
+ [Icon, 'Icon'],
97
+ [Method, 'Method'],
98
+ [Mode, 'Mode'],
99
+ [Network, 'Network'],
100
+ [Numerosity, 'Numerosity'],
101
+ [Pattern, 'Pattern'],
102
+ [Phase, 'Phase'],
103
+ [Quantifier, 'Quantifier'],
104
+ [RegistrationChannel, 'RegistrationChannel'],
105
+ [RegistrationLineup, 'RegistrationLineup'],
106
+ [RegistrationMailing, 'RegistrationMailing'],
107
+ [RegistrationStatus, 'RegistrationStatus'],
108
+ [Role, 'Role'],
109
+ [RouteCardinality, 'RouteCardinality'],
110
+ [RouteParameter, 'RouteParameter'],
111
+ [RoutePathname, 'RoutePathname'],
112
+ [RouteService, 'RouteService'],
113
+ [Route, 'Route'],
114
+ [Runtime, 'Runtime'],
115
+ [ServiceRuntime, 'ServiceRuntime'],
116
+ [Service, 'Service'],
117
+ [ThemeStatus, 'ThemeStatus'],
118
+ [VenueAudience, 'VenueAudience'],
119
+ [VenueStatus, 'VenueStatus'],
120
+ ])
121
+
122
+ /**
123
+ * @template Relation
124
+ * @template {keyof Relation} Key
125
+ *
126
+ * @param {Relation} relation
127
+ * @param {Key} value
128
+ *
129
+ * @returns {Relation[Key]}
130
+ *
131
+ * @throws {TypeError}
132
+ */
133
+ export const access = (relation, value) => {
134
+ const node = Node.get(relation)
135
+
136
+ const prop = Prop.get(relation)
137
+
138
+ const read = value?.[node]?.[prop] ?? value?.[prop] ?? value
139
+
140
+ if (Object.hasOwn(relation, read))
141
+ return relation[read]
142
+ else
143
+ throw TypeError(`Could not require key '${value}' from '${Tag.get(relation)}'.`)
144
+ }
145
+
146
+ /**
147
+ * @template Relation
148
+ * @template {keyof Relation} Key
149
+ *
150
+ * @param {Relation} relation
151
+ * @param {Key} value
152
+ *
153
+ * @returns {Relation[Key] | 'Unknown'}
154
+ */
155
+ export const tryAccess = (relation, value) => {
156
+ try {
157
+ return access(relation, value)
158
+ } catch (error) {
159
+ return 'Unknown'
160
+ }
161
+ }
@@ -0,0 +1,29 @@
1
+ import { RouteParameter } from '../entities/route-parameter.js'
2
+ import { RoutePathname } from '../entities/route-pathname.js'
3
+ import { Route } from '../entities/route.js'
4
+
5
+ import { access } from './access.js'
6
+
7
+ export const hydrateRoutePathname = Object.freeze(
8
+ /**
9
+ * @template {keyof typeof import('../system/route.js').Route} RouteTemplate
10
+ *
11
+ * @param {RouteTemplate} maybeRoute
12
+ * @param {any[]} maybeParams
13
+ */
14
+ (maybeRoute, maybeParams) => {
15
+ if (!Array.isArray(maybeParams))
16
+ throw TypeError(`Parameter 'params' must be 'Array'.`)
17
+
18
+ var route = access(Route, maybeRoute)
19
+
20
+ var pathname = access(RoutePathname, route)
21
+
22
+ var params = access(RouteParameter, route)
23
+
24
+ return params
25
+ .split('/')
26
+ .filter(Boolean)
27
+ .reduce((pathname, param, index) => pathname.replace(param, maybeParams[index]), pathname)
28
+ },
29
+ )
@@ -0,0 +1,35 @@
1
+ import { Method } from '../entities/method.js'
2
+
3
+ import { access } from './access.js'
4
+ import { hydrateRoutePathname } from './hydrate-route-pathname.js'
5
+
6
+ export const tag = Object.freeze(
7
+ /**
8
+ * @template {keyof typeof import('../system/method.js').Method} MethodTemplate
9
+ * @template {keyof typeof import('../system/route.js').Route} RouteTemplate
10
+ * @template {typeof import('../system/route.js').RoutePathname[RouteTemplate]} RoutePathnameTemplate
11
+ *
12
+ * @param {MethodTemplate} maybeMethod
13
+ * @param {RouteTemplate} maybeRoute
14
+ * @param {any[]} maybeParams
15
+ *
16
+ * @returns {`${MethodTemplate}/${RoutePathnameTemplate}`}
17
+ */
18
+ (maybeMethod, maybeRoute, maybeParams) => {
19
+ var method = access(Method, maybeMethod)
20
+
21
+ return method + '/' + hydrateRoutePathname(maybeRoute, maybeParams)
22
+ },
23
+ )
24
+
25
+ export const tagexp = Object.freeze(
26
+ /**
27
+ * @template {keyof typeof import('../system/method.js').Method} MethodTemplate
28
+ * @template {keyof typeof import('../system/route.js').Route} RouteTemplate
29
+ *
30
+ * @param {MethodTemplate} maybeMethod
31
+ * @param {RouteTemplate} maybeRoute
32
+ * @param {any[]} maybeParams
33
+ */
34
+ (maybeMethod, maybeRoute, maybeParams) => new RegExp(`^${tag(maybeMethod, maybeRoute, maybeParams)}$`),
35
+ )
package/source/index.js CHANGED
@@ -1,34 +1,40 @@
1
- export * from './enumerations/core/features.js'
2
- export * from './enumerations/core/methods.js'
3
- export * from './enumerations/core/networks.js'
4
- export * from './enumerations/core/runtimes.js'
5
-
6
- export * from './enumerations/misc/constants.js'
7
- export * from './enumerations/misc/icons.js'
8
- export * from './enumerations/misc/keys.js'
9
- export * from './enumerations/misc/phases.js'
10
- export * from './enumerations/misc/regexps.js'
11
- export * from './enumerations/misc/routes.js'
12
-
13
- export * from './enumerations/entities/affilation.js'
14
- export * from './enumerations/entities/cities-mode.js'
15
- export * from './enumerations/entities/game-status.js'
16
- export * from './enumerations/entities/password-mode.js'
17
- export * from './enumerations/entities/registration-attribute.js'
18
- export * from './enumerations/entities/registration-channel.js'
19
- export * from './enumerations/entities/registration-lineup.js'
20
- export * from './enumerations/entities/registration-mailing.js'
21
- export * from './enumerations/entities/registration-status.js'
22
- export * from './enumerations/entities/role-mode.js'
23
- export * from './enumerations/entities/role.js'
24
-
25
- export * from './enumerations/entities/city/timezone-mode.js'
26
- export * from './enumerations/entities/city/venues-mode.js'
27
-
28
- export * from './enumerations/entities/venue/audience.js'
29
- export * from './enumerations/entities/venue/city-mode.js'
30
- export * from './enumerations/entities/venue/status.js'
31
-
32
- export * from './enumerations/entities/version.js'
33
-
34
- export * from './functions/tag.js'
1
+ export * from './entities/blend.js'
2
+ export * from './entities/cardinality.js'
3
+ export * from './entities/category.js'
4
+ export * from './entities/city-affilation.js'
5
+ export * from './entities/city-chatapp-version.js'
6
+ export * from './entities/constants.js'
7
+ export * from './entities/display.js'
8
+ export * from './entities/game-status.js'
9
+ export * from './entities/gender.js'
10
+ export * from './entities/icon.js'
11
+ export * from './entities/key.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.js'
26
+ export * from './entities/route-parameter.js'
27
+ export * from './entities/route-pathname.js'
28
+ export * from './entities/route-relation.js'
29
+ export * from './entities/route-service.js'
30
+ export * from './entities/route.js'
31
+ export * from './entities/runtime.js'
32
+ export * from './entities/segment.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/access.js'
39
+ export * from './helpers/hydrate-route-pathname.js'
40
+ export * from './helpers/tag.js'