@shakerquiz/utilities 0.6.13 → 0.6.15

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.
@@ -20,7 +20,8 @@ jobs:
20
20
  fetch-depth: 0
21
21
  - uses: actions/setup-node@v6
22
22
  with:
23
- node-version: '24'
23
+ node-version: 24
24
+ - uses: oven-sh/setup-bun@v2
24
25
  - run: npm install -g npm@latest
25
26
  - run: git config user.name "github-actions[bot]"
26
27
  - run: git config user.email "github-actions[bot]@users.noreply.github.com"
package/package.json CHANGED
@@ -1,7 +1,7 @@
1
1
  {
2
2
  "type": "module",
3
3
  "name": "@shakerquiz/utilities",
4
- "version": "0.6.13",
4
+ "version": "0.6.15",
5
5
  "author": "yurkimus <yurkimus@gmail.com>",
6
6
  "license": "ISC",
7
7
  "repository": {
@@ -10,5 +10,8 @@
10
10
  },
11
11
  "exports": {
12
12
  "default": "./source/index.js"
13
+ },
14
+ "scripts": {
15
+ "prepublishOnly": "bun ./scripts/route-cardinality.js && bun ./scripts/route-parameter.js && bun ./scripts/route-pathname.js && bun ./scripts/route-relation.js && bun ./scripts/route-service.js"
13
16
  }
14
17
  }
