@shakerquiz/utilities 0.5.132 → 0.5.134

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 (32) hide show
  1. package/package.json +1 -1
  2. package/source/enumerations/display.js +4 -0
  3. package/source/enumerations/entities/registration-attribute.js +2 -2
  4. package/source/enumerations/entities/role.js +7 -7
  5. package/source/enumerations/method.js +44 -0
  6. package/source/enumerations/{entities/mode.js → mode.js} +4 -2
  7. package/source/enumerations/networks.js +31 -0
  8. package/source/enumerations/phases.js +31 -0
  9. package/source/enumerations/{misc/regexps.js → regexps.js} +0 -1
  10. package/source/enumerations/{misc/routes.js → routes.js} +360 -409
  11. package/source/enumerations/service.js +37 -0
  12. package/source/functions/hydrate-route-pathname.js +18 -0
  13. package/source/functions/route-key.js +17 -0
  14. package/source/functions/tag.js +3 -2
  15. package/source/index.js +22 -23
  16. package/source/enumerations/core/features.js +0 -56
  17. package/source/enumerations/core/methods.js +0 -16
  18. package/source/enumerations/core/networks.js +0 -6
  19. package/source/enumerations/entities/render-context.js +0 -8
  20. package/source/enumerations/misc/phases.js +0 -42
  21. package/source/functions/tag.d.ts +0 -1
  22. /package/source/enumerations/{entities/city → city}/timezone-mode.js +0 -0
  23. /package/source/enumerations/{entities/city → city}/venues-mode.js +0 -0
  24. /package/source/enumerations/{misc/constants.js → constants.js} +0 -0
  25. /package/source/enumerations/{entities/gender.js → gender.js} +0 -0
  26. /package/source/enumerations/{misc/icons.js → icons.js} +0 -0
  27. /package/source/enumerations/{misc/keys.js → keys.js} +0 -0
  28. /package/source/enumerations/{entities/numerosity.js → numerosity.js} +0 -0
  29. /package/source/enumerations/{core/runtimes.js → runtimes.js} +0 -0
  30. /package/source/enumerations/{entities/venue → venue}/audience.js +0 -0
  31. /package/source/enumerations/{entities/venue → venue}/city-mode.js +0 -0
  32. /package/source/enumerations/{entities/venue → venue}/status.js +0 -0
@@ -0,0 +1,37 @@
1
+ export var Service = /** @type {const} */ ({
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
+ 'Vkma': 'Vkma',
18
+ })
19
+
20
+ export var Services = [
21
+ Service['Users'],
22
+ Service['Roles'],
23
+ Service['Checkin'],
24
+ Service['Locations'],
25
+ Service['Cities'],
26
+ Service['Venues'],
27
+ Service['Themes'],
28
+ Service['Games'],
29
+ Service['Registrations'],
30
+ Service['Files'],
31
+ Service['Procedures'],
32
+ Service['Integrations'],
33
+ Service['Updates'],
34
+ Service['Hub'],
35
+ Service['Landing'],
36
+ Service['Vkma'],
37
+ ]
@@ -0,0 +1,18 @@
1
+ import { guardRoute, guardRouteParams, guardRoutePathname } from '../enumerations/routes.js'
2
+ import { isTag } from '../functions/tag.js'
3
+
4
+ export var hydrateRoutePathname = (maybeRoute, maybeRouteParams) => {
5
+ if (isTag('Array', maybeRouteParams))
6
+ throw TypeError(`Parameter 'maybeRouteParams' must be 'Array'.`)
7
+
8
+ var route = guardRoute(maybeRoute)
9
+
10
+ var pathname = guardRoutePathname(route)
11
+
12
+ var params = guardRouteParams(route)
13
+
14
+ return params.reduce(
15
+ (pathname, param, index) => pathname.replace(param, maybeRouteParams[index]),
16
+ pathname,
17
+ )
18
+ }
@@ -0,0 +1,17 @@
1
+ import { inferMethod } from '../enumerations/method.js'
2
+ import { Mode } from '../enumerations/mode.js'
3
+ import { hydrateRoutePathname } from '../functions/hydrate-route-pathname.js'
4
+
5
+ /**
6
+ * @param {keyof typeof import('@shakerquiz/utilities').Method} maybeMethod
7
+ * @param {keyof typeof import('@shakerquiz/utilities').Route} maybeRoute
8
+ * @param {any[]} maybeParameters
9
+ */
10
+ export var routeKey = (maybeMethod, maybeRoute, maybeParameters) => {
11
+ var method = inferMethod(maybeMethod)
12
+
13
+ if (method === Mode['Unknown'])
14
+ throw TypeError(`Cannot infer method of '${maybeMethod}'.`)
15
+
16
+ return method + '/' + hydrateRoutePathname(maybeRoute, maybeParameters)
17
+ }
@@ -1,5 +1,6 @@
1
1
  /**
2
- * @param {*} value
3
2
  * @returns {string}
4
3
  */
