@kuckit/application 1.0.2 → 2.0.0
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/create-user-DFzpTkKR.js +34 -0
- package/dist/create-user-DFzpTkKR.js.map +1 -0
- package/dist/create-user-Tx0hVNQH.d.ts +31 -0
- package/dist/events/index.d.ts +2 -0
- package/dist/events/index.js +3 -0
- package/dist/events-CBFE7GCV.js +1 -0
- package/dist/get-user-profile-RYU3DyqZ.js +19 -0
- package/dist/get-user-profile-RYU3DyqZ.js.map +1 -0
- package/dist/get-user-profile-a0C2QG0r.d.ts +28 -0
- package/dist/index-BoGG5KAY.d.ts +1 -0
- package/dist/index-C8MjPjfD.d.ts +2 -0
- package/dist/index-C_7znSwG.d.ts +2 -0
- package/dist/index.d.ts +7 -78
- package/dist/index.js +6 -75
- package/dist/ports/index.d.ts +2 -0
- package/dist/ports/index.js +3 -0
- package/dist/ports-CBEzGE5T.js +1 -0
- package/dist/update-user-profile-7E9Zd_ap.js +29 -0
- package/dist/update-user-profile-7E9Zd_ap.js.map +1 -0
- package/dist/update-user-profile-8aqagn6Z.d.ts +34 -0
- package/dist/usecases/create-user.d.ts +2 -0
- package/dist/usecases/create-user.js +3 -0
- package/dist/usecases/get-user-profile.d.ts +2 -0
- package/dist/usecases/get-user-profile.js +3 -0
- package/dist/usecases/index.d.ts +5 -0
- package/dist/usecases/index.js +6 -0
- package/dist/usecases/update-user-profile.d.ts +2 -0
- package/dist/usecases/update-user-profile.js +3 -0
- package/dist/usecases-B1DG2fBy.js +1 -0
- package/package.json +2 -2
|
@@ -0,0 +1,34 @@
|
|
|
1
|
+
import { randomUUID } from "crypto";
|
|
2
|
+
|
|
3
|
+
//#region src/usecases/create-user.ts
|
|
4
|
+
/**
|
|
5
|
+
* Use case: Create user
|
|
6
|
+
* Publishes 'user.created' event after successful creation
|
|
7
|
+
*/
|
|
8
|
+
const makeCreateUser = (deps) => {
|
|
9
|
+
return async (input) => {
|
|
10
|
+
if (await deps.userRepository.findByEmail(input.email)) throw new Error("USER_ALREADY_EXISTS");
|
|
11
|
+
const now = deps.clock.now();
|
|
12
|
+
const newUser = {
|
|
13
|
+
id: randomUUID(),
|
|
14
|
+
name: input.name,
|
|
15
|
+
email: input.email,
|
|
16
|
+
emailVerified: input.emailVerified,
|
|
17
|
+
permissions: ["modules:read"],
|
|
18
|
+
createdAt: now,
|
|
19
|
+
updatedAt: now
|
|
20
|
+
};
|
|
21
|
+
await deps.userRepository.save(newUser);
|
|
22
|
+
await deps.eventPublisher.publish("user.created", {
|
|
23
|
+
userId: newUser.id,
|
|
24
|
+
email: newUser.email,
|
|
25
|
+
name: newUser.name,
|
|
26
|
+
createdAt: newUser.createdAt
|
|
27
|
+
}, newUser.id);
|
|
28
|
+
return newUser;
|
|
29
|
+
};
|
|
30
|
+
};
|
|
31
|
+
|
|
32
|
+
//#endregion
|
|
33
|
+
export { makeCreateUser as t };
|
|
34
|
+
//# sourceMappingURL=create-user-DFzpTkKR.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"create-user-DFzpTkKR.js","names":["newUser: User"],"sources":["../src/usecases/create-user.ts"],"sourcesContent":["import type { UserRepository } from '@kuckit/domain/ports/user-repository'\nimport type { EventPublisher } from '@kuckit/domain/ports/event-publisher'\nimport type { Clock } from '@kuckit/domain/ports/clock'\nimport type { User } from '@kuckit/domain/entities/user'\nimport { randomUUID } from 'crypto'\n\n/**\n * Dependencies required by the use case\n */\nexport interface CreateUserDeps {\n\treadonly userRepository: UserRepository\n\treadonly eventPublisher: EventPublisher\n\treadonly clock: Clock\n}\n\n/**\n * Input for the use case\n */\nexport interface CreateUserInput {\n\treadonly name: string\n\treadonly email: string\n\treadonly emailVerified: boolean\n}\n\n/**\n * Use case: Create user\n * Publishes 'user.created' event after successful creation\n */\nexport const makeCreateUser = (deps: CreateUserDeps) => {\n\treturn async (input: CreateUserInput): Promise<User> => {\n\t\t// Check if user already exists by email\n\t\tconst existingUser = await deps.userRepository.findByEmail(input.email)\n\n\t\tif (existingUser) {\n\t\t\tthrow new Error('USER_ALREADY_EXISTS')\n\t\t}\n\n\t\t// Create new user entity\n\t\tconst now = deps.clock.now()\n\t\tconst newUser: User = {\n\t\t\tid: randomUUID(),\n\t\t\tname: input.name,\n\t\t\temail: input.email,\n\t\t\temailVerified: input.emailVerified,\n\t\t\tpermissions: ['modules:read'],\n\t\t\tcreatedAt: now,\n\t\t\tupdatedAt: now,\n\t\t}\n\n\t\t// Save to repository\n\t\tawait deps.userRepository.save(newUser)\n\n\t\t// Publish event\n\t\tawait deps.eventPublisher.publish(\n\t\t\t'user.created',\n\t\t\t{\n\t\t\t\tuserId: newUser.id,\n\t\t\t\temail: newUser.email,\n\t\t\t\tname: newUser.name,\n\t\t\t\tcreatedAt: newUser.createdAt,\n\t\t\t},\n\t\t\tnewUser.id\n\t\t)\n\n\t\treturn newUser\n\t}\n}\n"],"mappings":";;;;;;;AA4BA,MAAa,kBAAkB,SAAyB;AACvD,QAAO,OAAO,UAA0C;AAIvD,MAFqB,MAAM,KAAK,eAAe,YAAY,MAAM,MAAM,CAGtE,OAAM,IAAI,MAAM,sBAAsB;EAIvC,MAAM,MAAM,KAAK,MAAM,KAAK;EAC5B,MAAMA,UAAgB;GACrB,IAAI,YAAY;GAChB,MAAM,MAAM;GACZ,OAAO,MAAM;GACb,eAAe,MAAM;GACrB,aAAa,CAAC,eAAe;GAC7B,WAAW;GACX,WAAW;GACX;AAGD,QAAM,KAAK,eAAe,KAAK,QAAQ;AAGvC,QAAM,KAAK,eAAe,QACzB,gBACA;GACC,QAAQ,QAAQ;GAChB,OAAO,QAAQ;GACf,MAAM,QAAQ;GACd,WAAW,QAAQ;GACnB,EACD,QAAQ,GACR;AAED,SAAO"}
|
|
@@ -0,0 +1,31 @@
|
|
|
1
|
+
import { UserRepository } from "@kuckit/domain/ports/user-repository";
|
|
2
|
+
import { User } from "@kuckit/domain/entities/user";
|
|
3
|
+
import { EventPublisher } from "@kuckit/domain/ports/event-publisher";
|
|
4
|
+
import { Clock } from "@kuckit/domain/ports/clock";
|
|
5
|
+
|
|
6
|
+
//#region src/usecases/create-user.d.ts
|
|
7
|
+
|
|
8
|
+
/**
|
|
9
|
+
* Dependencies required by the use case
|
|
10
|
+
*/
|
|
11
|
+
interface CreateUserDeps {
|
|
12
|
+
readonly userRepository: UserRepository;
|
|
13
|
+
readonly eventPublisher: EventPublisher;
|
|
14
|
+
readonly clock: Clock;
|
|
15
|
+
}
|
|
16
|
+
/**
|
|
17
|
+
* Input for the use case
|
|
18
|
+
*/
|
|
19
|
+
interface CreateUserInput {
|
|
20
|
+
readonly name: string;
|
|
21
|
+
readonly email: string;
|
|
22
|
+
readonly emailVerified: boolean;
|
|
23
|
+
}
|
|
24
|
+
/**
|
|
25
|
+
* Use case: Create user
|
|
26
|
+
* Publishes 'user.created' event after successful creation
|
|
27
|
+
*/
|
|
28
|
+
declare const makeCreateUser: (deps: CreateUserDeps) => (input: CreateUserInput) => Promise<User>;
|
|
29
|
+
//#endregion
|
|
30
|
+
export { CreateUserInput as n, makeCreateUser as r, CreateUserDeps as t };
|
|
31
|
+
//# sourceMappingURL=create-user-Tx0hVNQH.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export { };
|
|
@@ -0,0 +1,19 @@
|
|
|
1
|
+
//#region src/usecases/get-user-profile.ts
|
|
2
|
+
/**
|
|
3
|
+
* Use case: Get user profile
|
|
4
|
+
* Pure business logic with no infrastructure dependencies
|
|
5
|
+
*
|
|
6
|
+
* No events for read operations - this is a query use case that doesn't
|
|
7
|
+
* modify state, so no domain events are published.
|
|
8
|
+
*/
|
|
9
|
+
const makeGetUserProfile = (deps) => {
|
|
10
|
+
return async (input) => {
|
|
11
|
+
const user = await deps.userRepository.findById(input.userId);
|
|
12
|
+
if (!user) throw new Error("USER_NOT_FOUND");
|
|
13
|
+
return user;
|
|
14
|
+
};
|
|
15
|
+
};
|
|
16
|
+
|
|
17
|
+
//#endregion
|
|
18
|
+
export { makeGetUserProfile as t };
|
|
19
|
+
//# sourceMappingURL=get-user-profile-RYU3DyqZ.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"get-user-profile-RYU3DyqZ.js","names":[],"sources":["../src/usecases/get-user-profile.ts"],"sourcesContent":["import type { UserRepository } from '@kuckit/domain/ports/user-repository'\nimport type { User } from '@kuckit/domain/entities/user'\n\n/**\n * Dependencies required by the use case\n */\nexport interface GetUserProfileDeps {\n\treadonly userRepository: UserRepository\n}\n\n/**\n * Input for the use case\n */\nexport interface GetUserProfileInput {\n\treadonly userId: string\n}\n\n/**\n * Use case: Get user profile\n * Pure business logic with no infrastructure dependencies\n *\n * No events for read operations - this is a query use case that doesn't\n * modify state, so no domain events are published.\n */\nexport const makeGetUserProfile = (deps: GetUserProfileDeps) => {\n\treturn async (input: GetUserProfileInput): Promise<User> => {\n\t\tconst user = await deps.userRepository.findById(input.userId)\n\n\t\tif (!user) {\n\t\t\tthrow new Error('USER_NOT_FOUND')\n\t\t}\n\n\t\treturn user\n\t}\n}\n"],"mappings":";;;;;;;;AAwBA,MAAa,sBAAsB,SAA6B;AAC/D,QAAO,OAAO,UAA8C;EAC3D,MAAM,OAAO,MAAM,KAAK,eAAe,SAAS,MAAM,OAAO;AAE7D,MAAI,CAAC,KACJ,OAAM,IAAI,MAAM,iBAAiB;AAGlC,SAAO"}
|
|
@@ -0,0 +1,28 @@
|
|
|
1
|
+
import { UserRepository } from "@kuckit/domain/ports/user-repository";
|
|
2
|
+
import { User } from "@kuckit/domain/entities/user";
|
|
3
|
+
|
|
4
|
+
//#region src/usecases/get-user-profile.d.ts
|
|
5
|
+
|
|
6
|
+
/**
|
|
7
|
+
* Dependencies required by the use case
|
|
8
|
+
*/
|
|
9
|
+
interface GetUserProfileDeps {
|
|
10
|
+
readonly userRepository: UserRepository;
|
|
11
|
+
}
|
|
12
|
+
/**
|
|
13
|
+
* Input for the use case
|
|
14
|
+
*/
|
|
15
|
+
interface GetUserProfileInput {
|
|
16
|
+
readonly userId: string;
|
|
17
|
+
}
|
|
18
|
+
/**
|
|
19
|
+
* Use case: Get user profile
|
|
20
|
+
* Pure business logic with no infrastructure dependencies
|
|
21
|
+
*
|
|
22
|
+
* No events for read operations - this is a query use case that doesn't
|
|
23
|
+
* modify state, so no domain events are published.
|
|
24
|
+
*/
|
|
25
|
+
declare const makeGetUserProfile: (deps: GetUserProfileDeps) => (input: GetUserProfileInput) => Promise<User>;
|
|
26
|
+
//#endregion
|
|
27
|
+
export { GetUserProfileInput as n, makeGetUserProfile as r, GetUserProfileDeps as t };
|
|
28
|
+
//# sourceMappingURL=get-user-profile-a0C2QG0r.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export { };
|
package/dist/index.d.ts
CHANGED
|
@@ -1,78 +1,7 @@
|
|
|
1
|
-
import {
|
|
2
|
-
import {
|
|
3
|
-
import {
|
|
4
|
-
import {
|
|
5
|
-
import
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
/**
|
|
9
|
-
* Dependencies required by the use case
|
|
10
|
-
*/
|
|
11
|
-
interface GetUserProfileDeps {
|
|
12
|
-
readonly userRepository: UserRepository;
|
|
13
|
-
}
|
|
14
|
-
/**
|
|
15
|
-
* Input for the use case
|
|
16
|
-
*/
|
|
17
|
-
interface GetUserProfileInput {
|
|
18
|
-
readonly userId: string;
|
|
19
|
-
}
|
|
20
|
-
/**
|
|
21
|
-
* Use case: Get user profile
|
|
22
|
-
* Pure business logic with no infrastructure dependencies
|
|
23
|
-
*
|
|
24
|
-
* No events for read operations - this is a query use case that doesn't
|
|
25
|
-
* modify state, so no domain events are published.
|
|
26
|
-
*/
|
|
27
|
-
declare const makeGetUserProfile: (deps: GetUserProfileDeps) => (input: GetUserProfileInput) => Promise<User>;
|
|
28
|
-
//#endregion
|
|
29
|
-
//#region src/usecases/update-user-profile.d.ts
|
|
30
|
-
/**
|
|
31
|
-
* Dependencies required by the use case
|
|
32
|
-
*/
|
|
33
|
-
interface UpdateUserProfileDeps {
|
|
34
|
-
readonly userRepository: UserRepository;
|
|
35
|
-
readonly eventPublisher: EventPublisher;
|
|
36
|
-
readonly clock: Clock;
|
|
37
|
-
}
|
|
38
|
-
/**
|
|
39
|
-
* Input for the use case
|
|
40
|
-
*/
|
|
41
|
-
interface UpdateUserProfileInput {
|
|
42
|
-
readonly userId: string;
|
|
43
|
-
readonly updates: {
|
|
44
|
-
readonly name?: string;
|
|
45
|
-
readonly email?: string;
|
|
46
|
-
readonly emailVerified?: boolean;
|
|
47
|
-
};
|
|
48
|
-
}
|
|
49
|
-
/**
|
|
50
|
-
* Use case: Update user profile
|
|
51
|
-
* Publishes 'user.updated' event after successful update
|
|
52
|
-
*/
|
|
53
|
-
declare const makeUpdateUserProfile: (deps: UpdateUserProfileDeps) => (input: UpdateUserProfileInput) => Promise<User>;
|
|
54
|
-
//#endregion
|
|
55
|
-
//#region src/usecases/create-user.d.ts
|
|
56
|
-
/**
|
|
57
|
-
* Dependencies required by the use case
|
|
58
|
-
*/
|
|
59
|
-
interface CreateUserDeps {
|
|
60
|
-
readonly userRepository: UserRepository;
|
|
61
|
-
readonly eventPublisher: EventPublisher;
|
|
62
|
-
readonly clock: Clock;
|
|
63
|
-
}
|
|
64
|
-
/**
|
|
65
|
-
* Input for the use case
|
|
66
|
-
*/
|
|
67
|
-
interface CreateUserInput {
|
|
68
|
-
readonly name: string;
|
|
69
|
-
readonly email: string;
|
|
70
|
-
readonly emailVerified: boolean;
|
|
71
|
-
}
|
|
72
|
-
/**
|
|
73
|
-
* Use case: Create user
|
|
74
|
-
* Publishes 'user.created' event after successful creation
|
|
75
|
-
*/
|
|
76
|
-
declare const makeCreateUser: (deps: CreateUserDeps) => (input: CreateUserInput) => Promise<User>;
|
|
77
|
-
//#endregion
|
|
78
|
-
export { type CacheStore, CreateUserDeps, CreateUserInput, type DomainEvent, type EventBus, type EventHandler, type EventMap, type EventMeta, type EventName, GetUserProfileDeps, GetUserProfileInput, type RateLimiterStore, type TypedDomainEvent, UpdateUserProfileDeps, UpdateUserProfileInput, makeCreateUser, makeGetUserProfile, makeUpdateUserProfile };
|
|
1
|
+
import { a as EventMeta, i as EventMap, n as EventBus, o as EventName, r as EventHandler, s as TypedDomainEvent, t as DomainEvent } from "./index-C8MjPjfD.js";
|
|
2
|
+
import { n as GetUserProfileInput, r as makeGetUserProfile, t as GetUserProfileDeps } from "./get-user-profile-a0C2QG0r.js";
|
|
3
|
+
import { n as UpdateUserProfileInput, r as makeUpdateUserProfile, t as UpdateUserProfileDeps } from "./update-user-profile-8aqagn6Z.js";
|
|
4
|
+
import { n as CreateUserInput, r as makeCreateUser, t as CreateUserDeps } from "./create-user-Tx0hVNQH.js";
|
|
5
|
+
import "./index-BoGG5KAY.js";
|
|
6
|
+
import { n as RateLimiterStore, t as CacheStore } from "./index-C_7znSwG.js";
|
|
7
|
+
export { CacheStore, CreateUserDeps, CreateUserInput, DomainEvent, EventBus, EventHandler, EventMap, EventMeta, EventName, GetUserProfileDeps, GetUserProfileInput, RateLimiterStore, TypedDomainEvent, UpdateUserProfileDeps, UpdateUserProfileInput, makeCreateUser, makeGetUserProfile, makeUpdateUserProfile };
|
package/dist/index.js
CHANGED
|
@@ -1,77 +1,8 @@
|
|
|
1
|
-
import {
|
|
1
|
+
import { t as makeGetUserProfile } from "./get-user-profile-RYU3DyqZ.js";
|
|
2
|
+
import { t as makeUpdateUserProfile } from "./update-user-profile-7E9Zd_ap.js";
|
|
3
|
+
import { t as makeCreateUser } from "./create-user-DFzpTkKR.js";
|
|
4
|
+
import "./usecases-B1DG2fBy.js";
|
|
5
|
+
import "./events-CBFE7GCV.js";
|
|
6
|
+
import "./ports-CBEzGE5T.js";
|
|
2
7
|
|
|
3
|
-
//#region src/usecases/get-user-profile.ts
|
|
4
|
-
/**
|
|
5
|
-
* Use case: Get user profile
|
|
6
|
-
* Pure business logic with no infrastructure dependencies
|
|
7
|
-
*
|
|
8
|
-
* No events for read operations - this is a query use case that doesn't
|
|
9
|
-
* modify state, so no domain events are published.
|
|
10
|
-
*/
|
|
11
|
-
const makeGetUserProfile = (deps) => {
|
|
12
|
-
return async (input) => {
|
|
13
|
-
const user = await deps.userRepository.findById(input.userId);
|
|
14
|
-
if (!user) throw new Error("USER_NOT_FOUND");
|
|
15
|
-
return user;
|
|
16
|
-
};
|
|
17
|
-
};
|
|
18
|
-
|
|
19
|
-
//#endregion
|
|
20
|
-
//#region src/usecases/update-user-profile.ts
|
|
21
|
-
/**
|
|
22
|
-
* Use case: Update user profile
|
|
23
|
-
* Publishes 'user.updated' event after successful update
|
|
24
|
-
*/
|
|
25
|
-
const makeUpdateUserProfile = (deps) => {
|
|
26
|
-
return async (input) => {
|
|
27
|
-
const existingUser = await deps.userRepository.findById(input.userId);
|
|
28
|
-
if (!existingUser) throw new Error("USER_NOT_FOUND");
|
|
29
|
-
const updatedUser = {
|
|
30
|
-
...existingUser,
|
|
31
|
-
name: input.updates.name ?? existingUser.name,
|
|
32
|
-
email: input.updates.email ?? existingUser.email,
|
|
33
|
-
emailVerified: input.updates.emailVerified ?? existingUser.emailVerified,
|
|
34
|
-
updatedAt: deps.clock.now()
|
|
35
|
-
};
|
|
36
|
-
await deps.userRepository.save(updatedUser);
|
|
37
|
-
await deps.eventPublisher.publish("user.updated", {
|
|
38
|
-
userId: updatedUser.id,
|
|
39
|
-
changes: input.updates,
|
|
40
|
-
updatedAt: updatedUser.updatedAt
|
|
41
|
-
}, updatedUser.id);
|
|
42
|
-
return updatedUser;
|
|
43
|
-
};
|
|
44
|
-
};
|
|
45
|
-
|
|
46
|
-
//#endregion
|
|
47
|
-
//#region src/usecases/create-user.ts
|
|
48
|
-
/**
|
|
49
|
-
* Use case: Create user
|
|
50
|
-
* Publishes 'user.created' event after successful creation
|
|
51
|
-
*/
|
|
52
|
-
const makeCreateUser = (deps) => {
|
|
53
|
-
return async (input) => {
|
|
54
|
-
if (await deps.userRepository.findByEmail(input.email)) throw new Error("USER_ALREADY_EXISTS");
|
|
55
|
-
const now = deps.clock.now();
|
|
56
|
-
const newUser = {
|
|
57
|
-
id: randomUUID(),
|
|
58
|
-
name: input.name,
|
|
59
|
-
email: input.email,
|
|
60
|
-
emailVerified: input.emailVerified,
|
|
61
|
-
permissions: ["modules:read"],
|
|
62
|
-
createdAt: now,
|
|
63
|
-
updatedAt: now
|
|
64
|
-
};
|
|
65
|
-
await deps.userRepository.save(newUser);
|
|
66
|
-
await deps.eventPublisher.publish("user.created", {
|
|
67
|
-
userId: newUser.id,
|
|
68
|
-
email: newUser.email,
|
|
69
|
-
name: newUser.name,
|
|
70
|
-
createdAt: newUser.createdAt
|
|
71
|
-
}, newUser.id);
|
|
72
|
-
return newUser;
|
|
73
|
-
};
|
|
74
|
-
};
|
|
75
|
-
|
|
76
|
-
//#endregion
|
|
77
8
|
export { makeCreateUser, makeGetUserProfile, makeUpdateUserProfile };
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export { };
|
|
@@ -0,0 +1,29 @@
|
|
|
1
|
+
//#region src/usecases/update-user-profile.ts
|
|
2
|
+
/**
|
|
3
|
+
* Use case: Update user profile
|
|
4
|
+
* Publishes 'user.updated' event after successful update
|
|
5
|
+
*/
|
|
6
|
+
const makeUpdateUserProfile = (deps) => {
|
|
7
|
+
return async (input) => {
|
|
8
|
+
const existingUser = await deps.userRepository.findById(input.userId);
|
|
9
|
+
if (!existingUser) throw new Error("USER_NOT_FOUND");
|
|
10
|
+
const updatedUser = {
|
|
11
|
+
...existingUser,
|
|
12
|
+
name: input.updates.name ?? existingUser.name,
|
|
13
|
+
email: input.updates.email ?? existingUser.email,
|
|
14
|
+
emailVerified: input.updates.emailVerified ?? existingUser.emailVerified,
|
|
15
|
+
updatedAt: deps.clock.now()
|
|
16
|
+
};
|
|
17
|
+
await deps.userRepository.save(updatedUser);
|
|
18
|
+
await deps.eventPublisher.publish("user.updated", {
|
|
19
|
+
userId: updatedUser.id,
|
|
20
|
+
changes: input.updates,
|
|
21
|
+
updatedAt: updatedUser.updatedAt
|
|
22
|
+
}, updatedUser.id);
|
|
23
|
+
return updatedUser;
|
|
24
|
+
};
|
|
25
|
+
};
|
|
26
|
+
|
|
27
|
+
//#endregion
|
|
28
|
+
export { makeUpdateUserProfile as t };
|
|
29
|
+
//# sourceMappingURL=update-user-profile-7E9Zd_ap.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"update-user-profile-7E9Zd_ap.js","names":["updatedUser: User"],"sources":["../src/usecases/update-user-profile.ts"],"sourcesContent":["import type { UserRepository } from '@kuckit/domain/ports/user-repository'\nimport type { EventPublisher } from '@kuckit/domain/ports/event-publisher'\nimport type { Clock } from '@kuckit/domain/ports/clock'\nimport type { User } from '@kuckit/domain/entities/user'\n\n/**\n * Dependencies required by the use case\n */\nexport interface UpdateUserProfileDeps {\n\treadonly userRepository: UserRepository\n\treadonly eventPublisher: EventPublisher\n\treadonly clock: Clock\n}\n\n/**\n * Input for the use case\n */\nexport interface UpdateUserProfileInput {\n\treadonly userId: string\n\treadonly updates: {\n\t\treadonly name?: string\n\t\treadonly email?: string\n\t\treadonly emailVerified?: boolean\n\t}\n}\n\n/**\n * Use case: Update user profile\n * Publishes 'user.updated' event after successful update\n */\nexport const makeUpdateUserProfile = (deps: UpdateUserProfileDeps) => {\n\treturn async (input: UpdateUserProfileInput): Promise<User> => {\n\t\t// Find existing user\n\t\tconst existingUser = await deps.userRepository.findById(input.userId)\n\n\t\tif (!existingUser) {\n\t\t\tthrow new Error('USER_NOT_FOUND')\n\t\t}\n\n\t\t// Create updated user\n\t\tconst updatedUser: User = {\n\t\t\t...existingUser,\n\t\t\tname: input.updates.name ?? existingUser.name,\n\t\t\temail: input.updates.email ?? existingUser.email,\n\t\t\temailVerified: input.updates.emailVerified ?? existingUser.emailVerified,\n\t\t\tupdatedAt: deps.clock.now(),\n\t\t}\n\n\t\t// Save to repository\n\t\tawait deps.userRepository.save(updatedUser)\n\n\t\t// Publish event\n\t\tawait deps.eventPublisher.publish(\n\t\t\t'user.updated',\n\t\t\t{\n\t\t\t\tuserId: updatedUser.id,\n\t\t\t\tchanges: input.updates,\n\t\t\t\tupdatedAt: updatedUser.updatedAt,\n\t\t\t},\n\t\t\tupdatedUser.id\n\t\t)\n\n\t\treturn updatedUser\n\t}\n}\n"],"mappings":";;;;;AA8BA,MAAa,yBAAyB,SAAgC;AACrE,QAAO,OAAO,UAAiD;EAE9D,MAAM,eAAe,MAAM,KAAK,eAAe,SAAS,MAAM,OAAO;AAErE,MAAI,CAAC,aACJ,OAAM,IAAI,MAAM,iBAAiB;EAIlC,MAAMA,cAAoB;GACzB,GAAG;GACH,MAAM,MAAM,QAAQ,QAAQ,aAAa;GACzC,OAAO,MAAM,QAAQ,SAAS,aAAa;GAC3C,eAAe,MAAM,QAAQ,iBAAiB,aAAa;GAC3D,WAAW,KAAK,MAAM,KAAK;GAC3B;AAGD,QAAM,KAAK,eAAe,KAAK,YAAY;AAG3C,QAAM,KAAK,eAAe,QACzB,gBACA;GACC,QAAQ,YAAY;GACpB,SAAS,MAAM;GACf,WAAW,YAAY;GACvB,EACD,YAAY,GACZ;AAED,SAAO"}
|
|
@@ -0,0 +1,34 @@
|
|
|
1
|
+
import { UserRepository } from "@kuckit/domain/ports/user-repository";
|
|
2
|
+
import { User } from "@kuckit/domain/entities/user";
|
|
3
|
+
import { EventPublisher } from "@kuckit/domain/ports/event-publisher";
|
|
4
|
+
import { Clock } from "@kuckit/domain/ports/clock";
|
|
5
|
+
|
|
6
|
+
//#region src/usecases/update-user-profile.d.ts
|
|
7
|
+
|
|
8
|
+
/**
|
|
9
|
+
* Dependencies required by the use case
|
|
10
|
+
*/
|
|
11
|
+
interface UpdateUserProfileDeps {
|
|
12
|
+
readonly userRepository: UserRepository;
|
|
13
|
+
readonly eventPublisher: EventPublisher;
|
|
14
|
+
readonly clock: Clock;
|
|
15
|
+
}
|
|
16
|
+
/**
|
|
17
|
+
* Input for the use case
|
|
18
|
+
*/
|
|
19
|
+
interface UpdateUserProfileInput {
|
|
20
|
+
readonly userId: string;
|
|
21
|
+
readonly updates: {
|
|
22
|
+
readonly name?: string;
|
|
23
|
+
readonly email?: string;
|
|
24
|
+
readonly emailVerified?: boolean;
|
|
25
|
+
};
|
|
26
|
+
}
|
|
27
|
+
/**
|
|
28
|
+
* Use case: Update user profile
|
|
29
|
+
* Publishes 'user.updated' event after successful update
|
|
30
|
+
*/
|
|
31
|
+
declare const makeUpdateUserProfile: (deps: UpdateUserProfileDeps) => (input: UpdateUserProfileInput) => Promise<User>;
|
|
32
|
+
//#endregion
|
|
33
|
+
export { UpdateUserProfileInput as n, makeUpdateUserProfile as r, UpdateUserProfileDeps as t };
|
|
34
|
+
//# sourceMappingURL=update-user-profile-8aqagn6Z.d.ts.map
|
|
@@ -0,0 +1,5 @@
|
|
|
1
|
+
import { n as GetUserProfileInput, r as makeGetUserProfile, t as GetUserProfileDeps } from "../get-user-profile-a0C2QG0r.js";
|
|
2
|
+
import { n as UpdateUserProfileInput, r as makeUpdateUserProfile, t as UpdateUserProfileDeps } from "../update-user-profile-8aqagn6Z.js";
|
|
3
|
+
import { n as CreateUserInput, r as makeCreateUser, t as CreateUserDeps } from "../create-user-Tx0hVNQH.js";
|
|
4
|
+
import "../index-BoGG5KAY.js";
|
|
5
|
+
export { CreateUserDeps, CreateUserInput, GetUserProfileDeps, GetUserProfileInput, UpdateUserProfileDeps, UpdateUserProfileInput, makeCreateUser, makeGetUserProfile, makeUpdateUserProfile };
|
|
@@ -0,0 +1,6 @@
|
|
|
1
|
+
import { t as makeGetUserProfile } from "../get-user-profile-RYU3DyqZ.js";
|
|
2
|
+
import { t as makeUpdateUserProfile } from "../update-user-profile-7E9Zd_ap.js";
|
|
3
|
+
import { t as makeCreateUser } from "../create-user-DFzpTkKR.js";
|
|
4
|
+
import "../usecases-B1DG2fBy.js";
|
|
5
|
+
|
|
6
|
+
export { makeCreateUser, makeGetUserProfile, makeUpdateUserProfile };
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export { };
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@kuckit/application",
|
|
3
|
-
"version": "
|
|
3
|
+
"version": "2.0.0",
|
|
4
4
|
"type": "module",
|
|
5
5
|
"main": "dist/index.js",
|
|
6
6
|
"types": "dist/index.d.ts",
|
|
@@ -22,7 +22,7 @@
|
|
|
22
22
|
"prepublishOnly": "npm run build && node ../../scripts/resolve-workspace-protocols.cjs && node ../../scripts/check-no-workspace-protocol.cjs"
|
|
23
23
|
},
|
|
24
24
|
"dependencies": {
|
|
25
|
-
"@kuckit/domain": "^
|
|
25
|
+
"@kuckit/domain": "^2.0.0"
|
|
26
26
|
},
|
|
27
27
|
"devDependencies": {
|
|
28
28
|
"tsdown": "catalog:"
|