@@ -0,0 +1,23 @@
1
+ import template from './templates/route-cardinality.js' with { type: 'text' }
2
+
3
+ import { Routes } from '../source/entities/route.js'
4
+ import { Segment } from '../source/entities/segment.js'
5
+
6
+ let cardinalities = Routes.map(route => {
7
+ const cardinalities = route.split('/').map(key => Segment[key].cardinality)
8
+
9
+ return cardinalities.length > 1
10
+ ? cardinalities.at(0) + '/' + cardinalities.at(-1)
11
+ : cardinalities.at(0)
12
+ })
13
+
14
+ let RouteCardinalities = JSON.stringify(cardinalities, undefined, 2)
15
+
16
+ let RouteCardinality = JSON.stringify(Routes.reduce((o, x, i) => (o[x] = cardinalities[i], o), {}), null, 2)
17
+
18
+ Bun.write(
19
+ './source/entities/route-cardinality.js',
20
+ template
21
+ .replace('/* RouteCardinalities */', RouteCardinalities)
22
+ .replace('/* RouteCardinality */', RouteCardinality),
23
+ )
@@ -0,0 +1,29 @@
1
+ import template from './templates/route-parameter.js' with { type: 'text' }
2
+
3
+ import { Routes } from '../source/entities/route.js'
4
+ import { Segment } from '../source/entities/segment.js'
5
+
6
+ let pathnames = Routes.map(route =>
7
+ route
8
+ .split('/')
9
+ .map(key => Segment[key].cardinality === '1' ? key + '/:' + key : key)
10
+ .join('/')
11
+ )
12
+
13
+ let parameters = pathnames.map(pathname =>
14
+ pathname
15
+ .split('/')
16
+ .filter(key => key.includes(':'))
17
+ .join('/')
18
+ )
19
+
20
+ let RouteParameters = JSON.stringify(parameters, undefined, 2)
21
+
22
+ let RouteParameter = JSON.stringify(Routes.reduce((o, x, i) => (o[x] = parameters[i], o), {}), null, 2)
23
+
24
+ Bun.write(
25
+ './source/entities/route-parameter.js',
26
+ template
27
+ .replace('/* RouteParameters */', RouteParameters)
28
+ .replace('/* RouteParameter */', RouteParameter),
29
+ )
@@ -0,0 +1,22 @@
1
+ import template from './templates/route-pathname.js' with { type: 'text' }
2
+
3
+ import { Routes } from '../source/entities/route.js'
4
+ import { Segment } from '../source/entities/segment.js'
5
+
6
+ let pathnames = Routes.map(route =>
7
+ route
8
+ .split('/')
9
+ .map(key => Segment[key].cardinality === '1' ? key + '/:' + key : key)
10
+ .join('/')
11
+ )
12
+
13
+ let RoutePathnames = JSON.stringify(pathnames, undefined, 2)
14
+
15
+ let RoutePathname = JSON.stringify(Routes.reduce((o, x, i) => (o[x] = pathnames[i], o), {}), null, 2)
16
+
17
+ Bun.write(
18
+ './source/entities/route-pathname.js',
19
+ template
20
+ .replace('/* RoutePathnames */', RoutePathnames)
21
+ .replace('/* RoutePathname */', RoutePathname),
22
+ )
@@ -0,0 +1,26 @@
1
+ import template from './templates/route-relation.js' with { type: 'text' }
2
+
3
+ import { Routes } from '../source/entities/route.js'
4
+ import { Segment } from '../source/entities/segment.js'
5
+
6
+ let relations = Routes.map(route =>
7
+ route
8
+ .split('/')
9
+ .map((key, index) =>
10
+ Segment[key].cardinality === '1' || index > 0
11
+ ? key
12
+ : Segment[key].relation ?? key
13
+ )
14
+ .join('/')
15
+ )
16
+
17
+ let RouteRelations = JSON.stringify(relations, undefined, 2)
18
+
19
+ let RouteRelation = JSON.stringify(Routes.reduce((o, x, i) => (o[x] = relations[i], o), {}), null, 2)
20
+
21
+ Bun.write(
22
+ './source/entities/route-relation.js',
23
+ template
24
+ .replace('/* RouteRelations */', RouteRelations)
25
+ .replace('/* RouteRelation */', RouteRelation),
26
+ )
@@ -0,0 +1,25 @@
1
+ import template from './templates/route-service.js' with { type: 'text' }
2
+
3
+ import { Routes } from '../source/entities/route.js'
4
+ import { Segment } from '../source/entities/segment.js'
5
+
6
+ let config = [undefined, 2]
7
+
8
+ let services = Routes.map(route => Segment[route.split('/').at(0)].service)
9
+
10
+ let RouteServices = services.filter((x, i, a) => a.indexOf(x) === i)
11
+
12
+ let RouteService = Routes.reduce((o, x, i) => (o[x] = services[i], o), {})
13
+
14
+ let ServiceRoutes = Object
15
+ .entries(Object.groupBy(Object.entries(RouteService), ([, service]) => service))
16
+ .map(([service, pairs]) => [service, pairs.map(([route]) => route)])
17
+ .reduce((o, [s, r]) => (o[s] = r, o), {})
18
+
19
+ Bun.write(
20
+ './source/entities/route-service.js',
21
+ template
22
+ .replace('/* RouteServices */', JSON.stringify(RouteServices, ...config))
23
+ .replace('/* RouteService */', JSON.stringify(RouteService, ...config))
24
+ .replace('/* ServiceRoutes */', JSON.stringify(ServiceRoutes, ...config)),
25
+ )
@@ -0,0 +1,5 @@
1
+ /* --- AUTOGENERATED --- */
2
+
3
+ export const RouteCardinalities = Object.freeze( /** @type {const} */ (/* RouteCardinalities */))
4
+
5
+ export const RouteCardinality = Object.freeze(/** @type {const} */ (/* RouteCardinality */))
@@ -0,0 +1,5 @@
1
+ /* --- AUTOGENERATED --- */
2
+
3
+ export const RouteParameters = Object.freeze( /** @type {const} */ (/* RouteParameters */))
4
+
5
+ export const RouteParameter = Object.freeze(/** @type {const} */ (/* RouteParameter */))
@@ -0,0 +1,5 @@
1
+ /* --- AUTOGENERATED --- */
2
+
3
+ export const RoutePathnames = Object.freeze( /** @type {const} */ (/* RoutePathnames */))
4
+
5
+ export const RoutePathname = Object.freeze(/** @type {const} */ (/* RoutePathname */))
@@ -0,0 +1,5 @@
1
+ /* --- AUTOGENERATED --- */
2
+
3
+ export const RouteRelations = Object.freeze( /** @type {const} */ (/* RouteRelations */))
4
+
5
+ export const RouteRelation = Object.freeze(/** @type {const} */ (/* RouteRelation */))
@@ -0,0 +1,7 @@
1
+ /* --- AUTOGENERATED --- */
2
+
3
+ export const RouteServices = Object.freeze( /** @type {const} */ (/* RouteServices */))
4
+
5
+ export const RouteService = Object.freeze(/** @type {const} */ (/* RouteService */))
6
+
7
+ export const ServiceRoutes = Object.freeze(/** @type {const} */ (/* ServiceRoutes */))
@@ -1,8 +1,4 @@
1
1
  export const Cardinality = Object.freeze({
2
2
  '1': '1',
3
- '1-1': '1-1',
4
- '1-N': '1-N',
5
- 'N': 'N',
6
- 'N-1': 'N-1',
7
- 'N-N': 'N-N',
3
+ 'n': 'n',
8
4
  })