5
- export var getTag = value => Object.prototype.toString.call(value).slice(8, -1)
4
+ export var inferTag = value => Object.prototype.toString.call(value).slice(8, -1)
5
+
6
+ export var isTag = (tag, value) => tag === inferTag(value)
package/source/index.js CHANGED
@@ -1,14 +1,16 @@
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'
1
+ export * from './enumerations/constants.js'
2
+ export * from './enumerations/display.js'
3
+ export * from './enumerations/gender.js'
4
+ export * from './enumerations/icons.js'
5
+ export * from './enumerations/keys.js'
6
+ export * from './enumerations/method.js'
7
+ export * from './enumerations/mode.js'
8
+ export * from './enumerations/networks.js'
9
+ export * from './enumerations/numerosity.js'
10
+ export * from './enumerations/phases.js'
11
+ export * from './enumerations/regexps.js'
12
+ export * from './enumerations/routes.js'
13
+ export * from './enumerations/runtimes.js'
12
14
 
13
15
  export * from './enumerations/entities/affilation.js'
14
16
  export * from './enumerations/entities/game-status.js'
@@ -18,19 +20,16 @@ export * from './enumerations/entities/registration-channel.js'
18
20
  export * from './enumerations/entities/registration-lineup.js'
19
21
  export * from './enumerations/entities/registration-mailing.js'
20
22
  export * from './enumerations/entities/registration-status.js'
21
-
22
- export * from './enumerations/entities/city/timezone-mode.js'
23
- export * from './enumerations/entities/city/venues-mode.js'
24
-
25
- export * from './enumerations/entities/venue/audience.js'
26
- export * from './enumerations/entities/venue/city-mode.js'
27
- export * from './enumerations/entities/venue/status.js'
28
-
29
- export * from './enumerations/entities/gender.js'
30
- export * from './enumerations/entities/mode.js'
31
- export * from './enumerations/entities/numerosity.js'
32
- export * from './enumerations/entities/render-context.js'
33
23
  export * from './enumerations/entities/role.js'
34
24
  export * from './enumerations/entities/version.js'
35
25
 
26
+ export * from './enumerations/city/timezone-mode.js'
27
+ export * from './enumerations/city/venues-mode.js'
28
+
29
+ export * from './enumerations/venue/audience.js'
30
+ export * from './enumerations/venue/city-mode.js'
31
+ export * from './enumerations/venue/status.js'
32
+
33
+ export * from './functions/hydrate-route-pathname.js'
34
+ export * from './functions/route-key.js'
36
35
  export * from './functions/tag.js'
