@shizuoka-its/core 2.0.0-alpha.1 → 2.0.0-alpha.3

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/domain/aggregates/event/Event.d.ts +39 -0
  2. package/dist/domain/aggregates/event/Event.js +68 -0
  3. package/dist/domain/aggregates/event/EventRepository.d.ts +7 -0
  4. package/dist/domain/aggregates/event/Exhibit.d.ts +31 -0
  5. package/dist/domain/aggregates/event/Exhibit.js +52 -0
  6. package/dist/domain/aggregates/event/LightningTalk.d.ts +17 -0
  7. package/dist/domain/aggregates/event/LightningTalk.js +30 -0
  8. package/dist/domain/aggregates/event/index.d.ts +4 -0
  9. package/dist/domain/aggregates/event/index.js +20 -0
  10. package/dist/domain/aggregates/index.d.ts +2 -0
  11. package/dist/domain/aggregates/index.js +18 -0
  12. package/dist/domain/{member → aggregates/member}/DiscordAccount.d.ts +5 -0
  13. package/dist/domain/{member → aggregates/member}/DiscordAccount.js +7 -0
  14. package/dist/domain/aggregates/member/Member.d.ts +38 -0
  15. package/dist/domain/{member → aggregates/member}/Member.js +25 -8
  16. package/dist/domain/aggregates/member/MemberRepository.js +2 -0
  17. package/dist/domain/exceptions/DomainExceptions.d.ts +18 -0
  18. package/dist/domain/exceptions/DomainExceptions.js +43 -1
  19. package/dist/domain/index.d.ts +1 -1
  20. package/dist/domain/index.js +1 -1
  21. package/dist/domain/value-objects/LightningTalkDuration.d.ts +4 -0
  22. package/dist/domain/value-objects/LightningTalkDuration.js +11 -0
  23. package/dist/domain/value-objects/Url.d.ts +4 -0
  24. package/dist/domain/value-objects/Url.js +19 -0
  25. package/dist/domain/value-objects/index.d.ts +3 -1
  26. package/dist/domain/value-objects/index.js +3 -1
  27. package/dist/executable/member.d.ts +9 -9
  28. package/dist/infrastructure/prisma/PrismaMemberRepository.js +17 -13
  29. package/package.json +1 -1
  30. package/dist/domain/member/Member.d.ts +0 -23
  31. /package/dist/domain/{member/MemberRepository.js → aggregates/event/EventRepository.js} +0 -0
  32. /package/dist/domain/{member → aggregates/member}/MemberRepository.d.ts +0 -0
  33. /package/dist/domain/{member → aggregates/member}/index.d.ts +0 -0
  34. /package/dist/domain/{member → aggregates/member}/index.js +0 -0
