11import type { ObjectId } from "bson" ;
2- import type { AtLeast , Flags , TaskType } from "../types/mod.ts" ;
2+ import type { AtLeast } from "../types/mod.ts" ;
33import { Base , type BaseParameters } from "./Base.ts" ;
44
5+ /**
6+ * Parameters for creating a {@link Project} entity.
7+ */
58export interface ProjectParameters extends BaseParameters < "Project" > {
6- name : string ;
7- type : TaskType ;
9+ /** The organization id the project belongs to. */
10+ readonly organizationId : ObjectId ;
11+ /** The title of the project. */
12+ title : string ;
13+ /** The URL slug of the project (unique to the organization) */
814 slug : string ;
9- guidelines ?: string ;
15+ /** The color of the project shown in the UI. */
1016 bgColorClass : string ;
11- config : ObjectId ;
12- flags : Flags & {
13- isAnonymized : boolean ;
17+ /** Project flags. */
18+ flags : {
19+ /** Is the project active/archived? */
20+ isActive : boolean ;
21+ /** Is the project soft deleted? */
22+ isDeleted : boolean ;
1423 } ;
1524}
1625
26+ /**
27+ * Poject entity class for representing a reseach project.
28+ */
1729export class Project extends Base < "Project" > {
18- name : string ;
19- slug : string ;
20- type : TaskType ;
21- guidelines ?: string ;
22- bgColorClass : string ;
23- config : ObjectId ;
24- flags : Flags & {
25- isAnonymized : boolean ;
26- } ;
30+ readonly organizationId : ProjectParameters [ "organizationId" ] ;
31+ title : ProjectParameters [ "title" ] ;
32+ slug : ProjectParameters [ "slug" ] ;
33+ bgColorClass : ProjectParameters [ "bgColorClass" ] ;
34+ flags : ProjectParameters [ "flags" ] ;
2735
2836 constructor ( {
37+ organizationId,
2938 bgColorClass,
30- config,
3139 flags,
32- guidelines,
3340 slug,
34- name,
35- type,
41+ title,
3642 _id,
3743 _version,
3844 createdAt,
@@ -41,31 +47,32 @@ export class Project extends Base<"Project"> {
4147 updatedBy,
4248 } : AtLeast <
4349 ProjectParameters ,
44- "createdBy" | "bgColorClass" | "config" | " flags" | "slug" | "name " | "type "
50+ "createdBy" | "bgColorClass" | "flags" | "slug" | "title " | "organizationId "
4551 > ) {
4652 super ( { _id, _version, createdAt, updatedAt, createdBy, updatedBy } ) ;
4753
4854 this . bgColorClass = bgColorClass ;
49- this . config = config ;
5055 this . flags = flags ;
51- this . guidelines = guidelines ;
5256 this . slug = slug ;
53- this . name = name ;
54- this . type = type ;
57+ this . title = title ;
58+ this . organizationId = organizationId ;
5559 }
5660
61+ /**
62+ * Transforms the {@link Project} class object into a {@link ProjectParameters}-like
63+ * json object. Useful for saving the entity to the database.
64+ * @returns a json representation of the project entity.
65+ */
5766 toJSON ( ) : Omit < ProjectParameters , "kind" > {
5867 const json = super . toJSON ( ) ;
5968 return {
6069 ...json ,
6170 bgColorClass : this . bgColorClass ,
62- config : this . config ,
6371 flags : this . flags ,
64- guidelines : this . guidelines ,
6572 slug : this . slug ,
66- name : this . name ,
67- type : this . type ,
73+ title : this . title ,
6874 createdBy : this . createdBy ,
75+ organizationId : this . organizationId ,
6976 } ;
7077 }
7178}
0 commit comments