@shizuoka-its/core 2.0.1 → 2.1.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.
Files changed (34) hide show
  1. package/dist/application/exceptions/ApplicationExceptions.d.ts +11 -5
  2. package/dist/application/exceptions/ApplicationExceptions.js +27 -6
  3. package/dist/application/usecase/event/AddExhibitToEvent.js +1 -1
  4. package/dist/application/usecase/event/ChangeExhibitDescription.js +1 -1
  5. package/dist/application/usecase/event/ChangeExhibitMarkdownContent.js +1 -1
  6. package/dist/application/usecase/event/ChangeExhibitName.js +1 -1
  7. package/dist/application/usecase/event/ChangeExhibitUrl.js +1 -1
  8. package/dist/application/usecase/event/ChangeLightningTalkDuration.js +1 -1
  9. package/dist/application/usecase/event/ChangeLightningTalkSlideUrl.js +1 -1
  10. package/dist/application/usecase/event/ChangeLightningTalkStartTime.js +1 -1
  11. package/dist/application/usecase/event/DeleteEvent.js +1 -1
  12. package/dist/application/usecase/event/RemoveExhibitFromEvent.js +1 -1
  13. package/dist/application/usecase/event/UpdateEvent.js +1 -1
  14. package/dist/application/usecase/eventParticipation/GetMembersByEvent.js +1 -1
  15. package/dist/application/usecase/eventParticipation/GetMembersByExhibit.js +1 -1
  16. package/dist/application/usecase/eventParticipation/RegisterMemberToEvent.js +2 -2
  17. package/dist/application/usecase/eventParticipation/RegisterMemberToExhibit.js +2 -2
  18. package/dist/application/usecase/eventParticipation/RemoveMemberFromEvent.js +1 -1
  19. package/dist/application/usecase/eventParticipation/RemoveMemberFromExhibit.js +1 -1
  20. package/dist/application/usecase/member/ChangeDiscordNickName.js +2 -2
  21. package/dist/application/usecase/member/ConnectDiscordAccount.js +1 -1
  22. package/dist/application/usecase/member/RegisterMember.d.ts +4 -2
  23. package/dist/application/usecase/member/RegisterMember.js +3 -9
  24. package/dist/application/usecase/member/UpdateMember.js +1 -1
  25. package/dist/domain/aggregates/event/Event.js +1 -1
  26. package/dist/domain/aggregates/event/Exhibit.js +1 -1
  27. package/dist/domain/exceptions/DomainExceptions.d.ts +13 -16
  28. package/dist/domain/exceptions/DomainExceptions.js +27 -34
  29. package/dist/domain/value-objects/Departments.js +1 -1
  30. package/dist/domain/value-objects/Email.js +1 -1
  31. package/dist/domain/value-objects/LightningTalkDuration.js +1 -1
  32. package/dist/domain/value-objects/UniversityEmail.js +1 -1
  33. package/dist/domain/value-objects/Url.js +2 -2
  34. package/package.json +1 -1
@@ -2,17 +2,23 @@ export declare class ApplicationException extends Error {
2
2
  constructor(message: string);
3
3
  }
4
4
  export declare class EventNotFoundException extends ApplicationException {
5
- constructor(message?: string);
5
+ constructor(eventId: string);
6
6
  }
7
7
  export declare class ExhibitNotFoundException extends ApplicationException {
8
- constructor(message?: string);
8
+ constructor(exhibitId: string);
9
+ }
10
+ export declare class ExhibitNotFoundFromExhibitIdException extends ApplicationException {
11
+ constructor(exhibitId: string);
9
12
  }
10
13
  export declare class MemberEmailAlreadyExistsException extends ApplicationException {
11
- constructor(message?: string);
14
+ constructor(email: string);
12
15
  }
13
16
  export declare class MemberNotFoundException extends ApplicationException {
14
- constructor(message?: string);
17
+ constructor(memberId: string);
18
+ }
19
+ export declare class MemberNotFoundFromDiscordAccountIdException extends ApplicationException {
20
+ constructor(discordAccountId: string);
15
21
  }
16
22
  export declare class DiscordAccountNotConnectedException extends ApplicationException {
17
- constructor(message?: string);
23
+ constructor(userId: string, discordUserId: string);
18
24
  }
@@ -1,6 +1,6 @@
1
1
  "use strict";
2
2
  Object.defineProperty(exports, "__esModule", { value: true });
