@shakerquiz/utilities 0.6.13 → 0.6.14

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.
@@ -1,71 +1,82 @@
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/vk_group_token': 'city/vk_group_token',
13
- 'city/venue': 'city/venue',
14
- 'city/venues': 'city/venues',
15
- 'countries': 'countries',
16
- 'country': 'country',
17
- 'currencies': 'currencies',
18
- 'currency': 'currency',
19
- 'game': 'game',
20
- 'game/city': 'game/city',
21
- 'game/registration': 'game/registration',
22
- 'game/registrations': 'game/registrations',
23
- 'game/registrations/export': 'game/registrations/export',
24
- 'game/summary': 'game/summary',
25
- 'game/theme': 'game/theme',
26
- 'game/venue': 'game/venue',
27
- 'games': 'games',
28
- 'games/city': 'games/city',
29
- 'games/registrations': 'games/registrations',
30
- 'games/registrations/export': 'games/registrations/export',
31
- 'games/summary': 'games/summary',
32
- 'games/theme': 'games/theme',
33
- 'games/venue': 'games/venue',
34
- 'registration': 'registration',
35
- 'registration/cancellation': 'registration/cancellation',
36
- 'registration/channel': 'registration/channel',
37
- 'registration/confirmation': 'registration/confirmation',
38
- 'registration/export': 'registration/export',
39
- 'registration/city': 'registration/city',
40
- 'registration/game': 'registration/game',
41
- 'registration/game/theme': 'registration/game/theme',
42
- 'registration/mailing': 'registration/mailing',
43
- 'registrations': 'registrations',
44
- 'registrations/city': 'registrations/city',
45
- 'registrations/game': 'registrations/game',
46
- 'registrations/game/theme': 'registrations/game/theme',
47
- 'registrations/export': 'registrations/export',
48
- 'role': 'role',
49
- 'roles': 'roles',
50
- 'theme': 'theme',
51
- 'theme/cover': 'theme/cover',
52
- 'themes': 'themes',
53
- 'themes/cover': 'themes/cover',
54
- 'timezone': 'timezone',
55
- 'timezones': 'timezones',
56
- 'user': 'user',
57
- 'user/cities': 'user/cities',
58
- 'user/city': 'user/city',
59
- 'user/password': 'user/password',
60
- 'user/role': 'user/role',
61
- 'users': 'users',
62
- 'users/cities': 'users/cities',
63
- 'users/password': 'users/password',
64
- 'users/role': 'users/role',
65
- 'venue': 'venue',
66
- 'venue/city': 'venue/city',
67
- 'venues': 'venues',
68
- 'venues/city': 'venues/city',
69
- })
1
+ export const Routes = Object.freeze(
2
+ /** @type {const} */ ([
3
+ 'role',
4
+ 'roles',
5
+ 'user',
6
+ 'user/password',
7
+ 'user/role',
8
+ 'user/city',
9
+ 'user/cities',
10
+ 'users',
11
+ 'users/password',
12
+ 'users/role',
13
+ 'users/cities',
14
+ 'checkin',
15
+ 'cities',
16
+ 'cities/country',
17
+ 'cities/currency',
18
+ 'cities/timezone',
19
+ 'cities/venues',
20
+ 'city',
21
+ 'city/vk_group_token',
22
+ 'city/country',
23
+ 'city/currency',
24
+ 'city/timezone',
25
+ 'city/venue',
26
+ 'city/venues',
27
+ 'country',
28
+ 'countries',
29
+ 'currency',
30
+ 'currencies',
31
+ 'timezone',
32
+ 'timezones',
33
+ 'venue',
34
+ 'venue/city',
35
+ 'venues',
36
+ 'venues/city',
37
+ 'theme',
38
+ 'theme/cover',
39
+ 'themes',
40
+ 'themes/cover',
41
+ 'themes/games',
42
+ 'game',
43
+ 'game/city',
44
+ 'game/registration',
45
+ 'game/registrations',
46
+ 'game/registrations/export',
47
+ 'game/summary',
48
+ 'game/theme',
49
+ 'game/theme/cover',
50
+ 'game/venue',
51
+ 'games',
52
+ 'games/city',
53
+ 'games/registrations',
54
+ 'games/registrations/export',
55
+ 'games/summary',
56
+ 'games/theme',
57
+ 'games/theme/cover',
58
+ 'games/venue',
59
+ 'registration',
60
+ 'registration/cancellation',
61
+ 'registration/channel',
62
+ 'registration/confirmation',
63
+ 'registration/export',
64
+ 'registration/city',
65
+ 'registration/game',
66
+ 'registration/game/theme',
67
+ 'registration/game/theme/cover',
68
+ 'registration/mailing',
69
+ 'registrations',
70
+ 'registrations/city',
71
+ 'registrations/game',
72
+ 'registrations/game/theme',
73
+ 'registrations/export',
74
+ ]),
75
+ )
70
76
 
