@shakerquiz/utilities 4.0.2 → 4.0.4

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/package.json CHANGED
@@ -1,7 +1,7 @@
1
1
  {
2
2
  "type": "module",
3
3
  "name": "@shakerquiz/utilities",
4
- "version": "4.0.2",
4
+ "version": "4.0.4",
5
5
  "author": "yurkimus <yurkimus@gmail.com>",
6
6
  "license": "ISC",
7
7
  "repository": {
@@ -74,6 +74,12 @@ export const Route = Object.freeze(
74
74
  'registrations/game': 'registrations/game',
75
75
  'registrations/game/theme': 'registrations/game/theme',
76
76
  'registrations/export': 'registrations/export',
77
+ 'telegram/webhook': 'telegram/webhook',
78
+ 'telegram/registration/mailing': 'telegram/registration/mailing',
79
+ 'chatapp/webhook': 'chatapp/webhook',
80
+ 'chatapp/registration': 'chatapp/registration',
81
+ 'chatapp/registration/mailing': 'chatapp/registration/mailing',
82
+ 'bitrix/registration': 'bitrix/registration',
77
83
  }),
78
84
  )
79
85
 
@@ -151,6 +157,12 @@ export const RouteCardinality = Object.freeze(
151
157
  'registrations/game': 'n/1',
152
158
  'registrations/game/theme': 'n/1',
153
159
  'registrations/export': 'n/1',
160
+ 'telegram/webhook': '1/1',
161
+ 'telegram/registration/mailing': '1/1',
162
+ 'chatapp/webhook': '1/1',
163
+ 'chatapp/registration': '1/1',
164
+ 'chatapp/registration/mailing': '1/1',
165
+ 'bitrix/registration': '1/1',
154
166
  }),
155
167
  )
156
168
 
@@ -228,6 +240,12 @@ export const RoutePathname = Object.freeze(
228
240
  'registrations/game': 'registrations/game/:game',
229
241
  'registrations/game/theme': 'registrations/game/:game/theme/:theme',
230
242
  'registrations/export': 'registrations/export',
243
+ 'telegram/webhook': 'telegram/webhook',
244
+ 'telegram/registration/mailing': 'telegram/registration/:registration/mailing',
245
+ 'chatapp/webhook': 'chatapp/webhook',
246
+ 'chatapp/registration': 'chatapp/registration/:registration',
247
+ 'chatapp/registration/mailing': 'chatapp/registration/:registration/mailing',
248
+ 'bitrix/registration': 'bitrix/registration/:registration',
231
249
  }),
232
250
  )
233
251
 
@@ -305,6 +323,12 @@ export const PathnameRoute = Object.freeze(
305
323
  'registrations/game/:game': 'registrations/game',
306
324
  'registrations/game/:game/theme/:theme': 'registrations/game/theme',
307
325
  'registrations/export': 'registrations/export',
326
+ 'telegram/webhook': 'telegram/webhook',
327
+ 'telegram/registration/:registration/mailing': 'telegram/registration/mailing',
328
+ 'chatapp/webhook': 'chatapp/webhook',
329
+ 'chatapp/registration/:registration': 'chatapp/registration',
330
+ 'chatapp/registration/:registration/mailing': 'chatapp/registration/mailing',
331
+ 'bitrix/registration/:registration': 'bitrix/registration',
308
332
  }),
309
333
  )
310
334
 
@@ -513,6 +537,20 @@ export const PathnameParameters = Object.freeze(
513
537
  ':theme',
514
538
  ],
515
539
  'registrations/export': [],
540
+ 'telegram/webhook': [],
541
+ 'telegram/registration/:registration/mailing': [
542
+ ':registration',
543
+ ],
544
+ 'chatapp/webhook': [],
545
+ 'chatapp/registration/:registration': [
546
+ ':registration',
547
+ ],
548
+ 'chatapp/registration/:registration/mailing': [
549
+ ':registration',
550
+ ],
551
+ 'bitrix/registration/:registration': [
552
+ ':registration',
553
+ ],
516
554
  }),
517
555
  )
518
556
 
