@shakerquiz/utilities 0.3.45 → 0.4.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.
- package/dprint.json +2 -1
- package/package.json +3 -8
- package/source/enumerations/core/domains.d.ts +13 -0
- package/source/enumerations/core/domains.js +149 -0
- package/source/enumerations/core/features.d.ts +13 -0
- package/source/enumerations/core/features.js +29 -0
- package/source/enumerations/core/kinds.d.ts +1 -0
- package/source/enumerations/core/kinds.js +4 -0
- package/source/enumerations/core/methods.d.ts +8 -0
- package/source/enumerations/core/methods.js +25 -0
- package/source/enumerations/{procedures.d.ts → core/procedures.d.ts} +3 -6
- package/source/enumerations/core/procedures.js +45 -0
- package/source/enumerations/core/scopes.d.ts +4 -0
- package/source/enumerations/core/scopes.js +12 -0
- package/source/enumerations/entities/affilations.d.ts +1 -0
- package/source/enumerations/entities/affilations.js +4 -0
- package/source/enumerations/entities/game-statuses.d.ts +1 -0
- package/source/enumerations/entities/game-statuses.js +11 -0
- package/source/enumerations/entities/lineups.d.ts +1 -0
- package/source/enumerations/entities/lineups.js +4 -0
- package/source/enumerations/entities/registration-statuses.d.ts +1 -0
- package/source/enumerations/entities/registration-statuses.js +5 -0
- package/source/enumerations/entities/roles.d.ts +1 -0
- package/source/enumerations/entities/roles.js +4 -0
- package/source/enumerations/misc/icons.d.ts +1 -0
- package/source/enumerations/misc/icons.js +326 -0
- package/source/enumerations/misc/phases.d.ts +1 -0
- package/source/enumerations/misc/phases.js +7 -0
- package/source/enumerations/misc/requirements.d.ts +1 -0
- package/source/enumerations/misc/requirements.js +4 -0
- package/source/enumerations/schemas.d.ts +1 -1
- package/source/enumerations/schemas.js +8 -10
- package/source/functions/pathname.d.ts +1 -1
- package/source/functions/pathname.js +16 -21
- package/source/functions/request.d.ts +3 -0
- package/source/functions/request.js +81 -0
- package/source/functions/schema.js +3 -3
- package/source/globals.d.ts +38 -37
- package/source/index.d.ts +21 -25
- package/source/index.js +21 -25
- package/source/enumerations/affilations.d.ts +0 -4
- package/source/enumerations/affilations.js +0 -4
- package/source/enumerations/backends.d.ts +0 -19
- package/source/enumerations/backends.js +0 -45
- package/source/enumerations/default.d.ts +0 -1
- package/source/enumerations/default.js +0 -1
- package/source/enumerations/domains.d.ts +0 -25
- package/source/enumerations/domains.js +0 -154
- package/source/enumerations/features.d.ts +0 -48
- package/source/enumerations/features.js +0 -109
- package/source/enumerations/frontends.d.ts +0 -13
- package/source/enumerations/frontends.js +0 -41
- package/source/enumerations/game-statuses.d.ts +0 -11
- package/source/enumerations/game-statuses.js +0 -11
- package/source/enumerations/icons.d.ts +0 -326
- package/source/enumerations/icons.js +0 -326
- package/source/enumerations/kinds.d.ts +0 -4
- package/source/enumerations/kinds.js +0 -4
- package/source/enumerations/lineups.d.ts +0 -4
- package/source/enumerations/lineups.js +0 -4
- package/source/enumerations/methods.d.ts +0 -18
- package/source/enumerations/methods.js +0 -27
- package/source/enumerations/networks.d.ts +0 -4
- package/source/enumerations/networks.js +0 -4
- package/source/enumerations/pages.d.ts +0 -18
- package/source/enumerations/pages.js +0 -86
- package/source/enumerations/phases.d.ts +0 -7
- package/source/enumerations/phases.js +0 -7
- package/source/enumerations/procedures.js +0 -50
- package/source/enumerations/registration-statuses.d.ts +0 -5
- package/source/enumerations/registration-statuses.js +0 -5
- package/source/enumerations/requirements.d.ts +0 -4
- package/source/enumerations/requirements.js +0 -4
- package/source/enumerations/roles.d.ts +0 -4
- package/source/enumerations/roles.js +0 -4
- package/source/enumerations/services.d.ts +0 -22
- package/source/enumerations/services.js +0 -23
- package/source/functions/fetch.d.ts +0 -15
- package/source/functions/fetch.js +0 -138
- package/source/functions/origin.d.ts +0 -3
- package/source/functions/origin.js +0 -140
- package/source/functions/url.d.ts +0 -6
- package/source/functions/url.js +0 -45
- /package/source/enumerations/{constants.d.ts → misc/constants.d.ts} +0 -0
- /package/source/enumerations/{constants.js → misc/constants.js} +0 -0
- /package/source/enumerations/{cookies.d.ts → misc/cookies.d.ts} +0 -0
- /package/source/enumerations/{cookies.js → misc/cookies.js} +0 -0
- /package/source/enumerations/{regexps.d.ts → misc/regexps.d.ts} +0 -0
- /package/source/enumerations/{regexps.js → misc/regexps.js} +0 -0
|
@@ -0,0 +1,326 @@
|
|
|
1
|
+
export var Icons = /** @type {const} */ ([
|
|
2
|
+
'academic-cap',
|
|
3
|
+
'adjustments-horizontal',
|
|
4
|
+
'adjustments-vertical',
|
|
5
|
+
'archive-box-arrow-down',
|
|
6
|
+
'archive-box-x-mark',
|
|
7
|
+
'archive-box',
|
|
8
|
+
'arrow-down-circle',
|
|
9
|
+
'arrow-down-left',
|
|
10
|
+
'arrow-down-on-square-stack',
|
|
11
|
+
'arrow-down-on-square',
|
|
12
|
+
'arrow-down-right',
|
|
13
|
+
'arrow-down-tray',
|
|
14
|
+
'arrow-down',
|
|
15
|
+
'arrow-left-circle',
|
|
16
|
+
'arrow-left-end-on-rectangle',
|
|
17
|
+
'arrow-left-on-rectangle',
|
|
18
|
+
'arrow-left-start-on-rectangle',
|
|
19
|
+
'arrow-left',
|
|
20
|
+
'arrow-long-down',
|
|
21
|
+
'arrow-long-left',
|
|
22
|
+
'arrow-long-right',
|
|
23
|
+
'arrow-long-up',
|
|
24
|
+
'arrow-path-rounded-square',
|
|
25
|
+
'arrow-path',
|
|
26
|
+
'arrow-right-circle',
|
|
27
|
+
'arrow-right-end-on-rectangle',
|
|
28
|
+
'arrow-right-on-rectangle',
|
|
29
|
+
'arrow-right-start-on-rectangle',
|
|
30
|
+
'arrow-right',
|
|
31
|
+
'arrow-small-down',
|
|
32
|
+
'arrow-small-left',
|
|
33
|
+
'arrow-small-right',
|
|
34
|
+
'arrow-small-up',
|
|
35
|
+
'arrow-top-right-on-square',
|
|
36
|
+
'arrow-trending-down',
|
|
37
|
+
'arrow-trending-up',
|
|
38
|
+
'arrow-turn-down-left',
|
|
39
|
+
'arrow-turn-down-right',
|
|
40
|
+
'arrow-turn-left-down',
|
|
41
|
+
'arrow-turn-left-up',
|
|
42
|
+
'arrow-turn-right-down',
|
|
43
|
+
'arrow-turn-right-up',
|
|
44
|
+
'arrow-turn-up-left',
|
|
45
|
+
'arrow-turn-up-right',
|
|
46
|
+
'arrow-up-circle',
|
|
47
|
+
'arrow-up-left',
|
|
48
|
+
'arrow-up-on-square-stack',
|
|
49
|
+
'arrow-up-on-square',
|
|
50
|
+
'arrow-up-right',
|
|
51
|
+
'arrow-up-tray',
|
|
52
|
+
'arrow-up',
|
|
53
|
+
'arrow-uturn-down',
|
|
54
|
+
'arrow-uturn-left',
|
|
55
|
+
'arrow-uturn-right',
|
|
56
|
+
'arrow-uturn-up',
|
|
57
|
+
'arrows-pointing-in',
|
|
58
|
+
'arrows-pointing-out',
|
|
59
|
+
'arrows-right-left',
|
|
60
|
+
'arrows-up-down',
|
|
61
|
+
'at-symbol',
|
|
62
|
+
'backspace',
|
|
63
|
+
'backward',
|
|
64
|
+
'banknotes',
|
|
65
|
+
'bars-2',
|
|
66
|
+
'bars-3-bottom-left',
|
|
67
|
+
'bars-3-bottom-right',
|
|
68
|
+
'bars-3-center-left',
|
|
69
|
+
'bars-3',
|
|
70
|
+
'bars-4',
|
|
71
|
+
'bars-arrow-down',
|
|
72
|
+
'bars-arrow-up',
|
|
73
|
+
'battery-0',
|
|
74
|
+
'battery-100',
|
|
75
|
+
'battery-50',
|
|
76
|
+
'beaker',
|
|
77
|
+
'bell-alert',
|
|
78
|
+
'bell-slash',
|
|
79
|
+
'bell-snooze',
|
|
80
|
+
'bell',
|
|
81
|
+
'bold',
|
|
82
|
+
'bolt-slash',
|
|
83
|
+
'bolt',
|
|
84
|
+
'book-open',
|
|
85
|
+
'bookmark-slash',
|
|
86
|
+
'bookmark-square',
|
|
87
|
+
'bookmark',
|
|
88
|
+
'briefcase',
|
|
89
|
+
'bug-ant',
|
|
90
|
+
'building-library',
|
|
91
|
+
'building-office-2',
|
|
92
|
+
'building-office',
|
|
93
|
+
'building-storefront',
|
|
94
|
+
'cake',
|
|
95
|
+
'calculator',
|
|
96
|
+
'calendar-date-range',
|
|
97
|
+
'calendar-days',
|
|
98
|
+
'calendar',
|
|
99
|
+
'camera',
|
|
100
|
+
'chart-bar-square',
|
|
101
|
+
'chart-bar',
|
|
102
|
+
'chart-pie',
|
|
103
|
+
'chat-bubble-bottom-center-text',
|
|
104
|
+
'chat-bubble-bottom-center',
|
|
105
|
+
'chat-bubble-left-ellipsis',
|
|
106
|
+
'chat-bubble-left-right',
|
|
107
|
+
'chat-bubble-left',
|
|
108
|
+
'chat-bubble-oval-left-ellipsis',
|
|
109
|
+
'chat-bubble-oval-left',
|
|
110
|
+
'check-badge',
|
|
111
|
+
'check-circle',
|
|
112
|
+
'check',
|
|
113
|
+
'chevron-double-down',
|
|
114
|
+
'chevron-double-left',
|
|
115
|
+
'chevron-double-right',
|
|
116
|
+
'chevron-double-up',
|
|
117
|
+
'chevron-down',
|
|
118
|
+
'chevron-left',
|
|
119
|
+
'chevron-right',
|
|
120
|
+
'chevron-up-down',
|
|
121
|
+
'chevron-up',
|
|
122
|
+
'circle-stack',
|
|
123
|
+
'clipboard-document-check',
|
|
124
|
+
'clipboard-document-list',
|
|
125
|
+
'clipboard-document',
|
|
126
|
+
'clipboard',
|
|
127
|
+
'clock',
|
|
128
|
+
'cloud-arrow-down',
|
|
129
|
+
'cloud-arrow-up',
|
|
130
|
+
'cloud',
|
|
131
|
+
'code-bracket-square',
|
|
132
|
+
'code-bracket',
|
|
133
|
+
'cog-6-tooth',
|
|
134
|
+
'cog-8-tooth',
|
|
135
|
+
'cog',
|
|
136
|
+
'command-line',
|
|
137
|
+
'computer-desktop',
|
|
138
|
+
'cpu-chip',
|
|
139
|
+
'credit-card',
|
|
140
|
+
'cube-transparent',
|
|
141
|
+
'cube',
|
|
142
|
+
'currency-bangladeshi',
|
|
143
|
+
'currency-dollar',
|
|
144
|
+
'currency-euro',
|
|
145
|
+
'currency-pound',
|
|
146
|
+
'currency-rupee',
|
|
147
|
+
'currency-yen',
|
|
148
|
+
'cursor-arrow-rays',
|
|
149
|
+
'cursor-arrow-ripple',
|
|
150
|
+
'device-phone-mobile',
|
|
151
|
+
'device-tablet',
|
|
152
|
+
'divide',
|
|
153
|
+
'document-arrow-down',
|
|
154
|
+
'document-arrow-up',
|
|
155
|
+
'document-chart-bar',
|
|
156
|
+
'document-check',
|
|
157
|
+
'document-currency-bangladeshi',
|
|
158
|
+
'document-currency-dollar',
|
|
159
|
+
'document-currency-euro',
|
|
160
|
+
'document-currency-pound',
|
|
161
|
+
'document-currency-rupee',
|
|
162
|
+
'document-currency-yen',
|
|
163
|
+
'document-duplicate',
|
|
164
|
+
'document-magnifying-glass',
|
|
165
|
+
'document-minus',
|
|
166
|
+
'document-plus',
|
|
167
|
+
'document-text',
|
|
168
|
+
'document',
|
|
169
|
+
'ellipsis-horizontal-circle',
|
|
170
|
+
'ellipsis-horizontal',
|
|
171
|
+
'ellipsis-vertical',
|
|
172
|
+
'envelope-open',
|
|
173
|
+
'envelope',
|
|
174
|
+
'equals',
|
|
175
|
+
'exclamation-circle',
|
|
176
|
+
'exclamation-triangle',
|
|
177
|
+
'eye-dropper',
|
|
178
|
+
'eye-slash',
|
|
179
|
+
'eye',
|
|
180
|
+
'face-frown',
|
|
181
|
+
'face-smile',
|
|
182
|
+
'film',
|
|
183
|
+
'finger-print',
|
|
184
|
+
'fire',
|
|
185
|
+
'flag',
|
|
186
|
+
'folder-arrow-down',
|
|
187
|
+
'folder-minus',
|
|
188
|
+
'folder-open',
|
|
189
|
+
'folder-plus',
|
|
190
|
+
'folder',
|
|
191
|
+
'forward',
|
|
192
|
+
'funnel',
|
|
193
|
+
'gif',
|
|
194
|
+
'gift-top',
|
|
195
|
+
'gift',
|
|
196
|
+
'globe-alt',
|
|
197
|
+
'globe-americas',
|
|
198
|
+
'globe-asia-australia',
|
|
199
|
+
'globe-europe-africa',
|
|
200
|
+
'h1',
|
|
201
|
+
'h2',
|
|
202
|
+
'h3',
|
|
203
|
+
'hand-raised',
|
|
204
|
+
'hand-thumb-down',
|
|
205
|
+
'hand-thumb-up',
|
|
206
|
+
'hashtag',
|
|
207
|
+
'heart',
|
|
208
|
+
'home-modern',
|
|
209
|
+
'home',
|
|
210
|
+
'identification',
|
|
211
|
+
'inbox-arrow-down',
|
|
212
|
+
'inbox-stack',
|
|
213
|
+
'inbox',
|
|
214
|
+
'information-circle',
|
|
215
|
+
'italic',
|
|
216
|
+
'key',
|
|
217
|
+
'language',
|
|
218
|
+
'lifebuoy',
|
|
219
|
+
'light-bulb',
|
|
220
|
+
'link-slash',
|
|
221
|
+
'link',
|
|
222
|
+
'list-bullet',
|
|
223
|
+
'lock-closed',
|
|
224
|
+
'lock-open',
|
|
225
|
+
'magnifying-glass-circle',
|
|
226
|
+
'magnifying-glass-minus',
|
|
227
|
+
'magnifying-glass-plus',
|
|
228
|
+
'magnifying-glass',
|
|
229
|
+
'map-pin',
|
|
230
|
+
'map',
|
|
231
|
+
'megaphone',
|
|
232
|
+
'microphone',
|
|
233
|
+
'minus-circle',
|
|
234
|
+
'minus-small',
|
|
235
|
+
'minus',
|
|
236
|
+
'moon',
|
|
237
|
+
'musical-note',
|
|
238
|
+
'newspaper',
|
|
239
|
+
'no-symbol',
|
|
240
|
+
'numbered-list',
|
|
241
|
+
'paint-brush',
|
|
242
|
+
'paper-airplane',
|
|
243
|
+
'paper-clip',
|
|
244
|
+
'pause-circle',
|
|
245
|
+
'pause',
|
|
246
|
+
'pencil-square',
|
|
247
|
+
'pencil',
|
|
248
|
+
'percent-badge',
|
|
249
|
+
'phone-arrow-down-left',
|
|
250
|
+
'phone-arrow-up-right',
|
|
251
|
+
'phone-x-mark',
|
|
252
|
+
'phone',
|
|
253
|
+
'photo',
|
|
254
|
+
'play-circle',
|
|
255
|
+
'play-pause',
|
|
256
|
+
'play',
|
|
257
|
+
'plus-circle',
|
|
258
|
+
'plus-small',
|
|
259
|
+
'plus',
|
|
260
|
+
'power',
|
|
261
|
+
'presentation-chart-bar',
|
|
262
|
+
'presentation-chart-line',
|
|
263
|
+
'printer',
|
|
264
|
+
'puzzle-piece',
|
|
265
|
+
'qr-code',
|
|
266
|
+
'question-mark-circle',
|
|
267
|
+
'queue-list',
|
|
268
|
+
'radio',
|
|
269
|
+
'receipt-percent',
|
|
270
|
+
'receipt-refund',
|
|
271
|
+
'rectangle-group',
|
|
272
|
+
'rectangle-stack',
|
|
273
|
+
'rocket-launch',
|
|
274
|
+
'rss',
|
|
275
|
+
'scale',
|
|
276
|
+
'scissors',
|
|
277
|
+
'server-stack',
|
|
278
|
+
'server',
|
|
279
|
+
'share',
|
|
280
|
+
'shield-check',
|
|
281
|
+
'shield-exclamation',
|
|
282
|
+
'shopping-bag',
|
|
283
|
+
'shopping-cart',
|
|
284
|
+
'signal-slash',
|
|
285
|
+
'signal',
|
|
286
|
+
'slash',
|
|
287
|
+
'sparkles',
|
|
288
|
+
'speaker-wave',
|
|
289
|
+
'speaker-x-mark',
|
|
290
|
+
'square-2-stack',
|
|
291
|
+
'square-3-stack-3d',
|
|
292
|
+
'squares-2x2',
|
|
293
|
+
'squares-plus',
|
|
294
|
+
'star',
|
|
295
|
+
'stop-circle',
|
|
296
|
+
'stop',
|
|
297
|
+
'strikethrough',
|
|
298
|
+
'sun',
|
|
299
|
+
'swatch',
|
|
300
|
+
'table-cells',
|
|
301
|
+
'tag',
|
|
302
|
+
'ticket',
|
|
303
|
+
'trash',
|
|
304
|
+
'trophy',
|
|
305
|
+
'truck',
|
|
306
|
+
'tv',
|
|
307
|
+
'underline',
|
|
308
|
+
'user-circle',
|
|
309
|
+
'user-group',
|
|
310
|
+
'user-minus',
|
|
311
|
+
'user-plus',
|
|
312
|
+
'user',
|
|
313
|
+
'users',
|
|
314
|
+
'variable',
|
|
315
|
+
'video-camera-slash',
|
|
316
|
+
'video-camera',
|
|
317
|
+
'view-columns',
|
|
318
|
+
'viewfinder-circle',
|
|
319
|
+
'wallet',
|
|
320
|
+
'wifi',
|
|
321
|
+
'window',
|
|
322
|
+
'wrench-screwdriver',
|
|
323
|
+
'wrench',
|
|
324
|
+
'x-circle',
|
|
325
|
+
'x-mark',
|
|
326
|
+
])
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export const Phases: readonly ["Aborted", "Failed", "Idle", "Loaded", "Loading"];
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export const Requirements: readonly ["Checkin", "Body"];
|
|
@@ -1,5 +1,3 @@
|
|
|
1
|
-
import { Domains } from '../enumerations/domains.js'
|
|
2
|
-
|
|
3
1
|
import { CitySchema } from '../schemas/city.js'
|
|
4
2
|
import { GameSchema } from '../schemas/game.js'
|
|
5
3
|
import { RegistrationSchema } from '../schemas/registration.js'
|
|
@@ -8,12 +6,12 @@ import { ThemeSchema } from '../schemas/theme.js'
|
|
|
8
6
|
import { UserSchema } from '../schemas/user.js'
|
|
9
7
|
import { VenueSchema } from '../schemas/venue.js'
|
|
10
8
|
|
|
11
|
-
export var
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
|
|
9
|
+
export var DomainSchema = /** @type {const} */ ({
|
|
10
|
+
'User': UserSchema,
|
|
11
|
+
'Role': RoleSchema,
|
|
12
|
+
'City': CitySchema,
|
|
13
|
+
'Venue': VenueSchema,
|
|
14
|
+
'Theme': ThemeSchema,
|
|
15
|
+
'Game': GameSchema,
|
|
16
|
+
'Registration': RegistrationSchema,
|
|
19
17
|
})
|
|
@@ -1 +1 @@
|
|
|
1
|
-
export function
|
|
1
|
+
export function scopePathname(scope: Scope): string;
|
|
@@ -1,40 +1,35 @@
|
|
|
1
1
|
import { is } from '@yurkimus/types'
|
|
2
2
|
|
|
3
|
-
import {
|
|
4
|
-
import {
|
|
3
|
+
import { FeatureKindPathname } from '../enumerations/core/features.js'
|
|
4
|
+
import { Scopes } from '../enumerations/core/scopes.js'
|
|
5
5
|
|
|
6
6
|
/**
|
|
7
|
-
* @param {
|
|
8
|
-
* @param {Kind} [kind]
|
|
7
|
+
* @param {Scope} scope
|
|
9
8
|
*/
|
|
10
|
-
export var
|
|
11
|
-
|
|
12
|
-
kind = Kinds.Unit,
|
|
13
|
-
) => {
|
|
14
|
-
if (!(feature in Features))
|
|
9
|
+
export var scopePathname = scope => {
|
|
10
|
+
if (!Scopes.includes(scope))
|
|
15
11
|
throw TypeError(
|
|
16
|
-
`[
|
|
12
|
+
`[scopePathname] Unknown scope '${scope}': not present in 'Scopes'.`,
|
|
17
13
|
)
|
|
18
14
|
|
|
19
|
-
|
|
20
|
-
throw TypeError(
|
|
21
|
-
`[getFeaturePathname] Parameter 'kind' must be a member of 'Kinds'.`,
|
|
22
|
-
)
|
|
15
|
+
var [method, feature, kind] = scope.split('/')
|
|
23
16
|
|
|
24
|
-
if (!(feature in
|
|
17
|
+
if (!(feature in FeatureKindPathname))
|
|
25
18
|
throw TypeError(
|
|
26
|
-
`[
|
|
19
|
+
`[scopePathname] Feature '${feature}' is not defined in 'FeatureKindPathname'.`,
|
|
27
20
|
)
|
|
28
21
|
|
|
29
|
-
if (!(kind in
|
|
22
|
+
if (!(kind in FeatureKindPathname[feature]))
|
|
30
23
|
throw TypeError(
|
|
31
|
-
`[
|
|
24
|
+
`[scopePathname] Kind '${kind}' is not defined under Feature '${feature}' in 'FeatureKindPathname'.`,
|
|
32
25
|
)
|
|
33
26
|
|
|
34
|
-
if (!is('String',
|
|
27
|
+
if (!is('String', FeatureKindPathname[feature][kind]))
|
|
35
28
|
throw TypeError(
|
|
36
|
-
`[
|
|
29
|
+
`[scopePathname] Invalid value at FeatureKindPathname['${feature}']['${kind}']: expected a string, got '${typeof FeatureKindPathname[
|
|
30
|
+
feature
|
|
31
|
+
][kind]}'.`,
|
|
37
32
|
)
|
|
38
33
|
|
|
39
|
-
return
|
|
34
|
+
return FeatureKindPathname[feature][kind]
|
|
40
35
|
}
|
|
@@ -0,0 +1,81 @@
|
|
|
1
|
+
import { Methods } from '../enumerations/core/methods.js'
|
|
2
|
+
import { Scopes } from '../enumerations/core/scopes.js'
|
|
3
|
+
|
|
4
|
+
/**
|
|
5
|
+
* @param {Response} response
|
|
6
|
+
*/
|
|
7
|
+
export var parseResponse = response => {
|
|
8
|
+
let mime = response.headers.get('Content-Type') ?? ''
|
|
9
|
+
|
|
10
|
+
if (mime.includes('application/json'))
|
|
11
|
+
return Promise.all([
|
|
12
|
+
response,
|
|
13
|
+
response.json(),
|
|
14
|
+
])
|
|
15
|
+
else if (mime.includes('multipart/form-data'))
|
|
16
|
+
return Promise.all([
|
|
17
|
+
response,
|
|
18
|
+
response.formData(),
|
|
19
|
+
])
|
|
20
|
+
else
|
|
21
|
+
return Promise.all([
|
|
22
|
+
response,
|
|
23
|
+
response.text(),
|
|
24
|
+
])
|
|
25
|
+
}
|
|
26
|
+
|
|
27
|
+
/**
|
|
28
|
+
* @param {Scope} scope
|
|
29
|
+
* @param {[Response, any]} param1
|
|
30
|
+
*/
|
|
31
|
+
export var resolveResponse = (scope, [response, value]) => {
|
|
32
|
+
let [method, feature, kind] = scope.split('/')
|
|
33
|
+
|
|
34
|
+
if (response.ok) {
|
|
35
|
+
switch (response.status) {
|
|
36
|
+
case 204:
|
|
37
|
+
switch (kind) {
|
|
38
|
+
case 'Unit':
|
|
39
|
+
return null
|
|
40
|
+
|
|
41
|
+
case 'Set':
|
|
42
|
+
return []
|
|
43
|
+
}
|
|
44
|
+
|
|
45
|
+
default:
|
|
46
|
+
return value
|
|
47
|
+
}
|
|
48
|
+
} else
|
|
49
|
+
throw value
|
|
50
|
+
}
|
|
51
|
+
|
|
52
|
+
/**
|
|
53
|
+
* @template R
|
|
54
|
+
*
|
|
55
|
+
* @param {Scope} scope
|
|
56
|
+
* @param {RequestInfo} input
|
|
57
|
+
* @param {RequestInit} init
|
|
58
|
+
*
|
|
59
|
+
* @returns {Promise<R>}
|
|
60
|
+
*/
|
|
61
|
+
export var scopeRequest = (scope, input, init) => {
|
|
62
|
+
if (!Scopes.includes(scope))
|
|
63
|
+
throw TypeError(
|
|
64
|
+
`Parameter 'scope' must be listed in 'Scopes'.`,
|
|
65
|
+
)
|
|
66
|
+
|
|
67
|
+
let [method, feature, kind] = scope.split('/')
|
|
68
|
+
|
|
69
|
+
if (!('method' in init))
|
|
70
|
+
init.method = method
|
|
71
|
+
|
|
72
|
+
if (!Methods.includes(init.method))
|
|
73
|
+
throw TypeError(
|
|
74
|
+
`[featureFetch] Method '${init.method}' is not listed in 'Methods'.`,
|
|
75
|
+
)
|
|
76
|
+
|
|
77
|
+
return globalThis
|
|
78
|
+
.fetch(input, init)
|
|
79
|
+
.then(parseResponse)
|
|
80
|
+
.then(resolveResponse.bind(null, scope))
|
|
81
|
+
}
|
|
@@ -1,16 +1,16 @@
|
|
|
1
|
-
import {
|
|
1
|
+
import { DomainSchema } from '../enumerations/schemas.js'
|
|
2
2
|
|
|
3
3
|
/**
|
|
4
4
|
* @param {Feature} feature
|
|
5
5
|
* @param {*} object
|
|
6
6
|
*/
|
|
7
7
|
export function validateSchema(feature, object) {
|
|
8
|
-
if (!(feature in
|
|
8
|
+
if (!(feature in DomainSchema))
|
|
9
9
|
throw TypeError(
|
|
10
10
|
`[validateSchema] Parameter 'feature' '${feature}' must be a member of 'Schemas'.`,
|
|
11
11
|
)
|
|
12
12
|
|
|
13
|
-
let schema =
|
|
13
|
+
let schema = DomainSchema[feature]
|
|
14
14
|
|
|
15
15
|
for (let property in object)
|
|
16
16
|
if (!(property in schema))
|
package/source/globals.d.ts
CHANGED
|
@@ -7,14 +7,6 @@ interface RequestInit {
|
|
|
7
7
|
* @description A method string defined by RFC7231 @see {@link https://datatracker.ietf.org/doc/html/rfc7231#section-4.3}
|
|
8
8
|
*/
|
|
9
9
|
method?: Method
|
|
10
|
-
/**
|
|
11
|
-
* @description Target network to where send the request
|
|
12
|
-
*/
|
|
13
|
-
network?: Network
|
|
14
|
-
/**
|
|
15
|
-
* @description A string to declaratively set the Authorization header.
|
|
16
|
-
*/
|
|
17
|
-
cookie?: string
|
|
18
10
|
}
|
|
19
11
|
|
|
20
12
|
/**
|
|
@@ -27,60 +19,69 @@ type UseState<Type> = [
|
|
|
27
19
|
]
|
|
28
20
|
|
|
29
21
|
/**
|
|
30
|
-
*
|
|
22
|
+
* Core
|
|
31
23
|
*/
|
|
32
24
|
|
|
33
|
-
type Method =
|
|
25
|
+
type Method = typeof import('./enumerations/core/methods.js').Methods[number]
|
|
34
26
|
|
|
35
|
-
type
|
|
27
|
+
type Domain = typeof import('./enumerations/core/domains.js').Domains[number]
|
|
36
28
|
|
|
37
|
-
type
|
|
29
|
+
type Procedure =
|
|
30
|
+
typeof import('./enumerations/core/procedures.js').Procedures[number]
|
|
38
31
|
|
|
39
|
-
type
|
|
32
|
+
type Feature = Domain | Procedure
|
|
40
33
|
|
|
41
|
-
type
|
|
42
|
-
keyof typeof import('./enumerations/requirements.d.ts').Requirements
|
|
43
|
-
|
|
44
|
-
/**
|
|
45
|
-
* Domain
|
|
46
|
-
*/
|
|
34
|
+
type Kind = typeof import('./enumerations/core/kinds.js').Kinds[number]
|
|
47
35
|
|
|
48
|
-
type
|
|
49
|
-
type Page = keyof typeof import('./enumerations/pages.js').Pages
|
|
50
|
-
type Procedure = keyof typeof import('./enumerations/procedures.js').Procedures
|
|
51
|
-
type Feature = Domain | Page | Procedure
|
|
36
|
+
type Scope = `${Method}/${Feature}/${Kind}`
|
|
52
37
|
|
|
53
|
-
type
|
|
54
|
-
|
|
55
|
-
type Service = Backend | Frontend
|
|
38
|
+
type Requirement =
|
|
39
|
+
typeof import('./enumerations/misc/requirements.js').Requirements[number]
|
|
56
40
|
|
|
57
|
-
type Role = keyof typeof import('./enumerations/roles.js').Roles
|
|
41
|
+
type Role = keyof typeof import('./enumerations/entities/roles.js').Roles
|
|
58
42
|
|
|
59
43
|
type GameStatus =
|
|
60
|
-
keyof typeof import('./enumerations/game-statuses.js').GameStatuses
|
|
44
|
+
keyof typeof import('./enumerations/entities/game-statuses.js').GameStatuses
|
|
61
45
|
|
|
62
46
|
type RegistrationStatus =
|
|
63
|
-
keyof typeof import('./enumerations/registration-statuses.js').RegistrationStatuses
|
|
47
|
+
keyof typeof import('./enumerations/entities/registration-statuses.js').RegistrationStatuses
|
|
64
48
|
|
|
65
|
-
type Lineup = keyof typeof import('./enumerations/lineups.js').Lineups
|
|
49
|
+
type Lineup = keyof typeof import('./enumerations/entities/lineups.js').Lineups
|
|
66
50
|
|
|
67
51
|
type Affilation =
|
|
68
|
-
keyof typeof import('./enumerations/affilations.js').Affilations
|
|
52
|
+
keyof typeof import('./enumerations/entities/affilations.js').Affilations
|
|
53
|
+
|
|
54
|
+
/**
|
|
55
|
+
* Misc
|
|
56
|
+
*/
|
|
57
|
+
|
|
58
|
+
type Icon = typeof import('./enumerations/misc/icons.js').Icons[number]
|
|
59
|
+
|
|
60
|
+
type Phase = typeof import('./enumerations/misc/phases.js').Phases[number]
|
|
61
|
+
|
|
62
|
+
/**
|
|
63
|
+
* Products
|
|
64
|
+
*/
|
|
65
|
+
|
|
66
|
+
type ScopePhase = Record<Scope, Phase>
|
|
67
|
+
|
|
68
|
+
type ScopeState = Record<Scope, any>
|
|
69
|
+
|
|
70
|
+
type ScopeController = Record<Scope, AbortController | null>
|
|
69
71
|
|
|
70
72
|
/**
|
|
71
73
|
* Schemas
|
|
72
74
|
*/
|
|
73
75
|
|
|
74
76
|
type CityColumn = keyof typeof import('./schemas/city.js').CityColumns
|
|
77
|
+
|
|
75
78
|
type GameColumn = keyof typeof import('./schemas/game.js').GameColumns
|
|
79
|
+
|
|
76
80
|
type RegistrationColumn =
|
|
77
81
|
keyof typeof import('./schemas/registration.js').RegistrationColumns
|
|
82
|
+
|
|
78
83
|
type ThemeColumn = keyof typeof import('./schemas/theme.js').ThemeColumns
|
|
79
|
-
type UserColumn = keyof typeof import('./schemas/user.js').UserColumns
|
|
80
|
-
type VenueColumn = keyof typeof import('./schemas/venue.js').VenueColumns
|
|
81
84
|
|
|
82
|
-
|
|
83
|
-
* Misc
|
|
84
|
-
*/
|
|
85
|
+
type UserColumn = keyof typeof import('./schemas/user.js').UserColumns
|
|
85
86
|
|
|
86
|
-
type
|
|
87
|
+
type VenueColumn = keyof typeof import('./schemas/venue.js').VenueColumns
|