Files
planka/server/api/models/Action.js

122 lines
3.8 KiB
JavaScript
Raw Normal View History

/*!
* 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:
* - cardId
* - type
* - data
* properties:
* id:
* type: string
* description: Unique identifier for the action
* example: 1357158568008091264
* boardId:
* type: string
* nullable: true
* description: ID of the board where the action occurred
* example: 1357158568008091265
* cardId:
* type: string
* description: ID of the card where the action occurred
* example: 1357158568008091266
* userId:
* type: string
* nullable: true
* description: ID of the user who performed the action
* example: 1357158568008091267
* 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-01T00:00:00.000Z
* updatedAt:
* type: string
* format: date-time
* nullable: true
* description: When the action was last updated
* example: 2024-01-01T00:00:00.000Z
*/
const Types = {
CREATE_CARD: 'createCard',
MOVE_CARD: 'moveCard',
ADD_MEMBER_TO_CARD: 'addMemberToCard',
REMOVE_MEMBER_FROM_CARD: 'removeMemberFromCard',
COMPLETE_TASK: 'completeTask',
UNCOMPLETE_TASK: 'uncompleteTask',
};
2019-08-31 04:07:25 +05: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 = {
Types,
INTERNAL_NOTIFIABLE_TYPES,
EXTERNAL_NOTIFIABLE_TYPES,
PERSONAL_NOTIFIABLE_TYPES,
2019-08-31 04:07:25 +05:00
attributes: {
// ╔═╗╦═╗╦╔╦╗╦╔╦╗╦╦ ╦╔═╗╔═╗
// ╠═╝╠╦╝║║║║║ ║ ║╚╗╔╝║╣ ╚═╗
// ╩ ╩╚═╩╩ ╩╩ ╩ ╩ ╚╝ ╚═╝╚═╝
type: {
type: 'string',
isIn: Object.values(Types),
required: true,
2019-08-31 04:07:25 +05:00
},
data: {
type: 'json',
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,
columnName: 'card_id',
2019-08-31 04:07:25 +05:00
},
userId: {
model: 'User',
columnName: 'user_id',
},
},
2019-08-31 04:07:25 +05:00
};