3
- exports.DiscordAccountNotConnectedException = exports.MemberNotFoundException = exports.MemberEmailAlreadyExistsException = exports.ExhibitNotFoundException = exports.EventNotFoundException = exports.ApplicationException = void 0;
3
+ exports.DiscordAccountNotConnectedException = exports.MemberNotFoundFromDiscordAccountIdException = exports.MemberNotFoundException = exports.MemberEmailAlreadyExistsException = exports.ExhibitNotFoundFromExhibitIdException = exports.ExhibitNotFoundException = exports.EventNotFoundException = exports.ApplicationException = void 0;
4
4
  class ApplicationException extends Error {
5
5
  constructor(message) {
6
6
  super(message);
@@ -9,35 +9,56 @@ class ApplicationException extends Error {
9
9
  }
10
10
  exports.ApplicationException = ApplicationException;
11
11
  class EventNotFoundException extends ApplicationException {
12
- constructor(message = "イベントが見つかりません") {
12
+ constructor(eventId) {
13
+ const message = `イベントが見つかりません: ${eventId}`;
13
14
  super(message);
14
15
  this.name = "EventNotFoundException";
15
16
  }
16
17
  }
17
18
  exports.EventNotFoundException = EventNotFoundException;
18
19
  class ExhibitNotFoundException extends ApplicationException {
19
- constructor(message = "展示が見つかりません") {
20
+ constructor(exhibitId) {
21
+ const message = `展示が見つかりません: ${exhibitId}`;
20
22
  super(message);
21
23
  this.name = "ExhibitNotFoundException";
22
24
  }
23
25
  }
24
26
  exports.ExhibitNotFoundException = ExhibitNotFoundException;
27
+ class ExhibitNotFoundFromExhibitIdException extends ApplicationException {
28
+ constructor(exhibitId) {
29
+ const message = `指定された展示IDで展示が見つかりません: ${exhibitId}`;
30
+ super(message);
31
+ this.name = "ExhibitNotFoundFromExhibitIdException";
32
+ }
33
+ }
34
+ exports.ExhibitNotFoundFromExhibitIdException = ExhibitNotFoundFromExhibitIdException;
25
35
  class MemberEmailAlreadyExistsException extends ApplicationException {
26
- constructor(message = "このメールアドレスは既に登録されています") {
36
+ constructor(email) {
37
+ const message = `このメールアドレスは既に登録されています: ${email}`;
27
38
  super(message);
28
39
  this.name = "MemberEmailAlreadyExistsException";
29
40
  }
30
41
  }
31
42
  exports.MemberEmailAlreadyExistsException = MemberEmailAlreadyExistsException;
32
43
  class MemberNotFoundException extends ApplicationException {
33
- constructor(message = "メンバーが見つかりません") {
44
+ constructor(memberId) {
45
+ const message = `メンバーが見つかりません: ${memberId}`;
34
46
  super(message);
35
47
  this.name = "MemberNotFoundException";
36
48
  }
37
49
  }
38
50
  exports.MemberNotFoundException = MemberNotFoundException;
51
+ class MemberNotFoundFromDiscordAccountIdException extends ApplicationException {
52
+ constructor(discordAccountId) {
53
+ const message = `指定されたDiscordアカウントIDからメンバーが見つかりません: (DiscordアカウントID) ${discordAccountId}`;
54
+ super(message);
55
+ this.name = "MemberNotFoundFromDiscordAccountIdException";
56
+ }
57
+ }
58
+ exports.MemberNotFoundFromDiscordAccountIdException = MemberNotFoundFromDiscordAccountIdException;
39
59
  class DiscordAccountNotConnectedException extends ApplicationException {
40
- constructor(message = "このDiscordアカウントは紐づいていません") {
60
+ constructor(userId, discordUserId) {
61
+ const message = `ユーザー: ${userId} のDiscordアカウントは紐づいていません: ${discordUserId}`;
41
62
  super(message);
42
63
  this.name = "DiscordAccountNotConnectedException";
43
64
  }
@@ -15,7 +15,7 @@ class AddExhibitToEvent extends base_1.IUseCase {
15
15
  async execute(input) {
16
16
  const event = await this.eventRepository.findById(input.eventId);
17
17
  if (!event) {
18
- throw new exceptions_1.EventNotFoundException();
18
+ throw new exceptions_1.EventNotFoundException(input.eventId);
19
19
  }
20
20
  const { id, name, description, markdownContent, url } = input.exhibit;
21
21
  const exhibit = new domain_1.Exhibit(id, name, description, markdownContent, url);
@@ -14,7 +14,7 @@ class ChangeExhibitDescription extends base_1.IUseCase {
14
14
  async execute(input) {
15
15
  const event = await this.eventRepository.findById(input.eventId);
16
16
  if (!event) {
17
- throw new exceptions_1.EventNotFoundException();
17
+ throw new exceptions_1.EventNotFoundException(input.eventId);
18
18
  }
19
19
  event.changeExhibitDescription(input.exhibitId, input.newDescription);
20
20
  await this.eventRepository.save(event);
@@ -14,7 +14,7 @@ class ChangeExhibitMarkdownContent extends base_1.IUseCase {
14
14
  async execute(input) {
15
15
  const event = await this.eventRepository.findById(input.eventId);
16
16
  if (!event) {
17
- throw new exceptions_1.EventNotFoundException();
17
+ throw new exceptions_1.EventNotFoundException(input.eventId);
18
18
  }
19
19
  event.changeExhibitMarkdownContent(input.exhibitId, input.newMarkdownContent);
20
20
  await this.eventRepository.save(event);
@@ -14,7 +14,7 @@ class ChangeExhibitName extends base_1.IUseCase {
14
14
  async execute(input) {
15
15
  const event = await this.eventRepository.findById(input.eventId);
16
16
  if (!event) {
17
- throw new exceptions_1.EventNotFoundException();
17
+ throw new exceptions_1.EventNotFoundException(input.eventId);
18
18
  }
19
19
  event.changeExhibitName(input.exhibitId, input.newName);
20
20
  await this.eventRepository.save(event);
@@ -14,7 +14,7 @@ class ChangeExhibitUrl extends base_1.IUseCase {
14
14
  async execute(input) {
15
15
  const event = await this.eventRepository.findById(input.eventId);
16
16
  if (!event) {
17
- throw new exceptions_1.EventNotFoundException();
17
+ throw new exceptions_1.EventNotFoundException(input.eventId);
18
18
  }
19
19
  event.changeExhibitUrl(input.exhibitId, input.newUrl);
20
20
  await this.eventRepository.save(event);
@@ -14,7 +14,7 @@ class ChangeLightningTalkDuration extends base_1.IUseCase {
14
14
  async execute(input) {
15
15
  const event = await this.eventRepository.findById(input.eventId);
16
16
  if (!event) {
17
- throw new exceptions_1.EventNotFoundException();
17
+ throw new exceptions_1.EventNotFoundException(input.eventId);
18
18
  }
19
19
  event.changeExhibitLightningTalkDuration(input.exhibitId, input.newDuration);
20
20
  await this.eventRepository.save(event);
@@ -14,7 +14,7 @@ class ChangeLightningTalkSlideUrl extends base_1.IUseCase {
14
14
  async execute(input) {
15
15
  const event = await this.eventRepository.findById(input.eventId);
16
16
  if (!event) {
17
- throw new exceptions_1.EventNotFoundException();
17
+ throw new exceptions_1.EventNotFoundException(input.eventId);
18
18
  }
19
19
  event.changeExhibitLightningTalkSlideUrl(input.exhibitId, input.newSlideUrl);
20
20
  await this.eventRepository.save(event);
@@ -14,7 +14,7 @@ class ChangeLightningTalkStartTime extends base_1.IUseCase {
14
14
  async execute(input) {
15
15
  const event = await this.eventRepository.findById(input.eventId);
16
16
  if (!event) {
17
- throw new exceptions_1.EventNotFoundException();
17
+ throw new exceptions_1.EventNotFoundException(input.eventId);
18
18
  }
19
19
  event.changeExhibitLightningTalkStartTime(input.exhibitId, input.newStartTime);
20
20
  await this.eventRepository.save(event);
@@ -14,7 +14,7 @@ class DeleteEvent extends base_1.IUseCase {
14
14
  async execute(input) {
15
15
  const event = await this.eventRepository.findById(input.eventId);
16
16
  if (!event) {
17
- throw new exceptions_1.EventNotFoundException();
17
+ throw new exceptions_1.EventNotFoundException(input.eventId);
18
18
  }
19
19
  await this.eventRepository.delete(input.eventId);
20
20
  return { event };
@@ -14,7 +14,7 @@ class RemoveExhibitFromEvent extends base_1.IUseCase {
14
14
  async execute(input) {
15
15
  const event = await this.eventRepository.findById(input.eventId);
16
16
  if (!event) {
17
- throw new exceptions_1.EventNotFoundException();
17
+ throw new exceptions_1.EventNotFoundException(input.eventId);
18
18
  }
19
19
  event.removeExhibit(input.exhibitId);
20
20
  await this.eventRepository.save(event);
@@ -11,7 +11,7 @@ class UpdateEvent extends base_1.IUseCase {
11
11
  async execute(input) {
12
12
  const event = await this.eventRepository.findById(input.eventId);
13
13
  if (!event) {
14
- throw new exceptions_1.EventNotFoundException();
14
+ throw new exceptions_1.EventNotFoundException(input.eventId);
15
15
  }
16
16
  if (input.name !== undefined) {
17
17
  event.changeName(input.name);
@@ -12,7 +12,7 @@ class GetMembersByEvent extends base_1.IUseCase {
12
12
  async execute(input) {
13
13
  const event = await this.eventRepository.findById(input.eventId);
14
14
  if (!event) {
15
- throw new exceptions_1.EventNotFoundException();
15
+ throw new exceptions_1.EventNotFoundException(input.eventId);
16
16
  }
17
17
  const members = (await Promise.all(event
18
18
  .getMemberIds()
@@ -12,7 +12,7 @@ class GetMembersByExhibit extends base_1.IUseCase {
12
12
  async execute(input) {
13
13
  const event = await this.eventRepository.findByExhibitId(input.exhibitId);
14
14
  if (!event) {
15
- throw new exceptions_1.EventNotFoundException();
15
+ throw new exceptions_1.ExhibitNotFoundFromExhibitIdException(input.exhibitId);
16
16
  }
17
17
  const memberResults = await Promise.all(event
18
18
  .getMemberIds()
@@ -12,11 +12,11 @@ class RegisterMemberToEvent extends base_1.IUseCase {
12
12
  async execute(input) {
13
13
  const event = await this.eventRepository.findById(input.eventId);
14
14
  if (!event) {
15
- throw new exceptions_1.EventNotFoundException();
15
+ throw new exceptions_1.EventNotFoundException(input.eventId);
16
16
  }
17
17
  const member = await this.memberRepository.findById(input.memberId);
18
18
  if (!member) {
19
- throw new exceptions_1.MemberNotFoundException();
19
+ throw new exceptions_1.MemberNotFoundException(input.memberId);
20
20
  }
21
21
  event.addMemberId(input.memberId);
22
22
  await this.eventRepository.save(event);
@@ -12,11 +12,11 @@ class RegisterMemberToExhibit extends base_1.IUseCase {
12
12
  async execute(input) {
13
13
  const event = await this.eventRepository.findByExhibitId(input.exhibitId);
14
14
  if (!event) {
15
- throw new exceptions_1.EventNotFoundException();
15
+ throw new exceptions_1.EventNotFoundException(input.exhibitId);
16
16
  }
17
17
  const member = await this.memberRepository.findById(input.memberId);
18
18
  if (!member) {
19
- throw new exceptions_1.MemberNotFoundException();
19
+ throw new exceptions_1.MemberNotFoundException(input.memberId);
20
20
  }
21
21
  event.addExhibitMemberId(input.exhibitId, input.memberId);
22
22
  await this.eventRepository.save(event);
@@ -12,7 +12,7 @@ class RemoveMemberFromEvent extends base_1.IUseCase {
12
12
  async execute(input) {
13
13
  const event = await this.eventRepository.findById(input.eventId);
14
14
  if (!event) {
15
- throw new exceptions_1.EventNotFoundException();
15
+ throw new exceptions_1.EventNotFoundException(input.eventId);
16
16
  }
17
17
  event.removeMemberId(input.memberId);
18
18
  await this.eventRepository.save(event);
@@ -12,7 +12,7 @@ class RemoveMemberFromExhibit extends base_1.IUseCase {
12
12
  async execute(input) {
13
13
  const event = await this.eventRepository.findByExhibitId(input.exhibitId);
14
14
  if (!event) {
15
- throw new exceptions_1.EventNotFoundException();
15
+ throw new exceptions_1.EventNotFoundException(input.exhibitId);
16
16
  }
17
17
  event.removeExhibitMemberId(input.exhibitId, input.memberId);
18
18
  await this.eventRepository.save(event);
@@ -11,11 +11,11 @@ class ChangeDiscordNickNameUseCase extends base_1.IUseCase {
11
11
  async execute(input) {
12
12
  const member = await this.memberRepo.findByDiscordAccountId(input.discordAccountId);
13
13
  if (!member) {
14
- throw new exceptions_1.MemberNotFoundException();
14
+ throw new exceptions_1.MemberNotFoundFromDiscordAccountIdException(input.discordAccountId);
15
15
  }
16
16
  const discordAccount = member.getDiscordAccountById(input.discordAccountId);
17
17
  if (!discordAccount) {
18
- throw new exceptions_1.DiscordAccountNotConnectedException();
18
+ throw new exceptions_1.DiscordAccountNotConnectedException(member.id, input.discordAccountId);
19
19
  }
20
20
  discordAccount.setNickName(input.discordNickName);
21
21
  await this.memberRepo.save(member);
@@ -13,7 +13,7 @@ class ConnectDiscordAccountUseCase extends base_1.IUseCase {
13
13
  var _a;
14
14
  const member = await this.memberRepo.findById(input.memberId);
15
15
  if (!member) {
16
- throw new exceptions_1.MemberNotFoundException();
16
+ throw new exceptions_1.MemberNotFoundException(input.memberId);
17
17
  }
18
18
  const discordAccount = new domain_1.DiscordAccount(input.discordAccountId, (_a = input.discordNickName) !== null && _a !== void 0 ? _a : "", member.id);
19
19
  member.addDiscordAccount(discordAccount);
@@ -6,8 +6,10 @@ export interface RegisterMemberInput {
6
6
  department: string;
7
7
  email: string;
8
8
  personalEmail?: string;
9
- discordAccountId?: string;
10
- discordNickName?: string;
9
+ discordInfo?: {
10
+ accountId: string;
11
+ nickName: string;
12
+ };
11
13
  }
12
14
  export interface RegisterMemberOutput {
13
15
  member: Member;
@@ -11,23 +11,17 @@ class RegisterMemberUseCase extends base_1.IUseCase {
11
11
  this.memberRepo = memberRepo;
12
12
  }
13
13
  async execute(input) {
14
- // TODO: この入力値のバリデーションはUsecaseが本来着目するべき処理の流れという関心事では無い
15
- if (input.discordNickName) {
16
- if (!input.discordAccountId) {
17
- throw new exceptions_1.DiscordAccountNotConnectedException();
18
- }
19
- }
20
14
  const existingMember = await this.memberRepo.findByEmail(input.email);
21
15
  if (existingMember) {
22
- throw new exceptions_1.MemberEmailAlreadyExistsException();
16
+ throw new exceptions_1.MemberEmailAlreadyExistsException(input.email);
23
17
  }
24
18
  const universityEmail = new domain_1.UniversityEmail(input.email);
25
19
  const personalEmail = input.personalEmail
26
20
  ? new domain_1.Email(input.personalEmail)
27
21
  : undefined;
28
22
  const member = new domain_1.Member((0, uuid_1.v4)(), input.name, input.studentId, domain_1.Department.fromString(input.department), universityEmail, personalEmail);
29
- if (input.discordAccountId && input.discordNickName) {
30
- const discordAccount = new domain_1.DiscordAccount(input.discordAccountId, input.discordNickName, member.id);
23
+ if (input.discordInfo) {
24
+ const discordAccount = new domain_1.DiscordAccount(input.discordInfo.accountId, input.discordInfo.nickName, member.id);
31
25
  member.addDiscordAccount(discordAccount);
32
26
  }
33
27
  await this.memberRepo.save(member);
@@ -12,7 +12,7 @@ class UpdateMemberUseCase extends base_1.IUseCase {
12
12
  async execute(input) {
13
13
  const member = await this.memberRepo.findById(input.memberId);
14
14
  if (!member) {
15
- throw new exceptions_1.MemberNotFoundException();
15
+ throw new exceptions_1.MemberNotFoundException(input.memberId);
16
16
  }
17
17
  if (input.name) {
18
18
  member.setName(input.name);
@@ -79,7 +79,7 @@ class Event {
79
79
  removeMemberId(memberId) {
80
80
  for (const exhibit of this.exhibits) {
81
81
  if (exhibit.getMemberIds().includes(memberId)) {
82
- throw new exceptions_1.ExhibitHasMemberException();
82
+ throw new exceptions_1.ExhibitHasMemberException(exhibit.id, memberId);
83
83
  }
84
84
  }
85
85
  this.memberIds.delete(memberId);
@@ -8,7 +8,7 @@ class Exhibit {
8
8
  const exhibit = new Exhibit(id, name, description, markdownContent, url);
9
9
  // NOTE: ここで例外を投げるのは、Exhibit の id と LightningTalk の exhibitId が一致しているかどうかをチェックしているため
10
10
  if (lt.exhibitId !== id) {
11
- throw new exceptions_1.LightningTalkExhibitIdMismatchException();
11
+ throw new exceptions_1.LightningTalkExhibitIdMismatchException(id, lt.exhibitId);
12
12
  }
13
13
  exhibit.lightningTalk = lt;
14
14
  return exhibit;
@@ -1,45 +1,42 @@
1
1
  export declare class DomainException extends Error {
2
2
  constructor(message: string);
3
3
  }
4
- export declare class InvalidMemberException extends DomainException {
5
- constructor(message?: string);
6
- }
7
4
  export declare class InvalidEmailFormatException extends DomainException {
8
- constructor(message?: string);
5
+ constructor(email: string);
9
6
  }
10
7
  export declare class DiscordAccountAlreadyConnectedException extends DomainException {
11
- constructor(message?: string);
8
+ constructor();
12
9
  }
13
10
  export declare class DiscordAccountNotConnectedException extends DomainException {
14
- constructor(message?: string);
11
+ constructor();
15
12
  }
16
13
  export declare class InvalidUniversityEmailException extends DomainException {
17
- constructor(message?: string);
14
+ constructor(email: string);
18
15
  }
19
16
  export declare class InvalidDepartmentException extends DomainException {
20
- constructor(message?: string);
17
+ constructor(department: string);
21
18
  }
22
19
  export declare class InvalidLightningTalkDurationException extends DomainException {
23
- constructor(message?: string);
20
+ constructor(duration: number);
24
21
  }
25
22
  export declare class InvalidUrlException extends DomainException {
26
- constructor(message?: string);
23
+ constructor(url: string);
27
24
  }
28
25
  export declare class InvalidUrlProtocolException extends DomainException {
29
- constructor(message?: string);
26
+ constructor(url: string, protocol: string);
30
27
  }
31
28
  export declare class ExhibitAlreadyExistsException extends DomainException {
32
- constructor(message?: string);
29
+ constructor(exhibitId: string);
33
30
  }
34
31
  export declare class ExhibitNotFoundException extends DomainException {
35
- constructor(message?: string);
32
+ constructor(exhibitId: string);
36
33
  }
37
34
  export declare class LightningTalkNotFoundException extends DomainException {
38
- constructor(message?: string);
35
+ constructor(lightningTalkId: string);
39
36
  }
40
37
  export declare class LightningTalkExhibitIdMismatchException extends DomainException {
41
- constructor(message?: string);
38
+ constructor(lightningTalkId: string, exhibitId: string);
42
39
  }
43
40
  export declare class ExhibitHasMemberException extends DomainException {
44
- constructor(message?: string);
41
+ constructor(exhibitId: string, memberId: string);
45
42
  }
@@ -1,6 +1,6 @@
1
1
  "use strict";
2
2
  Object.defineProperty(exports, "__esModule", { value: true });
3
- exports.ExhibitHasMemberException = exports.LightningTalkExhibitIdMismatchException = exports.LightningTalkNotFoundException = exports.ExhibitNotFoundException = exports.ExhibitAlreadyExistsException = exports.InvalidUrlProtocolException = exports.InvalidUrlException = exports.InvalidLightningTalkDurationException = exports.InvalidDepartmentException = exports.InvalidUniversityEmailException = exports.DiscordAccountNotConnectedException = exports.DiscordAccountAlreadyConnectedException = exports.InvalidEmailFormatException = exports.InvalidMemberException = exports.DomainException = void 0;
3
+ exports.ExhibitHasMemberException = exports.LightningTalkExhibitIdMismatchException = exports.LightningTalkNotFoundException = exports.ExhibitNotFoundException = exports.ExhibitAlreadyExistsException = exports.InvalidUrlProtocolException = exports.InvalidUrlException = exports.InvalidLightningTalkDurationException = exports.InvalidDepartmentException = exports.InvalidUniversityEmailException = exports.DiscordAccountNotConnectedException = exports.DiscordAccountAlreadyConnectedException = exports.InvalidEmailFormatException = exports.DomainException = void 0;
4
4
  class DomainException extends Error {
5
5
  constructor(message) {
6
6
  super(message);
@@ -8,100 +8,93 @@ class DomainException extends Error {
8
8
  }
9
9
  }
10
10
  exports.DomainException = DomainException;
11
- class InvalidMemberException extends DomainException {
12
- constructor(message = "無効なメンバーです") {
13
- super(message);
14
- this.name = "InvalidMemberException";
15
- }
16
- }
17
- exports.InvalidMemberException = InvalidMemberException;
18
11
  class InvalidEmailFormatException extends DomainException {
19
- constructor(message = "無効なメールアドレスの形式です") {
20
- super(message);
12
+ constructor(email) {
13
+ super(`無効なメールアドレスの形式です: ${email}`);
21
14
  this.name = "InvalidEmailFormatException";
22
15
  }
23
16
  }
24
17
  exports.InvalidEmailFormatException = InvalidEmailFormatException;
25
18
  class DiscordAccountAlreadyConnectedException extends DomainException {
26
- constructor(message = "同じDiscordアカウントがすでにユーザーに紐づいています") {
27
- super(message);
19
+ constructor() {
20
+ super("同じDiscordアカウントがすでにユーザーに紐づいています");
28
21
  this.name = "DiscordAccountAlreadyConnectedException";
29
22
  }
30
23
  }
31
24
  exports.DiscordAccountAlreadyConnectedException = DiscordAccountAlreadyConnectedException;
32
25
  class DiscordAccountNotConnectedException extends DomainException {
33
- constructor(message = "指定されたDiscordアカウントがユーザーに紐づいていません") {
34
- super(message);
26
+ constructor() {
27
+ super("指定されたDiscordアカウントがユーザーに紐づいていません");
35
28
  this.name = "DiscordAccountNotConnectedException";
36
29
  }
37
30
  }
38
31
  exports.DiscordAccountNotConnectedException = DiscordAccountNotConnectedException;
39
32
  class InvalidUniversityEmailException extends DomainException {
40
- constructor(message = "無効な大学のメールアドレスです") {
41
- super(message);
33
+ constructor(email) {
34
+ super(`無効な大学のメールアドレスです: ${email} (大学ドメインが必要です)`);
42
35
  this.name = "InvalidUniversityEmailException";
43
36
  }
44
37
  }
45
38
  exports.InvalidUniversityEmailException = InvalidUniversityEmailException;
46
39
  class InvalidDepartmentException extends DomainException {
47
- constructor(message = "無効な学部識別子です") {
48
- super(message);
40
+ constructor(department) {
41
+ super(`無効な学部識別子です: ${department} (有効値: CS, BI, IA, GRADUATE, ALUMNI, OTHERS)`);
49
42
  this.name = "InvalidDepartmentException";
50
43
  }
51
44
  }
52
45
  exports.InvalidDepartmentException = InvalidDepartmentException;
53
46
  class InvalidLightningTalkDurationException extends DomainException {
54
- constructor(message = "無効なライトニングトークの長さです") {
55
- super(message);
47
+ constructor(duration) {
48
+ super(`無効なライトニングトークの長さです: ${duration}分 (正の数値で指定してください)`);
56
49
  this.name = "InvalidLightningTalkDurationException";
57
50
  }
58
51
  }
59
52
  exports.InvalidLightningTalkDurationException = InvalidLightningTalkDurationException;
60
53
  class InvalidUrlException extends DomainException {
61
- constructor(message = "無効なURLです") {
62
- super(message);
54
+ constructor(url) {
55
+ super(`無効なURLです: ${url}`);
63
56
  this.name = "InvalidUrlException";
64
57
  }
65
58
  }
66
59
  exports.InvalidUrlException = InvalidUrlException;
67
60
  class InvalidUrlProtocolException extends DomainException {
68
- constructor(message = "指定されたURLのプロトコルは許可されていません。httpまたはhttpsを使用してください。") {
69
- super(message);
61
+ constructor(url, protocol) {
62
+ super(`指定されたURLのプロトコルは許可されていません: ${url} (プロトコル: ${protocol})`);
70
63
  this.name = "InvalidUrlProtocolException";
71
64
  }
72
65
  }
73
66
  exports.InvalidUrlProtocolException = InvalidUrlProtocolException;
74
67
  class ExhibitAlreadyExistsException extends DomainException {
75
- constructor(message = "既に同一の展示が登録されています") {
76
- super(message);
68
+ constructor(exhibitId) {
69
+ super(`既に同一の展示が登録されています: ${exhibitId}`);
77
70
  this.name = "ExhibitAlreadyExistsException";
78
71
  }
79
72
  }
80
73
  exports.ExhibitAlreadyExistsException = ExhibitAlreadyExistsException;
81
74
  class ExhibitNotFoundException extends DomainException {
82
- constructor(message = "指定された展示が見つかりません") {
83
- super(message);
75
+ constructor(exhibitId) {
76
+ super(`指定された展示が見つかりません: ${exhibitId}`);
84
77
  this.name = "ExhibitNotFoundException";
85
78
  }
86
79
  }
87
80
  exports.ExhibitNotFoundException = ExhibitNotFoundException;
88
81
  class LightningTalkNotFoundException extends DomainException {
89
- constructor(message = "指定されたライトニングトークが見つかりません") {
90
- super(message);
82
+ constructor(lightningTalkId) {
83
+ super(`指定されたライトニングトークが見つかりません: ${lightningTalkId}`);
91
84
  this.name = "LightningTalkNotFoundException";
92
85
  }
93
86
  }
94
87
  exports.LightningTalkNotFoundException = LightningTalkNotFoundException;
95
88
  class LightningTalkExhibitIdMismatchException extends DomainException {
96
- constructor(message = "指定されたライトニングトークのidが展示のidと一致していません") {
97
- super(message);
89
+ constructor(lightningTalkId, exhibitId) {
90
+ super(`指定されたライトニングトークのidが展示のidと一致していません: ライトニングトークID ${lightningTalkId}, 展示ID ${exhibitId}`);
98
91
  this.name = "LightningTalkExhibitIdMismatchException";
99
92
  }
100
93
  }
101
94
  exports.LightningTalkExhibitIdMismatchException = LightningTalkExhibitIdMismatchException;
102
95
  class ExhibitHasMemberException extends DomainException {
103
- constructor(message = "イベントに紐づいた展示に当該メンバーがいるため、Eventから削除できません") {
104
- super(message);
96
+ constructor(exhibitId, memberId) {
97
+ super(`イベントに紐づいた展示に当該メンバーがいるため、Eventから削除できません: 展示ID ${exhibitId}, メンバーID ${memberId}`);
105
98
  this.name = "ExhibitHasMemberException";
106
99
  }
107
100
  }
@@ -16,7 +16,7 @@ class Department extends ValueObject_1.ValueObject {
16
16
  "ALUMNI",
17
17
  "OTHERS",
18
18
  ];
19
- this.throwIfInvalid(validDepartments.includes(this.value), new exceptions_1.InvalidDepartmentException());
19
+ this.throwIfInvalid(validDepartments.includes(this.value), new exceptions_1.InvalidDepartmentException(this.value));
20
20
  }
21
21
  }
22
22
  exports.Department = Department;
@@ -6,7 +6,7 @@ const ValueObject_1 = require("./ValueObject");
6
6
  class Email extends ValueObject_1.ValueObject {
7
7
  validate() {
8
8
  const emailRegex = /^[a-zA-Z0-9._%+-]+@[a-zA-Z0-9.-]+\.[a-zA-Z]{2,}$/;
9
- this.throwIfInvalid(emailRegex.test(this.value), new exceptions_1.InvalidEmailFormatException());
9
+ this.throwIfInvalid(emailRegex.test(this.value), new exceptions_1.InvalidEmailFormatException(this.value));
10
10
  }
11
11
  }
12
12
  exports.Email = Email;
@@ -5,7 +5,7 @@ const exceptions_1 = require("../exceptions");
5
5
  const ValueObject_1 = require("./ValueObject");
6
6
  class LightningTalkDuration extends ValueObject_1.ValueObject {
7
7
  validate() {
8
- this.throwIfInvalid(this.value > 0, new exceptions_1.InvalidLightningTalkDurationException());
8
+ this.throwIfInvalid(this.value > 0, new exceptions_1.InvalidLightningTalkDurationException(this.value));
9
9
  }
10
10
  }
11
11
  exports.LightningTalkDuration = LightningTalkDuration;
@@ -7,7 +7,7 @@ const UNIVERSITY_EMAIL_DOMAIN = "@shizuoka.ac.jp";
7
7
  class UniversityEmail extends Email_1.Email {
8
8
  validate() {
9
9
  super.validate();
10
- this.throwIfInvalid(this.value.endsWith(UNIVERSITY_EMAIL_DOMAIN), new exceptions_1.InvalidUniversityEmailException());
10
+ this.throwIfInvalid(this.value.endsWith(UNIVERSITY_EMAIL_DOMAIN), new exceptions_1.InvalidUniversityEmailException(this.value));
11
11
  }
12
12
  }
13
13
  exports.UniversityEmail = UniversityEmail;
@@ -10,10 +10,10 @@ class Url extends ValueObject_1.ValueObject {
10
10
  parsed = new URL(this.value);
11
11
  }
12
12
  catch (_a) {
13
- this.throwIfInvalid(false, new exceptions_1.InvalidUrlException(`無効な URL 形式です: ${this.value}`));
13
+ this.throwIfInvalid(false, new exceptions_1.InvalidUrlException(this.value));
14
14
  return;
15
15
  }
16
- this.throwIfInvalid(["http:", "https:"].includes(parsed.protocol), new exceptions_1.InvalidUrlProtocolException());
16
+ this.throwIfInvalid(["http:", "https:"].includes(parsed.protocol), new exceptions_1.InvalidUrlProtocolException(this.value, parsed.protocol));
17
17
  }
18
18
  }
19
19
  exports.Url = Url;
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@shizuoka-its/core",
3
- "version": "2.0.1",
3
+ "version": "2.1.0",
4
4
  "description": "ITS core library",
5
5
  "main": "dist/index.js",
6
6
  "types": "dist/index.d.ts",