Refactor API documentation and model attributes for consistency: rename 'isDeleted' to 'delete' and 'encrypted_title'/'encrypted_body' to 'title'/'body'
Despliegue Automático / desplegar (push) Successful in 4m25s

This commit is contained in:
2026-08-15 18:53:09 +02:00
parent ff768cf556
commit f3a0391507
4 changed files with 42 additions and 42 deletions
+1 -1
View File
@@ -24,7 +24,7 @@ const Category = sequelize.define('Category', {
type: DataTypes.INTEGER,
defaultValue: 1,
},
isDeleted: {
delete: {
type: DataTypes.BOOLEAN,
defaultValue: false
}
+4 -4
View File
@@ -8,11 +8,11 @@ const Note = sequelize.define('Note', {
type: DataTypes.UUID,
primaryKey: true,
},
encrypted_title: {
title: {
type: DataTypes.TEXT,
allowNull: false
},
encrypted_body: {
body: {
type: DataTypes.TEXT,
allowNull: false
},
@@ -24,11 +24,11 @@ const Note = sequelize.define('Note', {
type: DataTypes.INTEGER,
defaultValue: 1,
},
isDeleted: {
delete: {
type: DataTypes.BOOLEAN,
defaultValue: false
},
isPermanentlyDeleted: {
permanentDelete: {
type: DataTypes.BOOLEAN,
defaultValue: false
}
+16 -16
View File
@@ -16,7 +16,7 @@ const normalizeCategory = (category) => ({
encrypted_name: category.encrypted_name,
colorValue: category.colorValue ?? null,
iconCodePoint: category.iconCodePoint ?? null,
isDeleted: Boolean(category.isDeleted),
delete: Boolean(category.delete),
serverVersion: category.serverVersion || 1,
isDirty: false,
updatedAt: category.updatedAt instanceof Date ? category.updatedAt.toISOString() : toIso(category.updatedAt)
@@ -25,28 +25,28 @@ const normalizeCategory = (category) => ({
const normalizeNote = (note) => ({
id: note.id,
categoryId: note.categoryId || null,
encrypted_title: note.encrypted_title,
encrypted_body: note.encrypted_body,
title: note.title,
body: note.body,
position: note.position,
isDeleted: Boolean(note.isDeleted),
isPermanentlyDeleted: Boolean(note.isPermanentlyDeleted),
delete: Boolean(note.delete),
permanentDelete: Boolean(note.permanentDelete),
serverVersion: note.serverVersion || 1,
updatedAt: note.updatedAt instanceof Date ? note.updatedAt.toISOString() : toIso(note.updatedAt)
});
const buildStoredNoteData = (incomingNote, existingNote = null) => {
const isPermanentlyDeleted = Boolean(incomingNote.isPermanentlyDeleted);
const position = isPermanentlyDeleted
const permanentDelete = Boolean(incomingNote.permanentDelete);
const position = permanentDelete
? 0
: (incomingNote.position ?? existingNote?.position ?? 0);
return {
categoryId: incomingNote.categoryId || null,
encrypted_title: isPermanentlyDeleted ? '' : incomingNote.encrypted_title,
encrypted_body: isPermanentlyDeleted ? '' : incomingNote.encrypted_body,
title: permanentDelete ? '' : incomingNote.title,
body: permanentDelete ? '' : incomingNote.body,
position,
isDeleted: Boolean(incomingNote.isDeleted) || isPermanentlyDeleted,
isPermanentlyDeleted
delete: Boolean(incomingNote.delete) || permanentDelete,
permanentDelete
};
};
@@ -94,7 +94,7 @@ class SyncService {
encrypted_name: incomingCategory.encrypted_name,
colorValue: incomingCategory.colorValue ?? null,
iconCodePoint: incomingCategory.iconCodePoint ?? null,
isDeleted: Boolean(incomingCategory.isDeleted),
delete: Boolean(incomingCategory.delete),
serverVersion: 1
}, { transaction });
continue;
@@ -106,7 +106,7 @@ class SyncService {
encrypted_name: incomingCategory.encrypted_name,
colorValue: incomingCategory.colorValue ?? existingCategory.colorValue ?? null,
iconCodePoint: incomingCategory.iconCodePoint ?? existingCategory.iconCodePoint ?? null,
isDeleted: Boolean(incomingCategory.isDeleted),
delete: Boolean(incomingCategory.delete),
serverVersion: serverVersion + 1
}, { transaction });
} else {
@@ -115,10 +115,10 @@ class SyncService {
}
for (const incomingNote of incomingNotes) {
const isPermanentlyDeleted = Boolean(incomingNote.isPermanentlyDeleted);
const permanentDelete = Boolean(incomingNote.permanentDelete);
if (!incomingNote.id || (!isPermanentlyDeleted && (!incomingNote.encrypted_title || !incomingNote.encrypted_body))) {
throw new Error('Cada nota debe incluir id, encrypted_title y encrypted_body');
if (!incomingNote.id || (!permanentDelete && (!incomingNote.title || !incomingNote.body))) {
throw new Error('Cada nota debe incluir id, title y body');
}
const incomingBaseVersion = getIncomingVersion('nota', incomingNote);