@bgord/bun 1.4.20 → 1.4.21
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/dist/modules/preferences/command-handlers/handleSetUserLanguageCommand.d.ts +7 -1
- package/dist/modules/preferences/command-handlers/handleSetUserLanguageCommand.d.ts.map +1 -1
- package/dist/modules/preferences/command-handlers/handleSetUserLanguageCommand.js +4 -4
- package/dist/modules/preferences/command-handlers/handleSetUserLanguageCommand.js.map +1 -1
- package/dist/tsconfig.tsbuildinfo +1 -1
- package/package.json +1 -1
- package/src/modules/preferences/command-handlers/handleSetUserLanguageCommand.ts +11 -10
package/package.json
CHANGED
|
@@ -9,27 +9,28 @@ import * as Invariants from "../invariants";
|
|
|
9
9
|
import type * as Ports from "../ports";
|
|
10
10
|
import type * as VO from "../value-objects";
|
|
11
11
|
|
|
12
|
+
type Dependencies = {
|
|
13
|
+
EventStore: EventStoreLike<AcceptedEvent>;
|
|
14
|
+
IdProvider: IdProviderPort;
|
|
15
|
+
Clock: ClockPort;
|
|
16
|
+
UserLanguageQuery: Ports.UserLanguageQueryPort;
|
|
17
|
+
};
|
|
18
|
+
|
|
12
19
|
type AcceptedEvent = Events.UserLanguageSetEventType;
|
|
13
20
|
|
|
14
21
|
export const handleSetUserLanguageCommand =
|
|
15
|
-
<L extends readonly tools.LanguageType[]>(
|
|
16
|
-
EventStore: EventStoreLike<AcceptedEvent>,
|
|
17
|
-
IdProvider: IdProviderPort,
|
|
18
|
-
Clock: ClockPort,
|
|
19
|
-
query: Ports.UserLanguageQueryPort,
|
|
20
|
-
supported: VO.SupportedLanguagesSet<L>,
|
|
21
|
-
) =>
|
|
22
|
+
<L extends readonly tools.LanguageType[]>(supported: VO.SupportedLanguagesSet<L>, deps: Dependencies) =>
|
|
22
23
|
async (command: Commands.SetUserLanguageCommandType) => {
|
|
23
24
|
const candidate = supported.ensure(command.payload.language);
|
|
24
|
-
const current = await
|
|
25
|
+
const current = await deps.UserLanguageQuery.get(command.payload.userId);
|
|
25
26
|
|
|
26
27
|
if (Invariants.UserLanguageHasChanged.fails({ current, candidate: command.payload.language })) return;
|
|
27
28
|
|
|
28
29
|
const event = Events.UserLanguageSetEvent.parse({
|
|
29
|
-
...createEventEnvelope(`preferences_${command.payload.userId}`,
|
|
30
|
+
...createEventEnvelope(`preferences_${command.payload.userId}`, deps),
|
|
30
31
|
name: Events.USER_LANGUAGE_SET_EVENT,
|
|
31
32
|
payload: { userId: command.payload.userId, language: candidate },
|
|
32
33
|
} satisfies Events.UserLanguageSetEventType);
|
|
33
34
|
|
|
34
|
-
await EventStore.save([event]);
|
|
35
|
+
await deps.EventStore.save([event]);
|
|
35
36
|
};
|