@@ -1,56 +0,0 @@
1
- export var Feature = /** @type {const} */ ({
2
- 'role': 'role',
3
- 'roles': 'roles',
4
- 'user': 'user',
5
- 'users': 'users',
6
- 'checkin': 'checkin',
7
- 'checkins': 'checkins',
8
- 'country': 'country',
9
- 'countries': 'countries',
10
- 'currency': 'currency',
11
- 'currencies': 'currencies',
12
- 'timezone': 'timezone',
13
- 'timezones': 'timezones',
14
- 'city': 'city',
15
- 'cities': 'cities',
16
- 'venue': 'venue',
17
- 'venues': 'venues',
18
- 'theme': 'theme',
19
- 'themes': 'themes',
20
- 'game': 'game',
21
- 'games': 'games',
22
- 'registration': 'registration',
23
- 'registrations': 'registrations',
24
- 'mailing': 'mailing',
25
- 'mailings': 'mailings',
26
- })
27
-
28
- export var Features = Object.values(Feature)
29
-
30
- /** @type {Record<Feature, Icon>} */
31
- export var FeatureIcon = {
32
- [Feature.role]: 'hero/solid/identification',
33
- [Feature.roles]: 'hero/solid/identification',
34
- [Feature.user]: 'hero/solid/users',
35
- [Feature.users]: 'hero/solid/users',
36
- [Feature.checkin]: 'arrow-right-end-on-rectangle',
37
- [Feature.checkins]: 'arrow-right-end-on-rectangle',
38
- [Feature.country]: 'hero/outline/no-symbol',
39
- [Feature.countries]: 'hero/outline/no-symbol',
40
- [Feature.currency]: 'hero/outline/banknotes',
41
- [Feature.currencies]: 'hero/outline/banknotes',
42
- [Feature.timezone]: 'hero/outline/no-symbol',
43
- [Feature.timezones]: 'hero/outline/no-symbol',
44
- [Feature.city]: 'hero/outline/building-office',
45
- [Feature.cities]: 'hero/outline/building-office',
46
- [Feature.venue]: 'hero/outline/map-pin',
47
- [Feature.venues]: 'hero/outline/map-pin',
48
- [Feature.theme]: 'hero/outline/document-text',
49
- [Feature.themes]: 'hero/outline/document-text',
50
- [Feature.game]: 'hero/outline/newspaper',
51
- [Feature.games]: 'hero/outline/newspaper',
52
- [Feature.registration]: 'hero/outline/user-group',
53
- [Feature.registrations]: 'hero/outline/user-group',
54
- [Feature.mailing]: 'hero/outline/envelope',
55
- [Feature.mailings]: 'hero/outline/envelope',
56
- }
@@ -1,16 +0,0 @@
1
- /**
2
- * Related specifications:
3
- * - HTTP/1.1 (Core Methods): {@link https://datatracker.ietf.org/doc/html/rfc7231#section-4.3}
4
- * - PATCH: {@link https://datatracker.ietf.org/doc/html/rfc5789}
5
- * - CONNECT: {@link https://datatracker.ietf.org/doc/html/rfc9110}
6
- * - WebDAV Extensions {@link https://datatracker.ietf.org/doc/html/rfc4918}
7
- */
8
- export var Method = /** @type {const} */ ({
9
- 'DELETE': 'DELETE',
10
- 'GET': 'GET',
11
- 'OPTIONS': 'OPTIONS',
12
- 'PATCH': 'PATCH',
13
- 'POST': 'POST',
14
- })
15
-
16
- export var Methods = Object.values(Method)
@@ -1,6 +0,0 @@
1
- export var Network = /** @type {const} */ ({
2
- 'Docker': 'Docker',
3
- 'Public': 'Public',
4
- })
5
-
6
- export var Networks = Object.values(Network)
@@ -1,8 +0,0 @@
1
- export var RenderMode = /** @type {const} */ ({
2
- 'Tag': 'Tag',
3
- 'Chip': 'Chip',
4
- 'Unset': 'Unset',
5
- 'Domain': 'Domain',
6
- 'Derived': 'Derived',
7
- 'Indifferent': 'Indifferent',
8
- })
@@ -1,42 +0,0 @@
1
- export var Phase = /** @type {const} */ ({
2
- 'Idle': 'Idle',
3
- 'Loading': 'Loading',
4
- 'Loaded': 'Loaded',
5
- 'Aborted': 'Aborted',
6
- 'Failed': 'Failed',
7
- })
8
-
9
- export var Phases = Object.values(Phase)
10
-
11
- export var PhaseWieght = {
12
- [Phase.Idle]: 0,
13
- [Phase.Loading]: 1,
14
- [Phase.Loaded]: 2,
15
- [Phase.Aborted]: 3,
16
- [Phase.Failed]: 4,
17
- }
18
-
19
- export var PhaseTitle = {
20
- [Phase.Idle]: 'Простой',
21
- [Phase.Loading]: 'В процессе',
22
- [Phase.Loaded]: 'Завершено',
23
- [Phase.Aborted]: 'Оборвано',
24
- [Phase.Failed]: 'Ошибка',
25
- }
26
-
27
- /** @type {Record<Phase, Icon>} */
28
- export var PhaseIcon = {
29
- [Phase.Idle]: 'hero/outline/clock',
30
- [Phase.Loading]: 'hero/outline/clock',
31
- [Phase.Loaded]: 'hero/outline/check',
32
- [Phase.Aborted]: 'hero/outline/x-mark',
33
- [Phase.Failed]: 'hero/outline/x-mark',
34
- }
35
-
36
- export var PhaseColor = {
37
- [Phase.Idle]: 'text-default',
38
- [Phase.Loading]: 'text-default',
39
- [Phase.Loaded]: 'text-success',
40
- [Phase.Aborted]: 'text-warning',
41
- [Phase.Failed]: 'text-danger',
42
- }
@@ -1 +0,0 @@
1
- export function getTag(value: any): string;
File without changes
File without changes