Skip to content

Commit

Permalink
removing artboard from layers and designs
Browse files Browse the repository at this point in the history
  • Loading branch information
goodeats committed May 22, 2024
1 parent 98d6868 commit c60b2f0
Show file tree
Hide file tree
Showing 29 changed files with 232 additions and 1,749 deletions.
55 changes: 0 additions & 55 deletions app/models/artboard/artboard.get.server.ts
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,6 @@ import { prisma } from '#app/utils/db.server'
import {
type IArtboard,
type IArtboardWithBranchesAndVersions,
type IArtboardWithDesignsAndLayers,
} from '../artboard/artboard.server'

export type queryArtboardWhereArgsType = z.infer<typeof whereArgs>
Expand All @@ -13,31 +12,6 @@ const whereArgs = z.object({
slug: z.string().optional(),
})

const includeDesigns = {
palette: true,
size: true,
fill: true,
stroke: true,
line: true,
rotate: true,
layout: true,
template: true,
}

// no ordering for now since these are linked lists
const includeDesignsAndLayers = {
designs: {
include: includeDesigns,
},
layers: {
include: {
designs: {
include: includeDesigns,
},
},
},
}

// TODO: Add schemas for each type of query and parse with zod
// aka if by id that should be present, if by slug that should be present
// owner id should be present unless admin (not set up yet)
Expand All @@ -49,22 +23,6 @@ const validateQueryWhereArgsPresent = (where: queryArtboardWhereArgsType) => {
}
}

export const getArtboardsWithDesignsAndLayers = async ({
where,
}: {
where: queryArtboardWhereArgsType
}): Promise<IArtboardWithDesignsAndLayers[]> => {
validateQueryWhereArgsPresent(where)
const artboards = await prisma.artboard.findMany({
where,
include: includeDesignsAndLayers,
orderBy: {
createdAt: 'asc',
},
})
return artboards
}

