2025-05-10 02:09:06 +02:00
/ * !
* Copyright ( c ) 2024 PLANKA Software GmbH
* Licensed under the Fair Use License : https : //github.com/plankanban/planka/blob/master/LICENSE.md
* /
2019-08-31 04:07:25 +05:00
/ * *
* Action . js
*
* @ description : : A model definition represents a database table / collection .
* @ docs : : https : //sailsjs.com/docs/concepts/models-and-orm/models
* /
2025-09-08 16:20:27 +02:00
/ * *
* @ swagger
* components :
* schemas :
* Action :
* type : object
* required :
2025-09-08 23:40:36 +02:00
* - id
2025-09-12 12:17:01 +02:00
* - boardId
2025-09-08 16:20:27 +02:00
* - cardId
2025-09-12 12:17:01 +02:00
* - userId
2025-09-08 16:20:27 +02:00
* - type
* - data
2025-09-12 12:17:01 +02:00
* - createdAt
* - updatedAt
2025-09-08 16:20:27 +02:00
* properties :
* id :
* type : string
* description : Unique identifier for the action
2025-09-08 19:14:31 +02:00
* example : "1357158568008091264"
2025-09-08 16:20:27 +02:00
* boardId :
* type : string
* nullable : true
* description : ID of the board where the action occurred
2025-09-08 19:14:31 +02:00
* example : "1357158568008091265"
2025-09-08 16:20:27 +02:00
* cardId :
* type : string
* description : ID of the card where the action occurred
2025-09-08 19:14:31 +02:00
* example : "1357158568008091266"
2025-09-08 16:20:27 +02:00
* userId :
* type : string
* nullable : true
* description : ID of the user who performed the action
2025-09-08 19:14:31 +02:00
* example : "1357158568008091267"
2025-09-08 16:20:27 +02:00
* type :
* type : string
* enum : [ createCard , moveCard , addMemberToCard , removeMemberFromCard , completeTask , uncompleteTask ]
* description : Type of the action
* example : moveCard
* data :
* type : object
* description : Action specific data ( varies by type )
* example : { "card" : { "name" : "Implement user authentication" } , "toList" : { "id" : "1357158568008091268" , "name" : "To Do" , "type" : "active" } , "fromList" : { "id" : "1357158568008091269" , "name" : "Done" , "type" : "closed" } }
* createdAt :
* type : string
* format : date - time
* nullable : true
* description : When the action was created
* example : 2024 - 01 - 01 T00 : 00 : 00.000 Z
* updatedAt :
* type : string
* format : date - time
* nullable : true
* description : When the action was last updated
* example : 2024 - 01 - 01 T00 : 00 : 00.000 Z
* /
2021-06-24 01:05:22 +05:00
const Types = {
CREATE _CARD : 'createCard' ,
MOVE _CARD : 'moveCard' ,
2025-05-17 01:50:40 +02:00
ADD _MEMBER _TO _CARD : 'addMemberToCard' ,
2025-05-17 22:24:37 +02:00
REMOVE _MEMBER _FROM _CARD : 'removeMemberFromCard' ,
2025-05-20 21:17:51 +02:00
COMPLETE _TASK : 'completeTask' ,
UNCOMPLETE _TASK : 'uncompleteTask' ,
2021-06-24 01:05:22 +05:00
} ;
2019-08-31 04:07:25 +05:00
2025-05-17 22:24:37 +02:00
const INTERNAL _NOTIFIABLE _TYPES = [ Types . MOVE _CARD , Types . ADD _MEMBER _TO _CARD ] ;
const EXTERNAL _NOTIFIABLE _TYPES = [ Types . CREATE _CARD , Types . MOVE _CARD ] ;
const PERSONAL _NOTIFIABLE _TYPES = [ Types . ADD _MEMBER _TO _CARD ] ;
2019-08-31 04:07:25 +05:00
module . exports = {
2021-06-24 01:05:22 +05:00
Types ,
2025-05-17 22:24:37 +02:00
INTERNAL _NOTIFIABLE _TYPES ,
EXTERNAL _NOTIFIABLE _TYPES ,
PERSONAL _NOTIFIABLE _TYPES ,
2019-08-31 04:07:25 +05:00
attributes : {
// ╔═╗╦═╗╦╔╦╗╦╔╦╗╦╦ ╦╔═╗╔═╗
// ╠═╝╠╦╝║║║║║ ║ ║╚╗╔╝║╣ ╚═╗
// ╩ ╩╚═╩╩ ╩╩ ╩ ╩ ╚╝ ╚═╝╚═╝
type : {
type : 'string' ,
2021-06-24 01:05:22 +05:00
isIn : Object . values ( Types ) ,
2019-11-05 18:01:42 +05:00
required : true ,
2019-08-31 04:07:25 +05:00
} ,
data : {
type : 'json' ,
2019-11-05 18:01:42 +05:00
required : true ,
2019-08-31 04:07:25 +05:00
} ,
// ╔═╗╔╦╗╔╗ ╔═╗╔╦╗╔═╗
// ║╣ ║║║╠╩╗║╣ ║║╚═╗
// ╚═╝╩ ╩╚═╝╚═╝═╩╝╚═╝
// ╔═╗╔═╗╔═╗╔═╗╔═╗╦╔═╗╔╦╗╦╔═╗╔╗╔╔═╗
// ╠═╣╚═╗╚═╗║ ║║ ║╠═╣ ║ ║║ ║║║║╚═╗
// ╩ ╩╚═╝╚═╝╚═╝╚═╝╩╩ ╩ ╩ ╩╚═╝╝╚╝╚═╝
2025-05-22 23:14:46 +02:00
boardId : {
model : 'Board' ,
columnName : 'board_id' ,
} ,
2019-08-31 04:07:25 +05:00
cardId : {
model : 'Card' ,
required : true ,
2019-11-05 18:01:42 +05:00
columnName : 'card_id' ,
2019-08-31 04:07:25 +05:00
} ,
userId : {
model : 'User' ,
2019-11-05 18:01:42 +05:00
columnName : 'user_id' ,
} ,
} ,
2019-08-31 04:07:25 +05:00
} ;