@shakerquiz/utilities 1.0.0 → 2.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.
- package/.github/workflows/publish.yml +32 -0
- package/dprint.json +3 -8
- package/jsconfig.json +13 -6
- package/package.json +16 -9
- package/source/enumerations/core/features.d.ts +40 -0
- package/source/enumerations/core/features.js +205 -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/core/networks.d.ts +1 -0
- package/source/enumerations/core/networks.js +4 -0
- package/source/enumerations/core/runtimes.d.ts +1 -0
- package/source/enumerations/core/runtimes.js +4 -0
- package/source/enumerations/core/scopes.d.ts +5 -0
- package/source/enumerations/core/scopes.js +27 -0
- package/source/enumerations/entities/city-affilations.d.ts +1 -0
- package/source/enumerations/entities/city-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/registration-attributes.d.ts +2 -0
- package/source/enumerations/entities/registration-attributes.js +57 -0
- package/source/enumerations/entities/registration-channels.d.ts +1 -0
- package/source/enumerations/entities/registration-channels.js +5 -0
- package/source/enumerations/entities/registration-lineups.d.ts +5 -0
- package/source/enumerations/entities/registration-lineups.js +43 -0
- package/source/enumerations/entities/registration-mailings.d.ts +1 -0
- package/source/enumerations/entities/registration-mailings.js +6 -0
- package/source/enumerations/entities/registration-statuses.d.ts +5 -0
- package/source/enumerations/entities/registration-statuses.js +54 -0
- package/source/enumerations/entities/roles.d.ts +1 -0
- package/source/enumerations/entities/roles.js +5 -0
- package/source/enumerations/entities/venue-statuses.d.ts +1 -0
- package/source/enumerations/entities/venue-statuses.js +4 -0
- package/source/enumerations/misc/constants.d.ts +3 -0
- package/source/enumerations/{constants.js → misc/constants.js} +2 -2
- package/source/enumerations/misc/cookies.d.ts +5 -0
- package/source/enumerations/{cookies.js → misc/cookies.js} +2 -2
- 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/regexps.d.ts +5 -0
- package/source/enumerations/{regexps.js → misc/regexps.js} +2 -2
- package/source/functions/tag.d.ts +1 -0
- package/source/functions/tag.js +5 -0
- package/source/index.d.ts +26 -14
- package/source/index.js +24 -11
- package/source/misc.d.ts +79 -0
- package/source/schemas/PATCH/Game/admin/schema.json +34 -0
- package/source/schemas/PATCH/Game/default/schema.json +6 -0
- package/source/schemas/PATCH/Game/organizer/schema.json +34 -0
- package/source/schemas/PATCH/Registration/admin/schema.json +6 -0
- package/source/schemas/PATCH/Registration/default/schema.json +104 -0
- package/source/schemas/PATCH/Registration/organizer/schema.json +43 -0
- package/source/schemas/PATCH/Venue/admin/schema.json +40 -0
- package/source/schemas/PATCH/Venue/default/schema.json +6 -0
- package/source/schemas/PATCH/Venue/organizer/schema.json +43 -0
- package/source/schemas/POST/Game/admin/schema.json +27 -0
- package/source/schemas/POST/Game/default/schema.json +27 -0
- package/source/schemas/POST/Game/organizer/schema.json +27 -0
- package/source/schemas/POST/Mailing/admin/schema.json +6 -0
- package/source/schemas/POST/Mailing/default/schema.json +6 -0
- package/source/schemas/POST/Mailing/organizer/schema.json +12 -0
- package/source/schemas/POST/Registration/admin/schema.json +6 -0
- package/source/schemas/POST/Registration/default/schema.json +125 -0
- package/source/schemas/POST/Registration/organizer/schema.json +6 -0
- package/source/schemas/POST/Venue/admin/schema.json +6 -0
- package/source/schemas/POST/Venue/default/schema.json +6 -0
- package/source/schemas/POST/Venue/organizer/schema.json +49 -0
- package/source/schemas/game.schema.json +93 -0
- package/source/schemas/registration.schema.json +123 -0
- package/source/schemas/theme.schema.json +48 -0
- package/source/schemas/venue.schema.json +56 -0
- package/source/scope.d.ts +874 -0
- package/source/server.d.ts +5 -0
- package/source/tables.d.ts +187 -0
- package/source/enumerations/constants.d.ts +0 -3
- package/source/enumerations/cookies.d.ts +0 -5
- package/source/enumerations/features.d.ts +0 -58
- package/source/enumerations/features.js +0 -49
- package/source/enumerations/game-statuses.d.ts +0 -39
- package/source/enumerations/game-statuses.js +0 -39
- package/source/enumerations/kinds.d.ts +0 -4
- package/source/enumerations/kinds.js +0 -4
- package/source/enumerations/methods.d.ts +0 -7
- package/source/enumerations/methods.js +0 -7
- package/source/enumerations/networks.d.ts +0 -4
- package/source/enumerations/networks.js +0 -4
- package/source/enumerations/phases.d.ts +0 -7
- package/source/enumerations/phases.js +0 -7
- package/source/enumerations/regexps.d.ts +0 -4
- package/source/enumerations/roles.d.ts +0 -5
- package/source/enumerations/roles.js +0 -5
- package/source/functions/request.d.ts +0 -131
- package/source/functions/request.js +0 -202
- package/source/globals.d.ts +0 -14
- package/source/results.d.ts +0 -137
- package/source/rows.d.ts +0 -533
|
@@ -1,202 +0,0 @@
|
|
|
1
|
-
import * as cookies from '@yurkimus/cookies'
|
|
2
|
-
import { MessageError } from '@yurkimus/errors'
|
|
3
|
-
import * as message from '@yurkimus/message'
|
|
4
|
-
import { ResponseStatus } from '@yurkimus/response-status'
|
|
5
|
-
|
|
6
|
-
import {
|
|
7
|
-
FeatureKinds,
|
|
8
|
-
FeatureRequests,
|
|
9
|
-
FeatureUrls,
|
|
10
|
-
} from '../enumerations/features.js'
|
|
11
|
-
import { Kinds } from '../enumerations/kinds.js'
|
|
12
|
-
|
|
13
|
-
let handleMessage = (feature, [response, body]) => {
|
|
14
|
-
switch (response.status) {
|
|
15
|
-
case 200:
|
|
16
|
-
case 201:
|
|
17
|
-
return body
|
|
18
|
-
|
|
19
|
-
case 204:
|
|
20
|
-
switch (FeatureKinds[feature]) {
|
|
21
|
-
case Kinds.Item:
|
|
22
|
-
return null
|
|
23
|
-
|
|
24
|
-
case Kinds.List:
|
|
25
|
-
return []
|
|
26
|
-
}
|
|
27
|
-
|
|
28
|
-
case 400:
|
|
29
|
-
case 401:
|
|
30
|
-
case 403:
|
|
31
|
-
case 404:
|
|
32
|
-
case 409:
|
|
33
|
-
case 415:
|
|
34
|
-
case 500:
|
|
35
|
-
case 502:
|
|
36
|
-
throw MessageError(
|
|
37
|
-
body.message,
|
|
38
|
-
ResponseStatus(response.status),
|
|
39
|
-
)
|
|
40
|
-
|
|
41
|
-
default:
|
|
42
|
-
throw body
|
|
43
|
-
}
|
|
44
|
-
}
|
|
45
|
-
|
|
46
|
-
/**
|
|
47
|
-
* @template {FeaturesUnion} Feature
|
|
48
|
-
* @template {MethodsUnion} Method
|
|
49
|
-
* @template {NetworksUnion} Network
|
|
50
|
-
*
|
|
51
|
-
* @param {Feature} feature
|
|
52
|
-
* @param {Method} method
|
|
53
|
-
* @param {Network} network
|
|
54
|
-
* @param {import('@yurkimus/url').URLOptions | undefined} options
|
|
55
|
-
* @param {RequestInit} init
|
|
56
|
-
*/
|
|
57
|
-
let makeRequest = (feature, method, network, options, init) => {
|
|
58
|
-
if (!('method' in init))
|
|
59
|
-
init.method = method
|
|
60
|
-
|
|
61
|
-
let url = FeatureUrls
|
|
62
|
-
.get(feature)
|
|
63
|
-
.get(network)
|
|
64
|
-
|
|
65
|
-
let request = new Request(url(options), init)
|
|
66
|
-
|
|
67
|
-
if (!request.headers.has('Content-Type'))
|
|
68
|
-
request.headers.set(
|
|
69
|
-
'Content-Type',
|
|
70
|
-
'application/json',
|
|
71
|
-
)
|
|
72
|
-
|
|
73
|
-
if ('cookie' in init)
|
|
74
|
-
request.headers.set(
|
|
75
|
-
'Authorization',
|
|
76
|
-
cookies.read('shaker-quiz-token', init.cookie),
|
|
77
|
-
)
|
|
78
|
-
|
|
79
|
-
return fetch(request)
|
|
80
|
-
.then(message.read)
|
|
81
|
-
.then(handleMessage.bind(undefined, feature))
|
|
82
|
-
}
|
|
83
|
-
|
|
84
|
-
/**
|
|
85
|
-
* @type {WeakMap<Function, Map<'onbefore' | 'onfulfilled' | 'onrejected', Set<Function>>>}
|
|
86
|
-
*/
|
|
87
|
-
export let Extensions = new WeakMap()
|
|
88
|
-
|
|
89
|
-
/**
|
|
90
|
-
* @template {FeaturesUnion} Feature
|
|
91
|
-
* @template {MethodsUnion} Method
|
|
92
|
-
* @template {NetworksUnion} Network
|
|
93
|
-
*
|
|
94
|
-
* @param {Feature} feature
|
|
95
|
-
* @param {Method} method
|
|
96
|
-
* @param {Network} network
|
|
97
|
-
*/
|
|
98
|
-
export let useRequest = (feature, method, network) => {
|
|
99
|
-
if (
|
|
100
|
-
!FeatureRequests
|
|
101
|
-
.has(feature)
|
|
102
|
-
)
|
|
103
|
-
throw TypeError(`Feature '${feature}' must be listed in 'FeatureRequests'.`)
|
|
104
|
-
|
|
105
|
-
if (
|
|
106
|
-
!FeatureRequests
|
|
107
|
-
.get(feature)
|
|
108
|
-
.has(method)
|
|
109
|
-
)
|
|
110
|
-
throw TypeError(`Method '${method}' must be listed in 'FeatureRequests'.`)
|
|
111
|
-
|
|
112
|
-
if (
|
|
113
|
-
!FeatureUrls
|
|
114
|
-
.has(feature)
|
|
115
|
-
)
|
|
116
|
-
throw TypeError(`Feature '${feature}' must be listed in 'FeatureUrls'.`)
|
|
117
|
-
|
|
118
|
-
if (
|
|
119
|
-
!FeatureUrls
|
|
120
|
-
.get(feature)
|
|
121
|
-
.has(network)
|
|
122
|
-
)
|
|
123
|
-
throw TypeError(`Network '${network}' must be listed in 'FeatureUrls'.`)
|
|
124
|
-
|
|
125
|
-
/**
|
|
126
|
-
* @param {import('@yurkimus/url').URLOptions} options
|
|
127
|
-
* @param {RequestInit} init
|
|
128
|
-
*/
|
|
129
|
-
let request = (options, init) => {
|
|
130
|
-
let onbefore = parameters => {
|
|
131
|
-
let predicates = Extensions
|
|
132
|
-
.get(request)
|
|
133
|
-
.get('onbefore')
|
|
134
|
-
|
|
135
|
-
return (predicates.size > 0)
|
|
136
|
-
? Array
|
|
137
|
-
.from(predicates)
|
|
138
|
-
.reduce(
|
|
139
|
-
(parameters, onbefore) => onbefore(parameters),
|
|
140
|
-
parameters,
|
|
141
|
-
)
|
|
142
|
-
: parameters
|
|
143
|
-
}
|
|
144
|
-
|
|
145
|
-
let onfulfilled = contract => {
|
|
146
|
-
let predicates = Extensions
|
|
147
|
-
.get(request)
|
|
148
|
-
.get('onfulfilled')
|
|
149
|
-
|
|
150
|
-
return (predicates.size > 0)
|
|
151
|
-
? Array
|
|
152
|
-
.from(predicates)
|
|
153
|
-
.reduce(
|
|
154
|
-
(contract, onfulfilled) => onfulfilled(contract),
|
|
155
|
-
contract,
|
|
156
|
-
)
|
|
157
|
-
: contract
|
|
158
|
-
}
|
|
159
|
-
|
|
160
|
-
let onrejected = reason => {
|
|
161
|
-
let predicates = Extensions
|
|
162
|
-
.get(request)
|
|
163
|
-
.get('onrejected')
|
|
164
|
-
|
|
165
|
-
Array
|
|
166
|
-
.from(predicates)
|
|
167
|
-
.forEach(onrejected => onrejected(reason))
|
|
168
|
-
|
|
169
|
-
throw reason
|
|
170
|
-
}
|
|
171
|
-
|
|
172
|
-
return new Promise((resolve, reject) => {
|
|
173
|
-
try {
|
|
174
|
-
resolve(onbefore([options, init]))
|
|
175
|
-
} catch (reason) {
|
|
176
|
-
reject(reason)
|
|
177
|
-
}
|
|
178
|
-
})
|
|
179
|
-
.then(([options, init]) =>
|
|
180
|
-
makeRequest(
|
|
181
|
-
feature,
|
|
182
|
-
method,
|
|
183
|
-
network,
|
|
184
|
-
options,
|
|
185
|
-
init,
|
|
186
|
-
)
|
|
187
|
-
)
|
|
188
|
-
.then(onfulfilled)
|
|
189
|
-
.catch(onrejected)
|
|
190
|
-
}
|
|
191
|
-
|
|
192
|
-
Extensions.set(
|
|
193
|
-
request,
|
|
194
|
-
new Map([
|
|
195
|
-
['onbefore', new Set([])],
|
|
196
|
-
['onfulfilled', new Set([])],
|
|
197
|
-
['onrejected', new Set([])],
|
|
198
|
-
]),
|
|
199
|
-
)
|
|
200
|
-
|
|
201
|
-
return request
|
|
202
|
-
}
|
package/source/globals.d.ts
DELETED
package/source/results.d.ts
DELETED
|
@@ -1,137 +0,0 @@
|
|
|
1
|
-
/**
|
|
2
|
-
* Checkin
|
|
3
|
-
*/
|
|
4
|
-
|
|
5
|
-
type CheckinResult =
|
|
6
|
-
& {
|
|
7
|
-
id: UserRow['id']
|
|
8
|
-
first_name: UserRow['first_name']
|
|
9
|
-
last_name: UserRow['last_name']
|
|
10
|
-
third_name: UserRow['third_name']
|
|
11
|
-
phone: UserRow['phone']
|
|
12
|
-
email: UserRow['email']
|
|
13
|
-
}
|
|
14
|
-
& {
|
|
15
|
-
image_id: ImageMediaRow['id']
|
|
16
|
-
}
|
|
17
|
-
& {
|
|
18
|
-
role_id: string
|
|
19
|
-
role_name: string
|
|
20
|
-
}
|
|
21
|
-
|
|
22
|
-
/**
|
|
23
|
-
* City
|
|
24
|
-
*/
|
|
25
|
-
|
|
26
|
-
type CityResult = CityRow
|
|
27
|
-
|
|
28
|
-
type CityPublicResult = {
|
|
29
|
-
address: CityRow['address']
|
|
30
|
-
alias: CityRow['alias']
|
|
31
|
-
country: CityRow['country']
|
|
32
|
-
custom_html: CityRow['custom_html']
|
|
33
|
-
custom_script: CityRow['custom_script']
|
|
34
|
-
email: CityRow['email']
|
|
35
|
-
id: CityRow['id']
|
|
36
|
-
inst_link: CityRow['inst_link']
|
|
37
|
-
max_members_count: CityRow['max_members_count']
|
|
38
|
-
meta_description: CityRow['meta_description']
|
|
39
|
-
meta_title: CityRow['meta_title']
|
|
40
|
-
min_members_count: CityRow['min_members_count']
|
|
41
|
-
name: CityRow['name']
|
|
42
|
-
phone: CityRow['phone']
|
|
43
|
-
tg_link: CityRow['tg_link']
|
|
44
|
-
vk_group_id: CityRow['vk_group_id']
|
|
45
|
-
vk_link: CityRow['vk_link']
|
|
46
|
-
yandex_metrica: CityRow['yandex_metrica']
|
|
47
|
-
}
|
|
48
|
-
|
|
49
|
-
/**
|
|
50
|
-
* Theme
|
|
51
|
-
*/
|
|
52
|
-
|
|
53
|
-
type ThemeResult = {
|
|
54
|
-
id: ThemeRow['id']
|
|
55
|
-
time_created: ThemeRow['time_created']
|
|
56
|
-
name: ThemeRow['name']
|
|
57
|
-
description: ThemeRow['description']
|
|
58
|
-
short_description: ThemeRow['short_description']
|
|
59
|
-
image_id: ImageMediaRow['id']
|
|
60
|
-
media_title: MediaRow['title']
|
|
61
|
-
media_path: MediaRow['path']
|
|
62
|
-
}
|
|
63
|
-
|
|
64
|
-
/**
|
|
65
|
-
* Game
|
|
66
|
-
*/
|
|
67
|
-
|
|
68
|
-
type GameResult =
|
|
69
|
-
& {
|
|
70
|
-
event_id: GameRow['id']
|
|
71
|
-
event_alias: GameRow['alias']
|
|
72
|
-
event_number: GameRow['number']
|
|
73
|
-
event_time: GameRow['event_time']
|
|
74
|
-
event_status: GameRow['status']
|
|
75
|
-
}
|
|
76
|
-
& {
|
|
77
|
-
location_id: LocationRow['id']
|
|
78
|
-
location_name: LocationRow['name']
|
|
79
|
-
}
|
|
80
|
-
& {
|
|
81
|
-
city_id: CityRow['id']
|
|
82
|
-
city_alias: CityRow['alias']
|
|
83
|
-
city_name: CityRow['name']
|
|
84
|
-
city_is_franchise: CityRow['is_franchise']
|
|
85
|
-
}
|
|
86
|
-
& {
|
|
87
|
-
theme_id: ThemeRow['id']
|
|
88
|
-
theme_name: ThemeRow['name']
|
|
89
|
-
}
|
|
90
|
-
& {
|
|
91
|
-
media_id: ImageMediaRow['id']
|
|
92
|
-
media_title: ImageMediaRow['title']
|
|
93
|
-
media_path: ImageMediaRow['path']
|
|
94
|
-
}
|
|
95
|
-
& {
|
|
96
|
-
people_amount: number
|
|
97
|
-
people_reserve_amount: number
|
|
98
|
-
teams_amount: number
|
|
99
|
-
teams_reserve_amount: number
|
|
100
|
-
}
|
|
101
|
-
|
|
102
|
-
type GamePublicResult =
|
|
103
|
-
& {
|
|
104
|
-
theme_description: ThemeRow['description']
|
|
105
|
-
theme_id: ThemeRow['id']
|
|
106
|
-
theme_name: ThemeRow['name']
|
|
107
|
-
theme_short_description: ThemeRow['short_description']
|
|
108
|
-
}
|
|
109
|
-
& {
|
|
110
|
-
alias: GameRow['alias']
|
|
111
|
-
currency: GameRow['currency']
|
|
112
|
-
id: GameRow['id']
|
|
113
|
-
max_members_count: GameRow['max_members_count']
|
|
114
|
-
min_members_count: GameRow['min_members_count']
|
|
115
|
-
number: GameRow['number']
|
|
116
|
-
price: GameRow['price']
|
|
117
|
-
status: GameRow['status']
|
|
118
|
-
event_time: GameRow['event_time']
|
|
119
|
-
}
|
|
120
|
-
& {
|
|
121
|
-
city_alias: CityRow['alias']
|
|
122
|
-
city_id: CityRow['id']
|
|
123
|
-
}
|
|
124
|
-
& {
|
|
125
|
-
location_house_number: LocationRow['house_number']
|
|
126
|
-
location_id: LocationRow['id']
|
|
127
|
-
location_info: LocationRow['location_info']
|
|
128
|
-
location_name: LocationRow['name']
|
|
129
|
-
location_street: LocationRow['street']
|
|
130
|
-
}
|
|
131
|
-
& {
|
|
132
|
-
media_id: MediaRow['id']
|
|
133
|
-
media_path: MediaRow['path']
|
|
134
|
-
}
|
|
135
|
-
& {
|
|
136
|
-
image_id: ImageMediaRow['id']
|
|
137
|
-
}
|