From c60b2f053e28fde2cb2780ed8c37687ae1fcce52 Mon Sep 17 00:00:00 2001 From: Pat Needham Date: Wed, 22 May 2024 03:30:38 -0400 Subject: [PATCH 1/3] removing artboard from layers and designs --- app/models/artboard/artboard.get.server.ts | 55 --- app/models/artboard/artboard.server.ts | 7 +- app/models/design-artboard.server.ts | 100 ------ app/models/design/design.server.ts | 3 - app/models/layer/layer.server.ts | 1 - app/schema/design-artboard.ts | 43 --- app/schema/design.ts | 14 - app/schema/layer-artboard.ts | 34 -- app/schema/layer.ts | 21 +- app/services/artboard/build/create.service.ts | 296 ---------------- .../artboard/design/create.service.ts | 48 --- .../artboard/design/delete.service.ts | 37 -- .../artboard/design/move-down.service.ts | 41 --- .../artboard/design/move-up.service.ts | 41 --- .../artboard/design/toggle-visible.service.ts | 37 -- .../artboard/layer/clone-designs.service.ts | 38 --- app/services/artboard/layer/create.service.ts | 36 -- app/services/artboard/layer/delete.service.ts | 134 -------- .../artboard/layer/move-down.service.ts | 191 ----------- .../artboard/layer/move-up.service.ts | 191 ----------- .../artboard/layer/toggle-visible.service.ts | 52 --- app/services/design/clone-many.service.ts | 8 +- app/strategies/design/create.strategy.ts | 49 --- .../design/update-selected.strategy.ts | 54 --- app/strategies/layer/create.strategy.ts | 59 ---- package.json | 1 - .../create-artboard-versions-and-branches.ts | 315 +++++++++--------- .../migration.sql | 65 ++++ prisma/schema.prisma | 10 - 29 files changed, 232 insertions(+), 1749 deletions(-) delete mode 100644 app/models/design-artboard.server.ts delete mode 100644 app/schema/design-artboard.ts delete mode 100644 app/schema/layer-artboard.ts delete mode 100644 app/services/artboard/build/create.service.ts delete mode 100644 app/services/artboard/design/create.service.ts delete mode 100644 app/services/artboard/design/delete.service.ts delete mode 100644 app/services/artboard/design/move-down.service.ts delete mode 100644 app/services/artboard/design/move-up.service.ts delete mode 100644 app/services/artboard/design/toggle-visible.service.ts delete mode 100644 app/services/artboard/layer/clone-designs.service.ts delete mode 100644 app/services/artboard/layer/create.service.ts delete mode 100644 app/services/artboard/layer/delete.service.ts delete mode 100644 app/services/artboard/layer/move-down.service.ts delete mode 100644 app/services/artboard/layer/move-up.service.ts delete mode 100644 app/services/artboard/layer/toggle-visible.service.ts create mode 100644 prisma/migrations/20240522070118_remove_artboard_from_layer_and_design/migration.sql diff --git a/app/models/artboard/artboard.get.server.ts b/app/models/artboard/artboard.get.server.ts index dbcde332..e7654d8b 100644 --- a/app/models/artboard/artboard.get.server.ts +++ b/app/models/artboard/artboard.get.server.ts @@ -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 @@ -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) @@ -49,22 +23,6 @@ const validateQueryWhereArgsPresent = (where: queryArtboardWhereArgsType) => { } } -export const getArtboardsWithDesignsAndLayers = async ({ - where, -}: { - where: queryArtboardWhereArgsType -}): Promise => { - validateQueryWhereArgsPresent(where) - const artboards = await prisma.artboard.findMany({ - where, - include: includeDesignsAndLayers, - orderBy: { - createdAt: 'asc', - }, - }) - return artboards -} - export const getArtboard = async ({ where, }: { @@ -77,19 +35,6 @@ export const getArtboard = async ({ return artboard } -export const getArtboardWithDesignsAndLayers = async ({ - where, -}: { - where: queryArtboardWhereArgsType -}): Promise => { - validateQueryWhereArgsPresent(where) - const artboard = await prisma.artboard.findFirst({ - where, - include: includeDesignsAndLayers, - }) - return artboard -} - export const getArtboardWithBranchesAndVersions = async ({ where, }: { diff --git a/app/models/artboard/artboard.server.ts b/app/models/artboard/artboard.server.ts index 381d8649..c09b8eda 100644 --- a/app/models/artboard/artboard.server.ts +++ b/app/models/artboard/artboard.server.ts @@ -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 @@ -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[] } diff --git a/app/models/design-artboard.server.ts b/app/models/design-artboard.server.ts deleted file mode 100644 index a1434a9a..00000000 --- a/app/models/design-artboard.server.ts +++ /dev/null @@ -1,100 +0,0 @@ -import { type Design } from '@prisma/client' -import { DesignTypeEnum, type designTypeEnum } from '#app/schema/design' -import { prisma } from '#app/utils/db.server' -import { filterVisibleDesigns } from '#app/utils/design' -import { orderLinkedItems } from '#app/utils/linked-list.utils' -import { filterNonArrayRotates } from '#app/utils/rotate' -import { type IArtboard } from './artboard/artboard.server' -import { - findManyDesignsWithType, - type IDesignWithPalette, - type IDesign, - type IDesignWithRotate, -} from './design/design.server' -import { type IPalette } from './design-type/palette/palette.server' -import { type IRotate } from './design-type/rotate/rotate.server' - -// this file may no longer be necessary - -export interface IDesignWithArtboard extends IDesign { - artboard: IArtboard -} - -export const findFirstVisibleArtboardDesignByType = async ({ - artboardId, - type, -}: { - artboardId: IArtboard['id'] - type: designTypeEnum -}): Promise => { - return await prisma.design.findFirst({ - where: { artboardId, type, visible: true }, - }) -} - -export const updateArtboardSelectedDesign = ({ - artboardId, - designId, - type, -}: { - artboardId: IArtboard['id'] - designId: Design['id'] - type: designTypeEnum -}) => { - const deselectDesign = deselectArtboardSelectedDesign({ - artboardId, - type, - }) - const selectDesign = prisma.design.update({ - where: { id: designId }, - data: { selected: true }, - }) - return [deselectDesign, selectDesign] -} - -export const deselectArtboardSelectedDesign = ({ - artboardId, - type, -}: { - artboardId: IArtboard['id'] - type: designTypeEnum -}) => { - return prisma.design.updateMany({ - where: { artboardId, type, selected: true }, - data: { selected: false }, - }) -} - -export const getArtboardVisiblePalettes = async ({ - artboardId, -}: { - artboardId: IArtboard['id'] -}): Promise => { - const designPalettes = (await findManyDesignsWithType({ - where: { type: DesignTypeEnum.PALETTE, artboardId }, - })) as IDesignWithPalette[] - - const visibleDesignPalettes = filterVisibleDesigns( - orderLinkedItems(designPalettes), - ) as IDesignWithPalette[] - - return visibleDesignPalettes.map(design => design.palette) -} - -export const getArtboardVisibleRotates = async ({ - artboardId, -}: { - artboardId: IArtboard['id'] -}): Promise => { - const designRotates = (await findManyDesignsWithType({ - where: { type: DesignTypeEnum.ROTATE, artboardId }, - })) as IDesignWithRotate[] - - const visibleDesignRotates = filterVisibleDesigns( - orderLinkedItems(designRotates), - ) as IDesignWithRotate[] - - return filterNonArrayRotates( - visibleDesignRotates.map(design => design.rotate), - ) -} diff --git a/app/models/design/design.server.ts b/app/models/design/design.server.ts index c899d8ae..4f4219e6 100644 --- a/app/models/design/design.server.ts +++ b/app/models/design/design.server.ts @@ -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, @@ -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'] @@ -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 diff --git a/app/models/layer/layer.server.ts b/app/models/layer/layer.server.ts index a989f766..923b5555 100644 --- a/app/models/layer/layer.server.ts +++ b/app/models/layer/layer.server.ts @@ -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 diff --git a/app/schema/design-artboard.ts b/app/schema/design-artboard.ts deleted file mode 100644 index f17b2543..00000000 --- a/app/schema/design-artboard.ts +++ /dev/null @@ -1,43 +0,0 @@ -import { z } from 'zod' -import { DesignTypeEnum, type designTypeEnum } from './design' - -// copied from ./design.ts -// may not be necessary? -export interface DesignArtboard { - type: designTypeEnum - ownerId: string - artboardId?: string -} - -export const ArtboardDesignDataCreateSchema = z.object({ - type: z.nativeEnum(DesignTypeEnum), - ownerId: z.string(), - artboardId: z.string(), - visible: z.boolean().optional(), - selected: z.boolean().optional(), -}) satisfies z.Schema - -export const NewArtboardDesignSchema = z.object({ - artboardId: z.string(), - type: z.nativeEnum(DesignTypeEnum), - visibleDesignsCount: z.number().optional(), -}) - -export const DeleteArtboardDesignSchema = z.object({ - id: z.string(), - artboardId: z.string(), - updateSelectedDesignId: z.string().optional(), -}) - -export const ToggleVisibleArtboardDesignSchema = z.object({ - id: z.string(), - artboardId: z.string(), - updateSelectedDesignId: z.string().optional(), -}) - -export const ReorderArtboardDesignSchema = z.object({ - id: z.string(), - artboardId: z.string(), - direction: z.enum(['up', 'down']), - updateSelectedDesignId: z.string().optional(), -}) diff --git a/app/schema/design.ts b/app/schema/design.ts index de809699..a4cc9146 100644 --- a/app/schema/design.ts +++ b/app/schema/design.ts @@ -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, @@ -46,7 +40,6 @@ export const DesignParentTypeIdEnum = { export type designParentTypeIdEnum = ObjectValues export const DesignCloneSourceTypeEnum = { - ARTBOARD: 'artboard', ARTBOARD_VERSION: 'artboardVersion', LAYER: 'layer', } as const @@ -58,7 +51,6 @@ export interface Design { type: designTypeEnum ownerId: string // one of these should be included - artboardId?: string artboardVersionId?: string layerId?: string } @@ -67,7 +59,6 @@ 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(), @@ -75,22 +66,18 @@ export const designSchema = z.object({ }) satisfies z.Schema 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 @@ -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(), diff --git a/app/schema/layer-artboard.ts b/app/schema/layer-artboard.ts deleted file mode 100644 index 0b3d06fd..00000000 --- a/app/schema/layer-artboard.ts +++ /dev/null @@ -1,34 +0,0 @@ -import { z } from 'zod' -import { LayerNameSchema } from './layer' - -export interface LayerDataCreate { - name: string - ownerId: string - artboardId?: string -} - -export const ArtboardLayerDataCreateSchema = z.object({ - name: LayerNameSchema, - ownerId: z.string(), - artboardId: z.string(), -}) satisfies z.Schema - -export const NewArtboardLayerSchema = z.object({ - artboardId: z.string(), -}) - -export const DeleteArtboardLayerSchema = z.object({ - id: z.string(), - artboardId: z.string(), -}) - -export const ToggleVisibleArtboardLayerSchema = z.object({ - id: z.string(), - artboardId: z.string(), -}) - -export const ReorderArtboardLayerSchema = z.object({ - id: z.string(), - artboardId: z.string(), - direction: z.enum(['up', 'down']), -}) diff --git a/app/schema/layer.ts b/app/schema/layer.ts index 79c148b9..8ea2a554 100644 --- a/app/schema/layer.ts +++ b/app/schema/layer.ts @@ -1,10 +1,4 @@ import { z } from 'zod' -import { - type ReorderArtboardLayerSchema, - type NewArtboardLayerSchema, - type ToggleVisibleArtboardLayerSchema, - type DeleteArtboardLayerSchema, -} from './layer-artboard' import { type ReorderArtboardVersionLayerSchema, type NewArtboardVersionLayerSchema, @@ -37,21 +31,14 @@ export const EditLayerDescriptionSchema = z.object({ }) // later there will be layer groups -export type NewLayerSchemaType = - | typeof NewArtboardLayerSchema - | typeof NewArtboardVersionLayerSchema +export type NewLayerSchemaType = typeof NewArtboardVersionLayerSchema -export type ReorderLayerSchemaType = - | typeof ReorderArtboardLayerSchema - | typeof ReorderArtboardVersionLayerSchema +export type ReorderLayerSchemaType = typeof ReorderArtboardVersionLayerSchema export type ToggleVisibleLayerSchemaType = - | typeof ToggleVisibleArtboardLayerSchema - | typeof ToggleVisibleArtboardVersionLayerSchema + typeof ToggleVisibleArtboardVersionLayerSchema -export type DeleteLayerSchemaType = - | typeof DeleteArtboardLayerSchema - | typeof DeleteArtboardVersionLayerSchema +export type DeleteLayerSchemaType = typeof DeleteArtboardVersionLayerSchema export type SelectLayerSchemaType = typeof SelectArtboardVersionLayerSchema diff --git a/app/services/artboard/build/create.service.ts b/app/services/artboard/build/create.service.ts deleted file mode 100644 index b477c1d2..00000000 --- a/app/services/artboard/build/create.service.ts +++ /dev/null @@ -1,296 +0,0 @@ -import { - type IGeneratorDesigns, - type IArtboardGenerator, - type ILayerGenerator, -} from '#app/definitions/artboard-generator' -import { type IArtboard } from '#app/models/artboard/artboard.server' -import { - type IDesignWithType, - findManyDesignsWithType, -} from '#app/models/design/design.server' -import { - getArtboardVisiblePalettes, - getArtboardVisibleRotates, -} from '#app/models/design-artboard.server' -import { - getLayerVisiblePalettes, - getLayerVisibleRotates, -} from '#app/models/design-layer/design-layer.server' -import { type IRotate } from '#app/models/design-type/rotate/rotate.server' -import { type ILayer } from '#app/models/layer/layer.server' -import { type rotateBasisTypeEnum } from '#app/schema/rotate' -import { - filterSelectedDesignTypes, - findFirstDesignsByTypeInArray, - verifySelectedDesignTypesAllPresent, -} from '#app/utils/design' -import { filterLayersVisible } from '#app/utils/layer.utils' -import { isArrayRotateBasisType } from '#app/utils/rotate' - -export const artboardBuildCreateService = async ({ - artboard, - layers, -}: { - artboard: IArtboard - layers: ILayer[] -}): Promise => { - try { - // Step 1: verify artboard selected designs are all present - const { artboardGeneratorDesigns, message } = - await verifyArtboardGeneratorDesigns({ - artboard, - }) - - // Step 2: return failure with message if not - if (!artboardGeneratorDesigns) { - return { - id: artboard.id, - layers: [], - success: false, - message, - } - } - - // Step 3: build the artboard generator layer - // which will be the global settings for all layers - const artboardGeneratorLayer = await buildGeneratorArtboardLayer({ - artboardId: artboard.id, - artboard, - artboardGeneratorDesigns, - }) - - // Step 4: build the generator layers - // each layer can override any of the global settings - const generatorLayers = await buildGeneratorLayers({ - layers, - artboardGeneratorLayer, - }) - - return { - id: artboard.id, - layers: generatorLayers, - success: true, - message: 'Artboard generator created successfully.', - } - } catch (error) { - console.log(error) - return { - id: artboard.id, - layers: [], - success: false, - message: 'Unknown error creating artboard generator.', - } - } -} - -const verifyArtboardGeneratorDesigns = async ({ - artboard, -}: { - artboard: IArtboard -}): Promise<{ - artboardGeneratorDesigns: IGeneratorDesigns | null - message: string -}> => { - // Step 1: get all selected designs for the artboard - const artboardSelectedDesigns = await getArtboardSelectedDesigns({ - artboardId: artboard.id, - }) - - // Step 2: split the selected designs into the first of each type - const selectedDesignTypes = findFirstDesignsByTypeInArray({ - designs: artboardSelectedDesigns, - }) - - // Step 3: validate that all selected design types are present - // message will indicate which design type is missing - const { success, message } = verifySelectedDesignTypesAllPresent({ - selectedDesignTypes, - }) - - // Step 4: return failure with message if selected designs are not valid - if (!success) { - return { - message, - artboardGeneratorDesigns: null, - } - } - - // Step 5: reformat the selected designs to be generator designs - // this is to ensure that the selected designs are not null - const artboardGeneratorDesigns = { - ...selectedDesignTypes, - palette: [selectedDesignTypes.palette], - } as IGeneratorDesigns - - return { - artboardGeneratorDesigns, - message: 'Artboard generator designs are present.', - } -} - -const getArtboardSelectedDesigns = async ({ - artboardId, -}: { - artboardId: IArtboard['id'] -}): Promise => { - return await findManyDesignsWithType({ - where: { artboardId, selected: true }, - }) -} - -// default/global design settings for each layer -// layer can override any of these values -const buildGeneratorArtboardLayer = async ({ - artboardId, - artboard, - artboardGeneratorDesigns, -}: { - artboardId: string - artboard: IArtboard - artboardGeneratorDesigns: IGeneratorDesigns -}): Promise => { - // get all visible palettes to use for fill or stroke - const palettes = await getArtboardVisiblePalettes({ artboardId }) - - // get all visible rotates to use for rotate if visible random - const rotates = await getRotates({ - artboardId, - rotate: artboardGeneratorDesigns.rotate, - }) - - // container defaults to artboar dimensions - const container = getArtboardContainer({ artboard }) - - return { - ...artboardGeneratorDesigns, - palette: palettes, - rotates, - container, - } -} - -const getArtboardContainer = ({ artboard }: { artboard: IArtboard }) => { - const { width, height } = artboard - return { - width, - height, - top: 0, - left: 0, - margin: 0, - canvas: { - width, - height, - }, - } -} - -const buildGeneratorLayers = async ({ - layers, - artboardGeneratorLayer, -}: { - layers: ILayer[] - artboardGeneratorLayer: ILayerGenerator -}) => { - const visibleLayers = filterLayersVisible({ layers }) - - return await Promise.all( - visibleLayers.map(layer => - buildGeneratorLayer({ - layer, - artboardGeneratorLayer, - }), - ), - ) -} - -const buildGeneratorLayer = async ({ - layer, - artboardGeneratorLayer, -}: { - layer: ILayer - artboardGeneratorLayer: ILayerGenerator -}): Promise => { - const layerId = layer.id - - // Step 1: get all selected designs for the layer - const layerSelectedDesigns = await getLayerSelectedDesigns({ layerId }) - - // Step 2: split the selected designs into the first of each type - const selectedDesignTypes = findFirstDesignsByTypeInArray({ - designs: layerSelectedDesigns, - }) - - // Step 3: filter the selected designs that are present - // separate the palette from the rest of the layer generator designs - // if the layer has no palette we do not want to override the artboard palette - const { palette, ...layerGeneratorDesigns } = filterSelectedDesignTypes({ - selectedDesignTypes, - }) - - // Step 4: initialize the generator layer - // with the artboard generator layer settings as default - // and the layer generator designs as overrides - // and layer details - const { id, name, description } = layer - const layerGenerator = { - ...artboardGeneratorLayer, - ...layerGeneratorDesigns, - id, - name, - description, - } - - // Step 5: get all visible palettes to use for fill or stroke - // if empty, then use the artboard palette - const palettes = await getLayerVisiblePalettes({ layerId }) - if (palettes.length > 0) { - layerGenerator.palette = palettes - } - - // Step 6: get all visible rotates to use for rotate if visible random - // if empty, then use the artboard rotate - const { rotate } = layerGeneratorDesigns - if (rotate) { - const rotates = await getRotates({ - layerId, - rotate, - }) - - if (rotates.length > 0) { - layerGenerator.rotates = rotates - } - } - - return layerGenerator -} - -const getLayerSelectedDesigns = async ({ - layerId, -}: { - layerId: ILayer['id'] -}) => { - return await findManyDesignsWithType({ - where: { layerId, selected: true }, - }) -} - -const getRotates = async ({ - artboardId, - layerId, - rotate, -}: { - artboardId?: IArtboard['id'] - layerId?: ILayer['id'] - rotate: IRotate -}) => { - const allRotates = isArrayRotateBasisType(rotate.basis as rotateBasisTypeEnum) - - if (allRotates) { - if (artboardId) { - return await getArtboardVisibleRotates({ artboardId }) - } else if (layerId) { - return await getLayerVisibleRotates({ layerId }) - } - } - return [] -} diff --git a/app/services/artboard/design/create.service.ts b/app/services/artboard/design/create.service.ts deleted file mode 100644 index bf4cd9c0..00000000 --- a/app/services/artboard/design/create.service.ts +++ /dev/null @@ -1,48 +0,0 @@ -import { type User } from '@prisma/client' -import { type IArtboard } from '#app/models/artboard/artboard.server' -import { type IDesignCreatedResponse } from '#app/models/design/design.create.server' -import { - type IDesignCreateOverrides, - type IDesignTypeCreateOverrides, -} from '#app/models/design/design.server' -import { type designTypeEnum } from '#app/schema/design' -import { ArtboardCreateDesignStrategy } from '#app/strategies/design/create.strategy' -import { ArtboardUpdateSelectedDesignStrategy } from '#app/strategies/design/update-selected.strategy' -import { designCreateService } from '../../design/create.service' - -export const artboardDesignCreateService = async ({ - userId, - artboardId, - type, - designOverrides = {}, - designTypeOverrides = {}, -}: { - userId: User['id'] - artboardId: IArtboard['id'] - type: designTypeEnum - designOverrides?: IDesignCreateOverrides - designTypeOverrides?: IDesignTypeCreateOverrides -}): Promise => { - try { - const strategy = new ArtboardCreateDesignStrategy() - const updateSelectedDesignStrategy = - new ArtboardUpdateSelectedDesignStrategy() - return designCreateService({ - userId, - targetEntityId: artboardId, - type, - designOverrides: designOverrides || {}, - designTypeOverrides: designTypeOverrides || {}, - strategy, - updateSelectedDesignStrategy, - }) - } catch (error) { - console.log('artboardDesignCreateService error:', error) - const errorType = error instanceof Error - const errorMessage = errorType ? error.message : 'An unknown error occurred' - return { - success: false, - message: errorMessage, - } - } -} diff --git a/app/services/artboard/design/delete.service.ts b/app/services/artboard/design/delete.service.ts deleted file mode 100644 index 119b9247..00000000 --- a/app/services/artboard/design/delete.service.ts +++ /dev/null @@ -1,37 +0,0 @@ -import { type User } from '@prisma/client' -import { type IArtboard } from '#app/models/artboard/artboard.server' -import { type IDesignIdOrNull, type IDesign } from '#app/models/design/design.server' -import { ArtboardUpdateSelectedDesignStrategy } from '#app/strategies/design/update-selected.strategy' -import { designDeleteService } from '../../design/delete.service' - -export const artboardDesignDeleteService = async ({ - userId, - id, - artboardId, - updateSelectedDesignId, -}: { - userId: User['id'] - id: IDesign['id'] - artboardId: IArtboard['id'] - updateSelectedDesignId: IDesignIdOrNull -}) => { - try { - const updateSelectedDesignStrategy = - new ArtboardUpdateSelectedDesignStrategy() - return designDeleteService({ - userId, - id, - targetEntityId: artboardId, - updateSelectedDesignId, - updateSelectedDesignStrategy, - }) - } catch (error) { - console.log('artboardDesignDeleteService error:', error) - const errorType = error instanceof Error - const errorMessage = errorType ? error.message : 'An unknown error occurred' - return { - success: false, - message: errorMessage, - } - } -} diff --git a/app/services/artboard/design/move-down.service.ts b/app/services/artboard/design/move-down.service.ts deleted file mode 100644 index 816a0a14..00000000 --- a/app/services/artboard/design/move-down.service.ts +++ /dev/null @@ -1,41 +0,0 @@ -import { type User } from '@prisma/client' -import { type IArtboard } from '#app/models/artboard/artboard.server' -import { - type IDesign, - type IDesignIdOrNull, -} from '#app/models/design/design.server' -import { type IDesignUpdatedResponse } from '#app/models/design/design.update.server' -import { ArtboardUpdateSelectedDesignStrategy } from '#app/strategies/design/update-selected.strategy' -import { designMoveDownService } from '../../design/move-down.service' - -export const artboardDesignMoveDownService = async ({ - userId, - id, - artboardId, - updateSelectedDesignId, -}: { - userId: User['id'] - id: IDesign['id'] - artboardId: IArtboard['id'] - updateSelectedDesignId?: IDesignIdOrNull -}): Promise => { - try { - const updateSelectedDesignStrategy = - new ArtboardUpdateSelectedDesignStrategy() - return designMoveDownService({ - userId, - id, - targetEntityId: artboardId, - updateSelectedDesignId, - updateSelectedDesignStrategy, - }) - } catch (error) { - console.log('artboardDesignMoveDownService error:', error) - const errorType = error instanceof Error - const errorMessage = errorType ? error.message : 'An unknown error occurred' - return { - success: false, - message: errorMessage, - } - } -} diff --git a/app/services/artboard/design/move-up.service.ts b/app/services/artboard/design/move-up.service.ts deleted file mode 100644 index 973e9bc5..00000000 --- a/app/services/artboard/design/move-up.service.ts +++ /dev/null @@ -1,41 +0,0 @@ -import { type User } from '@prisma/client' -import { type IArtboard } from '#app/models/artboard/artboard.server' -import { - type IDesign, - type IDesignIdOrNull, -} from '#app/models/design/design.server' -import { type IDesignUpdatedResponse } from '#app/models/design/design.update.server' -import { ArtboardUpdateSelectedDesignStrategy } from '#app/strategies/design/update-selected.strategy' -import { designMoveUpService } from '../../design/move-up.service' - -export const artboardDesignMoveUpService = async ({ - userId, - id, - artboardId, - updateSelectedDesignId, -}: { - userId: User['id'] - id: IDesign['id'] - artboardId: IArtboard['id'] - updateSelectedDesignId: IDesignIdOrNull -}): Promise => { - try { - const updateSelectedDesignStrategy = - new ArtboardUpdateSelectedDesignStrategy() - return designMoveUpService({ - userId, - id, - targetEntityId: artboardId, - updateSelectedDesignId, - updateSelectedDesignStrategy, - }) - } catch (error) { - console.log('artboardDesignMoveUpService error:', error) - const errorType = error instanceof Error - const errorMessage = errorType ? error.message : 'An unknown error occurred' - return { - success: false, - message: errorMessage, - } - } -} diff --git a/app/services/artboard/design/toggle-visible.service.ts b/app/services/artboard/design/toggle-visible.service.ts deleted file mode 100644 index 88a8f8b1..00000000 --- a/app/services/artboard/design/toggle-visible.service.ts +++ /dev/null @@ -1,37 +0,0 @@ -import { type User } from '@prisma/client' -import { type IArtboard } from '#app/models/artboard/artboard.server' -import { type IDesign, type IDesignIdOrNull } from '#app/models/design/design.server' -import { ArtboardUpdateSelectedDesignStrategy } from '#app/strategies/design/update-selected.strategy' -import { designToggleVisibleService } from '../../design/toggle-visible.service' - -export const artboardDesignToggleVisibleService = async ({ - userId, - id, - artboardId, - updateSelectedDesignId, -}: { - userId: User['id'] - id: IDesign['id'] - artboardId: IArtboard['id'] - updateSelectedDesignId: IDesignIdOrNull -}) => { - try { - const updateSelectedDesignStrategy = - new ArtboardUpdateSelectedDesignStrategy() - return designToggleVisibleService({ - userId, - id, - targetEntityId: artboardId, - updateSelectedDesignId, - updateSelectedDesignStrategy, - }) - } catch (error) { - console.log('artboardDesignToggleVisibleService error:', error) - const errorType = error instanceof Error - const errorMessage = errorType ? error.message : 'An unknown error occurred' - return { - success: false, - message: errorMessage, - } - } -} diff --git a/app/services/artboard/layer/clone-designs.service.ts b/app/services/artboard/layer/clone-designs.service.ts deleted file mode 100644 index bb0e937e..00000000 --- a/app/services/artboard/layer/clone-designs.service.ts +++ /dev/null @@ -1,38 +0,0 @@ -import { type User } from '@prisma/client' -import { type IDesignEntityId } from '#app/models/design/design.server' -import { type ILayer } from '#app/models/layer/layer.server' -import { type designCloneSourceTypeEnum } from '#app/schema/design' -import { CloneDesignToLayerStrategy } from '#app/strategies/design/clone.strategy' -import { cloneDesignsService } from '../../design/clone-many.service' - -export const artboardLayerCloneDesignsService = async ({ - userId, - sourceEntityType, - sourceEntityId, - targetEntityId, -}: { - userId: User['id'] - sourceEntityType: designCloneSourceTypeEnum - sourceEntityId: IDesignEntityId - targetEntityId: ILayer['id'] -}) => { - try { - const entityStrategy = new CloneDesignToLayerStrategy() - - await cloneDesignsService({ - userId, - sourceEntityType, - sourceEntityId, - targetEntityId, - entityStrategy, - }) - } catch (error) { - console.log('artboardLayerCloneDesignsService error:', error) - const errorType = error instanceof Error - const errorMessage = errorType ? error.message : 'An unknown error occurred' - return { - success: false, - message: errorMessage, - } - } -} diff --git a/app/services/artboard/layer/create.service.ts b/app/services/artboard/layer/create.service.ts deleted file mode 100644 index 19895a81..00000000 --- a/app/services/artboard/layer/create.service.ts +++ /dev/null @@ -1,36 +0,0 @@ -import { type User, type Artboard } from '@prisma/client' -import { type ILayerCreatedResponse } from '#app/models/layer/layer.create.server' -import { type ILayerCreateOverrides } from '#app/models/layer/layer.server' -import { ArtboardCreateLayerStrategy } from '#app/strategies/layer/create.strategy' -import { layerCreateService } from '../../layer/create.service' - -export const artboardLayerCreateService = async ({ - userId, - artboardId, - layerOverrides = {}, - skipCloneDesigns = false, -}: { - userId: User['id'] - artboardId: Artboard['id'] - layerOverrides?: ILayerCreateOverrides - skipCloneDesigns?: boolean -}): Promise => { - try { - const strategy = new ArtboardCreateLayerStrategy() - return await layerCreateService({ - userId, - targetEntityId: artboardId, - layerOverrides, - skipCloneDesigns, - strategy, - }) - } catch (error) { - console.log('artboardLayerCreateService error:', error) - const errorType = error instanceof Error - const errorMessage = errorType ? error.message : 'An unknown error occurred' - return { - success: false, - message: errorMessage, - } - } -} diff --git a/app/services/artboard/layer/delete.service.ts b/app/services/artboard/layer/delete.service.ts deleted file mode 100644 index c30b5aa2..00000000 --- a/app/services/artboard/layer/delete.service.ts +++ /dev/null @@ -1,134 +0,0 @@ -import { type User, type Layer, type Artboard } from '@prisma/client' -import { - findFirstLayer, - connectPrevAndNextLayers, - updateLayerToHead, - updateLayerToTail, -} from '#app/models/layer/layer.server' -import { prisma } from '#app/utils/db.server' - -export const artboardLayerDeleteService = async ({ - userId, - id, - artboardId, -}: { - userId: User['id'] - id: Layer['id'] - artboardId: Artboard['id'] -}) => { - try { - // Step 1: get the layer - const layer = await getLayer({ - userId, - id, - }) - const { nextId, prevId } = layer - - // Step 2: get next and previous layers - const { nextLayer, prevLayer } = await getAdjacentLayers({ - userId, - layer, - }) - - // Step 3: delete layer - const deleteLayerPromise = deleteLayer({ id }) - - // Step 4: update next/prev layers if they exist - const updateLayerNodesPromises = updateLayerNodes({ - nextId, - nextLayer, - prevId, - prevLayer, - }) - - await prisma.$transaction([deleteLayerPromise, ...updateLayerNodesPromises]) - - return { success: true } - } catch (error) { - console.log(error) - return { error: true } - } -} - -const getLayer = async ({ - id, - userId, -}: { - id: Layer['id'] - userId: User['id'] -}) => { - const layer = await findFirstLayer({ - where: { id, ownerId: userId }, - }) - - if (!layer) throw new Error('Layer not found') - - return layer -} - -const getAdjacentLayers = async ({ - userId, - layer, -}: { - userId: User['id'] - layer: Layer -}) => { - const { nextId, prevId } = layer - - const nextLayer = nextId - ? await getLayer({ - userId, - id: nextId, - }) - : null - - const prevLayer = prevId - ? await getLayer({ - userId, - id: prevId, - }) - : null - - return { nextLayer, prevLayer } -} - -const deleteLayer = ({ id }: { id: Layer['id'] }) => { - return prisma.layer.delete({ - where: { id }, - }) -} - -// maintain linked list integrity -const updateLayerNodes = ({ - nextId, - nextLayer, - prevId, - prevLayer, -}: { - nextId: string | null - nextLayer: Layer | null - prevId: string | null - prevLayer: Layer | null -}) => { - const updateLayerNodesPromises = [] - - if (!prevId && nextId && nextLayer) { - // If head, remove prevId from next layer, becomes head - const nextLayerToHeadPromise = updateLayerToHead({ id: nextId }) - updateLayerNodesPromises.push(nextLayerToHeadPromise) - } else if (!nextId && prevId && prevLayer) { - // If tail, remove nextId from prev layer, becomes tail - const prevLayerToTailPromise = updateLayerToTail({ id: prevId }) - updateLayerNodesPromises.push(prevLayerToTailPromise) - } else if (prevId && nextId && prevLayer && nextLayer) { - // If in middle, connect prev and next layers directly - const connectLayersPromise = connectPrevAndNextLayers({ - prevId, - nextId, - }) - - updateLayerNodesPromises.push(...connectLayersPromise) - } - - return updateLayerNodesPromises -} diff --git a/app/services/artboard/layer/move-down.service.ts b/app/services/artboard/layer/move-down.service.ts deleted file mode 100644 index 0cf5d425..00000000 --- a/app/services/artboard/layer/move-down.service.ts +++ /dev/null @@ -1,191 +0,0 @@ -import { type User } from '@prisma/client' -import { type IArtboard } from '#app/models/artboard/artboard.server' -import { - findFirstLayer, - updateLayerRemoveNodes, - type ILayer, - updateLayerNodes, -} from '#app/models/layer/layer.server' -import { prisma } from '#app/utils/db.server' - -export const artboardLayerMoveDownService = async ({ - userId, - id, - artboardId, -}: { - userId: User['id'] - id: ILayer['id'] - artboardId: IArtboard['id'] -}) => { - try { - const moveDownLayerPromises = [] - - // Step 1: get the current layer - // make sure it is not already tail - const currentLayer = await getLayer({ id, userId }) - const { prevId, nextId } = currentLayer - if (!nextId) throw new Error('Layer is already tail') - - // Step 2: get next layer - const nextLayer = await getLayer({ id: nextId, userId }) - const nextNextId = nextLayer.nextId - - // Step 3: get adjacent layers if they exist - const { nextNextLayer, prevLayer } = await getAdjacentLayers({ - userId, - nextNextId, - prevId, - }) - - // Step 4: remove nextId and prevId nodes from all layers - // to satisfy unique constraint when updating other layers - const laterPromiseArgs = { - currentLayer, - nextLayer, - nextNextLayer, - prevLayer, - } - - const removeNodesPromises = removeLayerNodes(laterPromiseArgs) - moveDownLayerPromises.push(...removeNodesPromises) - - // Step 5: update nextId and prevId nodes for current and next layers - // and ensure consistency for adjacent layers - const updateNodesPromises = updateLayerNodesPromises(laterPromiseArgs) - moveDownLayerPromises.push(...updateNodesPromises) - - // Step 6: run all move down promises - await prisma.$transaction(moveDownLayerPromises) - - return { success: true } - } catch (error) { - console.log(error) - return { error: true } - } -} - -const getLayer = async ({ - id, - userId, -}: { - id: ILayer['id'] - userId: User['id'] -}) => { - const layer = await findFirstLayer({ - where: { id, ownerId: userId }, - }) - - if (!layer) throw new Error(`Layer not found: ${id}`) - - return layer -} - -const getAdjacentLayers = async ({ - userId, - nextNextId, - prevId, -}: { - userId: User['id'] - nextNextId: string | null - prevId: string | null -}) => { - const nextNextLayer = nextNextId - ? await getLayer({ - id: nextNextId, - userId, - }) - : null - - const prevLayer = prevId ? await getLayer({ id: prevId, userId }) : null - - return { nextNextLayer, prevLayer } -} - -const removeLayerNodes = ({ - currentLayer, - nextLayer, - nextNextLayer, - prevLayer, -}: { - currentLayer: ILayer - nextLayer: ILayer - nextNextLayer: ILayer | null | undefined - prevLayer: ILayer | null | undefined -}) => { - const removeNodesPromises = [ - updateLayerRemoveNodes({ - id: currentLayer.id, - }), - updateLayerRemoveNodes({ - id: nextLayer.id, - }), - ] - - if (nextNextLayer) { - removeNodesPromises.push( - updateLayerRemoveNodes({ - id: nextNextLayer.id, - }), - ) - } - - if (prevLayer) { - removeNodesPromises.push( - updateLayerRemoveNodes({ - id: prevLayer.id, - }), - ) - } - - return removeNodesPromises -} - -const updateLayerNodesPromises = ({ - currentLayer, - nextLayer, - nextNextLayer, - prevLayer, -}: { - currentLayer: ILayer - nextLayer: ILayer - nextNextLayer: ILayer | null | undefined - prevLayer: ILayer | null | undefined -}) => { - const updateNodesPromises = [] - - // swap nextId and prevId for current and next nodes - const currentNodesPromise = updateLayerNodes({ - id: currentLayer.id, - prevId: nextLayer.id, - nextId: nextLayer.nextId, - }) - - const nextNodesPromise = updateLayerNodes({ - id: nextLayer.id, - prevId: currentLayer.prevId, - nextId: currentLayer.id, - }) - - updateNodesPromises.push(currentNodesPromise, nextNodesPromise) - - // ensure consistency for adjacent nodes - if (nextNextLayer) { - const nextNextNodesPromise = updateLayerNodes({ - id: nextNextLayer.id, - prevId: currentLayer.id, - nextId: nextNextLayer.nextId, - }) - updateNodesPromises.push(nextNextNodesPromise) - } - - if (prevLayer) { - const prevNodesPromise = updateLayerNodes({ - id: prevLayer.id, - prevId: prevLayer.prevId, - nextId: currentLayer.nextId, - }) - updateNodesPromises.push(prevNodesPromise) - } - - return updateNodesPromises -} diff --git a/app/services/artboard/layer/move-up.service.ts b/app/services/artboard/layer/move-up.service.ts deleted file mode 100644 index 933dc60e..00000000 --- a/app/services/artboard/layer/move-up.service.ts +++ /dev/null @@ -1,191 +0,0 @@ -import { type User } from '@prisma/client' -import { type IArtboard } from '#app/models/artboard/artboard.server' -import { - findFirstLayer, - updateLayerRemoveNodes, - type ILayer, - updateLayerNodes, -} from '#app/models/layer/layer.server' -import { prisma } from '#app/utils/db.server' - -export const artboardLayerMoveUpService = async ({ - userId, - id, - artboardId, -}: { - userId: User['id'] - id: ILayer['id'] - artboardId: IArtboard['id'] -}) => { - try { - const moveUpLayerPromises = [] - - // Step 1: get the current layer - // make sure it is not already head - const currentLayer = await getLayer({ id, userId }) - const { prevId, nextId } = currentLayer - if (!prevId) throw new Error('Layer is already head') - - // Step 2: get previous layer - const prevLayer = await getLayer({ id: prevId, userId }) - const prevPrevId = prevLayer.prevId - - // Step 3: get adjacent layers if they exist - const { prevPrevLayer, nextLayer } = await getAdjacentLayers({ - userId, - prevPrevId, - nextId, - }) - - // Step 4: remove nextId and prevId nodes from all layers - // to satisfy unique constraint when updating other layers - const layerPromiseArgs = { - currentLayer, - prevLayer, - prevPrevLayer, - nextLayer, - } - - const removeNodesPromises = removeLayerNodes(layerPromiseArgs) - moveUpLayerPromises.push(...removeNodesPromises) - - // Step 5: update nextId and prevId nodes for current and previous layers - // and ensure consistency for adjacent layers - const updateNodesPromises = updateLayerNodesPromises(layerPromiseArgs) - moveUpLayerPromises.push(...updateNodesPromises) - - // Step 6: run all move up promises - await prisma.$transaction(moveUpLayerPromises) - - return { success: true } - } catch (error) { - console.log(error) - return { error: true } - } -} - -const getLayer = async ({ - id, - userId, -}: { - id: ILayer['id'] - userId: User['id'] -}) => { - const layer = await findFirstLayer({ - where: { id, ownerId: userId }, - }) - - if (!layer) throw new Error(`Layer not found: ${id}`) - - return layer -} - -const getAdjacentLayers = async ({ - userId, - prevPrevId, - nextId, -}: { - userId: User['id'] - prevPrevId: string | null - nextId: string | null -}) => { - const prevPrevLayer = prevPrevId - ? await getLayer({ - id: prevPrevId, - userId, - }) - : null - - const nextLayer = nextId ? await getLayer({ id: nextId, userId }) : null - - return { prevPrevLayer, nextLayer } -} - -const removeLayerNodes = ({ - currentLayer, - prevLayer, - prevPrevLayer, - nextLayer, -}: { - currentLayer: ILayer - prevLayer: ILayer - prevPrevLayer: ILayer | null | undefined - nextLayer: ILayer | null | undefined -}) => { - const removeNodesPromises = [ - updateLayerRemoveNodes({ - id: currentLayer.id, - }), - updateLayerRemoveNodes({ - id: prevLayer.id, - }), - ] - - if (prevPrevLayer) { - removeNodesPromises.push( - updateLayerRemoveNodes({ - id: prevPrevLayer.id, - }), - ) - } - - if (nextLayer) { - removeNodesPromises.push( - updateLayerRemoveNodes({ - id: nextLayer.id, - }), - ) - } - - return removeNodesPromises -} - -const updateLayerNodesPromises = ({ - currentLayer, - prevLayer, - prevPrevLayer, - nextLayer, -}: { - currentLayer: ILayer - prevLayer: ILayer - prevPrevLayer: ILayer | null | undefined - nextLayer: ILayer | null | undefined -}) => { - const updateNodesPromises = [] - - // swap nextId and prevId for current and previous nodes - const currentNodesPromise = updateLayerNodes({ - id: currentLayer.id, - prevId: prevLayer.prevId, - nextId: prevLayer.id, - }) - - const prevNodesPromise = updateLayerNodes({ - id: prevLayer.id, - prevId: currentLayer.id, - nextId: currentLayer.nextId, - }) - - updateNodesPromises.push(currentNodesPromise, prevNodesPromise) - - // ensure consistency for adjacent nodes - if (prevPrevLayer) { - const prevPrevNodesPromise = updateLayerNodes({ - id: prevPrevLayer.id, - prevId: prevPrevLayer.prevId, - nextId: currentLayer.id, - }) - updateNodesPromises.push(prevPrevNodesPromise) - } - - if (nextLayer) { - const nextNodesPromise = updateLayerNodes({ - id: nextLayer.id, - prevId: currentLayer.prevId, - nextId: nextLayer.nextId, - }) - updateNodesPromises.push(nextNodesPromise) - } - - return updateNodesPromises -} diff --git a/app/services/artboard/layer/toggle-visible.service.ts b/app/services/artboard/layer/toggle-visible.service.ts deleted file mode 100644 index 96decf5b..00000000 --- a/app/services/artboard/layer/toggle-visible.service.ts +++ /dev/null @@ -1,52 +0,0 @@ -import { type User } from '@prisma/client' -import { type IArtboard } from '#app/models/artboard/artboard.server' -import { - findFirstLayer, - updateLayerVisible, - type ILayer, -} from '#app/models/layer/layer.server' -import { prisma } from '#app/utils/db.server' - -export const artboardLayerToggleVisibleService = async ({ - userId, - id, - artboardId, -}: { - userId: User['id'] - id: ILayer['id'] - artboardId: IArtboard['id'] -}) => { - try { - // Step 1: get the design - const layer = await getLayer({ id, userId }) - const { visible } = layer - - // Step 2: update the design visible state - const toggleLayerVisiblePromise = updateLayerVisible({ - id, - visible: !visible, - }) - await prisma.$transaction([toggleLayerVisiblePromise]) - - return { success: true } - } catch (error) { - console.log(error) - return { error: true } - } -} - -const getLayer = async ({ - id, - userId, -}: { - id: ILayer['id'] - userId: User['id'] -}) => { - const layer = await findFirstLayer({ - where: { id, ownerId: userId }, - }) - - if (!layer) throw new Error(`Layer not found: ${id}`) - - return layer -} diff --git a/app/services/design/clone-many.service.ts b/app/services/design/clone-many.service.ts index 853b82a1..fa518314 100644 --- a/app/services/design/clone-many.service.ts +++ b/app/services/design/clone-many.service.ts @@ -67,11 +67,9 @@ const getSourceEntityDesigns = async ({ sourceEntityId: IDesignEntityId }): Promise => { const where = - sourceEntityType === DesignCloneSourceTypeEnum.ARTBOARD - ? { artboardId: sourceEntityId } - : sourceEntityType === DesignCloneSourceTypeEnum.ARTBOARD_VERSION - ? { artboardVersionId: sourceEntityId } - : { layerId: sourceEntityId } + sourceEntityType === DesignCloneSourceTypeEnum.ARTBOARD_VERSION + ? { artboardVersionId: sourceEntityId } + : { layerId: sourceEntityId } return await findManyDesignsWithType({ where }) } diff --git a/app/strategies/design/create.strategy.ts b/app/strategies/design/create.strategy.ts index cf0a4515..0c7f4581 100644 --- a/app/strategies/design/create.strategy.ts +++ b/app/strategies/design/create.strategy.ts @@ -1,5 +1,4 @@ import { type User } from '@prisma/client' -import { type IArtboard } from '#app/models/artboard/artboard.server' import { type IArtboardVersion } from '#app/models/artboard-version/artboard-version.server' import { createArtboardVersionDesign, @@ -13,7 +12,6 @@ import { } from '#app/models/design/design.server' import { type ILayer } from '#app/models/layer/layer.server' import { type designTypeEnum } from '#app/schema/design' -import { ArtboardDesignDataCreateSchema } from '#app/schema/design-artboard' import { LayerDesignDataCreateSchema } from '#app/schema/design-layer' import { prisma } from '#app/utils/db.server' @@ -132,50 +130,3 @@ export class ArtboardVersionCreateDesignStrategy return Number(visibleDesignsByTypeCount) } } - -export class ArtboardCreateDesignStrategy implements ICreateDesignStrategy { - async getDesignsByTypeTail({ - targetEntityId, - type, - }: { - targetEntityId: IArtboard['id'] - type: designTypeEnum - }): Promise { - return await getDesign({ - where: { type, artboardId: targetEntityId, nextId: null }, - }) - } - - async createEntityDesign({ - userId, - targetEntityId, - type, - designOverrides, - }: { - userId: User['id'] - targetEntityId: IArtboard['id'] - type: designTypeEnum - designOverrides: IDesignCreateOverrides - }): Promise { - const data = ArtboardDesignDataCreateSchema.parse({ - type, - ownerId: userId, - artboardId: targetEntityId, - ...designOverrides, - }) - return await prisma.design.create({ data }) - } - - async visibleDesignsByTypeCount({ - targetEntityId, - type, - }: { - targetEntityId: IArtboard['id'] - type: designTypeEnum - }): Promise { - const visibleDesignsByTypeCount = await prisma.design.count({ - where: { artboardId: targetEntityId, type, visible: true }, - }) - return Number(visibleDesignsByTypeCount) - } -} diff --git a/app/strategies/design/update-selected.strategy.ts b/app/strategies/design/update-selected.strategy.ts index adf1cf8d..bd6f4714 100644 --- a/app/strategies/design/update-selected.strategy.ts +++ b/app/strategies/design/update-selected.strategy.ts @@ -1,4 +1,3 @@ -import { type IArtboard } from '#app/models/artboard/artboard.server' import { type IArtboardVersion } from '#app/models/artboard-version/artboard-version.server' import { type IDesign, @@ -10,11 +9,6 @@ import { deselectArtboardVersionSelectedDesign, updateArtboardVersionSelectedDesign, } from '#app/models/design-artboard-version/design-artboard-version.server' -import { - deselectArtboardSelectedDesign, - findFirstVisibleArtboardDesignByType, - updateArtboardSelectedDesign, -} from '#app/models/design-artboard.server' import { findFirstVisibleLayerDesignByType } from '#app/models/design-layer/design-layer.get.server' import { deselectLayerSelectedDesign, @@ -135,51 +129,3 @@ export class ArtboardVersionUpdateSelectedDesignStrategy await prisma.$transaction([deselectDesignsPromise]) } } - -export class ArtboardUpdateSelectedDesignStrategy - implements IUpdateSelectedDesignStrategy -{ - async updateSelectedDesign({ - targetEntityId, - designId, - type, - }: { - targetEntityId: IArtboard['id'] - designId: IDesign['id'] - type: designTypeEnum - }) { - const updateSelectedDesignPromise = updateArtboardSelectedDesign({ - artboardId: targetEntityId, - designId, - type, - }) - await prisma.$transaction(updateSelectedDesignPromise) - } - - async findFirstVisibleDesign({ - targetEntityId, - type, - }: { - targetEntityId: IArtboard['id'] - type: designTypeEnum - }) { - return await findFirstVisibleArtboardDesignByType({ - artboardId: targetEntityId, - type, - }) - } - - async deselectDesign({ - targetEntityId, - type, - }: { - targetEntityId: IArtboard['id'] - type: designTypeEnum - }) { - const deselectDesignsPromise = deselectArtboardSelectedDesign({ - artboardId: targetEntityId, - type, - }) - await prisma.$transaction([deselectDesignsPromise]) - } -} diff --git a/app/strategies/layer/create.strategy.ts b/app/strategies/layer/create.strategy.ts index ff7e32d8..adc94748 100644 --- a/app/strategies/layer/create.strategy.ts +++ b/app/strategies/layer/create.strategy.ts @@ -1,5 +1,4 @@ import { type User } from '@prisma/client' -import { type IArtboard } from '#app/models/artboard/artboard.server' import { type IArtboardVersion } from '#app/models/artboard-version/artboard-version.server' import { createLayer } from '#app/models/layer/layer.create.server' import { @@ -9,9 +8,7 @@ import { type ILayerEntityId, } from '#app/models/layer/layer.server' import { DesignCloneSourceTypeEnum } from '#app/schema/design' -import { ArtboardLayerDataCreateSchema } from '#app/schema/layer-artboard' import { ArtboardVersionLayerDataCreateSchema } from '#app/schema/layer-artboard-version' -import { artboardLayerCloneDesignsService } from '#app/services/artboard/layer/clone-designs.service' import { artboardVersionLayerCloneDesignsService } from '#app/services/artboard/version/layer/clone-designs.service' import { prisma } from '#app/utils/db.server' @@ -92,59 +89,3 @@ export class ArtboardVersionCreateLayerStrategy }) } } - -export class ArtboardCreateLayerStrategy implements ICreateLayerStrategy { - async getEntityLayersTail({ - targetEntityId, - }: { - targetEntityId: IArtboard['id'] - }): Promise { - return await findFirstLayer({ - where: { artboardId: targetEntityId, nextId: null }, - }) - } - - async createEntityLayer({ - userId, - targetEntityId, - layerOverrides, - }: { - userId: User['id'] - targetEntityId: IArtboard['id'] - layerOverrides: ILayerCreateOverrides - }): Promise { - const data = ArtboardLayerDataCreateSchema.parse({ - ownerId: userId, - artboardId: targetEntityId, - ...layerOverrides, - }) - return await createLayer({ data }) - } - - async getEntityLayersCount({ - targetEntityId, - }: { - targetEntityId: IArtboard['id'] - }): Promise { - return await prisma.layer.count({ - where: { artboardId: targetEntityId }, - }) - } - - async layerCloneDesignsService({ - userId, - sourceEntityId, - targetEntityId, - }: { - userId: User['id'] - sourceEntityId: ILayerEntityId - targetEntityId: ILayerEntityId - }) { - await artboardLayerCloneDesignsService({ - userId, - sourceEntityType: DesignCloneSourceTypeEnum.ARTBOARD, - sourceEntityId, - targetEntityId, - }) - } -} diff --git a/package.json b/package.json index fd0a13d1..03661cb3 100644 --- a/package.json +++ b/package.json @@ -30,7 +30,6 @@ "typecheck": "tsc", "typecheck:watch": "tsc -w", "validate": "run-p \"test -- --run\" lint typecheck test:e2e:run", - "data:migrate": "npx vite-node ./prisma/data-migrations/create-artboard-versions-and-branches.ts", "fly:status": "./scripts/fly.io/app-status.sh", "fly:console:prisma:studio": "./scripts/fly.io/app-console-prisma-studio.sh", "fly:console:prisma:studio:proxy": "./scripts/fly.io/app-console-prisma-studio-proxy.sh", diff --git a/prisma/data-migrations/create-artboard-versions-and-branches.ts b/prisma/data-migrations/create-artboard-versions-and-branches.ts index 2ec352ca..568e7d69 100644 --- a/prisma/data-migrations/create-artboard-versions-and-branches.ts +++ b/prisma/data-migrations/create-artboard-versions-and-branches.ts @@ -1,156 +1,159 @@ -import { getArtboardsWithDesignsAndLayers } from '#app/models/artboard/artboard.get.server' -import { type IArtboardWithDesignsAndLayers } from '#app/models/artboard/artboard.server' -import { createDefaultArtboardBranchWithVersion } from '#app/models/artboard-branch/artboard-branch.create.server' -import { type IArtboardVersion } from '#app/models/artboard-version/artboard-version.server' -import { DesignCloneSourceTypeEnum } from '#app/schema/design' -import { LayerCloneSourceTypeEnum } from '#app/schema/layer' -import { artboardVersionCloneDesignsService } from '#app/services/artboard/version/clone-designs.service' -import { artboardVersionCloneLayersService } from '#app/services/artboard/version/clone-layers.service' -import { prisma } from '#app/utils/db.server' - -// artboards will have version control now -// new prisma migration created the following tables: -// - ArtboardVersion, ArtboardBranch, ArtboardMergeRequest -// and the following changes to existing tables: -// - artboard: has many versions, branches, mergeRequests -// - layer: added artboardVersion, artboardBranch -// - design: added artboardVersion, artboardBranch - -// the goal of this script: -// - for each artboard -// - - create a new version (latest) -// - - create a new branch (main) -// - - deep copy layers and designs to the new version and branch - -// after this script runs, there is more work to do: -// - routing, ui, and api changes to support artboard versions and branches - -// how to run: -// 1) add the folowing to package.json scripts: -// "data:migrate": "npx vite-node ./prisma/data-migrations/create-artboard-versions-and-branches.ts" -// 2) run `npm run data:migrate` -// 3) remove the script from package.json - -export const createArtboardVersionsBranches = async () => { - console.log('createArtboardVersionsBranches begin 🎬') - - // Step 1: remove all artboard branches and versions from previous runs - await clear() - - // const initialEntityCounts = await getCountOfAllEntities() - - // Step 2: get all artboards - // with their designs, layers, and layers' designs - const artboards = await getArtboards() - - // Step 2: clone each artboard to a new version and branch - for (const [, artboard] of artboards.entries()) { - await cloneArtboard({ artboard }) - } - - console.log('createArtboardVersionsBranches end 🏁') -} - -const clear = async () => { - await prisma.artboardBranch.deleteMany() - await prisma.artboardVersion.deleteMany() - await prisma.layer.deleteMany({ - where: { - artboardVersionId: { - not: null, - }, - }, - }) - await prisma.design.deleteMany({ - where: { - artboardVersionId: { - not: null, - }, - }, - }) -} - -const getArtboards = async (): Promise => { - return await getArtboardsWithDesignsAndLayers({ where: {} }) -} - -const cloneArtboard = async ({ - artboard, -}: { - artboard: IArtboardWithDesignsAndLayers -}) => { - console.log('artboard: ', artboard.name) - - // Step 1: create a new branch and version - const artboardVersions = await createArtboardBranchWithVersion({ artboard }) - - // Step 2: clone artboard children to the new version - for (const [, artboardVersion] of artboardVersions.entries()) { - await cloneArtboardChildrenToVersion({ artboard, artboardVersion }) - } -} - -const createArtboardBranchWithVersion = async ({ - artboard, -}: { - artboard: IArtboardWithDesignsAndLayers -}): Promise => { - const artboardBranch = await createDefaultArtboardBranchWithVersion({ - artboard, - }) - - if (!artboardBranch) { - throw new Error('createArtboardBranchWithVersion failed') - } - - return artboardBranch.versions -} - -const cloneArtboardChildrenToVersion = async ({ - artboard, - artboardVersion, -}: { - artboard: IArtboardWithDesignsAndLayers - artboardVersion: IArtboardVersion -}) => { - await cloneArtboardDesignsToVersion({ - artboard, - artboardVersion, - }) - await cloneArtboardLayersToVersion({ - artboard, - artboardVersion, - }) -} - -const cloneArtboardDesignsToVersion = async ({ - artboard, - artboardVersion, -}: { - artboard: IArtboardWithDesignsAndLayers - artboardVersion: IArtboardVersion -}) => { - return await artboardVersionCloneDesignsService({ - userId: artboard.ownerId, - sourceEntityType: DesignCloneSourceTypeEnum.ARTBOARD, - sourceEntityId: artboard.id, - targetEntityId: artboardVersion.id, - }) -} - -const cloneArtboardLayersToVersion = async ({ - artboard, - artboardVersion, -}: { - artboard: IArtboardWithDesignsAndLayers - artboardVersion: IArtboardVersion -}) => { - return await artboardVersionCloneLayersService({ - userId: artboard.ownerId, - sourceEntityType: LayerCloneSourceTypeEnum.ARTBOARD, - sourceEntityId: artboard.id, - targetEntityId: artboardVersion.id, - }) -} - -await createArtboardVersionsBranches() +// archived: this script is no longer needed +// keeping for reference when the next script is needed + +// import { getArtboardsWithDesignsAndLayers } from '#app/models/artboard/artboard.get.server' +// import { type IArtboardWithDesignsAndLayers } from '#app/models/artboard/artboard.server' +// import { createDefaultArtboardBranchWithVersion } from '#app/models/artboard-branch/artboard-branch.create.server' +// import { type IArtboardVersion } from '#app/models/artboard-version/artboard-version.server' +// import { DesignCloneSourceTypeEnum } from '#app/schema/design' +// import { LayerCloneSourceTypeEnum } from '#app/schema/layer' +// import { artboardVersionCloneDesignsService } from '#app/services/artboard/version/clone-designs.service' +// import { artboardVersionCloneLayersService } from '#app/services/artboard/version/clone-layers.service' +// import { prisma } from '#app/utils/db.server' + +// // artboards will have version control now +// // new prisma migration created the following tables: +// // - ArtboardVersion, ArtboardBranch, ArtboardMergeRequest +// // and the following changes to existing tables: +// // - artboard: has many versions, branches, mergeRequests +// // - layer: added artboardVersion, artboardBranch +// // - design: added artboardVersion, artboardBranch + +// // the goal of this script: +// // - for each artboard +// // - - create a new version (latest) +// // - - create a new branch (main) +// // - - deep copy layers and designs to the new version and branch + +// // after this script runs, there is more work to do: +// // - routing, ui, and api changes to support artboard versions and branches + +// // how to run: +// // 1) add the folowing to package.json scripts: +// // "data:migrate": "npx vite-node ./prisma/data-migrations/create-artboard-versions-and-branches.ts" +// // 2) run `npm run data:migrate` +// // 3) remove the script from package.json + +// export const createArtboardVersionsBranches = async () => { +// console.log('createArtboardVersionsBranches begin 🎬') + +// // Step 1: remove all artboard branches and versions from previous runs +// await clear() + +// // const initialEntityCounts = await getCountOfAllEntities() + +// // Step 2: get all artboards +// // with their designs, layers, and layers' designs +// const artboards = await getArtboards() + +// // Step 2: clone each artboard to a new version and branch +// for (const [, artboard] of artboards.entries()) { +// await cloneArtboard({ artboard }) +// } + +// console.log('createArtboardVersionsBranches end 🏁') +// } + +// const clear = async () => { +// await prisma.artboardBranch.deleteMany() +// await prisma.artboardVersion.deleteMany() +// await prisma.layer.deleteMany({ +// where: { +// artboardVersionId: { +// not: null, +// }, +// }, +// }) +// await prisma.design.deleteMany({ +// where: { +// artboardVersionId: { +// not: null, +// }, +// }, +// }) +// } + +// const getArtboards = async (): Promise => { +// return await getArtboardsWithDesignsAndLayers({ where: {} }) +// } + +// const cloneArtboard = async ({ +// artboard, +// }: { +// artboard: IArtboardWithDesignsAndLayers +// }) => { +// console.log('artboard: ', artboard.name) + +// // Step 1: create a new branch and version +// const artboardVersions = await createArtboardBranchWithVersion({ artboard }) + +// // Step 2: clone artboard children to the new version +// for (const [, artboardVersion] of artboardVersions.entries()) { +// await cloneArtboardChildrenToVersion({ artboard, artboardVersion }) +// } +// } + +// const createArtboardBranchWithVersion = async ({ +// artboard, +// }: { +// artboard: IArtboardWithDesignsAndLayers +// }): Promise => { +// const artboardBranch = await createDefaultArtboardBranchWithVersion({ +// artboard, +// }) + +// if (!artboardBranch) { +// throw new Error('createArtboardBranchWithVersion failed') +// } + +// return artboardBranch.versions +// } + +// const cloneArtboardChildrenToVersion = async ({ +// artboard, +// artboardVersion, +// }: { +// artboard: IArtboardWithDesignsAndLayers +// artboardVersion: IArtboardVersion +// }) => { +// await cloneArtboardDesignsToVersion({ +// artboard, +// artboardVersion, +// }) +// await cloneArtboardLayersToVersion({ +// artboard, +// artboardVersion, +// }) +// } + +// const cloneArtboardDesignsToVersion = async ({ +// artboard, +// artboardVersion, +// }: { +// artboard: IArtboardWithDesignsAndLayers +// artboardVersion: IArtboardVersion +// }) => { +// return await artboardVersionCloneDesignsService({ +// userId: artboard.ownerId, +// sourceEntityType: DesignCloneSourceTypeEnum.ARTBOARD, +// sourceEntityId: artboard.id, +// targetEntityId: artboardVersion.id, +// }) +// } + +// const cloneArtboardLayersToVersion = async ({ +// artboard, +// artboardVersion, +// }: { +// artboard: IArtboardWithDesignsAndLayers +// artboardVersion: IArtboardVersion +// }) => { +// return await artboardVersionCloneLayersService({ +// userId: artboard.ownerId, +// sourceEntityType: LayerCloneSourceTypeEnum.ARTBOARD, +// sourceEntityId: artboard.id, +// targetEntityId: artboardVersion.id, +// }) +// } + +// await createArtboardVersionsBranches() diff --git a/prisma/migrations/20240522070118_remove_artboard_from_layer_and_design/migration.sql b/prisma/migrations/20240522070118_remove_artboard_from_layer_and_design/migration.sql new file mode 100644 index 00000000..1296d06d --- /dev/null +++ b/prisma/migrations/20240522070118_remove_artboard_from_layer_and_design/migration.sql @@ -0,0 +1,65 @@ +/* + Warnings: + + - You are about to drop the column `artboardId` on the `Design` table. All the data in the column will be lost. + - You are about to drop the column `artboardId` on the `Layer` table. All the data in the column will be lost. + +*/ +-- RedefineTables +PRAGMA foreign_keys=OFF; +CREATE TABLE "new_Design" ( + "id" TEXT NOT NULL PRIMARY KEY, + "type" TEXT NOT NULL, + "visible" BOOLEAN NOT NULL DEFAULT true, + "selected" BOOLEAN NOT NULL DEFAULT false, + "createdAt" DATETIME NOT NULL DEFAULT CURRENT_TIMESTAMP, + "nextId" TEXT, + "prevId" TEXT, + "ownerId" TEXT NOT NULL, + "artboardVersionId" TEXT, + "layerId" TEXT, + CONSTRAINT "Design_nextId_fkey" FOREIGN KEY ("nextId") REFERENCES "Design" ("id") ON DELETE SET NULL ON UPDATE CASCADE, + CONSTRAINT "Design_ownerId_fkey" FOREIGN KEY ("ownerId") REFERENCES "User" ("id") ON DELETE CASCADE ON UPDATE CASCADE, + CONSTRAINT "Design_artboardVersionId_fkey" FOREIGN KEY ("artboardVersionId") REFERENCES "ArtboardVersion" ("id") ON DELETE CASCADE ON UPDATE CASCADE, + CONSTRAINT "Design_layerId_fkey" FOREIGN KEY ("layerId") REFERENCES "Layer" ("id") ON DELETE CASCADE ON UPDATE CASCADE +); +INSERT INTO "new_Design" ("artboardVersionId", "createdAt", "id", "layerId", "nextId", "ownerId", "prevId", "selected", "type", "visible") SELECT "artboardVersionId", "createdAt", "id", "layerId", "nextId", "ownerId", "prevId", "selected", "type", "visible" FROM "Design"; +DROP TABLE "Design"; +ALTER TABLE "new_Design" RENAME TO "Design"; +CREATE UNIQUE INDEX "Design_nextId_key" ON "Design"("nextId"); +CREATE UNIQUE INDEX "Design_prevId_key" ON "Design"("prevId"); +CREATE INDEX "Design_ownerId_idx" ON "Design"("ownerId"); +CREATE INDEX "Design_layerId_idx" ON "Design"("layerId"); +CREATE INDEX "Design_artboardVersionId_idx" ON "Design"("artboardVersionId"); +CREATE TABLE "new_Layer" ( + "id" TEXT NOT NULL PRIMARY KEY, + "name" TEXT NOT NULL, + "description" TEXT, + "slug" TEXT, + "visible" BOOLEAN NOT NULL DEFAULT true, + "selected" BOOLEAN NOT NULL DEFAULT false, + "createdAt" DATETIME NOT NULL DEFAULT CURRENT_TIMESTAMP, + "updatedAt" DATETIME NOT NULL, + "ownerId" TEXT NOT NULL, + "artboardVersionId" TEXT, + "nextId" TEXT, + "prevId" TEXT, + "parentId" TEXT, + CONSTRAINT "Layer_ownerId_fkey" FOREIGN KEY ("ownerId") REFERENCES "User" ("id") ON DELETE CASCADE ON UPDATE CASCADE, + CONSTRAINT "Layer_artboardVersionId_fkey" FOREIGN KEY ("artboardVersionId") REFERENCES "ArtboardVersion" ("id") ON DELETE CASCADE ON UPDATE CASCADE, + CONSTRAINT "Layer_nextId_fkey" FOREIGN KEY ("nextId") REFERENCES "Layer" ("id") ON DELETE SET NULL ON UPDATE CASCADE, + CONSTRAINT "Layer_parentId_fkey" FOREIGN KEY ("parentId") REFERENCES "Layer" ("id") ON DELETE CASCADE ON UPDATE CASCADE +); +INSERT INTO "new_Layer" ("artboardVersionId", "createdAt", "description", "id", "name", "nextId", "ownerId", "parentId", "prevId", "selected", "slug", "updatedAt", "visible") SELECT "artboardVersionId", "createdAt", "description", "id", "name", "nextId", "ownerId", "parentId", "prevId", "selected", "slug", "updatedAt", "visible" FROM "Layer"; +DROP TABLE "Layer"; +ALTER TABLE "new_Layer" RENAME TO "Layer"; +CREATE UNIQUE INDEX "Layer_nextId_key" ON "Layer"("nextId"); +CREATE UNIQUE INDEX "Layer_prevId_key" ON "Layer"("prevId"); +CREATE INDEX "Layer_ownerId_idx" ON "Layer"("ownerId"); +CREATE INDEX "Layer_artboardVersionId_idx" ON "Layer"("artboardVersionId"); +CREATE INDEX "Layer_parentId_idx" ON "Layer"("parentId"); +CREATE INDEX "Layer_ownerId_updatedAt_idx" ON "Layer"("ownerId", "updatedAt"); +CREATE UNIQUE INDEX "Layer_slug_ownerId_artboardVersionId_key" ON "Layer"("slug", "ownerId", "artboardVersionId"); +PRAGMA foreign_key_check("Design"); +PRAGMA foreign_key_check("Layer"); +PRAGMA foreign_keys=ON; diff --git a/prisma/schema.prisma b/prisma/schema.prisma index a8e8c832..824d0056 100644 --- a/prisma/schema.prisma +++ b/prisma/schema.prisma @@ -223,9 +223,6 @@ model Artboard { branches ArtboardBranch[] mergeRequests ArtboardMergeRequest[] - layers Layer[] - designs Design[] - // non-unique foreign key @@index([projectId]) @@index([ownerId]) @@ -250,9 +247,6 @@ model Layer { owner User @relation(fields: [ownerId], references: [id], onDelete: Cascade, onUpdate: Cascade) ownerId String - artboard Artboard? @relation(fields: [artboardId], references: [id], onDelete: Cascade, onUpdate: Cascade) - artboardId String? - artboardVersionId String? artboardVersion ArtboardVersion? @relation(fields: [artboardVersionId], references: [id], onDelete: Cascade, onUpdate: Cascade) @@ -276,7 +270,6 @@ model Layer { // This helps our order by in the user search a LOT @@index([ownerId, updatedAt]) // Unique constraint for slug scoped to ownerId - @@unique([slug, ownerId, artboardId]) @@unique([slug, ownerId, artboardVersionId]) } @@ -349,9 +342,6 @@ model Design { owner User @relation(fields: [ownerId], references: [id], onDelete: Cascade, onUpdate: Cascade) ownerId String - artboard Artboard? @relation(fields: [artboardId], references: [id], onDelete: Cascade, onUpdate: Cascade) - artboardId String? - artboardVersionId String? artboardVersion ArtboardVersion? @relation(fields: [artboardVersionId], references: [id], onDelete: Cascade, onUpdate: Cascade) From 054faa8e9afba1d5bea5b3f1316ad132a3b957d2 Mon Sep 17 00:00:00 2001 From: Pat Needham Date: Wed, 22 May 2024 04:18:52 -0400 Subject: [PATCH 2/3] artboard to artwork --- README.md | 8 +- .../templates/card/dashboard-entity-cards.tsx | 24 +- .../dashboard-entity-panel.actions.delete.tsx | 16 +- ...d-entity-panel.actions.toggle-selected.tsx | 20 +- ...rd-entity-panel.actions.toggle-visible.tsx | 26 +- .../panel/dashboard-entity-panel.header.tsx | 20 +- .../panel/dashboard-entity-panel.reorder.tsx | 34 +-- .../dashboard-entity-panel.values.layer.tsx | 8 +- ...oard-generator.ts => artwork-generator.ts} | 16 +- .../artboard-branch.create.server.ts | 86 ------ .../artboard-branch/artboard-branch.server.ts | 16 -- .../artboard-version.delete.server.ts | 21 -- .../artboard-version.update.server.ts | 159 ----------- app/models/artboard/artboard.server.ts | 20 -- .../artwork-branch.create.server.ts | 86 ++++++ .../artwork-branch.get.server.ts} | 32 +-- .../artwork-branch/artwork-branch.server.ts | 16 ++ .../artwork-version.create.server.ts} | 24 +- .../artwork-version.delete.server.ts | 21 ++ .../artwork-version.get.server.ts} | 40 +-- .../artwork-version.server.ts} | 10 +- .../artwork-version.update.server.ts | 159 +++++++++++ .../artwork.get.server.ts} | 32 +-- app/models/artwork/artwork.server.ts | 20 ++ .../design-artboard-version.create.server.ts | 18 -- .../design-artboard-version.delete.server.ts | 18 -- .../design-artboard-version.update.server.ts | 35 --- .../design-artwork-version.create.server.ts | 18 ++ .../design-artwork-version.delete.server.ts | 18 ++ .../design-artwork-version.get.server.ts} | 10 +- .../design-artwork-version.server.ts} | 40 +-- .../design-artwork-version.update.server.ts | 35 +++ app/models/design/design.create.server.ts | 16 +- app/models/design/design.get.server.ts | 4 +- app/models/design/design.server.ts | 12 +- .../layer-artboard-version.update.server.ts | 77 ----- .../layer-artwork-version.update.server.ts | 77 +++++ app/models/layer/layer.create.server.ts | 18 +- app/models/layer/layer.delete.server.ts | 10 +- app/models/layer/layer.server.ts | 8 +- app/models/project/project.get.server.ts | 16 +- app/models/project/project.server.ts | 6 +- ...h.create.tsx => artwork-branch.create.tsx} | 36 +-- ....create.tsx => artwork-version.create.tsx} | 18 +- ....tsx => artwork-version.design.create.tsx} | 24 +- ....tsx => artwork-version.design.delete.tsx} | 24 +- ...> artwork-version.design.update.order.tsx} | 32 +-- ...artwork-version.design.update.visible.tsx} | 24 +- ...e.tsx => artwork-version.layer.create.tsx} | 29 +- ...e.tsx => artwork-version.layer.delete.tsx} | 28 +- ...=> artwork-version.layer.update.order.tsx} | 32 +-- ...artwork-version.layer.update.selected.tsx} | 24 +- ... artwork-version.layer.update.visible.tsx} | 24 +- ... => artwork-version.update.background.tsx} | 22 +- ....tsx => artwork-version.update.height.tsx} | 22 +- ...h.tsx => artwork-version.update.width.tsx} | 22 +- .../api.v1+/layer.design.create.tsx | 2 +- .../api.v1+/layer.design.update.visible.tsx | 2 +- app/routes/sketch+/index.tsx | 4 +- .../sidebars.panel.artboard-version.frame.tsx | 30 -- ...sidebars.panel.artboard-version.layers.tsx | 34 --- .../sidebars.panel.artboard-version.tsx | 18 -- ...idebars.panel.designs.artboard-version.tsx | 27 -- .../$branchSlug.$versionSlug.tsx | 54 ++-- .../$artworkSlug+}/$branchSlug._index.tsx | 12 +- .../$artworkSlug+}/$branchSlug.tsx | 32 +-- .../__components/canvas-content.tsx | 16 +- .../header.artwork.button-group.tsx} | 34 +-- .../header.artwork.comboboxes.tsx} | 42 +-- .../__components/header.artwork.tsx} | 28 +- ...bars.panel.artwork-version.background.tsx} | 10 +- .../sidebars.panel.artwork-version.frame.tsx | 30 ++ .../sidebars.panel.artwork-version.layers.tsx | 34 +++ .../sidebars.panel.artwork-version.tsx | 18 ++ ...sidebars.panel.designs.artwork-version.tsx | 27 ++ .../sidebars.panel.designs.layer.tsx | 0 .../__components/sidebars.panel.designs.tsx | 0 .../__components/sidebars.panel.layer.tsx | 0 .../$artworkSlug+}/__components/sidebars.tsx | 14 +- .../$artworkSlug+}/_index.tsx | 14 +- .../$artworkSlug+}/route.tsx | 26 +- .../{artboards+ => artworks+}/index.tsx | 24 +- .../{artboards+ => artworks+}/route.tsx | 10 +- .../projects+/$projectSlug_+/index.tsx | 14 +- .../projects+/$projectSlug_+/route.tsx | 4 +- .../projects+/components/projects-sidebar.tsx | 14 +- app/routes/sketch+/projects+/index.tsx | 4 +- app/routes/sketch+/projects+/route.tsx | 4 +- .../$artworkId}/_index/components.tsx | 28 +- .../_index/delete-artwork-form.tsx} | 6 +- .../$artworkId}/_index/queries.ts | 8 +- .../$artworkId}/_index/route.tsx | 64 ++--- .../$artworkId}/edit/edit-form.server.ts | 22 +- .../$artworkId}/edit/edit-form.tsx | 32 +-- .../$artworkId}/edit/route.tsx | 30 +- .../$artworkId}/route.tsx | 12 +- .../{artboards+ => artworks+}/components.tsx | 24 +- .../{artboards+ => artworks+}/route.tsx | 10 +- .../_index/{artboards.tsx => artworks.tsx} | 28 +- .../$projectId/_index/components.tsx | 4 +- .../projects+/$projectId/_index/route.tsx | 2 +- .../{artboards => artworks}/_index/route.tsx | 0 .../new/new-artwork-form.server.ts} | 22 +- .../new/new-artwork-form.tsx} | 14 +- .../{artboards => artworks}/new/route.tsx | 6 +- .../{artboards => artworks}/route.tsx | 2 +- .../{artboard-branch.ts => artwork-branch.ts} | 8 +- ...artboard-version.ts => artwork-version.ts} | 26 +- app/schema/{artboard.ts => artwork.ts} | 16 +- ...d-version.ts => design-artwork-version.ts} | 26 +- app/schema/design.ts | 32 +-- app/schema/entity.ts | 38 +-- app/schema/layer-artboard-version.ts | 41 --- app/schema/layer-artwork-version.ts | 41 +++ app/schema/layer.ts | 30 +- .../artboard/branch/create.service.ts | 113 -------- .../artboard/branch/version/create.service.ts | 136 --------- .../artboard/version/update.service.ts | 65 ----- app/services/artwork/branch/create.service.ts | 113 ++++++++ .../artwork/branch/version/create.service.ts | 136 +++++++++ .../version/clone-designs.service.ts | 12 +- .../version/clone-layers.service.ts | 12 +- .../version/design/create.service.ts | 24 +- .../version/design/delete.service.ts | 16 +- .../version/design/move-down.service.ts | 16 +- .../version/design/move-up.service.ts | 16 +- .../version/design/toggle-visible.service.ts | 16 +- .../version/generator/build.service.ts | 56 ++-- .../version/layer/clone-designs.service.ts | 4 +- .../version/layer/create.service.ts | 16 +- .../version/layer/delete.service.ts | 10 +- .../version/layer/move-down.service.ts | 10 +- .../version/layer/move-up.service.ts | 10 +- .../version/layer/select.service.ts | 20 +- .../version/layer/toggle-visible.service.ts | 10 +- .../artwork/version/update.service.ts | 65 +++++ .../canvas/draw-background.service.ts | 4 +- app/services/canvas/draw.service.ts | 4 +- .../layer/build/build-draw-layers.service.ts | 6 +- .../build/build-layer-draw-count.service.ts | 2 +- .../build/build-layer-draw-fill.service.ts | 2 +- .../build/build-layer-draw-line.service.ts | 2 +- .../build-layer-draw-position.service.ts | 2 +- .../build/build-layer-draw-rotate.service.ts | 2 +- .../build/build-layer-draw-size.service.ts | 2 +- .../build/build-layer-draw-stroke.service.ts | 2 +- .../build-layer-draw-template.service.ts | 2 +- .../draw/draw-layer-item-fill.service.ts | 2 +- .../draw/draw-layer-item-line.service.ts | 2 +- .../draw/draw-layer-item-position.service.ts | 2 +- .../draw/draw-layer-item-rotate.service.ts | 2 +- .../draw/draw-layer-item-stroke.service.ts | 2 +- .../draw/draw-layer-item-template.service.ts | 2 +- .../layer/draw/draw-layer-item.service.ts | 2 +- .../canvas/layer/draw/draw-layers.service.ts | 2 +- ...aw-layer-item-template-triangle.service.ts | 2 +- app/services/design/clone-many.service.ts | 4 +- app/services/layer/clone-many.service.ts | 8 +- app/services/layer/create.service.ts | 2 +- .../dashboard-panel/create-entity.strategy.ts | 8 +- .../dashboard-panel/delete-entity.strategy.ts | 8 +- .../entity-action/entity-action.ts | 24 +- .../update-entity-order.strategy.ts | 8 +- .../update-entity-selected.strategy.ts | 4 +- .../update-entity-visible.strategy.ts | 8 +- app/strategies/design/clone.strategy.ts | 8 +- app/strategies/design/create.strategy.ts | 20 +- .../design/update-selected.strategy.ts | 30 +- app/strategies/layer/clone.strategy.ts | 8 +- app/strategies/layer/create.strategy.ts | 26 +- .../validate-submission.strategy.ts | 42 +-- app/utils/db.server.ts | 8 +- app/utils/design.ts | 14 +- app/utils/dev.utils.ts | 46 +-- app/utils/line.ts | 2 +- app/utils/matches.ts | 32 +-- ...s => prisma-extensions-artwork-version.ts} | 26 +- ...tboard.ts => prisma-extensions-artwork.ts} | 26 +- app/utils/routes.const.ts | 32 +-- app/utils/size.ts | 2 +- app/utils/user.ts | 2 +- .../migration.sql | 269 ++++++++++++++++++ prisma/schema.prisma | 72 ++--- prisma/seed.ts | 14 +- 184 files changed, 2406 insertions(+), 2136 deletions(-) rename app/definitions/{artboard-generator.ts => artwork-generator.ts} (81%) delete mode 100644 app/models/artboard-branch/artboard-branch.create.server.ts delete mode 100644 app/models/artboard-branch/artboard-branch.server.ts delete mode 100644 app/models/artboard-version/artboard-version.delete.server.ts delete mode 100644 app/models/artboard-version/artboard-version.update.server.ts delete mode 100644 app/models/artboard/artboard.server.ts create mode 100644 app/models/artwork-branch/artwork-branch.create.server.ts rename app/models/{artboard-branch/artboard-branch.get.server.ts => artwork-branch/artwork-branch.get.server.ts} (63%) create mode 100644 app/models/artwork-branch/artwork-branch.server.ts rename app/models/{artboard-version/artboard-version.create.server.ts => artwork-version/artwork-version.create.server.ts} (63%) create mode 100644 app/models/artwork-version/artwork-version.delete.server.ts rename app/models/{artboard-version/artboard-version.get.server.ts => artwork-version/artwork-version.get.server.ts} (66%) rename app/models/{artboard-version/artboard-version.server.ts => artwork-version/artwork-version.server.ts} (50%) create mode 100644 app/models/artwork-version/artwork-version.update.server.ts rename app/models/{artboard/artboard.get.server.ts => artwork/artwork.get.server.ts} (53%) create mode 100644 app/models/artwork/artwork.server.ts delete mode 100644 app/models/design-artboard-version/design-artboard-version.create.server.ts delete mode 100644 app/models/design-artboard-version/design-artboard-version.delete.server.ts delete mode 100644 app/models/design-artboard-version/design-artboard-version.update.server.ts create mode 100644 app/models/design-artwork-version/design-artwork-version.create.server.ts create mode 100644 app/models/design-artwork-version/design-artwork-version.delete.server.ts rename app/models/{design-artboard-version/design-artboard-version.get.server.ts => design-artwork-version/design-artwork-version.get.server.ts} (64%) rename app/models/{design-artboard-version/design-artboard-version.server.ts => design-artwork-version/design-artwork-version.server.ts} (63%) create mode 100644 app/models/design-artwork-version/design-artwork-version.update.server.ts delete mode 100644 app/models/layer-artboard-version/layer-artboard-version.update.server.ts create mode 100644 app/models/layer-artwork-version/layer-artwork-version.update.server.ts rename app/routes/resources+/api.v1+/{artboard-branch.create.tsx => artwork-branch.create.tsx} (79%) rename app/routes/resources+/api.v1+/{artboard-version.create.tsx => artwork-version.create.tsx} (88%) rename app/routes/resources+/api.v1+/{artboard-version.design.create.tsx => artwork-version.design.create.tsx} (71%) rename app/routes/resources+/api.v1+/{artboard-version.design.delete.tsx => artwork-version.design.delete.tsx} (71%) rename app/routes/resources+/api.v1+/{artboard-version.design.update.order.tsx => artwork-version.design.update.order.tsx} (71%) rename app/routes/resources+/api.v1+/{artboard-version.design.update.visible.tsx => artwork-version.design.update.visible.tsx} (71%) rename app/routes/resources+/api.v1+/{artboard-version.layer.create.tsx => artwork-version.layer.create.tsx} (70%) rename app/routes/resources+/api.v1+/{artboard-version.layer.delete.tsx => artwork-version.layer.delete.tsx} (74%) rename app/routes/resources+/api.v1+/{artboard-version.layer.update.order.tsx => artwork-version.layer.update.order.tsx} (72%) rename app/routes/resources+/api.v1+/{artboard-version.layer.update.selected.tsx => artwork-version.layer.update.selected.tsx} (73%) rename app/routes/resources+/api.v1+/{artboard-version.layer.update.visible.tsx => artwork-version.layer.update.visible.tsx} (71%) rename app/routes/resources+/api.v1+/{artboard-version.update.background.tsx => artwork-version.update.background.tsx} (80%) rename app/routes/resources+/api.v1+/{artboard-version.update.height.tsx => artwork-version.update.height.tsx} (80%) rename app/routes/resources+/api.v1+/{artboard-version.update.width.tsx => artwork-version.update.width.tsx} (81%) delete mode 100644 app/routes/sketch+/projects+/$projectSlug_+/artboards+/$artboardSlug+/__components/sidebars.panel.artboard-version.frame.tsx delete mode 100644 app/routes/sketch+/projects+/$projectSlug_+/artboards+/$artboardSlug+/__components/sidebars.panel.artboard-version.layers.tsx delete mode 100644 app/routes/sketch+/projects+/$projectSlug_+/artboards+/$artboardSlug+/__components/sidebars.panel.artboard-version.tsx delete mode 100644 app/routes/sketch+/projects+/$projectSlug_+/artboards+/$artboardSlug+/__components/sidebars.panel.designs.artboard-version.tsx rename app/routes/sketch+/projects+/$projectSlug_+/{artboards+/$artboardSlug+ => artworks+/$artworkSlug+}/$branchSlug.$versionSlug.tsx (57%) rename app/routes/sketch+/projects+/$projectSlug_+/{artboards+/$artboardSlug+ => artworks+/$artworkSlug+}/$branchSlug._index.tsx (72%) rename app/routes/sketch+/projects+/$projectSlug_+/{artboards+/$artboardSlug+ => artworks+/$artworkSlug+}/$branchSlug.tsx (56%) rename app/routes/sketch+/projects+/$projectSlug_+/{artboards+/$artboardSlug+ => artworks+/$artworkSlug+}/__components/canvas-content.tsx (77%) rename app/routes/sketch+/projects+/$projectSlug_+/{artboards+/$artboardSlug+/__components/header.artboard.button-group.tsx => artworks+/$artworkSlug+/__components/header.artwork.button-group.tsx} (56%) rename app/routes/sketch+/projects+/$projectSlug_+/{artboards+/$artboardSlug+/__components/header.artboard.comboboxes.tsx => artworks+/$artworkSlug+/__components/header.artwork.comboboxes.tsx} (56%) rename app/routes/sketch+/projects+/$projectSlug_+/{artboards+/$artboardSlug+/__components/header.artboard.tsx => artworks+/$artworkSlug+/__components/header.artwork.tsx} (56%) rename app/routes/sketch+/projects+/$projectSlug_+/{artboards+/$artboardSlug+/__components/sidebars.panel.artboard-version.background.tsx => artworks+/$artworkSlug+/__components/sidebars.panel.artwork-version.background.tsx} (55%) create mode 100644 app/routes/sketch+/projects+/$projectSlug_+/artworks+/$artworkSlug+/__components/sidebars.panel.artwork-version.frame.tsx create mode 100644 app/routes/sketch+/projects+/$projectSlug_+/artworks+/$artworkSlug+/__components/sidebars.panel.artwork-version.layers.tsx create mode 100644 app/routes/sketch+/projects+/$projectSlug_+/artworks+/$artworkSlug+/__components/sidebars.panel.artwork-version.tsx create mode 100644 app/routes/sketch+/projects+/$projectSlug_+/artworks+/$artworkSlug+/__components/sidebars.panel.designs.artwork-version.tsx rename app/routes/sketch+/projects+/$projectSlug_+/{artboards+/$artboardSlug+ => artworks+/$artworkSlug+}/__components/sidebars.panel.designs.layer.tsx (100%) rename app/routes/sketch+/projects+/$projectSlug_+/{artboards+/$artboardSlug+ => artworks+/$artworkSlug+}/__components/sidebars.panel.designs.tsx (100%) rename app/routes/sketch+/projects+/$projectSlug_+/{artboards+/$artboardSlug+ => artworks+/$artworkSlug+}/__components/sidebars.panel.layer.tsx (100%) rename app/routes/sketch+/projects+/$projectSlug_+/{artboards+/$artboardSlug+ => artworks+/$artworkSlug+}/__components/sidebars.tsx (70%) rename app/routes/sketch+/projects+/$projectSlug_+/{artboards+/$artboardSlug+ => artworks+/$artworkSlug+}/_index.tsx (72%) rename app/routes/sketch+/projects+/$projectSlug_+/{artboards+/$artboardSlug+ => artworks+/$artworkSlug+}/route.tsx (66%) rename app/routes/sketch+/projects+/$projectSlug_+/{artboards+ => artworks+}/index.tsx (71%) rename app/routes/sketch+/projects+/$projectSlug_+/{artboards+ => artworks+}/route.tsx (78%) rename app/routes/users+/$username_+/{artboards+/$artboardId => artworks+/$artworkId}/_index/components.tsx (61%) rename app/routes/users+/$username_+/{artboards+/$artboardId/_index/delete-artboard-form.tsx => artworks+/$artworkId/_index/delete-artwork-form.tsx} (90%) rename app/routes/users+/$username_+/{artboards+/$artboardId => artworks+/$artworkId}/_index/queries.ts (67%) rename app/routes/users+/$username_+/{artboards+/$artboardId => artworks+/$artworkId}/_index/route.tsx (62%) rename app/routes/users+/$username_+/{artboards+/$artboardId => artworks+/$artworkId}/edit/edit-form.server.ts (74%) rename app/routes/users+/$username_+/{artboards+/$artboardId => artworks+/$artworkId}/edit/edit-form.tsx (89%) rename app/routes/users+/$username_+/{artboards+/$artboardId => artworks+/$artworkId}/edit/route.tsx (65%) rename app/routes/users+/$username_+/{artboards+/$artboardId => artworks+/$artworkId}/route.tsx (76%) rename app/routes/users+/$username_+/{artboards+ => artworks+}/components.tsx (82%) rename app/routes/users+/$username_+/{artboards+ => artworks+}/route.tsx (90%) rename app/routes/users+/$username_+/projects+/$projectId/_index/{artboards.tsx => artworks.tsx} (79%) rename app/routes/users+/$username_+/projects+/$projectId/{artboards => artworks}/_index/route.tsx (100%) rename app/routes/users+/$username_+/projects+/$projectId/{artboards/new/new-artboard-form.server.ts => artworks/new/new-artwork-form.server.ts} (72%) rename app/routes/users+/$username_+/projects+/$projectId/{artboards/new/new-artboard-form.tsx => artworks/new/new-artwork-form.tsx} (93%) rename app/routes/users+/$username_+/projects+/$projectId/{artboards => artworks}/new/route.tsx (84%) rename app/routes/users+/$username_+/projects+/$projectId/{artboards => artworks}/route.tsx (95%) rename app/schema/{artboard-branch.ts => artwork-branch.ts} (72%) rename app/schema/{artboard-version.ts => artwork-version.ts} (66%) rename app/schema/{artboard.ts => artwork.ts} (76%) rename app/schema/{design-artboard-version.ts => design-artwork-version.ts} (52%) delete mode 100644 app/schema/layer-artboard-version.ts create mode 100644 app/schema/layer-artwork-version.ts delete mode 100644 app/services/artboard/branch/create.service.ts delete mode 100644 app/services/artboard/branch/version/create.service.ts delete mode 100644 app/services/artboard/version/update.service.ts create mode 100644 app/services/artwork/branch/create.service.ts create mode 100644 app/services/artwork/branch/version/create.service.ts rename app/services/{artboard => artwork}/version/clone-designs.service.ts (64%) rename app/services/{artboard => artwork}/version/clone-layers.service.ts (64%) rename app/services/{artboard => artwork}/version/design/create.service.ts (58%) rename app/services/{artboard => artwork}/version/design/delete.service.ts (62%) rename app/services/{artboard => artwork}/version/design/move-down.service.ts (62%) rename app/services/{artboard => artwork}/version/design/move-up.service.ts (62%) rename app/services/{artboard => artwork}/version/design/toggle-visible.service.ts (62%) rename app/services/{artboard => artwork}/version/generator/build.service.ts (83%) rename app/services/{artboard => artwork}/version/layer/clone-designs.service.ts (88%) rename app/services/{artboard => artwork}/version/layer/create.service.ts (62%) rename app/services/{artboard => artwork}/version/layer/delete.service.ts (91%) rename app/services/{artboard => artwork}/version/layer/move-down.service.ts (93%) rename app/services/{artboard => artwork}/version/layer/move-up.service.ts (93%) rename app/services/{artboard => artwork}/version/layer/select.service.ts (68%) rename app/services/{artboard => artwork}/version/layer/toggle-visible.service.ts (78%) create mode 100644 app/services/artwork/version/update.service.ts rename app/utils/{prisma-extensions-artboard-version.ts => prisma-extensions-artwork-version.ts} (55%) rename app/utils/{prisma-extensions-artboard.ts => prisma-extensions-artwork.ts} (59%) create mode 100644 prisma/migrations/20240522073958_rename_artboard_to_artwork/migration.sql diff --git a/README.md b/README.md index 211e509c..239c9474 100644 --- a/README.md +++ b/README.md @@ -20,11 +20,11 @@ To get started with this project, follow these steps: Please keep in mind this is a personal project, not yet intended for a wide audience - login as `adminUser` set from seeds in `prisma/seed.ts` (if you want to change this then run `npm run setup` again) -- from user dropdown in upper right navigate to sketch and select `My First Artboard` (created from seed) +- from user dropdown in upper right navigate to sketch and select `My First Artwork` (created from seed) - add at least one design attribute for each category -- add a layer, which will adopt the artboard design attributes +- add a layer, which will adopt the artwork design attributes - click on the layer name to select it and adjust the designs from there -- move up/down, make visible/invisible, add/remove designs and layers to create different outputs on the artboard +- move up/down, make visible/invisible, add/remove designs and layers to create different outputs on the artwork ## TECH STACK @@ -42,7 +42,7 @@ Please keep in mind this is a personal project, not yet intended for a wide audi ## ROADMAP -- version history to save instances of artboards if I like the designs +- version history to save instances of artworks if I like the designs - connect to shopify products - migrate to [vite](https://remix.run/blog/remix-heart-vite) - import/export image assets to modify pixels into art diff --git a/app/components/templates/card/dashboard-entity-cards.tsx b/app/components/templates/card/dashboard-entity-cards.tsx index 9557066a..3b7766a2 100644 --- a/app/components/templates/card/dashboard-entity-cards.tsx +++ b/app/components/templates/card/dashboard-entity-cards.tsx @@ -6,12 +6,12 @@ import { DashboardCardNone, DashboardCardWrapper, } from '#app/components/layout' -import { type IArtboard } from '#app/models/artboard/artboard.server' -import { type IProjectWithArtboards } from '#app/models/project/project.server' +import { type IArtwork } from '#app/models/artwork/artwork.server' +import { type IProjectWithArtworks } from '#app/models/project/project.server' -type DashboardCardEntitiesType = IProjectWithArtboards[] | IArtboard[] -type DashboardCardEntityType = IProjectWithArtboards | IArtboard -type DashboardCardType = 'Project' | 'Artboard' +type DashboardCardEntitiesType = IProjectWithArtworks[] | IArtwork[] +type DashboardCardEntityType = IProjectWithArtworks | IArtwork +type DashboardCardType = 'Project' | 'Artwork' export const DashboardEntityCards = ({ entities, @@ -150,14 +150,14 @@ const ExistingEntityCardContent = ({ }) => { switch (type) { case 'Project': - const project = item as IProjectWithArtboards - const artboardNames = project.artboards - .map(artboard => artboard.name) + const project = item as IProjectWithArtworks + const artworkNames = project.artworks + .map(artwork => artwork.name) .join(', ') - return artboardNames.length === 0 ? 'No artboards' : artboardNames - case 'Artboard': - const artboard = item as IArtboard - return `Visible: ${artboard.isVisible ? 'Yes' : 'No'}` + return artworkNames.length === 0 ? 'No artworks' : artworkNames + case 'Artwork': + const artwork = item as IArtwork + return `Visible: ${artwork.isVisible ? 'Yes' : 'No'}` default: return 'No details available' } diff --git a/app/components/templates/panel/dashboard-entity-panel.actions.delete.tsx b/app/components/templates/panel/dashboard-entity-panel.actions.delete.tsx index 28330af8..9d28d7b0 100644 --- a/app/components/templates/panel/dashboard-entity-panel.actions.delete.tsx +++ b/app/components/templates/panel/dashboard-entity-panel.actions.delete.tsx @@ -1,5 +1,4 @@ import { memo, useCallback } from 'react' -import { ArtboardVersionDesignDelete } from '#app/routes/resources+/api.v1+/artboard-version.design.delete' import { LayerDesignDelete } from '#app/routes/resources+/api.v1+/layer.design.delete' import { type entityParentTypeEnum, @@ -10,6 +9,7 @@ import { EntityParentType, } from '#app/schema/entity' import { type IDashboardPanelDeleteEntityStrategy } from '#app/strategies/component/dashboard-panel/delete-entity.strategy' +import { ArtworkVersionDesignDelete } from '#app/routes/resources+/api.v1+/artwork-version.design.delete' interface DeleteChildEntityFormProps { entityType: entityTypeEnum @@ -18,12 +18,12 @@ interface DeleteChildEntityFormProps { parent: IEntityParentType } -const ArtboardVersionDeleteChildEntityForm = memo( +const ArtworkVersionDeleteChildEntityForm = memo( ({ entityType, entity, parent }: DeleteChildEntityFormProps) => { switch (entityType) { case EntityType.DESIGN: return ( - @@ -31,13 +31,13 @@ const ArtboardVersionDeleteChildEntityForm = memo( case EntityType.LAYER: return 'av l' default: - console.log('unknown artboard version entity type', entityType) + console.log('unknown artwork version entity type', entityType) return null } }, ) -ArtboardVersionDeleteChildEntityForm.displayName = - 'ArtboardVersionDeleteChildEntityForm' +ArtworkVersionDeleteChildEntityForm.displayName = + 'ArtworkVersionDeleteChildEntityForm' const LayerDeleteChildEntityForm = memo( ({ entityType, entity, parent }: DeleteChildEntityFormProps) => { @@ -55,9 +55,9 @@ LayerDeleteChildEntityForm.displayName = 'LayerDeleteChildEntityForm' const DeleteEntityForm = memo( ({ parentType, entityType, entity, parent }: DeleteChildEntityFormProps) => { switch (parentType) { - case EntityParentType.ARTBOARD_VERSION: + case EntityParentType.ARTWORK_VERSION: return ( - { switch (entityType) { case EntityType.LAYER: return ( - ) default: - console.log('unknown artboard version entity type', entityType) + console.log('unknown artwork version entity type', entityType) return null } }, ) -ArtboardVersionToggleSelectedChildEntityForm.displayName = - 'ArtboardVersionToggleSelectedChildEntityForm' +ArtworkVersionToggleSelectedChildEntityForm.displayName = + 'ArtworkVersionToggleSelectedChildEntityForm' const ToggleSelectedEntityForm = memo( ({ @@ -46,9 +46,9 @@ const ToggleSelectedEntityForm = memo( parent, }: ToggleSelectedChildEntityFormProps) => { switch (parentType) { - case EntityParentType.ARTBOARD_VERSION: + case EntityParentType.ARTWORK_VERSION: return ( - { switch (entityType) { case EntityType.DESIGN: return ( - ) case EntityType.LAYER: return ( - ) default: - console.log('unknown artboard version entity type', entityType) + console.log('unknown artwork version entity type', entityType) return null } }, ) -ArtboardVersionToggleVisibleChildEntityForm.displayName = - 'ArtboardVersionToggleVisibleChildEntityForm' +ArtworkVersionToggleVisibleChildEntityForm.displayName = + 'ArtworkVersionToggleVisibleChildEntityForm' const LayerToggleVisibleChildEntityForm = memo( ({ entityType, entity, parent }: ToggleVisibleChildEntityFormProps) => { @@ -75,9 +75,9 @@ const ToggleVisibleEntityForm = memo( parent, }: ToggleVisibleChildEntityFormProps) => { switch (parentType) { - case EntityParentType.ARTBOARD_VERSION: + case EntityParentType.ARTWORK_VERSION: return ( - { switch (entityType) { case EntityType.DESIGN: return ( - ) case EntityType.LAYER: - return + return default: - console.log('unknown artboard version entity type', entityType) + console.log('unknown artwork version entity type', entityType) return null } }, ) -ArtboardVersionCreateChildEntityForm.displayName = - 'ArtboardVersionCreateChildEntityForm' +ArtworkVersionCreateChildEntityForm.displayName = + 'ArtworkVersionCreateChildEntityForm' const LayerCreateChildEntityForm = memo( ({ entityType, type, parent }: CreateChildEntityFormProps) => { @@ -70,9 +70,9 @@ LayerCreateChildEntityForm.displayName = 'LayerCreateChildEntityForm' const CreateEntityForm = memo( ({ parentType, entityType, type, parent }: CreateChildEntityFormProps) => { switch (parentType) { - case EntityParentType.ARTBOARD_VERSION: + case EntityParentType.ARTWORK_VERSION: return ( - - - @@ -54,28 +54,28 @@ const ArtboardVersionReorderChildEntityForm = memo( case EntityType.LAYER: return ( <> - - ) default: - console.log('unknown artboard version entity type', entityType) + console.log('unknown artwork version entity type', entityType) return null } }, ) -ArtboardVersionReorderChildEntityForm.displayName = - 'ArtboardVersionReorderChildEntityForm' +ArtworkVersionReorderChildEntityForm.displayName = + 'ArtworkVersionReorderChildEntityForm' const LayerReorderChildEntityForm = memo( ({ @@ -121,9 +121,9 @@ const ReorderEntityForm = memo( atBottom, }: ReorderChildEntityFormProps) => { switch (parentType) { - case EntityParentType.ARTBOARD_VERSION: + case EntityParentType.ARTWORK_VERSION: return ( - { Delete - diff --git a/app/definitions/artboard-generator.ts b/app/definitions/artwork-generator.ts similarity index 81% rename from app/definitions/artboard-generator.ts rename to app/definitions/artwork-generator.ts index f59774a4..e657db72 100644 --- a/app/definitions/artboard-generator.ts +++ b/app/definitions/artwork-generator.ts @@ -1,5 +1,5 @@ -import { type IArtboard } from '#app/models/artboard/artboard.server' -import { type IArtboardVersion } from '#app/models/artboard-version/artboard-version.server' +import { type IArtwork } from '#app/models/artwork/artwork.server' +import { type IArtworkVersion } from '#app/models/artwork-version/artwork-version.server' import { type IFill } from '#app/models/design-type/fill/fill.server' import { type ILayout } from '#app/models/design-type/layout/layout.server' import { type ILine } from '#app/models/design-type/line/line.server' @@ -12,14 +12,14 @@ import { type ILayer } from '#app/models/layer/layer.server' // object sent to the client // generator has final building blocks for the generation(s) -export interface IArtboardGenerator { - id: IArtboard['id'] +export interface IArtworkGenerator { + id: IArtwork['id'] layers: ILayerGenerator[] success: boolean message: string } -export interface IArtboardVersionGenerator { - id: IArtboardVersion['id'] +export interface IArtworkVersionGenerator { + id: IArtworkVersion['id'] settings: { width: number height: number @@ -30,7 +30,7 @@ export interface IArtboardVersionGenerator { message: string } -// layer can override or default to artboard version design types +// layer can override or default to artwork version design types export interface IGeneratorDesigns { palette: IPalette[] size: ISize @@ -53,7 +53,7 @@ export interface ILayerGenerator extends IGeneratorDesigns { } // TODO: make container a design type -// right now all layers are the same size as artboard/canvas +// right now all layers are the same size as artwork/canvas export interface ILayerGeneratorContainer { width: number height: number diff --git a/app/models/artboard-branch/artboard-branch.create.server.ts b/app/models/artboard-branch/artboard-branch.create.server.ts deleted file mode 100644 index 9bde9968..00000000 --- a/app/models/artboard-branch/artboard-branch.create.server.ts +++ /dev/null @@ -1,86 +0,0 @@ -import { type IntentActionArgs } from '#app/definitions/intent-action-args' -import { NewArtboardBranchSchema } from '#app/schema/artboard-branch' -import { ValidateArtboardParentSubmissionStrategy } from '#app/strategies/validate-submission.strategy' -import { validateEntitySubmission } from '#app/utils/conform-utils' -import { prisma } from '#app/utils/db.server' -import { type IArtboard } from '../artboard/artboard.server' -import { type IUser } from '../user/user.server' -import { - type IArtboardBranch, - type IArtboardBranchWithVersions, -} from './artboard-branch.server' - -export interface IArtboardBranchCreatedResponse { - success: boolean - message?: string - createdArtboardBranch?: IArtboardBranch -} - -export const validateNewArtboardBranchSubmission = async ({ - userId, - formData, -}: IntentActionArgs) => { - const strategy = new ValidateArtboardParentSubmissionStrategy() - - return await validateEntitySubmission({ - userId, - formData, - schema: NewArtboardBranchSchema, - strategy, - }) -} - -export const createArtboardBranch = async ({ - data, -}: { - data: { - ownerId: IUser['id'] - artboardId: IArtboard['id'] - parentId?: IArtboardBranch['id'] - name: string - slug: string - description: string | null | undefined - } -}) => { - const artboardBranch = await prisma.artboardBranch.create({ - data, - }) - return artboardBranch -} - -export const createDefaultArtboardBranchWithVersion = async ({ - artboard, -}: { - artboard: Pick -}): Promise => { - const { ownerId } = artboard - - const artboardBranch = await prisma.artboardBranch.create({ - data: { - artboard: { - connect: { - id: artboard.id, - }, - }, - owner: { - connect: { - id: ownerId, - }, - }, - default: true, - versions: { - create: { - owner: { - connect: { - id: ownerId, - }, - }, - }, - }, - }, - include: { - versions: true, - }, - }) - return artboardBranch -} diff --git a/app/models/artboard-branch/artboard-branch.server.ts b/app/models/artboard-branch/artboard-branch.server.ts deleted file mode 100644 index be719094..00000000 --- a/app/models/artboard-branch/artboard-branch.server.ts +++ /dev/null @@ -1,16 +0,0 @@ -import { type ArtboardBranch } from '@prisma/client' -import { type DateOrString } from '#app/definitions/prisma-helper' -import { type IArtboardVersion } from '../artboard-version/artboard-version.server' - -// Omitting 'createdAt' and 'updatedAt' from the ArtboardBranch interface -// prisma query returns a string for these fields -type BaseArtboardBranch = Omit - -export interface IArtboardBranch extends BaseArtboardBranch { - createdAt: DateOrString - updatedAt: DateOrString -} - -export interface IArtboardBranchWithVersions extends IArtboardBranch { - versions: IArtboardVersion[] -} diff --git a/app/models/artboard-version/artboard-version.delete.server.ts b/app/models/artboard-version/artboard-version.delete.server.ts deleted file mode 100644 index 6a40428e..00000000 --- a/app/models/artboard-version/artboard-version.delete.server.ts +++ /dev/null @@ -1,21 +0,0 @@ -import { prisma } from '#app/utils/db.server' -import { type IArtboardVersion } from './artboard-version.server' - -export interface IArtboardVersionDeletedResponse { - success: boolean - message?: string -} - -export const deleteArtboardVersions = ({ - ids, -}: { - ids: IArtboardVersion['id'][] -}) => { - return prisma.artboardVersion.deleteMany({ - where: { - id: { - in: ids, - }, - }, - }) -} diff --git a/app/models/artboard-version/artboard-version.update.server.ts b/app/models/artboard-version/artboard-version.update.server.ts deleted file mode 100644 index 15f7f35c..00000000 --- a/app/models/artboard-version/artboard-version.update.server.ts +++ /dev/null @@ -1,159 +0,0 @@ -import { type IntentActionArgs } from '#app/definitions/intent-action-args' -import { - ArtboardVersionWidthSchema, - type ArtboardVersionUpdateSchemaType, - ArtboardVersionHeightSchema, - ArtboardVersionBackgroundSchema, -} from '#app/schema/artboard-version' -import { ValidateArtboardVersionSubmissionStrategy } from '#app/strategies/validate-submission.strategy' -import { validateEntitySubmission } from '#app/utils/conform-utils' -import { prisma } from '#app/utils/db.server' -import { findFirstArtboardVersionInstance } from '#app/utils/prisma-extensions-artboard-version' -import { type IArtboardVersion } from './artboard-version.server' - -const validateUpdateSubmission = async ({ - userId, - formData, - schema, -}: IntentActionArgs & { - schema: ArtboardVersionUpdateSchemaType -}) => { - const strategy = new ValidateArtboardVersionSubmissionStrategy() - - return await validateEntitySubmission({ - userId, - formData, - schema, - strategy, - }) -} - -export async function validateArtboardVersionWidthSubmission( - args: IntentActionArgs, -) { - return validateUpdateSubmission({ - ...args, - schema: ArtboardVersionWidthSchema, - }) -} - -export async function validateArtboardVersionHeightSubmission( - args: IntentActionArgs, -) { - return validateUpdateSubmission({ - ...args, - schema: ArtboardVersionHeightSchema, - }) -} - -export async function validateArtboardVersionBackgroundSubmission( - args: IntentActionArgs, -) { - return validateUpdateSubmission({ - ...args, - schema: ArtboardVersionBackgroundSchema, - }) -} - -const getArtboardVersionInstance = async ({ - id, -}: { - id: IArtboardVersion['id'] -}) => { - return await findFirstArtboardVersionInstance({ - where: { id }, - }) -} - -// updating instance instead of regular prism update -// this may not be easier, but it's more explicit -export const updateArtboardVersionWidth = async ({ - id, - width, -}: { - id: IArtboardVersion['id'] - width: number -}) => { - const artboardVersion = await getArtboardVersionInstance({ id }) - if (!artboardVersion) return { success: false } - - try { - const data = ArtboardVersionWidthSchema.parse({ id, width }) - artboardVersion.width = data.width - artboardVersion.updatedAt = new Date() - await artboardVersion.save() - - return { success: true } - } catch (error) { - // consider how to handle this error where this is called - console.error(error) - return { success: false } - } -} - -export const updateArtboardVersionHeight = async ({ - id, - height, -}: { - id: IArtboardVersion['id'] - height: number -}) => { - const artboardVersion = await getArtboardVersionInstance({ id }) - if (!artboardVersion) return { success: false } - - try { - const data = ArtboardVersionHeightSchema.parse({ id, height }) - artboardVersion.height = data.height - artboardVersion.updatedAt = new Date() - await artboardVersion.save() - - return { success: true } - } catch (error) { - // consider how to handle this error where this is called - console.error(error) - return { success: false } - } -} - -export const updateArtboardVersionBackground = async ({ - id, - background, -}: { - id: IArtboardVersion['id'] - background: string -}) => { - const artboardVersion = await getArtboardVersionInstance({ id }) - if (!artboardVersion) return { success: false } - - try { - console.log('background', background) - const data = ArtboardVersionBackgroundSchema.parse({ id, background }) - artboardVersion.background = data.background - artboardVersion.updatedAt = new Date() - await artboardVersion.save() - - return { success: true } - } catch (error) { - // consider how to handle this error where this is called - console.error(error) - return { success: false } - } -} - -export const connectPrevAndNext = ({ - prevId, - nextId, -}: { - prevId: IArtboardVersion['id'] - nextId: IArtboardVersion['id'] -}) => { - const connectNextToPrev = prisma.artboardVersion.update({ - where: { id: prevId }, - data: { nextId }, - }) - const connectPrevToNext = prisma.artboardVersion.update({ - where: { id: nextId }, - data: { prevId }, - }) - return [connectNextToPrev, connectPrevToNext] -} diff --git a/app/models/artboard/artboard.server.ts b/app/models/artboard/artboard.server.ts deleted file mode 100644 index c09b8eda..00000000 --- a/app/models/artboard/artboard.server.ts +++ /dev/null @@ -1,20 +0,0 @@ -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 IProjectWithArtboards } from '../project/project.server' - -// Omitting 'createdAt' and 'updatedAt' from the Artboard interface -// prisma query returns a string for these fields -type BaseArtboard = Omit - -export interface IArtboard extends BaseArtboard { - createdAt: DateOrString - updatedAt: DateOrString -} -export interface IArtboardWithProject extends IArtboard { - project: IProjectWithArtboards -} - -export interface IArtboardWithBranchesAndVersions extends IArtboard { - branches: IArtboardBranchWithVersions[] -} diff --git a/app/models/artwork-branch/artwork-branch.create.server.ts b/app/models/artwork-branch/artwork-branch.create.server.ts new file mode 100644 index 00000000..a719f611 --- /dev/null +++ b/app/models/artwork-branch/artwork-branch.create.server.ts @@ -0,0 +1,86 @@ +import { type IntentActionArgs } from '#app/definitions/intent-action-args' +import { ValidateArtworkParentSubmissionStrategy } from '#app/strategies/validate-submission.strategy' +import { validateEntitySubmission } from '#app/utils/conform-utils' +import { prisma } from '#app/utils/db.server' +import { type IArtwork } from '../artwork/artwork.server' +import { type IUser } from '../user/user.server' +import { + type IArtworkBranch, + type IArtworkBranchWithVersions, +} from './artwork-branch.server' +import { NewArtworkBranchSchema } from '#app/schema/artwork-branch' + +export interface IArtworkBranchCreatedResponse { + success: boolean + message?: string + createdArtworkBranch?: IArtworkBranch +} + +export const validateNewArtworkBranchSubmission = async ({ + userId, + formData, +}: IntentActionArgs) => { + const strategy = new ValidateArtworkParentSubmissionStrategy() + + return await validateEntitySubmission({ + userId, + formData, + schema: NewArtworkBranchSchema, + strategy, + }) +} + +export const createArtworkBranch = async ({ + data, +}: { + data: { + ownerId: IUser['id'] + artworkId: IArtwork['id'] + parentId?: IArtworkBranch['id'] + name: string + slug: string + description: string | null | undefined + } +}) => { + const artworkBranch = await prisma.artworkBranch.create({ + data, + }) + return artworkBranch +} + +export const createDefaultArtworkBranchWithVersion = async ({ + artwork, +}: { + artwork: Pick +}): Promise => { + const { ownerId } = artwork + + const artworkBranch = await prisma.artworkBranch.create({ + data: { + artwork: { + connect: { + id: artwork.id, + }, + }, + owner: { + connect: { + id: ownerId, + }, + }, + default: true, + versions: { + create: { + owner: { + connect: { + id: ownerId, + }, + }, + }, + }, + }, + include: { + versions: true, + }, + }) + return artworkBranch +} diff --git a/app/models/artboard-branch/artboard-branch.get.server.ts b/app/models/artwork-branch/artwork-branch.get.server.ts similarity index 63% rename from app/models/artboard-branch/artboard-branch.get.server.ts rename to app/models/artwork-branch/artwork-branch.get.server.ts index 6175d548..b1ae1b8c 100644 --- a/app/models/artboard-branch/artboard-branch.get.server.ts +++ b/app/models/artwork-branch/artwork-branch.get.server.ts @@ -1,23 +1,23 @@ import { z } from 'zod' import { prisma } from '#app/utils/db.server' import { - type IArtboardBranch, - type IArtboardBranchWithVersions, -} from './artboard-branch.server' + type IArtworkBranch, + type IArtworkBranchWithVersions, +} from './artwork-branch.server' -export type queryArtboardBranchWhereArgsType = z.infer +export type queryArtworkBranchWhereArgsType = z.infer const whereArgs = z.object({ id: z.string().optional(), ownerId: z.string().optional(), slug: z.string().optional(), - artboardId: z.string().optional(), + artworkId: z.string().optional(), }) // 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) const validateQueryWhereArgsPresent = ( - where: queryArtboardBranchWhereArgsType, + where: queryArtworkBranchWhereArgsType, ) => { const nullValuesAllowed: string[] = ['nextId', 'prevId'] const missingValues: Record = {} @@ -32,28 +32,28 @@ const validateQueryWhereArgsPresent = ( if (Object.keys(missingValues).length > 0) { console.log('Missing values:', missingValues) throw new Error( - 'Null or undefined values are not allowed in query parameters for artboard branch.', + 'Null or undefined values are not allowed in query parameters for artwork branch.', ) } } -export const getArtboardBranch = async ({ +export const getArtworkBranch = async ({ where, }: { - where: queryArtboardBranchWhereArgsType -}): Promise => { + where: queryArtworkBranchWhereArgsType +}): Promise => { validateQueryWhereArgsPresent(where) - const branch = await prisma.artboardBranch.findFirst({ where }) + const branch = await prisma.artworkBranch.findFirst({ where }) return branch } -export const getArtboardBranchWithVersions = async ({ +export const getArtworkBranchWithVersions = async ({ where, }: { - where: queryArtboardBranchWhereArgsType -}): Promise => { + where: queryArtworkBranchWhereArgsType +}): Promise => { validateQueryWhereArgsPresent(where) - const artboardBranch = await prisma.artboardBranch.findFirst({ + const artworkBranch = await prisma.artworkBranch.findFirst({ where, include: { versions: { @@ -63,5 +63,5 @@ export const getArtboardBranchWithVersions = async ({ }, }, }) - return artboardBranch + return artworkBranch } diff --git a/app/models/artwork-branch/artwork-branch.server.ts b/app/models/artwork-branch/artwork-branch.server.ts new file mode 100644 index 00000000..979626b5 --- /dev/null +++ b/app/models/artwork-branch/artwork-branch.server.ts @@ -0,0 +1,16 @@ +import { type ArtworkBranch } from '@prisma/client' +import { type DateOrString } from '#app/definitions/prisma-helper' +import { type IArtworkVersion } from '../artwork-version/artwork-version.server' + +// Omitting 'createdAt' and 'updatedAt' from the ArtworkBranch interface +// prisma query returns a string for these fields +type BaseArtworkBranch = Omit + +export interface IArtworkBranch extends BaseArtworkBranch { + createdAt: DateOrString + updatedAt: DateOrString +} + +export interface IArtworkBranchWithVersions extends IArtworkBranch { + versions: IArtworkVersion[] +} diff --git a/app/models/artboard-version/artboard-version.create.server.ts b/app/models/artwork-version/artwork-version.create.server.ts similarity index 63% rename from app/models/artboard-version/artboard-version.create.server.ts rename to app/models/artwork-version/artwork-version.create.server.ts index f6f48c20..384298bf 100644 --- a/app/models/artboard-version/artboard-version.create.server.ts +++ b/app/models/artwork-version/artwork-version.create.server.ts @@ -1,38 +1,38 @@ import { type IntentActionArgs } from '#app/definitions/intent-action-args' -import { NewArtboardVersionSchema } from '#app/schema/artboard-version' -import { ValidateArtboardBranchParentSubmissionStrategy } from '#app/strategies/validate-submission.strategy' +import { ValidateArtworkBranchParentSubmissionStrategy } from '#app/strategies/validate-submission.strategy' import { validateEntitySubmission } from '#app/utils/conform-utils' import { prisma } from '#app/utils/db.server' -import { type IArtboardBranch } from '../artboard-branch/artboard-branch.server' +import { type IArtworkBranch } from '../artwork-branch/artwork-branch.server' import { type IUser } from '../user/user.server' -import { type IArtboardVersion } from './artboard-version.server' +import { type IArtworkVersion } from './artwork-version.server' +import { NewArtworkVersionSchema } from '#app/schema/artwork-version' -export interface IArtboardVersionCreatedResponse { +export interface IArtworkVersionCreatedResponse { success: boolean message?: string - createdArtboardVersion?: IArtboardVersion + createdArtworkVersion?: IArtworkVersion } -export const validateNewArtboardVersionSubmission = async ({ +export const validateNewArtworkVersionSubmission = async ({ userId, formData, }: IntentActionArgs) => { - const strategy = new ValidateArtboardBranchParentSubmissionStrategy() + const strategy = new ValidateArtworkBranchParentSubmissionStrategy() return await validateEntitySubmission({ userId, formData, - schema: NewArtboardVersionSchema, + schema: NewArtworkVersionSchema, strategy, }) } -export const createArtboardVersion = async ({ +export const createArtworkVersion = async ({ data, }: { data: { ownerId: IUser['id'] - branchId: IArtboardBranch['id'] + branchId: IArtworkBranch['id'] name?: string slug?: string description?: string @@ -41,7 +41,7 @@ export const createArtboardVersion = async ({ background?: string } }) => { - return await prisma.artboardVersion.create({ + return await prisma.artworkVersion.create({ data, }) } diff --git a/app/models/artwork-version/artwork-version.delete.server.ts b/app/models/artwork-version/artwork-version.delete.server.ts new file mode 100644 index 00000000..3519d0ce --- /dev/null +++ b/app/models/artwork-version/artwork-version.delete.server.ts @@ -0,0 +1,21 @@ +import { prisma } from '#app/utils/db.server' +import { type IArtworkVersion } from './artwork-version.server' + +export interface IArtworkVersionDeletedResponse { + success: boolean + message?: string +} + +export const deleteArtworkVersions = ({ + ids, +}: { + ids: IArtworkVersion['id'][] +}) => { + return prisma.artworkVersion.deleteMany({ + where: { + id: { + in: ids, + }, + }, + }) +} diff --git a/app/models/artboard-version/artboard-version.get.server.ts b/app/models/artwork-version/artwork-version.get.server.ts similarity index 66% rename from app/models/artboard-version/artboard-version.get.server.ts rename to app/models/artwork-version/artwork-version.get.server.ts index 3f8a5545..434ccb87 100644 --- a/app/models/artboard-version/artboard-version.get.server.ts +++ b/app/models/artwork-version/artwork-version.get.server.ts @@ -2,11 +2,11 @@ import { z } from 'zod' import { zodStringOrNull } from '#app/schema/zod-helpers' import { prisma } from '#app/utils/db.server' import { - type IArtboardVersionWithDesignsAndLayers, - type IArtboardVersion, -} from './artboard-version.server' + type IArtworkVersionWithDesignsAndLayers, + type IArtworkVersion, +} from './artwork-version.server' -export type queryArtboardVersionWhereArgsType = z.infer +export type queryArtworkVersionWhereArgsType = z.infer const whereArgs = z.object({ id: z.string().optional(), ownerId: z.string().optional(), @@ -45,7 +45,7 @@ const includeDesignsAndLayers = { // 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) const validateQueryWhereArgsPresent = ( - where: queryArtboardVersionWhereArgsType, + where: queryArtworkVersionWhereArgsType, ) => { const nullValuesAllowed: string[] = ['nextId', 'prevId'] const missingValues: Record = {} @@ -60,43 +60,43 @@ const validateQueryWhereArgsPresent = ( if (Object.keys(missingValues).length > 0) { console.log('Missing values:', missingValues) throw new Error( - 'Null or undefined values are not allowed in query parameters for artboard version.', + 'Null or undefined values are not allowed in query parameters for artwork version.', ) } } -export const getArtboardVersions = async ({ +export const getArtworkVersions = async ({ where, }: { - where: queryArtboardVersionWhereArgsType -}): Promise => { + where: queryArtworkVersionWhereArgsType +}): Promise => { validateQueryWhereArgsPresent(where) - return await prisma.artboardVersion.findMany({ + return await prisma.artworkVersion.findMany({ where, }) } -export const getArtboardVersion = async ({ +export const getArtworkVersion = async ({ where, }: { - where: queryArtboardVersionWhereArgsType -}): Promise => { + where: queryArtworkVersionWhereArgsType +}): Promise => { validateQueryWhereArgsPresent(where) - const artboardVersion = await prisma.artboardVersion.findFirst({ + const artworkVersion = await prisma.artworkVersion.findFirst({ where, }) - return artboardVersion + return artworkVersion } -export const getArtboardVersionWithDesignsAndLayers = async ({ +export const getArtworkVersionWithDesignsAndLayers = async ({ where, }: { - where: queryArtboardVersionWhereArgsType -}): Promise => { + where: queryArtworkVersionWhereArgsType +}): Promise => { validateQueryWhereArgsPresent(where) - const artboardVersion = await prisma.artboardVersion.findFirst({ + const artworkVersion = await prisma.artworkVersion.findFirst({ where, include: includeDesignsAndLayers, }) - return artboardVersion + return artworkVersion } diff --git a/app/models/artboard-version/artboard-version.server.ts b/app/models/artwork-version/artwork-version.server.ts similarity index 50% rename from app/models/artboard-version/artboard-version.server.ts rename to app/models/artwork-version/artwork-version.server.ts index 922e4aad..9eb2b113 100644 --- a/app/models/artboard-version/artboard-version.server.ts +++ b/app/models/artwork-version/artwork-version.server.ts @@ -1,18 +1,18 @@ -import { type ArtboardVersion } from '@prisma/client' +import { type ArtworkVersion } from '@prisma/client' import { type DateOrString } from '#app/definitions/prisma-helper' import { type IDesignWithType } from '../design/design.server' import { type ILayerWithDesigns } from '../layer/layer.server' -// Omitting 'createdAt' and 'updatedAt' from the ArtboardVersion interface +// Omitting 'createdAt' and 'updatedAt' from the ArtworkVersion interface // prisma query returns a string for these fields -type BaseArtboardVersion = Omit +type BaseArtworkVersion = Omit -export interface IArtboardVersion extends BaseArtboardVersion { +export interface IArtworkVersion extends BaseArtworkVersion { createdAt: DateOrString updatedAt: DateOrString } -export interface IArtboardVersionWithDesignsAndLayers extends IArtboardVersion { +export interface IArtworkVersionWithDesignsAndLayers extends IArtworkVersion { designs: IDesignWithType[] layers: ILayerWithDesigns[] } diff --git a/app/models/artwork-version/artwork-version.update.server.ts b/app/models/artwork-version/artwork-version.update.server.ts new file mode 100644 index 00000000..e02c03db --- /dev/null +++ b/app/models/artwork-version/artwork-version.update.server.ts @@ -0,0 +1,159 @@ +import { type IntentActionArgs } from '#app/definitions/intent-action-args' +import { ValidateArtworkVersionSubmissionStrategy } from '#app/strategies/validate-submission.strategy' +import { validateEntitySubmission } from '#app/utils/conform-utils' +import { prisma } from '#app/utils/db.server' +import { type IArtworkVersion } from './artwork-version.server' +import { + ArtworkVersionWidthSchema, + type ArtworkVersionUpdateSchemaType, + ArtworkVersionHeightSchema, + ArtworkVersionBackgroundSchema, +} from '#app/schema/artwork-version' +import { findFirstArtworkVersionInstance } from '#app/utils/prisma-extensions-artwork-version' + +const validateUpdateSubmission = async ({ + userId, + formData, + schema, +}: IntentActionArgs & { + schema: ArtworkVersionUpdateSchemaType +}) => { + const strategy = new ValidateArtworkVersionSubmissionStrategy() + + return await validateEntitySubmission({ + userId, + formData, + schema, + strategy, + }) +} + +export async function validateArtworkVersionWidthSubmission( + args: IntentActionArgs, +) { + return validateUpdateSubmission({ + ...args, + schema: ArtworkVersionWidthSchema, + }) +} + +export async function validateArtworkVersionHeightSubmission( + args: IntentActionArgs, +) { + return validateUpdateSubmission({ + ...args, + schema: ArtworkVersionHeightSchema, + }) +} + +export async function validateArtworkVersionBackgroundSubmission( + args: IntentActionArgs, +) { + return validateUpdateSubmission({ + ...args, + schema: ArtworkVersionBackgroundSchema, + }) +} + +const getArtworkVersionInstance = async ({ + id, +}: { + id: IArtworkVersion['id'] +}) => { + return await findFirstArtworkVersionInstance({ + where: { id }, + }) +} + +// updating instance instead of regular prism update +// this may not be easier, but it's more explicit +export const updateArtworkVersionWidth = async ({ + id, + width, +}: { + id: IArtworkVersion['id'] + width: number +}) => { + const artworkVersion = await getArtworkVersionInstance({ id }) + if (!artworkVersion) return { success: false } + + try { + const data = ArtworkVersionWidthSchema.parse({ id, width }) + artworkVersion.width = data.width + artworkVersion.updatedAt = new Date() + await artworkVersion.save() + + return { success: true } + } catch (error) { + // consider how to handle this error where this is called + console.error(error) + return { success: false } + } +} + +export const updateArtworkVersionHeight = async ({ + id, + height, +}: { + id: IArtworkVersion['id'] + height: number +}) => { + const artworkVersion = await getArtworkVersionInstance({ id }) + if (!artworkVersion) return { success: false } + + try { + const data = ArtworkVersionHeightSchema.parse({ id, height }) + artworkVersion.height = data.height + artworkVersion.updatedAt = new Date() + await artworkVersion.save() + + return { success: true } + } catch (error) { + // consider how to handle this error where this is called + console.error(error) + return { success: false } + } +} + +export const updateArtworkVersionBackground = async ({ + id, + background, +}: { + id: IArtworkVersion['id'] + background: string +}) => { + const artworkVersion = await getArtworkVersionInstance({ id }) + if (!artworkVersion) return { success: false } + + try { + console.log('background', background) + const data = ArtworkVersionBackgroundSchema.parse({ id, background }) + artworkVersion.background = data.background + artworkVersion.updatedAt = new Date() + await artworkVersion.save() + + return { success: true } + } catch (error) { + // consider how to handle this error where this is called + console.error(error) + return { success: false } + } +} + +export const connectPrevAndNext = ({ + prevId, + nextId, +}: { + prevId: IArtworkVersion['id'] + nextId: IArtworkVersion['id'] +}) => { + const connectNextToPrev = prisma.artworkVersion.update({ + where: { id: prevId }, + data: { nextId }, + }) + const connectPrevToNext = prisma.artworkVersion.update({ + where: { id: nextId }, + data: { prevId }, + }) + return [connectNextToPrev, connectPrevToNext] +} diff --git a/app/models/artboard/artboard.get.server.ts b/app/models/artwork/artwork.get.server.ts similarity index 53% rename from app/models/artboard/artboard.get.server.ts rename to app/models/artwork/artwork.get.server.ts index e7654d8b..73cd087a 100644 --- a/app/models/artboard/artboard.get.server.ts +++ b/app/models/artwork/artwork.get.server.ts @@ -1,11 +1,11 @@ import { z } from 'zod' import { prisma } from '#app/utils/db.server' import { - type IArtboard, - type IArtboardWithBranchesAndVersions, -} from '../artboard/artboard.server' + type IArtwork, + type IArtworkWithBranchesAndVersions, +} from '../artwork/artwork.server' -export type queryArtboardWhereArgsType = z.infer +export type queryArtworkWhereArgsType = z.infer const whereArgs = z.object({ id: z.string().optional(), ownerId: z.string().optional(), @@ -15,33 +15,33 @@ const whereArgs = z.object({ // 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) -const validateQueryWhereArgsPresent = (where: queryArtboardWhereArgsType) => { +const validateQueryWhereArgsPresent = (where: queryArtworkWhereArgsType) => { if (Object.values(where).some(value => !value)) { throw new Error( - 'Null or undefined values are not allowed in query parameters for artboard.', + 'Null or undefined values are not allowed in query parameters for artwork.', ) } } -export const getArtboard = async ({ +export const getArtwork = async ({ where, }: { - where: queryArtboardWhereArgsType -}): Promise => { + where: queryArtworkWhereArgsType +}): Promise => { validateQueryWhereArgsPresent(where) - const artboard = await prisma.artboard.findFirst({ + const artwork = await prisma.artwork.findFirst({ where, }) - return artboard + return artwork } -export const getArtboardWithBranchesAndVersions = async ({ +export const getArtworkWithBranchesAndVersions = async ({ where, }: { - where: queryArtboardWhereArgsType -}): Promise => { + where: queryArtworkWhereArgsType +}): Promise => { validateQueryWhereArgsPresent(where) - const artboard = await prisma.artboard.findFirst({ + const artwork = await prisma.artwork.findFirst({ where, include: { branches: { @@ -51,5 +51,5 @@ export const getArtboardWithBranchesAndVersions = async ({ }, }, }) - return artboard + return artwork } diff --git a/app/models/artwork/artwork.server.ts b/app/models/artwork/artwork.server.ts new file mode 100644 index 00000000..f77208db --- /dev/null +++ b/app/models/artwork/artwork.server.ts @@ -0,0 +1,20 @@ +import { type Artwork } from '@prisma/client' +import { type DateOrString } from '#app/definitions/prisma-helper' +import { type IArtworkBranchWithVersions } from '../artwork-branch/artwork-branch.server' +import { type IProjectWithArtworks } from '../project/project.server' + +// Omitting 'createdAt' and 'updatedAt' from the Artwork interface +// prisma query returns a string for these fields +type BaseArtwork = Omit + +export interface IArtwork extends BaseArtwork { + createdAt: DateOrString + updatedAt: DateOrString +} +export interface IArtworkWithProject extends IArtwork { + project: IProjectWithArtworks +} + +export interface IArtworkWithBranchesAndVersions extends IArtwork { + branches: IArtworkBranchWithVersions[] +} diff --git a/app/models/design-artboard-version/design-artboard-version.create.server.ts b/app/models/design-artboard-version/design-artboard-version.create.server.ts deleted file mode 100644 index 98e05fb1..00000000 --- a/app/models/design-artboard-version/design-artboard-version.create.server.ts +++ /dev/null @@ -1,18 +0,0 @@ -import { type IntentActionArgs } from '#app/definitions/intent-action-args' -import { NewArtboardVersionDesignSchema } from '#app/schema/design-artboard-version' -import { ValidateArtboardVersionParentSubmissionStrategy } from '#app/strategies/validate-submission.strategy' -import { validateEntitySubmission } from '#app/utils/conform-utils' - -export const validateArtboardVersionNewDesignSubmission = async ({ - userId, - formData, -}: IntentActionArgs) => { - const strategy = new ValidateArtboardVersionParentSubmissionStrategy() - - return await validateEntitySubmission({ - userId, - formData, - schema: NewArtboardVersionDesignSchema, - strategy, - }) -} diff --git a/app/models/design-artboard-version/design-artboard-version.delete.server.ts b/app/models/design-artboard-version/design-artboard-version.delete.server.ts deleted file mode 100644 index 16a7c3b9..00000000 --- a/app/models/design-artboard-version/design-artboard-version.delete.server.ts +++ /dev/null @@ -1,18 +0,0 @@ -import { type IntentActionArgs } from '#app/definitions/intent-action-args' -import { DeleteArtboardVersionDesignSchema } from '#app/schema/design-artboard-version' -import { ValidateArtboardVersionParentSubmissionStrategy } from '#app/strategies/validate-submission.strategy' -import { validateEntitySubmission } from '#app/utils/conform-utils' - -export const validateArtboardVersionDeleteDesignSubmission = async ({ - userId, - formData, -}: IntentActionArgs) => { - const strategy = new ValidateArtboardVersionParentSubmissionStrategy() - - return await validateEntitySubmission({ - userId, - formData, - schema: DeleteArtboardVersionDesignSchema, - strategy, - }) -} diff --git a/app/models/design-artboard-version/design-artboard-version.update.server.ts b/app/models/design-artboard-version/design-artboard-version.update.server.ts deleted file mode 100644 index fe43ceaa..00000000 --- a/app/models/design-artboard-version/design-artboard-version.update.server.ts +++ /dev/null @@ -1,35 +0,0 @@ -import { type IntentActionArgs } from '#app/definitions/intent-action-args' -import { - ReorderArtboardVersionDesignSchema, - ToggleVisibleArtboardVersionDesignSchema, -} from '#app/schema/design-artboard-version' -import { ValidateArtboardVersionParentSubmissionStrategy } from '#app/strategies/validate-submission.strategy' -import { validateEntitySubmission } from '#app/utils/conform-utils' - -export const validateArtboardVersionToggleVisibeDesignSubmission = async ({ - userId, - formData, -}: IntentActionArgs) => { - const strategy = new ValidateArtboardVersionParentSubmissionStrategy() - - return await validateEntitySubmission({ - userId, - formData, - schema: ToggleVisibleArtboardVersionDesignSchema, - strategy, - }) -} - -export const validateArtboardVersionReorderDesignSubmission = async ({ - userId, - formData, -}: IntentActionArgs) => { - const strategy = new ValidateArtboardVersionParentSubmissionStrategy() - - return await validateEntitySubmission({ - userId, - formData, - schema: ReorderArtboardVersionDesignSchema, - strategy, - }) -} diff --git a/app/models/design-artwork-version/design-artwork-version.create.server.ts b/app/models/design-artwork-version/design-artwork-version.create.server.ts new file mode 100644 index 00000000..90fd8de3 --- /dev/null +++ b/app/models/design-artwork-version/design-artwork-version.create.server.ts @@ -0,0 +1,18 @@ +import { type IntentActionArgs } from '#app/definitions/intent-action-args' +import { ValidateArtworkVersionParentSubmissionStrategy } from '#app/strategies/validate-submission.strategy' +import { validateEntitySubmission } from '#app/utils/conform-utils' +import { NewArtworkVersionDesignSchema } from '#app/schema/design-artwork-version' + +export const validateArtworkVersionNewDesignSubmission = async ({ + userId, + formData, +}: IntentActionArgs) => { + const strategy = new ValidateArtworkVersionParentSubmissionStrategy() + + return await validateEntitySubmission({ + userId, + formData, + schema: NewArtworkVersionDesignSchema, + strategy, + }) +} diff --git a/app/models/design-artwork-version/design-artwork-version.delete.server.ts b/app/models/design-artwork-version/design-artwork-version.delete.server.ts new file mode 100644 index 00000000..ee2cc527 --- /dev/null +++ b/app/models/design-artwork-version/design-artwork-version.delete.server.ts @@ -0,0 +1,18 @@ +import { type IntentActionArgs } from '#app/definitions/intent-action-args' +import { ValidateArtworkVersionParentSubmissionStrategy } from '#app/strategies/validate-submission.strategy' +import { validateEntitySubmission } from '#app/utils/conform-utils' +import { DeleteArtworkVersionDesignSchema } from '#app/schema/design-artwork-version' + +export const validateArtworkVersionDeleteDesignSubmission = async ({ + userId, + formData, +}: IntentActionArgs) => { + const strategy = new ValidateArtworkVersionParentSubmissionStrategy() + + return await validateEntitySubmission({ + userId, + formData, + schema: DeleteArtworkVersionDesignSchema, + strategy, + }) +} diff --git a/app/models/design-artboard-version/design-artboard-version.get.server.ts b/app/models/design-artwork-version/design-artwork-version.get.server.ts similarity index 64% rename from app/models/design-artboard-version/design-artboard-version.get.server.ts rename to app/models/design-artwork-version/design-artwork-version.get.server.ts index 7312122e..24b9b4a1 100644 --- a/app/models/design-artboard-version/design-artboard-version.get.server.ts +++ b/app/models/design-artwork-version/design-artwork-version.get.server.ts @@ -1,18 +1,18 @@ import { type designTypeEnum } from '#app/schema/design' import { prisma } from '#app/utils/db.server' import { orderLinkedItems } from '#app/utils/linked-list.utils' -import { type IArtboardVersion } from '../artboard-version/artboard-version.server' +import { type IArtworkVersion } from '../artwork-version/artwork-version.server' import { type IDesign } from '../design/design.server' -export const findFirstVisibleArtboardVersionDesignByType = async ({ - artboardVersionId, +export const findFirstVisibleArtworkVersionDesignByType = async ({ + artworkVersionId, type, }: { - artboardVersionId: IArtboardVersion['id'] + artworkVersionId: IArtworkVersion['id'] type: designTypeEnum }): Promise => { const designs = await prisma.design.findMany({ - where: { artboardVersionId, type }, + where: { artworkVersionId, type }, }) const orderedDesigns = orderLinkedItems(designs) return orderedDesigns.find(design => design.visible) || null diff --git a/app/models/design-artboard-version/design-artboard-version.server.ts b/app/models/design-artwork-version/design-artwork-version.server.ts similarity index 63% rename from app/models/design-artboard-version/design-artboard-version.server.ts rename to app/models/design-artwork-version/design-artwork-version.server.ts index 824b3fc4..8b6ee259 100644 --- a/app/models/design-artboard-version/design-artboard-version.server.ts +++ b/app/models/design-artwork-version/design-artwork-version.server.ts @@ -4,7 +4,7 @@ import { prisma } from '#app/utils/db.server' import { filterVisibleDesigns } from '#app/utils/design' import { orderLinkedItems } from '#app/utils/linked-list.utils' import { filterNonArrayRotates } from '#app/utils/rotate' -import { type IArtboardVersion } from '../artboard-version/artboard-version.server' +import { type IArtworkVersion } from '../artwork-version/artwork-version.server' import { findManyDesignsWithType, type IDesignWithPalette, @@ -14,21 +14,21 @@ import { import { type IPalette } from '../design-type/palette/palette.server' import { type IRotate } from '../design-type/rotate/rotate.server' -export interface IDesignWithArtboardVersion extends IDesign { - artboardVersion: IArtboardVersion +export interface IDesignWithArtworkVersion extends IDesign { + artworkVersion: IArtworkVersion } -export const updateArtboardVersionSelectedDesign = ({ - artboardVersionId, +export const updateArtworkVersionSelectedDesign = ({ + artworkVersionId, designId, type, }: { - artboardVersionId: IArtboardVersion['id'] + artworkVersionId: IArtworkVersion['id'] designId: Design['id'] type: designTypeEnum }) => { - const deselectDesign = deselectArtboardVersionSelectedDesign({ - artboardVersionId, + const deselectDesign = deselectArtworkVersionSelectedDesign({ + artworkVersionId, type, }) const selectDesign = prisma.design.update({ @@ -38,26 +38,26 @@ export const updateArtboardVersionSelectedDesign = ({ return [deselectDesign, selectDesign] } -export const deselectArtboardVersionSelectedDesign = ({ - artboardVersionId, +export const deselectArtworkVersionSelectedDesign = ({ + artworkVersionId, type, }: { - artboardVersionId: IArtboardVersion['id'] + artworkVersionId: IArtworkVersion['id'] type: designTypeEnum }) => { return prisma.design.updateMany({ - where: { artboardVersionId, type, selected: true }, + where: { artworkVersionId, type, selected: true }, data: { selected: false }, }) } -export const getArtboardVersionVisiblePalettes = async ({ - artboardVersionId, +export const getArtworkVersionVisiblePalettes = async ({ + artworkVersionId, }: { - artboardVersionId: IArtboardVersion['id'] + artworkVersionId: IArtworkVersion['id'] }): Promise => { const designPalettes = (await findManyDesignsWithType({ - where: { type: DesignTypeEnum.PALETTE, artboardVersionId }, + where: { type: DesignTypeEnum.PALETTE, artworkVersionId }, })) as IDesignWithPalette[] const visibleDesignPalettes = filterVisibleDesigns( @@ -67,13 +67,13 @@ export const getArtboardVersionVisiblePalettes = async ({ return visibleDesignPalettes.map(design => design.palette) } -export const getArtboardVersionVisibleRotates = async ({ - artboardVersionId, +export const getArtworkVersionVisibleRotates = async ({ + artworkVersionId, }: { - artboardVersionId: IArtboardVersion['id'] + artworkVersionId: IArtworkVersion['id'] }): Promise => { const designRotates = (await findManyDesignsWithType({ - where: { type: DesignTypeEnum.ROTATE, artboardVersionId }, + where: { type: DesignTypeEnum.ROTATE, artworkVersionId }, })) as IDesignWithRotate[] const visibleDesignRotates = filterVisibleDesigns( diff --git a/app/models/design-artwork-version/design-artwork-version.update.server.ts b/app/models/design-artwork-version/design-artwork-version.update.server.ts new file mode 100644 index 00000000..33afb3f5 --- /dev/null +++ b/app/models/design-artwork-version/design-artwork-version.update.server.ts @@ -0,0 +1,35 @@ +import { type IntentActionArgs } from '#app/definitions/intent-action-args' +import { ValidateArtworkVersionParentSubmissionStrategy } from '#app/strategies/validate-submission.strategy' +import { validateEntitySubmission } from '#app/utils/conform-utils' +import { + ReorderArtworkVersionDesignSchema, + ToggleVisibleArtworkVersionDesignSchema, +} from '#app/schema/design-artwork-version' + +export const validateArtworkVersionToggleVisibeDesignSubmission = async ({ + userId, + formData, +}: IntentActionArgs) => { + const strategy = new ValidateArtworkVersionParentSubmissionStrategy() + + return await validateEntitySubmission({ + userId, + formData, + schema: ToggleVisibleArtworkVersionDesignSchema, + strategy, + }) +} + +export const validateArtworkVersionReorderDesignSubmission = async ({ + userId, + formData, +}: IntentActionArgs) => { + const strategy = new ValidateArtworkVersionParentSubmissionStrategy() + + return await validateEntitySubmission({ + userId, + formData, + schema: ReorderArtworkVersionDesignSchema, + strategy, + }) +} diff --git a/app/models/design/design.create.server.ts b/app/models/design/design.create.server.ts index 572a611d..e7722d52 100644 --- a/app/models/design/design.create.server.ts +++ b/app/models/design/design.create.server.ts @@ -1,9 +1,9 @@ import { type User } from '@prisma/client' import { type designTypeEnum } from '#app/schema/design' -import { NewArtboardVersionDesignSchema } from '#app/schema/design-artboard-version' +import { NewArtworkVersionDesignSchema } from '#app/schema/design-artwork-version' import { prisma } from '#app/utils/db.server' -import { type IArtboard } from '../artboard/artboard.server' -import { type IArtboardVersion } from '../artboard-version/artboard-version.server' +import { type IArtwork } from '../artwork/artwork.server' +import { type IArtworkVersion } from '../artwork-version/artwork-version.server' import { type IDesign } from '../design/design.server' import { type ILayer } from '../layer/layer.server' @@ -19,8 +19,8 @@ export const createDesign = async ({ data: { ownerId: User['id'] type: designTypeEnum - artboardId?: IArtboard['id'] - artboardVersionId?: IArtboardVersion['id'] + artworkId?: IArtwork['id'] + artworkVersionId?: IArtworkVersion['id'] layerId?: ILayer['id'] visible?: boolean selected?: boolean @@ -30,19 +30,19 @@ export const createDesign = async ({ return createdDesign } -export const createArtboardVersionDesign = async ({ +export const createArtworkVersionDesign = async ({ data, }: { data: { ownerId: User['id'] type: designTypeEnum - artboardVersionId: IArtboardVersion['id'] + artworkVersionId: IArtworkVersion['id'] visible?: boolean selected?: boolean } }): Promise => { const { ownerId } = data - const parsedData = NewArtboardVersionDesignSchema.parse(data) + const parsedData = NewArtworkVersionDesignSchema.parse(data) const createdDesign = await createDesign({ data: { ownerId, ...parsedData } }) return createdDesign } diff --git a/app/models/design/design.get.server.ts b/app/models/design/design.get.server.ts index 071ce2c5..a850a399 100644 --- a/app/models/design/design.get.server.ts +++ b/app/models/design/design.get.server.ts @@ -9,8 +9,8 @@ const whereArgs = z.object({ id: z.string().optional(), type: z.nativeEnum(DesignTypeEnum).optional(), ownerId: z.string().optional(), - artboardId: z.string().optional(), - artboardVersionId: z.string().optional(), + artworkId: z.string().optional(), + artworkVersionId: z.string().optional(), layerId: z.string().optional(), nextId: zodStringOrNull.optional(), prevId: zodStringOrNull.optional(), diff --git a/app/models/design/design.server.ts b/app/models/design/design.server.ts index 4f4219e6..dcbb0b73 100644 --- a/app/models/design/design.server.ts +++ b/app/models/design/design.server.ts @@ -6,9 +6,9 @@ import { } from '#app/schema/design' import { prisma } from '#app/utils/db.server' import { - type IArtboardVersionWithDesignsAndLayers, - type IArtboardVersion, -} from '../artboard-version/artboard-version.server' + type IArtworkVersionWithDesignsAndLayers, + type IArtworkVersion, +} from '../artwork-version/artwork-version.server' import { type IFillCreateOverrides } from '../design-type/fill/fill.create.server' import { type IFill } from '../design-type/fill/fill.server' import { type ILayoutCreateOverrides } from '../design-type/layout/layout.create.server' @@ -32,8 +32,8 @@ export type IDesignIdOrNull = IDesign['id'] | null | undefined export type IDesignEntityId = | IDesign['id'] - | IArtboardVersion['id'] - | IArtboardVersionWithDesignsAndLayers['id'] + | IArtworkVersion['id'] + | IArtworkVersionWithDesignsAndLayers['id'] export type IDesignEntityIdOrNull = IDesignEntityId | null | undefined export interface IDesignCreateOverrides { @@ -59,7 +59,7 @@ export interface IDesignWithType { nextId: string | null prevId: string | null ownerId: string - artboardVersionId: string | null + artworkVersionId: string | null layerId: string | null palette: IPalette | null size: ISize | null diff --git a/app/models/layer-artboard-version/layer-artboard-version.update.server.ts b/app/models/layer-artboard-version/layer-artboard-version.update.server.ts deleted file mode 100644 index b37229a8..00000000 --- a/app/models/layer-artboard-version/layer-artboard-version.update.server.ts +++ /dev/null @@ -1,77 +0,0 @@ -import { type IntentActionArgs } from '#app/definitions/intent-action-args' -import { - ReorderArtboardVersionLayerSchema, - SelectArtboardVersionLayerSchema, - ToggleVisibleArtboardVersionLayerSchema, -} from '#app/schema/layer-artboard-version' -import { ValidateArtboardVersionParentSubmissionStrategy } from '#app/strategies/validate-submission.strategy' -import { validateEntitySubmission } from '#app/utils/conform-utils' -import { prisma } from '#app/utils/db.server' -import { type IArtboardVersion } from '../artboard-version/artboard-version.server' -import { type ILayer } from '../layer/layer.server' - -export const validateArtboardVersionToggleVisibeLayerSubmission = async ({ - userId, - formData, -}: IntentActionArgs) => { - const strategy = new ValidateArtboardVersionParentSubmissionStrategy() - - return await validateEntitySubmission({ - userId, - formData, - schema: ToggleVisibleArtboardVersionLayerSchema, - strategy, - }) -} - -export const validateArtboardVersionReorderLayerSubmission = async ({ - userId, - formData, -}: IntentActionArgs) => { - const strategy = new ValidateArtboardVersionParentSubmissionStrategy() - - return await validateEntitySubmission({ - userId, - formData, - schema: ReorderArtboardVersionLayerSchema, - strategy, - }) -} - -export const validateArtboardVersionSelectLayerSubmission = async ({ - userId, - formData, -}: IntentActionArgs) => { - const strategy = new ValidateArtboardVersionParentSubmissionStrategy() - - return await validateEntitySubmission({ - userId, - formData, - schema: SelectArtboardVersionLayerSchema, - strategy, - }) -} - -export const deselectArtboardVersionLayers = ({ - artboardVersionId, -}: { - artboardVersionId: IArtboardVersion['id'] -}) => { - return prisma.layer.updateMany({ - where: { artboardVersionId }, - data: { selected: false }, - }) -} - -export const updateLayerSelected = ({ - id, - selected, -}: { - id: ILayer['id'] - selected: boolean -}) => { - return prisma.layer.update({ - where: { id }, - data: { selected }, - }) -} diff --git a/app/models/layer-artwork-version/layer-artwork-version.update.server.ts b/app/models/layer-artwork-version/layer-artwork-version.update.server.ts new file mode 100644 index 00000000..0371b95b --- /dev/null +++ b/app/models/layer-artwork-version/layer-artwork-version.update.server.ts @@ -0,0 +1,77 @@ +import { type IntentActionArgs } from '#app/definitions/intent-action-args' +import { ValidateArtworkVersionParentSubmissionStrategy } from '#app/strategies/validate-submission.strategy' +import { validateEntitySubmission } from '#app/utils/conform-utils' +import { prisma } from '#app/utils/db.server' +import { type IArtworkVersion } from '../artwork-version/artwork-version.server' +import { type ILayer } from '../layer/layer.server' +import { + ReorderArtworkVersionLayerSchema, + SelectArtworkVersionLayerSchema, + ToggleVisibleArtworkVersionLayerSchema, +} from '#app/schema/layer-artwork-version' + +export const validateArtworkVersionToggleVisibeLayerSubmission = async ({ + userId, + formData, +}: IntentActionArgs) => { + const strategy = new ValidateArtworkVersionParentSubmissionStrategy() + + return await validateEntitySubmission({ + userId, + formData, + schema: ToggleVisibleArtworkVersionLayerSchema, + strategy, + }) +} + +export const validateArtworkVersionReorderLayerSubmission = async ({ + userId, + formData, +}: IntentActionArgs) => { + const strategy = new ValidateArtworkVersionParentSubmissionStrategy() + + return await validateEntitySubmission({ + userId, + formData, + schema: ReorderArtworkVersionLayerSchema, + strategy, + }) +} + +export const validateArtworkVersionSelectLayerSubmission = async ({ + userId, + formData, +}: IntentActionArgs) => { + const strategy = new ValidateArtworkVersionParentSubmissionStrategy() + + return await validateEntitySubmission({ + userId, + formData, + schema: SelectArtworkVersionLayerSchema, + strategy, + }) +} + +export const deselectArtworkVersionLayers = ({ + artworkVersionId, +}: { + artworkVersionId: IArtworkVersion['id'] +}) => { + return prisma.layer.updateMany({ + where: { artworkVersionId }, + data: { selected: false }, + }) +} + +export const updateLayerSelected = ({ + id, + selected, +}: { + id: ILayer['id'] + selected: boolean +}) => { + return prisma.layer.update({ + where: { id }, + data: { selected }, + }) +} diff --git a/app/models/layer/layer.create.server.ts b/app/models/layer/layer.create.server.ts index a215e3da..67b7619f 100644 --- a/app/models/layer/layer.create.server.ts +++ b/app/models/layer/layer.create.server.ts @@ -1,10 +1,10 @@ import { type IntentActionArgs } from '#app/definitions/intent-action-args' -import { NewArtboardVersionLayerSchema } from '#app/schema/layer-artboard-version' -import { ValidateArtboardVersionParentSubmissionStrategy } from '#app/strategies/validate-submission.strategy' +import { NewArtworkVersionLayerSchema } from '#app/schema/layer-artwork-version' +import { ValidateArtworkVersionParentSubmissionStrategy } from '#app/strategies/validate-submission.strategy' import { validateEntitySubmission } from '#app/utils/conform-utils' import { prisma } from '#app/utils/db.server' -import { type IArtboard } from '../artboard/artboard.server' -import { type IArtboardVersion } from '../artboard-version/artboard-version.server' +import { type IArtwork } from '../artwork/artwork.server' +import { type IArtworkVersion } from '../artwork-version/artwork-version.server' import { type ILayer } from '../layer/layer.server' import { type IUser } from '../user/user.server' @@ -14,16 +14,16 @@ export interface ILayerCreatedResponse { createdLayer?: ILayer } -export const validateArtboardVersionNewLayerSubmission = async ({ +export const validateArtworkVersionNewLayerSubmission = async ({ userId, formData, }: IntentActionArgs) => { - const strategy = new ValidateArtboardVersionParentSubmissionStrategy() + const strategy = new ValidateArtworkVersionParentSubmissionStrategy() return await validateEntitySubmission({ userId, formData, - schema: NewArtboardVersionLayerSchema, + schema: NewArtworkVersionLayerSchema, strategy, }) } @@ -34,8 +34,8 @@ export const createLayer = async ({ data: { ownerId: IUser['id'] name: string - artboardId?: IArtboard['id'] - artboardVersionId?: IArtboardVersion['id'] + artworkId?: IArtwork['id'] + artworkVersionId?: IArtworkVersion['id'] description?: string | undefined slug?: string | undefined visible?: boolean diff --git a/app/models/layer/layer.delete.server.ts b/app/models/layer/layer.delete.server.ts index 93d13091..e9181e4f 100644 --- a/app/models/layer/layer.delete.server.ts +++ b/app/models/layer/layer.delete.server.ts @@ -1,6 +1,6 @@ import { type IntentActionArgs } from '#app/definitions/intent-action-args' -import { DeleteArtboardVersionLayerSchema } from '#app/schema/layer-artboard-version' -import { ValidateArtboardVersionParentSubmissionStrategy } from '#app/strategies/validate-submission.strategy' +import { DeleteArtworkVersionLayerSchema } from '#app/schema/layer-artwork-version' +import { ValidateArtworkVersionParentSubmissionStrategy } from '#app/strategies/validate-submission.strategy' import { validateEntitySubmission } from '#app/utils/conform-utils' import { prisma } from '#app/utils/db.server' import { type ILayer } from '../layer/layer.server' @@ -10,16 +10,16 @@ export interface ILayerDeletedResponse { message?: string } -export const validateArtboardVersionDeleteLayerSubmission = async ({ +export const validateArtworkVersionDeleteLayerSubmission = async ({ userId, formData, }: IntentActionArgs) => { - const strategy = new ValidateArtboardVersionParentSubmissionStrategy() + const strategy = new ValidateArtworkVersionParentSubmissionStrategy() return await validateEntitySubmission({ userId, formData, - schema: DeleteArtboardVersionLayerSchema, + schema: DeleteArtworkVersionLayerSchema, strategy, }) } diff --git a/app/models/layer/layer.server.ts b/app/models/layer/layer.server.ts index 923b5555..d86adbf5 100644 --- a/app/models/layer/layer.server.ts +++ b/app/models/layer/layer.server.ts @@ -5,8 +5,8 @@ import { type whereArgsType, } from '#app/schema/layer' import { prisma } from '#app/utils/db.server' -import { type IArtboard } from '../artboard/artboard.server' -import { type IArtboardVersion } from '../artboard-version/artboard-version.server' +import { type IArtwork } from '../artwork/artwork.server' +import { type IArtworkVersion } from '../artwork-version/artwork-version.server' import { type IDesignWithType } from '../design/design.server' export interface ILayer { @@ -19,7 +19,7 @@ export interface ILayer { createdAt: Date | string updatedAt: Date | string ownerId: string - artboardVersionId: string | null + artworkVersionId: string | null nextId: string | null prevId: string | null parentId: string | null @@ -27,7 +27,7 @@ export interface ILayer { // designs: IDesignWithType[] } -export type ILayerEntityId = IArtboard['id'] | IArtboardVersion['id'] +export type ILayerEntityId = IArtwork['id'] | IArtworkVersion['id'] export interface ILayerWithDesigns extends ILayer { designs: IDesignWithType[] } diff --git a/app/models/project/project.get.server.ts b/app/models/project/project.get.server.ts index 75fe7d36..cd6b9e89 100644 --- a/app/models/project/project.get.server.ts +++ b/app/models/project/project.get.server.ts @@ -1,6 +1,6 @@ import { z } from 'zod' import { prisma } from '#app/utils/db.server' -import { type IProjectWithArtboards } from './project.server' +import { type IProjectWithArtworks } from './project.server' export type queryProjectWhereArgsType = z.infer const queryWhereArgs = z.object({ @@ -15,21 +15,21 @@ const queryWhereArgs = z.object({ const validateQueryWhereArgsPresent = (where: queryProjectWhereArgsType) => { if (Object.values(where).some(value => !value)) { throw new Error( - 'Null or undefined values are not allowed in query parameters for artboard.', + 'Null or undefined values are not allowed in query parameters for artwork.', ) } } -export const getProjectsWithArtboards = async ({ +export const getProjectsWithArtworks = async ({ where, }: { where: queryProjectWhereArgsType -}): Promise => { +}): Promise => { validateQueryWhereArgsPresent(where) const projects = await prisma.project.findMany({ where, include: { - artboards: { + artworks: { orderBy: { createdAt: 'desc', }, @@ -42,16 +42,16 @@ export const getProjectsWithArtboards = async ({ return projects } -export const getProjectWithArtboards = async ({ +export const getProjectWithArtworks = async ({ where, }: { where: queryProjectWhereArgsType -}): Promise => { +}): Promise => { validateQueryWhereArgsPresent(where) const project = await prisma.project.findFirst({ where, include: { - artboards: { + artworks: { orderBy: { createdAt: 'desc', }, diff --git a/app/models/project/project.server.ts b/app/models/project/project.server.ts index 6bf22944..3bccd5a3 100644 --- a/app/models/project/project.server.ts +++ b/app/models/project/project.server.ts @@ -1,6 +1,6 @@ import { type Project } from '@prisma/client' import { type DateOrString } from '#app/definitions/prisma-helper' -import { type IArtboard } from '../artboard/artboard.server' +import { type IArtwork } from '../artwork/artwork.server' // Omitting 'createdAt' and 'updatedAt' from the Project interface // prisma query returns a string for these fields @@ -10,6 +10,6 @@ export interface IProject extends BaseProject { createdAt: DateOrString updatedAt: DateOrString } -export interface IProjectWithArtboards extends IProject { - artboards: IArtboard[] +export interface IProjectWithArtworks extends IProject { + artworks: IArtwork[] } diff --git a/app/routes/resources+/api.v1+/artboard-branch.create.tsx b/app/routes/resources+/api.v1+/artwork-branch.create.tsx similarity index 79% rename from app/routes/resources+/api.v1+/artboard-branch.create.tsx rename to app/routes/resources+/api.v1+/artwork-branch.create.tsx index 424a2c18..16e6e4c2 100644 --- a/app/routes/resources+/api.v1+/artboard-branch.create.tsx +++ b/app/routes/resources+/api.v1+/artwork-branch.create.tsx @@ -18,21 +18,21 @@ import { } from '#app/components/ui/dialog' import { PanelIconButton } from '#app/components/ui/panel-icon-button' import { StatusButton } from '#app/components/ui/status-button' -import { type IArtboard } from '#app/models/artboard/artboard.server' -import { validateNewArtboardBranchSubmission } from '#app/models/artboard-branch/artboard-branch.create.server' -import { type IArtboardBranch } from '#app/models/artboard-branch/artboard-branch.server' -import { type IArtboardVersion } from '#app/models/artboard-version/artboard-version.server' -import { NewArtboardBranchSchema } from '#app/schema/artboard-branch' +import { type IArtwork } from '#app/models/artwork/artwork.server' +import { validateNewArtworkBranchSubmission } from '#app/models/artwork-branch/artwork-branch.create.server' +import { type IArtworkBranch } from '#app/models/artwork-branch/artwork-branch.server' +import { type IArtworkVersion } from '#app/models/artwork-version/artwork-version.server' +import { NewArtworkBranchSchema } from '#app/schema/artwork-branch' import { validateNoJS } from '#app/schema/form-data' -import { artboardBranchCreateService } from '#app/services/artboard/branch/create.service' +import { artworkBranchCreateService } from '#app/services/artwork/branch/create.service' import { requireUserId } from '#app/utils/auth.server' import { stringToSlug, useIsPending } from '#app/utils/misc' import { Routes } from '#app/utils/routes.const' // https://www.epicweb.dev/full-stack-components -const route = Routes.RESOURCES.API.V1.ARTBOARD_BRANCH.CREATE -const schema = NewArtboardBranchSchema +const route = Routes.RESOURCES.API.V1.ARTWORK_BRANCH.CREATE +const schema = NewArtworkBranchSchema export async function action({ request }: ActionFunctionArgs) { const userId = await requireUserId(request) @@ -41,13 +41,13 @@ export async function action({ request }: ActionFunctionArgs) { let createSuccess = false let errorMessage = '' - const { status, submission } = await validateNewArtboardBranchSubmission({ + const { status, submission } = await validateNewArtworkBranchSubmission({ userId, formData, }) if (status === 'success') { - const { success, message } = await artboardBranchCreateService({ + const { success, message } = await artworkBranchCreateService({ userId, ...submission.value, }) @@ -69,15 +69,15 @@ export async function action({ request }: ActionFunctionArgs) { ) } -export const ArtboardBranchCreate = ({ +export const ArtworkBranchCreate = ({ branchId, - artboardId, + artworkId, versionId, formId, }: { - branchId: IArtboardBranch['id'] - artboardId: IArtboard['id'] - versionId: IArtboardVersion['id'] + branchId: IArtworkBranch['id'] + artworkId: IArtwork['id'] + versionId: IArtworkVersion['id'] formId: string }) => { const [open, setOpen] = useState(false) @@ -88,7 +88,7 @@ export const ArtboardBranchCreate = ({ let isHydrated = useHydrated() const [form, fields] = useForm({ - id: `${formId}-${artboardId}-${branchId}-${versionId}`, + id: `${formId}-${artworkId}-${branchId}-${versionId}`, constraint: getFieldsetConstraint(schema), lastSubmission: fetcher.data?.submission, onValidate: ({ formData }) => { @@ -125,7 +125,7 @@ export const ArtboardBranchCreate = ({ Create a new branch - Save a new branch of this artboard. Add a name and description to + Save a new branch of this artwork. Add a name and description to help understand the changes. Click save when you're done. @@ -135,7 +135,7 @@ export const ArtboardBranchCreate = ({ - +
diff --git a/app/routes/resources+/api.v1+/artboard-version.create.tsx b/app/routes/resources+/api.v1+/artwork-version.create.tsx similarity index 88% rename from app/routes/resources+/api.v1+/artboard-version.create.tsx rename to app/routes/resources+/api.v1+/artwork-version.create.tsx index c63efd77..bb915c11 100644 --- a/app/routes/resources+/api.v1+/artboard-version.create.tsx +++ b/app/routes/resources+/api.v1+/artwork-version.create.tsx @@ -18,23 +18,23 @@ import { } from '#app/components/ui/dialog' import { PanelIconButton } from '#app/components/ui/panel-icon-button' import { StatusButton } from '#app/components/ui/status-button' -import { validateNewArtboardVersionSubmission } from '#app/models/artboard-version/artboard-version.create.server' -import { NewArtboardVersionSchema } from '#app/schema/artboard-version' +import { validateNewArtworkVersionSubmission } from '#app/models/artwork-version/artwork-version.create.server' +import { NewArtworkVersionSchema } from '#app/schema/artwork-version' import { type IEntityId, type IEntityParentId, type entityParentIdTypeEnum, } from '#app/schema/entity' import { validateNoJS } from '#app/schema/form-data' -import { artboardVersionCreateService } from '#app/services/artboard/branch/version/create.service' +import { artworkVersionCreateService } from '#app/services/artwork/branch/version/create.service' import { requireUserId } from '#app/utils/auth.server' import { useIsPending } from '#app/utils/misc' import { Routes } from '#app/utils/routes.const' // https://www.epicweb.dev/full-stack-components -const route = Routes.RESOURCES.API.V1.ARTBOARD_VERSION.CREATE -const schema = NewArtboardVersionSchema +const route = Routes.RESOURCES.API.V1.ARTWORK_VERSION.CREATE +const schema = NewArtworkVersionSchema export async function action({ request }: ActionFunctionArgs) { const userId = await requireUserId(request) @@ -42,13 +42,13 @@ export async function action({ request }: ActionFunctionArgs) { const noJS = validateNoJS({ formData }) let createSuccess = false - const { status, submission } = await validateNewArtboardVersionSubmission({ + const { status, submission } = await validateNewArtworkVersionSubmission({ userId, formData, }) if (status === 'success') { - const { success } = await artboardVersionCreateService({ + const { success } = await artworkVersionCreateService({ userId, ...submission.value, }) @@ -69,7 +69,7 @@ export async function action({ request }: ActionFunctionArgs) { ) } -export const ArtboardVersionCreate = ({ +export const ArtworkVersionCreate = ({ entityId, parentTypeId, parentId, @@ -144,7 +144,7 @@ export const ArtboardVersionCreate = ({ Create new version - Save a new version of this artboard. Add a description to help + Save a new version of this artwork. Add a description to help understand the changes. Click save when you're done. diff --git a/app/routes/resources+/api.v1+/artboard-version.design.create.tsx b/app/routes/resources+/api.v1+/artwork-version.design.create.tsx similarity index 71% rename from app/routes/resources+/api.v1+/artboard-version.design.create.tsx rename to app/routes/resources+/api.v1+/artwork-version.design.create.tsx index 5bcc8422..bddce00b 100644 --- a/app/routes/resources+/api.v1+/artboard-version.design.create.tsx +++ b/app/routes/resources+/api.v1+/artwork-version.design.create.tsx @@ -6,21 +6,21 @@ import { AuthenticityTokenInput } from 'remix-utils/csrf/react' import { redirectBack } from 'remix-utils/redirect-back' import { useHydrated } from 'remix-utils/use-hydrated' import { PanelIconButton } from '#app/components/ui/panel-icon-button' -import { type IArtboardVersion } from '#app/models/artboard-version/artboard-version.server' -import { validateArtboardVersionNewDesignSubmission } from '#app/models/design-artboard-version/design-artboard-version.create.server' +import { type IArtworkVersion } from '#app/models/artwork-version/artwork-version.server' +import { validateArtworkVersionNewDesignSubmission } from '#app/models/design-artwork-version/design-artwork-version.create.server' import { type designTypeEnum } from '#app/schema/design' -import { NewArtboardVersionDesignSchema } from '#app/schema/design-artboard-version' +import { NewArtworkVersionDesignSchema } from '#app/schema/design-artwork-version' import { EntityParentIdType } from '#app/schema/entity' import { validateNoJS } from '#app/schema/form-data' -import { artboardVersionDesignCreateService } from '#app/services/artboard/version/design/create.service' +import { artworkVersionDesignCreateService } from '#app/services/artwork/version/design/create.service' import { requireUserId } from '#app/utils/auth.server' import { useIsPending } from '#app/utils/misc' import { Routes } from '#app/utils/routes.const' // https://www.epicweb.dev/full-stack-components -const route = Routes.RESOURCES.API.V1.ARTBOARD_VERSION.DESIGN.CREATE -const schema = NewArtboardVersionDesignSchema +const route = Routes.RESOURCES.API.V1.ARTWORK_VERSION.DESIGN.CREATE +const schema = NewArtworkVersionDesignSchema export async function action({ request }: ActionFunctionArgs) { const userId = await requireUserId(request) @@ -29,13 +29,13 @@ export async function action({ request }: ActionFunctionArgs) { let createSuccess = false const { status, submission } = - await validateArtboardVersionNewDesignSubmission({ + await validateArtworkVersionNewDesignSubmission({ userId, formData, }) if (status === 'success') { - const { success } = await artboardVersionDesignCreateService({ + const { success } = await artworkVersionDesignCreateService({ userId, ...submission.value, }) @@ -56,19 +56,19 @@ export async function action({ request }: ActionFunctionArgs) { ) } -export const ArtboardVersionDesignCreate = ({ +export const ArtworkVersionDesignCreate = ({ type, versionId, }: { type: designTypeEnum - versionId: IArtboardVersion['id'] + versionId: IArtworkVersion['id'] }) => { const fetcher = useFetcher() const lastSubmission = fetcher.data?.submission const isPending = useIsPending() let isHydrated = useHydrated() const [form] = useForm({ - id: `artboard-version-design-create-${versionId}-new`, + id: `artwork-version-design-create-${versionId}-new`, constraint: getFieldsetConstraint(schema), lastSubmission, }) @@ -80,7 +80,7 @@ export const ArtboardVersionDesignCreate = ({ diff --git a/app/routes/resources+/api.v1+/artboard-version.design.delete.tsx b/app/routes/resources+/api.v1+/artwork-version.design.delete.tsx similarity index 71% rename from app/routes/resources+/api.v1+/artboard-version.design.delete.tsx rename to app/routes/resources+/api.v1+/artwork-version.design.delete.tsx index d28542c2..1e33ddb4 100644 --- a/app/routes/resources+/api.v1+/artboard-version.design.delete.tsx +++ b/app/routes/resources+/api.v1+/artwork-version.design.delete.tsx @@ -6,21 +6,21 @@ import { AuthenticityTokenInput } from 'remix-utils/csrf/react' import { redirectBack } from 'remix-utils/redirect-back' import { useHydrated } from 'remix-utils/use-hydrated' import { PanelIconButton } from '#app/components/ui/panel-icon-button' -import { type IArtboardVersion } from '#app/models/artboard-version/artboard-version.server' +import { type IArtworkVersion } from '#app/models/artwork-version/artwork-version.server' import { type IDesign } from '#app/models/design/design.server' -import { validateArtboardVersionDeleteDesignSubmission } from '#app/models/design-artboard-version/design-artboard-version.delete.server' -import { DeleteArtboardVersionDesignSchema } from '#app/schema/design-artboard-version' +import { validateArtworkVersionDeleteDesignSubmission } from '#app/models/design-artwork-version/design-artwork-version.delete.server' +import { DeleteArtworkVersionDesignSchema } from '#app/schema/design-artwork-version' import { EntityParentIdType } from '#app/schema/entity' import { validateNoJS } from '#app/schema/form-data' -import { artboardVersionDesignDeleteService } from '#app/services/artboard/version/design/delete.service' +import { artworkVersionDesignDeleteService } from '#app/services/artwork/version/design/delete.service' import { requireUserId } from '#app/utils/auth.server' import { useIsPending } from '#app/utils/misc' import { Routes } from '#app/utils/routes.const' // https://www.epicweb.dev/full-stack-components -const route = Routes.RESOURCES.API.V1.ARTBOARD_VERSION.DESIGN.DELETE -const schema = DeleteArtboardVersionDesignSchema +const route = Routes.RESOURCES.API.V1.ARTWORK_VERSION.DESIGN.DELETE +const schema = DeleteArtworkVersionDesignSchema export async function action({ request }: ActionFunctionArgs) { const userId = await requireUserId(request) @@ -29,13 +29,13 @@ export async function action({ request }: ActionFunctionArgs) { let deleteSuccess = false const { status, submission } = - await validateArtboardVersionDeleteDesignSubmission({ + await validateArtworkVersionDeleteDesignSubmission({ userId, formData, }) if (status === 'success') { - const { success } = await artboardVersionDesignDeleteService({ + const { success } = await artworkVersionDesignDeleteService({ userId, ...submission.value, }) @@ -56,19 +56,19 @@ export async function action({ request }: ActionFunctionArgs) { ) } -export const ArtboardVersionDesignDelete = ({ +export const ArtworkVersionDesignDelete = ({ designId, versionId, }: { designId: IDesign['id'] - versionId: IArtboardVersion['id'] + versionId: IArtworkVersion['id'] }) => { const fetcher = useFetcher() const lastSubmission = fetcher.data?.submission const isPending = useIsPending() let isHydrated = useHydrated() const [form] = useForm({ - id: `artboard-version-design-delete-${versionId}-${designId}`, + id: `artwork-version-design-delete-${versionId}-${designId}`, constraint: getFieldsetConstraint(schema), lastSubmission, }) @@ -81,7 +81,7 @@ export const ArtboardVersionDesignDelete = ({ diff --git a/app/routes/resources+/api.v1+/artboard-version.design.update.order.tsx b/app/routes/resources+/api.v1+/artwork-version.design.update.order.tsx similarity index 71% rename from app/routes/resources+/api.v1+/artboard-version.design.update.order.tsx rename to app/routes/resources+/api.v1+/artwork-version.design.update.order.tsx index 33e280e3..d29e484a 100644 --- a/app/routes/resources+/api.v1+/artboard-version.design.update.order.tsx +++ b/app/routes/resources+/api.v1+/artwork-version.design.update.order.tsx @@ -7,22 +7,22 @@ import { redirectBack } from 'remix-utils/redirect-back' import { useHydrated } from 'remix-utils/use-hydrated' import { type IconName } from '#app/components/ui/icon' import { PanelIconButton } from '#app/components/ui/panel-icon-button' -import { type IArtboardVersion } from '#app/models/artboard-version/artboard-version.server' +import { type IArtworkVersion } from '#app/models/artwork-version/artwork-version.server' import { type IDesign } from '#app/models/design/design.server' -import { validateArtboardVersionReorderDesignSubmission } from '#app/models/design-artboard-version/design-artboard-version.update.server' -import { ReorderArtboardVersionDesignSchema } from '#app/schema/design-artboard-version' +import { validateArtworkVersionReorderDesignSubmission } from '#app/models/design-artwork-version/design-artwork-version.update.server' +import { ReorderArtworkVersionDesignSchema } from '#app/schema/design-artwork-version' import { EntityParentIdType } from '#app/schema/entity' import { validateNoJS } from '#app/schema/form-data' -import { artboardVersionDesignMoveDownService } from '#app/services/artboard/version/design/move-down.service' -import { artboardVersionDesignMoveUpService } from '#app/services/artboard/version/design/move-up.service' +import { artworkVersionDesignMoveDownService } from '#app/services/artwork/version/design/move-down.service' +import { artworkVersionDesignMoveUpService } from '#app/services/artwork/version/design/move-up.service' import { requireUserId } from '#app/utils/auth.server' import { useIsPending } from '#app/utils/misc' import { Routes } from '#app/utils/routes.const' // https://www.epicweb.dev/full-stack-components -const route = Routes.RESOURCES.API.V1.ARTBOARD_VERSION.DESIGN.UPDATE.ORDER -const schema = ReorderArtboardVersionDesignSchema +const route = Routes.RESOURCES.API.V1.ARTWORK_VERSION.DESIGN.UPDATE.ORDER +const schema = ReorderArtworkVersionDesignSchema export async function action({ request }: ActionFunctionArgs) { const userId = await requireUserId(request) @@ -31,7 +31,7 @@ export async function action({ request }: ActionFunctionArgs) { let updateSuccess = false const { status, submission } = - await validateArtboardVersionReorderDesignSubmission({ + await validateArtworkVersionReorderDesignSubmission({ userId, formData, }) @@ -40,14 +40,14 @@ export async function action({ request }: ActionFunctionArgs) { const { direction } = submission.value const { success } = direction === 'up' - ? await artboardVersionDesignMoveUpService({ + ? await artworkVersionDesignMoveUpService({ userId, ...submission.value, - }) - : await artboardVersionDesignMoveDownService({ + }) + : await artworkVersionDesignMoveDownService({ userId, ...submission.value, - }) + }) updateSuccess = success } @@ -65,14 +65,14 @@ export async function action({ request }: ActionFunctionArgs) { ) } -export const ArtboardVersionDesignReorder = ({ +export const ArtworkVersionDesignReorder = ({ design, version, direction, atTopOrBottom = false, }: { design: IDesign - version: IArtboardVersion + version: IArtworkVersion direction: 'up' | 'down' atTopOrBottom?: boolean }) => { @@ -80,7 +80,7 @@ export const ArtboardVersionDesignReorder = ({ const designId = design.id const icon = `chevron-${direction}` const iconText = `Move ${direction}` - const formId = `artboard-version-design-reorder-${direction}-${versionId}-${designId}` + const formId = `artwork-version-design-reorder-${direction}-${versionId}-${designId}` const fetcher = useFetcher() const lastSubmission = fetcher.data?.submission @@ -100,7 +100,7 @@ export const ArtboardVersionDesignReorder = ({ diff --git a/app/routes/resources+/api.v1+/artboard-version.design.update.visible.tsx b/app/routes/resources+/api.v1+/artwork-version.design.update.visible.tsx similarity index 71% rename from app/routes/resources+/api.v1+/artboard-version.design.update.visible.tsx rename to app/routes/resources+/api.v1+/artwork-version.design.update.visible.tsx index 6778e240..c1786562 100644 --- a/app/routes/resources+/api.v1+/artboard-version.design.update.visible.tsx +++ b/app/routes/resources+/api.v1+/artwork-version.design.update.visible.tsx @@ -6,21 +6,21 @@ import { AuthenticityTokenInput } from 'remix-utils/csrf/react' import { redirectBack } from 'remix-utils/redirect-back' import { useHydrated } from 'remix-utils/use-hydrated' import { PanelIconButton } from '#app/components/ui/panel-icon-button' -import { type IArtboardVersion } from '#app/models/artboard-version/artboard-version.server' +import { type IArtworkVersion } from '#app/models/artwork-version/artwork-version.server' import { type IDesign } from '#app/models/design/design.server' -import { validateArtboardVersionToggleVisibeDesignSubmission } from '#app/models/design-artboard-version/design-artboard-version.update.server' -import { ToggleVisibleArtboardVersionDesignSchema } from '#app/schema/design-artboard-version' +import { validateArtworkVersionToggleVisibeDesignSubmission } from '#app/models/design-artwork-version/design-artwork-version.update.server' +import { ToggleVisibleArtworkVersionDesignSchema } from '#app/schema/design-artwork-version' import { EntityParentIdType } from '#app/schema/entity' import { validateNoJS } from '#app/schema/form-data' -import { artboardVersionDesignToggleVisibleService } from '#app/services/artboard/version/design/toggle-visible.service' +import { artworkVersionDesignToggleVisibleService } from '#app/services/artwork/version/design/toggle-visible.service' import { requireUserId } from '#app/utils/auth.server' import { useIsPending } from '#app/utils/misc' import { Routes } from '#app/utils/routes.const' // https://www.epicweb.dev/full-stack-components -const route = Routes.RESOURCES.API.V1.ARTBOARD_VERSION.DESIGN.UPDATE.VISIBLE -const schema = ToggleVisibleArtboardVersionDesignSchema +const route = Routes.RESOURCES.API.V1.ARTWORK_VERSION.DESIGN.UPDATE.VISIBLE +const schema = ToggleVisibleArtworkVersionDesignSchema export async function action({ request }: ActionFunctionArgs) { const userId = await requireUserId(request) @@ -29,13 +29,13 @@ export async function action({ request }: ActionFunctionArgs) { let updateSuccess = false const { status, submission } = - await validateArtboardVersionToggleVisibeDesignSubmission({ + await validateArtworkVersionToggleVisibeDesignSubmission({ userId, formData, }) if (status === 'success') { - const { success } = await artboardVersionDesignToggleVisibleService({ + const { success } = await artworkVersionDesignToggleVisibleService({ userId, ...submission.value, }) @@ -56,12 +56,12 @@ export async function action({ request }: ActionFunctionArgs) { ) } -export const ArtboardVersionDesignToggleVisible = ({ +export const ArtworkVersionDesignToggleVisible = ({ design, version, }: { design: IDesign - version: IArtboardVersion + version: IArtworkVersion }) => { const versionId = version.id const designId = design.id @@ -74,7 +74,7 @@ export const ArtboardVersionDesignToggleVisible = ({ const isPending = useIsPending() let isHydrated = useHydrated() const [form] = useForm({ - id: `artboard-version-design-toggle-visible-${versionId}-${designId}`, + id: `artwork-version-design-toggle-visible-${versionId}-${designId}`, constraint: getFieldsetConstraint(schema), lastSubmission, }) @@ -87,7 +87,7 @@ export const ArtboardVersionDesignToggleVisible = ({ diff --git a/app/routes/resources+/api.v1+/artboard-version.layer.create.tsx b/app/routes/resources+/api.v1+/artwork-version.layer.create.tsx similarity index 70% rename from app/routes/resources+/api.v1+/artboard-version.layer.create.tsx rename to app/routes/resources+/api.v1+/artwork-version.layer.create.tsx index c4d0822e..68579639 100644 --- a/app/routes/resources+/api.v1+/artboard-version.layer.create.tsx +++ b/app/routes/resources+/api.v1+/artwork-version.layer.create.tsx @@ -6,20 +6,20 @@ import { AuthenticityTokenInput } from 'remix-utils/csrf/react' import { redirectBack } from 'remix-utils/redirect-back' import { useHydrated } from 'remix-utils/use-hydrated' import { PanelIconButton } from '#app/components/ui/panel-icon-button' -import { type IArtboardVersion } from '#app/models/artboard-version/artboard-version.server' -import { validateArtboardVersionNewLayerSubmission } from '#app/models/layer/layer.create.server' +import { type IArtworkVersion } from '#app/models/artwork-version/artwork-version.server' +import { validateArtworkVersionNewLayerSubmission } from '#app/models/layer/layer.create.server' import { EntityParentIdType } from '#app/schema/entity' import { validateNoJS } from '#app/schema/form-data' -import { NewArtboardVersionLayerSchema } from '#app/schema/layer-artboard-version' -import { artboardVersionLayerCreateService } from '#app/services/artboard/version/layer/create.service' +import { NewArtworkVersionLayerSchema } from '#app/schema/layer-artwork-version' +import { artworkVersionLayerCreateService } from '#app/services/artwork/version/layer/create.service' import { requireUserId } from '#app/utils/auth.server' import { useIsPending } from '#app/utils/misc' import { Routes } from '#app/utils/routes.const' // https://www.epicweb.dev/full-stack-components -const route = Routes.RESOURCES.API.V1.ARTBOARD_VERSION.LAYER.CREATE -const schema = NewArtboardVersionLayerSchema +const route = Routes.RESOURCES.API.V1.ARTWORK_VERSION.LAYER.CREATE +const schema = NewArtworkVersionLayerSchema export async function action({ request }: ActionFunctionArgs) { const userId = await requireUserId(request) @@ -27,14 +27,15 @@ export async function action({ request }: ActionFunctionArgs) { const noJS = validateNoJS({ formData }) let createSuccess = false - const { status, submission } = - await validateArtboardVersionNewLayerSubmission({ + const { status, submission } = await validateArtworkVersionNewLayerSubmission( + { userId, formData, - }) + }, + ) if (status === 'success') { - const { success } = await artboardVersionLayerCreateService({ + const { success } = await artworkVersionLayerCreateService({ userId, ...submission.value, }) @@ -55,17 +56,17 @@ export async function action({ request }: ActionFunctionArgs) { ) } -export const ArtboardVersionLayerCreate = ({ +export const ArtworkVersionLayerCreate = ({ versionId, }: { - versionId: IArtboardVersion['id'] + versionId: IArtworkVersion['id'] }) => { const fetcher = useFetcher() const lastSubmission = fetcher.data?.submission const isPending = useIsPending() let isHydrated = useHydrated() const [form] = useForm({ - id: `artboard-version-layer-create-${versionId}-new`, + id: `artwork-version-layer-create-${versionId}-new`, constraint: getFieldsetConstraint(schema), lastSubmission, }) @@ -77,7 +78,7 @@ export const ArtboardVersionLayerCreate = ({ diff --git a/app/routes/resources+/api.v1+/artboard-version.layer.delete.tsx b/app/routes/resources+/api.v1+/artwork-version.layer.delete.tsx similarity index 74% rename from app/routes/resources+/api.v1+/artboard-version.layer.delete.tsx rename to app/routes/resources+/api.v1+/artwork-version.layer.delete.tsx index 343810cb..682a07be 100644 --- a/app/routes/resources+/api.v1+/artboard-version.layer.delete.tsx +++ b/app/routes/resources+/api.v1+/artwork-version.layer.delete.tsx @@ -7,21 +7,21 @@ import { redirectBack } from 'remix-utils/redirect-back' import { useHydrated } from 'remix-utils/use-hydrated' import { Icon } from '#app/components/ui/icon' import { StatusButton } from '#app/components/ui/status-button' -import { type IArtboardVersion } from '#app/models/artboard-version/artboard-version.server' -import { validateArtboardVersionDeleteLayerSubmission } from '#app/models/layer/layer.delete.server' +import { type IArtworkVersion } from '#app/models/artwork-version/artwork-version.server' +import { validateArtworkVersionDeleteLayerSubmission } from '#app/models/layer/layer.delete.server' import { type ILayer } from '#app/models/layer/layer.server' import { EntityParentIdType } from '#app/schema/entity' import { validateNoJS } from '#app/schema/form-data' -import { DeleteArtboardVersionLayerSchema } from '#app/schema/layer-artboard-version' -import { artboardVersionLayerDeleteService } from '#app/services/artboard/version/layer/delete.service' +import { DeleteArtworkVersionLayerSchema } from '#app/schema/layer-artwork-version' +import { artworkVersionLayerDeleteService } from '#app/services/artwork/version/layer/delete.service' import { requireUserId } from '#app/utils/auth.server' import { useIsPending } from '#app/utils/misc' import { Routes } from '#app/utils/routes.const' // https://www.epicweb.dev/full-stack-components -const route = Routes.RESOURCES.API.V1.ARTBOARD_VERSION.LAYER.DELETE -const schema = DeleteArtboardVersionLayerSchema +const route = Routes.RESOURCES.API.V1.ARTWORK_VERSION.LAYER.DELETE +const schema = DeleteArtworkVersionLayerSchema export async function action({ request }: ActionFunctionArgs) { const userId = await requireUserId(request) @@ -30,13 +30,13 @@ export async function action({ request }: ActionFunctionArgs) { let deleteSuccess = false const { status, submission } = - await validateArtboardVersionDeleteLayerSubmission({ + await validateArtworkVersionDeleteLayerSubmission({ userId, formData, }) if (status === 'success') { - const { success } = await artboardVersionLayerDeleteService({ + const { success } = await artworkVersionLayerDeleteService({ userId, ...submission.value, }) @@ -57,18 +57,18 @@ export async function action({ request }: ActionFunctionArgs) { ) } -export const ArtboardVersionLayerDelete = ({ +export const ArtworkVersionLayerDelete = ({ layer, - artboardVersion, + artworkVersion, formLocation, }: { layer: ILayer - artboardVersion: IArtboardVersion + artworkVersion: IArtworkVersion formLocation?: string }) => { const layerId = layer.id - const versionId = artboardVersion.id - const formId = `artboard-version-layer-delete-${versionId}-${layerId}${ + const versionId = artworkVersion.id + const formId = `artwork-version-layer-delete-${versionId}-${layerId}${ formLocation ? `-${formLocation}` : '' }` @@ -97,7 +97,7 @@ export const ArtboardVersionLayerDelete = ({ diff --git a/app/routes/resources+/api.v1+/artboard-version.layer.update.order.tsx b/app/routes/resources+/api.v1+/artwork-version.layer.update.order.tsx similarity index 72% rename from app/routes/resources+/api.v1+/artboard-version.layer.update.order.tsx rename to app/routes/resources+/api.v1+/artwork-version.layer.update.order.tsx index fd044145..8a95ade0 100644 --- a/app/routes/resources+/api.v1+/artboard-version.layer.update.order.tsx +++ b/app/routes/resources+/api.v1+/artwork-version.layer.update.order.tsx @@ -7,22 +7,22 @@ import { redirectBack } from 'remix-utils/redirect-back' import { useHydrated } from 'remix-utils/use-hydrated' import { type IconName } from '#app/components/ui/icon' import { PanelIconButton } from '#app/components/ui/panel-icon-button' -import { type IArtboardVersion } from '#app/models/artboard-version/artboard-version.server' +import { type IArtworkVersion } from '#app/models/artwork-version/artwork-version.server' import { type ILayer } from '#app/models/layer/layer.server' -import { validateArtboardVersionReorderLayerSubmission } from '#app/models/layer-artboard-version/layer-artboard-version.update.server' +import { validateArtworkVersionReorderLayerSubmission } from '#app/models/layer-artwork-version/layer-artwork-version.update.server' import { EntityParentIdType } from '#app/schema/entity' import { validateNoJS } from '#app/schema/form-data' -import { ReorderArtboardVersionLayerSchema } from '#app/schema/layer-artboard-version' -import { artboardVersionLayerMoveDownService } from '#app/services/artboard/version/layer/move-down.service' -import { artboardVersionLayerMoveUpService } from '#app/services/artboard/version/layer/move-up.service' +import { ReorderArtworkVersionLayerSchema } from '#app/schema/layer-artwork-version' +import { artworkVersionLayerMoveDownService } from '#app/services/artwork/version/layer/move-down.service' +import { artworkVersionLayerMoveUpService } from '#app/services/artwork/version/layer/move-up.service' import { requireUserId } from '#app/utils/auth.server' import { useIsPending } from '#app/utils/misc' import { Routes } from '#app/utils/routes.const' // https://www.epicweb.dev/full-stack-components -const route = Routes.RESOURCES.API.V1.ARTBOARD_VERSION.LAYER.UPDATE.ORDER -const schema = ReorderArtboardVersionLayerSchema +const route = Routes.RESOURCES.API.V1.ARTWORK_VERSION.LAYER.UPDATE.ORDER +const schema = ReorderArtworkVersionLayerSchema export async function action({ request }: ActionFunctionArgs) { const userId = await requireUserId(request) @@ -31,7 +31,7 @@ export async function action({ request }: ActionFunctionArgs) { let updateSuccess = false const { status, submission } = - await validateArtboardVersionReorderLayerSubmission({ + await validateArtworkVersionReorderLayerSubmission({ userId, formData, }) @@ -40,14 +40,14 @@ export async function action({ request }: ActionFunctionArgs) { const { direction } = submission.value const { success } = direction === 'up' - ? await artboardVersionLayerMoveUpService({ + ? await artworkVersionLayerMoveUpService({ userId, ...submission.value, - }) - : await artboardVersionLayerMoveDownService({ + }) + : await artworkVersionLayerMoveDownService({ userId, ...submission.value, - }) + }) updateSuccess = success } @@ -65,14 +65,14 @@ export async function action({ request }: ActionFunctionArgs) { ) } -export const ArtboardVersionLayerReorder = ({ +export const ArtworkVersionLayerReorder = ({ layer, version, direction, atTopOrBottom = false, }: { layer: ILayer - version: IArtboardVersion + version: IArtworkVersion direction: 'up' | 'down' atTopOrBottom?: boolean }) => { @@ -80,7 +80,7 @@ export const ArtboardVersionLayerReorder = ({ const layerId = layer.id const icon = `chevron-${direction}` const iconText = `Move ${direction}` - const formId = `artboard-version-layer-reorder-${direction}-${versionId}-${layerId}` + const formId = `artwork-version-layer-reorder-${direction}-${versionId}-${layerId}` const fetcher = useFetcher() const lastSubmission = fetcher.data?.submission @@ -100,7 +100,7 @@ export const ArtboardVersionLayerReorder = ({ diff --git a/app/routes/resources+/api.v1+/artboard-version.layer.update.selected.tsx b/app/routes/resources+/api.v1+/artwork-version.layer.update.selected.tsx similarity index 73% rename from app/routes/resources+/api.v1+/artboard-version.layer.update.selected.tsx rename to app/routes/resources+/api.v1+/artwork-version.layer.update.selected.tsx index 663071e4..25a7596b 100644 --- a/app/routes/resources+/api.v1+/artboard-version.layer.update.selected.tsx +++ b/app/routes/resources+/api.v1+/artwork-version.layer.update.selected.tsx @@ -6,21 +6,21 @@ import { AuthenticityTokenInput } from 'remix-utils/csrf/react' import { redirectBack } from 'remix-utils/redirect-back' import { useHydrated } from 'remix-utils/use-hydrated' import { PanelIconButton } from '#app/components/ui/panel-icon-button' -import { type IArtboardVersion } from '#app/models/artboard-version/artboard-version.server' +import { type IArtworkVersion } from '#app/models/artwork-version/artwork-version.server' import { type ILayer } from '#app/models/layer/layer.server' -import { validateArtboardVersionSelectLayerSubmission } from '#app/models/layer-artboard-version/layer-artboard-version.update.server' +import { validateArtworkVersionSelectLayerSubmission } from '#app/models/layer-artwork-version/layer-artwork-version.update.server' import { EntityParentIdType } from '#app/schema/entity' import { validateNoJS } from '#app/schema/form-data' -import { SelectArtboardVersionLayerSchema } from '#app/schema/layer-artboard-version' -import { artboardVersionLayerSelectService } from '#app/services/artboard/version/layer/select.service' +import { SelectArtworkVersionLayerSchema } from '#app/schema/layer-artwork-version' +import { artworkVersionLayerSelectService } from '#app/services/artwork/version/layer/select.service' import { requireUserId } from '#app/utils/auth.server' import { useIsPending } from '#app/utils/misc' import { Routes } from '#app/utils/routes.const' // https://www.epicweb.dev/full-stack-components -const route = Routes.RESOURCES.API.V1.ARTBOARD_VERSION.LAYER.UPDATE.SELECTED -const schema = SelectArtboardVersionLayerSchema +const route = Routes.RESOURCES.API.V1.ARTWORK_VERSION.LAYER.UPDATE.SELECTED +const schema = SelectArtworkVersionLayerSchema export async function action({ request }: ActionFunctionArgs) { const userId = await requireUserId(request) @@ -29,13 +29,13 @@ export async function action({ request }: ActionFunctionArgs) { let updateSuccess = false const { status, submission } = - await validateArtboardVersionSelectLayerSubmission({ + await validateArtworkVersionSelectLayerSubmission({ userId, formData, }) if (status === 'success') { - const { success } = await artboardVersionLayerSelectService({ + const { success } = await artworkVersionLayerSelectService({ userId, ...submission.value, }) @@ -56,12 +56,12 @@ export async function action({ request }: ActionFunctionArgs) { ) } -export const ArtboardVersionLayerToggleSelected = ({ +export const ArtworkVersionLayerToggleSelected = ({ layer, version, }: { layer: ILayer - version: IArtboardVersion + version: IArtworkVersion }) => { const versionId = version.id const layerId = layer.id @@ -75,7 +75,7 @@ export const ArtboardVersionLayerToggleSelected = ({ const isPending = useIsPending() let isHydrated = useHydrated() const [form] = useForm({ - id: `artboard-version-layer-toggle-selected-${versionId}-new`, + id: `artwork-version-layer-toggle-selected-${versionId}-new`, constraint: getFieldsetConstraint(schema), lastSubmission, }) @@ -88,7 +88,7 @@ export const ArtboardVersionLayerToggleSelected = ({ diff --git a/app/routes/resources+/api.v1+/artboard-version.layer.update.visible.tsx b/app/routes/resources+/api.v1+/artwork-version.layer.update.visible.tsx similarity index 71% rename from app/routes/resources+/api.v1+/artboard-version.layer.update.visible.tsx rename to app/routes/resources+/api.v1+/artwork-version.layer.update.visible.tsx index cc61bc88..99972b8f 100644 --- a/app/routes/resources+/api.v1+/artboard-version.layer.update.visible.tsx +++ b/app/routes/resources+/api.v1+/artwork-version.layer.update.visible.tsx @@ -6,21 +6,21 @@ import { AuthenticityTokenInput } from 'remix-utils/csrf/react' import { redirectBack } from 'remix-utils/redirect-back' import { useHydrated } from 'remix-utils/use-hydrated' import { PanelIconButton } from '#app/components/ui/panel-icon-button' -import { type IArtboardVersion } from '#app/models/artboard-version/artboard-version.server' +import { type IArtworkVersion } from '#app/models/artwork-version/artwork-version.server' import { type ILayer } from '#app/models/layer/layer.server' -import { validateArtboardVersionToggleVisibeLayerSubmission } from '#app/models/layer-artboard-version/layer-artboard-version.update.server' +import { validateArtworkVersionToggleVisibeLayerSubmission } from '#app/models/layer-artwork-version/layer-artwork-version.update.server' import { EntityParentIdType } from '#app/schema/entity' import { validateNoJS } from '#app/schema/form-data' -import { ToggleVisibleArtboardVersionLayerSchema } from '#app/schema/layer-artboard-version' -import { artboardVersionLayerToggleVisibleService } from '#app/services/artboard/version/layer/toggle-visible.service' +import { ToggleVisibleArtworkVersionLayerSchema } from '#app/schema/layer-artwork-version' +import { artworkVersionLayerToggleVisibleService } from '#app/services/artwork/version/layer/toggle-visible.service' import { requireUserId } from '#app/utils/auth.server' import { useIsPending } from '#app/utils/misc' import { Routes } from '#app/utils/routes.const' // https://www.epicweb.dev/full-stack-components -const route = Routes.RESOURCES.API.V1.ARTBOARD_VERSION.LAYER.UPDATE.VISIBLE -const schema = ToggleVisibleArtboardVersionLayerSchema +const route = Routes.RESOURCES.API.V1.ARTWORK_VERSION.LAYER.UPDATE.VISIBLE +const schema = ToggleVisibleArtworkVersionLayerSchema export async function action({ request }: ActionFunctionArgs) { const userId = await requireUserId(request) @@ -29,13 +29,13 @@ export async function action({ request }: ActionFunctionArgs) { let updateSuccess = false const { status, submission } = - await validateArtboardVersionToggleVisibeLayerSubmission({ + await validateArtworkVersionToggleVisibeLayerSubmission({ userId, formData, }) if (status === 'success') { - const { success } = await artboardVersionLayerToggleVisibleService({ + const { success } = await artworkVersionLayerToggleVisibleService({ userId, ...submission.value, }) @@ -56,12 +56,12 @@ export async function action({ request }: ActionFunctionArgs) { ) } -export const ArtboardVersionLayerToggleVisible = ({ +export const ArtworkVersionLayerToggleVisible = ({ layer, version, }: { layer: ILayer - version: IArtboardVersion + version: IArtworkVersion }) => { const versionId = version.id const layerId = layer.id @@ -74,7 +74,7 @@ export const ArtboardVersionLayerToggleVisible = ({ const isPending = useIsPending() let isHydrated = useHydrated() const [form] = useForm({ - id: `artboard-version-layer-toggle-visible-${versionId}-new`, + id: `artwork-version-layer-toggle-visible-${versionId}-new`, constraint: getFieldsetConstraint(schema), lastSubmission, }) @@ -87,7 +87,7 @@ export const ArtboardVersionLayerToggleVisible = ({ diff --git a/app/routes/resources+/api.v1+/artboard-version.update.background.tsx b/app/routes/resources+/api.v1+/artwork-version.update.background.tsx similarity index 80% rename from app/routes/resources+/api.v1+/artboard-version.update.background.tsx rename to app/routes/resources+/api.v1+/artwork-version.update.background.tsx index 689bff34..59f109e0 100644 --- a/app/routes/resources+/api.v1+/artboard-version.update.background.tsx +++ b/app/routes/resources+/api.v1+/artwork-version.update.background.tsx @@ -7,17 +7,17 @@ import { AuthenticityTokenInput } from 'remix-utils/csrf/react' import { redirectBack } from 'remix-utils/redirect-back' import { useHydrated } from 'remix-utils/use-hydrated' import { Input } from '#app/components/ui/input' -import { type IArtboardVersion } from '#app/models/artboard-version/artboard-version.server' -import { validateArtboardVersionBackgroundSubmission } from '#app/models/artboard-version/artboard-version.update.server' -import { ArtboardVersionBackgroundSchema } from '#app/schema/artboard-version' +import { type IArtworkVersion } from '#app/models/artwork-version/artwork-version.server' +import { validateArtworkVersionBackgroundSubmission } from '#app/models/artwork-version/artwork-version.update.server' +import { ArtworkVersionBackgroundSchema } from '#app/schema/artwork-version' import { validateNoJS } from '#app/schema/form-data' -import { updateArtboardVersionBackgroundService } from '#app/services/artboard/version/update.service' +import { updateArtworkVersionBackgroundService } from '#app/services/artwork/version/update.service' import { requireUserId } from '#app/utils/auth.server' import { useDebounce, useIsPending } from '#app/utils/misc' import { Routes } from '#app/utils/routes.const' -const route = Routes.RESOURCES.API.V1.ARTBOARD_VERSION.UPDATE.BACKGROUND -const schema = ArtboardVersionBackgroundSchema +const route = Routes.RESOURCES.API.V1.ARTWORK_VERSION.UPDATE.BACKGROUND +const schema = ArtworkVersionBackgroundSchema export async function action({ request }: ActionFunctionArgs) { const userId = await requireUserId(request) @@ -25,13 +25,13 @@ export async function action({ request }: ActionFunctionArgs) { const noJS = validateNoJS({ formData }) const { status, submission } = - await validateArtboardVersionBackgroundSubmission({ + await validateArtworkVersionBackgroundSubmission({ userId, formData, }) let updateSucess = false if (status === 'success') { - const { success } = await updateArtboardVersionBackgroundService({ + const { success } = await updateArtworkVersionBackgroundService({ ...submission.value, }) updateSucess = success @@ -49,13 +49,13 @@ export async function action({ request }: ActionFunctionArgs) { ) } -export const ArtboardVersionBackground = ({ +export const ArtworkVersionBackground = ({ version, }: { - version: IArtboardVersion + version: IArtworkVersion }) => { const versionId = version.id - const formId = `artboard-version-update-background-${versionId}` + const formId = `artwork-version-update-background-${versionId}` const fetcher = useFetcher() const lastSubmission = fetcher.data?.submission diff --git a/app/routes/resources+/api.v1+/artboard-version.update.height.tsx b/app/routes/resources+/api.v1+/artwork-version.update.height.tsx similarity index 80% rename from app/routes/resources+/api.v1+/artboard-version.update.height.tsx rename to app/routes/resources+/api.v1+/artwork-version.update.height.tsx index 660192ad..ac0026df 100644 --- a/app/routes/resources+/api.v1+/artboard-version.update.height.tsx +++ b/app/routes/resources+/api.v1+/artwork-version.update.height.tsx @@ -9,30 +9,30 @@ import { useHydrated } from 'remix-utils/use-hydrated' import { Icon } from '#app/components/ui/icon' import { Input } from '#app/components/ui/input' import { Label } from '#app/components/ui/label' -import { type IArtboardVersion } from '#app/models/artboard-version/artboard-version.server' -import { validateArtboardVersionHeightSubmission } from '#app/models/artboard-version/artboard-version.update.server' -import { ArtboardVersionHeightSchema } from '#app/schema/artboard-version' +import { type IArtworkVersion } from '#app/models/artwork-version/artwork-version.server' +import { validateArtworkVersionHeightSubmission } from '#app/models/artwork-version/artwork-version.update.server' +import { ArtworkVersionHeightSchema } from '#app/schema/artwork-version' import { validateNoJS } from '#app/schema/form-data' -import { updateArtboardVersionHeightService } from '#app/services/artboard/version/update.service' +import { updateArtworkVersionHeightService } from '#app/services/artwork/version/update.service' import { requireUserId } from '#app/utils/auth.server' import { useDebounce, useIsPending } from '#app/utils/misc' import { Routes } from '#app/utils/routes.const' -const route = Routes.RESOURCES.API.V1.ARTBOARD_VERSION.UPDATE.WIDTH -const schema = ArtboardVersionHeightSchema +const route = Routes.RESOURCES.API.V1.ARTWORK_VERSION.UPDATE.WIDTH +const schema = ArtworkVersionHeightSchema export async function action({ request }: ActionFunctionArgs) { const userId = await requireUserId(request) const formData = await request.formData() const noJS = validateNoJS({ formData }) - const { status, submission } = await validateArtboardVersionHeightSubmission({ + const { status, submission } = await validateArtworkVersionHeightSubmission({ userId, formData, }) let updateSucess = false if (status === 'success') { - const { success } = await updateArtboardVersionHeightService({ + const { success } = await updateArtworkVersionHeightService({ ...submission.value, }) updateSucess = success @@ -50,13 +50,13 @@ export async function action({ request }: ActionFunctionArgs) { ) } -export const ArtboardVersionHeight = ({ +export const ArtworkVersionHeight = ({ version, }: { - version: IArtboardVersion + version: IArtworkVersion }) => { const versionId = version.id - const formId = `artboard-version-update-height-${versionId}` + const formId = `artwork-version-update-height-${versionId}` const fetcher = useFetcher() const lastSubmission = fetcher.data?.submission diff --git a/app/routes/resources+/api.v1+/artboard-version.update.width.tsx b/app/routes/resources+/api.v1+/artwork-version.update.width.tsx similarity index 81% rename from app/routes/resources+/api.v1+/artboard-version.update.width.tsx rename to app/routes/resources+/api.v1+/artwork-version.update.width.tsx index 8740d003..32142ff9 100644 --- a/app/routes/resources+/api.v1+/artboard-version.update.width.tsx +++ b/app/routes/resources+/api.v1+/artwork-version.update.width.tsx @@ -9,30 +9,30 @@ import { useHydrated } from 'remix-utils/use-hydrated' import { Icon } from '#app/components/ui/icon' import { Input } from '#app/components/ui/input' import { Label } from '#app/components/ui/label' -import { type IArtboardVersion } from '#app/models/artboard-version/artboard-version.server' -import { validateArtboardVersionWidthSubmission } from '#app/models/artboard-version/artboard-version.update.server' -import { ArtboardVersionWidthSchema } from '#app/schema/artboard-version' +import { type IArtworkVersion } from '#app/models/artwork-version/artwork-version.server' +import { validateArtworkVersionWidthSubmission } from '#app/models/artwork-version/artwork-version.update.server' +import { ArtworkVersionWidthSchema } from '#app/schema/artwork-version' import { validateNoJS } from '#app/schema/form-data' -import { updateArtboardVersionWidthService } from '#app/services/artboard/version/update.service' +import { updateArtworkVersionWidthService } from '#app/services/artwork/version/update.service' import { requireUserId } from '#app/utils/auth.server' import { useDebounce, useIsPending } from '#app/utils/misc' import { Routes } from '#app/utils/routes.const' -const route = Routes.RESOURCES.API.V1.ARTBOARD_VERSION.UPDATE.WIDTH -const schema = ArtboardVersionWidthSchema +const route = Routes.RESOURCES.API.V1.ARTWORK_VERSION.UPDATE.WIDTH +const schema = ArtworkVersionWidthSchema export async function action({ request }: ActionFunctionArgs) { const userId = await requireUserId(request) const formData = await request.formData() const noJS = validateNoJS({ formData }) - const { status, submission } = await validateArtboardVersionWidthSubmission({ + const { status, submission } = await validateArtworkVersionWidthSubmission({ userId, formData, }) let updateSucess = false if (status === 'success') { - const { success } = await updateArtboardVersionWidthService({ + const { success } = await updateArtworkVersionWidthService({ ...submission.value, }) updateSucess = success @@ -50,13 +50,13 @@ export async function action({ request }: ActionFunctionArgs) { ) } -export const ArtboardVersionWidth = ({ +export const ArtworkVersionWidth = ({ version, }: { - version: IArtboardVersion + version: IArtworkVersion }) => { const versionId = version.id - const formId = `artboard-version-update-width-${versionId}` + const formId = `artwork-version-update-width-${versionId}` const fetcher = useFetcher() const lastSubmission = fetcher.data?.submission diff --git a/app/routes/resources+/api.v1+/layer.design.create.tsx b/app/routes/resources+/api.v1+/layer.design.create.tsx index 15b6098b..cbb74f86 100644 --- a/app/routes/resources+/api.v1+/layer.design.create.tsx +++ b/app/routes/resources+/api.v1+/layer.design.create.tsx @@ -67,7 +67,7 @@ export const LayerDesignCreate = ({ const isPending = useIsPending() let isHydrated = useHydrated() const [form] = useForm({ - id: `artboard-layer-create-${layerId}-new`, + id: `artwork-layer-create-${layerId}-new`, constraint: getFieldsetConstraint(schema), lastSubmission, }) diff --git a/app/routes/resources+/api.v1+/layer.design.update.visible.tsx b/app/routes/resources+/api.v1+/layer.design.update.visible.tsx index fd211f31..447e14ae 100644 --- a/app/routes/resources+/api.v1+/layer.design.update.visible.tsx +++ b/app/routes/resources+/api.v1+/layer.design.update.visible.tsx @@ -74,7 +74,7 @@ export const LayerDesignToggleVisible = ({ const isPending = useIsPending() let isHydrated = useHydrated() const [form] = useForm({ - id: `artboard-layer-design-toggle-visible-${layerId}-${designId}`, + id: `artwork-layer-design-toggle-visible-${layerId}-${designId}`, constraint: getFieldsetConstraint(schema), lastSubmission, }) diff --git a/app/routes/sketch+/index.tsx b/app/routes/sketch+/index.tsx index 6b1d7231..a79fdf3c 100644 --- a/app/routes/sketch+/index.tsx +++ b/app/routes/sketch+/index.tsx @@ -8,7 +8,7 @@ import { DashboardContentHeading2, } from '#app/components/layout' import { DashboardEntityCards } from '#app/components/templates' -import { getProjectsWithArtboards } from '#app/models/project/project.get.server' +import { getProjectsWithArtworks } from '#app/models/project/project.get.server' import { getUserBasic } from '#app/models/user/user.get.server' import { requireUserId } from '#app/utils/auth.server' import { useUser } from '#app/utils/user' @@ -19,7 +19,7 @@ export async function loader({ params, request }: LoaderFunctionArgs) { const owner = await getUserBasic({ where: { id: userId } }) invariantResponse(owner, 'Owner not found', { status: 404 }) - const projects = await getProjectsWithArtboards({ + const projects = await getProjectsWithArtworks({ where: { ownerId: userId }, }) return json({ projects }) diff --git a/app/routes/sketch+/projects+/$projectSlug_+/artboards+/$artboardSlug+/__components/sidebars.panel.artboard-version.frame.tsx b/app/routes/sketch+/projects+/$projectSlug_+/artboards+/$artboardSlug+/__components/sidebars.panel.artboard-version.frame.tsx deleted file mode 100644 index 26bcd201..00000000 --- a/app/routes/sketch+/projects+/$projectSlug_+/artboards+/$artboardSlug+/__components/sidebars.panel.artboard-version.frame.tsx +++ /dev/null @@ -1,30 +0,0 @@ -import { - SidebarPanel, - SidebarPanelHeader, - SidebarPanelRow, - SidebarPanelRowContainer, - SidebarPanelRowValuesContainer, -} from '#app/components/templates' -import { type IArtboardVersionWithDesignsAndLayers } from '#app/models/artboard-version/artboard-version.server' -import { ArtboardVersionHeight } from '#app/routes/resources+/api.v1+/artboard-version.update.height' -import { ArtboardVersionWidth } from '#app/routes/resources+/api.v1+/artboard-version.update.width' - -export const PanelArtboardVersionFrame = ({ - version, -}: { - version: IArtboardVersionWithDesignsAndLayers -}) => { - return ( - - - - - - - - - - - - ) -} diff --git a/app/routes/sketch+/projects+/$projectSlug_+/artboards+/$artboardSlug+/__components/sidebars.panel.artboard-version.layers.tsx b/app/routes/sketch+/projects+/$projectSlug_+/artboards+/$artboardSlug+/__components/sidebars.panel.artboard-version.layers.tsx deleted file mode 100644 index 2fda8a74..00000000 --- a/app/routes/sketch+/projects+/$projectSlug_+/artboards+/$artboardSlug+/__components/sidebars.panel.artboard-version.layers.tsx +++ /dev/null @@ -1,34 +0,0 @@ -import { DashboardEntityPanel } from '#app/components/templates/panel/dashboard-entity-panel' -import { type IArtboardVersionWithDesignsAndLayers } from '#app/models/artboard-version/artboard-version.server' -import { type ILayerWithDesigns } from '#app/models/layer/layer.server' -import { DashboardPanelCreateArtboardVersionLayerStrategy } from '#app/strategies/component/dashboard-panel/create-entity.strategy' -import { DashboardPanelArtboardVersionLayerActionStrategy } from '#app/strategies/component/dashboard-panel/entity-action/entity-action' -import { DashboardPanelUpdateArtboardVersionLayerTypeOrderStrategy } from '#app/strategies/component/dashboard-panel/update-entity-order.strategy' -import { orderLinkedItems } from '#app/utils/linked-list.utils' - -export const PanelArtboardVersionLayers = ({ - version, -}: { - version: IArtboardVersionWithDesignsAndLayers -}) => { - const orderedLayers = orderLinkedItems(version.layers) - - const strategyEntityNew = - new DashboardPanelCreateArtboardVersionLayerStrategy() - const strategyReorder = - new DashboardPanelUpdateArtboardVersionLayerTypeOrderStrategy() - const strategyActions = new DashboardPanelArtboardVersionLayerActionStrategy() - - return ( -
- -
- ) -} diff --git a/app/routes/sketch+/projects+/$projectSlug_+/artboards+/$artboardSlug+/__components/sidebars.panel.artboard-version.tsx b/app/routes/sketch+/projects+/$projectSlug_+/artboards+/$artboardSlug+/__components/sidebars.panel.artboard-version.tsx deleted file mode 100644 index d827d0cb..00000000 --- a/app/routes/sketch+/projects+/$projectSlug_+/artboards+/$artboardSlug+/__components/sidebars.panel.artboard-version.tsx +++ /dev/null @@ -1,18 +0,0 @@ -import { type IArtboardVersionWithDesignsAndLayers } from '#app/models/artboard-version/artboard-version.server' -import { PanelArtboardVersionBackground } from './sidebars.panel.artboard-version.background' -import { PanelArtboardVersionFrame } from './sidebars.panel.artboard-version.frame' -import { PanelArtboardVersionDesigns } from './sidebars.panel.designs.artboard-version' - -export const PanelArtboardVersion = ({ - version, -}: { - version: IArtboardVersionWithDesignsAndLayers -}) => { - return ( -
- - - -
- ) -} diff --git a/app/routes/sketch+/projects+/$projectSlug_+/artboards+/$artboardSlug+/__components/sidebars.panel.designs.artboard-version.tsx b/app/routes/sketch+/projects+/$projectSlug_+/artboards+/$artboardSlug+/__components/sidebars.panel.designs.artboard-version.tsx deleted file mode 100644 index 565dd061..00000000 --- a/app/routes/sketch+/projects+/$projectSlug_+/artboards+/$artboardSlug+/__components/sidebars.panel.designs.artboard-version.tsx +++ /dev/null @@ -1,27 +0,0 @@ -import { type IArtboardVersionWithDesignsAndLayers } from '#app/models/artboard-version/artboard-version.server' -import { DashboardPanelCreateArtboardVersionDesignTypeStrategy } from '#app/strategies/component/dashboard-panel/create-entity.strategy' -import { DashboardPanelArtboardVersionDesignActionStrategy } from '#app/strategies/component/dashboard-panel/entity-action/entity-action' -import { DashboardPanelUpdateArtboardVersionDesignTypeOrderStrategy } from '#app/strategies/component/dashboard-panel/update-entity-order.strategy' -import { PanelDesigns } from './sidebars.panel.designs' - -export const PanelArtboardVersionDesigns = ({ - version, -}: { - version: IArtboardVersionWithDesignsAndLayers -}) => { - const strategyEntityNew = - new DashboardPanelCreateArtboardVersionDesignTypeStrategy() - const strategyReorder = - new DashboardPanelUpdateArtboardVersionDesignTypeOrderStrategy() - const strategyActions = - new DashboardPanelArtboardVersionDesignActionStrategy() - - return ( - - ) -} diff --git a/app/routes/sketch+/projects+/$projectSlug_+/artboards+/$artboardSlug+/$branchSlug.$versionSlug.tsx b/app/routes/sketch+/projects+/$projectSlug_+/artworks+/$artworkSlug+/$branchSlug.$versionSlug.tsx similarity index 57% rename from app/routes/sketch+/projects+/$projectSlug_+/artboards+/$artboardSlug+/$branchSlug.$versionSlug.tsx rename to app/routes/sketch+/projects+/$projectSlug_+/artworks+/$artworkSlug+/$branchSlug.$versionSlug.tsx index 2b5d6878..28053f1c 100644 --- a/app/routes/sketch+/projects+/$projectSlug_+/artboards+/$artboardSlug+/$branchSlug.$versionSlug.tsx +++ b/app/routes/sketch+/projects+/$projectSlug_+/artworks+/$artworkSlug+/$branchSlug.$versionSlug.tsx @@ -12,37 +12,37 @@ import { DashboardContent, DashboardContentWrapper, } from '#app/components/layout' -import { getArtboard } from '#app/models/artboard/artboard.get.server' -import { getArtboardBranch } from '#app/models/artboard-branch/artboard-branch.get.server' -import { getArtboardVersionWithDesignsAndLayers } from '#app/models/artboard-version/artboard-version.get.server' +import { getArtwork } from '#app/models/artwork/artwork.get.server' +import { getArtworkBranch } from '#app/models/artwork-branch/artwork-branch.get.server' +import { getArtworkVersionWithDesignsAndLayers } from '#app/models/artwork-version/artwork-version.get.server' import { getUserBasic } from '#app/models/user/user.get.server' -import { artboardVersionGeneratorBuildService } from '#app/services/artboard/version/generator/build.service' +import { artworkVersionGeneratorBuildService } from '#app/services/artwork/version/generator/build.service' import { requireUserId } from '#app/utils/auth.server' import { routeLoaderMetaData } from '#app/utils/matches' import { projectLoaderRoute } from '../route' -import { artboardBranchLoaderRoute } from './$branchSlug' +import { artworkBranchLoaderRoute } from './$branchSlug' import { CanvasContent } from './__components/canvas-content' -import { ArtboardHeader } from './__components/header.artboard' +import { ArtworkHeader } from './__components/header.artwork' import { SidebarLeft, SidebarRight } from './__components/sidebars' -import { artboardLoaderRoute } from './route' +import { artworkLoaderRoute } from './route' -export const artboardVersionLoaderRoute = - 'routes/sketch+/projects+/$projectSlug_+/artboards+/$artboardSlug+/$branchSlug.$versionSlug' +export const artworkVersionLoaderRoute = + 'routes/sketch+/projects+/$projectSlug_+/artworks+/$artworkSlug+/$branchSlug.$versionSlug' export async function loader({ params, request }: LoaderFunctionArgs) { const userId = await requireUserId(request) const owner = await getUserBasic({ where: { id: userId } }) invariantResponse(owner, 'Owner not found', { status: 404 }) // https://sergiodxa.com/tutorials/avoid-waterfalls-of-queries-in-remix-loaders - const artboard = await getArtboard({ - where: { slug: params.artboardSlug, ownerId: owner.id }, + const artwork = await getArtwork({ + where: { slug: params.artworkSlug, ownerId: owner.id }, }) - invariantResponse(artboard, 'Artboard not found', { status: 404 }) + invariantResponse(artwork, 'Artwork not found', { status: 404 }) - const branch = await getArtboardBranch({ - where: { artboardId: artboard.id, slug: params.branchSlug }, + const branch = await getArtworkBranch({ + where: { artworkId: artwork.id, slug: params.branchSlug }, }) - invariantResponse(branch, 'Artboard Branch not found', { status: 404 }) + invariantResponse(branch, 'Artwork Branch not found', { status: 404 }) const { versionSlug } = params const where = @@ -50,17 +50,17 @@ export async function loader({ params, request }: LoaderFunctionArgs) { ? { ownerId: owner.id, branchId: branch.id, nextId: null } : { ownerId: owner.id, branchId: branch.id, slug: versionSlug } - const version = await getArtboardVersionWithDesignsAndLayers({ where }) - invariantResponse(version, 'Artboard Version not found', { status: 404 }) + const version = await getArtworkVersionWithDesignsAndLayers({ where }) + invariantResponse(version, 'Artwork Version not found', { status: 404 }) const selectedLayer = version.layers.find(layer => layer.selected) - const generator = await artboardVersionGeneratorBuildService({ version }) + const generator = await artworkVersionGeneratorBuildService({ version }) return json({ version, selectedLayer, generator }) } -export default function SketchProjectArtboardBranchVersionRoute() { +export default function SketchProjectArtworkBranchVersionRoute() { const data = useLoaderData() const { version, selectedLayer, generator } = data @@ -68,8 +68,8 @@ export default function SketchProjectArtboardBranchVersionRoute() { // the component names might need re-thinking, but works return ( - - + + @@ -86,22 +86,22 @@ export const meta: MetaFunction = ({ params, matches }) => { const projectData = routeLoaderMetaData(matches, projectLoaderRoute) const projectName = projectData?.project.name ?? params.projectSlug - const artboardData = routeLoaderMetaData(matches, artboardLoaderRoute) - const artboardName = artboardData?.artboard.name ?? params.artboardSlug + const artworkData = routeLoaderMetaData(matches, artworkLoaderRoute) + const artworkName = artworkData?.artwork.name ?? params.artworkSlug - const branchData = routeLoaderMetaData(matches, artboardBranchLoaderRoute) + const branchData = routeLoaderMetaData(matches, artworkBranchLoaderRoute) const branchName = branchData?.branch.name ?? params.branchSlug - const versionData = routeLoaderMetaData(matches, artboardVersionLoaderRoute) + const versionData = routeLoaderMetaData(matches, artworkVersionLoaderRoute) const versionName = versionData?.version.name ?? params.versionSlug return [ { - title: `${artboardName} | ${branchName} | ${versionName} | ${projectName} | Sketch | XYZ`, + title: `${artworkName} | ${branchName} | ${versionName} | ${projectName} | Sketch | XYZ`, }, { name: 'description', - content: `Sketch dashboard for XYZ artboard project: ${artboardName} (${projectName})`, + content: `Sketch dashboard for XYZ artwork project: ${artworkName} (${projectName})`, }, ] } diff --git a/app/routes/sketch+/projects+/$projectSlug_+/artboards+/$artboardSlug+/$branchSlug._index.tsx b/app/routes/sketch+/projects+/$projectSlug_+/artworks+/$artworkSlug+/$branchSlug._index.tsx similarity index 72% rename from app/routes/sketch+/projects+/$projectSlug_+/artboards+/$artboardSlug+/$branchSlug._index.tsx rename to app/routes/sketch+/projects+/$projectSlug_+/artworks+/$artworkSlug+/$branchSlug._index.tsx index 93c69da1..79b1bda2 100644 --- a/app/routes/sketch+/projects+/$projectSlug_+/artboards+/$artboardSlug+/$branchSlug._index.tsx +++ b/app/routes/sketch+/projects+/$projectSlug_+/artworks+/$artworkSlug+/$branchSlug._index.tsx @@ -1,12 +1,12 @@ import { invariantResponse } from '@epic-web/invariant' import { type LoaderFunctionArgs, redirect } from '@remix-run/node' import { GeneralErrorBoundary } from '#app/components/error-boundary' -import { getArtboardBranchWithVersions } from '#app/models/artboard-branch/artboard-branch.get.server' +import { getArtworkBranchWithVersions } from '#app/models/artwork-branch/artwork-branch.get.server' import { getUserBasic } from '#app/models/user/user.get.server' import { requireUserId } from '#app/utils/auth.server' -export const artboardBranchLoaderRoute = - 'routes/sketch+/projects+/$projectSlug_+/artboards+/$artboardSlug_+/$branchSlug_+/route' +export const artworkBranchLoaderRoute = + 'routes/sketch+/projects+/$projectSlug_+/artworks+/$artworkSlug_+/$branchSlug_+/route' export async function loader({ params, request }: LoaderFunctionArgs) { const userId = await requireUserId(request) const owner = await getUserBasic({ where: { id: userId } }) @@ -14,10 +14,10 @@ export async function loader({ params, request }: LoaderFunctionArgs) { // https://sergiodxa.com/tutorials/avoid-waterfalls-of-queries-in-remix-loaders const { branchSlug } = params - const branch = await getArtboardBranchWithVersions({ + const branch = await getArtworkBranchWithVersions({ where: { slug: branchSlug, ownerId: owner.id }, }) - invariantResponse(branch, 'Artboard Branch not found', { status: 404 }) + invariantResponse(branch, 'Artwork Branch not found', { status: 404 }) // simply redirect to latest version // when the branch path is visited @@ -35,7 +35,7 @@ export function ErrorBoundary() { statusHandlers={{ 404: ({ params }) => { return ( -

No artboard branch with the name "{params.branchSlug}" exists

+

No artwork branch with the name "{params.branchSlug}" exists

) }, }} diff --git a/app/routes/sketch+/projects+/$projectSlug_+/artboards+/$artboardSlug+/$branchSlug.tsx b/app/routes/sketch+/projects+/$projectSlug_+/artworks+/$artworkSlug+/$branchSlug.tsx similarity index 56% rename from app/routes/sketch+/projects+/$projectSlug_+/artboards+/$artboardSlug+/$branchSlug.tsx rename to app/routes/sketch+/projects+/$projectSlug_+/artworks+/$artworkSlug+/$branchSlug.tsx index 7941189d..9e26f585 100644 --- a/app/routes/sketch+/projects+/$projectSlug_+/artboards+/$artboardSlug+/$branchSlug.tsx +++ b/app/routes/sketch+/projects+/$projectSlug_+/artworks+/$artworkSlug+/$branchSlug.tsx @@ -5,31 +5,31 @@ import { type MetaFunction, } from '@remix-run/node' import { GeneralErrorBoundary } from '#app/components/error-boundary' -import { getArtboard } from '#app/models/artboard/artboard.get.server' -import { getArtboardBranchWithVersions } from '#app/models/artboard-branch/artboard-branch.get.server' +import { getArtwork } from '#app/models/artwork/artwork.get.server' +import { getArtworkBranchWithVersions } from '#app/models/artwork-branch/artwork-branch.get.server' import { getUserBasic } from '#app/models/user/user.get.server' import { requireUserId } from '#app/utils/auth.server' import { routeLoaderMetaData } from '#app/utils/matches' import { projectLoaderRoute } from '../route' -import { artboardLoaderRoute } from './route' +import { artworkLoaderRoute } from './route' -export const artboardBranchLoaderRoute = - 'routes/sketch+/projects+/$projectSlug_+/artboards+/$artboardSlug+/$branchSlug' +export const artworkBranchLoaderRoute = + 'routes/sketch+/projects+/$projectSlug_+/artworks+/$artworkSlug+/$branchSlug' export async function loader({ params, request }: LoaderFunctionArgs) { const userId = await requireUserId(request) const owner = await getUserBasic({ where: { id: userId } }) invariantResponse(owner, 'Owner not found', { status: 404 }) // https://sergiodxa.com/tutorials/avoid-waterfalls-of-queries-in-remix-loaders - const artboard = await getArtboard({ - where: { slug: params.artboardSlug, ownerId: owner.id }, + const artwork = await getArtwork({ + where: { slug: params.artworkSlug, ownerId: owner.id }, }) - invariantResponse(artboard, 'Artboard not found', { status: 404 }) + invariantResponse(artwork, 'Artwork not found', { status: 404 }) - const branch = await getArtboardBranchWithVersions({ - where: { artboardId: artboard.id, slug: params.branchSlug }, + const branch = await getArtworkBranchWithVersions({ + where: { artworkId: artwork.id, slug: params.branchSlug }, }) - invariantResponse(branch, 'Artboard Branch not found', { status: 404 }) + invariantResponse(branch, 'Artwork Branch not found', { status: 404 }) // ensure that data is loaded from the route // redirect on index.tsx @@ -40,18 +40,18 @@ export const meta: MetaFunction = ({ params, matches }) => { const projectData = routeLoaderMetaData(matches, projectLoaderRoute) const projectName = projectData?.project.name ?? params.projectSlug - const artboardData = routeLoaderMetaData(matches, artboardLoaderRoute) - const artboardName = artboardData?.artboard.name ?? params.artboardSlug + const artworkData = routeLoaderMetaData(matches, artworkLoaderRoute) + const artworkName = artworkData?.artwork.name ?? params.artworkSlug - const branchData = routeLoaderMetaData(matches, artboardBranchLoaderRoute) + const branchData = routeLoaderMetaData(matches, artworkBranchLoaderRoute) const branchName = branchData?.branch.name ?? params.branchSlug return [ { - title: `${artboardName} | ${branchName} | ${projectName} | Sketch | XYZ`, + title: `${artworkName} | ${branchName} | ${projectName} | Sketch | XYZ`, }, { name: 'description', - content: `Sketch dashboard for XYZ artboard project: ${artboardName} (${projectName})`, + content: `Sketch dashboard for XYZ artwork project: ${artworkName} (${projectName})`, }, ] } diff --git a/app/routes/sketch+/projects+/$projectSlug_+/artboards+/$artboardSlug+/__components/canvas-content.tsx b/app/routes/sketch+/projects+/$projectSlug_+/artworks+/$artworkSlug+/__components/canvas-content.tsx similarity index 77% rename from app/routes/sketch+/projects+/$projectSlug_+/artboards+/$artboardSlug+/__components/canvas-content.tsx rename to app/routes/sketch+/projects+/$projectSlug_+/artworks+/$artworkSlug+/__components/canvas-content.tsx index b6f79be6..e44f2173 100644 --- a/app/routes/sketch+/projects+/$projectSlug_+/artboards+/$artboardSlug+/__components/canvas-content.tsx +++ b/app/routes/sketch+/projects+/$projectSlug_+/artworks+/$artworkSlug+/__components/canvas-content.tsx @@ -10,7 +10,7 @@ import { type NodeProps, } from 'reactflow' import { ContainerIndex } from '#app/components/shared' -import { type IArtboardVersionGenerator } from '#app/definitions/artboard-generator' +import { type IArtworkVersionGenerator } from '#app/definitions/artwork-generator' import { canvasDrawService } from '#app/services/canvas/draw.service' import 'reactflow/dist/style.css' @@ -19,12 +19,12 @@ const initialNodes = [ id: 'a', type: 'canvas', position: { x: 0, y: 0 }, - data: { label: 'artboard-canvas' }, + data: { label: 'artwork-canvas' }, }, ] satisfies Node[] -const ArtboardCanvas = memo( - ({ generator }: { generator: IArtboardVersionGenerator }) => { +const ArtworkCanvas = memo( + ({ generator }: { generator: IArtworkVersionGenerator }) => { const { width, height, background } = generator.settings const canvasRef = useRef(null) @@ -46,19 +46,19 @@ const ArtboardCanvas = memo( ) }, ) -ArtboardCanvas.displayName = 'ArtboardCanvas' +ArtworkCanvas.displayName = 'ArtworkCanvas' export const CanvasContent = ({ generator, }: { - generator: IArtboardVersionGenerator + generator: IArtworkVersionGenerator }) => { const [nodes, , onNodesChange] = useNodesState(initialNodes) const nodeTypes = useMemo( () => ({ canvas: (props: NodeProps) => ( - + ), }), [generator], @@ -67,7 +67,7 @@ export const CanvasContent = ({ if (!generator.success) { return ( - {generator?.message || 'Artboard generator unsuccessful'} + {generator?.message || 'Artwork generator unsuccessful'} ) } diff --git a/app/routes/sketch+/projects+/$projectSlug_+/artboards+/$artboardSlug+/__components/header.artboard.button-group.tsx b/app/routes/sketch+/projects+/$projectSlug_+/artworks+/$artworkSlug+/__components/header.artwork.button-group.tsx similarity index 56% rename from app/routes/sketch+/projects+/$projectSlug_+/artboards+/$artboardSlug+/__components/header.artboard.button-group.tsx rename to app/routes/sketch+/projects+/$projectSlug_+/artworks+/$artworkSlug+/__components/header.artwork.button-group.tsx index 53dc3091..55492d0e 100644 --- a/app/routes/sketch+/projects+/$projectSlug_+/artboards+/$artboardSlug+/__components/header.artboard.button-group.tsx +++ b/app/routes/sketch+/projects+/$projectSlug_+/artworks+/$artworkSlug+/__components/header.artwork.button-group.tsx @@ -1,24 +1,24 @@ import { memo } from 'react' import { DashboardNav, NavbarButtonGroup } from '#app/components/layout' import { TooltipIconLink } from '#app/components/templates/navbar' -import { type IArtboard } from '#app/models/artboard/artboard.server' -import { type IArtboardBranch } from '#app/models/artboard-branch/artboard-branch.server' -import { type IArtboardVersion } from '#app/models/artboard-version/artboard-version.server' -import { ArtboardBranchCreate } from '#app/routes/resources+/api.v1+/artboard-branch.create' -import { ArtboardVersionCreate } from '#app/routes/resources+/api.v1+/artboard-version.create' +import { type IArtwork } from '#app/models/artwork/artwork.server' +import { type IArtworkBranch } from '#app/models/artwork-branch/artwork-branch.server' +import { type IArtworkVersion } from '#app/models/artwork-version/artwork-version.server' +import { ArtworkBranchCreate } from '#app/routes/resources+/api.v1+/artwork-branch.create' +import { ArtworkVersionCreate } from '#app/routes/resources+/api.v1+/artwork-version.create' import { EntityParentIdType } from '#app/schema/entity' import { useUser } from '#app/utils/user' export const NavActionsButtonGroup = memo( ({ - artboard, + artwork, branch, version, onLatestVersion, }: { - artboard: IArtboard - branch: IArtboardBranch - version: IArtboardVersion + artwork: IArtwork + branch: IArtworkBranch + version: IArtworkVersion onLatestVersion: boolean }) => { const user = useUser() @@ -32,24 +32,24 @@ export const NavActionsButtonGroup = memo( {/* info a, ab, abv */} {/* fork ab */} {/* merge ab */} - - diff --git a/app/routes/sketch+/projects+/$projectSlug_+/artboards+/$artboardSlug+/__components/header.artboard.comboboxes.tsx b/app/routes/sketch+/projects+/$projectSlug_+/artworks+/$artworkSlug+/__components/header.artwork.comboboxes.tsx similarity index 56% rename from app/routes/sketch+/projects+/$projectSlug_+/artboards+/$artboardSlug+/__components/header.artboard.comboboxes.tsx rename to app/routes/sketch+/projects+/$projectSlug_+/artworks+/$artworkSlug+/__components/header.artwork.comboboxes.tsx index e2f5e8c7..0525c488 100644 --- a/app/routes/sketch+/projects+/$projectSlug_+/artboards+/$artboardSlug+/__components/header.artboard.comboboxes.tsx +++ b/app/routes/sketch+/projects+/$projectSlug_+/artworks+/$artworkSlug+/__components/header.artwork.comboboxes.tsx @@ -2,44 +2,44 @@ import { memo } from 'react' import { DashboardNav } from '#app/components/layout' import { ComboboxNav } from '#app/components/templates/combobox' import { TooltipIcon, TooltipIconLink } from '#app/components/templates/navbar' -import { type IArtboardWithBranchesAndVersions } from '#app/models/artboard/artboard.server' -import { type IArtboardBranchWithVersions } from '#app/models/artboard-branch/artboard-branch.server' -import { type IArtboardVersion } from '#app/models/artboard-version/artboard-version.server' -import { type IProjectWithArtboards } from '#app/models/project/project.server' +import { type IArtworkWithBranchesAndVersions } from '#app/models/artwork/artwork.server' +import { type IArtworkBranchWithVersions } from '#app/models/artwork-branch/artwork-branch.server' +import { type IArtworkVersion } from '#app/models/artwork-version/artwork-version.server' +import { type IProjectWithArtworks } from '#app/models/project/project.server' export const NavComboboxes = memo( ({ project, - artboard, + artwork, branch, version, onLatestVersion, }: { - project: IProjectWithArtboards - artboard: IArtboardWithBranchesAndVersions - branch: IArtboardBranchWithVersions - version: IArtboardVersion + project: IProjectWithArtworks + artwork: IArtworkWithBranchesAndVersions + branch: IArtworkBranchWithVersions + version: IArtworkVersion onLatestVersion: boolean }) => { - const baseUrl = `/sketch/projects/${project.slug}/artboards` + const baseUrl = `/sketch/projects/${project.slug}/artworks` return ( {branch.description && ( {!onLatestVersion && ( // this should be displayed when: - // - creating a new artboard version - // - navigating to a previous artboard version + // - creating a new artwork version + // - navigating to a previous artwork version )} diff --git a/app/routes/sketch+/projects+/$projectSlug_+/artboards+/$artboardSlug+/__components/header.artboard.tsx b/app/routes/sketch+/projects+/$projectSlug_+/artworks+/$artworkSlug+/__components/header.artwork.tsx similarity index 56% rename from app/routes/sketch+/projects+/$projectSlug_+/artboards+/$artboardSlug+/__components/header.artboard.tsx rename to app/routes/sketch+/projects+/$projectSlug_+/artworks+/$artworkSlug+/__components/header.artwork.tsx index bac82c04..7ffbeb0f 100644 --- a/app/routes/sketch+/projects+/$projectSlug_+/artboards+/$artboardSlug+/__components/header.artboard.tsx +++ b/app/routes/sketch+/projects+/$projectSlug_+/artworks+/$artworkSlug+/__components/header.artwork.tsx @@ -2,21 +2,21 @@ import { useMatches } from '@remix-run/react' import { useCallback } from 'react' import { DashboardHeader } from '#app/components/layout' import { useRouteLoaderMatchData } from '#app/utils/matches' -import { artboardBranchLoaderRoute } from '../$branchSlug' -import { artboardVersionLoaderRoute } from '../$branchSlug.$versionSlug' +import { artworkBranchLoaderRoute } from '../$branchSlug' +import { artworkVersionLoaderRoute } from '../$branchSlug.$versionSlug' import { projectLoaderRoute } from '../../route' -import { artboardLoaderRoute } from '../route' -import { NavActionsButtonGroup } from './header.artboard.button-group' -import { NavComboboxes } from './header.artboard.comboboxes' +import { artworkLoaderRoute } from '../route' +import { NavActionsButtonGroup } from './header.artwork.button-group' +import { NavComboboxes } from './header.artwork.comboboxes' -export const ArtboardHeader = () => { +export const ArtworkHeader = () => { const matches = useMatches() const { project } = useRouteLoaderMatchData(matches, projectLoaderRoute) - const { artboard } = useRouteLoaderMatchData(matches, artboardLoaderRoute) - const { branch } = useRouteLoaderMatchData(matches, artboardBranchLoaderRoute) + const { artwork } = useRouteLoaderMatchData(matches, artworkLoaderRoute) + const { branch } = useRouteLoaderMatchData(matches, artworkBranchLoaderRoute) const { version } = useRouteLoaderMatchData( matches, - artboardVersionLoaderRoute, + artworkVersionLoaderRoute, ) const onLatestVersion = version.slug === 'latest' || branch.versions[0].id === version.id @@ -25,29 +25,29 @@ export const ArtboardHeader = () => { () => ( ), - [project, artboard, branch, version, onLatestVersion], + [project, artwork, branch, version, onLatestVersion], ) const navActionsButtonGroup = useCallback( () => ( ), - [artboard, branch, version, onLatestVersion], + [artwork, branch, version, onLatestVersion], ) return ( - + {navComboboxes()} {navActionsButtonGroup()} diff --git a/app/routes/sketch+/projects+/$projectSlug_+/artboards+/$artboardSlug+/__components/sidebars.panel.artboard-version.background.tsx b/app/routes/sketch+/projects+/$projectSlug_+/artworks+/$artworkSlug+/__components/sidebars.panel.artwork-version.background.tsx similarity index 55% rename from app/routes/sketch+/projects+/$projectSlug_+/artboards+/$artboardSlug+/__components/sidebars.panel.artboard-version.background.tsx rename to app/routes/sketch+/projects+/$projectSlug_+/artworks+/$artworkSlug+/__components/sidebars.panel.artwork-version.background.tsx index 374791a5..393f2896 100644 --- a/app/routes/sketch+/projects+/$projectSlug_+/artboards+/$artboardSlug+/__components/sidebars.panel.artboard-version.background.tsx +++ b/app/routes/sketch+/projects+/$projectSlug_+/artworks+/$artworkSlug+/__components/sidebars.panel.artwork-version.background.tsx @@ -5,13 +5,13 @@ import { SidebarPanelRowContainer, SidebarPanelRowValuesContainer, } from '#app/components/templates' -import { type IArtboardVersionWithDesignsAndLayers } from '#app/models/artboard-version/artboard-version.server' -import { ArtboardVersionBackground } from '#app/routes/resources+/api.v1+/artboard-version.update.background' +import { type IArtworkVersionWithDesignsAndLayers } from '#app/models/artwork-version/artwork-version.server' +import { ArtworkVersionBackground } from '#app/routes/resources+/api.v1+/artwork-version.update.background' -export const PanelArtboardVersionBackground = ({ +export const PanelArtworkVersionBackground = ({ version, }: { - version: IArtboardVersionWithDesignsAndLayers + version: IArtworkVersionWithDesignsAndLayers }) => { return ( @@ -19,7 +19,7 @@ export const PanelArtboardVersionBackground = ({ - + diff --git a/app/routes/sketch+/projects+/$projectSlug_+/artworks+/$artworkSlug+/__components/sidebars.panel.artwork-version.frame.tsx b/app/routes/sketch+/projects+/$projectSlug_+/artworks+/$artworkSlug+/__components/sidebars.panel.artwork-version.frame.tsx new file mode 100644 index 00000000..31bf73c6 --- /dev/null +++ b/app/routes/sketch+/projects+/$projectSlug_+/artworks+/$artworkSlug+/__components/sidebars.panel.artwork-version.frame.tsx @@ -0,0 +1,30 @@ +import { + SidebarPanel, + SidebarPanelHeader, + SidebarPanelRow, + SidebarPanelRowContainer, + SidebarPanelRowValuesContainer, +} from '#app/components/templates' +import { type IArtworkVersionWithDesignsAndLayers } from '#app/models/artwork-version/artwork-version.server' +import { ArtworkVersionHeight } from '#app/routes/resources+/api.v1+/artwork-version.update.height' +import { ArtworkVersionWidth } from '#app/routes/resources+/api.v1+/artwork-version.update.width' + +export const PanelArtworkVersionFrame = ({ + version, +}: { + version: IArtworkVersionWithDesignsAndLayers +}) => { + return ( + + + + + + + + + + + + ) +} diff --git a/app/routes/sketch+/projects+/$projectSlug_+/artworks+/$artworkSlug+/__components/sidebars.panel.artwork-version.layers.tsx b/app/routes/sketch+/projects+/$projectSlug_+/artworks+/$artworkSlug+/__components/sidebars.panel.artwork-version.layers.tsx new file mode 100644 index 00000000..18f9d420 --- /dev/null +++ b/app/routes/sketch+/projects+/$projectSlug_+/artworks+/$artworkSlug+/__components/sidebars.panel.artwork-version.layers.tsx @@ -0,0 +1,34 @@ +import { DashboardEntityPanel } from '#app/components/templates/panel/dashboard-entity-panel' +import { type IArtworkVersionWithDesignsAndLayers } from '#app/models/artwork-version/artwork-version.server' +import { type ILayerWithDesigns } from '#app/models/layer/layer.server' +import { DashboardPanelCreateArtworkVersionLayerStrategy } from '#app/strategies/component/dashboard-panel/create-entity.strategy' +import { DashboardPanelArtworkVersionLayerActionStrategy } from '#app/strategies/component/dashboard-panel/entity-action/entity-action' +import { DashboardPanelUpdateArtworkVersionLayerTypeOrderStrategy } from '#app/strategies/component/dashboard-panel/update-entity-order.strategy' +import { orderLinkedItems } from '#app/utils/linked-list.utils' + +export const PanelArtworkVersionLayers = ({ + version, +}: { + version: IArtworkVersionWithDesignsAndLayers +}) => { + const orderedLayers = orderLinkedItems(version.layers) + + const strategyEntityNew = + new DashboardPanelCreateArtworkVersionLayerStrategy() + const strategyReorder = + new DashboardPanelUpdateArtworkVersionLayerTypeOrderStrategy() + const strategyActions = new DashboardPanelArtworkVersionLayerActionStrategy() + + return ( +
+ +
+ ) +} diff --git a/app/routes/sketch+/projects+/$projectSlug_+/artworks+/$artworkSlug+/__components/sidebars.panel.artwork-version.tsx b/app/routes/sketch+/projects+/$projectSlug_+/artworks+/$artworkSlug+/__components/sidebars.panel.artwork-version.tsx new file mode 100644 index 00000000..54caef6a --- /dev/null +++ b/app/routes/sketch+/projects+/$projectSlug_+/artworks+/$artworkSlug+/__components/sidebars.panel.artwork-version.tsx @@ -0,0 +1,18 @@ +import { type IArtworkVersionWithDesignsAndLayers } from '#app/models/artwork-version/artwork-version.server' +import { PanelArtworkVersionBackground } from './sidebars.panel.artwork-version.background' +import { PanelArtworkVersionFrame } from './sidebars.panel.artwork-version.frame' +import { PanelArtworkVersionDesigns } from './sidebars.panel.designs.artwork-version' + +export const PanelArtworkVersion = ({ + version, +}: { + version: IArtworkVersionWithDesignsAndLayers +}) => { + return ( +
+ + + +
+ ) +} diff --git a/app/routes/sketch+/projects+/$projectSlug_+/artworks+/$artworkSlug+/__components/sidebars.panel.designs.artwork-version.tsx b/app/routes/sketch+/projects+/$projectSlug_+/artworks+/$artworkSlug+/__components/sidebars.panel.designs.artwork-version.tsx new file mode 100644 index 00000000..ad75fc65 --- /dev/null +++ b/app/routes/sketch+/projects+/$projectSlug_+/artworks+/$artworkSlug+/__components/sidebars.panel.designs.artwork-version.tsx @@ -0,0 +1,27 @@ +import { type IArtworkVersionWithDesignsAndLayers } from '#app/models/artwork-version/artwork-version.server' +import { DashboardPanelCreateArtworkVersionDesignTypeStrategy } from '#app/strategies/component/dashboard-panel/create-entity.strategy' +import { DashboardPanelArtworkVersionDesignActionStrategy } from '#app/strategies/component/dashboard-panel/entity-action/entity-action' +import { DashboardPanelUpdateArtworkVersionDesignTypeOrderStrategy } from '#app/strategies/component/dashboard-panel/update-entity-order.strategy' +import { PanelDesigns } from './sidebars.panel.designs' + +export const PanelArtworkVersionDesigns = ({ + version, +}: { + version: IArtworkVersionWithDesignsAndLayers +}) => { + const strategyEntityNew = + new DashboardPanelCreateArtworkVersionDesignTypeStrategy() + const strategyReorder = + new DashboardPanelUpdateArtworkVersionDesignTypeOrderStrategy() + const strategyActions = + new DashboardPanelArtworkVersionDesignActionStrategy() + + return ( + + ) +} diff --git a/app/routes/sketch+/projects+/$projectSlug_+/artboards+/$artboardSlug+/__components/sidebars.panel.designs.layer.tsx b/app/routes/sketch+/projects+/$projectSlug_+/artworks+/$artworkSlug+/__components/sidebars.panel.designs.layer.tsx similarity index 100% rename from app/routes/sketch+/projects+/$projectSlug_+/artboards+/$artboardSlug+/__components/sidebars.panel.designs.layer.tsx rename to app/routes/sketch+/projects+/$projectSlug_+/artworks+/$artworkSlug+/__components/sidebars.panel.designs.layer.tsx diff --git a/app/routes/sketch+/projects+/$projectSlug_+/artboards+/$artboardSlug+/__components/sidebars.panel.designs.tsx b/app/routes/sketch+/projects+/$projectSlug_+/artworks+/$artworkSlug+/__components/sidebars.panel.designs.tsx similarity index 100% rename from app/routes/sketch+/projects+/$projectSlug_+/artboards+/$artboardSlug+/__components/sidebars.panel.designs.tsx rename to app/routes/sketch+/projects+/$projectSlug_+/artworks+/$artworkSlug+/__components/sidebars.panel.designs.tsx diff --git a/app/routes/sketch+/projects+/$projectSlug_+/artboards+/$artboardSlug+/__components/sidebars.panel.layer.tsx b/app/routes/sketch+/projects+/$projectSlug_+/artworks+/$artworkSlug+/__components/sidebars.panel.layer.tsx similarity index 100% rename from app/routes/sketch+/projects+/$projectSlug_+/artboards+/$artboardSlug+/__components/sidebars.panel.layer.tsx rename to app/routes/sketch+/projects+/$projectSlug_+/artworks+/$artworkSlug+/__components/sidebars.panel.layer.tsx diff --git a/app/routes/sketch+/projects+/$projectSlug_+/artboards+/$artboardSlug+/__components/sidebars.tsx b/app/routes/sketch+/projects+/$projectSlug_+/artworks+/$artworkSlug+/__components/sidebars.tsx similarity index 70% rename from app/routes/sketch+/projects+/$projectSlug_+/artboards+/$artboardSlug+/__components/sidebars.tsx rename to app/routes/sketch+/projects+/$projectSlug_+/artworks+/$artworkSlug+/__components/sidebars.tsx index 45abd26e..06a11439 100644 --- a/app/routes/sketch+/projects+/$projectSlug_+/artboards+/$artboardSlug+/__components/sidebars.tsx +++ b/app/routes/sketch+/projects+/$projectSlug_+/artworks+/$artworkSlug+/__components/sidebars.tsx @@ -1,21 +1,21 @@ import { Sidebar } from '#app/components/layout' import { SidebarTabs, SidebarTabsContent } from '#app/components/templates' -import { type IArtboardVersionWithDesignsAndLayers } from '#app/models/artboard-version/artboard-version.server' +import { type IArtworkVersionWithDesignsAndLayers } from '#app/models/artwork-version/artwork-version.server' import { type ILayerWithDesigns } from '#app/models/layer/layer.server' -import { PanelArtboardVersion } from './sidebars.panel.artboard-version' -import { PanelArtboardVersionLayers } from './sidebars.panel.artboard-version.layers' +import { PanelArtworkVersion } from './sidebars.panel.artwork-version' +import { PanelArtworkVersionLayers } from './sidebars.panel.artwork-version.layers' import { PanelLayer } from './sidebars.panel.layer' export const SidebarLeft = ({ version, }: { - version: IArtboardVersionWithDesignsAndLayers + version: IArtworkVersionWithDesignsAndLayers }) => { return ( - + Add assets like images here @@ -29,7 +29,7 @@ export const SidebarRight = ({ version, selectedLayer, }: { - version: IArtboardVersionWithDesignsAndLayers + version: IArtworkVersionWithDesignsAndLayers selectedLayer: ILayerWithDesigns | undefined }) => { return ( @@ -39,7 +39,7 @@ export const SidebarRight = ({ {selectedLayer ? ( ) : ( - + )} diff --git a/app/routes/sketch+/projects+/$projectSlug_+/artboards+/$artboardSlug+/_index.tsx b/app/routes/sketch+/projects+/$projectSlug_+/artworks+/$artworkSlug+/_index.tsx similarity index 72% rename from app/routes/sketch+/projects+/$projectSlug_+/artboards+/$artboardSlug+/_index.tsx rename to app/routes/sketch+/projects+/$projectSlug_+/artworks+/$artworkSlug+/_index.tsx index 53db3f4e..ee14e0e1 100644 --- a/app/routes/sketch+/projects+/$projectSlug_+/artboards+/$artboardSlug+/_index.tsx +++ b/app/routes/sketch+/projects+/$projectSlug_+/artworks+/$artworkSlug+/_index.tsx @@ -1,7 +1,7 @@ import { invariantResponse } from '@epic-web/invariant' import { type LoaderFunctionArgs, redirect } from '@remix-run/node' import { GeneralErrorBoundary } from '#app/components/error-boundary' -import { getArtboard } from '#app/models/artboard/artboard.get.server' +import { getArtwork } from '#app/models/artwork/artwork.get.server' import { getUserBasic } from '#app/models/user/user.get.server' import { requireUserId } from '#app/utils/auth.server' @@ -11,14 +11,14 @@ export async function loader({ params, request }: LoaderFunctionArgs) { invariantResponse(owner, 'Owner not found', { status: 404 }) // https://sergiodxa.com/tutorials/avoid-waterfalls-of-queries-in-remix-loaders - const { artboardSlug } = params - const artboard = await getArtboard({ - where: { slug: artboardSlug, ownerId: owner.id }, + const { artworkSlug } = params + const artwork = await getArtwork({ + where: { slug: artworkSlug, ownerId: owner.id }, }) - invariantResponse(artboard, 'Artboard not found', { status: 404 }) + invariantResponse(artwork, 'Artwork not found', { status: 404 }) // simply redirect to main branch, latest version - // when the artboard path is visited + // when the artwork path is visited const { pathname } = new URL(request.url) const redirectPath = `${pathname}/main/latest` @@ -30,7 +30,7 @@ export function ErrorBoundary() { ( -

No artboard with the name "{params.artboardSlug}" exists

+

No artwork with the name "{params.artworkSlug}" exists

), }} /> diff --git a/app/routes/sketch+/projects+/$projectSlug_+/artboards+/$artboardSlug+/route.tsx b/app/routes/sketch+/projects+/$projectSlug_+/artworks+/$artworkSlug+/route.tsx similarity index 66% rename from app/routes/sketch+/projects+/$projectSlug_+/artboards+/$artboardSlug+/route.tsx rename to app/routes/sketch+/projects+/$projectSlug_+/artworks+/$artworkSlug+/route.tsx index 2787b7cc..28e04b73 100644 --- a/app/routes/sketch+/projects+/$projectSlug_+/artboards+/$artboardSlug+/route.tsx +++ b/app/routes/sketch+/projects+/$projectSlug_+/artworks+/$artworkSlug+/route.tsx @@ -5,14 +5,14 @@ import { type MetaFunction, } from '@remix-run/node' import { GeneralErrorBoundary } from '#app/components/error-boundary' -import { getArtboardWithBranchesAndVersions } from '#app/models/artboard/artboard.get.server' +import { getArtworkWithBranchesAndVersions } from '#app/models/artwork/artwork.get.server' import { getUserBasic } from '#app/models/user/user.get.server' import { requireUserId } from '#app/utils/auth.server' import { routeLoaderMetaData } from '#app/utils/matches' import { projectLoaderRoute } from '../route' // starting the flat routes here in this directory -// since the artboard will redirect to the branch and version route +// since the artwork will redirect to the branch and version route // there could be more added to the parent routes on their pages // the value of the flat routes appears to be in the IDE @@ -23,35 +23,35 @@ import { projectLoaderRoute } from '../route' // https://interactive-remix-routing-v2.netlify.app/ // docs: https://remix.run/docs/en/main/file-conventions/routes -export const artboardLoaderRoute = - 'routes/sketch+/projects+/$projectSlug_+/artboards+/$artboardSlug+/route' +export const artworkLoaderRoute = + 'routes/sketch+/projects+/$projectSlug_+/artworks+/$artworkSlug+/route' export async function loader({ params, request }: LoaderFunctionArgs) { const userId = await requireUserId(request) const owner = await getUserBasic({ where: { id: userId } }) invariantResponse(owner, 'Owner not found', { status: 404 }) // https://sergiodxa.com/tutorials/avoid-waterfalls-of-queries-in-remix-loaders - const artboard = await getArtboardWithBranchesAndVersions({ - where: { slug: params.artboardSlug, ownerId: owner.id }, + const artwork = await getArtworkWithBranchesAndVersions({ + where: { slug: params.artworkSlug, ownerId: owner.id }, }) - invariantResponse(artboard, 'Artboard not found', { status: 404 }) + invariantResponse(artwork, 'Artwork not found', { status: 404 }) // ensure that data is loaded from the route // redirect on index.tsx - return json({ artboard }) + return json({ artwork }) } export const meta: MetaFunction = ({ params, matches }) => { const projectData = routeLoaderMetaData(matches, projectLoaderRoute) const projectName = projectData?.project.name ?? params.projectSlug - const artboardData = routeLoaderMetaData(matches, artboardLoaderRoute) - const artboardName = artboardData?.artboard.name ?? params.artboardSlug + const artworkData = routeLoaderMetaData(matches, artworkLoaderRoute) + const artworkName = artworkData?.artwork.name ?? params.artworkSlug return [ - { title: `${artboardName} | ${projectName} | Sketch | XYZ` }, + { title: `${artworkName} | ${projectName} | Sketch | XYZ` }, { name: 'description', - content: `Sketch dashboard for artboard project: ${artboardName} (${projectName})`, + content: `Sketch dashboard for artwork project: ${artworkName} (${projectName})`, }, ] } @@ -61,7 +61,7 @@ export function ErrorBoundary() { ( -

No artboard with the name "{params.artboardSlug}" exists

+

No artwork with the name "{params.artworkSlug}" exists

), }} /> diff --git a/app/routes/sketch+/projects+/$projectSlug_+/artboards+/index.tsx b/app/routes/sketch+/projects+/$projectSlug_+/artworks+/index.tsx similarity index 71% rename from app/routes/sketch+/projects+/$projectSlug_+/artboards+/index.tsx rename to app/routes/sketch+/projects+/$projectSlug_+/artworks+/index.tsx index 3faa75e7..eea9e35c 100644 --- a/app/routes/sketch+/projects+/$projectSlug_+/artboards+/index.tsx +++ b/app/routes/sketch+/projects+/$projectSlug_+/artworks+/index.tsx @@ -6,20 +6,20 @@ import { DashboardContentHeading2, } from '#app/components/layout' import { DashboardEntityCards } from '#app/components/templates' -import { getProjectWithArtboards } from '#app/models/project/project.get.server' +import { getProjectWithArtworks } from '#app/models/project/project.get.server' import { getUserBasic } from '#app/models/user/user.get.server' import { requireUserId } from '#app/utils/auth.server' import { useUser } from '#app/utils/user' -export const artboardstLoaderRoute = - 'routes/sketch+/projects+/$projectSlug_+/artboards+/route' +export const artworkstLoaderRoute = + 'routes/sketch+/projects+/$projectSlug_+/artworks+/route' export async function loader({ params, request }: LoaderFunctionArgs) { const userId = await requireUserId(request) const owner = await getUserBasic({ where: { id: userId } }) invariantResponse(owner, 'Owner not found', { status: 404 }) const { projectSlug } = params - const project = await getProjectWithArtboards({ + const project = await getProjectWithArtworks({ where: { slug: projectSlug, ownerId: owner.id }, }) invariantResponse(project, 'Project not found', { status: 404 }) @@ -27,7 +27,7 @@ export async function loader({ params, request }: LoaderFunctionArgs) { return json({ project }) } -export default function SketchProjectArtboardsIndexRoute() { +export default function SketchProjectArtworksIndexRoute() { const data = useLoaderData() const { project } = data const user = useUser() @@ -38,18 +38,18 @@ export default function SketchProjectArtboardsIndexRoute() { - Artboards + Artworks
) diff --git a/app/routes/sketch+/projects+/$projectSlug_+/artboards+/route.tsx b/app/routes/sketch+/projects+/$projectSlug_+/artworks+/route.tsx similarity index 78% rename from app/routes/sketch+/projects+/$projectSlug_+/artboards+/route.tsx rename to app/routes/sketch+/projects+/$projectSlug_+/artworks+/route.tsx index 8cc5b250..135ba8da 100644 --- a/app/routes/sketch+/projects+/$projectSlug_+/artboards+/route.tsx +++ b/app/routes/sketch+/projects+/$projectSlug_+/artworks+/route.tsx @@ -5,7 +5,7 @@ import { type LoaderFunctionArgs, } from '@remix-run/node' import { Outlet } from '@remix-run/react' -import { getProjectWithArtboards } from '#app/models/project/project.get.server' +import { getProjectWithArtworks } from '#app/models/project/project.get.server' import { getUserBasic } from '#app/models/user/user.get.server' import { requireUserId } from '#app/utils/auth.server' import { routeLoaderMetaData } from '#app/utils/matches' @@ -18,7 +18,7 @@ export async function loader({ params, request }: LoaderFunctionArgs) { invariantResponse(owner, 'Owner not found', { status: 404 }) const { projectSlug } = params - const project = await getProjectWithArtboards({ + const project = await getProjectWithArtworks({ where: { slug: projectSlug, ownerId: owner.id }, }) invariantResponse(project, 'Project not found', { status: 404 }) @@ -26,7 +26,7 @@ export async function loader({ params, request }: LoaderFunctionArgs) { return json({ project }) } -export default function SketchProjectArtboardsRoute() { +export default function SketchProjectArtworksRoute() { return } @@ -34,10 +34,10 @@ export const meta: MetaFunction = ({ params, matches }) => { const projectData = routeLoaderMetaData(matches, projectLoaderRoute) const projectName = projectData?.project.name ?? params.slug return [ - { title: `Artboards | ${projectName} | Sketch | XYZ` }, + { title: `Artworks | ${projectName} | Sketch | XYZ` }, { name: 'description', - content: `Sketch dashboard for XYZ project artboards: ${projectName}`, + content: `Sketch dashboard for XYZ project artworks: ${projectName}`, }, ] } diff --git a/app/routes/sketch+/projects+/$projectSlug_+/index.tsx b/app/routes/sketch+/projects+/$projectSlug_+/index.tsx index 7ca40323..9b0e395f 100644 --- a/app/routes/sketch+/projects+/$projectSlug_+/index.tsx +++ b/app/routes/sketch+/projects+/$projectSlug_+/index.tsx @@ -17,17 +17,17 @@ export default function SketchProjectIndexRoute() {
{project.name} - - Artboards + + Artworks
) diff --git a/app/routes/sketch+/projects+/$projectSlug_+/route.tsx b/app/routes/sketch+/projects+/$projectSlug_+/route.tsx index 8e985fd7..4d96fab3 100644 --- a/app/routes/sketch+/projects+/$projectSlug_+/route.tsx +++ b/app/routes/sketch+/projects+/$projectSlug_+/route.tsx @@ -6,7 +6,7 @@ import { } from '@remix-run/node' import { Outlet } from '@remix-run/react' import { GeneralErrorBoundary } from '#app/components/error-boundary' -import { getProjectWithArtboards } from '#app/models/project/project.get.server' +import { getProjectWithArtworks } from '#app/models/project/project.get.server' import { getUserBasic } from '#app/models/user/user.get.server' import { requireUserId } from '#app/utils/auth.server' import { routeLoaderMetaData } from '#app/utils/matches' @@ -19,7 +19,7 @@ export async function loader({ params, request }: LoaderFunctionArgs) { invariantResponse(owner, 'Owner not found', { status: 404 }) const { projectSlug } = params - const project = await getProjectWithArtboards({ + const project = await getProjectWithArtworks({ where: { slug: projectSlug, ownerId: owner.id }, }) invariantResponse(project, 'Project not found', { status: 404 }) diff --git a/app/routes/sketch+/projects+/components/projects-sidebar.tsx b/app/routes/sketch+/projects+/components/projects-sidebar.tsx index 4ade9732..e186e703 100644 --- a/app/routes/sketch+/projects+/components/projects-sidebar.tsx +++ b/app/routes/sketch+/projects+/components/projects-sidebar.tsx @@ -1,13 +1,13 @@ import { Sidebar } from '#app/components/layout' import { type NavItem, NestedEntityNavSidebar } from '#app/components/templates' -import { type IProjectWithArtboards } from '#app/models/project/project.server' +import { type IProjectWithArtworks } from '#app/models/project/project.server' export const ProjectsSidebar = ({ projects, }: { - projects: IProjectWithArtboards[] + projects: IProjectWithArtworks[] }) => { - // prepare the projects and artboards for the sidebar + // prepare the projects and artworks for the sidebar // nested entity nav sidebar expects an array of items // each item should have an id, name, path // and optionally an icon and children @@ -16,10 +16,10 @@ export const ProjectsSidebar = ({ name: project.name, path: project.slug, icon: 'stack', - children: project.artboards.map(artboard => ({ - id: artboard.id, - name: artboard.name, - path: `${project.slug}/artboards/${artboard.slug}`, + children: project.artworks.map(artwork => ({ + id: artwork.id, + name: artwork.name, + path: `${project.slug}/artworks/${artwork.slug}`, icon: 'file', })), })) diff --git a/app/routes/sketch+/projects+/index.tsx b/app/routes/sketch+/projects+/index.tsx index 8dcc11cb..f7b4bcce 100644 --- a/app/routes/sketch+/projects+/index.tsx +++ b/app/routes/sketch+/projects+/index.tsx @@ -7,7 +7,7 @@ import { DashboardContentHeading2, } from '#app/components/layout' import { DashboardEntityCards } from '#app/components/templates' -import { getProjectsWithArtboards } from '#app/models/project/project.get.server' +import { getProjectsWithArtworks } from '#app/models/project/project.get.server' import { getUserBasic } from '#app/models/user/user.get.server' import { requireUserId } from '#app/utils/auth.server' import { useUser } from '#app/utils/user' @@ -19,7 +19,7 @@ export async function loader({ request }: LoaderFunctionArgs) { const owner = await getUserBasic({ where: { id: userId } }) invariantResponse(owner, 'Owner not found', { status: 404 }) - const projects = await getProjectsWithArtboards({ + const projects = await getProjectsWithArtworks({ where: { ownerId: userId }, }) return json({ projects }) diff --git a/app/routes/sketch+/projects+/route.tsx b/app/routes/sketch+/projects+/route.tsx index fba9da3c..72989c01 100644 --- a/app/routes/sketch+/projects+/route.tsx +++ b/app/routes/sketch+/projects+/route.tsx @@ -10,7 +10,7 @@ import { DashboardContent, DashboardContentWrapper, } from '#app/components/layout' -import { getProjectsWithArtboards } from '#app/models/project/project.get.server' +import { getProjectsWithArtworks } from '#app/models/project/project.get.server' import { getUserBasic } from '#app/models/user/user.get.server' import { requireUserId } from '#app/utils/auth.server' import { ProjectsSidebar } from './components/projects-sidebar' @@ -21,7 +21,7 @@ export async function loader({ request }: LoaderFunctionArgs) { const owner = await getUserBasic({ where: { id: userId } }) invariantResponse(owner, 'Owner not found', { status: 404 }) - const projects = await getProjectsWithArtboards({ + const projects = await getProjectsWithArtworks({ where: { ownerId: userId }, }) return json({ projects }) diff --git a/app/routes/users+/$username_+/artboards+/$artboardId/_index/components.tsx b/app/routes/users+/$username_+/artworks+/$artworkId/_index/components.tsx similarity index 61% rename from app/routes/users+/$username_+/artboards+/$artboardId/_index/components.tsx rename to app/routes/users+/$username_+/artworks+/$artworkId/_index/components.tsx index 1be2c5a8..e1bb57f7 100644 --- a/app/routes/users+/$username_+/artboards+/$artboardId/_index/components.tsx +++ b/app/routes/users+/$username_+/artworks+/$artworkId/_index/components.tsx @@ -9,56 +9,56 @@ import { FooterTimestamp, } from '#app/components/shared' import { userHasPermission, useOptionalUser } from '#app/utils/user' -import { DeletePermission } from './delete-artboard-form' +import { DeletePermission } from './delete-artwork-form' import { type loader } from './route' export const Header = () => { const data = useLoaderData() - return {data.artboard.name} + return {data.artwork.name} } export const Content = () => { const data = useLoaderData() - const artboard = data.artboard + const artwork = data.artwork const user = useOptionalUser() - const isOwner = user?.id === artboard.ownerId + const isOwner = user?.id === artwork.ownerId const canDelete = userHasPermission( user, - isOwner ? `delete:artboard:own` : `delete:artboard:any`, + isOwner ? `delete:artwork:own` : `delete:artwork:any`, ) const displayBar = canDelete || isOwner return ( - Visible: {artboard.isVisible ? 'Yes' : 'No'} - {artboard.description} + Visible: {artwork.isVisible ? 'Yes' : 'No'} + {artwork.description} - {artboard.width}x{artboard.height} + {artwork.width}x{artwork.height} - {artboard.backgroundColor} + {artwork.backgroundColor} ) } export const Footer = () => { const data = useLoaderData() - const artboard = data.artboard + const artwork = data.artwork const user = useOptionalUser() - const isOwner = user?.id === artboard.ownerId + const isOwner = user?.id === artwork.ownerId const canDelete = userHasPermission( user, - isOwner ? `delete:artboard:own` : `delete:artboard:any`, + isOwner ? `delete:artwork:own` : `delete:artwork:any`, ) return ( {data.timeAgo} ago - {canDelete ? : null} + {canDelete ? : null} Edit Sketch diff --git a/app/routes/users+/$username_+/artboards+/$artboardId/_index/delete-artboard-form.tsx b/app/routes/users+/$username_+/artworks+/$artworkId/_index/delete-artwork-form.tsx similarity index 90% rename from app/routes/users+/$username_+/artboards+/$artboardId/_index/delete-artboard-form.tsx rename to app/routes/users+/$username_+/artworks+/$artworkId/_index/delete-artwork-form.tsx index b6d3ef18..79748934 100644 --- a/app/routes/users+/$username_+/artboards+/$artboardId/_index/delete-artboard-form.tsx +++ b/app/routes/users+/$username_+/artworks+/$artworkId/_index/delete-artwork-form.tsx @@ -14,18 +14,18 @@ export function DeletePermission({ id }: { id: string }) { const actionData = useActionData() const isPending = useIsPending() const [form] = useForm({ - id: 'delete-artboard', + id: 'delete-artwork', lastSubmission: actionData?.submission, }) return (
- + { - const artboard = await prisma.artboard.findFirst({ - where: { slug: artboardId, ownerId: userId }, +export const getArtwork = async (userId: string, artworkId: string) => { + const artwork = await prisma.artwork.findFirst({ + where: { slug: artworkId, ownerId: userId }, select: { id: true, name: true, @@ -25,5 +25,5 @@ export const getArtboard = async (userId: string, artboardId: string) => { }, }, }) - return artboard + return artwork } diff --git a/app/routes/users+/$username_+/artboards+/$artboardId/_index/route.tsx b/app/routes/users+/$username_+/artworks+/$artworkId/_index/route.tsx similarity index 62% rename from app/routes/users+/$username_+/artboards+/$artboardId/_index/route.tsx rename to app/routes/users+/$username_+/artworks+/$artworkId/_index/route.tsx index bd199015..76b7f482 100644 --- a/app/routes/users+/$username_+/artboards+/$artboardId/_index/route.tsx +++ b/app/routes/users+/$username_+/artworks+/$artworkId/_index/route.tsx @@ -16,30 +16,30 @@ import { prisma } from '#app/utils/db.server' import { requireUserWithPermission } from '#app/utils/permissions.server.ts' import { redirectWithToast } from '#app/utils/toast.server' import { userHasPermission, useOptionalUser } from '#app/utils/user' -import { type loader as artboardsLoader } from '../../route.tsx' +import { type loader as artworksLoader } from '../../route.tsx' import { Content, Footer, Header } from './components.tsx' -import { getArtboard } from './queries.ts' +import { getArtwork } from './queries.ts' export async function loader({ params, request }: LoaderFunctionArgs) { const userId = await requireUserId(request) - const artboard = await getArtboard(userId, params.artboardId as string) + const artwork = await getArtwork(userId, params.artworkId as string) - invariantResponse(artboard, 'Not found', { status: 404 }) + invariantResponse(artwork, 'Not found', { status: 404 }) - const date = new Date(artboard.updatedAt) + const date = new Date(artwork.updatedAt) const timeAgo = formatDistanceToNow(date) return json({ - artboard, + artwork, timeAgo, - breadcrumb: artboard.name, - project: artboard.project, + breadcrumb: artwork.name, + project: artwork.project, }) } const DeleteFormSchema = z.object({ - intent: z.literal('delete-artboard'), - artboardId: z.string(), + intent: z.literal('delete-artwork'), + artworkId: z.string(), }) export async function action({ request }: ActionFunctionArgs) { @@ -56,9 +56,9 @@ export async function action({ request }: ActionFunctionArgs) { return json({ status: 'error', submission } as const, { status: 400 }) } - const { artboardId } = submission.value + const { artworkId } = submission.value - const artboard = await prisma.artboard.findFirst({ + const artwork = await prisma.artwork.findFirst({ select: { id: true, name: true, @@ -72,38 +72,38 @@ export async function action({ request }: ActionFunctionArgs) { }, }, }, - where: { id: artboardId }, + where: { id: artworkId }, }) - invariantResponse(artboard, 'Not found', { status: 404 }) + invariantResponse(artwork, 'Not found', { status: 404 }) - const { id, name, owner, ownerId, project } = artboard + const { id, name, owner, ownerId, project } = artwork const isOwner = ownerId === userId await requireUserWithPermission( request, - isOwner ? `delete:artboard:own` : `delete:artboard:any`, + isOwner ? `delete:artwork:own` : `delete:artwork:any`, ) - await prisma.artboard.delete({ where: { id: id } }) + await prisma.artwork.delete({ where: { id: id } }) return redirectWithToast( `/users/${owner.username}/projects/${project.slug}`, { type: 'success', title: 'Success', - // description: 'Your artboard has been deleted.', - description: `Deleted artboard: "${name}"`, + // description: 'Your artwork has been deleted.', + description: `Deleted artwork: "${name}"`, }, ) } -export default function ArtboardDetailsRoute() { +export default function ArtworkDetailsRoute() { const data = useLoaderData() const user = useOptionalUser() - const isOwner = user?.id === data.artboard.ownerId + const isOwner = user?.id === data.artwork.ownerId const canDelete = userHasPermission( user, - isOwner ? `delete:artboard:own` : `delete:artboard:any`, + isOwner ? `delete:artwork:own` : `delete:artwork:any`, ) const displayBar = canDelete || isOwner @@ -118,19 +118,19 @@ export default function ArtboardDetailsRoute() { export const meta: MetaFunction< typeof loader, - { 'routes/users+/$username_+/artboards': typeof artboardsLoader } + { 'routes/users+/$username_+/artworks': typeof artworksLoader } > = ({ data, params, matches }) => { - const artboardssMatch = matches.find( - m => m.id === 'routes/users+/$username_+/artboards', + const artworkssMatch = matches.find( + m => m.id === 'routes/users+/$username_+/artworks', ) - const displayName = artboardssMatch?.data?.owner.name ?? params.username - const entityTitle = data?.artboard.name ?? 'Artboard' + const displayName = artworkssMatch?.data?.owner.name ?? params.username + const entityTitle = data?.artwork.name ?? 'Artwork' const entityDescriptionSummary = - data?.artboard.description && data.artboard.description.length > 100 - ? data.artboard.description.slice(0, 97) + '...' - : data?.artboard.description || 'No description' + data?.artwork.description && data.artwork.description.length > 100 + ? data.artwork.description.slice(0, 97) + '...' + : data?.artwork.description || 'No description' return [ - { title: `${entityTitle} | ${displayName}'s Artboards | XYZ` }, + { title: `${entityTitle} | ${displayName}'s Artworks | XYZ` }, { name: 'description', content: entityDescriptionSummary, @@ -144,7 +144,7 @@ export function ErrorBoundary() { statusHandlers={{ 403: () =>

You are not allowed to do that

, 404: ({ params }) => ( -

No artboard with the name "{params.artboardId}" exists

+

No artwork with the name "{params.artworkId}" exists

), }} /> diff --git a/app/routes/users+/$username_+/artboards+/$artboardId/edit/edit-form.server.ts b/app/routes/users+/$username_+/artworks+/$artworkId/edit/edit-form.server.ts similarity index 74% rename from app/routes/users+/$username_+/artboards+/$artboardId/edit/edit-form.server.ts rename to app/routes/users+/$username_+/artworks+/$artworkId/edit/edit-form.server.ts index d5b53a87..f14d7615 100644 --- a/app/routes/users+/$username_+/artboards+/$artboardId/edit/edit-form.server.ts +++ b/app/routes/users+/$username_+/artworks+/$artworkId/edit/edit-form.server.ts @@ -5,7 +5,7 @@ import { requireUserId } from '#app/utils/auth.server' import { validateCSRF } from '#app/utils/csrf.server' import { prisma } from '#app/utils/db.server' import { stringToSlug } from '#app/utils/misc' -import { ArtboardEditorSchema } from './edit-form' +import { ArtworkEditorSchema } from './edit-form' export async function action({ request }: ActionFunctionArgs) { const userId = await requireUserId(request) @@ -14,29 +14,29 @@ export async function action({ request }: ActionFunctionArgs) { await validateCSRF(formData, request.headers) const submission = await parse(formData, { - schema: ArtboardEditorSchema.superRefine(async (data, ctx) => { + schema: ArtworkEditorSchema.superRefine(async (data, ctx) => { if (!data.id) return - const artboard = await prisma.artboard.findUnique({ + const artwork = await prisma.artwork.findUnique({ select: { id: true }, where: { id: data.id, ownerId: userId }, }) - if (!artboard) { + if (!artwork) { ctx.addIssue({ code: z.ZodIssueCode.custom, - message: `Artboard not found`, + message: `Artwork not found`, }) } const slug = stringToSlug(data.name) - const entityWithSlug = await prisma.artboard.findFirst({ + const entityWithSlug = await prisma.artwork.findFirst({ select: { id: true }, where: { slug, ownerId: userId }, }) if (entityWithSlug && entityWithSlug.id !== data.id) { ctx.addIssue({ code: z.ZodIssueCode.custom, - message: `Artboard with that name already exists`, + message: `Artwork with that name already exists`, }) } }), @@ -52,7 +52,7 @@ export async function action({ request }: ActionFunctionArgs) { } const { - id: artboardId, + id: artworkId, name, description, isVisible, @@ -62,9 +62,9 @@ export async function action({ request }: ActionFunctionArgs) { } = submission.value const slug = stringToSlug(name) - const updatedArtboard = await prisma.artboard.update({ + const updatedArtwork = await prisma.artwork.update({ select: { slug: true, owner: { select: { username: true } } }, - where: { id: artboardId }, + where: { id: artworkId }, data: { name, description, @@ -77,6 +77,6 @@ export async function action({ request }: ActionFunctionArgs) { }) return redirect( - `/users/${updatedArtboard.owner.username}/artboards/${updatedArtboard.slug}`, + `/users/${updatedArtwork.owner.username}/artworks/${updatedArtwork.slug}`, ) } diff --git a/app/routes/users+/$username_+/artboards+/$artboardId/edit/edit-form.tsx b/app/routes/users+/$username_+/artworks+/$artworkId/edit/edit-form.tsx similarity index 89% rename from app/routes/users+/$username_+/artboards+/$artboardId/edit/edit-form.tsx rename to app/routes/users+/$username_+/artworks+/$artworkId/edit/edit-form.tsx index 49ecf61c..5df7ab95 100644 --- a/app/routes/users+/$username_+/artboards+/$artboardId/edit/edit-form.tsx +++ b/app/routes/users+/$username_+/artworks+/$artworkId/edit/edit-form.tsx @@ -1,6 +1,6 @@ import { conform, useForm } from '@conform-to/react' import { getFieldsetConstraint, parse } from '@conform-to/zod' -import { type Artboard } from '@prisma/client' +import { type Artwork } from '@prisma/client' import { type SerializeFrom } from '@remix-run/node' import { Form, useActionData } from '@remix-run/react' import { AuthenticityTokenInput } from 'remix-utils/csrf/react' @@ -42,7 +42,7 @@ const widthMaxLength = 10000 const heightMinLength = 1 const heightMaxLength = 10000 -export const ArtboardEditorSchema = z.object({ +export const ArtworkEditorSchema = z.object({ id: z.string().optional(), name: z.string().min(titleMinLength).max(titleMaxLength), description: z.string().min(descriptionMinLength).max(descriptionMaxLength), @@ -65,11 +65,11 @@ export const ArtboardEditorSchema = z.object({ }) export function EditForm({ - artboard, + artwork, }: { - artboard: SerializeFrom< + artwork: SerializeFrom< Pick< - Artboard, + Artwork, | 'id' | 'name' | 'description' @@ -84,19 +84,19 @@ export function EditForm({ const isPending = useIsPending() const [form, fields] = useForm({ - id: 'edit-artboard-form', - constraint: getFieldsetConstraint(ArtboardEditorSchema), + id: 'edit-artwork-form', + constraint: getFieldsetConstraint(ArtworkEditorSchema), lastSubmission: actionData?.submission, onValidate({ formData }) { - return parse(formData, { schema: ArtboardEditorSchema }) + return parse(formData, { schema: ArtworkEditorSchema }) }, defaultValue: { - name: artboard.name ?? '', - description: artboard.description ?? '', - isVisible: artboard.isVisible ?? false, - width: artboard.width ?? 1080, // 9:16 - height: artboard.height ?? 1920, - backgroundColor: artboard.backgroundColor ?? '#FFFFFF', + name: artwork.name ?? '', + description: artwork.description ?? '', + isVisible: artwork.isVisible ?? false, + width: artwork.width ?? 1080, // 9:16 + height: artwork.height ?? 1920, + backgroundColor: artwork.backgroundColor ?? '#FFFFFF', }, }) @@ -221,7 +221,7 @@ export function EditForm({ rather than the first button in the form (which is delete/add image). */}
- +
) } -const ArtboardsTable = () => { +const ArtworksTable = () => { const data = useLoaderData() const user = useUser() - const artboards = data.project.artboards + const artworks = data.project.artworks return ( - A list of your recent artboards. + A list of your recent artworks. Name @@ -66,7 +66,7 @@ const ArtboardsTable = () => { - {artboards.map(artboard => { + {artworks.map(artwork => { const { name, description, @@ -75,12 +75,12 @@ const ArtboardsTable = () => { width, height, updatedAt, - } = artboard + } = artwork const date = new Date(updatedAt) const timeAgo = formatDistanceToNow(date) - const ArtboardToolTip = () => { + const ArtworkToolTip = () => { return ( @@ -94,7 +94,7 @@ const ArtboardsTable = () => { return ( - + {isVisible ? 'visible' : 'not visible'} @@ -102,7 +102,7 @@ const ArtboardsTable = () => { {timeAgo} ago - + diff --git a/app/routes/users+/$username_+/projects+/$projectId/_index/components.tsx b/app/routes/users+/$username_+/projects+/$projectId/_index/components.tsx index bf8e5f70..43069fd9 100644 --- a/app/routes/users+/$username_+/projects+/$projectId/_index/components.tsx +++ b/app/routes/users+/$username_+/projects+/$projectId/_index/components.tsx @@ -10,7 +10,7 @@ import { } from '#app/components/shared' import { Separator } from '#app/components/ui/separator' import { userHasPermission, useOptionalUser } from '#app/utils/user' -import { Artboards } from './artboards' +import { Artworks } from './artworks' import { DeletePermission } from './delete-project-form' import { type loader } from './route' @@ -46,7 +46,7 @@ export const Content = () => { Visible: {data.project.isVisible ? 'Yes' : 'No'} {data.project.description} - + ) } diff --git a/app/routes/users+/$username_+/projects+/$projectId/_index/route.tsx b/app/routes/users+/$username_+/projects+/$projectId/_index/route.tsx index 8bc61e96..965f63ed 100644 --- a/app/routes/users+/$username_+/projects+/$projectId/_index/route.tsx +++ b/app/routes/users+/$username_+/projects+/$projectId/_index/route.tsx @@ -30,7 +30,7 @@ export async function loader({ params, request }: LoaderFunctionArgs) { isVisible: true, ownerId: true, updatedAt: true, - artboards: { + artworks: { select: { name: true, description: true, diff --git a/app/routes/users+/$username_+/projects+/$projectId/artboards/_index/route.tsx b/app/routes/users+/$username_+/projects+/$projectId/artworks/_index/route.tsx similarity index 100% rename from app/routes/users+/$username_+/projects+/$projectId/artboards/_index/route.tsx rename to app/routes/users+/$username_+/projects+/$projectId/artworks/_index/route.tsx diff --git a/app/routes/users+/$username_+/projects+/$projectId/artboards/new/new-artboard-form.server.ts b/app/routes/users+/$username_+/projects+/$projectId/artworks/new/new-artwork-form.server.ts similarity index 72% rename from app/routes/users+/$username_+/projects+/$projectId/artboards/new/new-artboard-form.server.ts rename to app/routes/users+/$username_+/projects+/$projectId/artworks/new/new-artwork-form.server.ts index 6efea0e5..a56b2e4f 100644 --- a/app/routes/users+/$username_+/projects+/$projectId/artboards/new/new-artboard-form.server.ts +++ b/app/routes/users+/$username_+/projects+/$projectId/artworks/new/new-artwork-form.server.ts @@ -1,12 +1,12 @@ import { parse } from '@conform-to/zod' import { json, redirect, type ActionFunctionArgs } from '@remix-run/node' import { z } from 'zod' -import { createDefaultArtboardBranchWithVersion } from '#app/models/artboard-branch/artboard-branch.create.server' +import { createDefaultArtworkBranchWithVersion } from '#app/models/artwork-branch/artwork-branch.create.server' import { requireUserId } from '#app/utils/auth.server.ts' import { validateCSRF } from '#app/utils/csrf.server.ts' import { prisma } from '#app/utils/db.server.ts' import { stringToSlug } from '#app/utils/misc.tsx' -import { ArtboardEditorSchema } from './new-artboard-form' +import { ArtworkEditorSchema } from './new-artwork-form' export async function action({ request }: ActionFunctionArgs) { const userId = await requireUserId(request) @@ -15,7 +15,7 @@ export async function action({ request }: ActionFunctionArgs) { await validateCSRF(formData, request.headers) const submission = await parse(formData, { - schema: ArtboardEditorSchema.superRefine(async (data, ctx) => { + schema: ArtworkEditorSchema.superRefine(async (data, ctx) => { const project = await prisma.project.findUnique({ select: { id: true }, where: { id: data.projectId, ownerId: userId }, @@ -28,14 +28,14 @@ export async function action({ request }: ActionFunctionArgs) { } const slug = stringToSlug(data.name) - const artboardWithSlug = await prisma.artboard.findFirst({ + const artworkWithSlug = await prisma.artwork.findFirst({ select: { id: true }, where: { slug, ownerId: userId }, }) - if (artboardWithSlug) { + if (artworkWithSlug) { ctx.addIssue({ code: z.ZodIssueCode.custom, - message: 'Artboard with that name already exists', + message: 'Artwork with that name already exists', }) } }), @@ -54,7 +54,7 @@ export async function action({ request }: ActionFunctionArgs) { submission.value const slug = stringToSlug(name) - const createdArtboard = await prisma.artboard.create({ + const createdArtwork = await prisma.artwork.create({ select: { id: true, ownerId: true, @@ -74,10 +74,10 @@ export async function action({ request }: ActionFunctionArgs) { }, }) - await createDefaultArtboardBranchWithVersion({ - artboard: createdArtboard, + await createDefaultArtworkBranchWithVersion({ + artwork: createdArtwork, }) - const { owner } = createdArtboard - return redirect(`/users/${owner.username}/artboards/${createdArtboard.slug}`) + const { owner } = createdArtwork + return redirect(`/users/${owner.username}/artworks/${createdArtwork.slug}`) } diff --git a/app/routes/users+/$username_+/projects+/$projectId/artboards/new/new-artboard-form.tsx b/app/routes/users+/$username_+/projects+/$projectId/artworks/new/new-artwork-form.tsx similarity index 93% rename from app/routes/users+/$username_+/projects+/$projectId/artboards/new/new-artboard-form.tsx rename to app/routes/users+/$username_+/projects+/$projectId/artworks/new/new-artwork-form.tsx index 801a60cc..adf1c00c 100644 --- a/app/routes/users+/$username_+/projects+/$projectId/artboards/new/new-artboard-form.tsx +++ b/app/routes/users+/$username_+/projects+/$projectId/artworks/new/new-artwork-form.tsx @@ -23,7 +23,7 @@ import { removeWhitespace, trimSpacesInBetween, } from '#app/utils/string-formatting' -import { type action } from './new-artboard-form.server' +import { type action } from './new-artwork-form.server' import { type loader } from './route' const titleMinLength = 1 @@ -35,7 +35,7 @@ const widthMaxLength = 10000 const heightMinLength = 1 const heightMaxLength = 10000 -export const ArtboardEditorSchema = z.object({ +export const ArtworkEditorSchema = z.object({ projectId: z.string(), name: z.string().min(titleMinLength).max(titleMaxLength), description: z.string().min(descriptionMinLength).max(descriptionMaxLength), @@ -54,7 +54,7 @@ export const ArtboardEditorSchema = z.object({ }), }) -export function NewArtboardForm() { +export function NewArtworkForm() { const data = useLoaderData() const project = data.project @@ -62,11 +62,11 @@ export function NewArtboardForm() { const isPending = useIsPending() const [form, fields] = useForm({ - id: 'new-artboard-form', - constraint: getFieldsetConstraint(ArtboardEditorSchema), + id: 'new-artwork-form', + constraint: getFieldsetConstraint(ArtworkEditorSchema), lastSubmission: actionData?.submission, onValidate({ formData }) { - return parse(formData, { schema: ArtboardEditorSchema }) + return parse(formData, { schema: ArtworkEditorSchema }) }, defaultValue: { width: 1080, // 9:16 @@ -197,7 +197,7 @@ export function ErrorBoundary() { ( -

No artboard with the id "{params.artboardId}" exists

+

No artwork with the id "{params.artworkId}" exists

), }} /> diff --git a/app/routes/users+/$username_+/projects+/$projectId/artboards/new/route.tsx b/app/routes/users+/$username_+/projects+/$projectId/artworks/new/route.tsx similarity index 84% rename from app/routes/users+/$username_+/projects+/$projectId/artboards/new/route.tsx rename to app/routes/users+/$username_+/projects+/$projectId/artworks/new/route.tsx index 32e7a773..f9d9779c 100644 --- a/app/routes/users+/$username_+/projects+/$projectId/artboards/new/route.tsx +++ b/app/routes/users+/$username_+/projects+/$projectId/artworks/new/route.tsx @@ -3,8 +3,8 @@ import { json, type LoaderFunctionArgs } from '@remix-run/node' import { requireUserId } from '#app/utils/auth.server.ts' import { type BreadcrumbHandle } from '#app/utils/breadcrumbs.tsx' import { prisma } from '#app/utils/db.server.ts' -import { action } from './new-artboard-form.server.ts' -import { NewArtboardForm } from './new-artboard-form.tsx' +import { action } from './new-artwork-form.server.ts' +import { NewArtworkForm } from './new-artwork-form.tsx' export const handle: BreadcrumbHandle = { breadcrumb: () => 'New', @@ -22,4 +22,4 @@ export async function loader({ params, request }: LoaderFunctionArgs) { } export { action } -export default NewArtboardForm +export default NewArtworkForm diff --git a/app/routes/users+/$username_+/projects+/$projectId/artboards/route.tsx b/app/routes/users+/$username_+/projects+/$projectId/artworks/route.tsx similarity index 95% rename from app/routes/users+/$username_+/projects+/$projectId/artboards/route.tsx rename to app/routes/users+/$username_+/projects+/$projectId/artworks/route.tsx index b0f03d3b..ab04f5f0 100644 --- a/app/routes/users+/$username_+/projects+/$projectId/artboards/route.tsx +++ b/app/routes/users+/$username_+/projects+/$projectId/artworks/route.tsx @@ -5,7 +5,7 @@ import { type BreadcrumbHandle } from '#app/utils/breadcrumbs' import { prisma } from '#app/utils/db.server.ts' export const handle: BreadcrumbHandle = { - breadcrumb: () => 'Artboards', + breadcrumb: () => 'Artworks', } export async function loader({ params, request }: LoaderFunctionArgs) { diff --git a/app/schema/artboard-branch.ts b/app/schema/artwork-branch.ts similarity index 72% rename from app/schema/artboard-branch.ts rename to app/schema/artwork-branch.ts index b4b8d0ca..42ff2dda 100644 --- a/app/schema/artboard-branch.ts +++ b/app/schema/artwork-branch.ts @@ -1,17 +1,17 @@ import { z } from 'zod' -export const ArtboardBranchDataCreateSchema = z.object({ +export const ArtworkBranchDataCreateSchema = z.object({ ownerId: z.string(), - artboardId: z.string(), + artworkId: z.string(), parentId: z.string(), name: z.string().min(1).max(255), description: z.string().max(255), slug: z.string(), }) -export const NewArtboardBranchSchema = z.object({ +export const NewArtworkBranchSchema = z.object({ id: z.string(), - artboardId: z.string(), + artworkId: z.string(), // copy the current version to the new branch // could be the tail or an earlier version versionId: z.string(), diff --git a/app/schema/artboard-version.ts b/app/schema/artwork-version.ts similarity index 66% rename from app/schema/artboard-version.ts rename to app/schema/artwork-version.ts index afdeba17..a89c74bf 100644 --- a/app/schema/artboard-version.ts +++ b/app/schema/artwork-version.ts @@ -24,27 +24,27 @@ const heightSchema = z message: `Height must be at most ${heightMaxLength}`, }) -export type ArtboardVersionUpdateSchemaType = - | typeof ArtboardVersionWidthSchema - | typeof ArtboardVersionHeightSchema - | typeof ArtboardVersionBackgroundSchema +export type ArtworkVersionUpdateSchemaType = + | typeof ArtworkVersionWidthSchema + | typeof ArtworkVersionHeightSchema + | typeof ArtworkVersionBackgroundSchema -export const ArtboardVersionWidthSchema = z.object({ +export const ArtworkVersionWidthSchema = z.object({ id: z.string(), width: widthSchema, }) -export const ArtboardVersionHeightSchema = z.object({ +export const ArtworkVersionHeightSchema = z.object({ id: z.string(), height: heightSchema, }) -export const ArtboardVersionBackgroundSchema = z.object({ +export const ArtworkVersionBackgroundSchema = z.object({ id: z.string(), background: HexcodeSchema, }) -export const ArtboardVersionSelectedDesignsSchema = z.object({ +export const ArtworkVersionSelectedDesignsSchema = z.object({ paletteId: z.string().optional(), sizeId: z.string().optional(), fillId: z.string().optional(), @@ -55,11 +55,11 @@ export const ArtboardVersionSelectedDesignsSchema = z.object({ templateId: z.string().optional(), }) -export type ArtboardVersionSelectedDesignsType = z.infer< - typeof ArtboardVersionSelectedDesignsSchema +export type ArtworkVersionSelectedDesignsType = z.infer< + typeof ArtworkVersionSelectedDesignsSchema > -export const ArtboardVersionDataCreateSchema = z.object({ +export const ArtworkVersionDataCreateSchema = z.object({ ownerId: z.string(), branchId: z.string(), name: z.string().optional(), @@ -70,8 +70,8 @@ export const ArtboardVersionDataCreateSchema = z.object({ background: HexcodeSchema.optional(), }) -export const NewArtboardVersionSchema = z.object({ +export const NewArtworkVersionSchema = z.object({ id: z.string(), - artboardBranchId: z.string(), + artworkBranchId: z.string(), description: z.string(), }) diff --git a/app/schema/artboard.ts b/app/schema/artwork.ts similarity index 76% rename from app/schema/artboard.ts rename to app/schema/artwork.ts index 0ce18a7a..9c465894 100644 --- a/app/schema/artboard.ts +++ b/app/schema/artwork.ts @@ -6,7 +6,7 @@ const widthMaxLength = 50000 const heightMinLength = 1 const heightMaxLength = 50000 -export const ArtboardWidthSchema = z.object({ +export const ArtworkWidthSchema = z.object({ id: z.string(), width: z .number() @@ -18,7 +18,7 @@ export const ArtboardWidthSchema = z.object({ }), }) -export const ArtboardHeightSchema = z.object({ +export const ArtworkHeightSchema = z.object({ id: z.string(), height: z .number() @@ -30,12 +30,12 @@ export const ArtboardHeightSchema = z.object({ }), }) -export const ArtboardBackgroundColorSchema = z.object({ +export const ArtworkBackgroundColorSchema = z.object({ id: z.string(), backgroundColor: HexcodeSchema, }) -export const ArtboardSelectedDesignsSchema = z.object({ +export const ArtworkSelectedDesignsSchema = z.object({ paletteId: z.string().optional(), sizeId: z.string().optional(), fillId: z.string().optional(), @@ -46,8 +46,8 @@ export const ArtboardSelectedDesignsSchema = z.object({ templateId: z.string().optional(), }) -export type ArtboardSelectedDesignsType = z.infer< - typeof ArtboardSelectedDesignsSchema +export type ArtworkSelectedDesignsType = z.infer< + typeof ArtworkSelectedDesignsSchema > export type selectArgsType = z.infer @@ -63,8 +63,8 @@ const whereArgs = z.object({ ownerId: z.string().optional(), }) -export type findArtboardArgsType = z.infer -export const findArtboardArgs = z.object({ +export type findArtworkArgsType = z.infer +export const findArtworkArgs = z.object({ where: whereArgs, select: selectArgs.optional(), }) diff --git a/app/schema/design-artboard-version.ts b/app/schema/design-artwork-version.ts similarity index 52% rename from app/schema/design-artboard-version.ts rename to app/schema/design-artwork-version.ts index e1c3016a..d6e0e330 100644 --- a/app/schema/design-artboard-version.ts +++ b/app/schema/design-artwork-version.ts @@ -3,41 +3,41 @@ import { DesignTypeEnum, type designTypeEnum } from './design' // copied from ./design.ts // may not be necessary? -export interface DesignArtboardVersion { +export interface DesignArtworkVersion { type: designTypeEnum ownerId: string - artboardVersionId: string + artworkVersionId: string } -export const ArtboardVersionDesignDataCreateSchema = z.object({ +export const ArtworkVersionDesignDataCreateSchema = z.object({ type: z.nativeEnum(DesignTypeEnum), ownerId: z.string(), - artboardVersionId: z.string(), + artworkVersionId: z.string(), visible: z.boolean().optional(), selected: z.boolean().optional(), -}) satisfies z.Schema +}) satisfies z.Schema -export const NewArtboardVersionDesignSchema = z.object({ - artboardVersionId: z.string(), +export const NewArtworkVersionDesignSchema = z.object({ + artworkVersionId: z.string(), type: z.nativeEnum(DesignTypeEnum), visibleDesignsCount: z.number().optional(), }) -export const DeleteArtboardVersionDesignSchema = z.object({ +export const DeleteArtworkVersionDesignSchema = z.object({ id: z.string(), - artboardVersionId: z.string(), + artworkVersionId: z.string(), updateSelectedDesignId: z.string().optional(), }) -export const ToggleVisibleArtboardVersionDesignSchema = z.object({ +export const ToggleVisibleArtworkVersionDesignSchema = z.object({ id: z.string(), - artboardVersionId: z.string(), + artworkVersionId: z.string(), updateSelectedDesignId: z.string().optional(), }) -export const ReorderArtboardVersionDesignSchema = z.object({ +export const ReorderArtworkVersionDesignSchema = z.object({ id: z.string(), - artboardVersionId: z.string(), + artworkVersionId: z.string(), direction: z.enum(['up', 'down']), updateSelectedDesignId: z.string().optional(), }) diff --git a/app/schema/design.ts b/app/schema/design.ts index a4cc9146..9f7c0c38 100644 --- a/app/schema/design.ts +++ b/app/schema/design.ts @@ -1,13 +1,13 @@ import { z } from 'zod' -import { type IArtboardVersionWithDesignsAndLayers } from '#app/models/artboard-version/artboard-version.server' +import { type IArtworkVersionWithDesignsAndLayers } from '#app/models/artwork-version/artwork-version.server' import { type ILayerWithDesigns } from '#app/models/layer/layer.server' import { type ObjectValues } from '#app/utils/typescript-helpers' import { - type DeleteArtboardVersionDesignSchema, - type NewArtboardVersionDesignSchema, - type ReorderArtboardVersionDesignSchema, - type ToggleVisibleArtboardVersionDesignSchema, -} from './design-artboard-version' + type DeleteArtworkVersionDesignSchema, + type NewArtworkVersionDesignSchema, + type ReorderArtworkVersionDesignSchema, + type ToggleVisibleArtworkVersionDesignSchema, +} from './design-artwork-version' import { type ToggleVisibleLayerDesignSchema, type DeleteLayerDesignSchema, @@ -29,18 +29,18 @@ export const DesignTypeEnum = { export type designTypeEnum = ObjectValues export type DesignParentType = - | IArtboardVersionWithDesignsAndLayers + | IArtworkVersionWithDesignsAndLayers | ILayerWithDesigns export const DesignParentTypeIdEnum = { - ARTBOARD_VERSION_ID: 'artboardVersionId', + ARTWORK_VERSION_ID: 'artworkVersionId', LAYER_ID: 'layerId', // add more design types here } as const export type designParentTypeIdEnum = ObjectValues export const DesignCloneSourceTypeEnum = { - ARTBOARD_VERSION: 'artboardVersion', + ARTWORK_VERSION: 'artworkVersion', LAYER: 'layer', } as const export type designCloneSourceTypeEnum = ObjectValues< @@ -51,7 +51,7 @@ export interface Design { type: designTypeEnum ownerId: string // one of these should be included - artboardVersionId?: string + artworkVersionId?: string layerId?: string } @@ -59,26 +59,26 @@ export interface Design { export const designSchema = z.object({ type: z.nativeEnum(DesignTypeEnum), ownerId: z.string(), - artboardVersionId: z.string().optional(), + artworkVersionId: z.string().optional(), layerId: z.string().optional(), visible: z.boolean().optional(), selected: z.boolean().optional(), }) satisfies z.Schema export type NewDesignSchemaType = - | typeof NewArtboardVersionDesignSchema + | typeof NewArtworkVersionDesignSchema | typeof NewLayerDesignSchema export type ReorderDesignSchemaType = - | typeof ReorderArtboardVersionDesignSchema + | typeof ReorderArtworkVersionDesignSchema | typeof ReorderLayerDesignSchema export type ToggleVisibleDesignSchemaType = - | typeof ToggleVisibleArtboardVersionDesignSchema + | typeof ToggleVisibleArtworkVersionDesignSchema | typeof ToggleVisibleLayerDesignSchema export type DeleteDesignSchemaType = - | typeof DeleteArtboardVersionDesignSchema + | typeof DeleteArtworkVersionDesignSchema | typeof DeleteLayerDesignSchema export type selectArgsType = z.infer @@ -95,7 +95,7 @@ const whereArgs = z.object({ visible: z.boolean().optional(), selected: z.boolean().optional(), ownerId: z.string().optional(), - artboardVersionId: z.string().optional(), + artworkVersionId: z.string().optional(), layerId: z.string().optional(), prevId: zodStringOrNull.optional(), nextId: zodStringOrNull.optional(), diff --git a/app/schema/entity.ts b/app/schema/entity.ts index d0911887..74cd36d4 100644 --- a/app/schema/entity.ts +++ b/app/schema/entity.ts @@ -1,6 +1,6 @@ -import { type IArtboard } from '#app/models/artboard/artboard.server' -import { type IArtboardBranch } from '#app/models/artboard-branch/artboard-branch.server' -import { type IArtboardVersion } from '#app/models/artboard-version/artboard-version.server' +import { type IArtwork } from '#app/models/artwork/artwork.server' +import { type IArtworkBranch } from '#app/models/artwork-branch/artwork-branch.server' +import { type IArtworkVersion } from '#app/models/artwork-version/artwork-version.server' import { type IDesignWithType, type IDesign, @@ -36,7 +36,7 @@ export type IEntity = | ILayer | IDesign | IDesignWithType - | IArtboardVersion + | IArtworkVersion | IPalette | ISize | IFill @@ -49,16 +49,16 @@ export type IEntity = export type IEntityVisible = IDesign | IDesignWithType | ILayer export type IEntitySelectable = ILayer export type IEntityWithSlug = - | IArtboard - | IArtboardBranch - | IArtboardVersion + | IArtwork + | IArtworkBranch + | IArtworkVersion | IProject export type IEntityId = | ILayer['id'] | IDesign['id'] | IDesignWithType['id'] - | IArtboardVersion['id'] + | IArtworkVersion['id'] | IPalette['id'] | ISize['id'] | IFill['id'] @@ -72,16 +72,16 @@ export type IEntityType = designTypeEnum | 'layer' export type IEntityParentType = | IDesignWithType - | IArtboardVersion + | IArtworkVersion | DesignParentType -export type IEntityParentId = IDesignWithType['id'] | IArtboardVersion['id'] +export type IEntityParentId = IDesignWithType['id'] | IArtworkVersion['id'] export const EntityType = { DESIGN: 'design', - ARTBOARD: 'artboard', - ARTBOARD_BRANCH: 'artboardBranch', - ARTBOARD_VERSION: 'artboardVersion', + ARtwork: 'artwork', + ARTWORK_BRANCH: 'artworkBranch', + ARTWORK_VERSION: 'artworkVersion', LAYER: 'layer', // add more parent id types here } as const @@ -90,9 +90,9 @@ export type entityTypeEnum = ObjectValues export const EntityParentType = { PARENT: 'parent', DESIGN: 'design', - ARTBOARD: 'artboard', - ARTBOARD_BRANCH: 'artboardBranch', - ARTBOARD_VERSION: 'artboardVersion', + ARtwork: 'artwork', + ARTWORK_BRANCH: 'artworkBranch', + ARTWORK_VERSION: 'artworkVersion', LAYER: 'layer', // add more parent types here } as const @@ -101,9 +101,9 @@ export type entityParentTypeEnum = ObjectValues export const EntityParentIdType = { PARENT_ID: 'parentId', DESIGN_ID: 'designId', - ARTBOARD_ID: 'artboardId', - ARTBOARD_BRANCH_ID: 'artboardBranchId', - ARTBOARD_VERSION_ID: 'artboardVersionId', + ARTWORK_ID: 'artworkId', + ARTWORK_BRANCH_ID: 'artworkBranchId', + ARTWORK_VERSION_ID: 'artworkVersionId', LAYER_ID: 'layerId', // add more parent id types here } as const diff --git a/app/schema/layer-artboard-version.ts b/app/schema/layer-artboard-version.ts deleted file mode 100644 index e45c6d95..00000000 --- a/app/schema/layer-artboard-version.ts +++ /dev/null @@ -1,41 +0,0 @@ -import { z } from 'zod' -import { LayerDescriptionSchema, LayerNameSchema } from './layer' - -export interface LayerDataCreate { - name: string - ownerId: string - artboardVersionId?: string -} - -export const ArtboardVersionLayerDataCreateSchema = z.object({ - name: LayerNameSchema, - ownerId: z.string(), - artboardVersionId: z.string(), - description: LayerDescriptionSchema.optional(), - slug: z.string().optional(), -}) satisfies z.Schema - -export const NewArtboardVersionLayerSchema = z.object({ - artboardVersionId: z.string(), -}) - -export const DeleteArtboardVersionLayerSchema = z.object({ - id: z.string(), - artboardVersionId: z.string(), -}) - -export const ToggleVisibleArtboardVersionLayerSchema = z.object({ - id: z.string(), - artboardVersionId: z.string(), -}) - -export const SelectArtboardVersionLayerSchema = z.object({ - id: z.string(), - artboardVersionId: z.string(), -}) - -export const ReorderArtboardVersionLayerSchema = z.object({ - id: z.string(), - artboardVersionId: z.string(), - direction: z.enum(['up', 'down']), -}) diff --git a/app/schema/layer-artwork-version.ts b/app/schema/layer-artwork-version.ts new file mode 100644 index 00000000..93d42b25 --- /dev/null +++ b/app/schema/layer-artwork-version.ts @@ -0,0 +1,41 @@ +import { z } from 'zod' +import { LayerDescriptionSchema, LayerNameSchema } from './layer' + +export interface LayerDataCreate { + name: string + ownerId: string + artworkVersionId?: string +} + +export const ArtworkVersionLayerDataCreateSchema = z.object({ + name: LayerNameSchema, + ownerId: z.string(), + artworkVersionId: z.string(), + description: LayerDescriptionSchema.optional(), + slug: z.string().optional(), +}) satisfies z.Schema + +export const NewArtworkVersionLayerSchema = z.object({ + artworkVersionId: z.string(), +}) + +export const DeleteArtworkVersionLayerSchema = z.object({ + id: z.string(), + artworkVersionId: z.string(), +}) + +export const ToggleVisibleArtworkVersionLayerSchema = z.object({ + id: z.string(), + artworkVersionId: z.string(), +}) + +export const SelectArtworkVersionLayerSchema = z.object({ + id: z.string(), + artworkVersionId: z.string(), +}) + +export const ReorderArtworkVersionLayerSchema = z.object({ + id: z.string(), + artworkVersionId: z.string(), + direction: z.enum(['up', 'down']), +}) diff --git a/app/schema/layer.ts b/app/schema/layer.ts index 8ea2a554..0533f400 100644 --- a/app/schema/layer.ts +++ b/app/schema/layer.ts @@ -1,16 +1,16 @@ import { z } from 'zod' import { - type ReorderArtboardVersionLayerSchema, - type NewArtboardVersionLayerSchema, - type ToggleVisibleArtboardVersionLayerSchema, - type DeleteArtboardVersionLayerSchema, - type SelectArtboardVersionLayerSchema, -} from './layer-artboard-version' + type ReorderArtworkVersionLayerSchema, + type NewArtworkVersionLayerSchema, + type ToggleVisibleArtworkVersionLayerSchema, + type DeleteArtworkVersionLayerSchema, + type SelectArtworkVersionLayerSchema, +} from './layer-artwork-version' type ObjectValues = T[keyof T] export const LayerCloneSourceTypeEnum = { - ARTBOARD: 'artboard', - ARTBOARD_VERSION: 'artboardVersion', + ARtwork: 'artwork', + ARTWORK_VERSION: 'artworkVersion', LAYER: 'layer', } as const export type layerCloneSourceTypeEnum = ObjectValues< @@ -31,16 +31,16 @@ export const EditLayerDescriptionSchema = z.object({ }) // later there will be layer groups -export type NewLayerSchemaType = typeof NewArtboardVersionLayerSchema +export type NewLayerSchemaType = typeof NewArtworkVersionLayerSchema -export type ReorderLayerSchemaType = typeof ReorderArtboardVersionLayerSchema +export type ReorderLayerSchemaType = typeof ReorderArtworkVersionLayerSchema export type ToggleVisibleLayerSchemaType = - typeof ToggleVisibleArtboardVersionLayerSchema + typeof ToggleVisibleArtworkVersionLayerSchema -export type DeleteLayerSchemaType = typeof DeleteArtboardVersionLayerSchema +export type DeleteLayerSchemaType = typeof DeleteArtworkVersionLayerSchema -export type SelectLayerSchemaType = typeof SelectArtboardVersionLayerSchema +export type SelectLayerSchemaType = typeof SelectArtworkVersionLayerSchema export type selectArgsType = z.infer const selectArgs = z.object({ @@ -52,8 +52,8 @@ const zodStringOrNull = z.union([z.string(), z.null()]) const whereArgs = z.object({ id: z.string().optional(), ownerId: z.string().optional(), - artboardId: z.string().optional(), - artboardVersionId: z.string().optional(), + artworkId: z.string().optional(), + artworkVersionId: z.string().optional(), prevId: zodStringOrNull.optional(), nextId: zodStringOrNull.optional(), }) diff --git a/app/services/artboard/branch/create.service.ts b/app/services/artboard/branch/create.service.ts deleted file mode 100644 index a79cb532..00000000 --- a/app/services/artboard/branch/create.service.ts +++ /dev/null @@ -1,113 +0,0 @@ -import { invariant } from '@epic-web/invariant' -import { type IArtboard } from '#app/models/artboard/artboard.server' -import { - createArtboardBranch, - type IArtboardBranchCreatedResponse, -} from '#app/models/artboard-branch/artboard-branch.create.server' -import { getArtboardBranch } from '#app/models/artboard-branch/artboard-branch.get.server' -import { type IArtboardBranch } from '#app/models/artboard-branch/artboard-branch.server' -import { createArtboardVersion } from '#app/models/artboard-version/artboard-version.create.server' -import { getArtboardVersion } from '#app/models/artboard-version/artboard-version.get.server' -import { type IArtboardVersion } from '#app/models/artboard-version/artboard-version.server' -import { type IUser } from '#app/models/user/user.server' -import { ArtboardBranchDataCreateSchema } from '#app/schema/artboard-branch' -import { ArtboardVersionDataCreateSchema } from '#app/schema/artboard-version' -import { DesignCloneSourceTypeEnum } from '#app/schema/design' -import { LayerCloneSourceTypeEnum } from '#app/schema/layer' -import { stringToSlug } from '#app/utils/misc' -import { artboardVersionCloneDesignsService } from '../version/clone-designs.service' -import { artboardVersionCloneLayersService } from '../version/clone-layers.service' - -export const artboardBranchCreateService = async ({ - userId, - id, - artboardId, - versionId, - name, - description, -}: { - userId: IUser['id'] - id: IArtboardBranch['id'] - artboardId: IArtboard['id'] - versionId: IArtboardVersion['id'] - name: string - description?: string -}): Promise => { - try { - // Step 1: find the current artboard branch - // this could be the root branch ("main") - // or this could be a child branch - // get this for its name - const currentArtboardBranch = await getArtboardBranch({ - where: { id, ownerId: userId }, - }) - invariant(currentArtboardBranch, 'Current artboard branch not found') - - // Step 2: get data for new artboard branch - const branchData = ArtboardBranchDataCreateSchema.parse({ - ownerId: userId, - artboardId, - parentId: id, - name, - slug: stringToSlug(name), - description: - description || `New branch from ${currentArtboardBranch.name}`, - }) - - // Step 3: create the new artboard branch - const createdArtboardBranch = await createArtboardBranch({ - data: branchData, - }) - invariant(createdArtboardBranch, 'New artboard branch not created') - - // Step 4: get the current version of the artboard branch - // NOTE: do not use artboardVersionCreateService - // as that will attempt to connect versions from different branches - const currentArtboardVersion = await getArtboardVersion({ - where: { id: versionId, branchId: id, ownerId: userId }, - }) - invariant(currentArtboardVersion, 'Current artboard version not found') - - // Step 5: get data for new branch initial version - const { width, height, background } = currentArtboardVersion - const versionData = ArtboardVersionDataCreateSchema.parse({ - ownerId: userId, - branchId: createdArtboardBranch.id, - description: `New branch from ${currentArtboardBranch.name}, version ${currentArtboardVersion.name}`, - width, - height, - background, - }) - - // Step 6: create new artboard version - const createdArtboardVersion = await createArtboardVersion({ - data: versionData, - }) - invariant(createdArtboardVersion, 'New artboard version not created') - - // Step 7: copy contents of previous artboard version to new artboard version - await artboardVersionCloneDesignsService({ - userId, - sourceEntityType: DesignCloneSourceTypeEnum.ARTBOARD_VERSION, - sourceEntityId: currentArtboardVersion.id, - targetEntityId: createdArtboardVersion.id, - }) - await artboardVersionCloneLayersService({ - userId, - sourceEntityType: LayerCloneSourceTypeEnum.ARTBOARD_VERSION, - sourceEntityId: currentArtboardVersion.id, - targetEntityId: createdArtboardVersion.id, - }) - - return { - createdArtboardBranch, - success: true, - } - } catch (error) { - console.log(error) - return { - success: false, - message: 'Unknown error creating artboard generator.', - } - } -} diff --git a/app/services/artboard/branch/version/create.service.ts b/app/services/artboard/branch/version/create.service.ts deleted file mode 100644 index ab4f6afd..00000000 --- a/app/services/artboard/branch/version/create.service.ts +++ /dev/null @@ -1,136 +0,0 @@ -import { invariant } from '@epic-web/invariant' -import { type User } from '@prisma/client' -import { type IArtboardBranch } from '#app/models/artboard-branch/artboard-branch.server' -import { - type IArtboardVersionCreatedResponse, - incrementVersionNameString, - createArtboardVersion, -} from '#app/models/artboard-version/artboard-version.create.server' -import { deleteArtboardVersions } from '#app/models/artboard-version/artboard-version.delete.server' -import { - getArtboardVersion, - getArtboardVersions, -} from '#app/models/artboard-version/artboard-version.get.server' -import { type IArtboardVersion } from '#app/models/artboard-version/artboard-version.server' -import { connectPrevAndNext } from '#app/models/artboard-version/artboard-version.update.server' -import { ArtboardVersionDataCreateSchema } from '#app/schema/artboard-version' -import { DesignCloneSourceTypeEnum } from '#app/schema/design' -import { LayerCloneSourceTypeEnum } from '#app/schema/layer' -import { prisma } from '#app/utils/db.server' -import { orderLinkedItems } from '#app/utils/linked-list.utils' -import { artboardVersionCloneDesignsService } from '../../version/clone-designs.service' -import { artboardVersionCloneLayersService } from '../../version/clone-layers.service' - -// copy contents of previous artboard version to new artboard version - -export const artboardVersionCreateService = async ({ - userId, - id, - artboardBranchId, - description, -}: { - userId: User['id'] - id: IArtboardVersion['id'] - artboardBranchId: IArtboardBranch['id'] - description: string -}): Promise => { - try { - // Step 1: find the current artboard version - // this could be the tail - // or this could be an earlier version where the version history is being reset - // aka undo, undo, undo, new version edits - const currentArtboardVersion = await getArtboardVersion({ - where: { id, ownerId: userId }, - }) - invariant(currentArtboardVersion, 'Current artboard version not found') - - // Step 2: get data for new artboard version - const { name, width, height, background } = currentArtboardVersion - const newName = incrementVersionNameString(name) - const data = ArtboardVersionDataCreateSchema.parse({ - ownerId: userId, - branchId: artboardBranchId, - name: newName, - slug: newName, - description: description || 'new version', - width, - height, - background, - }) - - // Step 3: delete all artboard versions after the current artboard version - // getting multiple heads and tails on v1... - const artboardVersions = await getArtboardVersions({ - where: { branchId: artboardBranchId }, - }) - const deleteArtboardVersionsPromise = deleteArtboardVersionsAfterCurrent({ - id, - artboardVersions, - }) - await prisma.$transaction([deleteArtboardVersionsPromise]) - - // Step 4: create new artboard version - const createdArtboardVersion = await createArtboardVersion({ data }) - invariant(createdArtboardVersion, 'New artboard version not created') - - // Step 5: connect created and current versions - const connectNodesPromise = connectPrevAndNext({ - prevId: currentArtboardVersion.id, - nextId: createdArtboardVersion.id, - }) - await prisma.$transaction(connectNodesPromise) - - // Step 6: copy contents of previous artboard version to new artboard version - await artboardVersionCloneDesignsService({ - userId, - sourceEntityType: DesignCloneSourceTypeEnum.ARTBOARD_VERSION, - sourceEntityId: currentArtboardVersion.id, - targetEntityId: createdArtboardVersion.id, - }) - await artboardVersionCloneLayersService({ - userId, - sourceEntityType: LayerCloneSourceTypeEnum.ARTBOARD_VERSION, - sourceEntityId: currentArtboardVersion.id, - targetEntityId: createdArtboardVersion.id, - }) - - return { createdArtboardVersion, success: true } - } catch (error) { - console.log('designCreateService error:', error) - const errorType = error instanceof Error - const errorMessage = errorType ? error.message : 'An unknown error occurred' - return { - success: false, - message: errorMessage, - } - } -} - -const deleteArtboardVersionsAfterCurrent = ({ - id, - artboardVersions, -}: { - id: IArtboardVersion['id'] - artboardVersions: IArtboardVersion[] -}) => { - // Step 1: already got all artboard versions for branch - // (work-around) for async/await and returning prisma promise - // Step 2: reorder the artboard versions as linked list - const orderedArtboardVersions = - orderLinkedItems(artboardVersions) - - // Step 3: find the index of the current artboard version - const currentIndex = orderedArtboardVersions.findIndex( - artboardVersion => artboardVersion.id === id, - ) - - // Step 4: get the id's of the artboard versions after the current index - const artboardVersionsToDeleteIds = orderedArtboardVersions - .slice(currentIndex + 1) - .map(({ id }) => id) - - // Step 5: return the promise that deletes them - return deleteArtboardVersions({ - ids: artboardVersionsToDeleteIds, - }) -} diff --git a/app/services/artboard/version/update.service.ts b/app/services/artboard/version/update.service.ts deleted file mode 100644 index bb21d205..00000000 --- a/app/services/artboard/version/update.service.ts +++ /dev/null @@ -1,65 +0,0 @@ -import { type IArtboardVersion } from '#app/models/artboard-version/artboard-version.server' -import { - updateArtboardVersionBackground, - updateArtboardVersionHeight, - updateArtboardVersionWidth, -} from '#app/models/artboard-version/artboard-version.update.server' - -export async function updateArtboardVersionWidthService({ - id, - width, -}: { - id: IArtboardVersion['id'] - width: number -}) { - try { - const updatedArtboardVersion = await updateArtboardVersionWidth({ - id, - width, - }) - // later will be adding Activity class - // i.e, edit history so you can undo changes and/or see who made them - return { success: true, artboardVersion: updatedArtboardVersion } - } catch (error) { - console.error(error) - return { success: false } - } -} - -export async function updateArtboardVersionHeightService({ - id, - height, -}: { - id: IArtboardVersion['id'] - height: number -}) { - try { - const updatedArtboardVersion = await updateArtboardVersionHeight({ - id, - height, - }) - return { success: true, artboardVersion: updatedArtboardVersion } - } catch (error) { - console.error(error) - return { success: false } - } -} - -export async function updateArtboardVersionBackgroundService({ - id, - background, -}: { - id: IArtboardVersion['id'] - background: string -}) { - try { - const updatedArtboardVersion = await updateArtboardVersionBackground({ - id, - background, - }) - return { success: true, artboardVersion: updatedArtboardVersion } - } catch (error) { - console.error(error) - return { success: false } - } -} diff --git a/app/services/artwork/branch/create.service.ts b/app/services/artwork/branch/create.service.ts new file mode 100644 index 00000000..d8de05dd --- /dev/null +++ b/app/services/artwork/branch/create.service.ts @@ -0,0 +1,113 @@ +import { invariant } from '@epic-web/invariant' +import { type IArtwork } from '#app/models/artwork/artwork.server' +import { + createArtworkBranch, + type IArtworkBranchCreatedResponse, +} from '#app/models/artwork-branch/artwork-branch.create.server' +import { getArtworkBranch } from '#app/models/artwork-branch/artwork-branch.get.server' +import { type IArtworkBranch } from '#app/models/artwork-branch/artwork-branch.server' +import { createArtworkVersion } from '#app/models/artwork-version/artwork-version.create.server' +import { getArtworkVersion } from '#app/models/artwork-version/artwork-version.get.server' +import { type IArtworkVersion } from '#app/models/artwork-version/artwork-version.server' +import { type IUser } from '#app/models/user/user.server' +import { ArtworkBranchDataCreateSchema } from '#app/schema/artwork-branch' +import { ArtworkVersionDataCreateSchema } from '#app/schema/artwork-version' +import { DesignCloneSourceTypeEnum } from '#app/schema/design' +import { LayerCloneSourceTypeEnum } from '#app/schema/layer' +import { stringToSlug } from '#app/utils/misc' +import { artworkVersionCloneDesignsService } from '../version/clone-designs.service' +import { artworkVersionCloneLayersService } from '../version/clone-layers.service' + +export const artworkBranchCreateService = async ({ + userId, + id, + artworkId, + versionId, + name, + description, +}: { + userId: IUser['id'] + id: IArtworkBranch['id'] + artworkId: IArtwork['id'] + versionId: IArtworkVersion['id'] + name: string + description?: string +}): Promise => { + try { + // Step 1: find the current artwork branch + // this could be the root branch ("main") + // or this could be a child branch + // get this for its name + const currentArtworkBranch = await getArtworkBranch({ + where: { id, ownerId: userId }, + }) + invariant(currentArtworkBranch, 'Current artwork branch not found') + + // Step 2: get data for new artwork branch + const branchData = ArtworkBranchDataCreateSchema.parse({ + ownerId: userId, + artworkId, + parentId: id, + name, + slug: stringToSlug(name), + description: + description || `New branch from ${currentArtworkBranch.name}`, + }) + + // Step 3: create the new artwork branch + const createdArtworkBranch = await createArtworkBranch({ + data: branchData, + }) + invariant(createdArtworkBranch, 'New artwork branch not created') + + // Step 4: get the current version of the artwork branch + // NOTE: do not use artworkVersionCreateService + // as that will attempt to connect versions from different branches + const currentArtworkVersion = await getArtworkVersion({ + where: { id: versionId, branchId: id, ownerId: userId }, + }) + invariant(currentArtworkVersion, 'Current artwork version not found') + + // Step 5: get data for new branch initial version + const { width, height, background } = currentArtworkVersion + const versionData = ArtworkVersionDataCreateSchema.parse({ + ownerId: userId, + branchId: createdArtworkBranch.id, + description: `New branch from ${currentArtworkBranch.name}, version ${currentArtworkVersion.name}`, + width, + height, + background, + }) + + // Step 6: create new artwork version + const createdArtworkVersion = await createArtworkVersion({ + data: versionData, + }) + invariant(createdArtworkVersion, 'New artwork version not created') + + // Step 7: copy contents of previous artwork version to new artwork version + await artworkVersionCloneDesignsService({ + userId, + sourceEntityType: DesignCloneSourceTypeEnum.ARTWORK_VERSION, + sourceEntityId: currentArtworkVersion.id, + targetEntityId: createdArtworkVersion.id, + }) + await artworkVersionCloneLayersService({ + userId, + sourceEntityType: LayerCloneSourceTypeEnum.ARTWORK_VERSION, + sourceEntityId: currentArtworkVersion.id, + targetEntityId: createdArtworkVersion.id, + }) + + return { + createdArtworkBranch, + success: true, + } + } catch (error) { + console.log(error) + return { + success: false, + message: 'Unknown error creating artwork generator.', + } + } +} diff --git a/app/services/artwork/branch/version/create.service.ts b/app/services/artwork/branch/version/create.service.ts new file mode 100644 index 00000000..a6aafaea --- /dev/null +++ b/app/services/artwork/branch/version/create.service.ts @@ -0,0 +1,136 @@ +import { invariant } from '@epic-web/invariant' +import { type User } from '@prisma/client' +import { type IArtworkBranch } from '#app/models/artwork-branch/artwork-branch.server' +import { + type IArtworkVersionCreatedResponse, + incrementVersionNameString, + createArtworkVersion, +} from '#app/models/artwork-version/artwork-version.create.server' +import { deleteArtworkVersions } from '#app/models/artwork-version/artwork-version.delete.server' +import { + getArtworkVersion, + getArtworkVersions, +} from '#app/models/artwork-version/artwork-version.get.server' +import { type IArtworkVersion } from '#app/models/artwork-version/artwork-version.server' +import { connectPrevAndNext } from '#app/models/artwork-version/artwork-version.update.server' +import { ArtworkVersionDataCreateSchema } from '#app/schema/artwork-version' +import { DesignCloneSourceTypeEnum } from '#app/schema/design' +import { LayerCloneSourceTypeEnum } from '#app/schema/layer' +import { prisma } from '#app/utils/db.server' +import { orderLinkedItems } from '#app/utils/linked-list.utils' +import { artworkVersionCloneDesignsService } from '../../version/clone-designs.service' +import { artworkVersionCloneLayersService } from '../../version/clone-layers.service' + +// copy contents of previous artwork version to new artwork version + +export const artworkVersionCreateService = async ({ + userId, + id, + artworkBranchId, + description, +}: { + userId: User['id'] + id: IArtworkVersion['id'] + artworkBranchId: IArtworkBranch['id'] + description: string +}): Promise => { + try { + // Step 1: find the current artwork version + // this could be the tail + // or this could be an earlier version where the version history is being reset + // aka undo, undo, undo, new version edits + const currentArtworkVersion = await getArtworkVersion({ + where: { id, ownerId: userId }, + }) + invariant(currentArtworkVersion, 'Current artwork version not found') + + // Step 2: get data for new artwork version + const { name, width, height, background } = currentArtworkVersion + const newName = incrementVersionNameString(name) + const data = ArtworkVersionDataCreateSchema.parse({ + ownerId: userId, + branchId: artworkBranchId, + name: newName, + slug: newName, + description: description || 'new version', + width, + height, + background, + }) + + // Step 3: delete all artwork versions after the current artwork version + // getting multiple heads and tails on v1... + const artworkVersions = await getArtworkVersions({ + where: { branchId: artworkBranchId }, + }) + const deleteArtworkVersionsPromise = deleteArtworkVersionsAfterCurrent({ + id, + artworkVersions, + }) + await prisma.$transaction([deleteArtworkVersionsPromise]) + + // Step 4: create new artwork version + const createdArtworkVersion = await createArtworkVersion({ data }) + invariant(createdArtworkVersion, 'New artwork version not created') + + // Step 5: connect created and current versions + const connectNodesPromise = connectPrevAndNext({ + prevId: currentArtworkVersion.id, + nextId: createdArtworkVersion.id, + }) + await prisma.$transaction(connectNodesPromise) + + // Step 6: copy contents of previous artwork version to new artwork version + await artworkVersionCloneDesignsService({ + userId, + sourceEntityType: DesignCloneSourceTypeEnum.ARTWORK_VERSION, + sourceEntityId: currentArtworkVersion.id, + targetEntityId: createdArtworkVersion.id, + }) + await artworkVersionCloneLayersService({ + userId, + sourceEntityType: LayerCloneSourceTypeEnum.ARTWORK_VERSION, + sourceEntityId: currentArtworkVersion.id, + targetEntityId: createdArtworkVersion.id, + }) + + return { createdArtworkVersion, success: true } + } catch (error) { + console.log('designCreateService error:', error) + const errorType = error instanceof Error + const errorMessage = errorType ? error.message : 'An unknown error occurred' + return { + success: false, + message: errorMessage, + } + } +} + +const deleteArtworkVersionsAfterCurrent = ({ + id, + artworkVersions, +}: { + id: IArtworkVersion['id'] + artworkVersions: IArtworkVersion[] +}) => { + // Step 1: already got all artwork versions for branch + // (work-around) for async/await and returning prisma promise + // Step 2: reorder the artwork versions as linked list + const orderedArtworkVersions = + orderLinkedItems(artworkVersions) + + // Step 3: find the index of the current artwork version + const currentIndex = orderedArtworkVersions.findIndex( + artworkVersion => artworkVersion.id === id, + ) + + // Step 4: get the id's of the artwork versions after the current index + const artworkVersionsToDeleteIds = orderedArtworkVersions + .slice(currentIndex + 1) + .map(({ id }) => id) + + // Step 5: return the promise that deletes them + return deleteArtworkVersions({ + ids: artworkVersionsToDeleteIds, + }) +} diff --git a/app/services/artboard/version/clone-designs.service.ts b/app/services/artwork/version/clone-designs.service.ts similarity index 64% rename from app/services/artboard/version/clone-designs.service.ts rename to app/services/artwork/version/clone-designs.service.ts index 37f74d0a..6f3be63e 100644 --- a/app/services/artboard/version/clone-designs.service.ts +++ b/app/services/artwork/version/clone-designs.service.ts @@ -1,11 +1,11 @@ import { type User } from '@prisma/client' -import { type IArtboardVersion } from '#app/models/artboard-version/artboard-version.server' +import { type IArtworkVersion } from '#app/models/artwork-version/artwork-version.server' import { type IDesignEntityId } from '#app/models/design/design.server' import { type designCloneSourceTypeEnum } from '#app/schema/design' -import { CloneDesignsToArtboardVersionStrategy } from '#app/strategies/design/clone.strategy' +import { CloneDesignsToArtworkVersionStrategy } from '#app/strategies/design/clone.strategy' import { cloneDesignsService } from '../../design/clone-many.service' -export const artboardVersionCloneDesignsService = async ({ +export const artworkVersionCloneDesignsService = async ({ userId, sourceEntityType, sourceEntityId, @@ -14,10 +14,10 @@ export const artboardVersionCloneDesignsService = async ({ userId: User['id'] sourceEntityType: designCloneSourceTypeEnum sourceEntityId: IDesignEntityId - targetEntityId: IArtboardVersion['id'] + targetEntityId: IArtworkVersion['id'] }) => { try { - const entityStrategy = new CloneDesignsToArtboardVersionStrategy() + const entityStrategy = new CloneDesignsToArtworkVersionStrategy() await cloneDesignsService({ userId, @@ -27,7 +27,7 @@ export const artboardVersionCloneDesignsService = async ({ entityStrategy, }) } catch (error) { - console.log('artboardVersionCloneDesignsService error:', error) + console.log('artworkVersionCloneDesignsService error:', error) const errorType = error instanceof Error const errorMessage = errorType ? error.message : 'An unknown error occurred' return { diff --git a/app/services/artboard/version/clone-layers.service.ts b/app/services/artwork/version/clone-layers.service.ts similarity index 64% rename from app/services/artboard/version/clone-layers.service.ts rename to app/services/artwork/version/clone-layers.service.ts index 3201f295..c6db538c 100644 --- a/app/services/artboard/version/clone-layers.service.ts +++ b/app/services/artwork/version/clone-layers.service.ts @@ -1,11 +1,11 @@ import { type User } from '@prisma/client' -import { type IArtboardVersion } from '#app/models/artboard-version/artboard-version.server' +import { type IArtworkVersion } from '#app/models/artwork-version/artwork-version.server' import { type ILayerEntityId } from '#app/models/layer/layer.server' import { type layerCloneSourceTypeEnum } from '#app/schema/layer' -import { CloneLayersToArtboardVersionStrategy } from '#app/strategies/layer/clone.strategy' +import { CloneLayersToArtworkVersionStrategy } from '#app/strategies/layer/clone.strategy' import { cloneLayersService } from '../../layer/clone-many.service' -export const artboardVersionCloneLayersService = async ({ +export const artworkVersionCloneLayersService = async ({ userId, sourceEntityType, sourceEntityId, @@ -14,10 +14,10 @@ export const artboardVersionCloneLayersService = async ({ userId: User['id'] sourceEntityType: layerCloneSourceTypeEnum sourceEntityId: ILayerEntityId - targetEntityId: IArtboardVersion['id'] + targetEntityId: IArtworkVersion['id'] }) => { try { - const entityStrategy = new CloneLayersToArtboardVersionStrategy() + const entityStrategy = new CloneLayersToArtworkVersionStrategy() await cloneLayersService({ userId, @@ -27,7 +27,7 @@ export const artboardVersionCloneLayersService = async ({ entityStrategy, }) } catch (error) { - console.log('artboardVersionCloneLayersService error:', error) + console.log('artworkVersionCloneLayersService error:', error) const errorType = error instanceof Error const errorMessage = errorType ? error.message : 'An unknown error occurred' return { diff --git a/app/services/artboard/version/design/create.service.ts b/app/services/artwork/version/design/create.service.ts similarity index 58% rename from app/services/artboard/version/design/create.service.ts rename to app/services/artwork/version/design/create.service.ts index 8dce6a25..0e148a00 100644 --- a/app/services/artboard/version/design/create.service.ts +++ b/app/services/artwork/version/design/create.service.ts @@ -1,45 +1,45 @@ import { type User } from '@prisma/client' -import { type IArtboardVersion } from '#app/models/artboard-version/artboard-version.server' +import { type IArtworkVersion } from '#app/models/artwork-version/artwork-version.server' import { type IDesignCreatedResponse } from '#app/models/design/design.create.server' import { type IDesignCreateOverrides, type IDesignTypeCreateOverrides, } from '#app/models/design/design.server' import { type designTypeEnum } from '#app/schema/design' -import { ArtboardVersionCreateDesignStrategy } from '#app/strategies/design/create.strategy' -import { ArtboardVersionUpdateSelectedDesignStrategy } from '#app/strategies/design/update-selected.strategy' +import { ArtworkVersionCreateDesignStrategy } from '#app/strategies/design/create.strategy' +import { ArtworkVersionUpdateSelectedDesignStrategy } from '#app/strategies/design/update-selected.strategy' import { designCreateService } from '../../../design/create.service' -export const artboardVersionDesignCreateService = async ({ +export const artworkVersionDesignCreateService = async ({ userId, - artboardVersionId, + artworkVersionId, type, designOverrides = {}, designTypeOverrides = {}, }: { userId: User['id'] - artboardVersionId: IArtboardVersion['id'] + artworkVersionId: IArtworkVersion['id'] type: designTypeEnum designOverrides?: IDesignCreateOverrides designTypeOverrides?: IDesignTypeCreateOverrides }): Promise => { try { - const strategy = new ArtboardVersionCreateDesignStrategy() + const strategy = new ArtworkVersionCreateDesignStrategy() const updateSelectedDesignStrategy = - new ArtboardVersionUpdateSelectedDesignStrategy() + new ArtworkVersionUpdateSelectedDesignStrategy() - const createdArtboardVersionDesign = await designCreateService({ + const createdArtworkVersionDesign = await designCreateService({ userId, - targetEntityId: artboardVersionId, + targetEntityId: artworkVersionId, type, designOverrides: designOverrides || {}, designTypeOverrides: designTypeOverrides || {}, strategy, updateSelectedDesignStrategy, }) - return createdArtboardVersionDesign + return createdArtworkVersionDesign } catch (error) { - console.log('artboardVersionDesignCreateService error:', error) + console.log('artworkVersionDesignCreateService error:', error) const errorType = error instanceof Error const errorMessage = errorType ? error.message : 'An unknown error occurred' return { diff --git a/app/services/artboard/version/design/delete.service.ts b/app/services/artwork/version/design/delete.service.ts similarity index 62% rename from app/services/artboard/version/design/delete.service.ts rename to app/services/artwork/version/design/delete.service.ts index 5789ed0f..008aaeec 100644 --- a/app/services/artboard/version/design/delete.service.ts +++ b/app/services/artwork/version/design/delete.service.ts @@ -1,33 +1,33 @@ import { type User } from '@prisma/client' -import { type IArtboardVersion } from '#app/models/artboard-version/artboard-version.server' +import { type IArtworkVersion } from '#app/models/artwork-version/artwork-version.server' import { type IDesignDeletedResponse } from '#app/models/design/design.delete.server' import { type IDesignIdOrNull, type IDesign } from '#app/models/design/design.server' -import { ArtboardVersionUpdateSelectedDesignStrategy } from '#app/strategies/design/update-selected.strategy' +import { ArtworkVersionUpdateSelectedDesignStrategy } from '#app/strategies/design/update-selected.strategy' import { designDeleteService } from '../../../design/delete.service' -export const artboardVersionDesignDeleteService = async ({ +export const artworkVersionDesignDeleteService = async ({ userId, id, - artboardVersionId, + artworkVersionId, updateSelectedDesignId, }: { userId: User['id'] id: IDesign['id'] - artboardVersionId: IArtboardVersion['id'] + artworkVersionId: IArtworkVersion['id'] updateSelectedDesignId: IDesignIdOrNull }): Promise => { try { const updateSelectedDesignStrategy = - new ArtboardVersionUpdateSelectedDesignStrategy() + new ArtworkVersionUpdateSelectedDesignStrategy() return designDeleteService({ userId, id, - targetEntityId: artboardVersionId, + targetEntityId: artworkVersionId, updateSelectedDesignId, updateSelectedDesignStrategy, }) } catch (error) { - console.log('artboardVersionDesignDeleteService error:', error) + console.log('artworkVersionDesignDeleteService error:', error) const errorType = error instanceof Error const errorMessage = errorType ? error.message : 'An unknown error occurred' return { diff --git a/app/services/artboard/version/design/move-down.service.ts b/app/services/artwork/version/design/move-down.service.ts similarity index 62% rename from app/services/artboard/version/design/move-down.service.ts rename to app/services/artwork/version/design/move-down.service.ts index c26a5d17..2c6af138 100644 --- a/app/services/artboard/version/design/move-down.service.ts +++ b/app/services/artwork/version/design/move-down.service.ts @@ -1,36 +1,36 @@ import { type User } from '@prisma/client' -import { type IArtboardVersion } from '#app/models/artboard-version/artboard-version.server' +import { type IArtworkVersion } from '#app/models/artwork-version/artwork-version.server' import { type IDesign, type IDesignIdOrNull, } from '#app/models/design/design.server' import { type IDesignUpdatedResponse } from '#app/models/design/design.update.server' -import { ArtboardVersionUpdateSelectedDesignStrategy } from '#app/strategies/design/update-selected.strategy' +import { ArtworkVersionUpdateSelectedDesignStrategy } from '#app/strategies/design/update-selected.strategy' import { designMoveDownService } from '../../../design/move-down.service' -export const artboardVersionDesignMoveDownService = async ({ +export const artworkVersionDesignMoveDownService = async ({ userId, id, - artboardVersionId, + artworkVersionId, updateSelectedDesignId, }: { userId: User['id'] id: IDesign['id'] - artboardVersionId: IArtboardVersion['id'] + artworkVersionId: IArtworkVersion['id'] updateSelectedDesignId?: IDesignIdOrNull }): Promise => { try { const updateSelectedDesignStrategy = - new ArtboardVersionUpdateSelectedDesignStrategy() + new ArtworkVersionUpdateSelectedDesignStrategy() return designMoveDownService({ userId, id, - targetEntityId: artboardVersionId, + targetEntityId: artworkVersionId, updateSelectedDesignId, updateSelectedDesignStrategy, }) } catch (error) { - console.log('artboardVersionDesignMoveDownService error:', error) + console.log('artworkVersionDesignMoveDownService error:', error) const errorType = error instanceof Error const errorMessage = errorType ? error.message : 'An unknown error occurred' return { diff --git a/app/services/artboard/version/design/move-up.service.ts b/app/services/artwork/version/design/move-up.service.ts similarity index 62% rename from app/services/artboard/version/design/move-up.service.ts rename to app/services/artwork/version/design/move-up.service.ts index 02f4f266..2fd1dadb 100644 --- a/app/services/artboard/version/design/move-up.service.ts +++ b/app/services/artwork/version/design/move-up.service.ts @@ -1,33 +1,33 @@ import { type User } from '@prisma/client' -import { type IArtboardVersion } from '#app/models/artboard-version/artboard-version.server' +import { type IArtworkVersion } from '#app/models/artwork-version/artwork-version.server' import { type IDesign, type IDesignIdOrNull } from '#app/models/design/design.server' import { type IDesignUpdatedResponse } from '#app/models/design/design.update.server' -import { ArtboardVersionUpdateSelectedDesignStrategy } from '#app/strategies/design/update-selected.strategy' +import { ArtworkVersionUpdateSelectedDesignStrategy } from '#app/strategies/design/update-selected.strategy' import { designMoveUpService } from '../../../design/move-up.service' -export const artboardVersionDesignMoveUpService = async ({ +export const artworkVersionDesignMoveUpService = async ({ userId, id, - artboardVersionId, + artworkVersionId, updateSelectedDesignId, }: { userId: User['id'] id: IDesign['id'] - artboardVersionId: IArtboardVersion['id'] + artworkVersionId: IArtworkVersion['id'] updateSelectedDesignId: IDesignIdOrNull }): Promise => { try { const updateSelectedDesignStrategy = - new ArtboardVersionUpdateSelectedDesignStrategy() + new ArtworkVersionUpdateSelectedDesignStrategy() return designMoveUpService({ userId, id, - targetEntityId: artboardVersionId, + targetEntityId: artworkVersionId, updateSelectedDesignId, updateSelectedDesignStrategy, }) } catch (error) { - console.log('artboardVersionDesignMoveUpService error:', error) + console.log('artworkVersionDesignMoveUpService error:', error) const errorType = error instanceof Error const errorMessage = errorType ? error.message : 'An unknown error occurred' return { diff --git a/app/services/artboard/version/design/toggle-visible.service.ts b/app/services/artwork/version/design/toggle-visible.service.ts similarity index 62% rename from app/services/artboard/version/design/toggle-visible.service.ts rename to app/services/artwork/version/design/toggle-visible.service.ts index de859db5..52731e48 100644 --- a/app/services/artboard/version/design/toggle-visible.service.ts +++ b/app/services/artwork/version/design/toggle-visible.service.ts @@ -1,36 +1,36 @@ import { type User } from '@prisma/client' -import { type IArtboardVersion } from '#app/models/artboard-version/artboard-version.server' +import { type IArtworkVersion } from '#app/models/artwork-version/artwork-version.server' import { type IDesign, type IDesignIdOrNull, } from '#app/models/design/design.server' import { type IDesignUpdatedResponse } from '#app/models/design/design.update.server' -import { ArtboardVersionUpdateSelectedDesignStrategy } from '#app/strategies/design/update-selected.strategy' +import { ArtworkVersionUpdateSelectedDesignStrategy } from '#app/strategies/design/update-selected.strategy' import { designToggleVisibleService } from '../../../design/toggle-visible.service' -export const artboardVersionDesignToggleVisibleService = async ({ +export const artworkVersionDesignToggleVisibleService = async ({ userId, id, - artboardVersionId, + artworkVersionId, updateSelectedDesignId, }: { userId: User['id'] id: IDesign['id'] - artboardVersionId: IArtboardVersion['id'] + artworkVersionId: IArtworkVersion['id'] updateSelectedDesignId: IDesignIdOrNull }): Promise => { try { const updateSelectedDesignStrategy = - new ArtboardVersionUpdateSelectedDesignStrategy() + new ArtworkVersionUpdateSelectedDesignStrategy() return designToggleVisibleService({ userId, id, - targetEntityId: artboardVersionId, + targetEntityId: artworkVersionId, updateSelectedDesignId, updateSelectedDesignStrategy, }) } catch (error) { - console.log('artboardVersionDesignToggleVisibleService error:', error) + console.log('artworkVersionDesignToggleVisibleService error:', error) const errorType = error instanceof Error const errorMessage = errorType ? error.message : 'An unknown error occurred' return { diff --git a/app/services/artboard/version/generator/build.service.ts b/app/services/artwork/version/generator/build.service.ts similarity index 83% rename from app/services/artboard/version/generator/build.service.ts rename to app/services/artwork/version/generator/build.service.ts index 1a84aa49..0578d09f 100644 --- a/app/services/artboard/version/generator/build.service.ts +++ b/app/services/artwork/version/generator/build.service.ts @@ -1,17 +1,17 @@ import { type IGeneratorDesigns, type ILayerGenerator, - type IArtboardVersionGenerator, -} from '#app/definitions/artboard-generator' -import { type IArtboardVersionWithDesignsAndLayers } from '#app/models/artboard-version/artboard-version.server' + type IArtworkVersionGenerator, +} from '#app/definitions/artwork-generator' +import { type IArtworkVersionWithDesignsAndLayers } from '#app/models/artwork-version/artwork-version.server' import { findManyDesignsWithType, type IDesignWithType, } from '#app/models/design/design.server' import { - getArtboardVersionVisiblePalettes, - getArtboardVersionVisibleRotates, -} from '#app/models/design-artboard-version/design-artboard-version.server' + getArtworkVersionVisiblePalettes, + getArtworkVersionVisibleRotates, +} from '#app/models/design-artwork-version/design-artwork-version.server' import { getLayerVisiblePalettes, getLayerVisibleRotates, @@ -29,11 +29,11 @@ import { isArrayRotateBasisType } from '#app/utils/rotate' // "build" since it is creating the version generator each time // later, if we like the generator, we can save it to the database -export const artboardVersionGeneratorBuildService = async ({ +export const artworkVersionGeneratorBuildService = async ({ version, }: { - version: IArtboardVersionWithDesignsAndLayers -}): Promise => { + version: IArtworkVersionWithDesignsAndLayers +}): Promise => { try { // Step 1: verify version selected designs are all present const { defaultGeneratorDesigns, message } = @@ -79,7 +79,7 @@ export const artboardVersionGeneratorBuildService = async ({ }, layers: generatorLayers, success: true, - message: 'Artboard version generator created successfully.', + message: 'Artwork version generator created successfully.', } } catch (error) { console.log(error) @@ -92,7 +92,7 @@ export const artboardVersionGeneratorBuildService = async ({ }, layers: [], success: false, - message: 'Unknown error creating artboard version generator.', + message: 'Unknown error creating artwork version generator.', } } } @@ -100,7 +100,7 @@ export const artboardVersionGeneratorBuildService = async ({ const verifyDefaultGeneratorDesigns = async ({ version, }: { - version: IArtboardVersionWithDesignsAndLayers + version: IArtworkVersionWithDesignsAndLayers }): Promise<{ defaultGeneratorDesigns: IGeneratorDesigns | null message: string @@ -108,7 +108,7 @@ const verifyDefaultGeneratorDesigns = async ({ // Step 1: get all selected designs for the version // design table has `selected: boolean` field const selectedDesigns = await getVersionSelectedDesigns({ - artboardVersionId: version.id, + artworkVersionId: version.id, }) // Step 2: split the selected designs into the first of each type @@ -144,12 +144,12 @@ const verifyDefaultGeneratorDesigns = async ({ } const getVersionSelectedDesigns = async ({ - artboardVersionId, + artworkVersionId, }: { - artboardVersionId: IArtboardVersionWithDesignsAndLayers['id'] + artworkVersionId: IArtworkVersionWithDesignsAndLayers['id'] }): Promise => { return await findManyDesignsWithType({ - where: { artboardVersionId, selected: true }, + where: { artworkVersionId, selected: true }, }) } @@ -159,24 +159,24 @@ const buildDefaultGeneratorLayer = async ({ version, defaultGeneratorDesigns, }: { - version: IArtboardVersionWithDesignsAndLayers + version: IArtworkVersionWithDesignsAndLayers defaultGeneratorDesigns: IGeneratorDesigns }): Promise => { - const artboardVersionId = version.id + const artworkVersionId = version.id // get all visible palettes to use for fill or stroke - const palettes = await getArtboardVersionVisiblePalettes({ - artboardVersionId, + const palettes = await getArtworkVersionVisiblePalettes({ + artworkVersionId, }) // get all visible rotates to use for rotate if visible random const rotates = await getRotates({ - artboardVersionId, + artworkVersionId, rotate: defaultGeneratorDesigns.rotate, }) // container defaults to version dimensions - const container = getArtboardVersionContainer({ version }) + const container = getArtworkVersionContainer({ version }) return { ...defaultGeneratorDesigns, @@ -186,10 +186,10 @@ const buildDefaultGeneratorLayer = async ({ } } -const getArtboardVersionContainer = ({ +const getArtworkVersionContainer = ({ version, }: { - version: IArtboardVersionWithDesignsAndLayers + version: IArtworkVersionWithDesignsAndLayers }) => { const { width, height } = version return { @@ -296,19 +296,19 @@ const getLayerSelectedDesigns = async ({ } const getRotates = async ({ - artboardVersionId, + artworkVersionId, layerId, rotate, }: { - artboardVersionId?: IArtboardVersionWithDesignsAndLayers['id'] + artworkVersionId?: IArtworkVersionWithDesignsAndLayers['id'] layerId?: ILayer['id'] rotate: IRotate }) => { const allRotates = isArrayRotateBasisType(rotate.basis as rotateBasisTypeEnum) if (allRotates) { - if (artboardVersionId) { - return await getArtboardVersionVisibleRotates({ artboardVersionId }) + if (artworkVersionId) { + return await getArtworkVersionVisibleRotates({ artworkVersionId }) } else if (layerId) { return await getLayerVisibleRotates({ layerId }) } diff --git a/app/services/artboard/version/layer/clone-designs.service.ts b/app/services/artwork/version/layer/clone-designs.service.ts similarity index 88% rename from app/services/artboard/version/layer/clone-designs.service.ts rename to app/services/artwork/version/layer/clone-designs.service.ts index d99b75bd..8247bd00 100644 --- a/app/services/artboard/version/layer/clone-designs.service.ts +++ b/app/services/artwork/version/layer/clone-designs.service.ts @@ -5,7 +5,7 @@ import { type designCloneSourceTypeEnum } from '#app/schema/design' import { CloneDesignToLayerStrategy } from '#app/strategies/design/clone.strategy' import { cloneDesignsService } from '../../../design/clone-many.service' -export const artboardVersionLayerCloneDesignsService = async ({ +export const artworkVersionLayerCloneDesignsService = async ({ userId, sourceEntityType, sourceEntityId, @@ -27,7 +27,7 @@ export const artboardVersionLayerCloneDesignsService = async ({ entityStrategy, }) } catch (error) { - console.log('artboardVersionLayerCloneDesignsService error:', error) + console.log('artworkVersionLayerCloneDesignsService error:', error) const errorType = error instanceof Error const errorMessage = errorType ? error.message : 'An unknown error occurred' return { diff --git a/app/services/artboard/version/layer/create.service.ts b/app/services/artwork/version/layer/create.service.ts similarity index 62% rename from app/services/artboard/version/layer/create.service.ts rename to app/services/artwork/version/layer/create.service.ts index 5ac00740..7f63e8fe 100644 --- a/app/services/artboard/version/layer/create.service.ts +++ b/app/services/artwork/version/layer/create.service.ts @@ -1,32 +1,32 @@ import { type User } from '@prisma/client' -import { type IArtboardVersion } from '#app/models/artboard-version/artboard-version.server' +import { type IArtworkVersion } from '#app/models/artwork-version/artwork-version.server' import { type ILayerCreatedResponse } from '#app/models/layer/layer.create.server' import { type ILayerCreateOverrides } from '#app/models/layer/layer.server' -import { ArtboardVersionCreateLayerStrategy } from '#app/strategies/layer/create.strategy' +import { ArtworkVersionCreateLayerStrategy } from '#app/strategies/layer/create.strategy' import { layerCreateService } from '../../../layer/create.service' -export const artboardVersionLayerCreateService = async ({ +export const artworkVersionLayerCreateService = async ({ userId, - artboardVersionId, + artworkVersionId, layerOverrides = {}, skipCloneDesigns = false, }: { userId: User['id'] - artboardVersionId: IArtboardVersion['id'] + artworkVersionId: IArtworkVersion['id'] layerOverrides?: ILayerCreateOverrides skipCloneDesigns?: boolean }): Promise => { try { - const strategy = new ArtboardVersionCreateLayerStrategy() + const strategy = new ArtworkVersionCreateLayerStrategy() return await layerCreateService({ userId, - targetEntityId: artboardVersionId, + targetEntityId: artworkVersionId, layerOverrides, skipCloneDesigns, strategy, }) } catch (error) { - console.log('artboardVersionLayerCreateService error:', error) + console.log('artworkVersionLayerCreateService error:', error) const errorType = error instanceof Error const errorMessage = errorType ? error.message : 'An unknown error occurred' return { diff --git a/app/services/artboard/version/layer/delete.service.ts b/app/services/artwork/version/layer/delete.service.ts similarity index 91% rename from app/services/artboard/version/layer/delete.service.ts rename to app/services/artwork/version/layer/delete.service.ts index c56d2f04..a7d68c93 100644 --- a/app/services/artboard/version/layer/delete.service.ts +++ b/app/services/artwork/version/layer/delete.service.ts @@ -1,4 +1,4 @@ -import { type IArtboardVersion } from '#app/models/artboard-version/artboard-version.server' +import { type IArtworkVersion } from '#app/models/artwork-version/artwork-version.server' import { type ILayerDeletedResponse } from '#app/models/layer/layer.delete.server' import { findFirstLayer, @@ -11,14 +11,14 @@ import { type IUser } from '#app/models/user/user.server' import { prisma } from '#app/utils/db.server' // TODO: move logic to direct layer service -export const artboardVersionLayerDeleteService = async ({ +export const artworkVersionLayerDeleteService = async ({ userId, id, - artboardVersionId, + artworkVersionId, }: { userId: IUser['id'] id: ILayer['id'] - artboardVersionId: IArtboardVersion['id'] + artworkVersionId: IArtworkVersion['id'] }): Promise => { try { // Step 1: get the layer @@ -49,7 +49,7 @@ export const artboardVersionLayerDeleteService = async ({ return { success: true } } catch (error) { - console.log('artboardVersionLayerDeleteService error:', error) + console.log('artworkVersionLayerDeleteService error:', error) const errorType = error instanceof Error const errorMessage = errorType ? error.message : 'An unknown error occurred' return { diff --git a/app/services/artboard/version/layer/move-down.service.ts b/app/services/artwork/version/layer/move-down.service.ts similarity index 93% rename from app/services/artboard/version/layer/move-down.service.ts rename to app/services/artwork/version/layer/move-down.service.ts index 24773eae..8f787884 100644 --- a/app/services/artboard/version/layer/move-down.service.ts +++ b/app/services/artwork/version/layer/move-down.service.ts @@ -1,4 +1,4 @@ -import { type IArtboardVersion } from '#app/models/artboard-version/artboard-version.server' +import { type IArtworkVersion } from '#app/models/artwork-version/artwork-version.server' import { findFirstLayer, updateLayerRemoveNodes, @@ -8,14 +8,14 @@ import { import { type IUser } from '#app/models/user/user.server' import { prisma } from '#app/utils/db.server' -export const artboardVersionLayerMoveDownService = async ({ +export const artworkVersionLayerMoveDownService = async ({ userId, id, - artboardVersionId, + artworkVersionId, }: { userId: IUser['id'] id: ILayer['id'] - artboardVersionId: IArtboardVersion['id'] + artworkVersionId: IArtworkVersion['id'] }) => { try { const moveDownLayerPromises = [] @@ -59,7 +59,7 @@ export const artboardVersionLayerMoveDownService = async ({ return { success: true } } catch (error) { - console.log('artboardVersionLayerMoveDownService error:', error) + console.log('artworkVersionLayerMoveDownService error:', error) const errorType = error instanceof Error const errorMessage = errorType ? error.message : 'An unknown error occurred' return { diff --git a/app/services/artboard/version/layer/move-up.service.ts b/app/services/artwork/version/layer/move-up.service.ts similarity index 93% rename from app/services/artboard/version/layer/move-up.service.ts rename to app/services/artwork/version/layer/move-up.service.ts index 9f249e51..88d9d5b7 100644 --- a/app/services/artboard/version/layer/move-up.service.ts +++ b/app/services/artwork/version/layer/move-up.service.ts @@ -1,4 +1,4 @@ -import { type IArtboardVersion } from '#app/models/artboard-version/artboard-version.server' +import { type IArtworkVersion } from '#app/models/artwork-version/artwork-version.server' import { findFirstLayer, updateLayerRemoveNodes, @@ -8,14 +8,14 @@ import { import { type IUser } from '#app/models/user/user.server' import { prisma } from '#app/utils/db.server' -export const artboardVersionLayerMoveUpService = async ({ +export const artworkVersionLayerMoveUpService = async ({ userId, id, - artboardVersionId, + artworkVersionId, }: { userId: IUser['id'] id: ILayer['id'] - artboardVersionId: IArtboardVersion['id'] + artworkVersionId: IArtworkVersion['id'] }) => { try { const moveUpLayerPromises = [] @@ -59,7 +59,7 @@ export const artboardVersionLayerMoveUpService = async ({ return { success: true } } catch (error) { - console.log('artboardVersionLayerMoveUpService error:', error) + console.log('artworkVersionLayerMoveUpService error:', error) const errorType = error instanceof Error const errorMessage = errorType ? error.message : 'An unknown error occurred' return { diff --git a/app/services/artboard/version/layer/select.service.ts b/app/services/artwork/version/layer/select.service.ts similarity index 68% rename from app/services/artboard/version/layer/select.service.ts rename to app/services/artwork/version/layer/select.service.ts index 308b390c..b8ca01b1 100644 --- a/app/services/artboard/version/layer/select.service.ts +++ b/app/services/artwork/version/layer/select.service.ts @@ -1,20 +1,20 @@ -import { type IArtboardVersion } from '#app/models/artboard-version/artboard-version.server' +import { type IArtworkVersion } from '#app/models/artwork-version/artwork-version.server' import { findFirstLayer, type ILayer } from '#app/models/layer/layer.server' import { - deselectArtboardVersionLayers, + deselectArtworkVersionLayers, updateLayerSelected, -} from '#app/models/layer-artboard-version/layer-artboard-version.update.server' +} from '#app/models/layer-artwork-version/layer-artwork-version.update.server' import { type IUser } from '#app/models/user/user.server' import { prisma } from '#app/utils/db.server' -export const artboardVersionLayerSelectService = async ({ +export const artworkVersionLayerSelectService = async ({ userId, id, - artboardVersionId, + artworkVersionId, }: { userId: IUser['id'] id: ILayer['id'] - artboardVersionId: IArtboardVersion['id'] + artworkVersionId: IArtworkVersion['id'] }) => { try { const promises = [] @@ -22,9 +22,9 @@ export const artboardVersionLayerSelectService = async ({ const layer = await getLayer({ id, userId }) const { selected } = layer - // Step 2: deselect all layers in the artboard version - const deselectLayersPromise = deselectArtboardVersionLayers({ - artboardVersionId, + // Step 2: deselect all layers in the artwork version + const deselectLayersPromise = deselectArtworkVersionLayers({ + artworkVersionId, }) promises.push(deselectLayersPromise) @@ -41,7 +41,7 @@ export const artboardVersionLayerSelectService = async ({ return { success: true } } catch (error) { - console.log('artboardVersionLayerSelectService error:', error) + console.log('artworkVersionLayerSelectService error:', error) const errorType = error instanceof Error const errorMessage = errorType ? error.message : 'An unknown error occurred' return { diff --git a/app/services/artboard/version/layer/toggle-visible.service.ts b/app/services/artwork/version/layer/toggle-visible.service.ts similarity index 78% rename from app/services/artboard/version/layer/toggle-visible.service.ts rename to app/services/artwork/version/layer/toggle-visible.service.ts index 65bdf440..ae9afc79 100644 --- a/app/services/artboard/version/layer/toggle-visible.service.ts +++ b/app/services/artwork/version/layer/toggle-visible.service.ts @@ -1,4 +1,4 @@ -import { type IArtboardVersion } from '#app/models/artboard-version/artboard-version.server' +import { type IArtworkVersion } from '#app/models/artwork-version/artwork-version.server' import { findFirstLayer, updateLayerVisible, @@ -7,14 +7,14 @@ import { import { type IUser } from '#app/models/user/user.server' import { prisma } from '#app/utils/db.server' -export const artboardVersionLayerToggleVisibleService = async ({ +export const artworkVersionLayerToggleVisibleService = async ({ userId, id, - artboardVersionId, + artworkVersionId, }: { userId: IUser['id'] id: ILayer['id'] - artboardVersionId: IArtboardVersion['id'] + artworkVersionId: IArtworkVersion['id'] }) => { try { // Step 1: get the design @@ -30,7 +30,7 @@ export const artboardVersionLayerToggleVisibleService = async ({ return { success: true } } catch (error) { - console.log('artboardVersionLayerToggleVisibleService error:', error) + console.log('artworkVersionLayerToggleVisibleService error:', error) const errorType = error instanceof Error const errorMessage = errorType ? error.message : 'An unknown error occurred' return { diff --git a/app/services/artwork/version/update.service.ts b/app/services/artwork/version/update.service.ts new file mode 100644 index 00000000..f2b88c9b --- /dev/null +++ b/app/services/artwork/version/update.service.ts @@ -0,0 +1,65 @@ +import { type IArtworkVersion } from '#app/models/artwork-version/artwork-version.server' +import { + updateArtworkVersionBackground, + updateArtworkVersionHeight, + updateArtworkVersionWidth, +} from '#app/models/artwork-version/artwork-version.update.server' + +export async function updateArtworkVersionWidthService({ + id, + width, +}: { + id: IArtworkVersion['id'] + width: number +}) { + try { + const updatedArtworkVersion = await updateArtworkVersionWidth({ + id, + width, + }) + // later will be adding Activity class + // i.e, edit history so you can undo changes and/or see who made them + return { success: true, artworkVersion: updatedArtworkVersion } + } catch (error) { + console.error(error) + return { success: false } + } +} + +export async function updateArtworkVersionHeightService({ + id, + height, +}: { + id: IArtworkVersion['id'] + height: number +}) { + try { + const updatedArtworkVersion = await updateArtworkVersionHeight({ + id, + height, + }) + return { success: true, artworkVersion: updatedArtworkVersion } + } catch (error) { + console.error(error) + return { success: false } + } +} + +export async function updateArtworkVersionBackgroundService({ + id, + background, +}: { + id: IArtworkVersion['id'] + background: string +}) { + try { + const updatedArtworkVersion = await updateArtworkVersionBackground({ + id, + background, + }) + return { success: true, artworkVersion: updatedArtworkVersion } + } catch (error) { + console.error(error) + return { success: false } + } +} diff --git a/app/services/canvas/draw-background.service.ts b/app/services/canvas/draw-background.service.ts index dec48271..c71bd3f0 100644 --- a/app/services/canvas/draw-background.service.ts +++ b/app/services/canvas/draw-background.service.ts @@ -1,11 +1,11 @@ -import { type IArtboardVersionGenerator } from '#app/definitions/artboard-generator' +import { type IArtworkVersionGenerator } from '#app/definitions/artwork-generator' export const canvasDrawBackgroundService = ({ ctx, generator, }: { ctx: CanvasRenderingContext2D - generator: IArtboardVersionGenerator + generator: IArtworkVersionGenerator }) => { const { width, height, background } = generator.settings diff --git a/app/services/canvas/draw.service.ts b/app/services/canvas/draw.service.ts index edd31016..7d6283a3 100644 --- a/app/services/canvas/draw.service.ts +++ b/app/services/canvas/draw.service.ts @@ -1,4 +1,4 @@ -import { type IArtboardVersionGenerator } from '#app/definitions/artboard-generator' +import { type IArtworkVersionGenerator } from '#app/definitions/artwork-generator' import { canvasDrawBackgroundService } from './draw-background.service' import { canvasLayerBuildDrawLayersService } from './layer/build/build-draw-layers.service' import { canvasDrawLayersService } from './layer/draw/draw-layers.service' @@ -8,7 +8,7 @@ export const canvasDrawService = ({ generator, }: { canvas: HTMLCanvasElement - generator: IArtboardVersionGenerator + generator: IArtworkVersionGenerator }) => { // Step 1: get canvas const ctx = getContext(canvas) diff --git a/app/services/canvas/layer/build/build-draw-layers.service.ts b/app/services/canvas/layer/build/build-draw-layers.service.ts index 10fa5347..c941a6f5 100644 --- a/app/services/canvas/layer/build/build-draw-layers.service.ts +++ b/app/services/canvas/layer/build/build-draw-layers.service.ts @@ -1,8 +1,8 @@ import { - type IArtboardVersionGenerator, + type IArtworkVersionGenerator, type IGenerationItem, type ILayerGenerator, -} from '#app/definitions/artboard-generator' +} from '#app/definitions/artwork-generator' import { canvasBuildLayerDrawCountService } from './build-layer-draw-count.service' import { canvasBuildLayerDrawFillService } from './build-layer-draw-fill.service' import { canvasBuildLayerDrawLineService } from './build-layer-draw-line.service' @@ -17,7 +17,7 @@ export const canvasLayerBuildDrawLayersService = ({ generator, }: { ctx: CanvasRenderingContext2D - generator: IArtboardVersionGenerator + generator: IArtworkVersionGenerator }): IGenerationItem[][] => { const { layers } = generator diff --git a/app/services/canvas/layer/build/build-layer-draw-count.service.ts b/app/services/canvas/layer/build/build-layer-draw-count.service.ts index e9da49b6..f91384d8 100644 --- a/app/services/canvas/layer/build/build-layer-draw-count.service.ts +++ b/app/services/canvas/layer/build/build-layer-draw-count.service.ts @@ -1,4 +1,4 @@ -import { type ILayerGenerator } from '#app/definitions/artboard-generator' +import { type ILayerGenerator } from '#app/definitions/artwork-generator' import { LayoutStyleTypeEnum } from '#app/schema/layout' export const canvasBuildLayerDrawCountService = ({ diff --git a/app/services/canvas/layer/build/build-layer-draw-fill.service.ts b/app/services/canvas/layer/build/build-layer-draw-fill.service.ts index 829f4427..1be3dbeb 100644 --- a/app/services/canvas/layer/build/build-layer-draw-fill.service.ts +++ b/app/services/canvas/layer/build/build-layer-draw-fill.service.ts @@ -1,4 +1,4 @@ -import { type ILayerGenerator } from '#app/definitions/artboard-generator' +import { type ILayerGenerator } from '#app/definitions/artwork-generator' import { FillBasisTypeEnum, FillStyleTypeEnum } from '#app/schema/fill' import { getCircularItemInArray, diff --git a/app/services/canvas/layer/build/build-layer-draw-line.service.ts b/app/services/canvas/layer/build/build-layer-draw-line.service.ts index 759938a6..1ff38caa 100644 --- a/app/services/canvas/layer/build/build-layer-draw-line.service.ts +++ b/app/services/canvas/layer/build/build-layer-draw-line.service.ts @@ -1,4 +1,4 @@ -import { type ILayerGenerator } from '#app/definitions/artboard-generator' +import { type ILayerGenerator } from '#app/definitions/artwork-generator' import { LineFormatTypeEnum } from '#app/schema/line' import { linePercentToPixel } from '#app/utils/line' diff --git a/app/services/canvas/layer/build/build-layer-draw-position.service.ts b/app/services/canvas/layer/build/build-layer-draw-position.service.ts index 5674a631..0e3d9bc4 100644 --- a/app/services/canvas/layer/build/build-layer-draw-position.service.ts +++ b/app/services/canvas/layer/build/build-layer-draw-position.service.ts @@ -1,4 +1,4 @@ -import { type ILayerGenerator } from '#app/definitions/artboard-generator' +import { type ILayerGenerator } from '#app/definitions/artwork-generator' import { FillBasisTypeEnum } from '#app/schema/fill' import { LayoutStyleTypeEnum } from '#app/schema/layout' import { StrokeBasisTypeEnum } from '#app/schema/stroke' diff --git a/app/services/canvas/layer/build/build-layer-draw-rotate.service.ts b/app/services/canvas/layer/build/build-layer-draw-rotate.service.ts index 4f32336f..4e3096ab 100644 --- a/app/services/canvas/layer/build/build-layer-draw-rotate.service.ts +++ b/app/services/canvas/layer/build/build-layer-draw-rotate.service.ts @@ -1,4 +1,4 @@ -import { type ILayerGenerator } from '#app/definitions/artboard-generator' +import { type ILayerGenerator } from '#app/definitions/artwork-generator' import { RotateBasisTypeEnum } from '#app/schema/rotate' import { getCircularItemInArray, diff --git a/app/services/canvas/layer/build/build-layer-draw-size.service.ts b/app/services/canvas/layer/build/build-layer-draw-size.service.ts index d3de520d..406e6004 100644 --- a/app/services/canvas/layer/build/build-layer-draw-size.service.ts +++ b/app/services/canvas/layer/build/build-layer-draw-size.service.ts @@ -1,4 +1,4 @@ -import { type ILayerGenerator } from '#app/definitions/artboard-generator' +import { type ILayerGenerator } from '#app/definitions/artwork-generator' import { LineFormatTypeEnum } from '#app/schema/line' import { SizeFormatTypeEnum } from '#app/schema/size' import { diff --git a/app/services/canvas/layer/build/build-layer-draw-stroke.service.ts b/app/services/canvas/layer/build/build-layer-draw-stroke.service.ts index b0794414..293feabb 100644 --- a/app/services/canvas/layer/build/build-layer-draw-stroke.service.ts +++ b/app/services/canvas/layer/build/build-layer-draw-stroke.service.ts @@ -1,4 +1,4 @@ -import { type ILayerGenerator } from '#app/definitions/artboard-generator' +import { type ILayerGenerator } from '#app/definitions/artwork-generator' import { StrokeBasisTypeEnum } from '#app/schema/stroke' import { getCircularItemInArray, diff --git a/app/services/canvas/layer/build/build-layer-draw-template.service.ts b/app/services/canvas/layer/build/build-layer-draw-template.service.ts index bb3fb099..179c57f1 100644 --- a/app/services/canvas/layer/build/build-layer-draw-template.service.ts +++ b/app/services/canvas/layer/build/build-layer-draw-template.service.ts @@ -1,4 +1,4 @@ -import { type ILayerGenerator } from '#app/definitions/artboard-generator' +import { type ILayerGenerator } from '#app/definitions/artwork-generator' export const canvasBuildLayerDrawTemplateService = ({ layer, diff --git a/app/services/canvas/layer/draw/draw-layer-item-fill.service.ts b/app/services/canvas/layer/draw/draw-layer-item-fill.service.ts index 7ecb9b6f..1314c3eb 100644 --- a/app/services/canvas/layer/draw/draw-layer-item-fill.service.ts +++ b/app/services/canvas/layer/draw/draw-layer-item-fill.service.ts @@ -1,4 +1,4 @@ -import { type IGenerationItem } from '#app/definitions/artboard-generator' +import { type IGenerationItem } from '#app/definitions/artwork-generator' export const drawLayerItemFillService = ({ ctx, diff --git a/app/services/canvas/layer/draw/draw-layer-item-line.service.ts b/app/services/canvas/layer/draw/draw-layer-item-line.service.ts index 2e281548..7970db69 100644 --- a/app/services/canvas/layer/draw/draw-layer-item-line.service.ts +++ b/app/services/canvas/layer/draw/draw-layer-item-line.service.ts @@ -1,4 +1,4 @@ -import { type IGenerationItem } from '#app/definitions/artboard-generator' +import { type IGenerationItem } from '#app/definitions/artwork-generator' export const drawLayerItemLineService = ({ ctx, diff --git a/app/services/canvas/layer/draw/draw-layer-item-position.service.ts b/app/services/canvas/layer/draw/draw-layer-item-position.service.ts index 204a1a1d..dab95430 100644 --- a/app/services/canvas/layer/draw/draw-layer-item-position.service.ts +++ b/app/services/canvas/layer/draw/draw-layer-item-position.service.ts @@ -1,4 +1,4 @@ -import { type IGenerationItem } from '#app/definitions/artboard-generator' +import { type IGenerationItem } from '#app/definitions/artwork-generator' export const drawLayerItemPositionService = ({ ctx, diff --git a/app/services/canvas/layer/draw/draw-layer-item-rotate.service.ts b/app/services/canvas/layer/draw/draw-layer-item-rotate.service.ts index a72defe5..741794cd 100644 --- a/app/services/canvas/layer/draw/draw-layer-item-rotate.service.ts +++ b/app/services/canvas/layer/draw/draw-layer-item-rotate.service.ts @@ -1,4 +1,4 @@ -import { type IGenerationItem } from '#app/definitions/artboard-generator' +import { type IGenerationItem } from '#app/definitions/artwork-generator' export const drawLayerItemRotateService = ({ ctx, diff --git a/app/services/canvas/layer/draw/draw-layer-item-stroke.service.ts b/app/services/canvas/layer/draw/draw-layer-item-stroke.service.ts index 89738602..db9e1e6a 100644 --- a/app/services/canvas/layer/draw/draw-layer-item-stroke.service.ts +++ b/app/services/canvas/layer/draw/draw-layer-item-stroke.service.ts @@ -1,4 +1,4 @@ -import { type IGenerationItem } from '#app/definitions/artboard-generator' +import { type IGenerationItem } from '#app/definitions/artwork-generator' export const drawLayerItemStrokeService = ({ ctx, diff --git a/app/services/canvas/layer/draw/draw-layer-item-template.service.ts b/app/services/canvas/layer/draw/draw-layer-item-template.service.ts index 7eba7e7e..9c454b3d 100644 --- a/app/services/canvas/layer/draw/draw-layer-item-template.service.ts +++ b/app/services/canvas/layer/draw/draw-layer-item-template.service.ts @@ -1,4 +1,4 @@ -import { type IGenerationItem } from '#app/definitions/artboard-generator' +import { type IGenerationItem } from '#app/definitions/artwork-generator' import { drawTemplateTriangleService } from './templates/draw-layer-item-template-triangle.service' export const drawLayerItemTemplateService = ({ diff --git a/app/services/canvas/layer/draw/draw-layer-item.service.ts b/app/services/canvas/layer/draw/draw-layer-item.service.ts index b2ba34cc..4621c386 100644 --- a/app/services/canvas/layer/draw/draw-layer-item.service.ts +++ b/app/services/canvas/layer/draw/draw-layer-item.service.ts @@ -1,4 +1,4 @@ -import { type IGenerationItem } from '#app/definitions/artboard-generator' +import { type IGenerationItem } from '#app/definitions/artwork-generator' import { ctxBegin, ctxEnd } from '../../ctx.utils' import { drawLayerItemFillService } from './draw-layer-item-fill.service' import { drawLayerItemLineService } from './draw-layer-item-line.service' diff --git a/app/services/canvas/layer/draw/draw-layers.service.ts b/app/services/canvas/layer/draw/draw-layers.service.ts index 7e5b60a1..27aac4e6 100644 --- a/app/services/canvas/layer/draw/draw-layers.service.ts +++ b/app/services/canvas/layer/draw/draw-layers.service.ts @@ -1,4 +1,4 @@ -import { type IGenerationItem } from '#app/definitions/artboard-generator' +import { type IGenerationItem } from '#app/definitions/artwork-generator' import { drawLayerItemService } from './draw-layer-item.service' export const canvasDrawLayersService = ({ diff --git a/app/services/canvas/layer/draw/templates/draw-layer-item-template-triangle.service.ts b/app/services/canvas/layer/draw/templates/draw-layer-item-template-triangle.service.ts index 93c90d40..c6079dfb 100644 --- a/app/services/canvas/layer/draw/templates/draw-layer-item-template-triangle.service.ts +++ b/app/services/canvas/layer/draw/templates/draw-layer-item-template-triangle.service.ts @@ -1,4 +1,4 @@ -import { type IGenerationItem } from '#app/definitions/artboard-generator' +import { type IGenerationItem } from '#app/definitions/artwork-generator' export const drawTemplateTriangleService = ({ ctx, diff --git a/app/services/design/clone-many.service.ts b/app/services/design/clone-many.service.ts index fa518314..9b50d0c1 100644 --- a/app/services/design/clone-many.service.ts +++ b/app/services/design/clone-many.service.ts @@ -67,8 +67,8 @@ const getSourceEntityDesigns = async ({ sourceEntityId: IDesignEntityId }): Promise => { const where = - sourceEntityType === DesignCloneSourceTypeEnum.ARTBOARD_VERSION - ? { artboardVersionId: sourceEntityId } + sourceEntityType === DesignCloneSourceTypeEnum.ARTWORK_VERSION + ? { artworkVersionId: sourceEntityId } : { layerId: sourceEntityId } return await findManyDesignsWithType({ where }) diff --git a/app/services/layer/clone-many.service.ts b/app/services/layer/clone-many.service.ts index 14cf241c..09c33c5d 100644 --- a/app/services/layer/clone-many.service.ts +++ b/app/services/layer/clone-many.service.ts @@ -62,10 +62,10 @@ const getSourceEntityLayers = async ({ sourceEntityId: ILayerEntityId }): Promise => { const where = - sourceEntityType === LayerCloneSourceTypeEnum.ARTBOARD - ? { artboardId: sourceEntityId } - : LayerCloneSourceTypeEnum.ARTBOARD_VERSION - ? { artboardVersionId: sourceEntityId } + sourceEntityType === LayerCloneSourceTypeEnum.ARtwork + ? { artworkId: sourceEntityId } + : LayerCloneSourceTypeEnum.ARTWORK_VERSION + ? { artworkVersionId: sourceEntityId } : { layerId: sourceEntityId } const layers = await getLayersWithDesigns({ where }) diff --git a/app/services/layer/create.service.ts b/app/services/layer/create.service.ts index 2fb50101..300bd89f 100644 --- a/app/services/layer/create.service.ts +++ b/app/services/layer/create.service.ts @@ -51,7 +51,7 @@ export const layerCreateService = async ({ await prisma.$transaction(connectLayersPromise) } - // Step 4: copy designs from artboard to created layer + // Step 4: copy designs from artwork to created layer // skip likely from cloning a layer // need to wait for it to be created if (!skipCloneDesigns) { diff --git a/app/strategies/component/dashboard-panel/create-entity.strategy.ts b/app/strategies/component/dashboard-panel/create-entity.strategy.ts index 990d998c..12472286 100644 --- a/app/strategies/component/dashboard-panel/create-entity.strategy.ts +++ b/app/strategies/component/dashboard-panel/create-entity.strategy.ts @@ -10,18 +10,18 @@ export interface IDashboardPanelCreateEntityStrategy { parentType: entityParentTypeEnum } -export class DashboardPanelCreateArtboardVersionDesignTypeStrategy +export class DashboardPanelCreateArtworkVersionDesignTypeStrategy implements IDashboardPanelCreateEntityStrategy { entityType: entityTypeEnum = EntityType.DESIGN - parentType: entityParentTypeEnum = EntityParentType.ARTBOARD_VERSION + parentType: entityParentTypeEnum = EntityParentType.ARTWORK_VERSION } -export class DashboardPanelCreateArtboardVersionLayerStrategy +export class DashboardPanelCreateArtworkVersionLayerStrategy implements IDashboardPanelCreateEntityStrategy { entityType: entityTypeEnum = EntityType.LAYER - parentType: entityParentTypeEnum = EntityParentType.ARTBOARD_VERSION + parentType: entityParentTypeEnum = EntityParentType.ARTWORK_VERSION } export class DashboardPanelCreateLayerDesignTypeStrategy diff --git a/app/strategies/component/dashboard-panel/delete-entity.strategy.ts b/app/strategies/component/dashboard-panel/delete-entity.strategy.ts index 81ef066b..9ea1caee 100644 --- a/app/strategies/component/dashboard-panel/delete-entity.strategy.ts +++ b/app/strategies/component/dashboard-panel/delete-entity.strategy.ts @@ -12,20 +12,20 @@ export interface IDashboardPanelDeleteEntityStrategy { parentType: entityParentTypeEnum } -export class DashboardPanelDeleteArtboardVersionDesignStrategy +export class DashboardPanelDeleteArtworkVersionDesignStrategy implements IDashboardPanelDeleteEntityStrategy { actionType: entityActionTypeEnum = EntityActionType.DELETE entityType: entityTypeEnum = EntityType.DESIGN - parentType: entityParentTypeEnum = EntityParentType.ARTBOARD_VERSION + parentType: entityParentTypeEnum = EntityParentType.ARTWORK_VERSION } -export class DashboardPanelDeleteArtboardVersionLayerStrategy +export class DashboardPanelDeleteArtworkVersionLayerStrategy implements IDashboardPanelDeleteEntityStrategy { actionType: entityActionTypeEnum = EntityActionType.DELETE entityType: entityTypeEnum = EntityType.LAYER - parentType: entityParentTypeEnum = EntityParentType.ARTBOARD_VERSION + parentType: entityParentTypeEnum = EntityParentType.ARTWORK_VERSION } export class DashboardPanelDeleteLayerDesignStrategy diff --git a/app/strategies/component/dashboard-panel/entity-action/entity-action.ts b/app/strategies/component/dashboard-panel/entity-action/entity-action.ts index 82b9c80a..7057042c 100644 --- a/app/strategies/component/dashboard-panel/entity-action/entity-action.ts +++ b/app/strategies/component/dashboard-panel/entity-action/entity-action.ts @@ -1,12 +1,12 @@ import { - DashboardPanelDeleteArtboardVersionDesignStrategy, + DashboardPanelDeleteArtworkVersionDesignStrategy, DashboardPanelDeleteLayerDesignStrategy, type IDashboardPanelDeleteEntityStrategy, } from '../delete-entity.strategy' -import { DashboardPanelSelectArtboardVersionLayerStrategy } from '../update-entity-selected.strategy' +import { DashboardPanelSelectArtworkVersionLayerStrategy } from '../update-entity-selected.strategy' import { - DashboardPanelUpdateArtboardVersionDesignVisibleStrategy, - DashboardPanelUpdateArtboardVersionLayerVisibleStrategy, + DashboardPanelUpdateArtworkVersionDesignVisibleStrategy, + DashboardPanelUpdateArtworkVersionLayerVisibleStrategy, DashboardPanelUpdateLayerDesignVisibleStrategy, type IDashboardPanelUpdateEntityVisibleStrategy, } from '../update-entity-visible.strategy' @@ -19,30 +19,30 @@ export interface IDashboardPanelEntityActionStrategy { getPanelActions(): IPanelEntityActionStrategy[] } -// artboard design -export class DashboardPanelArtboardVersionDesignActionStrategy +// artwork design +export class DashboardPanelArtworkVersionDesignActionStrategy implements IDashboardPanelEntityActionStrategy { getPanelActions(): IPanelEntityActionStrategy[] { const strategyToggleVisible = - new DashboardPanelUpdateArtboardVersionDesignVisibleStrategy() + new DashboardPanelUpdateArtworkVersionDesignVisibleStrategy() const strategyDelete = - new DashboardPanelDeleteArtboardVersionDesignStrategy() + new DashboardPanelDeleteArtworkVersionDesignStrategy() return [strategyToggleVisible, strategyDelete] } } -// artboard layer -export class DashboardPanelArtboardVersionLayerActionStrategy +// artwork layer +export class DashboardPanelArtworkVersionLayerActionStrategy implements IDashboardPanelEntityActionStrategy { getPanelActions(): IPanelEntityActionStrategy[] { const strategyToggleVisible = - new DashboardPanelUpdateArtboardVersionLayerVisibleStrategy() + new DashboardPanelUpdateArtworkVersionLayerVisibleStrategy() const strategySelect = - new DashboardPanelSelectArtboardVersionLayerStrategy() + new DashboardPanelSelectArtworkVersionLayerStrategy() // delete in popover so it's less easy to click accidentally from left sidebar diff --git a/app/strategies/component/dashboard-panel/update-entity-order.strategy.ts b/app/strategies/component/dashboard-panel/update-entity-order.strategy.ts index 76b0c049..0369c02e 100644 --- a/app/strategies/component/dashboard-panel/update-entity-order.strategy.ts +++ b/app/strategies/component/dashboard-panel/update-entity-order.strategy.ts @@ -10,18 +10,18 @@ export interface IDashboardPanelUpdateEntityOrderStrategy { parentType: entityParentTypeEnum } -export class DashboardPanelUpdateArtboardVersionDesignTypeOrderStrategy +export class DashboardPanelUpdateArtworkVersionDesignTypeOrderStrategy implements IDashboardPanelUpdateEntityOrderStrategy { entityType: entityTypeEnum = EntityType.DESIGN - parentType: entityParentTypeEnum = EntityParentType.ARTBOARD_VERSION + parentType: entityParentTypeEnum = EntityParentType.ARTWORK_VERSION } -export class DashboardPanelUpdateArtboardVersionLayerTypeOrderStrategy +export class DashboardPanelUpdateArtworkVersionLayerTypeOrderStrategy implements IDashboardPanelUpdateEntityOrderStrategy { entityType: entityTypeEnum = EntityType.LAYER - parentType: entityParentTypeEnum = EntityParentType.ARTBOARD_VERSION + parentType: entityParentTypeEnum = EntityParentType.ARTWORK_VERSION } export class DashboardPanelUpdateLayerDesignTypeOrderStrategy diff --git a/app/strategies/component/dashboard-panel/update-entity-selected.strategy.ts b/app/strategies/component/dashboard-panel/update-entity-selected.strategy.ts index b0b59cb3..12482eff 100644 --- a/app/strategies/component/dashboard-panel/update-entity-selected.strategy.ts +++ b/app/strategies/component/dashboard-panel/update-entity-selected.strategy.ts @@ -13,10 +13,10 @@ export interface IDashboardPanelSelectEntityStrategy { parentType: entityParentTypeEnum } -export class DashboardPanelSelectArtboardVersionLayerStrategy +export class DashboardPanelSelectArtworkVersionLayerStrategy implements IDashboardPanelSelectEntityStrategy { actionType: entityActionTypeEnum = EntityActionType.SELECT entityType: entityTypeEnum = EntityType.LAYER - parentType: entityParentTypeEnum = EntityParentType.ARTBOARD_VERSION + parentType: entityParentTypeEnum = EntityParentType.ARTWORK_VERSION } diff --git a/app/strategies/component/dashboard-panel/update-entity-visible.strategy.ts b/app/strategies/component/dashboard-panel/update-entity-visible.strategy.ts index 79bf1035..94a4dcb1 100644 --- a/app/strategies/component/dashboard-panel/update-entity-visible.strategy.ts +++ b/app/strategies/component/dashboard-panel/update-entity-visible.strategy.ts @@ -13,20 +13,20 @@ export interface IDashboardPanelUpdateEntityVisibleStrategy { parentType: entityParentTypeEnum } -export class DashboardPanelUpdateArtboardVersionDesignVisibleStrategy +export class DashboardPanelUpdateArtworkVersionDesignVisibleStrategy implements IDashboardPanelUpdateEntityVisibleStrategy { actionType: entityActionTypeEnum = EntityActionType.TOGGLE_VISIBLE entityType: entityTypeEnum = EntityType.DESIGN - parentType: entityParentTypeEnum = EntityParentType.ARTBOARD_VERSION + parentType: entityParentTypeEnum = EntityParentType.ARTWORK_VERSION } -export class DashboardPanelUpdateArtboardVersionLayerVisibleStrategy +export class DashboardPanelUpdateArtworkVersionLayerVisibleStrategy implements IDashboardPanelUpdateEntityVisibleStrategy { actionType: entityActionTypeEnum = EntityActionType.TOGGLE_VISIBLE entityType: entityTypeEnum = EntityType.LAYER - parentType: entityParentTypeEnum = EntityParentType.ARTBOARD_VERSION + parentType: entityParentTypeEnum = EntityParentType.ARTWORK_VERSION } export class DashboardPanelUpdateLayerDesignVisibleStrategy diff --git a/app/strategies/design/clone.strategy.ts b/app/strategies/design/clone.strategy.ts index b5bee51a..b5f60ca8 100644 --- a/app/strategies/design/clone.strategy.ts +++ b/app/strategies/design/clone.strategy.ts @@ -6,7 +6,7 @@ import { type IDesignEntityId, } from '#app/models/design/design.server' import { type designTypeEnum } from '#app/schema/design' -import { artboardVersionDesignCreateService } from '#app/services/artboard/version/design/create.service' +import { artworkVersionDesignCreateService } from '#app/services/artwork/version/design/create.service' import { layerDesignCreateService } from '#app/services/layer/design/create.service' export interface ICloneDesignsStrategy { @@ -43,7 +43,7 @@ export class CloneDesignToLayerStrategy implements ICloneDesignsStrategy { } } -export class CloneDesignsToArtboardVersionStrategy +export class CloneDesignsToArtworkVersionStrategy implements ICloneDesignsStrategy { async createEntityDesignService({ @@ -59,9 +59,9 @@ export class CloneDesignsToArtboardVersionStrategy designOverrides?: IDesignCreateOverrides designTypeOverrides?: IDesignTypeCreateOverrides }): Promise { - return await artboardVersionDesignCreateService({ + return await artworkVersionDesignCreateService({ userId, - artboardVersionId: targetEntityId, + artworkVersionId: targetEntityId, type, designOverrides, designTypeOverrides, diff --git a/app/strategies/design/create.strategy.ts b/app/strategies/design/create.strategy.ts index 0c7f4581..22151d8b 100644 --- a/app/strategies/design/create.strategy.ts +++ b/app/strategies/design/create.strategy.ts @@ -1,7 +1,7 @@ import { type User } from '@prisma/client' -import { type IArtboardVersion } from '#app/models/artboard-version/artboard-version.server' +import { type IArtworkVersion } from '#app/models/artwork-version/artwork-version.server' import { - createArtboardVersionDesign, + createArtworkVersionDesign, createDesign, } from '#app/models/design/design.create.server' import { getDesign } from '#app/models/design/design.get.server' @@ -80,18 +80,18 @@ export class LayerCreateDesignStrategy implements ICreateDesignStrategy { } } -export class ArtboardVersionCreateDesignStrategy +export class ArtworkVersionCreateDesignStrategy implements ICreateDesignStrategy { async getDesignsByTypeTail({ targetEntityId, type, }: { - targetEntityId: IArtboardVersion['id'] + targetEntityId: IArtworkVersion['id'] type: designTypeEnum }): Promise { return await getDesign({ - where: { type, artboardVersionId: targetEntityId, nextId: null }, + where: { type, artworkVersionId: targetEntityId, nextId: null }, }) } @@ -102,17 +102,17 @@ export class ArtboardVersionCreateDesignStrategy designOverrides, }: { userId: User['id'] - targetEntityId: IArtboardVersion['id'] + targetEntityId: IArtworkVersion['id'] type: designTypeEnum designOverrides: IDesignCreateOverrides }): Promise { const data = { ownerId: userId, type, - artboardVersionId: targetEntityId, + artworkVersionId: targetEntityId, ...designOverrides, } - return await createArtboardVersionDesign({ + return await createArtworkVersionDesign({ data, }) } @@ -121,11 +121,11 @@ export class ArtboardVersionCreateDesignStrategy targetEntityId, type, }: { - targetEntityId: IArtboardVersion['id'] + targetEntityId: IArtworkVersion['id'] type: designTypeEnum }): Promise { const visibleDesignsByTypeCount = await prisma.design.count({ - where: { artboardVersionId: targetEntityId, type, visible: true }, + where: { artworkVersionId: targetEntityId, type, visible: true }, }) return Number(visibleDesignsByTypeCount) } diff --git a/app/strategies/design/update-selected.strategy.ts b/app/strategies/design/update-selected.strategy.ts index bd6f4714..f7f1959f 100644 --- a/app/strategies/design/update-selected.strategy.ts +++ b/app/strategies/design/update-selected.strategy.ts @@ -1,14 +1,14 @@ -import { type IArtboardVersion } from '#app/models/artboard-version/artboard-version.server' +import { type IArtworkVersion } from '#app/models/artwork-version/artwork-version.server' import { type IDesign, type IDesignEntityId, type IDesignIdOrNull, } from '#app/models/design/design.server' -import { findFirstVisibleArtboardVersionDesignByType } from '#app/models/design-artboard-version/design-artboard-version.get.server' +import { findFirstVisibleArtworkVersionDesignByType } from '#app/models/design-artwork-version/design-artwork-version.get.server' import { - deselectArtboardVersionSelectedDesign, - updateArtboardVersionSelectedDesign, -} from '#app/models/design-artboard-version/design-artboard-version.server' + deselectArtworkVersionSelectedDesign, + updateArtworkVersionSelectedDesign, +} from '#app/models/design-artwork-version/design-artwork-version.server' import { findFirstVisibleLayerDesignByType } from '#app/models/design-layer/design-layer.get.server' import { deselectLayerSelectedDesign, @@ -82,7 +82,7 @@ export class LayerUpdateSelectedDesignStrategy } } -export class ArtboardVersionUpdateSelectedDesignStrategy +export class ArtworkVersionUpdateSelectedDesignStrategy implements IUpdateSelectedDesignStrategy { async updateSelectedDesign({ @@ -90,12 +90,12 @@ export class ArtboardVersionUpdateSelectedDesignStrategy designId, type, }: { - targetEntityId: IArtboardVersion['id'] + targetEntityId: IArtworkVersion['id'] designId: IDesign['id'] type: designTypeEnum }) { - const updateSelectedDesignPromise = updateArtboardVersionSelectedDesign({ - artboardVersionId: targetEntityId, + const updateSelectedDesignPromise = updateArtworkVersionSelectedDesign({ + artworkVersionId: targetEntityId, designId, type, }) @@ -106,11 +106,11 @@ export class ArtboardVersionUpdateSelectedDesignStrategy targetEntityId, type, }: { - targetEntityId: IArtboardVersion['id'] + targetEntityId: IArtworkVersion['id'] type: designTypeEnum }) { - return await findFirstVisibleArtboardVersionDesignByType({ - artboardVersionId: targetEntityId, + return await findFirstVisibleArtworkVersionDesignByType({ + artworkVersionId: targetEntityId, type, }) } @@ -119,11 +119,11 @@ export class ArtboardVersionUpdateSelectedDesignStrategy targetEntityId, type, }: { - targetEntityId: IArtboardVersion['id'] + targetEntityId: IArtworkVersion['id'] type: designTypeEnum }) { - const deselectDesignsPromise = deselectArtboardVersionSelectedDesign({ - artboardVersionId: targetEntityId, + const deselectDesignsPromise = deselectArtworkVersionSelectedDesign({ + artworkVersionId: targetEntityId, type, }) await prisma.$transaction([deselectDesignsPromise]) diff --git a/app/strategies/layer/clone.strategy.ts b/app/strategies/layer/clone.strategy.ts index e6e048b8..5d2f4e43 100644 --- a/app/strategies/layer/clone.strategy.ts +++ b/app/strategies/layer/clone.strategy.ts @@ -4,7 +4,7 @@ import { type ILayerCreateOverrides, type ILayerEntityId, } from '#app/models/layer/layer.server' -import { artboardVersionLayerCreateService } from '#app/services/artboard/version/layer/create.service' +import { artworkVersionLayerCreateService } from '#app/services/artwork/version/layer/create.service' export interface ICloneLayersStrategy { createEntityLayerService(args: { @@ -14,7 +14,7 @@ export interface ICloneLayersStrategy { }): Promise } -export class CloneLayersToArtboardVersionStrategy +export class CloneLayersToArtworkVersionStrategy implements ICloneLayersStrategy { async createEntityLayerService({ @@ -26,9 +26,9 @@ export class CloneLayersToArtboardVersionStrategy targetEntityId: ILayerEntityId layerOverrides?: ILayerCreateOverrides }): Promise { - return await artboardVersionLayerCreateService({ + return await artworkVersionLayerCreateService({ userId, - artboardVersionId: targetEntityId, + artworkVersionId: targetEntityId, layerOverrides, // need to create layer before cloning designs // later, perhaps pass designs along diff --git a/app/strategies/layer/create.strategy.ts b/app/strategies/layer/create.strategy.ts index adc94748..91dae022 100644 --- a/app/strategies/layer/create.strategy.ts +++ b/app/strategies/layer/create.strategy.ts @@ -1,5 +1,5 @@ import { type User } from '@prisma/client' -import { type IArtboardVersion } from '#app/models/artboard-version/artboard-version.server' +import { type IArtworkVersion } from '#app/models/artwork-version/artwork-version.server' import { createLayer } from '#app/models/layer/layer.create.server' import { findFirstLayer, @@ -8,8 +8,8 @@ import { type ILayerEntityId, } from '#app/models/layer/layer.server' import { DesignCloneSourceTypeEnum } from '#app/schema/design' -import { ArtboardVersionLayerDataCreateSchema } from '#app/schema/layer-artboard-version' -import { artboardVersionLayerCloneDesignsService } from '#app/services/artboard/version/layer/clone-designs.service' +import { ArtworkVersionLayerDataCreateSchema } from '#app/schema/layer-artwork-version' +import { artworkVersionLayerCloneDesignsService } from '#app/services/artwork/version/layer/clone-designs.service' import { prisma } from '#app/utils/db.server' export interface ICreateLayerStrategy { @@ -31,16 +31,16 @@ export interface ICreateLayerStrategy { }): Promise } -export class ArtboardVersionCreateLayerStrategy +export class ArtworkVersionCreateLayerStrategy implements ICreateLayerStrategy { async getEntityLayersTail({ targetEntityId, }: { - targetEntityId: IArtboardVersion['id'] + targetEntityId: IArtworkVersion['id'] }): Promise { return await findFirstLayer({ - where: { artboardVersionId: targetEntityId, nextId: null }, + where: { artworkVersionId: targetEntityId, nextId: null }, }) } @@ -50,12 +50,12 @@ export class ArtboardVersionCreateLayerStrategy layerOverrides, }: { userId: User['id'] - targetEntityId: IArtboardVersion['id'] + targetEntityId: IArtworkVersion['id'] layerOverrides: ILayerCreateOverrides }): Promise { - const data = ArtboardVersionLayerDataCreateSchema.parse({ + const data = ArtworkVersionLayerDataCreateSchema.parse({ ownerId: userId, - artboardVersionId: targetEntityId, + artworkVersionId: targetEntityId, ...layerOverrides, }) const createdLayer = await createLayer({ data }) @@ -65,10 +65,10 @@ export class ArtboardVersionCreateLayerStrategy async getEntityLayersCount({ targetEntityId, }: { - targetEntityId: IArtboardVersion['id'] + targetEntityId: IArtworkVersion['id'] }): Promise { return await prisma.layer.count({ - where: { artboardVersionId: targetEntityId }, + where: { artworkVersionId: targetEntityId }, }) } @@ -81,9 +81,9 @@ export class ArtboardVersionCreateLayerStrategy sourceEntityId: ILayerEntityId targetEntityId: ILayerEntityId }) { - await artboardVersionLayerCloneDesignsService({ + await artworkVersionLayerCloneDesignsService({ userId, - sourceEntityType: DesignCloneSourceTypeEnum.ARTBOARD_VERSION, + sourceEntityType: DesignCloneSourceTypeEnum.ARTWORK_VERSION, sourceEntityId, targetEntityId, }) diff --git a/app/strategies/validate-submission.strategy.ts b/app/strategies/validate-submission.strategy.ts index e3d07a82..ba0be83f 100644 --- a/app/strategies/validate-submission.strategy.ts +++ b/app/strategies/validate-submission.strategy.ts @@ -1,8 +1,8 @@ import { type User } from '@prisma/client' import { type z } from 'zod' -import { getArtboard } from '#app/models/artboard/artboard.get.server' -import { getArtboardBranch } from '#app/models/artboard-branch/artboard-branch.get.server' -import { getArtboardVersion } from '#app/models/artboard-version/artboard-version.get.server' +import { getArtwork } from '#app/models/artwork/artwork.get.server' +import { getArtworkBranch } from '#app/models/artwork-branch/artwork-branch.get.server' +import { getArtworkVersion } from '#app/models/artwork-version/artwork-version.get.server' import { getDesign } from '#app/models/design/design.get.server' import { getLayer } from '#app/models/layer/layer.get.server' import { addNotFoundIssue } from '#app/utils/conform-utils' @@ -15,7 +15,7 @@ export interface IValidateSubmissionStrategy { }): Promise } -export class ValidateArtboardParentSubmissionStrategy +export class ValidateArtworkParentSubmissionStrategy implements IValidateSubmissionStrategy { async validateFormDataEntity({ @@ -27,15 +27,15 @@ export class ValidateArtboardParentSubmissionStrategy data: any ctx: any }): Promise { - const { artboardId } = data - const artboard = await getArtboard({ - where: { id: artboardId, ownerId: userId }, + const { artworkId } = data + const artwork = await getArtwork({ + where: { id: artworkId, ownerId: userId }, }) - if (!artboard) ctx.addIssue(addNotFoundIssue('Artboard')) + if (!artwork) ctx.addIssue(addNotFoundIssue('Artwork')) } } -export class ValidateArtboardBranchParentSubmissionStrategy +export class ValidateArtworkBranchParentSubmissionStrategy implements IValidateSubmissionStrategy { async validateFormDataEntity({ @@ -47,15 +47,15 @@ export class ValidateArtboardBranchParentSubmissionStrategy data: any ctx: any }): Promise { - const { artboardBranchId } = data - const artboardBranch = await getArtboardBranch({ - where: { id: artboardBranchId, ownerId: userId }, + const { artworkBranchId } = data + const artworkBranch = await getArtworkBranch({ + where: { id: artworkBranchId, ownerId: userId }, }) - if (!artboardBranch) ctx.addIssue(addNotFoundIssue('ArtboardBranch')) + if (!artworkBranch) ctx.addIssue(addNotFoundIssue('ArtworkBranch')) } } -export class ValidateArtboardVersionSubmissionStrategy +export class ValidateArtworkVersionSubmissionStrategy implements IValidateSubmissionStrategy { async validateFormDataEntity({ @@ -68,14 +68,14 @@ export class ValidateArtboardVersionSubmissionStrategy ctx: any }): Promise { const { id } = data - const artboardVersion = await getArtboardVersion({ + const artworkVersion = await getArtworkVersion({ where: { id, ownerId: userId }, }) - if (!artboardVersion) ctx.addIssue(addNotFoundIssue('ArtboardVersion')) + if (!artworkVersion) ctx.addIssue(addNotFoundIssue('ArtworkVersion')) } } -export class ValidateArtboardVersionParentSubmissionStrategy +export class ValidateArtworkVersionParentSubmissionStrategy implements IValidateSubmissionStrategy { async validateFormDataEntity({ @@ -87,11 +87,11 @@ export class ValidateArtboardVersionParentSubmissionStrategy data: any ctx: any }): Promise { - const { artboardVersionId } = data - const artboardVersion = await getArtboardVersion({ - where: { id: artboardVersionId, ownerId: userId }, + const { artworkVersionId } = data + const artworkVersion = await getArtworkVersion({ + where: { id: artworkVersionId, ownerId: userId }, }) - if (!artboardVersion) ctx.addIssue(addNotFoundIssue('ArtboardVersion')) + if (!artworkVersion) ctx.addIssue(addNotFoundIssue('ArtworkVersion')) } } diff --git a/app/utils/db.server.ts b/app/utils/db.server.ts index 8f6dedca..c94958cc 100644 --- a/app/utils/db.server.ts +++ b/app/utils/db.server.ts @@ -2,8 +2,8 @@ import { remember } from '@epic-web/remember' import { PrismaClient, type Prisma } from '@prisma/client' import { type DefaultArgs } from '@prisma/client/runtime/library' import chalk from 'chalk' -import { ArtboardPrismaExtensions } from './prisma-extensions-artboard' -import { ArtboardVersionPrismaExtensions } from './prisma-extensions-artboard-version' +import { ArtworkPrismaExtensions } from './prisma-extensions-artwork' +import { ArtworkVersionPrismaExtensions } from './prisma-extensions-artwork-version' import { DesignPrismaExtensions, DesignPrismaQueryExtensions, @@ -26,8 +26,8 @@ export type PrismaTransactionType = Omit< export const prismaExtended = remember('prisma', () => { return new PrismaClient({}) - .$extends(ArtboardPrismaExtensions) - .$extends(ArtboardVersionPrismaExtensions) + .$extends(ArtworkPrismaExtensions) + .$extends(ArtworkVersionPrismaExtensions) .$extends(DesignPrismaQueryExtensions) .$extends(DesignPrismaExtensions) .$extends(PalettePrismaExtensions) diff --git a/app/utils/design.ts b/app/utils/design.ts index a265648d..5e0b9812 100644 --- a/app/utils/design.ts +++ b/app/utils/design.ts @@ -424,8 +424,8 @@ export const designsByTypeToPanelArray = ({ ] } -// used from artboard create service -// get all selected designs by type for artboard and each layer +// used from artwork create service +// get all selected designs by type for artwork and each layer // then separate them by type here export const findFirstDesignsByTypeInArray = ({ designs, @@ -453,8 +453,8 @@ export const findFirstDesignsByTypeInArray = ({ } } -// used from artboard generator create service -// verify artboard has all design types +// used from artwork generator create service +// verify artwork has all design types // or canvas shouldn't be displayed export const verifySelectedDesignTypesAllPresent = ({ selectedDesignTypes, @@ -478,7 +478,7 @@ export const verifySelectedDesignTypesAllPresent = ({ // indicating that the design type is missing return { success: false, - message: `Please make a ${designType} design available for the artboard.`, + message: `Please make a ${designType} design available for the artwork.`, } } } @@ -487,8 +487,8 @@ export const verifySelectedDesignTypesAllPresent = ({ return { success: true, message: 'All selected designs are present' } } -// used from artboard generator create service -// layer generators will have artboard generator designs as default +// used from artwork generator create service +// layer generators will have artwork generator designs as default // so only return the selected designs for layer to merge and override export const filterSelectedDesignTypes = ({ selectedDesignTypes, diff --git a/app/utils/dev.utils.ts b/app/utils/dev.utils.ts index 3240cdbc..1a792bda 100644 --- a/app/utils/dev.utils.ts +++ b/app/utils/dev.utils.ts @@ -2,9 +2,9 @@ import { prisma } from '#app/utils/db.server' export const getCountOfAllEntities = async () => { const usersCount = await prisma.user.count() - const artboardsCount = await prisma.artboard.count() - const artboardBranchesCount = await prisma.artboardBranch.count() - const artboardVersionsCount = await prisma.artboardVersion.count() + const artworksCount = await prisma.artwork.count() + const artworkBranchesCount = await prisma.artworkBranch.count() + const artworkVersionsCount = await prisma.artworkVersion.count() const layersCount = await prisma.layer.count() const designsCount = await prisma.design.count() const palettesCount = await prisma.palette.count() @@ -14,9 +14,9 @@ export const getCountOfAllEntities = async () => { // such as to verify count changes from a script return { usersCount, - artboardsCount, - artboardBranchesCount, - artboardVersionsCount, + artworksCount, + artworkBranchesCount, + artworkVersionsCount, layersCount, designsCount, palettesCount, @@ -24,7 +24,7 @@ export const getCountOfAllEntities = async () => { } export const getFullStats = async () => { - // await prisma.artboard.findMany({ + // await prisma.artwork.findMany({ // include: { // designs: true, // layers: { @@ -44,44 +44,44 @@ export const getFullStats = async () => { // }, // }, // }) - // for (const artboard of artboards) { - // console.log('artboard: ', artboard.name) - // // let artboardLayerDesignCount = 0 - // // for (const layer of artboard.layers) { + // for (const artwork of artworks) { + // console.log('artwork: ', artwork.name) + // // let artworkLayerDesignCount = 0 + // // for (const layer of artwork.layers) { // // for (const designa of layer.designs) { // // // console.log('designa: ', designa.type) - // // artboardLayerDesignCount++ + // // artworkLayerDesignCount++ // // } // // } - // // for (const version of artboard.versions) { + // // for (const version of artwork.versions) { // // // console.log('version: ', version.name) - // // // let artboardVersionLayerDesignCount = 0 + // // // let artworkVersionLayerDesignCount = 0 // // // for (const layer of version.layers) { // // // console.log('layer: ', layer.name) // // // for (const design of layer.designs) { // // // // console.log('design: ', design.type) - // // // artboardVersionLayerDesignCount++ + // // // artworkVersionLayerDesignCount++ // // // } // // // } - // // // console.log(`designs: artboard ${artboard.designs.length}`) + // // // console.log(`designs: artwork ${artwork.designs.length}`) // // // console.log(`designs: version ${version.designs.length}`) - // // // console.log(`layers: artboard ${artboard.layers.length} `) + // // // console.log(`layers: artwork ${artwork.layers.length} `) // // // console.log(`layers: version ${version.layers.length}`) - // // // console.log(`layer designs: artboard ${artboardLayerDesignCount}`) - // // // console.log(`layer designs: version ${artboardVersionLayerDesignCount}`) + // // // console.log(`layer designs: artwork ${artworkLayerDesignCount}`) + // // // console.log(`layer designs: version ${artworkVersionLayerDesignCount}`) // // } // } // const AdesignsCount = await prisma.design.count({ - // where: { artboardId: { not: null } }, + // where: { artworkId: { not: null } }, // }) // const AVesignsCount = await prisma.design.count({ - // where: { artboardId: { not: null } }, + // where: { artworkId: { not: null } }, // }) // const AdLayersCount = await prisma.layer.count({ - // where: { artboardId: { not: null } }, + // where: { artworkId: { not: null } }, // }) // const AVLayersCount = await prisma.layer.count({ - // where: { artboardId: { not: null } }, + // where: { artworkId: { not: null } }, // }) // console.log('AdesignsCount: ', AdesignsCount) // console.log('AVesignsCount: ', AVesignsCount) diff --git a/app/utils/line.ts b/app/utils/line.ts index 749a8c22..e045d064 100644 --- a/app/utils/line.ts +++ b/app/utils/line.ts @@ -1,4 +1,4 @@ -import { type ILayerGeneratorContainer } from '#app/definitions/artboard-generator' +import { type ILayerGeneratorContainer } from '#app/definitions/artwork-generator' import { type ILine } from '#app/models/design-type/line/line.server' import { type ISize } from '#app/models/design-type/size/size.server' import { LineBasisTypeEnum } from '#app/schema/line' diff --git a/app/utils/matches.ts b/app/utils/matches.ts index 2bb302c6..3628e31a 100644 --- a/app/utils/matches.ts +++ b/app/utils/matches.ts @@ -4,21 +4,21 @@ import { type UIMatch } from '@remix-run/react' import { type MetaMatches } from '@remix-run/react/dist/routeModules' import { type loader as rootLoader } from '#app/root.tsx' import { - type artboardstLoaderRoute, - type loader as artboardsLoader, -} from '#app/routes/sketch+/projects+/$projectSlug_+/artboards+' + type artworkstLoaderRoute, + type loader as artworksLoader, +} from '#app/routes/sketch+/projects+/$projectSlug_+/artworks+' import { - type artboardBranchLoaderRoute, - type loader as artboardBranchLoader, -} from '#app/routes/sketch+/projects+/$projectSlug_+/artboards+/$artboardSlug+/$branchSlug' + type artworkBranchLoaderRoute, + type loader as artworkBranchLoader, +} from '#app/routes/sketch+/projects+/$projectSlug_+/artworks+/$artworkSlug+/$branchSlug' import { - type artboardVersionLoaderRoute, - type loader as artboardVersionLoader, -} from '#app/routes/sketch+/projects+/$projectSlug_+/artboards+/$artboardSlug+/$branchSlug.$versionSlug' + type artworkVersionLoaderRoute, + type loader as artworkVersionLoader, +} from '#app/routes/sketch+/projects+/$projectSlug_+/artworks+/$artworkSlug+/$branchSlug.$versionSlug' import { - type artboardLoaderRoute, - type loader as artboardLoader, -} from '#app/routes/sketch+/projects+/$projectSlug_+/artboards+/$artboardSlug+/route' + type artworkLoaderRoute, + type loader as artworkLoader, +} from '#app/routes/sketch+/projects+/$projectSlug_+/artworks+/$artworkSlug+/route' import { type projectLoaderRoute, type loader as projectLoader, @@ -35,10 +35,10 @@ interface RouteLoaders { root: typeof rootLoader [projectsLoaderRoute]: typeof projectsLoader [projectLoaderRoute]: typeof projectLoader - [artboardstLoaderRoute]: typeof artboardsLoader - [artboardLoaderRoute]: typeof artboardLoader - [artboardBranchLoaderRoute]: typeof artboardBranchLoader - [artboardVersionLoaderRoute]: typeof artboardVersionLoader + [artworkstLoaderRoute]: typeof artworksLoader + [artworkLoaderRoute]: typeof artworkLoader + [artworkBranchLoaderRoute]: typeof artworkBranchLoader + [artworkVersionLoaderRoute]: typeof artworkVersionLoader } export function routeLoaderMetaData( diff --git a/app/utils/prisma-extensions-artboard-version.ts b/app/utils/prisma-extensions-artwork-version.ts similarity index 55% rename from app/utils/prisma-extensions-artboard-version.ts rename to app/utils/prisma-extensions-artwork-version.ts index 4811c9fb..2be2f9f5 100644 --- a/app/utils/prisma-extensions-artboard-version.ts +++ b/app/utils/prisma-extensions-artwork-version.ts @@ -1,5 +1,5 @@ import { Prisma } from '@prisma/client' -import { type whereArgsType } from '#app/schema/artboard' +import { type whereArgsType } from '#app/schema/artwork' import { prismaExtended } from './db.server' // must be in /utils to actually connect to prisma @@ -10,16 +10,16 @@ import { prismaExtended } from './db.server' // instance methods .save() and .delete() // https://github.com/prisma/prisma-client-extensions/blob/main/instance-methods/script.ts -export const ArtboardVersionPrismaExtensions = Prisma.defineExtension({ +export const ArtworkVersionPrismaExtensions = Prisma.defineExtension({ result: { - artboardVersion: { + artworkVersion: { save: { needs: { id: true }, - compute(artboardVersion) { + compute(artworkVersion) { return () => { - return prismaExtended.artboardVersion.update({ - where: { id: artboardVersion.id }, - data: artboardVersion, + return prismaExtended.artworkVersion.update({ + where: { id: artworkVersion.id }, + data: artworkVersion, }) } }, @@ -29,7 +29,7 @@ export const ArtboardVersionPrismaExtensions = Prisma.defineExtension({ needs: { id: true }, compute({ id }) { return () => { - return prismaExtended.artboardVersion.delete({ + return prismaExtended.artworkVersion.delete({ where: { id }, }) } @@ -40,18 +40,18 @@ export const ArtboardVersionPrismaExtensions = Prisma.defineExtension({ }) // https://github.com/prisma/docs/issues/5058#issuecomment-1636473141 -export type ExtendedArtboardVersion = Prisma.Result< - typeof prismaExtended.artboardVersion, +export type ExtendedArtworkVersion = Prisma.Result< + typeof prismaExtended.artworkVersion, any, 'findFirstOrThrow' > -export const findFirstArtboardVersionInstance = async ({ +export const findFirstArtworkVersionInstance = async ({ where, }: { where: whereArgsType -}): Promise => { - return await prismaExtended.artboardVersion.findFirst({ +}): Promise => { + return await prismaExtended.artworkVersion.findFirst({ where, }) } diff --git a/app/utils/prisma-extensions-artboard.ts b/app/utils/prisma-extensions-artwork.ts similarity index 59% rename from app/utils/prisma-extensions-artboard.ts rename to app/utils/prisma-extensions-artwork.ts index 5b945981..229bb1c1 100644 --- a/app/utils/prisma-extensions-artboard.ts +++ b/app/utils/prisma-extensions-artwork.ts @@ -1,5 +1,5 @@ import { Prisma } from '@prisma/client' -import { type whereArgsType } from '#app/schema/artboard' +import { type whereArgsType } from '#app/schema/artwork' import { prismaExtended } from './db.server' // must be in /utils to actually connect to prisma @@ -10,16 +10,16 @@ import { prismaExtended } from './db.server' // instance methods .save() and .delete() // https://github.com/prisma/prisma-client-extensions/blob/main/instance-methods/script.ts -export const ArtboardPrismaExtensions = Prisma.defineExtension({ +export const ArtworkPrismaExtensions = Prisma.defineExtension({ result: { - artboard: { + artwork: { save: { needs: { id: true }, - compute(artboard) { + compute(artwork) { return () => { - return prismaExtended.artboard.update({ - where: { id: artboard.id }, - data: artboard, + return prismaExtended.artwork.update({ + where: { id: artwork.id }, + data: artwork, }) } }, @@ -29,7 +29,7 @@ export const ArtboardPrismaExtensions = Prisma.defineExtension({ needs: { id: true }, compute({ id }) { return () => { - return prismaExtended.artboard.delete({ + return prismaExtended.artwork.delete({ where: { id }, }) } @@ -40,18 +40,18 @@ export const ArtboardPrismaExtensions = Prisma.defineExtension({ }) // https://github.com/prisma/docs/issues/5058#issuecomment-1636473141 -export type ExtendedArtboard = Prisma.Result< - typeof prismaExtended.artboard, +export type ExtendedArtwork = Prisma.Result< + typeof prismaExtended.artwork, any, 'findFirstOrThrow' > -export const findFirstArtboardInstance = async ({ +export const findFirstArtworkInstance = async ({ where, }: { where: whereArgsType -}): Promise => { - return await prismaExtended.artboard.findFirst({ +}): Promise => { + return await prismaExtended.artwork.findFirst({ where, }) } diff --git a/app/utils/routes.const.ts b/app/utils/routes.const.ts index fcd36c5c..06999253 100644 --- a/app/utils/routes.const.ts +++ b/app/utils/routes.const.ts @@ -7,31 +7,31 @@ export const Routes = { RESOURCES: { API: { V1: { - ARTBOARD_BRANCH: { - CREATE: `${pathBase}/artboard-branch/create`, + ARTWORK_BRANCH: { + CREATE: `${pathBase}/artwork-branch/create`, }, - ARTBOARD_VERSION: { - CREATE: `${pathBase}/artboard-version/create`, + ARTWORK_VERSION: { + CREATE: `${pathBase}/artwork-version/create`, UPDATE: { - BACKGROUND: `${pathBase}/artboard-version/update/background`, - WIDTH: `${pathBase}/artboard-version/update/width`, - HEIGHT: `${pathBase}/artboard-version/update/height`, + BACKGROUND: `${pathBase}/artwork-version/update/background`, + WIDTH: `${pathBase}/artwork-version/update/width`, + HEIGHT: `${pathBase}/artwork-version/update/height`, }, DESIGN: { - CREATE: `${pathBase}/artboard-version/design/create`, - DELETE: `${pathBase}/artboard-version/design/delete`, + CREATE: `${pathBase}/artwork-version/design/create`, + DELETE: `${pathBase}/artwork-version/design/delete`, UPDATE: { - VISIBLE: `${pathBase}/artboard-version/design/update/visible`, - ORDER: `${pathBase}/artboard-version/design/update/order`, + VISIBLE: `${pathBase}/artwork-version/design/update/visible`, + ORDER: `${pathBase}/artwork-version/design/update/order`, }, }, LAYER: { - CREATE: `${pathBase}/artboard-version/layer/create`, - DELETE: `${pathBase}/artboard-version/layer/delete`, + CREATE: `${pathBase}/artwork-version/layer/create`, + DELETE: `${pathBase}/artwork-version/layer/delete`, UPDATE: { - VISIBLE: `${pathBase}/artboard-version/layer/update/visible`, - ORDER: `${pathBase}/artboard-version/layer/update/order`, - SELECTED: `${pathBase}/artboard-version/layer/update/selected`, + VISIBLE: `${pathBase}/artwork-version/layer/update/visible`, + ORDER: `${pathBase}/artwork-version/layer/update/order`, + SELECTED: `${pathBase}/artwork-version/layer/update/selected`, }, }, }, diff --git a/app/utils/size.ts b/app/utils/size.ts index d9b8b55e..829adeda 100644 --- a/app/utils/size.ts +++ b/app/utils/size.ts @@ -1,4 +1,4 @@ -import { type ILayerGeneratorContainer } from '#app/definitions/artboard-generator' +import { type ILayerGeneratorContainer } from '#app/definitions/artwork-generator' import { type ISize } from '#app/models/design-type/size/size.server' import { SizeBasisTypeEnum } from '#app/schema/size' diff --git a/app/utils/user.ts b/app/utils/user.ts index 8fd7ff14..b182c9c3 100644 --- a/app/utils/user.ts +++ b/app/utils/user.ts @@ -25,7 +25,7 @@ export function useUser() { } type Action = 'create' | 'read' | 'update' | 'delete' -type Entity = 'user' | 'note' | 'project' | 'artboard' | 'layer' +type Entity = 'user' | 'note' | 'project' | 'artwork' | 'layer' type Access = 'own' | 'any' | 'own,any' | 'any,own' export type PermissionString = | `${Action}:${Entity}` diff --git a/prisma/migrations/20240522073958_rename_artboard_to_artwork/migration.sql b/prisma/migrations/20240522073958_rename_artboard_to_artwork/migration.sql new file mode 100644 index 00000000..4cb04ba2 --- /dev/null +++ b/prisma/migrations/20240522073958_rename_artboard_to_artwork/migration.sql @@ -0,0 +1,269 @@ +/* + Warnings: + + - You are about to drop the `Artboard` table. If the table is not empty, all the data it contains will be lost. + - You are about to drop the `ArtboardBranch` table. If the table is not empty, all the data it contains will be lost. + - You are about to drop the `ArtboardMergeRequest` table. If the table is not empty, all the data it contains will be lost. + - You are about to drop the `ArtboardVersion` table. If the table is not empty, all the data it contains will be lost. + - You are about to drop the column `artboardVersionId` on the `Design` table. All the data in the column will be lost. + - You are about to drop the column `artboardVersionId` on the `Layer` table. All the data in the column will be lost. + +*/ +-- DropIndex +DROP INDEX "Artboard_slug_ownerId_key"; + +-- DropIndex +DROP INDEX "Artboard_ownerId_updatedAt_idx"; + +-- DropIndex +DROP INDEX "Artboard_projectId_updatedAt_idx"; + +-- DropIndex +DROP INDEX "Artboard_ownerId_idx"; + +-- DropIndex +DROP INDEX "Artboard_projectId_idx"; + +-- DropIndex +DROP INDEX "ArtboardBranch_artboardId_slug_key"; + +-- DropIndex +DROP INDEX "ArtboardBranch_artboardId_name_key"; + +-- DropIndex +DROP INDEX "ArtboardBranch_ownerId_idx"; + +-- DropIndex +DROP INDEX "ArtboardBranch_artboardId_idx"; + +-- DropIndex +DROP INDEX "ArtboardMergeRequest_targetBranchId_idx"; + +-- DropIndex +DROP INDEX "ArtboardMergeRequest_sourceBranchId_idx"; + +-- DropIndex +DROP INDEX "ArtboardMergeRequest_artboardId_idx"; + +-- DropIndex +DROP INDEX "ArtboardVersion_branchId_slug_key"; + +-- DropIndex +DROP INDEX "ArtboardVersion_branchId_name_key"; + +-- DropIndex +DROP INDEX "ArtboardVersion_ownerId_idx"; + +-- DropIndex +DROP INDEX "ArtboardVersion_branchId_idx"; + +-- DropIndex +DROP INDEX "ArtboardVersion_prevId_key"; + +-- DropIndex +DROP INDEX "ArtboardVersion_nextId_key"; + +-- DropTable +PRAGMA foreign_keys=off; +DROP TABLE "Artboard"; +PRAGMA foreign_keys=on; + +-- DropTable +PRAGMA foreign_keys=off; +DROP TABLE "ArtboardBranch"; +PRAGMA foreign_keys=on; + +-- DropTable +PRAGMA foreign_keys=off; +DROP TABLE "ArtboardMergeRequest"; +PRAGMA foreign_keys=on; + +-- DropTable +PRAGMA foreign_keys=off; +DROP TABLE "ArtboardVersion"; +PRAGMA foreign_keys=on; + +-- CreateTable +CREATE TABLE "Artwork" ( + "id" TEXT NOT NULL PRIMARY KEY, + "name" TEXT NOT NULL, + "description" TEXT, + "isVisible" BOOLEAN NOT NULL DEFAULT true, + "slug" TEXT NOT NULL, + "width" INTEGER NOT NULL, + "height" INTEGER NOT NULL, + "backgroundColor" TEXT NOT NULL, + "createdAt" DATETIME NOT NULL DEFAULT CURRENT_TIMESTAMP, + "updatedAt" DATETIME NOT NULL, + "ownerId" TEXT NOT NULL, + "projectId" TEXT NOT NULL, + CONSTRAINT "Artwork_ownerId_fkey" FOREIGN KEY ("ownerId") REFERENCES "User" ("id") ON DELETE CASCADE ON UPDATE CASCADE, + CONSTRAINT "Artwork_projectId_fkey" FOREIGN KEY ("projectId") REFERENCES "Project" ("id") ON DELETE CASCADE ON UPDATE CASCADE +); + +-- CreateTable +CREATE TABLE "ArtworkBranch" ( + "id" TEXT NOT NULL PRIMARY KEY, + "name" TEXT NOT NULL DEFAULT 'main', + "slug" TEXT NOT NULL DEFAULT 'main', + "description" TEXT, + "default" BOOLEAN NOT NULL DEFAULT false, + "active" BOOLEAN NOT NULL DEFAULT true, + "createdAt" DATETIME NOT NULL DEFAULT CURRENT_TIMESTAMP, + "updatedAt" DATETIME NOT NULL, + "ownerId" TEXT NOT NULL, + "artworkId" TEXT NOT NULL, + "parentId" TEXT, + CONSTRAINT "ArtworkBranch_ownerId_fkey" FOREIGN KEY ("ownerId") REFERENCES "User" ("id") ON DELETE CASCADE ON UPDATE CASCADE, + CONSTRAINT "ArtworkBranch_artworkId_fkey" FOREIGN KEY ("artworkId") REFERENCES "Artwork" ("id") ON DELETE CASCADE ON UPDATE CASCADE, + CONSTRAINT "ArtworkBranch_parentId_fkey" FOREIGN KEY ("parentId") REFERENCES "ArtworkBranch" ("id") ON DELETE SET NULL ON UPDATE CASCADE +); + +-- CreateTable +CREATE TABLE "ArtworkVersion" ( + "id" TEXT NOT NULL PRIMARY KEY, + "name" TEXT NOT NULL DEFAULT 'v0', + "slug" TEXT NOT NULL DEFAULT 'v0', + "description" TEXT NOT NULL DEFAULT 'initial version', + "width" INTEGER NOT NULL DEFAULT 1080, + "height" INTEGER NOT NULL DEFAULT 1920, + "background" TEXT NOT NULL DEFAULT 'FFFFFF', + "createdAt" DATETIME NOT NULL DEFAULT CURRENT_TIMESTAMP, + "updatedAt" DATETIME NOT NULL, + "ownerId" TEXT NOT NULL, + "branchId" TEXT NOT NULL, + "nextId" TEXT, + "prevId" TEXT, + CONSTRAINT "ArtworkVersion_ownerId_fkey" FOREIGN KEY ("ownerId") REFERENCES "User" ("id") ON DELETE CASCADE ON UPDATE CASCADE, + CONSTRAINT "ArtworkVersion_branchId_fkey" FOREIGN KEY ("branchId") REFERENCES "ArtworkBranch" ("id") ON DELETE CASCADE ON UPDATE CASCADE, + CONSTRAINT "ArtworkVersion_nextId_fkey" FOREIGN KEY ("nextId") REFERENCES "ArtworkVersion" ("id") ON DELETE SET NULL ON UPDATE CASCADE +); + +-- CreateTable +CREATE TABLE "ArtworkMergeRequest" ( + "id" TEXT NOT NULL PRIMARY KEY, + "status" TEXT NOT NULL DEFAULT 'open', + "title" TEXT NOT NULL, + "description" TEXT, + "createdAt" DATETIME NOT NULL DEFAULT CURRENT_TIMESTAMP, + "updatedAt" DATETIME NOT NULL, + "artworkId" TEXT NOT NULL, + "sourceBranchId" TEXT NOT NULL, + "targetBranchId" TEXT NOT NULL, + CONSTRAINT "ArtworkMergeRequest_artworkId_fkey" FOREIGN KEY ("artworkId") REFERENCES "Artwork" ("id") ON DELETE CASCADE ON UPDATE CASCADE, + CONSTRAINT "ArtworkMergeRequest_sourceBranchId_fkey" FOREIGN KEY ("sourceBranchId") REFERENCES "ArtworkBranch" ("id") ON DELETE CASCADE ON UPDATE CASCADE, + CONSTRAINT "ArtworkMergeRequest_targetBranchId_fkey" FOREIGN KEY ("targetBranchId") REFERENCES "ArtworkBranch" ("id") ON DELETE CASCADE ON UPDATE CASCADE +); + +-- RedefineTables +PRAGMA foreign_keys=OFF; +CREATE TABLE "new_Design" ( + "id" TEXT NOT NULL PRIMARY KEY, + "type" TEXT NOT NULL, + "visible" BOOLEAN NOT NULL DEFAULT true, + "selected" BOOLEAN NOT NULL DEFAULT false, + "createdAt" DATETIME NOT NULL DEFAULT CURRENT_TIMESTAMP, + "nextId" TEXT, + "prevId" TEXT, + "ownerId" TEXT NOT NULL, + "artworkVersionId" TEXT, + "layerId" TEXT, + CONSTRAINT "Design_nextId_fkey" FOREIGN KEY ("nextId") REFERENCES "Design" ("id") ON DELETE SET NULL ON UPDATE CASCADE, + CONSTRAINT "Design_ownerId_fkey" FOREIGN KEY ("ownerId") REFERENCES "User" ("id") ON DELETE CASCADE ON UPDATE CASCADE, + CONSTRAINT "Design_artworkVersionId_fkey" FOREIGN KEY ("artworkVersionId") REFERENCES "ArtworkVersion" ("id") ON DELETE CASCADE ON UPDATE CASCADE, + CONSTRAINT "Design_layerId_fkey" FOREIGN KEY ("layerId") REFERENCES "Layer" ("id") ON DELETE CASCADE ON UPDATE CASCADE +); +INSERT INTO "new_Design" ("createdAt", "id", "layerId", "nextId", "ownerId", "prevId", "selected", "type", "visible") SELECT "createdAt", "id", "layerId", "nextId", "ownerId", "prevId", "selected", "type", "visible" FROM "Design"; +DROP TABLE "Design"; +ALTER TABLE "new_Design" RENAME TO "Design"; +CREATE UNIQUE INDEX "Design_nextId_key" ON "Design"("nextId"); +CREATE UNIQUE INDEX "Design_prevId_key" ON "Design"("prevId"); +CREATE INDEX "Design_ownerId_idx" ON "Design"("ownerId"); +CREATE INDEX "Design_layerId_idx" ON "Design"("layerId"); +CREATE INDEX "Design_artworkVersionId_idx" ON "Design"("artworkVersionId"); +CREATE TABLE "new_Layer" ( + "id" TEXT NOT NULL PRIMARY KEY, + "name" TEXT NOT NULL, + "description" TEXT, + "slug" TEXT, + "visible" BOOLEAN NOT NULL DEFAULT true, + "selected" BOOLEAN NOT NULL DEFAULT false, + "createdAt" DATETIME NOT NULL DEFAULT CURRENT_TIMESTAMP, + "updatedAt" DATETIME NOT NULL, + "ownerId" TEXT NOT NULL, + "artworkVersionId" TEXT, + "nextId" TEXT, + "prevId" TEXT, + "parentId" TEXT, + CONSTRAINT "Layer_ownerId_fkey" FOREIGN KEY ("ownerId") REFERENCES "User" ("id") ON DELETE CASCADE ON UPDATE CASCADE, + CONSTRAINT "Layer_artworkVersionId_fkey" FOREIGN KEY ("artworkVersionId") REFERENCES "ArtworkVersion" ("id") ON DELETE CASCADE ON UPDATE CASCADE, + CONSTRAINT "Layer_nextId_fkey" FOREIGN KEY ("nextId") REFERENCES "Layer" ("id") ON DELETE SET NULL ON UPDATE CASCADE, + CONSTRAINT "Layer_parentId_fkey" FOREIGN KEY ("parentId") REFERENCES "Layer" ("id") ON DELETE CASCADE ON UPDATE CASCADE +); +INSERT INTO "new_Layer" ("createdAt", "description", "id", "name", "nextId", "ownerId", "parentId", "prevId", "selected", "slug", "updatedAt", "visible") SELECT "createdAt", "description", "id", "name", "nextId", "ownerId", "parentId", "prevId", "selected", "slug", "updatedAt", "visible" FROM "Layer"; +DROP TABLE "Layer"; +ALTER TABLE "new_Layer" RENAME TO "Layer"; +CREATE UNIQUE INDEX "Layer_nextId_key" ON "Layer"("nextId"); +CREATE UNIQUE INDEX "Layer_prevId_key" ON "Layer"("prevId"); +CREATE INDEX "Layer_ownerId_idx" ON "Layer"("ownerId"); +CREATE INDEX "Layer_artworkVersionId_idx" ON "Layer"("artworkVersionId"); +CREATE INDEX "Layer_parentId_idx" ON "Layer"("parentId"); +CREATE INDEX "Layer_ownerId_updatedAt_idx" ON "Layer"("ownerId", "updatedAt"); +CREATE UNIQUE INDEX "Layer_slug_ownerId_artworkVersionId_key" ON "Layer"("slug", "ownerId", "artworkVersionId"); +PRAGMA foreign_key_check("Design"); +PRAGMA foreign_key_check("Layer"); +PRAGMA foreign_keys=ON; + +-- CreateIndex +CREATE INDEX "Artwork_projectId_idx" ON "Artwork"("projectId"); + +-- CreateIndex +CREATE INDEX "Artwork_ownerId_idx" ON "Artwork"("ownerId"); + +-- CreateIndex +CREATE INDEX "Artwork_projectId_updatedAt_idx" ON "Artwork"("projectId", "updatedAt"); + +-- CreateIndex +CREATE INDEX "Artwork_ownerId_updatedAt_idx" ON "Artwork"("ownerId", "updatedAt"); + +-- CreateIndex +CREATE UNIQUE INDEX "Artwork_slug_ownerId_key" ON "Artwork"("slug", "ownerId"); + +-- CreateIndex +CREATE INDEX "ArtworkBranch_artworkId_idx" ON "ArtworkBranch"("artworkId"); + +-- CreateIndex +CREATE INDEX "ArtworkBranch_ownerId_idx" ON "ArtworkBranch"("ownerId"); + +-- CreateIndex +CREATE UNIQUE INDEX "ArtworkBranch_artworkId_name_key" ON "ArtworkBranch"("artworkId", "name"); + +-- CreateIndex +CREATE UNIQUE INDEX "ArtworkBranch_artworkId_slug_key" ON "ArtworkBranch"("artworkId", "slug"); + +-- CreateIndex +CREATE UNIQUE INDEX "ArtworkVersion_nextId_key" ON "ArtworkVersion"("nextId"); + +-- CreateIndex +CREATE UNIQUE INDEX "ArtworkVersion_prevId_key" ON "ArtworkVersion"("prevId"); + +-- CreateIndex +CREATE INDEX "ArtworkVersion_branchId_idx" ON "ArtworkVersion"("branchId"); + +-- CreateIndex +CREATE INDEX "ArtworkVersion_ownerId_idx" ON "ArtworkVersion"("ownerId"); + +-- CreateIndex +CREATE UNIQUE INDEX "ArtworkVersion_branchId_name_key" ON "ArtworkVersion"("branchId", "name"); + +-- CreateIndex +CREATE UNIQUE INDEX "ArtworkVersion_branchId_slug_key" ON "ArtworkVersion"("branchId", "slug"); + +-- CreateIndex +CREATE INDEX "ArtworkMergeRequest_artworkId_idx" ON "ArtworkMergeRequest"("artworkId"); + +-- CreateIndex +CREATE INDEX "ArtworkMergeRequest_sourceBranchId_idx" ON "ArtworkMergeRequest"("sourceBranchId"); + +-- CreateIndex +CREATE INDEX "ArtworkMergeRequest_targetBranchId_idx" ON "ArtworkMergeRequest"("targetBranchId"); diff --git a/prisma/schema.prisma b/prisma/schema.prisma index 824d0056..6ddd3806 100644 --- a/prisma/schema.prisma +++ b/prisma/schema.prisma @@ -27,9 +27,9 @@ model User { connections Connection[] // added after epic-stack created projects Project[] - artboards Artboard[] - artboardVersions ArtboardVersion[] - artboardBranches ArtboardBranch[] + artworks Artwork[] + artworkVersions ArtworkVersion[] + artworkBranches ArtworkBranch[] layers Layer[] designs Design[] assetImages AssetImage[] @@ -191,7 +191,7 @@ model Project { owner User @relation(fields: [ownerId], references: [id], onDelete: Cascade, onUpdate: Cascade) ownerId String - artboards Artboard[] + artworks Artwork[] // non-unique foreign key @@index([ownerId]) @@ -201,7 +201,7 @@ model Project { @@unique([slug, ownerId]) } -model Artboard { +model Artwork { id String @id @default(cuid()) name String description String? @@ -220,8 +220,8 @@ model Artboard { project Project @relation(fields: [projectId], references: [id], onDelete: Cascade, onUpdate: Cascade) projectId String - branches ArtboardBranch[] - mergeRequests ArtboardMergeRequest[] + branches ArtworkBranch[] + mergeRequests ArtworkMergeRequest[] // non-unique foreign key @@index([projectId]) @@ -247,8 +247,8 @@ model Layer { owner User @relation(fields: [ownerId], references: [id], onDelete: Cascade, onUpdate: Cascade) ownerId String - artboardVersionId String? - artboardVersion ArtboardVersion? @relation(fields: [artboardVersionId], references: [id], onDelete: Cascade, onUpdate: Cascade) + artworkVersionId String? + artworkVersion ArtworkVersion? @relation(fields: [artworkVersionId], references: [id], onDelete: Cascade, onUpdate: Cascade) next Layer? @relation("LayerDoublyLinkedList", fields: [nextId], references: [id]) nextId String? @unique @@ -265,12 +265,12 @@ model Layer { // non-unique foreign key @@index([ownerId]) - @@index([artboardVersionId]) + @@index([artworkVersionId]) @@index([parentId]) // This helps our order by in the user search a LOT @@index([ownerId, updatedAt]) // Unique constraint for slug scoped to ownerId - @@unique([slug, ownerId, artboardVersionId]) + @@unique([slug, ownerId, artworkVersionId]) } model AssetImage { @@ -342,8 +342,8 @@ model Design { owner User @relation(fields: [ownerId], references: [id], onDelete: Cascade, onUpdate: Cascade) ownerId String - artboardVersionId String? - artboardVersion ArtboardVersion? @relation(fields: [artboardVersionId], references: [id], onDelete: Cascade, onUpdate: Cascade) + artworkVersionId String? + artworkVersion ArtworkVersion? @relation(fields: [artworkVersionId], references: [id], onDelete: Cascade, onUpdate: Cascade) layer Layer? @relation(fields: [layerId], references: [id], onDelete: Cascade, onUpdate: Cascade) layerId String? @@ -360,7 +360,7 @@ model Design { // non-unique foreign key @@index([ownerId]) @@index([layerId]) - @@index([artboardVersionId]) + @@index([artworkVersionId]) } model Palette { @@ -476,7 +476,7 @@ model Template { designId String @unique } -model ArtboardBranch { +model ArtworkBranch { id String @id @default(cuid()) name String @default("main") slug String @default("main") @@ -490,30 +490,30 @@ model ArtboardBranch { owner User @relation(fields: [ownerId], references: [id], onDelete: Cascade, onUpdate: Cascade) ownerId String - artboard Artboard @relation(fields: [artboardId], references: [id], onDelete: Cascade, onUpdate: Cascade) - artboardId String + artwork Artwork @relation(fields: [artworkId], references: [id], onDelete: Cascade, onUpdate: Cascade) + artworkId String parentId String? - parent ArtboardBranch? @relation("ParentChildArtboardBranch", fields: [parentId], references: [id]) - children ArtboardBranch[] @relation("ParentChildArtboardBranch") + parent ArtworkBranch? @relation("ParentChildArtworkBranch", fields: [parentId], references: [id]) + children ArtworkBranch[] @relation("ParentChildArtworkBranch") - versions ArtboardVersion[] - mergeRequestsSource ArtboardMergeRequest[] @relation("ArtboardMergeRequestSourceBranch") - mergeRequestsTarget ArtboardMergeRequest[] @relation("ArtboardMergeRequestTargetBranch") + versions ArtworkVersion[] + mergeRequestsSource ArtworkMergeRequest[] @relation("ArtworkMergeRequestSourceBranch") + mergeRequestsTarget ArtworkMergeRequest[] @relation("ArtworkMergeRequestTargetBranch") // non-unique foreign key - @@index([artboardId]) + @@index([artworkId]) @@index([ownerId]) // Constraints to ensure only one 'default' version per branch // and only unique name per branch - // @@unique([artboardId, default]) + // @@unique([artworkId, default]) // can't have unique constraint on boolean -- come back later to fix - @@unique([artboardId, name]) - @@unique([artboardId, slug]) + @@unique([artworkId, name]) + @@unique([artworkId, slug]) } -model ArtboardVersion { +model ArtworkVersion { id String @id @default(cuid()) name String @default("v0") slug String @default("v0") @@ -531,13 +531,13 @@ model ArtboardVersion { owner User @relation(fields: [ownerId], references: [id], onDelete: Cascade, onUpdate: Cascade) ownerId String - branch ArtboardBranch @relation(fields: [branchId], references: [id], onDelete: Cascade, onUpdate: Cascade) + branch ArtworkBranch @relation(fields: [branchId], references: [id], onDelete: Cascade, onUpdate: Cascade) branchId String - next ArtboardVersion? @relation("ArtboardVersionDoublyLinkedList", fields: [nextId], references: [id]) + next ArtworkVersion? @relation("ArtworkVersionDoublyLinkedList", fields: [nextId], references: [id]) nextId String? @unique - prev ArtboardVersion? @relation("ArtboardVersionDoublyLinkedList") + prev ArtworkVersion? @relation("ArtworkVersionDoublyLinkedList") prevId String? @unique layers Layer[] @@ -553,7 +553,7 @@ model ArtboardVersion { @@unique([branchId, slug]) } -model ArtboardMergeRequest { +model ArtworkMergeRequest { id String @id @default(cuid()) status String @default("open") // e.g. open, closed, merged title String @@ -562,17 +562,17 @@ model ArtboardMergeRequest { createdAt DateTime @default(now()) updatedAt DateTime @updatedAt - artboard Artboard @relation(fields: [artboardId], references: [id], onDelete: Cascade, onUpdate: Cascade) - artboardId String + artwork Artwork @relation(fields: [artworkId], references: [id], onDelete: Cascade, onUpdate: Cascade) + artworkId String sourceBranchId String - sourceBranch ArtboardBranch @relation(name: "ArtboardMergeRequestSourceBranch", fields: [sourceBranchId], references: [id], onDelete: Cascade, onUpdate: Cascade) + sourceBranch ArtworkBranch @relation(name: "ArtworkMergeRequestSourceBranch", fields: [sourceBranchId], references: [id], onDelete: Cascade, onUpdate: Cascade) targetBranchId String - targetBranch ArtboardBranch @relation(name: "ArtboardMergeRequestTargetBranch", fields: [targetBranchId], references: [id], onDelete: Cascade, onUpdate: Cascade) + targetBranch ArtworkBranch @relation(name: "ArtworkMergeRequestTargetBranch", fields: [targetBranchId], references: [id], onDelete: Cascade, onUpdate: Cascade) // non-unique foreign key - @@index([artboardId]) + @@index([artworkId]) @@index([sourceBranchId]) @@index([targetBranchId]) } diff --git a/prisma/seed.ts b/prisma/seed.ts index 8c9d6722..04527cd4 100644 --- a/prisma/seed.ts +++ b/prisma/seed.ts @@ -21,7 +21,7 @@ async function seed() { console.time('🔑 Created permissions...') // don't forget to update permissions.ts when adding entities - const entities = ['user', 'note', 'project', 'artboard', 'layer'] + const entities = ['user', 'note', 'project', 'artwork', 'layer'] const actions = ['create', 'read', 'update', 'delete'] const accesses = ['own', 'any'] as const for (const entity of entities) { @@ -270,12 +270,12 @@ async function seed() { }) console.timeEnd(`🐨 Created admin user "pat"`) - console.time(`🐨 Created artboard`) - await prisma.artboard.create({ + console.time(`🐨 Created artwork`) + await prisma.artwork.create({ data: { - name: 'My First Artboard', - description: 'This is my first artboard. I am so excited to get started!', - slug: 'my-first-artboard', + name: 'My First Artwork', + description: 'This is my first artwork. I am so excited to get started!', + slug: 'my-first-artwork', width: 1080, height: 1920, backgroundColor: 'F5F5F5', @@ -283,7 +283,7 @@ async function seed() { projectId: '1zxo9f8e', // Associate with the first project by hard-coded id }, }) - console.timeEnd(`🐨 Created artboard`) + console.timeEnd(`🐨 Created artwork`) console.timeEnd(`🌱 Database has been seeded`) } From 711a9af7847fefb00be729b60df6dbbdff0ab125 Mon Sep 17 00:00:00 2001 From: Pat Needham Date: Wed, 22 May 2024 04:20:05 -0400 Subject: [PATCH 3/3] artboard to artwork --- .../panel/dashboard-entity-panel.actions.delete.tsx | 2 +- .../dashboard-entity-panel.actions.toggle-selected.tsx | 2 +- .../templates/panel/dashboard-entity-panel.header.tsx | 4 ++-- .../templates/panel/dashboard-entity-panel.reorder.tsx | 4 ++-- .../panel/dashboard-entity-panel.values.layer.tsx | 2 +- .../artwork-branch/artwork-branch.create.server.ts | 2 +- .../artwork-version/artwork-version.create.server.ts | 2 +- .../artwork-version/artwork-version.update.server.ts | 8 ++++---- .../design-artwork-version.create.server.ts | 2 +- .../design-artwork-version.delete.server.ts | 2 +- .../design-artwork-version.update.server.ts | 4 ++-- .../layer-artwork-version.update.server.ts | 10 +++++----- 12 files changed, 22 insertions(+), 22 deletions(-) diff --git a/app/components/templates/panel/dashboard-entity-panel.actions.delete.tsx b/app/components/templates/panel/dashboard-entity-panel.actions.delete.tsx index 9d28d7b0..42a552de 100644 --- a/app/components/templates/panel/dashboard-entity-panel.actions.delete.tsx +++ b/app/components/templates/panel/dashboard-entity-panel.actions.delete.tsx @@ -1,4 +1,5 @@ import { memo, useCallback } from 'react' +import { ArtworkVersionDesignDelete } from '#app/routes/resources+/api.v1+/artwork-version.design.delete' import { LayerDesignDelete } from '#app/routes/resources+/api.v1+/layer.design.delete' import { type entityParentTypeEnum, @@ -9,7 +10,6 @@ import { EntityParentType, } from '#app/schema/entity' import { type IDashboardPanelDeleteEntityStrategy } from '#app/strategies/component/dashboard-panel/delete-entity.strategy' -import { ArtworkVersionDesignDelete } from '#app/routes/resources+/api.v1+/artwork-version.design.delete' interface DeleteChildEntityFormProps { entityType: entityTypeEnum diff --git a/app/components/templates/panel/dashboard-entity-panel.actions.toggle-selected.tsx b/app/components/templates/panel/dashboard-entity-panel.actions.toggle-selected.tsx index 5610fd44..7dafedba 100644 --- a/app/components/templates/panel/dashboard-entity-panel.actions.toggle-selected.tsx +++ b/app/components/templates/panel/dashboard-entity-panel.actions.toggle-selected.tsx @@ -1,6 +1,7 @@ import { memo, useCallback } from 'react' import { type IArtworkVersion } from '#app/models/artwork-version/artwork-version.server' import { type ILayer } from '#app/models/layer/layer.server' +import { ArtworkVersionLayerToggleSelected } from '#app/routes/resources+/api.v1+/artwork-version.layer.update.selected' import { type entityParentTypeEnum, type entityTypeEnum, @@ -10,7 +11,6 @@ import { EntityParentType, } from '#app/schema/entity' import { type IDashboardPanelSelectEntityStrategy } from '#app/strategies/component/dashboard-panel/update-entity-selected.strategy' -import { ArtworkVersionLayerToggleSelected } from '#app/routes/resources+/api.v1+/artwork-version.layer.update.selected' interface ToggleSelectedChildEntityFormProps { entityType: entityTypeEnum diff --git a/app/components/templates/panel/dashboard-entity-panel.header.tsx b/app/components/templates/panel/dashboard-entity-panel.header.tsx index c141e9bd..7622c070 100644 --- a/app/components/templates/panel/dashboard-entity-panel.header.tsx +++ b/app/components/templates/panel/dashboard-entity-panel.header.tsx @@ -1,4 +1,6 @@ import { memo, useCallback } from 'react' +import { ArtworkVersionDesignCreate } from '#app/routes/resources+/api.v1+/artwork-version.design.create' +import { ArtworkVersionLayerCreate } from '#app/routes/resources+/api.v1+/artwork-version.layer.create' import { LayerDesignCreate } from '#app/routes/resources+/api.v1+/layer.design.create' import { type designTypeEnum } from '#app/schema/design' import { @@ -12,8 +14,6 @@ import { import { type IDashboardPanelCreateEntityStrategy } from '#app/strategies/component/dashboard-panel/create-entity.strategy' import { capitalize } from '#app/utils/string-formatting' import { SidebarPanelHeader, SidebarPanelRowActionsContainer } from '..' -import { ArtworkVersionDesignCreate } from '#app/routes/resources+/api.v1+/artwork-version.design.create' -import { ArtworkVersionLayerCreate } from '#app/routes/resources+/api.v1+/artwork-version.layer.create' // the create forms ultimately lead to resource routes with fetchers and actions // this causes unnecessary rerenders diff --git a/app/components/templates/panel/dashboard-entity-panel.reorder.tsx b/app/components/templates/panel/dashboard-entity-panel.reorder.tsx index d6d42170..0750cbf9 100644 --- a/app/components/templates/panel/dashboard-entity-panel.reorder.tsx +++ b/app/components/templates/panel/dashboard-entity-panel.reorder.tsx @@ -2,6 +2,8 @@ import { memo, useCallback } from 'react' import { type IArtworkVersion } from '#app/models/artwork-version/artwork-version.server' import { type IDesign } from '#app/models/design/design.server' import { type ILayer } from '#app/models/layer/layer.server' +import { ArtworkVersionDesignReorder } from '#app/routes/resources+/api.v1+/artwork-version.design.update.order' +import { ArtworkVersionLayerReorder } from '#app/routes/resources+/api.v1+/artwork-version.layer.update.order' import { LayerDesignReorder } from '#app/routes/resources+/api.v1+/layer.design.update.order' import { EntityParentType, @@ -13,8 +15,6 @@ import { } from '#app/schema/entity' import { type IDashboardPanelUpdateEntityOrderStrategy } from '#app/strategies/component/dashboard-panel/update-entity-order.strategy' import { SidebarPanelRowReorderContainer } from '..' -import { ArtworkVersionDesignReorder } from '#app/routes/resources+/api.v1+/artwork-version.design.update.order' -import { ArtworkVersionLayerReorder } from '#app/routes/resources+/api.v1+/artwork-version.layer.update.order' interface ReorderChildEntityFormProps { entityType: entityTypeEnum diff --git a/app/components/templates/panel/dashboard-entity-panel.values.layer.tsx b/app/components/templates/panel/dashboard-entity-panel.values.layer.tsx index 51ab695c..c132f034 100644 --- a/app/components/templates/panel/dashboard-entity-panel.values.layer.tsx +++ b/app/components/templates/panel/dashboard-entity-panel.values.layer.tsx @@ -3,12 +3,12 @@ import { SidebarPanelPopoverFormContainer } from '#app/components/layout/popover import { Separator } from '#app/components/ui/separator' import { type IArtworkVersion } from '#app/models/artwork-version/artwork-version.server' import { type ILayer } from '#app/models/layer/layer.server' +import { ArtworkVersionLayerDelete } from '#app/routes/resources+/api.v1+/artwork-version.layer.delete' import { LayerDescription } from '#app/routes/resources+/api.v1+/layer.update.description' import { LayerName } from '#app/routes/resources+/api.v1+/layer.update.name' import { type IEntityParentType, type IEntity } from '#app/schema/entity' import { SidebarPanelRowValuesContainer } from '..' import { PanelEntityPopover } from './dashboard-entity-panel.popover' -import { ArtworkVersionLayerDelete } from '#app/routes/resources+/api.v1+/artwork-version.layer.delete' interface EntityProps { entity: IEntity diff --git a/app/models/artwork-branch/artwork-branch.create.server.ts b/app/models/artwork-branch/artwork-branch.create.server.ts index a719f611..f75b6f35 100644 --- a/app/models/artwork-branch/artwork-branch.create.server.ts +++ b/app/models/artwork-branch/artwork-branch.create.server.ts @@ -1,4 +1,5 @@ import { type IntentActionArgs } from '#app/definitions/intent-action-args' +import { NewArtworkBranchSchema } from '#app/schema/artwork-branch' import { ValidateArtworkParentSubmissionStrategy } from '#app/strategies/validate-submission.strategy' import { validateEntitySubmission } from '#app/utils/conform-utils' import { prisma } from '#app/utils/db.server' @@ -8,7 +9,6 @@ import { type IArtworkBranch, type IArtworkBranchWithVersions, } from './artwork-branch.server' -import { NewArtworkBranchSchema } from '#app/schema/artwork-branch' export interface IArtworkBranchCreatedResponse { success: boolean diff --git a/app/models/artwork-version/artwork-version.create.server.ts b/app/models/artwork-version/artwork-version.create.server.ts index 384298bf..dec859ac 100644 --- a/app/models/artwork-version/artwork-version.create.server.ts +++ b/app/models/artwork-version/artwork-version.create.server.ts @@ -1,11 +1,11 @@ import { type IntentActionArgs } from '#app/definitions/intent-action-args' +import { NewArtworkVersionSchema } from '#app/schema/artwork-version' import { ValidateArtworkBranchParentSubmissionStrategy } from '#app/strategies/validate-submission.strategy' import { validateEntitySubmission } from '#app/utils/conform-utils' import { prisma } from '#app/utils/db.server' import { type IArtworkBranch } from '../artwork-branch/artwork-branch.server' import { type IUser } from '../user/user.server' import { type IArtworkVersion } from './artwork-version.server' -import { NewArtworkVersionSchema } from '#app/schema/artwork-version' export interface IArtworkVersionCreatedResponse { success: boolean diff --git a/app/models/artwork-version/artwork-version.update.server.ts b/app/models/artwork-version/artwork-version.update.server.ts index e02c03db..9652ea47 100644 --- a/app/models/artwork-version/artwork-version.update.server.ts +++ b/app/models/artwork-version/artwork-version.update.server.ts @@ -1,15 +1,15 @@ import { type IntentActionArgs } from '#app/definitions/intent-action-args' -import { ValidateArtworkVersionSubmissionStrategy } from '#app/strategies/validate-submission.strategy' -import { validateEntitySubmission } from '#app/utils/conform-utils' -import { prisma } from '#app/utils/db.server' -import { type IArtworkVersion } from './artwork-version.server' import { ArtworkVersionWidthSchema, type ArtworkVersionUpdateSchemaType, ArtworkVersionHeightSchema, ArtworkVersionBackgroundSchema, } from '#app/schema/artwork-version' +import { ValidateArtworkVersionSubmissionStrategy } from '#app/strategies/validate-submission.strategy' +import { validateEntitySubmission } from '#app/utils/conform-utils' +import { prisma } from '#app/utils/db.server' import { findFirstArtworkVersionInstance } from '#app/utils/prisma-extensions-artwork-version' +import { type IArtworkVersion } from './artwork-version.server' const validateUpdateSubmission = async ({ userId, diff --git a/app/models/design-artwork-version/design-artwork-version.create.server.ts b/app/models/design-artwork-version/design-artwork-version.create.server.ts index 90fd8de3..e58f9a93 100644 --- a/app/models/design-artwork-version/design-artwork-version.create.server.ts +++ b/app/models/design-artwork-version/design-artwork-version.create.server.ts @@ -1,7 +1,7 @@ import { type IntentActionArgs } from '#app/definitions/intent-action-args' +import { NewArtworkVersionDesignSchema } from '#app/schema/design-artwork-version' import { ValidateArtworkVersionParentSubmissionStrategy } from '#app/strategies/validate-submission.strategy' import { validateEntitySubmission } from '#app/utils/conform-utils' -import { NewArtworkVersionDesignSchema } from '#app/schema/design-artwork-version' export const validateArtworkVersionNewDesignSubmission = async ({ userId, diff --git a/app/models/design-artwork-version/design-artwork-version.delete.server.ts b/app/models/design-artwork-version/design-artwork-version.delete.server.ts index ee2cc527..1804a2bd 100644 --- a/app/models/design-artwork-version/design-artwork-version.delete.server.ts +++ b/app/models/design-artwork-version/design-artwork-version.delete.server.ts @@ -1,7 +1,7 @@ import { type IntentActionArgs } from '#app/definitions/intent-action-args' +import { DeleteArtworkVersionDesignSchema } from '#app/schema/design-artwork-version' import { ValidateArtworkVersionParentSubmissionStrategy } from '#app/strategies/validate-submission.strategy' import { validateEntitySubmission } from '#app/utils/conform-utils' -import { DeleteArtworkVersionDesignSchema } from '#app/schema/design-artwork-version' export const validateArtworkVersionDeleteDesignSubmission = async ({ userId, diff --git a/app/models/design-artwork-version/design-artwork-version.update.server.ts b/app/models/design-artwork-version/design-artwork-version.update.server.ts index 33afb3f5..40167e32 100644 --- a/app/models/design-artwork-version/design-artwork-version.update.server.ts +++ b/app/models/design-artwork-version/design-artwork-version.update.server.ts @@ -1,10 +1,10 @@ import { type IntentActionArgs } from '#app/definitions/intent-action-args' -import { ValidateArtworkVersionParentSubmissionStrategy } from '#app/strategies/validate-submission.strategy' -import { validateEntitySubmission } from '#app/utils/conform-utils' import { ReorderArtworkVersionDesignSchema, ToggleVisibleArtworkVersionDesignSchema, } from '#app/schema/design-artwork-version' +import { ValidateArtworkVersionParentSubmissionStrategy } from '#app/strategies/validate-submission.strategy' +import { validateEntitySubmission } from '#app/utils/conform-utils' export const validateArtworkVersionToggleVisibeDesignSubmission = async ({ userId, diff --git a/app/models/layer-artwork-version/layer-artwork-version.update.server.ts b/app/models/layer-artwork-version/layer-artwork-version.update.server.ts index 0371b95b..b5475592 100644 --- a/app/models/layer-artwork-version/layer-artwork-version.update.server.ts +++ b/app/models/layer-artwork-version/layer-artwork-version.update.server.ts @@ -1,14 +1,14 @@ import { type IntentActionArgs } from '#app/definitions/intent-action-args' -import { ValidateArtworkVersionParentSubmissionStrategy } from '#app/strategies/validate-submission.strategy' -import { validateEntitySubmission } from '#app/utils/conform-utils' -import { prisma } from '#app/utils/db.server' -import { type IArtworkVersion } from '../artwork-version/artwork-version.server' -import { type ILayer } from '../layer/layer.server' import { ReorderArtworkVersionLayerSchema, SelectArtworkVersionLayerSchema, ToggleVisibleArtworkVersionLayerSchema, } from '#app/schema/layer-artwork-version' +import { ValidateArtworkVersionParentSubmissionStrategy } from '#app/strategies/validate-submission.strategy' +import { validateEntitySubmission } from '#app/utils/conform-utils' +import { prisma } from '#app/utils/db.server' +import { type IArtworkVersion } from '../artwork-version/artwork-version.server' +import { type ILayer } from '../layer/layer.server' export const validateArtworkVersionToggleVisibeLayerSubmission = async ({ userId,