mirror of
https://github.com/lordmathis/lemma.git
synced 2025-11-05 15:44:21 +00:00
Update Workspace interface for optional properties
This commit is contained in:
@@ -7,6 +7,7 @@ export const apiCall = async (
|
|||||||
url: string,
|
url: string,
|
||||||
options: RequestInit = {}
|
options: RequestInit = {}
|
||||||
): Promise<Response> => {
|
): Promise<Response> => {
|
||||||
|
console.debug(`Making API call to: ${url}`);
|
||||||
try {
|
try {
|
||||||
const response = await fetch(url, {
|
const response = await fetch(url, {
|
||||||
...options,
|
...options,
|
||||||
@@ -17,6 +18,7 @@ export const apiCall = async (
|
|||||||
...options.headers,
|
...options.headers,
|
||||||
},
|
},
|
||||||
});
|
});
|
||||||
|
console.debug(`Response status: ${response.status} for URL: ${url}`);
|
||||||
|
|
||||||
// Handle 401 responses
|
// Handle 401 responses
|
||||||
if (response.status === 401) {
|
if (response.status === 401) {
|
||||||
|
|||||||
@@ -86,13 +86,17 @@ export const DEFAULT_WORKSPACE_SETTINGS: WorkspaceSettings = {
|
|||||||
};
|
};
|
||||||
|
|
||||||
export interface Workspace extends WorkspaceSettings {
|
export interface Workspace extends WorkspaceSettings {
|
||||||
|
id?: number;
|
||||||
|
userId?: number;
|
||||||
name: string;
|
name: string;
|
||||||
createdAt: number;
|
createdAt: number | string;
|
||||||
|
lastOpenedFilePath?: string;
|
||||||
}
|
}
|
||||||
|
|
||||||
export const DEFAULT_WORKSPACE: Workspace = {
|
export const DEFAULT_WORKSPACE: Workspace = {
|
||||||
name: '',
|
name: '',
|
||||||
createdAt: Date.now(),
|
createdAt: Date.now(),
|
||||||
|
lastOpenedFilePath: '',
|
||||||
...DEFAULT_WORKSPACE_SETTINGS,
|
...DEFAULT_WORKSPACE_SETTINGS,
|
||||||
};
|
};
|
||||||
|
|
||||||
@@ -102,10 +106,15 @@ export function isWorkspace(obj: unknown): obj is Workspace {
|
|||||||
obj !== null &&
|
obj !== null &&
|
||||||
'name' in obj &&
|
'name' in obj &&
|
||||||
typeof (obj as Workspace).name === 'string' &&
|
typeof (obj as Workspace).name === 'string' &&
|
||||||
|
'createdAt' in obj &&
|
||||||
|
(typeof (obj as Workspace).createdAt === 'number' ||
|
||||||
|
typeof (obj as Workspace).createdAt === 'string') &&
|
||||||
'theme' in obj &&
|
'theme' in obj &&
|
||||||
typeof (obj as Workspace).theme === 'string' &&
|
typeof (obj as Workspace).theme === 'string' &&
|
||||||
'autoSave' in obj &&
|
'autoSave' in obj &&
|
||||||
typeof (obj as Workspace).autoSave === 'boolean' &&
|
typeof (obj as Workspace).autoSave === 'boolean' &&
|
||||||
|
'showHiddenFiles' in obj &&
|
||||||
|
typeof (obj as Workspace).showHiddenFiles === 'boolean' &&
|
||||||
'gitEnabled' in obj &&
|
'gitEnabled' in obj &&
|
||||||
typeof (obj as Workspace).gitEnabled === 'boolean' &&
|
typeof (obj as Workspace).gitEnabled === 'boolean' &&
|
||||||
'gitUrl' in obj &&
|
'gitUrl' in obj &&
|
||||||
@@ -117,7 +126,11 @@ export function isWorkspace(obj: unknown): obj is Workspace {
|
|||||||
'gitAutoCommit' in obj &&
|
'gitAutoCommit' in obj &&
|
||||||
typeof (obj as Workspace).gitAutoCommit === 'boolean' &&
|
typeof (obj as Workspace).gitAutoCommit === 'boolean' &&
|
||||||
'gitCommitMsgTemplate' in obj &&
|
'gitCommitMsgTemplate' in obj &&
|
||||||
typeof (obj as Workspace).gitCommitMsgTemplate === 'string'
|
typeof (obj as Workspace).gitCommitMsgTemplate === 'string' &&
|
||||||
|
'gitCommitName' in obj &&
|
||||||
|
typeof (obj as Workspace).gitCommitName === 'string' &&
|
||||||
|
'gitCommitEmail' in obj &&
|
||||||
|
typeof (obj as Workspace).gitCommitEmail === 'string'
|
||||||
);
|
);
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -163,7 +176,7 @@ export interface FileNode {
|
|||||||
id: string;
|
id: string;
|
||||||
name: string;
|
name: string;
|
||||||
path: string;
|
path: string;
|
||||||
children: FileNode[];
|
children?: FileNode[];
|
||||||
}
|
}
|
||||||
|
|
||||||
export function isFileNode(obj: unknown): obj is FileNode {
|
export function isFileNode(obj: unknown): obj is FileNode {
|
||||||
@@ -176,8 +189,10 @@ export function isFileNode(obj: unknown): obj is FileNode {
|
|||||||
typeof (obj as FileNode).name === 'string' &&
|
typeof (obj as FileNode).name === 'string' &&
|
||||||
'path' in obj &&
|
'path' in obj &&
|
||||||
typeof (obj as FileNode).path === 'string' &&
|
typeof (obj as FileNode).path === 'string' &&
|
||||||
'children' in obj &&
|
(!('children' in obj) ||
|
||||||
Array.isArray((obj as FileNode).children)
|
(obj as FileNode).children === undefined ||
|
||||||
|
(obj as FileNode).children === null ||
|
||||||
|
Array.isArray((obj as FileNode).children))
|
||||||
);
|
);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
Reference in New Issue
Block a user