71
- export const Routes = Object.freeze(Object.values(Route))
77
+ export const Route = Object.freeze(
78
+ /** @type {{ [x in typeof Routes[number]]: x }} */ (Routes.reduce(
79
+ (o, x) => (o[x] = x, o),
80
+ {},
81
+ )),
82
+ )
@@ -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
+ )
@@ -2,15 +2,15 @@ import { Runtime } from './runtime.js'
2
2
  import { Service } from './service.js'
3
3
 
4
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'],
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
14
  [Service['Files']]: Runtime['Bun'],
15
15
  [Service['Procedures']]: Runtime['Bun'],
16
16
  [Service['Integrations']]: Runtime['Bun'],
@@ -1,5 +1,4 @@
1
1
  import { Blend } from '../entities/blend.js'
2
- import { CardinalityRoutes } from '../entities/cardinality-routes.js'
3
2
  import { Cardinality } from '../entities/cardinality.js'
4
3
  import { Category } from '../entities/category.js'
5
4
  import { CityAffilation } from '../entities/city-affilation.js'
@@ -21,21 +20,19 @@ import { RegistrationLineup } from '../entities/registration-lineup.js'
21
20
  import { RegistrationMailing } from '../entities/registration-mailing.js'
22
21
  import { RegistrationStatus } from '../entities/registration-status.js'
23
22
  import { Role } from '../entities/role.js'
24
- import { RouteCardinalityRoute } from '../entities/route-cardinality-route.js'
25
23
  import { RouteCardinality } from '../entities/route-cardinality.js'
26
- import { RoutePathnameParams } from '../entities/route-pathname-params.js'
24
+ import { RouteParameter } from '../entities/route-parameter.js'
27
25
  import { RoutePathname } from '../entities/route-pathname.js'
28
- import { RouteService } from '../entities/route-service.js'
26
+ import { RouteService, ServiceRoutes } from '../entities/route-service.js'
29
27
  import { Route } from '../entities/route.js'
30
28
  import { Runtime } from '../entities/runtime.js'
31
- import { ServiceRoutes } from '../entities/service-routes.js'
32
29
  import { ServiceRuntime } from '../entities/service-runtime.js'
33
30
  import { Service } from '../entities/service.js'
34
31
  import { ThemeStatus } from '../entities/theme-status.js'
35
32
  import { VenueAudience } from '../entities/venue-audience.js'
36
33
  import { VenueStatus } from '../entities/venue-status.js'
37
34
 