@@ -606,6 +644,12 @@ export const RouteBreakdown = Object.freeze(
606
644
  'registrations/game': 'registration/game',
607
645
  'registrations/game/theme': 'registration/game/theme',
608
646
  'registrations/export': 'registration/export',
647
+ 'telegram/webhook': 'telegram/webhook',
648
+ 'telegram/registration/mailing': 'telegram/registration/mailing',
649
+ 'chatapp/webhook': 'chatapp/webhook',
650
+ 'chatapp/registration': 'chatapp/registration',
651
+ 'chatapp/registration/mailing': 'chatapp/registration/mailing',
652
+ 'bitrix/registration': 'bitrix/registration',
609
653
  }),
610
654
  )
611
655
 
@@ -683,6 +727,12 @@ export const RouteService = Object.freeze(
683
727
  'registrations/game': 'Registrations',
684
728
  'registrations/game/theme': 'Registrations',
685
729
  'registrations/export': 'Registrations',
730
+ 'telegram/webhook': 'Telegram',
731
+ 'telegram/registration/mailing': 'Telegram',
732
+ 'chatapp/webhook': 'Chatapp',
733
+ 'chatapp/registration': 'Chatapp',
734
+ 'chatapp/registration/mailing': 'Chatapp',
735
+ 'bitrix/registration': 'Bitrix',
686
736
  }),
687
737
  )
688
738
 
@@ -778,5 +828,17 @@ export const ServiceRoutes = Object.freeze(
778
828
  'registrations/game/theme',
779
829
  'registrations/export',
780
830
  ],
831
+ 'Telegram': [
832
+ 'telegram/webhook',
833
+ 'telegram/registration/mailing',
834
+ ],
835
+ 'Chatapp': [
836
+ 'chatapp/webhook',
837
+ 'chatapp/registration',
838
+ 'chatapp/registration/mailing',
839
+ ],
840
+ 'Bitrix': [
841
+ 'bitrix/registration',
842
+ ],
781
843
  }),
782
844
  )
@@ -30,6 +30,10 @@ export const Keys = Object.freeze(
30
30
  'channel',
31
31
  'confirmation',
32
32
  'cancellation',
33
+ 'telegram',
34
+ 'chatapp',
35
+ 'bitrix',
36
+ 'webhook',
33
37
  ]),
34
38
  )
35
39
 
@@ -72,5 +72,11 @@ export const Routes = Object.freeze(
72
72
  'registrations/game',
73
73
  'registrations/game/theme',
74
74
  'registrations/export',
75
+ 'telegram/webhook',
76
+ 'telegram/registration/mailing',
77
+ 'chatapp/webhook',
78
+ 'chatapp/registration',
79
+ 'chatapp/registration/mailing',
80
+ 'bitrix/registration',
75
81
  ]),
76
82
  )
@@ -274,6 +274,42 @@ export const Segments = Object.freeze(
274
274
  pattern: undefined,
275
275
  }),
276
276
  ),
277
+ Object.freeze(
278
+ /** @type {const} */ ({
279
+ key: Key['telegram'],
280
+ cardinality: '1',
281
+ relation: undefined,
282
+ service: Service['Telegram'],
283
+ pattern: undefined,
284
+ }),
285
+ ),
286
+ Object.freeze(
287
+ /** @type {const} */ ({
288
+ key: Key['chatapp'],
289
+ cardinality: '1',
290
+ relation: undefined,
291
+ service: Service['Chatapp'],
292
+ pattern: undefined,
293
+ }),
294
+ ),
295
+ Object.freeze(
296
+ /** @type {const} */ ({
297
+ key: Key['bitrix'],
298
+ cardinality: '1',
299
+ relation: undefined,
300
+ service: Service['Bitrix'],
301
+ pattern: undefined,
302
+ }),
303
+ ),
304
+ Object.freeze(
305
+ /** @type {const} */ ({
306
+ key: Key['webhook'],
307
+ cardinality: '1',
308
+ relation: undefined,
309
+ service: undefined,
310
+ pattern: undefined,
311
+ }),
312
+ ),
277
313
  ]),
278
314
  )
279
315
 
@@ -18,6 +18,9 @@ export const Services = Object.freeze(
18
18
  'Telegram',
19
19
  'Vkma',
20
20
  'Minio',
21
+ 'Telegram',
22
+ 'Chatapp',
23
+ 'Bitrix',
21
24
  ]),