export const getArtboard = async ({
where,
}: {
Expand All @@ -77,19 +35,6 @@ export const getArtboard = async ({
return artboard
}

export const getArtboardWithDesignsAndLayers = async ({
where,
}: {
where: queryArtboardWhereArgsType
}): Promise<IArtboardWithDesignsAndLayers | null> => {
validateQueryWhereArgsPresent(where)
const artboard = await prisma.artboard.findFirst({
where,
include: includeDesignsAndLayers,
})
return artboard
}

export const getArtboardWithBranchesAndVersions = async ({
where,
}: {
Expand Down
7 changes: 1 addition & 6 deletions app/models/artboard/artboard.server.ts
Original file line number Diff line number Diff line change
@@ -1,8 +1,6 @@
import { type Artboard } from '@prisma/client'
import { type DateOrString } from '#app/definitions/prisma-helper'
import { type IArtboardBranchWithVersions } from '../artboard-branch/artboard-branch.server'
import { type IDesignWithType } from '../design/design.server'
import { type ILayerWithDesigns } from '../layer/layer.server'
import { type IProjectWithArtboards } from '../project/project.server'

// Omitting 'createdAt' and 'updatedAt' from the Artboard interface
Expand All @@ -16,10 +14,7 @@ export interface IArtboard extends BaseArtboard {
export interface IArtboardWithProject extends IArtboard {
project: IProjectWithArtboards
}
export interface IArtboardWithDesignsAndLayers extends IArtboard {
designs: IDesignWithType[]
layers: ILayerWithDesigns[]
}

export interface IArtboardWithBranchesAndVersions extends IArtboard {
branches: IArtboardBranchWithVersions[]
}
100 changes: 0 additions & 100 deletions app/models/design-artboard.server.ts

This file was deleted.

3 changes: 0 additions & 3 deletions app/models/design/design.server.ts
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,6 @@ import {
type whereArgsType,
} from '#app/schema/design'
import { prisma } from '#app/utils/db.server'
import { type IArtboard } from '../artboard/artboard.server'
import {
type IArtboardVersionWithDesignsAndLayers,
type IArtboardVersion,
Expand All @@ -32,7 +31,6 @@ export interface IDesign extends Design {}
export type IDesignIdOrNull = IDesign['id'] | null | undefined

export type IDesignEntityId =
| IArtboard['id']
| IDesign['id']
| IArtboardVersion['id']
| IArtboardVersionWithDesignsAndLayers['id']
Expand Down Expand Up @@ -61,7 +59,6 @@ export interface IDesignWithType {
nextId: string | null
prevId: string | null
ownerId: string
artboardId: string | null
artboardVersionId: string | null
layerId: string | null
palette: IPalette | null
Expand Down
1 change: 0 additions & 1 deletion app/models/layer/layer.server.ts
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,6 @@ export interface ILayer {
createdAt: Date | string
updatedAt: Date | string
ownerId: string
artboardId: string | null
artboardVersionId: string | null
nextId: string | null
prevId: string | null
Expand Down
43 changes: 0 additions & 43 deletions app/schema/design-artboard.ts

This file was deleted.

14 changes: 0 additions & 14 deletions app/schema/design.ts
Original file line number Diff line number Diff line change
Expand Up @@ -2,12 +2,6 @@ import { z } from 'zod'
import { type IArtboardVersionWithDesignsAndLayers } from '#app/models/artboard-version/artboard-version.server'
import { type ILayerWithDesigns } from '#app/models/layer/layer.server'
import { type ObjectValues } from '#app/utils/typescript-helpers'
import {
type ToggleVisibleArtboardDesignSchema,
type DeleteArtboardDesignSchema,
type NewArtboardDesignSchema,
type ReorderArtboardDesignSchema,
} from './design-artboard'
import {
type DeleteArtboardVersionDesignSchema,
type NewArtboardVersionDesignSchema,
Expand Down Expand Up @@ -46,7 +40,6 @@ export const DesignParentTypeIdEnum = {
export type designParentTypeIdEnum = ObjectValues<typeof DesignParentTypeIdEnum>

export const DesignCloneSourceTypeEnum = {
ARTBOARD: 'artboard',
ARTBOARD_VERSION: 'artboardVersion',
LAYER: 'layer',
} as const
Expand All @@ -58,7 +51,6 @@ export interface Design {
type: designTypeEnum
ownerId: string
// one of these should be included
artboardId?: string
artboardVersionId?: string
layerId?: string
}
Expand All @@ -67,30 +59,25 @@ export interface Design {
export const designSchema = z.object({
type: z.nativeEnum(DesignTypeEnum),
ownerId: z.string(),
artboardId: z.string().optional(),
artboardVersionId: z.string().optional(),
layerId: z.string().optional(),
visible: z.boolean().optional(),
selected: z.boolean().optional(),
}) satisfies z.Schema<Design>

export type NewDesignSchemaType =
| typeof NewArtboardDesignSchema
| typeof NewArtboardVersionDesignSchema
| typeof NewLayerDesignSchema

export type ReorderDesignSchemaType =
| typeof ReorderArtboardDesignSchema
| typeof ReorderArtboardVersionDesignSchema
| typeof ReorderLayerDesignSchema

export type ToggleVisibleDesignSchemaType =
| typeof ToggleVisibleArtboardDesignSchema
| typeof ToggleVisibleArtboardVersionDesignSchema
| typeof ToggleVisibleLayerDesignSchema

export type DeleteDesignSchemaType =
| typeof DeleteArtboardDesignSchema
| typeof DeleteArtboardVersionDesignSchema
| typeof DeleteLayerDesignSchema

Expand All @@ -108,7 +95,6 @@ const whereArgs = z.object({
visible: z.boolean().optional(),
selected: z.boolean().optional(),
ownerId: z.string().optional(),
artboardId: z.string().optional(),
artboardVersionId: z.string().optional(),
layerId: z.string().optional(),
prevId: zodStringOrNull.optional(),
Expand Down
34 changes: 0 additions & 34 deletions app/schema/layer-artboard.ts

This file was deleted.

Loading

0 comments on commit c60b2f0

Please sign in to comment.