Secure your code as it's written. Use Snyk Code to scan source code in minutes - no build needed - and fix issues immediately.
private async projectFileTree(
action: IAction,
tm: EntityManager,
) {
switch (action.type) {
case NotebookActionTypes.createNotebook: {
const {notebook} = action;
const parent = last(notebook.path);
const node = new DbFileTreeNode();
node.id = notebook.id;
node.notebookId = notebook.id;
node.owner = action.user;
node.type = FileType.notebook;
node.parent = parent ? new DbFileTreeNode(parent.id) : undefined;
return tm.getCustomRepository(FileTreeRepository).save(node);
}
}
}
function createFolderNode(defaultUser: string, folderName: string) {
const folderNode = new DbFileTreeNode();
folderNode.id = uuid();
folderNode.owner = defaultUser;
folderNode.folder = Object.assign(new DbFolder(), {
id: folderNode.id,
name: folderName,
owner: defaultUser,
});
return folderNode;
}
function createNotebookNode(defaultUser: string, notebookName: string) {
const notebook = createNotebook(defaultUser, notebookName);
const notebookNode = new DbFileTreeNode();
notebookNode.id = uuid();
notebookNode.owner = defaultUser;
notebookNode.notebookId = notebook.id;
notebookNode.type = FileType.notebook;
return [notebookNode, notebook] as const;
}
private async projectFileTree(
action: IAction,
tm: EntityManager,
) {
switch (action.type) {
case NotebookActionTypes.createNotebook: {
const {notebook} = action;
const parent = last(notebook.path);
const node = new DbFileTreeNode();
node.id = notebook.id;
node.notebookId = notebook.id;
node.owner = action.user;
node.type = FileType.notebook;
node.parent = parent ? new DbFileTreeNode(parent.id) : undefined;
return tm.getCustomRepository(FileTreeRepository).save(node);
}
}
}