22
25
  )
23
26
 
@@ -1,4 +1,4 @@
1
- import { ParameterPattern, PathnameParameters, Route, RoutePathname } from '../codegen/autogenerated.js'
1
+ import { PathnameParameters, Route, RoutePathname } from '../codegen/autogenerated.js'
2
2
  import { access } from './access.js'
3
3
 
4
4
  /**
@@ -24,27 +24,3 @@ export const hydrateRoutePathname = (maybeRoute, maybeParams) => {
24
24
  ? pathname.replace(parameter, maybeParams[index])
25
25
  : pathname, pathname)
26
26
  }
27
-
28
- /**
29
- * @template {keyof typeof import('@shakerquiz/utilities').Route} R
30
- *
31
- * @param {R} maybeRoute
32
- * @param {any[]} maybeParams
33
- *
34
- * @returns {typeof import('@shakerquiz/utilities').RoutePathname[R]}
35
- */
36
- export const parametrizeRoutePathname = (maybeRoute, maybeParams) => {
37
- if (!Array.isArray(maybeParams))
38
- throw TypeError(`Parameter 'params' must be 'Array'.`)
39
-
40
- var route = access(Route, maybeRoute)
41
-
42
- var pathname = access(RoutePathname, route)
43
-
44
- var pathnameParameters = access(PathnameParameters, pathname)
45
-
46
- return pathnameParameters.reduce((pathname, parameter, index) =>
47
- Object.hasOwn(maybeParams, index)
48
- ? pathname.replace(parameter, maybeParams[index])
49
- : pathname.replace(parameter, access(ParameterPattern, parameter)), pathname)
50
- }
@@ -1,7 +1,7 @@
1
1
  import { Method } from '../entities/method.js'
2
2
 
3
3
  import { access } from './access.js'
4
- import { hydrateRoutePathname, parametrizeRoutePathname } from './route-pathname.js'
4
+ import { hydrateRoutePathname } from './route-pathname.js'
5
5
 
6
6
  /**
7
7
  * @template {keyof typeof import('@shakerquiz/utilities').Method} M
@@ -26,29 +26,6 @@ export const tag = (maybeMethod, maybeRoute, maybeParams) => {
26
26
  return method + '/' + hydrateRoutePathname(maybeRoute, maybeParams)
27
27
  }
28
28
 
29
- /**
30
- * @template {keyof typeof import('@shakerquiz/utilities').Method} M
31
- * @template {keyof typeof import('@shakerquiz/utilities').Route} R
32
- *
33
- * @param {M} maybeMethod
34
- * @param {R} maybeRoute
35
- * @param {any[]} maybeParams
36
- *
37
- * @returns {`${M}/${ReturnType<typeof parametrizeRoutePathname<R>>}`}
38
- *
39
- * @example
40
- * tagplate('GET', 'cities', []) // => 'GET/cities'
41
- *
42
- * tagplate('GET', 'game/theme/cover', ['<g>']) // => 'GET/game/<g>/theme/<related pattern>/<related pattern>'
43
- *
44
- * tagplate('POST', 'city', []) // => 'POST/city/<related pattern>'
45
- */
46
- export const tagplate = (maybeMethod, maybeRoute, maybeParams) => {
47
- var method = access(Method, maybeMethod)
48
-
49
- return method + '/' + parametrizeRoutePathname(maybeRoute, maybeParams)
50
- }
51
-
52
29
  /**
53
30
  * @template {keyof typeof import('@shakerquiz/utilities').Method} M
54
31
  * @template {keyof typeof import('@shakerquiz/utilities').Route} R
@@ -58,4 +35,4 @@ export const tagplate = (maybeMethod, maybeRoute, maybeParams) => {
58
35
  * @param {any[]} maybeParams
59
36
  */
60
37
  export const tagexp = (maybeMethod, maybeRoute, maybeParams) =>
61
- new RegExp(`^${tagplate(maybeMethod, maybeRoute, maybeParams)}$`)
38
+ new RegExp(`^${tag(maybeMethod, maybeRoute, maybeParams)}$`)