Skip to content

Commit e7fc5dc

Browse files
authored
Register the participants service and its routes (#145)
The `participants` service of shaker-quiz/services#510 is not known to the package yet, so `url()` cannot address it and its routes cannot be named through `routePathname`. Participants joins `Service` and `ServiceRuntime` (a Bun service, like the other backend ones), the `participant` and `participants` segments are added, and the four routes of the service are declared: | route | pathname | |---|---| | `participant` | `participant/:participant` | | `participant/channel` | `participant/:participant/channel/:channel` | | `participant/mailing` | `participant/:participant/mailing/:mailing` | | `participants/channel/mailing/message` | `participants/channel/:channel/mailing/:mailing/message/:message` | These pathnames are the ones the service serves today from its own `route-pathname.js`, which it can drop once it depends on this version. Here `channel` is the kind of the channel (`vkontakte`, `telegram` or `email`), and `mailing` and `message` are ids. To build them the `channel`, `mailing` and `message` segments take a parameter: `mailing` and `message` a uuid, `channel` a word. They had none, and a segment gets its `:param` in the pathname only when it has a pattern, so seven routes that already contain them change their pathname: - `registration/channel`: `registration/:registration/channel` becomes `registration/:registration/channel/:channel` - `chatapp/registration/channel`: the same with the `chatapp/` prefix - `chatapp/registrations/channel`: `chatapp/registrations/channel` becomes `chatapp/registrations/channel/:channel` - `telegram/registration/mailing`: `…/:registration/mailing` becomes `…/:registration/mailing/:mailing` - `chatapp/registration/mailing`: the same with the `chatapp/` prefix - `telegram/registrations/mailing` and `chatapp/registrations/mailing`: `…/mailing` becomes `…/mailing/:mailing` Nothing breaks until a consumer bumps the package, as the services and the frontends pin it exactly, but the registrations, updates, hub and landing code that names these routes will need to follow when it does. The generated `source/codegen/autogenerated.js` is left to the publish workflow, as in the other changes. The `url` package gets its `source/participants` from this version through the same cascade.
2 parents cfa6087 + bfc8b37 commit e7fc5dc

4 files changed

Lines changed: 27 additions & 3 deletions

File tree

‎source/entities/routes.js‎

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -95,6 +95,10 @@ export const Route = /** @type {const} */ ({
9595
'registrations/game/status/search': 'registrations/game/status/search',
9696
'registrations/game/theme/search': 'registrations/game/theme/search',
9797
'registrations/game/venue/search': 'registrations/game/venue/search',
98+
'participant': 'participant',
99+
'participant/channel': 'participant/channel',
100+
'participant/mailing': 'participant/mailing',
101+
'participants/channel/mailing/message': 'participants/channel/mailing/message',
98102
'telegram/webhook': 'telegram/webhook',
99103
'telegram/registration': 'telegram/registration',
100104
'telegram/registration/lineup': 'telegram/registration/lineup',

‎source/entities/segment.js‎

Lines changed: 21 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -218,6 +218,24 @@ export const Segments = /** @type {const} */ ([
218218
pattern: null,
219219
kind: 'Entity',
220220
}),
221+
/** @type {const} */ ({
222+
key: 'participant',
223+
cardinality: '1',
224+
singular: 'participant',
225+
plural: 'participants',
226+
service: Service.Participants,
227+
pattern: Pattern.UUID.source,
228+
kind: 'Entity',
229+
}),
230+
/** @type {const} */ ({
231+
key: 'participants',
232+
cardinality: 'n',
233+
singular: 'participant',
234+
plural: 'participants',
235+
service: Service.Participants,
236+
pattern: null,
237+
kind: 'Entity',
238+
}),
221239
/** @type {const} */ ({
222240
key: 'status',
223241
cardinality: '1',
@@ -566,7 +584,7 @@ export const Segments = /** @type {const} */ ([
566584
singular: 'mailing',
567585
plural: 'mailings',
568586
service: null,
569-
pattern: null,
587+
pattern: Pattern.UUID.source,
570588
kind: 'Entity',
571589
}),
572590
/** @type {const} */ ({
@@ -575,7 +593,7 @@ export const Segments = /** @type {const} */ ([
575593
singular: 'message',
576594
plural: 'messages',
577595
service: null,
578-
pattern: null,
596+
pattern: Pattern.UUID.source,
579597
kind: 'Entity',
580598
}),
581599
/** @type {const} */ ({
@@ -584,7 +602,7 @@ export const Segments = /** @type {const} */ ([
584602
singular: 'channel',
585603
plural: 'channels',
586604
service: null,
587-
pattern: null,
605+
pattern: Pattern.STRING.source,
588606
kind: 'Property',
589607
}),
590608
/** @type {const} */ ({

‎source/entities/service-runtime.js‎

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -12,6 +12,7 @@ export let ServiceRuntime = {
1212
[Service.Themes]: Runtime.Bun,
1313
[Service.Games]: Runtime.Bun,
1414
[Service.Registrations]: Runtime.Bun,
15+
[Service.Participants]: Runtime.Bun,
1516
[Service.Procedures]: Runtime.Bun,
1617
[Service.Updates]: Runtime.Bun,
1718
[Service.Hub]: Runtime.Next,

‎source/entities/services.js‎

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -8,6 +8,7 @@ export let Service = /** @type {const} */ ({
88
Themes: 'Themes',
99
Games: 'Games',
1010
Registrations: 'Registrations',
11+
Participants: 'Participants',
1112
Procedures: 'Procedures',
1213
Updates: 'Updates',
1314
Hub: 'Hub',

0 commit comments

Comments
 (0)