@@ -0,0 +1,39 @@
1
+ import type { LightningTalkDuration, Url } from "../../value-objects";
2
+ import type { Exhibit } from "./Exhibit";
3
+ export declare class Event {
4
+ readonly id: string;
5
+ private name;
6
+ private date;
7
+ private exhibits;
8
+ constructor(id: string, name: string, date: Date);
9
+ changeName(newName: string): void;
10
+ changeDate(newDate: Date): void;
11
+ addExhibit(exhibit: Exhibit): void;
12
+ removeExhibit(exhibitId: string): void;
13
+ changeExhibitName(exhibitId: string, newName: string): void;
14
+ changeExhibitDescription(exhibitId: string, newDescription: string): void;
15
+ changeExhibitMarkdownContent(exhibitId: string, newMarkdownContent: string): void;
16
+ changeExhibitUrl(exhibitId: string, newUrl: Url): void;
17
+ changeExhibitLightningTalkStartTime(exhibitId: string, newStartTime: Date): void;
18
+ changeExhibitLightningTalkDuration(exhibitId: string, newDuration: LightningTalkDuration): void;
19
+ changeExhibitLightningTalkSlideUrl(exhibitId: string, newSlideUrl: Url): void;
20
+ private getExhibitOrThrow;
21
+ toSnapshot(): {
22
+ id: string;
23
+ name: string;
24
+ date: Date;
25
+ exhibits: {
26
+ id: string;
27
+ name: string;
28
+ description: string | undefined;
29
+ markdownContent: string | undefined;
30
+ url: Url | undefined;
31
+ lightningTalk: {
32
+ exhibitId: string;
33
+ startTime: Date;
34
+ durationMinutes: LightningTalkDuration;
35
+ slideUrl: Url | undefined;
36
+ } | undefined;
37
+ }[];
38
+ };
39
+ }
@@ -0,0 +1,68 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ exports.Event = void 0;
4
+ const exceptions_1 = require("../../exceptions");
5
+ class Event {
6
+ constructor(id, name,
7
+ // TODO: 期間を指定したい
8
+ date) {
9
+ this.id = id;
10
+ this.name = name;
11
+ this.date = date;
12
+ this.exhibits = [];
13
+ }
14
+ changeName(newName) {
15
+ this.name = newName;
16
+ }
17
+ changeDate(newDate) {
18
+ // NOTE: 時間を変更した時に、時間系のプロパティを持つエンティティの時間を変更する必要がある?
19
+ this.date = newDate;
20
+ }
21
+ addExhibit(exhibit) {
22
+ if (this.exhibits.some((x) => x.id === exhibit.id)) {
23
+ throw new exceptions_1.ExhibitAlreadyExistsException(`Exhibit(id=${exhibit.id}) は既に存在します`);
24
+ }
25
+ this.exhibits.push(exhibit);
26
+ }
27
+ removeExhibit(exhibitId) {
28
+ this.getExhibitOrThrow(exhibitId);
29
+ this.exhibits = this.exhibits.filter((x) => x.id !== exhibitId);
30
+ }
31
+ changeExhibitName(exhibitId, newName) {
32
+ this.getExhibitOrThrow(exhibitId).changeName(newName);
33
+ }
34
+ changeExhibitDescription(exhibitId, newDescription) {
35
+ this.getExhibitOrThrow(exhibitId).changeDescription(newDescription);
36
+ }
37
+ changeExhibitMarkdownContent(exhibitId, newMarkdownContent) {
38
+ this.getExhibitOrThrow(exhibitId).changeMarkdownContent(newMarkdownContent);
39
+ }
40
+ changeExhibitUrl(exhibitId, newUrl) {
41
+ this.getExhibitOrThrow(exhibitId).changeUrl(newUrl);
42
+ }
43
+ changeExhibitLightningTalkStartTime(exhibitId, newStartTime) {
44
+ this.getExhibitOrThrow(exhibitId).changeLightningTalkStartTime(newStartTime);
45
+ }
46
+ changeExhibitLightningTalkDuration(exhibitId, newDuration) {
47
+ this.getExhibitOrThrow(exhibitId).changeLightningTalkDuration(newDuration);
48
+ }
49
+ changeExhibitLightningTalkSlideUrl(exhibitId, newSlideUrl) {
50
+ this.getExhibitOrThrow(exhibitId).changeLightningTalkSlideUrl(newSlideUrl);
51
+ }
52
+ getExhibitOrThrow(exhibitId) {
53
+ const exhibit = this.exhibits.find((x) => x.id === exhibitId);
54
+ if (!exhibit) {
55
+ throw new exceptions_1.ExhibitNotFoundException(`Exhibit(id=${exhibitId}) が見つかりません`);
56
+ }
57
+ return exhibit;
58
+ }
59
+ toSnapshot() {
60
+ return {
61
+ id: this.id,
62
+ name: this.name,
63
+ date: this.date,
64
+ exhibits: this.exhibits.map((exhibit) => exhibit.toSnapshot()),
65
+ };
66
+ }
67
+ }
68
+ exports.Event = Event;
@@ -0,0 +1,7 @@
1
+ import type { Event } from "./Event";
2
+ export interface EventRepository {
3
+ findById(id: string): Promise<Event | null>;
4
+ findAll(): Promise<Event[]>;
5
+ save(event: Event): Promise<void>;
6
+ delete(eventId: string): Promise<void>;
7
+ }
@@ -0,0 +1,31 @@
1
+ import type { LightningTalkDuration, Url } from "../../value-objects";
2
+ export declare class Exhibit {
3
+ readonly id: string;
4
+ private name;
5
+ private description?;
6
+ private markdownContent?;
7
+ private url?;
8
+ private lightningTalk?;
9
+ constructor(id: string, name: string, description?: string | undefined, markdownContent?: string | undefined, url?: Url | undefined);
10
+ changeName(newName: string): void;
11
+ changeDescription(newDescription: string): void;
12
+ changeMarkdownContent(newMarkdownContent: string): void;
13
+ changeUrl(newUrl: Url): void;
14
+ changeLightningTalkStartTime(newStartTime: Date): void;
15
+ changeLightningTalkDuration(newDuration: LightningTalkDuration): void;
16
+ changeLightningTalkSlideUrl(newSlideUrl: Url): void;
17
+ private getLightningTalkOrThrow;
18
+ toSnapshot(): {
19
+ id: string;
20
+ name: string;
21
+ description: string | undefined;
22
+ markdownContent: string | undefined;
23
+ url: Url | undefined;
24
+ lightningTalk: {
25
+ exhibitId: string;
26
+ startTime: Date;
27
+ durationMinutes: LightningTalkDuration;
28
+ slideUrl: Url | undefined;
29
+ } | undefined;
30
+ };
31
+ }
@@ -0,0 +1,52 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ exports.Exhibit = void 0;
4
+ const exceptions_1 = require("../../exceptions");
5
+ class Exhibit {
6
+ constructor(id, name, description, markdownContent, url) {
7
+ this.id = id;
8
+ this.name = name;
9
+ this.description = description;
10
+ this.markdownContent = markdownContent;
11
+ this.url = url;
12
+ }
13
+ changeName(newName) {
14
+ this.name = newName;
15
+ }
16
+ changeDescription(newDescription) {
17
+ this.description = newDescription;
18
+ }
19
+ changeMarkdownContent(newMarkdownContent) {
20
+ this.markdownContent = newMarkdownContent;
21
+ }
22
+ changeUrl(newUrl) {
23
+ this.url = newUrl;
24
+ }
25
+ changeLightningTalkStartTime(newStartTime) {
26
+ this.getLightningTalkOrThrow().changeStartTime(newStartTime);
27
+ }
28
+ changeLightningTalkDuration(newDuration) {
29
+ this.getLightningTalkOrThrow().changeDuration(newDuration);
30
+ }
31
+ changeLightningTalkSlideUrl(newSlideUrl) {
32
+ this.getLightningTalkOrThrow().changeSlideUrl(newSlideUrl);
33
+ }
34
+ getLightningTalkOrThrow() {
35
+ if (!this.lightningTalk) {
36
+ throw new exceptions_1.LightningTalkNotFoundException(`Exhibit(id=${this.id}) に紐づく LightningTalk が存在しません`);
37
+ }
38
+ return this.lightningTalk;
39
+ }
40
+ toSnapshot() {
41
+ var _a;
42
+ return {
43
+ id: this.id,
44
+ name: this.name,
45
+ description: this.description,
46
+ markdownContent: this.markdownContent,
47
+ url: this.url,
48
+ lightningTalk: (_a = this.lightningTalk) === null || _a === void 0 ? void 0 : _a.toSnapshot(),
49
+ };
50
+ }
51
+ }
52
+ exports.Exhibit = Exhibit;
@@ -0,0 +1,17 @@
1
+ import type { LightningTalkDuration, Url } from "../../value-objects";
2
+ export declare class LightningTalk {
3
+ readonly exhibitId: string;
4
+ private startTime;
5
+ private durationMinutes;
6
+ private slideUrl?;
7
+ constructor(exhibitId: string, startTime: Date, durationMinutes: LightningTalkDuration, slideUrl?: Url | undefined);
8
+ changeSlideUrl(newSlideUrl: Url): void;
9
+ changeDuration(newDuration: LightningTalkDuration): void;
10
+ changeStartTime(newStartTime: Date): void;
11
+ toSnapshot(): {
12
+ exhibitId: string;
13
+ startTime: Date;
14
+ durationMinutes: LightningTalkDuration;
15
+ slideUrl: Url | undefined;
16
+ };
17
+ }
@@ -0,0 +1,30 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ exports.LightningTalk = void 0;
4
+ class LightningTalk {
5
+ constructor(exhibitId, startTime, durationMinutes, slideUrl) {
6
+ this.exhibitId = exhibitId;
7
+ this.startTime = startTime;
8
+ this.durationMinutes = durationMinutes;
9
+ this.slideUrl = slideUrl;
10
+ }
11
+ changeSlideUrl(newSlideUrl) {
12
+ this.slideUrl = newSlideUrl;
13
+ }
14
+ changeDuration(newDuration) {
15
+ this.durationMinutes = newDuration;
16
+ }
17
+ // TODO: イベントの期間内かどうかをチェックする必要がある?
18
+ changeStartTime(newStartTime) {
19
+ this.startTime = newStartTime;
20
+ }
21
+ toSnapshot() {
22
+ return {
23
+ exhibitId: this.exhibitId,
24
+ startTime: this.startTime,
25
+ durationMinutes: this.durationMinutes,
26
+ slideUrl: this.slideUrl,
27
+ };
28
+ }
29
+ }
30
+ exports.LightningTalk = LightningTalk;
@@ -0,0 +1,4 @@
1
+ export * from "./Event";
2
+ export * from "./EventRepository";
3
+ export * from "./Exhibit";
4
+ export * from "./LightningTalk";
@@ -0,0 +1,20 @@
1
+ "use strict";
2
+ var __createBinding = (this && this.__createBinding) || (Object.create ? (function(o, m, k, k2) {
3
+ if (k2 === undefined) k2 = k;
4
+ var desc = Object.getOwnPropertyDescriptor(m, k);
5
+ if (!desc || ("get" in desc ? !m.__esModule : desc.writable || desc.configurable)) {
6
+ desc = { enumerable: true, get: function() { return m[k]; } };
7
+ }
8
+ Object.defineProperty(o, k2, desc);
9
+ }) : (function(o, m, k, k2) {
10
+ if (k2 === undefined) k2 = k;
11
+ o[k2] = m[k];
12
+ }));
13
+ var __exportStar = (this && this.__exportStar) || function(m, exports) {
14
+ for (var p in m) if (p !== "default" && !Object.prototype.hasOwnProperty.call(exports, p)) __createBinding(exports, m, p);
15
+ };
16
+ Object.defineProperty(exports, "__esModule", { value: true });
17
+ __exportStar(require("./Event"), exports);
18
+ __exportStar(require("./EventRepository"), exports);
19
+ __exportStar(require("./Exhibit"), exports);
20
+ __exportStar(require("./LightningTalk"), exports);
@@ -0,0 +1,2 @@
1
+ export * from "./event";
2
+ export * from "./member";
@@ -0,0 +1,18 @@
1
+ "use strict";
2
+ var __createBinding = (this && this.__createBinding) || (Object.create ? (function(o, m, k, k2) {
3
+ if (k2 === undefined) k2 = k;
4
+ var desc = Object.getOwnPropertyDescriptor(m, k);
5
+ if (!desc || ("get" in desc ? !m.__esModule : desc.writable || desc.configurable)) {
6
+ desc = { enumerable: true, get: function() { return m[k]; } };
7
+ }
8
+ Object.defineProperty(o, k2, desc);
9
+ }) : (function(o, m, k, k2) {
10
+ if (k2 === undefined) k2 = k;
11
+ o[k2] = m[k];
12
+ }));
13
+ var __exportStar = (this && this.__exportStar) || function(m, exports) {
14
+ for (var p in m) if (p !== "default" && !Object.prototype.hasOwnProperty.call(exports, p)) __createBinding(exports, m, p);
15
+ };
16
+ Object.defineProperty(exports, "__esModule", { value: true });
17
+ __exportStar(require("./event"), exports);
18
+ __exportStar(require("./member"), exports);
@@ -5,4 +5,9 @@ export declare class DiscordAccount {
5
5
  constructor(id: string, // Discord ID
6
6
  nickName: string, memberId: string);
7
7
  setNickName(newNickName: string): void;
8
+ toSnapshot(): {
9
+ id: string;
10
+ nickName: string;
11
+ memberId: string;
12
+ };
8
13
  }
