Skip to content

Commit

Permalink
feat: store icons in book childtree
Browse files Browse the repository at this point in the history
  • Loading branch information
barthuijgen committed Oct 16, 2023
1 parent 1434aec commit 53d4794
Show file tree
Hide file tree
Showing 2 changed files with 10 additions and 2 deletions.
10 changes: 8 additions & 2 deletions libs/database/src/lib/data/blueprint_book.ts
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@ import { createBlueprint } from "./blueprint";

const mapBlueprintBookEntityToObject = (entity: blueprint_book): BlueprintBook => ({
id: entity.id,
child_tree: entity.child_tree ? ((entity.child_tree as unknown) as ChildTree) : [],
child_tree: entity.child_tree ? (entity.child_tree as unknown as ChildTree) : [],
blueprint_hash: entity.blueprint_hash,
label: entity.label || "",
description: entity.description || "",
Expand Down Expand Up @@ -61,6 +61,8 @@ export async function createBlueprintBook(
type: "blueprint",
id: result.id,
name: blueprint.blueprint.label || "",
icons:
blueprint.blueprint.icons?.map((icon) => `${icon.signal.type}:${icon.signal.name}`) || [],
});
blueprint_ids.push(result.id);
} else if (blueprint.blueprint_book) {
Expand All @@ -70,6 +72,10 @@ export async function createBlueprintBook(
id: result.id,
name: blueprint.blueprint_book.label,
children: result.child_tree,
icons:
blueprint.blueprint_book.icons?.map(
(icon) => `${icon.signal.type}:${icon.signal.name}`
) || [],
});
blueprint_book_ids.push(result.id);
}
Expand All @@ -81,7 +87,7 @@ export async function createBlueprintBook(
description: blueprintBook.description,
blueprint_hash: blueprint_hash,
is_modded: false,
child_tree: (child_tree as unknown) as Prisma.InputJsonObject,
child_tree: child_tree as unknown as Prisma.InputJsonObject,
updated_at: extraInfo.updated_at ? new Date(extraInfo.updated_at * 1000) : new Date(),
created_at: extraInfo.created_at ? new Date(extraInfo.created_at * 1000) : new Date(),
blueprint_books: {
Expand Down
2 changes: 2 additions & 0 deletions libs/types/src/lib/data-models.ts
Original file line number Diff line number Diff line change
Expand Up @@ -5,13 +5,15 @@ export interface ChildTreeBlueprint {
type: "blueprint";
id: string;
name: string;
icons?: string[];
}

export interface ChildTreeBlueprintBook {
type: "blueprint_book";
id: string;
name: string;
children: ChildTree;
icons?: string[];
}

export type ChildTree = Array<ChildTreeBlueprint | ChildTreeBlueprintBook>;
Expand Down

0 comments on commit 53d4794

Please sign in to comment.