@shakerquiz/utilities 0.6.3 → 0.6.5

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.
@@ -0,0 +1,30 @@
1
+ name: Publish
2
+
3
+ on:
4
+ pull_request:
5
+ types: [ closed ]
6
+ branches:
7
+ - main
8
+
9
+ permissions:
10
+ id-token: write
11
+ contents: write
12
+
13
+ jobs:
14
+ publish:
15
+ runs-on: ubuntu-latest
16
+ if: github.event.pull_request.merged == true
17
+ steps:
18
+ - uses: actions/checkout@v5
19
+ with:
20
+ fetch-depth: 0
21
+ - uses: actions/setup-node@v6
22
+ with:
23
+ node-version: '24'
24
+ - run: npm install -g npm@latest
25
+ - run: git config user.name "github-actions[bot]"
26
+ - run: git config user.email "github-actions[bot]@users.noreply.github.com"
27
+ - run: npm version patch
28
+ - run: npm ci
29
+ - run: npm publish
30
+ - run: git push --follow-tags
package/package.json CHANGED
@@ -1,7 +1,7 @@
1
1
  {
2
2
  "type": "module",
3
3
  "name": "@shakerquiz/utilities",
4
- "version": "0.6.3",
4
+ "version": "0.6.5",
5
5
  "author": "yurkimus <yurkimus@gmail.com>",
6
6
  "license": "ISC",
7
7
  "repository": {
@@ -8,9 +8,3 @@ export const CityAffilations = Object.freeze([
8
8
  'Branch',
9
9
  'Franchise',
10
10
  ])
11
-
12
- /** @satisfies {Record<keyof typeof CityAffilation, string>} */
13
- export const CityAffilationIcon = Object.freeze({
14
- 'Branch': 'hero/outline/building-office-2',
15
- 'Franchise': 'hero/outline/building-storefront',
16
- })
@@ -16,18 +16,6 @@ export const GameStatus = Object.freeze({
16
16
 
17
17
  export const GameStatuses = Object.freeze(Object.values(GameStatus))
18
18
 
19
- export const GameStatusIcon = Object.freeze({
20
- 'REJECTED': 'hero/outline/x-mark',
21
- 'MODERATION': 'hero/outline/clock',
22
- 'APPROVED': 'hero/outline/hand-thumb-up',
23
- 'CLOSED': 'hero/outline/exclamation-triangle',
24
- 'FORINVITES': 'hero/outline/lock-closed',
25
- 'PUBLISHED': 'hero/outline/check-circle',
26
- 'IS_RESERVE': 'hero/outline/user-plus',
27
- 'FINISHED': 'hero/outline/check',
28
- 'ARCHIVE': 'hero/outline/archive-box',
29
- })
30
-
31
19
  export const RoleGameStatusGameStatuses = Object.freeze({
32
20
  [Role['admin']]: Object.freeze({}),
33
21
 
@@ -7,8 +7,3 @@ export const Modes = Object.freeze([
7
7
  'Known',
8
8
  'Unknown',
9
9
  ])
10
-
11
- export const ModeIcon = Object.freeze({
12
- 'Known': 'hero/outline/check',
13
- 'Unknown': 'hero/outline/no-symbol',
14
- })
@@ -13,11 +13,3 @@ export const Phases = Object.freeze([
13
13
  'Aborted',
14
14
  'Failed',
15
15
  ])
16
-
17
- export const PhaseIcon = Object.freeze({
18
- 'Idle': 'hero/outline/clock',
19
- 'Loading': 'hero/outline/clock',
20
- 'Loaded': 'hero/outline/check',
21
- 'Aborted': 'hero/outline/signal-slash',
22
- 'Failed': 'hero/outline/x-mark',
23
- })
@@ -9,13 +9,6 @@ export const RegistrationAttribute = Object.freeze({
9
9
 
10
10
  export const RegistrationAttributes = Object.freeze(Object.values(RegistrationAttribute))
11
11
 
12
- export const RegistrationAttributeIcon = Object.freeze({
13
- [RegistrationAttribute.Alone]: 'hero/outline/user',
14
- [RegistrationAttribute.Newcomer]: 'hero/outline/sparkles',
15
- [RegistrationAttribute.Birthday]: 'hero/outline/cake',
16
- [RegistrationAttribute.Public]: 'hero/outline/user-plus',
17
- })
18
-
19
12
  export const RegistrationAttributeEmoji = Object.freeze({
20
13
  [RegistrationAttribute.Alone]: '👤',
21
14
  [RegistrationAttribute.Newcomer]: '✨',
@@ -9,9 +9,3 @@ export const RegistrationChannels = Object.freeze([
9
9
  'telegramBot',
10
10
  'email',
11
11
  ])
12
-
13
- export const RegistrationChannelIcon = Object.freeze({
14
- 'vkontakte': 'brand/solid/vk',
15
- 'telegramBot': 'brand/solid/telegram',
16
- 'email': 'hero/solid/at-symbol',
17
- })
@@ -8,11 +8,6 @@ export const RegistrationLineups = Object.freeze([
8
8
  'Reserve',
9
9
  ])
10
10
 
11
- export const RegistrationLineupIcon = Object.freeze({
12
- 'Main': 'hero/outline/user-circle',
13
- 'Reserve': 'hero/outline/pause-circle',
14
- })
15
-
16
11
  export const RegistrationLineupEmoji = Object.freeze({
17
12
  'Main': '🟢',
18
13
  'Reserve': '🟡',
@@ -11,13 +11,6 @@ export const RegistrationStatuses = Object.freeze([
11
11
  'Cancelled',
12
12
  ])
13
13
 
14
- /** @satisfies {Record<keyof typeof RegistrationStatus, string>} */
15
- export const RegistrationStatusIcon = Object.freeze({
16
- 'Confirmed': 'hero/outline/check-circle',
17
- 'Created': 'hero/outline/check',
18
- 'Cancelled': 'hero/outline/x-mark',
19
- })
20
-
21
14
  /** @satisfies {Record<keyof typeof RegistrationStatus, string>} */
22
15
  export const RegistrationStatusEmoji = Object.freeze({
23
16
  'Confirmed': '✅',
@@ -14,12 +14,3 @@ export const Roles = Object.freeze([
14
14
  'user',
15
15
  'manager',
16
16
  ])
17
-
18
- export const RoleIcon = Object.freeze({
19
- 'admin': 'hero/outline/user',
20
- 'organizer': 'hero/outline/user',
21
- 'captain': 'hero/outline/user',
22
- 'player': 'hero/outline/user',
23
- 'user': 'hero/outline/user',
24
- 'manager': 'hero/outline/user',
25
- })
@@ -64,112 +64,3 @@ export const RouteCardinality = Object.freeze({
64
64
  [Route['venues/city']]: Cardinality['N-1'],
65
65
  })
66
66
 
67
- export const RouteCardinalityRoute = Object.freeze({
68
- [Route['cities']]: {
69
- [Cardinality['1']]: Route['city'],
70
- },
71
-
72
- [Route['cities/country']]: {
73
- [Cardinality['1-1']]: Route['city/country'],
74
- },
75
-
76
- [Route['cities/currency']]: {
77
- [Cardinality['1-1']]: Route['city/currency'],
78
- },
79
-
80
- [Route['cities/timezone']]: {
81
- [Cardinality['1-1']]: Route['city/timezone'],
82
- },
83
-
84
- [Route['cities/venues']]: {
85
- [Cardinality['1-N']]: Route['city/venues'],
86
- },
87
-
88
- [Route['countries']]: {
89
- [Cardinality['1']]: Route['country'],
90
- },
91
-
92
- [Route['currencies']]: {
93
- [Cardinality['1']]: Route['currency'],
94
- },
95
-
96
- [Route['games']]: {
97
- [Cardinality['1']]: Route['game'],
98
- },
99
-
100
- [Route['games/city']]: {
101
- [Cardinality['1-1']]: Route['game/city'],
102
- },
103
-
104
- [Route['games/registrations']]: {
105
- [Cardinality['1']]: Route['game/registrations'],
106
- },
107
-
108
- [Route['games/summary']]: {
109
- [Cardinality['1']]: Route['game/summary'],
110
- },
111
-
112
- [Route['games/theme']]: {
113
- [Cardinality['1-1']]: Route['game/theme'],
114
- },
115
-
116
- [Route['games/venue']]: {
117
- [Cardinality['1-1']]: Route['game/venue'],
118
- },
119
-
120
- [Route['registrations']]: {
121
- [Cardinality['1']]: Route['registration'],
122
- },
123
-
124
- [Route['registrations/city']]: {
125
- [Cardinality['1-1']]: Route['registration/city'],
126
- },
127
-
128
- [Route['registrations/game']]: {
129
- [Cardinality['1-1']]: Route['registration/game'],
130
- },
131
-
132
- [Route['registrations/game/theme']]: {
133
- [Cardinality['1-1']]: Route['registration/game/theme'],
134
- },
135
-
136
- [Route['roles']]: {
137
- [Cardinality['1']]: Route['role'],
138
- },
139
-
140
- [Route['themes']]: {
141
- [Cardinality['1']]: Route['theme'],
142
- },
143
-
144
- [Route['themes/cover']]: {
145
- [Cardinality['1']]: Route['theme/cover'],
146
- },
147
-
148
- [Route['timezones']]: {
149
- [Cardinality['1']]: Route['timezone'],
150
- },
151
-
152
- [Route['user/cities']]: {
153
- [Cardinality['1']]: Route['user/cities'],
154
- },
155
-
156
- [Route['users']]: {
157
- [Cardinality['1']]: Route['user'],
158
- },
159
-
160
- [Route['users/cities']]: {
161
- [Cardinality['1']]: Route['user/cities'],
162
- },
163
-
164
- [Route['users/role']]: {
165
- [Cardinality['1']]: Route['user/role'],
166
- },
167
-
168
- [Route['venues']]: {
169
- [Cardinality['1']]: Route['venue'],
170
- },
171
-
172
- [Route['venues/city']]: {
173
- [Cardinality['1']]: Route['venue/city'],
174
- },
175
- })
@@ -17,5 +17,6 @@ export const ServiceRuntime = Object.freeze({
17
17
  [Service['Updates']]: Runtime['Bun'],
18
18
  [Service['Hub']]: Runtime['Node'],
19
19
  [Service['Landing']]: Runtime['Node'],
20
+ [Service['Telegram']]: Runtime['Node'],
20
21
  [Service['Vkma']]: Runtime['Vite'],
21
22
  })
@@ -14,6 +14,7 @@ export const Service = Object.freeze({
14
14
  'Updates': 'Updates',
15
15
  'Hub': 'Hub',
16
16
  'Landing': 'Landing',
17
+ 'Telegram': 'Telegram',
17
18
  'Vkma': 'Vkma',
18
19
  'Minio': 'Minio',
19
20
  })
@@ -7,8 +7,3 @@ export const ThemeStatuses = Object.freeze([
7
7
  'Active',
8
8
  'Archive',
9
9
  ])
10
-
11
- export const ThemeStatusIcon = Object.freeze({
12
- 'Active': 'hero/outline/check',
13
- 'Archive': 'hero/outline/archive-box',
14
- })
@@ -7,8 +7,3 @@ export const VenueAudiences = Object.freeze([
7
7
  'Open',
8
8
  'Adults',
9
9
  ])
10
-
11
- export const VenueAudienceIcon = Object.freeze({
12
- 'Open': 'hero/outline/lock-open',
13
- 'Adults': 'hero/outline/lock-closed',
14
- })
@@ -7,9 +7,3 @@ export const VenueStatuses = Object.freeze([
7
7
  'Active',
8
8
  'Archive',
9
9
  ])
10
-
11
- /** @satisfies {Record<keyof typeof VenueStatus, string>} */
12
- export const VenueStatusIcon = Object.freeze({
13
- 'Active': 'hero/outline/check',
14
- 'Archive': 'hero/outline/archive-box',
15
- })
@@ -0,0 +1,14 @@
1
+ export const access = (value, key) => {
2
+ if (Object.hasOwn(this.value, key))
3
+ return value[key]
4
+ else
5
+ throw TypeError(`Could not require key '${key}' from Relation '${JSON.stringify(value)}'.`)
6
+ }
7
+
8
+ export const tryAccess = (value, key) => {
9
+ try {
10
+ return access(value, key)
11
+ } catch (error) {
12
+ return 'Unknown'
13
+ }
14
+ }
@@ -1,7 +1,7 @@
1
1
  import { RoutePathnameParams } from '../entities/route-pathname-params.js'
2
2
  import { RoutePathname } from '../entities/route-pathname.js'
3
3
  import { Route } from '../entities/route.js'
4
- import { Relation } from '../prototypes/relation.js'
4
+ import { access } from '../helpers/access.js'
5
5
 
6
6
  export const hydrateRoutePathname = Object.freeze(
7
7
  /**
@@ -14,17 +14,11 @@ export const hydrateRoutePathname = Object.freeze(
14
14
  if (!Array.isArray(params))
15
15
  throw TypeError(`Parameter 'params' must be 'Array'.`)
16
16
 
17
- var r = Relation
18
- .of(Route)
19
- .require(route)
17
+ var r = access(Route, route)
20
18
 
21
- var rp = Relation
22
- .of(RoutePathname)
23
- .require(r)
19
+ var rp = access(RoutePathname, r)
24
20
 
25
- var rpp = Relation
26
- .of(RoutePathnameParams)
27
- .require(r)
21
+ var rpp = access(RoutePathnameParams, r)
28
22
 
29
23
  return rpp.reduce((rp, rpp, i) => rp.replace(rpp, params[i]), rp)
30
24
  },
@@ -1,6 +1,6 @@
1
1
  import { Method } from '../entities/method.js'
2
- import { Relation } from '../prototypes/relation.js'
3
2
  import { hydrateRoutePathname } from './hydrate-route-pathname.js'
3
+ import { access } from '../helpers/access.js'
4
4
 
5
5
  export const tag = Object.freeze(
6
6
  /**
@@ -15,9 +15,7 @@ export const tag = Object.freeze(
15
15
  * @returns {`${MethodTemplate}/${RoutePathnameTemplate}`}
16
16
  */
17
17
  (method, route, params) => {
18
- var m = Relation
19
- .of(Method)
20
- .require(method)
18
+ var m = access(Method, method)
21
19
 
22
20
  return m + '/' + hydrateRoutePathname(route, params)
23
21
  },
package/source/index.js CHANGED
@@ -35,7 +35,7 @@ export * from './entities/service.js'
35
35
  export * from './entities/theme-status.js'
36
36
  export * from './entities/venue-audience.js'
37
37
  export * from './entities/venue-status.js'
38
+ export * from './helpers/access.js'
38
39
  export * from './helpers/hydrate-route-pathname.js'
39
40
  export * from './helpers/string-tag.js'
40
41
  export * from './helpers/tag.js'
41
- export * from './prototypes/relation.js'
@@ -1,53 +0,0 @@
1
- /**
2
- * @template {*} Value
3
- *
4
- * @param {Value} value
5
- */
6
- export function Relation(value) {
7
- this.value = value
8
- }
9
-
10
- /**
11
- * @template {*} Value
12
- *
13
- * @param {Value} value
14
- */
15
- Relation.of = function(value) {
16
- return new Relation(value)
17
- }
18
-
19
- /**
20
- * @template {keyof Value} Key
21
- *
22
- * @this {Relation<Value>}
23
- *
24
- * @param {*} key
25
- *
26
- * @returns {Value[Key] | 'Unknown'}
27
- */
28
- Relation.prototype.expect = function(key) {
29
- if (Object.hasOwn(this.value, key))
30
- return this.value[key]
31
- else
32
- return 'Unknown'
33
- }
34
-
35
- /**
36
- * @template {keyof Value} Key
37
- *
38
- * @this {Relation<Value>}
39
- *
40
- * @param {*} key
41
- *
42
- * @returns {Value[Key]}
43
- *
44
- * @throws {TypeError}
45
- */
46
- Relation.prototype.require = function(key) {
47
- if (Object.hasOwn(this.value, key))
48
- return this.value[key]
49
- else
50
- throw TypeError(`Could not require key '${key}' from Relation '${JSON.stringify(this.value)}'.`)
51
- }
52
-
53
- Relation.prototype[Symbol.toStringTag] = 'Relation'