@@ -11,5 +11,12 @@ class DiscordAccount {
11
11
  setNickName(newNickName) {
12
12
  this.nickName = newNickName;
13
13
  }
14
+ toSnapshot() {
15
+ return {
16
+ id: this.id,
17
+ nickName: this.nickName,
18
+ memberId: this.memberId,
19
+ };
20
+ }
14
21
  }
15
22
  exports.DiscordAccount = DiscordAccount;
@@ -0,0 +1,38 @@
1
+ import type { Department } from "../../value-objects/Departments";
2
+ import type { Email } from "../../value-objects/Email";
3
+ import type { UniversityEmail } from "../../value-objects/UniversityEmail";
4
+ import type { DiscordAccount } from "./DiscordAccount";
5
+ export declare class Member {
6
+ readonly id: string;
7
+ private name;
8
+ private studentId;
9
+ private department;
10
+ private email;
11
+ private personalEmail?;
12
+ private discordAccounts;
13
+ constructor(id: string, name: string, studentId: string, department: Department, email: UniversityEmail, personalEmail?: Email | undefined);
14
+ setName(newName: string): void;
15
+ setStudentId(newStudentId: string): void;
16
+ setDepartment(newDepartment: Department): void;
17
+ setEmail(newEmail: UniversityEmail): void;
18
+ setPersonalEmail(newPersonalEmail?: Email): void;
19
+ addDiscordAccount(discordAccount: DiscordAccount): void;
20
+ removeDiscordAccount(discordAccountId: string): void;
21
+ getDiscordAccounts(): DiscordAccount[];
22
+ getDiscordAccountById(discordAccountId: string): DiscordAccount | undefined;
23
+ getDiscordAccountOrThrow(discordAccountId: string): DiscordAccount;
24
+ setDiscordAccountNickName(discordAccountId: string, newNickName: string): void;
25
+ toSnapshot(): {
26
+ id: string;
27
+ name: string;
28
+ studentId: string;
29
+ department: Department;
30
+ email: UniversityEmail;
31
+ personalEmail: Email | undefined;
32
+ discordAccounts: {
33
+ id: string;
34
+ nickName: string;
35
+ memberId: string;
36
+ }[];
37
+ };
38
+ }
@@ -1,7 +1,7 @@
1
1
  "use strict";
