11import { Document , Schema } from 'mongoose' ;
22import { field } from '../utils' ;
3- import { ACTIVITY_ACTIONS , ACTIVITY_PERFORMER_TYPES , ACTIVITY_TYPES , COC_CONTENT_TYPES } from './constants' ;
3+ import { ACTIVITY_ACTIONS , ACTIVITY_CONTENT_TYPES , ACTIVITY_PERFORMER_TYPES , ACTIVITY_TYPES } from './constants' ;
44
55export interface IActionPerformer {
66 type : string ;
@@ -22,23 +22,30 @@ interface IActivityDocument extends IActivity, Document {
2222 id ?: string ;
2323}
2424
25- export interface ICoc {
25+ export interface IContentType {
2626 id : string ;
2727 type : string ;
2828}
2929
30- interface ICocDocument extends ICoc , Document {
30+ interface IContentTypeDocument extends IContentType , Document {
3131 id : string ;
3232}
3333
3434export interface IActivityLogDocument extends Document {
3535 _id : string ;
3636 activity : IActivityDocument ;
3737 performedBy ?: IActionPerformerDocument ;
38- coc : ICocDocument ;
38+ contentType : IContentTypeDocument ;
3939 createdAt : Date ;
4040}
4141
42+ export interface IActivityLog {
43+ contentType : string ;
44+ contentId : string ;
45+ activityType : string ;
46+ limit : number ;
47+ }
48+
4249// Mongoose schemas ===========
4350
4451/* Performer of the action:
@@ -105,15 +112,15 @@ const activitySchema = new Schema(
105112
106113/* the customer that is related to a given ActivityLog
107114 can be both Company or Customer documents */
108- const cocSchema = new Schema (
115+ const contentTypeSchema = new Schema (
109116 {
110117 id : field ( {
111118 type : String ,
112119 required : true ,
113120 } ) ,
114121 type : field ( {
115122 type : String ,
116- enum : COC_CONTENT_TYPES . ALL ,
123+ enum : ACTIVITY_CONTENT_TYPES . ALL ,
117124 required : true ,
118125 } ) ,
119126 } ,
@@ -124,7 +131,9 @@ export const activityLogSchema = new Schema({
124131 _id : field ( { pkey : true } ) ,
125132 activity : { type : activitySchema } ,
126133 performedBy : { type : actionPerformerSchema , optional : true } ,
127- coc : { type : cocSchema } ,
134+ contentType : { type : contentTypeSchema } ,
135+ // TODO: remove
136+ coc : { type : contentTypeSchema , optional : true } ,
128137
129138 createdAt : field ( {
130139 type : Date ,
0 commit comments