@@ -0,0 +1,41 @@
1
+ export const Keys = Object.freeze(
2
+ /** @type {const} */ ([
3
+ 'checkin',
4
+ 'user',
5
+ 'users',
6
+ 'role',
7
+ 'roles',
8
+ 'country',
9
+ 'countries',
10
+ 'currency',
11
+ 'currencies',
12
+ 'timezone',
13
+ 'timezones',
14
+ 'city',
15
+ 'cities',
16
+ 'venue',
17
+ 'venues',
18
+ 'theme',
19
+ 'themes',
20
+ 'cover',
21
+ 'game',
22
+ 'games',
23
+ 'registration',
24
+ 'registrations',
25
+ 'export',
26
+ 'password',
27
+ 'vk_group_token',
28
+ 'summary',
29
+ 'mailing',
30
+ 'channel',
31
+ 'confirmation',
32
+ 'cancellation',
33
+ ]),
34
+ )
35
+
36
+ export const Key = Object.freeze(
37
+ /** @type {{ [x in typeof Keys[number]]: x }} */ (Keys.reduce(
38
+ (o, x) => (o[x] = x, o),
39
+ {},
40
+ )),
41
+ )
@@ -1,67 +1,149 @@
1
- import { Cardinality } from './cardinality.js'
2
- import { Route } from './route.js'
1
+ /* --- AUTOGENERATED --- */
3
2
 
