@shakerquiz/utilities 0.3.9 → 0.3.10
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/jsconfig.json +11 -8
- package/package.json +1 -4
- package/source/city.d.ts +40 -40
- package/source/enumerations/backends.d.ts +44 -0
- package/source/enumerations/backends.js +60 -0
- package/source/enumerations/default.d.ts +1 -0
- package/source/enumerations/default.js +1 -0
- package/source/enumerations/domains.d.ts +469 -0
- package/source/enumerations/domains.js +346 -0
- package/source/enumerations/features.d.ts +260 -401
- package/source/enumerations/features.js +26 -852
- package/source/enumerations/frontends.d.ts +34 -0
- package/source/enumerations/frontends.js +48 -0
- package/source/enumerations/game-statuses.d.ts +0 -6
- package/source/enumerations/game-statuses.js +0 -28
- package/source/enumerations/icons.d.ts +326 -0
- package/source/enumerations/icons.js +326 -0
- package/source/enumerations/kinds.d.ts +2 -2
- package/source/enumerations/kinds.js +2 -2
- package/source/enumerations/{request-methods.d.ts → methods.d.ts} +1 -1
- package/source/enumerations/{request-methods.js → methods.js} +1 -1
- package/source/enumerations/procedures.d.ts +74 -0
- package/source/enumerations/procedures.js +76 -0
- package/source/enumerations/roles.d.ts +2 -4
- package/source/enumerations/roles.js +0 -1
- package/source/enumerations/services.d.ts +48 -9
- package/source/enumerations/services.js +21 -30
- package/source/functions/fetch.d.ts +12 -15
- package/source/functions/fetch.js +64 -123
- package/source/functions/origin.d.ts +213 -1
- package/source/functions/origin.js +78 -40
- package/source/functions/pathname.d.ts +1 -0
- package/source/functions/pathname.js +40 -0
- package/source/functions/url.d.ts +1 -0
- package/source/functions/url.js +48 -0
- package/source/game.d.ts +17 -17
- package/source/globals.d.ts +22 -669
- package/source/index.d.ts +34 -14
- package/source/index.js +20 -1
- package/source/registration.d.ts +29 -29
- package/source/role.d.ts +3 -3
- package/source/rows.d.ts +9 -9
- package/source/theme.d.ts +3 -3
- package/source/user.d.ts +15 -15
- package/source/venue.d.ts +17 -17
|
@@ -2,45 +2,29 @@ import * as cookies from '@yurkimus/cookies'
|
|
|
2
2
|
import { MessageError } from '@yurkimus/errors'
|
|
3
3
|
import * as message from '@yurkimus/message'
|
|
4
4
|
import { ResponseStatus } from '@yurkimus/response-status'
|
|
5
|
+
import { url } from '@yurkimus/url'
|
|
5
6
|
|
|
6
7
|
import { Cookies } from '../enumerations/cookies.js'
|
|
7
|
-
import {
|
|
8
|
-
FeatureKinds,
|
|
9
|
-
FeaturePathnames,
|
|
10
|
-
Features,
|
|
11
|
-
ServiceFeatureNetworkURLs,
|
|
12
|
-
ServiceFeatures,
|
|
13
|
-
} from '../enumerations/features.js'
|
|
8
|
+
import { Features, FeatureServiceDefaults } from '../enumerations/features.js'
|
|
14
9
|
import { Kinds } from '../enumerations/kinds.js'
|
|
10
|
+
import { Methods } from '../enumerations/methods.js'
|
|
15
11
|
import { Networks } from '../enumerations/networks.js'
|
|
16
|
-
import {
|
|
17
|
-
import {
|
|
12
|
+
import { ServiceFeatures, Services } from '../enumerations/services.js'
|
|
13
|
+
import { getFeatureOrigin } from './origin.js'
|
|
14
|
+
import { getFeaturePathname } from './pathname.js'
|
|
18
15
|
|
|
19
|
-
|
|
20
|
-
* @typedef {'onbefore' | 'onfulfilled' | 'onrejected'} ExtensionHooks
|
|
21
|
-
*/
|
|
22
|
-
|
|
23
|
-
/**
|
|
24
|
-
* @typedef {WeakMap<Function, Map<ExtensionHooks, Set<Function>>>} Extensions
|
|
25
|
-
*/
|
|
26
|
-
|
|
27
|
-
/**
|
|
28
|
-
* @type {Extensions}
|
|
29
|
-
*/
|
|
30
|
-
export var extensions = new WeakMap()
|
|
31
|
-
|
|
32
|
-
var handleMessage = (feature, [response, body]) => {
|
|
16
|
+
var fulfillment = (kind, [response, body]) => {
|
|
33
17
|
switch (response.status) {
|
|
34
18
|
case 200:
|
|
35
19
|
case 201:
|
|
36
20
|
return body
|
|
37
21
|
|
|
38
22
|
case 204:
|
|
39
|
-
switch (
|
|
40
|
-
case Kinds.
|
|
23
|
+
switch (kind) {
|
|
24
|
+
case Kinds.Unit:
|
|
41
25
|
return null
|
|
42
26
|
|
|
43
|
-
case Kinds.
|
|
27
|
+
case Kinds.Set:
|
|
44
28
|
return []
|
|
45
29
|
}
|
|
46
30
|
|
|
@@ -53,92 +37,70 @@ var handleMessage = (feature, [response, body]) => {
|
|
|
53
37
|
}
|
|
54
38
|
|
|
55
39
|
/**
|
|
56
|
-
* @
|
|
57
|
-
* @param {ExtensionHooks} name
|
|
58
|
-
* @param {any} value
|
|
59
|
-
*/
|
|
60
|
-
var extension = (fetcher, name, value) =>
|
|
61
|
-
Array
|
|
62
|
-
.from(extensions.get(fetcher).get(name))
|
|
63
|
-
.reduce((x, f) => f(x), value)
|
|
64
|
-
|
|
65
|
-
/**
|
|
40
|
+
* @template {Feature} F
|
|
66
41
|
* @template {Service} S
|
|
67
|
-
* @template {typeof import('../enumerations/features.js').ServiceFeatures[S][number]} F
|
|
68
42
|
* @template {Network} N
|
|
43
|
+
* @template {Kind} K
|
|
69
44
|
*
|
|
70
|
-
* @param {S} service
|
|
71
45
|
* @param {F} feature
|
|
46
|
+
* @param {S} service
|
|
72
47
|
* @param {N} network
|
|
48
|
+
* @param {K} kind
|
|
73
49
|
*/
|
|
74
|
-
export var
|
|
50
|
+
export var useFeatureFetch = (
|
|
51
|
+
feature,
|
|
52
|
+
kind = Kinds.Unit,
|
|
53
|
+
service = FeatureServiceDefaults[feature],
|
|
54
|
+
network = Networks.Public,
|
|
55
|
+
) => {
|
|
56
|
+
if (!(feature in Features))
|
|
57
|
+
throw TypeError(
|
|
58
|
+
`Feature '${feature}' must be a member of 'Features'.`,
|
|
59
|
+
)
|
|
60
|
+
|
|
61
|
+
if (!(kind in Kinds))
|
|
62
|
+
throw TypeError(
|
|
63
|
+
`Kind '${kind}' must be a member of 'Kinds'.`,
|
|
64
|
+
)
|
|
65
|
+
|
|
66
|
+
if (!(service in Services))
|
|
67
|
+
throw TypeError(
|
|
68
|
+
`Service '${service}' must be a member of 'Services'.`,
|
|
69
|
+
)
|
|
70
|
+
|
|
71
|
+
if (!(network in Networks))
|
|
72
|
+
throw TypeError(
|
|
73
|
+
`Network '${network}' must be a member of 'Networks'.`,
|
|
74
|
+
)
|
|
75
|
+
|
|
76
|
+
if (!ServiceFeatures[service].includes(feature))
|
|
77
|
+
throw TypeError(
|
|
78
|
+
`Feature '${feature}' must be a member of 'ServiceFeatures[${service}]'.`,
|
|
79
|
+
)
|
|
80
|
+
|
|
75
81
|
/**
|
|
76
|
-
* @
|
|
77
|
-
* @template {Role} [R='default']
|
|
78
|
-
*
|
|
79
|
-
* @param {import('@yurkimus/url').URLOptions | undefined} options
|
|
82
|
+
* @param {import('@yurkimus/url').URLOptions} input
|
|
80
83
|
* @param {RequestInit} init
|
|
81
84
|
*
|
|
82
|
-
* @returns {Promise<
|
|
85
|
+
* @returns {Promise<any>}
|
|
83
86
|
*/
|
|
84
|
-
|
|
85
|
-
|
|
86
|
-
|
|
87
|
-
|
|
88
|
-
|
|
89
|
-
|
|
90
|
-
if (!(feature in Features))
|
|
91
|
-
throw TypeError(
|
|
92
|
-
`Feature '${feature}' is not listed in 'Features'.`,
|
|
93
|
-
)
|
|
94
|
-
|
|
95
|
-
if (!(feature in FeaturePathnames))
|
|
87
|
+
// @template {Method} [M='GET']
|
|
88
|
+
// FeatureFetchResponses[F][S][M][R][K]
|
|
89
|
+
// FeatureFetchResponses[F][S][M][R][K]
|
|
90
|
+
return (input, init) => {
|
|
91
|
+
if (!(init.method in Methods))
|
|
96
92
|
throw TypeError(
|
|
97
|
-
`
|
|
93
|
+
`Method '${init.method}' is not listed in 'Methods'.`,
|
|
98
94
|
)
|
|
99
95
|
|
|
100
|
-
|
|
101
|
-
|
|
102
|
-
|
|
103
|
-
|
|
104
|
-
|
|
105
|
-
|
|
106
|
-
|
|
107
|
-
|
|
108
|
-
)
|
|
109
|
-
|
|
110
|
-
if (!(network in Networks))
|
|
111
|
-
throw TypeError(
|
|
112
|
-
`Network '${network}' is not listed in 'Networks'.`,
|
|
113
|
-
)
|
|
114
|
-
|
|
115
|
-
if (!ServiceFeatureNetworkURLs.has(service))
|
|
116
|
-
throw TypeError(
|
|
117
|
-
`Service '${service}' is not listed in 'ServiceFeatureNetworkURLs'.`,
|
|
118
|
-
)
|
|
119
|
-
|
|
120
|
-
if (!ServiceFeatureNetworkURLs.get(service).has(feature))
|
|
121
|
-
throw TypeError(
|
|
122
|
-
`Feature '${feature}' is not listed in 'ServiceFeatureNetworkURLs[${service}]'.`,
|
|
123
|
-
)
|
|
124
|
-
|
|
125
|
-
if (!ServiceFeatureNetworkURLs.get(service).get(feature).has(network))
|
|
126
|
-
throw TypeError(
|
|
127
|
-
`Network '${network}' is not listed in 'ServiceFeatureNetworkURLs[${service}][${feature}]'.`,
|
|
128
|
-
)
|
|
129
|
-
|
|
130
|
-
if (!ServiceFeatureNetworkURLs.get(service).get(feature).get(network))
|
|
131
|
-
throw TypeError(
|
|
132
|
-
`Network '${network}' of 'ServiceFeatureNetworkURLs[${service}][${feature}]' has no value.`,
|
|
133
|
-
)
|
|
134
|
-
|
|
135
|
-
var url = ServiceFeatureNetworkURLs
|
|
136
|
-
.get(service)
|
|
137
|
-
.get(feature)
|
|
138
|
-
.get(network)
|
|
139
|
-
.call(undefined, options)
|
|
140
|
-
|
|
141
|
-
var request = new Request(url, init)
|
|
96
|
+
var request = new Request(
|
|
97
|
+
url(
|
|
98
|
+
getFeatureOrigin(feature, service, network),
|
|
99
|
+
getFeaturePathname(feature, kind),
|
|
100
|
+
input,
|
|
101
|
+
),
|
|
102
|
+
init,
|
|
103
|
+
)
|
|
142
104
|
|
|
143
105
|
if ('cookie' in init)
|
|
144
106
|
request.headers.set(
|
|
@@ -152,30 +114,9 @@ export var useFetch = (service, feature, network) => {
|
|
|
152
114
|
'application/json',
|
|
153
115
|
)
|
|
154
116
|
|
|
155
|
-
return
|
|
156
|
-
|
|
157
|
-
resolve(extension(fetcher, 'onbefore', request))
|
|
158
|
-
} catch (reason) {
|
|
159
|
-
reject(reason)
|
|
160
|
-
}
|
|
161
|
-
})
|
|
162
|
-
.then(fetch)
|
|
117
|
+
return globalThis
|
|
118
|
+
.fetch(request)
|
|
163
119
|
.then(message.read)
|
|
164
|
-
.then(
|
|
165
|
-
.then(extension.bind(undefined, fetcher, 'onfulfilled'))
|
|
166
|
-
.catch(reason => {
|
|
167
|
-
throw extension(fetcher, 'onrejected', reason)
|
|
168
|
-
})
|
|
120
|
+
.then(fulfillment.bind(undefined, kind))
|
|
169
121
|
}
|
|
170
|
-
|
|
171
|
-
extensions.set(
|
|
172
|
-
fetcher,
|
|
173
|
-
new Map([
|
|
174
|
-
['onbefore', new Set([])],
|
|
175
|
-
['onfulfilled', new Set([])],
|
|
176
|
-
['onrejected', new Set([])],
|
|
177
|
-
]),
|
|
178
|
-
)
|
|
179
|
-
|
|
180
|
-
return fetcher
|
|
181
122
|
}
|
|
@@ -1 +1,213 @@
|
|
|
1
|
-
export function
|
|
1
|
+
export function getFeatureOrigin(feature: Feature, service?: Service, network?: Network): any;
|
|
2
|
+
export function setFeatureOrigin(origins: Partial<Record<Feature, Partial<Record<Service, Partial<Record<Network, URL["origin"]>>>>>>): {
|
|
3
|
+
Checkin: {
|
|
4
|
+
Backend: {
|
|
5
|
+
Docker: string;
|
|
6
|
+
Public: string;
|
|
7
|
+
};
|
|
8
|
+
Games: {
|
|
9
|
+
Docker: string;
|
|
10
|
+
Public: string;
|
|
11
|
+
};
|
|
12
|
+
Locations: {
|
|
13
|
+
Docker: string;
|
|
14
|
+
Public: string;
|
|
15
|
+
};
|
|
16
|
+
Users: {
|
|
17
|
+
Docker: string;
|
|
18
|
+
Public: string;
|
|
19
|
+
};
|
|
20
|
+
Admin: {
|
|
21
|
+
Docker: string;
|
|
22
|
+
Public: string;
|
|
23
|
+
};
|
|
24
|
+
Landing: {
|
|
25
|
+
Docker: string;
|
|
26
|
+
Public: string;
|
|
27
|
+
};
|
|
28
|
+
MiniApp: {
|
|
29
|
+
Docker: string;
|
|
30
|
+
Public: string;
|
|
31
|
+
};
|
|
32
|
+
};
|
|
33
|
+
City: {
|
|
34
|
+
Backend: {
|
|
35
|
+
Docker: string;
|
|
36
|
+
Public: string;
|
|
37
|
+
};
|
|
38
|
+
Games: {
|
|
39
|
+
Docker: string;
|
|
40
|
+
Public: string;
|
|
41
|
+
};
|
|
42
|
+
Locations: {
|
|
43
|
+
Docker: string;
|
|
44
|
+
Public: string;
|
|
45
|
+
};
|
|
46
|
+
Users: {
|
|
47
|
+
Docker: string;
|
|
48
|
+
Public: string;
|
|
49
|
+
};
|
|
50
|
+
Admin: {
|
|
51
|
+
Docker: string;
|
|
52
|
+
Public: string;
|
|
53
|
+
};
|
|
54
|
+
Landing: {
|
|
55
|
+
Docker: string;
|
|
56
|
+
Public: string;
|
|
57
|
+
};
|
|
58
|
+
MiniApp: {
|
|
59
|
+
Docker: string;
|
|
60
|
+
Public: string;
|
|
61
|
+
};
|
|
62
|
+
};
|
|
63
|
+
Game: {
|
|
64
|
+
Backend: {
|
|
65
|
+
Docker: string;
|
|
66
|
+
Public: string;
|
|
67
|
+
};
|
|
68
|
+
Games: {
|
|
69
|
+
Docker: string;
|
|
70
|
+
Public: string;
|
|
71
|
+
};
|
|
72
|
+
Locations: {
|
|
73
|
+
Docker: string;
|
|
74
|
+
Public: string;
|
|
75
|
+
};
|
|
76
|
+
Users: {
|
|
77
|
+
Docker: string;
|
|
78
|
+
Public: string;
|
|
79
|
+
};
|
|
80
|
+
Admin: {
|
|
81
|
+
Docker: string;
|
|
82
|
+
Public: string;
|
|
83
|
+
};
|
|
84
|
+
Landing: {
|
|
85
|
+
Docker: string;
|
|
86
|
+
Public: string;
|
|
87
|
+
};
|
|
88
|
+
MiniApp: {
|
|
89
|
+
Docker: string;
|
|
90
|
+
Public: string;
|
|
91
|
+
};
|
|
92
|
+
};
|
|
93
|
+
Registration: {
|
|
94
|
+
Backend: {
|
|
95
|
+
Docker: string;
|
|
96
|
+
Public: string;
|
|
97
|
+
};
|
|
98
|
+
Games: {
|
|
99
|
+
Docker: string;
|
|
100
|
+
Public: string;
|
|
101
|
+
};
|
|
102
|
+
Locations: {
|
|
103
|
+
Docker: string;
|
|
104
|
+
Public: string;
|
|
105
|
+
};
|
|
106
|
+
Users: {
|
|
107
|
+
Docker: string;
|
|
108
|
+
Public: string;
|
|
109
|
+
};
|
|
110
|
+
Admin: {
|
|
111
|
+
Docker: string;
|
|
112
|
+
Public: string;
|
|
113
|
+
};
|
|
114
|
+
Landing: {
|
|
115
|
+
Docker: string;
|
|
116
|
+
Public: string;
|
|
117
|
+
};
|
|
118
|
+
MiniApp: {
|
|
119
|
+
Docker: string;
|
|
120
|
+
Public: string;
|
|
121
|
+
};
|
|
122
|
+
};
|
|
123
|
+
Theme: {
|
|
124
|
+
Backend: {
|
|
125
|
+
Docker: string;
|
|
126
|
+
Public: string;
|
|
127
|
+
};
|
|
128
|
+
Games: {
|
|
129
|
+
Docker: string;
|
|
130
|
+
Public: string;
|
|
131
|
+
};
|
|
132
|
+
Locations: {
|
|
133
|
+
Docker: string;
|
|
134
|
+
Public: string;
|
|
135
|
+
};
|
|
136
|
+
Users: {
|
|
137
|
+
Docker: string;
|
|
138
|
+
Public: string;
|
|
139
|
+
};
|
|
140
|
+
Admin: {
|
|
141
|
+
Docker: string;
|
|
142
|
+
Public: string;
|
|
143
|
+
};
|
|
144
|
+
Landing: {
|
|
145
|
+
Docker: string;
|
|
146
|
+
Public: string;
|
|
147
|
+
};
|
|
148
|
+
MiniApp: {
|
|
149
|
+
Docker: string;
|
|
150
|
+
Public: string;
|
|
151
|
+
};
|
|
152
|
+
};
|
|
153
|
+
User: {
|
|
154
|
+
Backend: {
|
|
155
|
+
Docker: string;
|
|
156
|
+
Public: string;
|
|
157
|
+
};
|
|
158
|
+
Games: {
|
|
159
|
+
Docker: string;
|
|
160
|
+
Public: string;
|
|
161
|
+
};
|
|
162
|
+
Locations: {
|
|
163
|
+
Docker: string;
|
|
164
|
+
Public: string;
|
|
165
|
+
};
|
|
166
|
+
Users: {
|
|
167
|
+
Docker: string;
|
|
168
|
+
Public: string;
|
|
169
|
+
};
|
|
170
|
+
Admin: {
|
|
171
|
+
Docker: string;
|
|
172
|
+
Public: string;
|
|
173
|
+
};
|
|
174
|
+
Landing: {
|
|
175
|
+
Docker: string;
|
|
176
|
+
Public: string;
|
|
177
|
+
};
|
|
178
|
+
MiniApp: {
|
|
179
|
+
Docker: string;
|
|
180
|
+
Public: string;
|
|
181
|
+
};
|
|
182
|
+
};
|
|
183
|
+
Venue: {
|
|
184
|
+
Backend: {
|
|
185
|
+
Docker: string;
|
|
186
|
+
Public: string;
|
|
187
|
+
};
|
|
188
|
+
Games: {
|
|
189
|
+
Docker: string;
|
|
190
|
+
Public: string;
|
|
191
|
+
};
|
|
192
|
+
Locations: {
|
|
193
|
+
Docker: string;
|
|
194
|
+
Public: string;
|
|
195
|
+
};
|
|
196
|
+
Users: {
|
|
197
|
+
Docker: string;
|
|
198
|
+
Public: string;
|
|
199
|
+
};
|
|
200
|
+
Admin: {
|
|
201
|
+
Docker: string;
|
|
202
|
+
Public: string;
|
|
203
|
+
};
|
|
204
|
+
Landing: {
|
|
205
|
+
Docker: string;
|
|
206
|
+
Public: string;
|
|
207
|
+
};
|
|
208
|
+
MiniApp: {
|
|
209
|
+
Docker: string;
|
|
210
|
+
Public: string;
|
|
211
|
+
};
|
|
212
|
+
};
|
|
213
|
+
};
|
|
@@ -1,68 +1,106 @@
|
|
|
1
|
-
import { url } from '@yurkimus/url'
|
|
2
|
-
|
|
3
1
|
import {
|
|
4
|
-
FeaturePathnames,
|
|
5
2
|
Features,
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
ServiceNetworkOrigins,
|
|
3
|
+
FeatureServiceDefaults,
|
|
4
|
+
FeatureServiceNetworkOrigins,
|
|
9
5
|
} from '../enumerations/features.js'
|
|
10
6
|
import { Networks } from '../enumerations/networks.js'
|
|
11
7
|
import { Services } from '../enumerations/services.js'
|
|
12
8
|
|
|
13
9
|
/**
|
|
14
|
-
* @param {
|
|
15
|
-
*
|
|
16
|
-
* @
|
|
10
|
+
* @param {Feature} feature
|
|
11
|
+
* @param {Service} [service]
|
|
12
|
+
* @param {Network} [network]
|
|
13
|
+
*/
|
|
14
|
+
export var getFeatureOrigin = (
|
|
15
|
+
feature,
|
|
16
|
+
service = FeatureServiceDefaults[feature],
|
|
17
|
+
network = Networks.Public,
|
|
18
|
+
) => {
|
|
19
|
+
if (!(feature in Features))
|
|
20
|
+
throw TypeError(
|
|
21
|
+
`Parameter 'feature' must be a member of 'Features'.`,
|
|
22
|
+
)
|
|
23
|
+
|
|
24
|
+
if (!(service in Services))
|
|
25
|
+
throw TypeError(
|
|
26
|
+
`Parameter 'service' must be a member of 'Services'.`,
|
|
27
|
+
)
|
|
28
|
+
|
|
29
|
+
if (!(network in Networks))
|
|
30
|
+
throw TypeError(
|
|
31
|
+
`Parameter 'network' must be a member of 'Networks'.`,
|
|
32
|
+
)
|
|
33
|
+
|
|
34
|
+
if (!(feature in FeatureServiceNetworkOrigins))
|
|
35
|
+
throw TypeError(
|
|
36
|
+
`Feature '${feature}' is not defined in 'FeatureServiceNetworkOrigins'.`,
|
|
37
|
+
)
|
|
38
|
+
|
|
39
|
+
if (!(service in FeatureServiceNetworkOrigins[feature]))
|
|
40
|
+
throw TypeError(
|
|
41
|
+
`Feature's '${feature}' Service '${service}' is not defined in 'FeatureServiceNetworkOrigins[${feature}]'.`,
|
|
42
|
+
)
|
|
43
|
+
|
|
44
|
+
if (!(network in FeatureServiceNetworkOrigins[feature][service]))
|
|
45
|
+
throw TypeError(
|
|
46
|
+
`Feature's '${feature}' Service '${service}' Network '${network}' is not defined in 'FeatureServiceNetworkOrigins[${feature}][${network}]'.`,
|
|
47
|
+
)
|
|
48
|
+
|
|
49
|
+
if (!URL.canParse(FeatureServiceNetworkOrigins[feature][service][network]))
|
|
50
|
+
throw TypeError(
|
|
51
|
+
`Feature's '${feature}' Service '${service}' Network '${network}' must be URL-like.`,
|
|
52
|
+
)
|
|
53
|
+
|
|
54
|
+
return FeatureServiceNetworkOrigins[feature][service][network]
|
|
55
|
+
}
|
|
56
|
+
|
|
57
|
+
/**
|
|
58
|
+
* @param {Partial<Record<Feature, Partial<Record<Service, Partial<Record<Network, URL['origin']>>>>>>} origins
|
|
17
59
|
*/
|
|
18
|
-
export var
|
|
19
|
-
for (var
|
|
20
|
-
if (!(
|
|
60
|
+
export var setFeatureOrigin = origins => {
|
|
61
|
+
for (var feature in origins) {
|
|
62
|
+
if (!(feature in Features))
|
|
21
63
|
throw TypeError(
|
|
22
|
-
`
|
|
64
|
+
`Parameter 'feature' must be a member of 'Features'.`,
|
|
23
65
|
)
|
|
24
66
|
|
|
25
|
-
|
|
26
|
-
|
|
67
|
+
if (!(feature in FeatureServiceNetworkOrigins))
|
|
68
|
+
throw TypeError(
|
|
69
|
+
`Feature '${feature}' is not defined 'FeatureServiceNetworkOrigins'.`,
|
|
70
|
+
)
|
|
71
|
+
|
|
72
|
+
for (var service in origins[feature]) {
|
|
73
|
+
if (!(service in Services))
|
|
27
74
|
throw TypeError(
|
|
28
|
-
`
|
|
75
|
+
`Parameter 'service' must be a member of 'Services'.`,
|
|
29
76
|
)
|
|
30
77
|
|
|
31
|
-
|
|
32
|
-
|
|
33
|
-
|
|
34
|
-
|
|
35
|
-
.set(network, origin)
|
|
36
|
-
|
|
37
|
-
for (var feature of ServiceFeatures[service]) {
|
|
38
|
-
if (!(feature in Features))
|
|
39
|
-
throw TypeError(
|
|
40
|
-
`Feature '${feature}' must be listed in 'Features'.`,
|
|
41
|
-
)
|
|
78
|
+
if (!(service in FeatureServiceNetworkOrigins[feature]))
|
|
79
|
+
throw TypeError(
|
|
80
|
+
`Feature's '${feature}' Service '${service}' is not defined 'FeatureServiceNetworkOrigins[${feature}]'.`,
|
|
81
|
+
)
|
|
42
82
|
|
|
43
|
-
|
|
83
|
+
for (var network in origins[feature][service]) {
|
|
84
|
+
if (!(network in Networks))
|
|
44
85
|
throw TypeError(
|
|
45
|
-
`
|
|
86
|
+
`Parameter 'network' must be a member of 'Networks'.`,
|
|
46
87
|
)
|
|
47
88
|
|
|
48
|
-
if (!
|
|
89
|
+
if (!(network in FeatureServiceNetworkOrigins[feature][service]))
|
|
49
90
|
throw TypeError(
|
|
50
|
-
`Service '${service}'
|
|
91
|
+
`Feature's '${feature}' Service '${service}' Network '${network}' is not defined 'FeatureServiceNetworkOrigins[${feature}][${service}]'.`,
|
|
51
92
|
)
|
|
52
93
|
|
|
53
|
-
if (!
|
|
94
|
+
if (!URL.canParse(origins[feature][service][network]))
|
|
54
95
|
throw TypeError(
|
|
55
|
-
`Feature '${feature}'
|
|
96
|
+
`Feature's '${feature}' Service '${service}' Network '${network}' must be URL-like.`,
|
|
56
97
|
)
|
|
57
98
|
|
|
58
|
-
|
|
59
|
-
|
|
60
|
-
.get(feature)
|
|
61
|
-
.set(
|
|
62
|
-
network,
|
|
63
|
-
url.bind(undefined, origin, FeaturePathnames[feature]),
|
|
64
|
-
)
|
|
99
|
+
FeatureServiceNetworkOrigins[feature][service][network] =
|
|
100
|
+
origins[feature][service][network]
|
|
65
101
|
}
|
|
66
102
|
}
|
|
67
103
|
}
|
|
104
|
+
|
|
105
|
+
return FeatureServiceNetworkOrigins
|
|
68
106
|
}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export function getFeaturePathname(feature: Feature, kind?: Kind): any;
|
|
@@ -0,0 +1,40 @@
|
|
|
1
|
+
import { is } from '@yurkimus/types'
|
|
2
|
+
|
|
3
|
+
import { FeatureKindPathnames, Features } from '../enumerations/features.js'
|
|
4
|
+
import { Kinds } from '../enumerations/kinds.js'
|
|
5
|
+
|
|
6
|
+
/**
|
|
7
|
+
* @param {Feature} feature
|
|
8
|
+
* @param {Kind} [kind]
|
|
9
|
+
*/
|
|
10
|
+
export var getFeaturePathname = (
|
|
11
|
+
feature,
|
|
12
|
+
kind = Kinds.Unit,
|
|
13
|
+
) => {
|
|
14
|
+
if (!(feature in Features))
|
|
15
|
+
throw TypeError(
|
|
16
|
+
`Parameter 'feature' must be a member of 'Features'.`,
|
|
17
|
+
)
|
|
18
|
+
|
|
19
|
+
if (!(kind in Kinds))
|
|
20
|
+
throw TypeError(
|
|
21
|
+
`Parameter 'kind' must be a member of 'Kinds'.`,
|
|
22
|
+
)
|
|
23
|
+
|
|
24
|
+
if (!(feature in FeatureKindPathnames))
|
|
25
|
+
throw TypeError(
|
|
26
|
+
`Feature '${feature}' is not defined in 'FeatureKindPathnames'.`,
|
|
27
|
+
)
|
|
28
|
+
|
|
29
|
+
if (!(kind in FeatureKindPathnames[feature]))
|
|
30
|
+
throw TypeError(
|
|
31
|
+
`Feature's '${feature}' Kind '${kind}' is not defined in 'FeatureKindPathnames[${feature}]'.`,
|
|
32
|
+
)
|
|
33
|
+
|
|
34
|
+
if (!is('String', FeatureKindPathnames[feature][kind]))
|
|
35
|
+
throw TypeError(
|
|
36
|
+
`Feature's '${feature}' Kind '${kind}' must be a 'String'.`,
|
|
37
|
+
)
|
|
38
|
+
|
|
39
|
+
return FeatureKindPathnames[feature][kind]
|
|
40
|
+
}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export function getFeatureUrl(feature: Feature, service?: Service, network?: Network, kind?: Kind): URL;
|
|
@@ -0,0 +1,48 @@
|
|
|
1
|
+
import { DomainServiceDefaults } from '../enumerations/domains.js'
|
|
2
|
+
import { Features } from '../enumerations/features.js'
|
|
3
|
+
import { Kinds } from '../enumerations/kinds.js'
|
|
4
|
+
import { Networks } from '../enumerations/networks.js'
|
|
5
|
+
import { ProcedureServiceDefaults } from '../enumerations/procedures.js'
|
|
6
|
+
import { Services } from '../enumerations/services.js'
|
|
7
|
+
|
|
8
|
+
import { getFeatureOrigin } from './origin.js'
|
|
9
|
+
import { getFeaturePathname } from './pathname.js'
|
|
10
|
+
|
|
11
|
+
/**
|
|
12
|
+
* @param {Feature} feature
|
|
13
|
+
* @param {Service} service
|
|
14
|
+
* @param {Network} [network]
|
|
15
|
+
* @param {Kind} [kind]
|
|
16
|
+
*/
|
|
17
|
+
export var getFeatureUrl = (
|
|
18
|
+
feature,
|
|
19
|
+
service = DomainServiceDefaults[feature]
|
|
20
|
+
?? ProcedureServiceDefaults[feature],
|
|
21
|
+
network = Networks.Public,
|
|
22
|
+
kind = Kinds.Unit,
|
|
23
|
+
) => {
|
|
24
|
+
if (!(feature in Features))
|
|
25
|
+
throw TypeError(
|
|
26
|
+
`Parameter 'feature' must be a member of 'Features'.`,
|
|
27
|
+
)
|
|
28
|
+
|
|
29
|
+
if (!(service in Services))
|
|
30
|
+
throw TypeError(
|
|
31
|
+
`Parameter 'service' must be a member of 'Services'.`,
|
|
32
|
+
)
|
|
33
|
+
|
|
34
|
+
if (!(network in Networks))
|
|
35
|
+
throw TypeError(
|
|
36
|
+
`Parameter 'network' must be a member of 'Networks'.`,
|
|
37
|
+
)
|
|
38
|
+
|
|
39
|
+
if (!(kind in Kinds))
|
|
40
|
+
throw TypeError(
|
|
41
|
+
`Parameter 'kind' must be a member of 'Kinds'.`,
|
|
42
|
+
)
|
|
43
|
+
|
|
44
|
+
return new URL(
|
|
45
|
+
getFeaturePathname(feature, kind),
|
|
46
|
+
getFeatureOrigin(feature, service, network),
|
|
47
|
+
)
|
|
48
|
+
}
|