38
- const RelationNode = new Map([
35
+ const Node = new Map([
39
36
  [CityAffilation, 'city'],
40
37
  [CityChatappVersion, 'city'],
41
38
  [GameStatus, 'game'],
@@ -49,9 +46,8 @@ const RelationNode = new Map([
49
46
  [VenueStatus, 'venue'],
50
47
  ])
51
48
 
52
- const RelationProp = new Map([
49
+ const Prop = new Map([
53
50
  [Blend, 'blend'],
54
- [CardinalityRoutes, 'routes'],
55
51
  [Cardinality, 'cardinality'],
56
52
  [Category, 'category'],
57
53
  [CityAffilation, 'affilation'],
@@ -73,9 +69,8 @@ const RelationProp = new Map([
73
69
  [RegistrationMailing, 'mailing'],
74
70
  [RegistrationStatus, 'status'],
75
71
  [Role, 'name'],
76
- [RouteCardinalityRoute, 'cardinality_route'],
77
72
  [RouteCardinality, 'cardinality'],
78
- [RoutePathnameParams, 'pathname_params'],
73
+ [RouteParameter, 'parameter'],
79
74
  [RoutePathname, 'pathname'],
80
75
  [RouteService, 'service'],
81
76
  [Route, 'route'],
@@ -88,17 +83,53 @@ const RelationProp = new Map([
88
83
  [VenueStatus, 'status'],
89
84
  ])
90
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
+
91
122
  export const access = (Relation, value) => {
92
- const node = RelationNode.get(Relation)
123
+ const node = Node.get(Relation)
93
124
 
94
- const prop = RelationProp.get(Relation)
125
+ const prop = Prop.get(Relation)
95
126
 
96
127
  const read = value?.[node]?.[prop] ?? value?.[prop] ?? value
97
128
 
98
129
  if (Object.hasOwn(Relation, read))
99
130
  return Relation[read]
100
131
  else
101
- throw TypeError(`Could not require key '${value}' from Relation '${JSON.stringify(Relation)}'.`)
132
+ throw TypeError(`Could not require key '${value}' from '${Tag.get(Relation)}'.`)
102
133
  }
103
134
 
104
135
  export const tryAccess = (Relation, value) => {
package/source/index.js CHANGED
@@ -1,5 +1,4 @@
1
1
  export * from './entities/blend.js'
2
- export * from './entities/cardinality-routes.js'
3
2
  export * from './entities/cardinality.js'
4
3
  export * from './entities/category.js'
5
4
  export * from './entities/city-affilation.js'
@@ -9,6 +8,7 @@ export * from './entities/display.js'
9
8
  export * from './entities/game-status.js'
10
9
  export * from './entities/gender.js'
11
10
  export * from './entities/icon.js'
11
+ export * from './entities/key.js'
12
12
  export * from './entities/method.js'
13
13
  export * from './entities/mode.js'
14
14
  export * from './entities/network.js'
@@ -22,14 +22,13 @@ export * from './entities/registration-lineup.js'
22
22
  export * from './entities/registration-mailing.js'
23
23
  export * from './entities/registration-status.js'
24
24
  export * from './entities/role.js'
25
- export * from './entities/route-cardinality-route.js'
26
25
  export * from './entities/route-cardinality.js'
27
- export * from './entities/route-pathname-params.js'
26
+ export * from './entities/route-parameter.js'
28
27
  export * from './entities/route-pathname.js'
29
- export * from './entities/route-service.js'
28
+ export * from './entities/route-relation.js'
30
29
  export * from './entities/route.js'
31
30
  export * from './entities/runtime.js'
32
- export * from './entities/service-routes.js'
31
+ export * from './entities/segment.js'
33
32
  export * from './entities/service-runtime.js'
34
33
  export * from './entities/service.js'
35
34
  export * from './entities/theme-status.js'
@@ -1,82 +0,0 @@
1
- import { Cardinality } from './cardinality.js'
2
- import { Route } from './route.js'
3
-
4
- export const CardinalityRoutes = Object.freeze({
5
- [Cardinality['1']]: Object.freeze([
6
- Route['checkin'],
7
- Route['city'],
8
- Route['country'],
9
- Route['currency'],
10
- Route['game'],
11
- Route['game/registrations/export'],
12
- Route['games/registrations/export'],
13
- Route['registration'],
14
- Route['registration/export'],
15
- Route['registrations/export'],
16
- Route['role'],
17
- Route['theme'],
18
- Route['timezone'],
19
- Route['user'],
20
- Route['venue'],
21
- ]),
22
-
23
- [Cardinality['1-1']]: Object.freeze([
24
- Route['city/country'],
25
- Route['city/currency'],
26
- Route['city/timezone'],
27
- Route['city/venue'],
28
- Route['game/city'],
29
- Route['game/registration'],
30
- Route['game/summary'],
31
- Route['game/theme'],
32
- Route['game/venue'],
33
- Route['registration/city'],
34
- Route['registration/game/theme'],
35
- Route['theme/cover'],
36
- Route['user/city'],
37
- Route['user/password'],
38
- Route['user/role'],
39
- Route['venue/city'],
40
- ]),
41
-
42
- [Cardinality['1-N']]: Object.freeze([
43
- Route['city/venues'],
44
- Route['game/registrations'],
45
- Route['user/cities'],
46
- ]),
47
-
48
- [Cardinality['N']]: Object.freeze([
49
- Route['cities'],
50
- Route['countries'],
51
- Route['currencies'],
52
- Route['games'],
53
- Route['registrations'],
54
- Route['roles'],
55
- Route['themes'],
56
- Route['timezones'],
57
- Route['users'],
58
- Route['venues'],
59
- ]),
60
-
61
- [Cardinality['N-1']]: Object.freeze([
62
- Route['cities/country'],
63
- Route['cities/currency'],
64
- Route['cities/timezone'],
65
- Route['games/city'],
66
- Route['games/summary'],
67
- Route['games/theme'],
68
- Route['games/venue'],
69
- Route['registrations/city'],
70
- Route['registrations/game'],
71
- Route['registrations/game/theme'],
72
- Route['themes/cover'],
73
- Route['users/role'],
74
- Route['venues/city'],
75
- ]),
76
-
77
- [Cardinality['N-N']]: Object.freeze([
78
- Route['cities/venues'],
79
- Route['games/registrations'],
80
- Route['users/cities'],
81
- ]),
82
- })