4
- export const RouteCardinality = Object.freeze({
5
- [Route['checkin']]: Cardinality['1'],
6
- [Route['cities']]: Cardinality['N'],
7
- [Route['cities/country']]: Cardinality['N-1'],
8
- [Route['cities/currency']]: Cardinality['N-1'],
9
- [Route['cities/timezone']]: Cardinality['N-1'],
10
- [Route['cities/venues']]: Cardinality['N-N'],
11
- [Route['city']]: Cardinality['1'],
12
- [Route['city/country']]: Cardinality['1-1'],
13
- [Route['city/currency']]: Cardinality['1-1'],
14
- [Route['city/timezone']]: Cardinality['1-1'],
15
- [Route['city/vk_group_token']]: Cardinality['1-1'],
16
- [Route['city/venue']]: Cardinality['1-1'],
17
- [Route['city/venues']]: Cardinality['1-N'],
18
- [Route['countries']]: Cardinality['N'],
19
- [Route['country']]: Cardinality['1'],
20
- [Route['currencies']]: Cardinality['N'],
21
- [Route['currency']]: Cardinality['1'],
22
- [Route['game']]: Cardinality['1'],
23
- [Route['game/city']]: Cardinality['1-1'],
24
- [Route['game/registration']]: Cardinality['1-1'],
25
- [Route['game/registrations']]: Cardinality['1-N'],
26
- [Route['game/registrations/export']]: Cardinality['1'],
27
- [Route['game/summary']]: Cardinality['1-1'],
28
- [Route['game/theme']]: Cardinality['1-1'],
29
- [Route['game/venue']]: Cardinality['1-1'],
30
- [Route['games']]: Cardinality['N'],
31
- [Route['games/city']]: Cardinality['N-1'],
32
- [Route['games/registrations']]: Cardinality['N-N'],
33
- [Route['games/registrations/export']]: Cardinality['1'],
34
- [Route['games/summary']]: Cardinality['N-1'],
35
- [Route['games/theme']]: Cardinality['N-1'],
36
- [Route['games/venue']]: Cardinality['N-1'],
37
- [Route['registration']]: Cardinality['1'],
38
- [Route['registration/city']]: Cardinality['1-1'],
39
- [Route['registration/game/theme']]: Cardinality['1-1'],
40
- [Route['registration/export']]: Cardinality['1'],
41
- [Route['registrations']]: Cardinality['N'],
42
- [Route['registrations/city']]: Cardinality['N-1'],
43
- [Route['registrations/game']]: Cardinality['N-1'],
44
- [Route['registrations/game/theme']]: Cardinality['N-1'],
45
- [Route['registrations/export']]: Cardinality['1'],
46
- [Route['role']]: Cardinality['1'],
47
- [Route['roles']]: Cardinality['N'],
48
- [Route['theme']]: Cardinality['1'],
49
- [Route['theme/cover']]: Cardinality['1-1'],
50
- [Route['themes']]: Cardinality['N'],
51
- [Route['themes/cover']]: Cardinality['N-1'],
52
- [Route['timezone']]: Cardinality['1'],
53
- [Route['timezones']]: Cardinality['N'],
54
- [Route['user']]: Cardinality['1'],
55
- [Route['user/cities']]: Cardinality['1-N'],
56
- [Route['user/city']]: Cardinality['1-1'],
57
- [Route['user/password']]: Cardinality['1-1'],
58
- [Route['user/role']]: Cardinality['1-1'],
59
- [Route['users']]: Cardinality['N'],
60
- [Route['users/cities']]: Cardinality['N-N'],
61
- [Route['users/role']]: Cardinality['N-1'],
62
- [Route['venue']]: Cardinality['1'],
63
- [Route['venue/city']]: Cardinality['1-1'],
64
- [Route['venues']]: Cardinality['N'],
65
- [Route['venues/city']]: Cardinality['N-1'],
66
- })
3
+ export const RouteCardinalities = Object.freeze( /** @type {const} */ ([
4
+ "1",
5
+ "n",
6
+ "1",
7
+ "1/1",
8
+ "1/1",
9
+ "1/1",
10
+ "1/n",
11
+ "n",
12
+ "n/1",
13
+ "n/1",
14
+ "n/n",
15
+ "1",
16
+ "n",
17
+ "n/1",
18
+ "n/1",
19
+ "n/1",
20
+ "n/n",
21
+ "1",
22
+ "1/1",
23
+ "1/1",
24
+ "1/1",
25
+ "1/1",
26
+ "1/1",
27
+ "1/n",
28
+ "1",
29
+ "n",
30
+ "1",
31
+ "n",
32
+ "1",
33
+ "n",
34
+ "1",
35
+ "1/1",
36
+ "n",
37
+ "n/1",
38
+ "1",
39
+ "1/1",
40
+ "n",
41
+ "n/1",
42
+ "n/n",
43
+ "1",
44
+ "1/1",
45
+ "1/1",
46
+ "1/n",
47
+ "1/1",
48
+ "1/1",
49
+ "1/1",
50
+ "1/1",
51
+ "1/1",
52
+ "n",
53
+ "n/1",
54
+ "n/n",
55
+ "n/1",
56
+ "n/1",
57
+ "n/1",
58
+ "n/1",
59
+ "n/1",
60
+ "1",
61
+ "1/1",
62
+ "1/1",
63
+ "1/1",
64
+ "1/1",
65
+ "1/1",
66
+ "1/1",
67
+ "1/1",
68
+ "1/1",
69
+ "1/1",
70
+ "n",
71
+ "n/1",
72
+ "n/1",
73
+ "n/1",
74
+ "n/1"
75
+ ]))
67
76
 