2
2
  Object.defineProperty(exports, "__esModule", { value: true });
3
3
  exports.Member = void 0;
4
- const DomainExceptions_1 = require("../exceptions/DomainExceptions");
4
+ const DomainExceptions_1 = require("../../exceptions/DomainExceptions");
5
5
  class Member {
6
6
  constructor(id, name, studentId, department, email, personalEmail) {
7
7
  this.id = id;
@@ -28,18 +28,14 @@ class Member {
28
28
  this.personalEmail = newPersonalEmail;
29
29
  }
30
30
  addDiscordAccount(discordAccount) {
31
- const existingAccount = this.discordAccounts.find((account) => account.id === discordAccount.id);
32
- if (existingAccount) {
31
+ if (this.getDiscordAccountById(discordAccount.id)) {
33
32
  throw new DomainExceptions_1.DiscordAccountAlreadyConnectedException();
34
33
  }
35
34
  this.discordAccounts.push(discordAccount);
36
35
  }
37
36
  removeDiscordAccount(discordAccountId) {
38
- const accountIndex = this.discordAccounts.findIndex((account) => account.id === discordAccountId);
39
- if (accountIndex === -1) {
40
- throw new DomainExceptions_1.DiscordAccountNotConnectedException();
41
- }
42
- this.discordAccounts.splice(accountIndex, 1);
37
+ this.getDiscordAccountOrThrow(discordAccountId);
38
+ this.discordAccounts = this.discordAccounts.filter((account) => account.id !== discordAccountId);
43
39
  }
44
40
  getDiscordAccounts() {
45
41
  return this.discordAccounts;
@@ -47,5 +43,26 @@ class Member {
47
43
  getDiscordAccountById(discordAccountId) {
48
44
  return this.discordAccounts.find((account) => account.id === discordAccountId);
49
45
  }
46
+ getDiscordAccountOrThrow(discordAccountId) {
47
+ const account = this.getDiscordAccountById(discordAccountId);
48
+ if (!account) {
49
+ throw new DomainExceptions_1.DiscordAccountNotConnectedException();
50
+ }
51
+ return account;
52
+ }
53
+ setDiscordAccountNickName(discordAccountId, newNickName) {
54
+ this.getDiscordAccountOrThrow(discordAccountId).setNickName(newNickName);
55
+ }
56
+ toSnapshot() {
57
+ return {
58
+ id: this.id,
59
+ name: this.name,
60
+ studentId: this.studentId,
61
+ department: this.department,
62
+ email: this.email,
63
+ personalEmail: this.personalEmail,
64
+ discordAccounts: this.discordAccounts.map((account) => account.toSnapshot()),
65
+ };
66
+ }
50
67
  }
51
68
  exports.Member = Member;
@@ -0,0 +1,2 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
@@ -19,3 +19,21 @@ export declare class InvalidUniversityEmailException extends DomainException {
19
19
  export declare class InvalidDepartmentException extends DomainException {
20
20
  constructor(message?: string);
21
21
  }
22
+ export declare class InvalidLightningTalkDurationException extends DomainException {
23
+ constructor(message?: string);
24
+ }
25
+ export declare class InvalidUrlException extends DomainException {
26
+ constructor(message?: string);
27
+ }
28
+ export declare class InvalidUrlProtocolException extends DomainException {
29
+ constructor(message?: string);
30
+ }
31
+ export declare class ExhibitAlreadyExistsException extends DomainException {
32
+ constructor(message?: string);
33
+ }
34
+ export declare class ExhibitNotFoundException extends DomainException {
35
+ constructor(message?: string);
36
+ }
37
+ export declare class LightningTalkNotFoundException extends DomainException {
38
+ constructor(message?: string);
39
+ }
@@ -1,6 +1,6 @@
1
1
  "use strict";
2
2
  Object.defineProperty(exports, "__esModule", { value: true });
3
- exports.InvalidDepartmentException = exports.InvalidUniversityEmailException = exports.DiscordAccountNotConnectedException = exports.DiscordAccountAlreadyConnectedException = exports.InvalidEmailFormatException = exports.InvalidMemberException = exports.DomainException = void 0;
3
+ 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;
4
4
  class DomainException extends Error {
5
5
  constructor(message) {
6
6
  super(message);
@@ -50,3 +50,45 @@ class InvalidDepartmentException extends DomainException {
50
50
  }
51
51
  }
52
52
  exports.InvalidDepartmentException = InvalidDepartmentException;
53
+ class InvalidLightningTalkDurationException extends DomainException {
54
+ constructor(message = "無効なライトニングトークの長さです") {
55
+ super(message);
56
+ this.name = "InvalidLightningTalkDurationException";
57
+ }
58
+ }
59
+ exports.InvalidLightningTalkDurationException = InvalidLightningTalkDurationException;
60
+ class InvalidUrlException extends DomainException {
61
+ constructor(message = "無効なURLです") {
62
+ super(message);
63
+ this.name = "InvalidUrlException";
64
+ }
65
+ }
66
+ exports.InvalidUrlException = InvalidUrlException;
67
+ class InvalidUrlProtocolException extends DomainException {
68
+ constructor(message = "指定されたURLのプロトコルは許可されていません。httpまたはhttpsを使用してください。") {
69
+ super(message);
70
+ this.name = "InvalidUrlProtocolException";
71
+ }
72
+ }
73
+ exports.InvalidUrlProtocolException = InvalidUrlProtocolException;
74
+ class ExhibitAlreadyExistsException extends DomainException {
75
+ constructor(message = "既に同一の展示が登録されています") {
76
+ super(message);
77
+ this.name = "ExhibitAlreadyExistsException";
78
+ }
79
+ }
80
+ exports.ExhibitAlreadyExistsException = ExhibitAlreadyExistsException;
81
+ class ExhibitNotFoundException extends DomainException {
82
+ constructor(message = "指定された展示が見つかりません") {
83
+ super(message);
84
+ this.name = "ExhibitNotFoundException";
85
+ }
86
+ }
87
+ exports.ExhibitNotFoundException = ExhibitNotFoundException;
88
+ class LightningTalkNotFoundException extends DomainException {
89
+ constructor(message = "指定されたライトニングトークが見つかりません") {
90
+ super(message);
91
+ this.name = "LightningTalkNotFoundException";
92
+ }
93
+ }
94
+ exports.LightningTalkNotFoundException = LightningTalkNotFoundException;
@@ -1,3 +1,3 @@
1
- export * from "./member";
2
1
  export * from "./value-objects";
3
2
  export * from "./exceptions";
3
+ export * from "./aggregates";
@@ -14,6 +14,6 @@ var __exportStar = (this && this.__exportStar) || function(m, exports) {
14
14
  for (var p in m) if (p !== "default" && !Object.prototype.hasOwnProperty.call(exports, p)) __createBinding(exports, m, p);
15
15
  };
16
16
  Object.defineProperty(exports, "__esModule", { value: true });
17
- __exportStar(require("./member"), exports);
18
17
  __exportStar(require("./value-objects"), exports);
19
18
  __exportStar(require("./exceptions"), exports);
19
+ __exportStar(require("./aggregates"), exports);
@@ -0,0 +1,4 @@
1
+ import { ValueObject } from "./ValueObject";
2
+ export declare class LightningTalkDuration extends ValueObject<number> {
3
+ protected validate(): void;
4
+ }
@@ -0,0 +1,11 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ exports.LightningTalkDuration = void 0;
4
+ const exceptions_1 = require("../exceptions");
5
+ const ValueObject_1 = require("./ValueObject");
6
+ class LightningTalkDuration extends ValueObject_1.ValueObject {
7
+ validate() {
8
+ this.throwIfInvalid(this.value > 0, new exceptions_1.InvalidLightningTalkDurationException());
9
+ }
10
+ }
11
+ exports.LightningTalkDuration = LightningTalkDuration;
@@ -0,0 +1,4 @@
1
+ import { ValueObject } from "./ValueObject";
2
+ export declare class Url extends ValueObject<string> {
3
+ protected validate(): void;
4
+ }
@@ -0,0 +1,19 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ exports.Url = void 0;
4
+ const exceptions_1 = require("../exceptions");
5
+ const ValueObject_1 = require("./ValueObject");
6
+ class Url extends ValueObject_1.ValueObject {
7
+ validate() {
8
+ let parsed;
9
+ try {
10
+ parsed = new URL(this.value);
11
+ }
12
+ catch (_a) {
13
+ this.throwIfInvalid(false, new exceptions_1.InvalidUrlException(`無効な URL 形式です: ${this.value}`));
14
+ return;
15
+ }
16
+ this.throwIfInvalid(["http:", "https:"].includes(parsed.protocol), new exceptions_1.InvalidUrlProtocolException());
17
+ }
18
+ }
19
+ exports.Url = Url;
@@ -1,4 +1,6 @@
1
+ export * from "./Departments";
1
2
  export * from "./Email";
3
+ export * from "./LightningTalkDuration";
2
4
  export * from "./UniversityEmail";
3
- export * from "./Departments";
5
+ export * from "./Url";
4
6
  export * from "./ValueObject";
@@ -14,7 +14,9 @@ var __exportStar = (this && this.__exportStar) || function(m, exports) {
14
14
  for (var p in m) if (p !== "default" && !Object.prototype.hasOwnProperty.call(exports, p)) __createBinding(exports, m, p);
15
15
  };
16
16
  Object.defineProperty(exports, "__esModule", { value: true });
17
+ __exportStar(require("./Departments"), exports);
17
18
  __exportStar(require("./Email"), exports);
19
+ __exportStar(require("./LightningTalkDuration"), exports);
18
20
  __exportStar(require("./UniversityEmail"), exports);
19
- __exportStar(require("./Departments"), exports);
21
+ __exportStar(require("./Url"), exports);
20
22
  __exportStar(require("./ValueObject"), exports);
@@ -1,12 +1,12 @@
1
- import type { ChangeDiscordNickNameInput, ChangeDiscordNickNameOutput, ConnectDiscordAccountInput, ConnectDiscordAccountOutput, GetMemberByDiscordIdInput, GetMemberByDiscordIdOutput, GetMemberByEmailInput, GetMemberByEmailOutput, GetMemberInput, GetMemberListInput, GetMemberListOutput, GetMemberOutput, IUseCase, RegisterMemberInput, RegisterMemberOutput, UpdateMemberInput, UpdateMemberOutput } from "../application";
1
+ import { ChangeDiscordNickNameUseCase, ConnectDiscordAccountUseCase, GetMemberByDiscordIdUseCase, GetMemberByEmailUseCase, GetMemberListUseCase, GetMemberUseCase, RegisterMemberUseCase, UpdateMemberUseCase } from "../application";
2
2
  export type MemberUseCases = {
3
- registerMember: IUseCase<RegisterMemberInput, RegisterMemberOutput>;
4
- updateMember: IUseCase<UpdateMemberInput, UpdateMemberOutput>;
5
- getMember: IUseCase<GetMemberInput, GetMemberOutput>;
6
- getMemberByEmail: IUseCase<GetMemberByEmailInput, GetMemberByEmailOutput>;
7
- getMemberByDiscordId: IUseCase<GetMemberByDiscordIdInput, GetMemberByDiscordIdOutput>;
8
- getMemberList: IUseCase<GetMemberListInput, GetMemberListOutput>;
9
- changeDiscordNickName: IUseCase<ChangeDiscordNickNameInput, ChangeDiscordNickNameOutput>;
10
- connectDiscordAccount: IUseCase<ConnectDiscordAccountInput, ConnectDiscordAccountOutput>;
3
+ registerMember: RegisterMemberUseCase;
4
+ updateMember: UpdateMemberUseCase;
5
+ getMember: GetMemberUseCase;
6
+ getMemberByEmail: GetMemberByEmailUseCase;
7
+ getMemberByDiscordId: GetMemberByDiscordIdUseCase;
8
+ getMemberList: GetMemberListUseCase;
9
+ changeDiscordNickName: ChangeDiscordNickNameUseCase;
10
+ connectDiscordAccount: ConnectDiscordAccountUseCase;
11
11
  };
12
12
  export declare function createMemberUseCases(): MemberUseCases;
@@ -7,6 +7,9 @@ const prisma = new client_1.PrismaClient();
7
7
  class PrismaMemberRepository {
8
8
  toDomain(record) {
9
9
  const member = new domain_1.Member(record.id, record.name, record.studentId, domain_1.Department.fromString(record.department), new domain_1.UniversityEmail(record.email), record.personalEmail ? new domain_1.Email(record.personalEmail) : undefined);
10
+ for (const discordAccount of record.discordAccounts) {
11
+ member.addDiscordAccount(new domain_1.DiscordAccount(discordAccount.id, discordAccount.nickName, discordAccount.memberId));
12
+ }
10
13
  return member;
11
14
  }
12
15
  async findByDiscordAccountId(discordAccountId) {
@@ -53,25 +56,26 @@ class PrismaMemberRepository {
53
56
  }
54
57
  async save(member) {
55
58
  var _a, _b;
59
+ const memberSnapshot = member.toSnapshot();
56
60
  await prisma.member.upsert({
57
- where: { id: member.id },
61
+ where: { id: memberSnapshot.id },
58
62
  update: {
59
- name: member.name,
60
- studentId: member.studentId,
61
- department: member.department.toString(),
62
- email: member.email.getValue(),
63
- personalEmail: (_a = member.personalEmail) === null || _a === void 0 ? void 0 : _a.getValue(),
63
+ name: memberSnapshot.name,
64
+ studentId: memberSnapshot.studentId,
65
+ department: memberSnapshot.department.toString(),
66
+ email: memberSnapshot.email.getValue(),
67
+ personalEmail: (_a = memberSnapshot.personalEmail) === null || _a === void 0 ? void 0 : _a.getValue(),
64
68
  },
65
69
  create: {
66
- id: member.id,
67
- name: member.name,
68
- studentId: member.studentId,
69
- department: member.department.toString(),
70
- email: member.email.getValue(),
71
- personalEmail: (_b = member.personalEmail) === null || _b === void 0 ? void 0 : _b.getValue(),
70
+ id: memberSnapshot.id,
71
+ name: memberSnapshot.name,
72
+ studentId: memberSnapshot.studentId,
73
+ department: memberSnapshot.department.toString(),
74
+ email: memberSnapshot.email.getValue(),
75
+ personalEmail: (_b = memberSnapshot.personalEmail) === null || _b === void 0 ? void 0 : _b.getValue(),
72
76
  },
73
77
  });
74
- for (const discordAccount of member.getDiscordAccounts()) {
78
+ for (const discordAccount of memberSnapshot.discordAccounts) {
75
79
  await prisma.discordAccount.upsert({
76
80
  where: { id: discordAccount.id },
77
81
  update: { nickName: discordAccount.nickName },
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@shizuoka-its/core",
3
- "version": "2.0.0-alpha.1",
3
+ "version": "2.0.0-alpha.3",
4
4
  "description": "ITS core library",
5
5
  "main": "dist/index.js",
6
6
  "types": "dist/index.d.ts",
@@ -1,23 +0,0 @@
1
- import type { Department } from "../value-objects/Departments";
2
- import type { Email } from "../value-objects/Email";
3
- import type { UniversityEmail } from "../value-objects/UniversityEmail";
4
- import type { DiscordAccount } from "./DiscordAccount";
5
- export declare class Member {
6
- readonly id: string;
7
- name: string;
8
- studentId: string;
9
- department: Department;
10
- email: UniversityEmail;
11
- personalEmail?: Email | undefined;
12
- private discordAccounts;
13
- constructor(id: string, name: string, studentId: string, department: Department, email: UniversityEmail, personalEmail?: Email | undefined);
14
- setName(newName: string): void;
15
- setStudentId(newStudentId: string): void;
16
- setDepartment(newDepartment: Department): void;
17
- setEmail(newEmail: UniversityEmail): void;
18
- setPersonalEmail(newPersonalEmail?: Email): void;
19
- addDiscordAccount(discordAccount: DiscordAccount): void;
20
- removeDiscordAccount(discordAccountId: string): void;
21
- getDiscordAccounts(): DiscordAccount[];
22
- getDiscordAccountById(discordAccountId: string): DiscordAccount | undefined;
23
- }