zinkee 0.1.38 → 0.1.40

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
@@ -59,6 +59,36 @@ export function buildTableColumns(keys: readonly string[]): readonly TableColumn
59
59
  return keys.map((key) => ({ key, label: key }));
60
60
  }
61
61
 
62
+ export interface FolderLocation {
63
+ id?: string;
64
+ name?: string | null;
65
+ isRoot?: boolean;
66
+ }
67
+
68
+ /** Column keys, in order, produced by {@link folderColumns}. Append them to a table's key list. */
69
+ export const FOLDER_TABLE_KEYS = ["folderId", "folderName", "folderIsRoot"] as const;
70
+
71
+ /**
72
+ * Flattens the API `folder` object (`{ id, name, isRoot }`) into the folderId/folderName/folderIsRoot table columns.
73
+ * The root folder arrives with a null name, so folderName renders it as "(root)". A missing folder (e.g. a workspace
74
+ * without a default group) leaves every column empty.
75
+ */
76
+ export function folderColumns(folder: FolderLocation | null | undefined): {
77
+ folderId: string;
78
+ folderName: string;
79
+ folderIsRoot: string;
80
+ } {
81
+ if (!folder) {
82
+ return { folderId: "", folderName: "", folderIsRoot: "" };
83
+ }
84
+
85
+ return {
86
+ folderId: folder.id ?? "",
87
+ folderName: folder.name ?? (folder.isRoot === true ? "(root)" : ""),
88
+ folderIsRoot: folder.isRoot === undefined ? "" : String(folder.isRoot),
89
+ };
90
+ }
91
+
62
92
  export function buildTableRows(
63
93
  rows: readonly Record<string, unknown>[],
64
94
  columns: readonly TableColumn[],