77
+ export const RouteCardinality = Object.freeze(/** @type {const} */ ({
78
+ "role": "1",
79
+ "roles": "n",
80
+ "user": "1",
81
+ "user/password": "1/1",
82
+ "user/role": "1/1",
83
+ "user/city": "1/1",
84
+ "user/cities": "1/n",
85
+ "users": "n",
86
+ "users/password": "n/1",
87
+ "users/role": "n/1",
88
+ "users/cities": "n/n",
89
+ "checkin": "1",
90
+ "cities": "n",
91
+ "cities/country": "n/1",
92
+ "cities/currency": "n/1",
93
+ "cities/timezone": "n/1",
94
+ "cities/venues": "n/n",
95
+ "city": "1",
96
+ "city/vk_group_token": "1/1",
97
+ "city/country": "1/1",
98
+ "city/currency": "1/1",
99
+ "city/timezone": "1/1",
100
+ "city/venue": "1/1",
101
+ "city/venues": "1/n",
102
+ "country": "1",
103
+ "countries": "n",
104
+ "currency": "1",
105
+ "currencies": "n",
106
+ "timezone": "1",
107
+ "timezones": "n",
108
+ "venue": "1",
109
+ "venue/city": "1/1",
110
+ "venues": "n",
111
+ "venues/city": "n/1",
112
+ "theme": "1",
113
+ "theme/cover": "1/1",
114
+ "themes": "n",
115
+ "themes/cover": "n/1",
116
+ "themes/games": "n/n",
117
+ "game": "1",
118
+ "game/city": "1/1",
119
+ "game/registration": "1/1",
120
+ "game/registrations": "1/n",
121
+ "game/registrations/export": "1/1",
122
+ "game/summary": "1/1",
123
+ "game/theme": "1/1",
124
+ "game/theme/cover": "1/1",
125
+ "game/venue": "1/1",
126
+ "games": "n",
127
+ "games/city": "n/1",
128
+ "games/registrations": "n/n",
129
+ "games/registrations/export": "n/1",
130
+ "games/summary": "n/1",
131
+ "games/theme": "n/1",
132
+ "games/theme/cover": "n/1",
133
+ "games/venue": "n/1",
134
+ "registration": "1",
135
+ "registration/cancellation": "1/1",
136
+ "registration/channel": "1/1",
137
+ "registration/confirmation": "1/1",
138
+ "registration/export": "1/1",
139
+ "registration/city": "1/1",
140
+ "registration/game": "1/1",
141
+ "registration/game/theme": "1/1",
142
+ "registration/game/theme/cover": "1/1",
143
+ "registration/mailing": "1/1",
144
+ "registrations": "n",
145
+ "registrations/city": "n/1",
146
+ "registrations/game": "n/1",
147
+ "registrations/game/theme": "n/1",
148
+ "registrations/export": "n/1"
149
+ }))
@@ -0,0 +1,149 @@
1
+ /* --- AUTOGENERATED --- */
2
+
3
+ export const RouteParameters = Object.freeze( /** @type {const} */ ([
4
+ ":role",
5
+ "",
6
+ ":user",
7
+ ":user/:password",
8
+ ":user/:role",
9
+ ":user/:city",
10
+ ":user",
11
+ "",
12
+ ":password",
13
+ ":role",
14
+ "",
15
+ ":checkin",
16
+ "",
17
+ ":country",
18
+ ":currency",
19
+ ":timezone",
20
+ "",
21
+ ":city",
22
+ ":city/:vk_group_token",
23
+ ":city/:country",
24
+ ":city/:currency",
25
+ ":city/:timezone",
26
+ ":city/:venue",
27
+ ":city",
28
+ ":country",
29
+ "",
30
+ ":currency",
31
+ "",
32
+ ":timezone",
33
+ "",
34
+ ":venue",
35
+ ":venue/:city",
36
+ "",
37
+ ":city",
38
+ ":theme",
39
+ ":theme/:cover",
40
+ "",
41
+ ":cover",
42
+ "",
43
+ ":game",
44
+ ":game/:city",
45
+ ":game/:registration",
46
+ ":game",
47
+ ":game/:export",
48
+ ":game/:summary",
49
+ ":game/:theme",
50
+ ":game/:theme/:cover",
51
+ ":game/:venue",
52
+ "",
53
+ ":city",
54
+ "",
55
+ ":export",
56
+ ":summary",
57
+ ":theme",
58
+ ":theme/:cover",
59
+ ":venue",
60
+ ":registration",
61
+ ":registration/:cancellation",
62
+ ":registration/:channel",
63
+ ":registration/:confirmation",
64
+ ":registration/:export",
65
+ ":registration/:city",
66
+ ":registration/:game",
67
+ ":registration/:game/:theme",
68
+ ":registration/:game/:theme/:cover",
69
+ ":registration/:mailing",
70
+ "",
71
+ ":city",
72
+ ":game",
73
+ ":game/:theme",
74
+ ":export"
75
+ ]))
76
+
77
+ export const RouteParameter = Object.freeze(/** @type {const} */ ({
78
+ "role": ":role",
79
+ "roles": "",
80
+ "user": ":user",
81
+ "user/password": ":user/:password",
82
+ "user/role": ":user/:role",
83
+ "user/city": ":user/:city",
84
+ "user/cities": ":user",
85
+ "users": "",
86
+ "users/password": ":password",
87
+ "users/role": ":role",
88
+ "users/cities": "",
89
+ "checkin": ":checkin",
90
+ "cities": "",
91
+ "cities/country": ":country",
92
+ "cities/currency": ":currency",
93
+ "cities/timezone": ":timezone",
94
+ "cities/venues": "",
95
+ "city": ":city",
96
+ "city/vk_group_token": ":city/:vk_group_token",
97
+ "city/country": ":city/:country",
98
+ "city/currency": ":city/:currency",
99
+ "city/timezone": ":city/:timezone",
100
+ "city/venue": ":city/:venue",
101
+ "city/venues": ":city",
102
+ "country": ":country",
103
+ "countries": "",
104
+ "currency": ":currency",
105
+ "currencies": "",
106
+ "timezone": ":timezone",
107
+ "timezones": "",
108
+ "venue": ":venue",
109
+ "venue/city": ":venue/:city",
110
+ "venues": "",
111
+ "venues/city": ":city",
112
+ "theme": ":theme",
113
+ "theme/cover": ":theme/:cover",
114
+ "themes": "",
115
+ "themes/cover": ":cover",
116
+ "themes/games": "",
117
+ "game": ":game",
118
+ "game/city": ":game/:city",
119
+ "game/registration": ":game/:registration",
120
+ "game/registrations": ":game",
121
+ "game/registrations/export": ":game/:export",
122
+ "game/summary": ":game/:summary",
123
+ "game/theme": ":game/:theme",
124
+ "game/theme/cover": ":game/:theme/:cover",
125
+ "game/venue": ":game/:venue",
126
+ "games": "",
127
+ "games/city": ":city",
128
+ "games/registrations": "",
129
+ "games/registrations/export": ":export",
130
+ "games/summary": ":summary",
131
+ "games/theme": ":theme",
132
+ "games/theme/cover": ":theme/:cover",
133
+ "games/venue": ":venue",
134
+ "registration": ":registration",
135
+ "registration/cancellation": ":registration/:cancellation",
136
+ "registration/channel": ":registration/:channel",
137
+ "registration/confirmation": ":registration/:confirmation",
138
+ "registration/export": ":registration/:export",
139
+ "registration/city": ":registration/:city",
140
+ "registration/game": ":registration/:game",
141
+ "registration/game/theme": ":registration/:game/:theme",
142
+ "registration/game/theme/cover": ":registration/:game/:theme/:cover",
143
+ "registration/mailing": ":registration/:mailing",
144
+ "registrations": "",
145
+ "registrations/city": ":city",
146
+ "registrations/game": ":game",
147
+ "registrations/game/theme": ":game/:theme",
148
+ "registrations/export": ":export"
149
+ }))