refactor(bulk_action): add basic type safety for client

This commit is contained in:
Elian Doran
2025-07-19 12:54:16 +03:00
parent 0d3de92890
commit 409638151c
4 changed files with 51 additions and 49 deletions

View File

@@ -5,3 +5,4 @@ export * from "./lib/hidden_subtree.js";
export * from "./lib/rows.js";
export * from "./lib/test-utils.js";
export * from "./lib/mime_type.js";
export * from "./lib/bulk_actions.js";

View File

@@ -0,0 +1,47 @@
export type ActionHandlers = {
addLabel: {
labelName: string;
labelValue?: string;
},
addRelation: {
relationName: string;
targetNoteId: string;
},
deleteNote: {},
deleteRevisions: {},
deleteLabel: {
labelName: string;
},
deleteRelation: {
relationName: string;
},
renameNote: {
newTitle: string;
},
renameLabel: {
oldLabelName: string;
newLabelName: string;
},
renameRelation: {
oldRelationName: string;
newRelationName: string;
},
updateLabelValue: {
labelName: string;
labelValue: string;
},
updateRelationTarget: {
relationName: string;
targetNoteId: string;
},
moveNote: {
targetParentNoteId: string;
},
executeScript: {
script: string;
}
};
export type BulkActionData<T extends keyof ActionHandlers> = ActionHandlers[T] & { name: T };
export type BulkAction = BulkActionData<keyof ActionHandlers>;