refactor(react): add type safety for note labels

This commit is contained in:
Elian Doran
2025-09-14 10:16:52 +03:00
parent 8a66ee7565
commit b8e4947adb
11 changed files with 84 additions and 36 deletions

View File

@@ -9,3 +9,4 @@ export * from "./lib/bulk_actions.js";
export * from "./lib/server_api.js";
export * from "./lib/shared_constants.js";
export * from "./lib/ws_api.js";
export * from "./lib/attribute_names.js";

View File

@@ -0,0 +1,45 @@
type Labels = {
color: string;
iconClass: string;
workspaceIconClass: string;
executeDescription: string;
executeTitle: string;
limit: string; // should be probably be number
calendarRoot: boolean;
workspaceCalendarRoot: boolean;
archived: boolean;
sorted: boolean;
template: boolean;
autoReadOnlyDisabled: boolean;
language: string;
originalFileName: string;
pageUrl: string;
// Search
searchString: string;
ancestorDepth: string;
orderBy: string;
orderDirection: string;
// Collection-specific
viewType: string;
status: string;
pageSize: number;
geolocation: string;
readOnly: boolean;
expanded: boolean;
"calendar:hideWeekends": boolean;
"calendar:weekNumbers": boolean;
"calendar:view": string;
"map:style": string;
"map:scale": boolean;
"board:groupBy": string;
maxNestingDepth: number;
includeArchived: boolean;
}
export type LabelNames = keyof Labels;
export type FilterLabelsByType<U> = {
[K in keyof Labels]: Labels[K] extends U ? K : never;
}[keyof Labels];