From 0c47394001cebf9a904fd5521056419761053dc7 Mon Sep 17 00:00:00 2001 From: ledouxm Date: Tue, 12 Nov 2024 15:15:39 +0100 Subject: [PATCH] feat: add picture_lines in db and save lines --- db/migrations/909-add_picture_lines.sql | 8 + .../src/generated/client/index.ts | 541 +++++- .../src/generated/client/migrations.ts | 19 + .../src/generated/client/pg-migrations.ts | 25 + .../src/generated/client/prismaClient.d.ts | 1510 ++++++++++++++++- .../src/generated/typebox/index.ts | 2 +- .../src/features/upload/DrawingCanvas.tsx | 405 ++++- .../src/features/upload/UploadImage.tsx | 52 +- 8 files changed, 2413 insertions(+), 149 deletions(-) create mode 100644 db/migrations/909-add_picture_lines.sql diff --git a/db/migrations/909-add_picture_lines.sql b/db/migrations/909-add_picture_lines.sql new file mode 100644 index 0000000..70aa5e7 --- /dev/null +++ b/db/migrations/909-add_picture_lines.sql @@ -0,0 +1,8 @@ +CREATE TABLE picture_lines ( + id TEXT PRIMARY KEY, + "pictureId" TEXT REFERENCES pictures(id) ON DELETE CASCADE, + lines TEXT NOT NULL, + "createdAt" TIMESTAMP +); + +ALTER TABLE picture_lines ENABLE ELECTRIC; \ No newline at end of file diff --git a/packages/electric-client/src/generated/client/index.ts b/packages/electric-client/src/generated/client/index.ts index 475f94c..a49fcff 100644 --- a/packages/electric-client/src/generated/client/index.ts +++ b/packages/electric-client/src/generated/client/index.ts @@ -21,6 +21,8 @@ export const DelegationScalarFieldEnumSchema = z.enum(['createdBy','delegatedTo' export const Pdf_snapshotScalarFieldEnumSchema = z.enum(['id','report_id','html','report','user_id']); +export const Picture_linesScalarFieldEnumSchema = z.enum(['id','pictureId','lines','createdAt']); + export const PicturesScalarFieldEnumSchema = z.enum(['id','reportId','url','createdAt']); export const QueryModeSchema = z.enum(['default','insensitive']); @@ -96,6 +98,19 @@ export const Pdf_snapshotSchema = z.object({ export type Pdf_snapshot = z.infer +///////////////////////////////////////// +// PICTURE LINES SCHEMA +///////////////////////////////////////// + +export const Picture_linesSchema = z.object({ + id: z.string(), + pictureId: z.string().nullable(), + lines: z.string(), + createdAt: z.coerce.date().nullable(), +}) + +export type Picture_lines = z.infer + ///////////////////////////////////////// // PICTURES SCHEMA ///////////////////////////////////////// @@ -260,11 +275,33 @@ export const Pdf_snapshotSelectSchema: z.ZodType = z. user_id: z.boolean().optional(), }).strict() +// PICTURE LINES +//------------------------------------------------------ + +export const Picture_linesIncludeSchema: z.ZodType = z.object({ + pictures: z.union([z.boolean(),z.lazy(() => PicturesArgsSchema)]).optional(), +}).strict() + +export const Picture_linesArgsSchema: z.ZodType = z.object({ + select: z.lazy(() => Picture_linesSelectSchema).optional(), + include: z.lazy(() => Picture_linesIncludeSchema).optional(), +}).strict(); + +export const Picture_linesSelectSchema: z.ZodType = z.object({ + id: z.boolean().optional(), + pictureId: z.boolean().optional(), + lines: z.boolean().optional(), + createdAt: z.boolean().optional(), + pictures: z.union([z.boolean(),z.lazy(() => PicturesArgsSchema)]).optional(), +}).strict() + // PICTURES //------------------------------------------------------ export const PicturesIncludeSchema: z.ZodType = z.object({ + picture_lines: z.union([z.boolean(),z.lazy(() => Picture_linesFindManyArgsSchema)]).optional(), report: z.union([z.boolean(),z.lazy(() => ReportArgsSchema)]).optional(), + _count: z.union([z.boolean(),z.lazy(() => PicturesCountOutputTypeArgsSchema)]).optional(), }).strict() export const PicturesArgsSchema: z.ZodType = z.object({ @@ -272,12 +309,22 @@ export const PicturesArgsSchema: z.ZodType = z.object({ include: z.lazy(() => PicturesIncludeSchema).optional(), }).strict(); +export const PicturesCountOutputTypeArgsSchema: z.ZodType = z.object({ + select: z.lazy(() => PicturesCountOutputTypeSelectSchema).nullish(), +}).strict(); + +export const PicturesCountOutputTypeSelectSchema: z.ZodType = z.object({ + picture_lines: z.boolean().optional(), +}).strict(); + export const PicturesSelectSchema: z.ZodType = z.object({ id: z.boolean().optional(), reportId: z.boolean().optional(), url: z.boolean().optional(), createdAt: z.boolean().optional(), + picture_lines: z.union([z.boolean(),z.lazy(() => Picture_linesFindManyArgsSchema)]).optional(), report: z.union([z.boolean(),z.lazy(() => ReportArgsSchema)]).optional(), + _count: z.union([z.boolean(),z.lazy(() => PicturesCountOutputTypeArgsSchema)]).optional(), }).strict() // REPORT @@ -624,6 +671,49 @@ export const Pdf_snapshotScalarWhereWithAggregatesInputSchema: z.ZodType StringNullableWithAggregatesFilterSchema),z.string() ]).optional().nullable(), }).strict(); +export const Picture_linesWhereInputSchema: z.ZodType = z.object({ + AND: z.union([ z.lazy(() => Picture_linesWhereInputSchema),z.lazy(() => Picture_linesWhereInputSchema).array() ]).optional(), + OR: z.lazy(() => Picture_linesWhereInputSchema).array().optional(), + NOT: z.union([ z.lazy(() => Picture_linesWhereInputSchema),z.lazy(() => Picture_linesWhereInputSchema).array() ]).optional(), + id: z.union([ z.lazy(() => StringFilterSchema),z.string() ]).optional(), + pictureId: z.union([ z.lazy(() => StringNullableFilterSchema),z.string() ]).optional().nullable(), + lines: z.union([ z.lazy(() => StringFilterSchema),z.string() ]).optional(), + createdAt: z.union([ z.lazy(() => DateTimeNullableFilterSchema),z.coerce.date() ]).optional().nullable(), + pictures: z.union([ z.lazy(() => PicturesRelationFilterSchema),z.lazy(() => PicturesWhereInputSchema) ]).optional().nullable(), +}).strict(); + +export const Picture_linesOrderByWithRelationInputSchema: z.ZodType = z.object({ + id: z.lazy(() => SortOrderSchema).optional(), + pictureId: z.lazy(() => SortOrderSchema).optional(), + lines: z.lazy(() => SortOrderSchema).optional(), + createdAt: z.lazy(() => SortOrderSchema).optional(), + pictures: z.lazy(() => PicturesOrderByWithRelationInputSchema).optional() +}).strict(); + +export const Picture_linesWhereUniqueInputSchema: z.ZodType = z.object({ + id: z.string().optional() +}).strict(); + +export const Picture_linesOrderByWithAggregationInputSchema: z.ZodType = z.object({ + id: z.lazy(() => SortOrderSchema).optional(), + pictureId: z.lazy(() => SortOrderSchema).optional(), + lines: z.lazy(() => SortOrderSchema).optional(), + createdAt: z.lazy(() => SortOrderSchema).optional(), + _count: z.lazy(() => Picture_linesCountOrderByAggregateInputSchema).optional(), + _max: z.lazy(() => Picture_linesMaxOrderByAggregateInputSchema).optional(), + _min: z.lazy(() => Picture_linesMinOrderByAggregateInputSchema).optional() +}).strict(); + +export const Picture_linesScalarWhereWithAggregatesInputSchema: z.ZodType = z.object({ + AND: z.union([ z.lazy(() => Picture_linesScalarWhereWithAggregatesInputSchema),z.lazy(() => Picture_linesScalarWhereWithAggregatesInputSchema).array() ]).optional(), + OR: z.lazy(() => Picture_linesScalarWhereWithAggregatesInputSchema).array().optional(), + NOT: z.union([ z.lazy(() => Picture_linesScalarWhereWithAggregatesInputSchema),z.lazy(() => Picture_linesScalarWhereWithAggregatesInputSchema).array() ]).optional(), + id: z.union([ z.lazy(() => StringWithAggregatesFilterSchema),z.string() ]).optional(), + pictureId: z.union([ z.lazy(() => StringNullableWithAggregatesFilterSchema),z.string() ]).optional().nullable(), + lines: z.union([ z.lazy(() => StringWithAggregatesFilterSchema),z.string() ]).optional(), + createdAt: z.union([ z.lazy(() => DateTimeNullableWithAggregatesFilterSchema),z.coerce.date() ]).optional().nullable(), +}).strict(); + export const PicturesWhereInputSchema: z.ZodType = z.object({ AND: z.union([ z.lazy(() => PicturesWhereInputSchema),z.lazy(() => PicturesWhereInputSchema).array() ]).optional(), OR: z.lazy(() => PicturesWhereInputSchema).array().optional(), @@ -632,6 +722,7 @@ export const PicturesWhereInputSchema: z.ZodType = z. reportId: z.union([ z.lazy(() => StringNullableFilterSchema),z.string() ]).optional().nullable(), url: z.union([ z.lazy(() => StringNullableFilterSchema),z.string() ]).optional().nullable(), createdAt: z.union([ z.lazy(() => DateTimeNullableFilterSchema),z.coerce.date() ]).optional().nullable(), + picture_lines: z.lazy(() => Picture_linesListRelationFilterSchema).optional(), report: z.union([ z.lazy(() => ReportRelationFilterSchema),z.lazy(() => ReportWhereInputSchema) ]).optional().nullable(), }).strict(); @@ -640,6 +731,7 @@ export const PicturesOrderByWithRelationInputSchema: z.ZodType SortOrderSchema).optional(), url: z.lazy(() => SortOrderSchema).optional(), createdAt: z.lazy(() => SortOrderSchema).optional(), + picture_lines: z.lazy(() => Picture_linesOrderByRelationAggregateInputSchema).optional(), report: z.lazy(() => ReportOrderByWithRelationInputSchema).optional() }).strict(); @@ -1214,10 +1306,59 @@ export const Pdf_snapshotUncheckedUpdateManyInputSchema: z.ZodType NullableStringFieldUpdateOperationsInputSchema) ]).optional().nullable(), }).strict(); +export const Picture_linesCreateInputSchema: z.ZodType = z.object({ + id: z.string(), + lines: z.string(), + createdAt: z.coerce.date().optional().nullable(), + pictures: z.lazy(() => PicturesCreateNestedOneWithoutPicture_linesInputSchema).optional() +}).strict(); + +export const Picture_linesUncheckedCreateInputSchema: z.ZodType = z.object({ + id: z.string(), + pictureId: z.string().optional().nullable(), + lines: z.string(), + createdAt: z.coerce.date().optional().nullable() +}).strict(); + +export const Picture_linesUpdateInputSchema: z.ZodType = z.object({ + id: z.union([ z.string(),z.lazy(() => StringFieldUpdateOperationsInputSchema) ]).optional(), + lines: z.union([ z.string(),z.lazy(() => StringFieldUpdateOperationsInputSchema) ]).optional(), + createdAt: z.union([ z.coerce.date(),z.lazy(() => NullableDateTimeFieldUpdateOperationsInputSchema) ]).optional().nullable(), + pictures: z.lazy(() => PicturesUpdateOneWithoutPicture_linesNestedInputSchema).optional() +}).strict(); + +export const Picture_linesUncheckedUpdateInputSchema: z.ZodType = z.object({ + id: z.union([ z.string(),z.lazy(() => StringFieldUpdateOperationsInputSchema) ]).optional(), + pictureId: z.union([ z.string(),z.lazy(() => NullableStringFieldUpdateOperationsInputSchema) ]).optional().nullable(), + lines: z.union([ z.string(),z.lazy(() => StringFieldUpdateOperationsInputSchema) ]).optional(), + createdAt: z.union([ z.coerce.date(),z.lazy(() => NullableDateTimeFieldUpdateOperationsInputSchema) ]).optional().nullable(), +}).strict(); + +export const Picture_linesCreateManyInputSchema: z.ZodType = z.object({ + id: z.string(), + pictureId: z.string().optional().nullable(), + lines: z.string(), + createdAt: z.coerce.date().optional().nullable() +}).strict(); + +export const Picture_linesUpdateManyMutationInputSchema: z.ZodType = z.object({ + id: z.union([ z.string(),z.lazy(() => StringFieldUpdateOperationsInputSchema) ]).optional(), + lines: z.union([ z.string(),z.lazy(() => StringFieldUpdateOperationsInputSchema) ]).optional(), + createdAt: z.union([ z.coerce.date(),z.lazy(() => NullableDateTimeFieldUpdateOperationsInputSchema) ]).optional().nullable(), +}).strict(); + +export const Picture_linesUncheckedUpdateManyInputSchema: z.ZodType = z.object({ + id: z.union([ z.string(),z.lazy(() => StringFieldUpdateOperationsInputSchema) ]).optional(), + pictureId: z.union([ z.string(),z.lazy(() => NullableStringFieldUpdateOperationsInputSchema) ]).optional().nullable(), + lines: z.union([ z.string(),z.lazy(() => StringFieldUpdateOperationsInputSchema) ]).optional(), + createdAt: z.union([ z.coerce.date(),z.lazy(() => NullableDateTimeFieldUpdateOperationsInputSchema) ]).optional().nullable(), +}).strict(); + export const PicturesCreateInputSchema: z.ZodType = z.object({ id: z.string(), url: z.string().optional().nullable(), createdAt: z.coerce.date().optional().nullable(), + picture_lines: z.lazy(() => Picture_linesCreateNestedManyWithoutPicturesInputSchema).optional(), report: z.lazy(() => ReportCreateNestedOneWithoutPicturesInputSchema).optional() }).strict(); @@ -1225,13 +1366,15 @@ export const PicturesUncheckedCreateInputSchema: z.ZodType Picture_linesUncheckedCreateNestedManyWithoutPicturesInputSchema).optional() }).strict(); export const PicturesUpdateInputSchema: z.ZodType = z.object({ id: z.union([ z.string(),z.lazy(() => StringFieldUpdateOperationsInputSchema) ]).optional(), url: z.union([ z.string(),z.lazy(() => NullableStringFieldUpdateOperationsInputSchema) ]).optional().nullable(), createdAt: z.union([ z.coerce.date(),z.lazy(() => NullableDateTimeFieldUpdateOperationsInputSchema) ]).optional().nullable(), + picture_lines: z.lazy(() => Picture_linesUpdateManyWithoutPicturesNestedInputSchema).optional(), report: z.lazy(() => ReportUpdateOneWithoutPicturesNestedInputSchema).optional() }).strict(); @@ -1240,6 +1383,7 @@ export const PicturesUncheckedUpdateInputSchema: z.ZodType NullableStringFieldUpdateOperationsInputSchema) ]).optional().nullable(), url: z.union([ z.string(),z.lazy(() => NullableStringFieldUpdateOperationsInputSchema) ]).optional().nullable(), createdAt: z.union([ z.coerce.date(),z.lazy(() => NullableDateTimeFieldUpdateOperationsInputSchema) ]).optional().nullable(), + picture_lines: z.lazy(() => Picture_linesUncheckedUpdateManyWithoutPicturesNestedInputSchema).optional() }).strict(); export const PicturesCreateManyInputSchema: z.ZodType = z.object({ @@ -1955,29 +2099,29 @@ export const DateTimeNullableFilterSchema: z.ZodType NestedDateTimeNullableFilterSchema) ]).optional().nullable(), }).strict(); -export const ReportRelationFilterSchema: z.ZodType = z.object({ - is: z.lazy(() => ReportWhereInputSchema).optional().nullable(), - isNot: z.lazy(() => ReportWhereInputSchema).optional().nullable() +export const PicturesRelationFilterSchema: z.ZodType = z.object({ + is: z.lazy(() => PicturesWhereInputSchema).optional().nullable(), + isNot: z.lazy(() => PicturesWhereInputSchema).optional().nullable() }).strict(); -export const PicturesCountOrderByAggregateInputSchema: z.ZodType = z.object({ +export const Picture_linesCountOrderByAggregateInputSchema: z.ZodType = z.object({ id: z.lazy(() => SortOrderSchema).optional(), - reportId: z.lazy(() => SortOrderSchema).optional(), - url: z.lazy(() => SortOrderSchema).optional(), + pictureId: z.lazy(() => SortOrderSchema).optional(), + lines: z.lazy(() => SortOrderSchema).optional(), createdAt: z.lazy(() => SortOrderSchema).optional() }).strict(); -export const PicturesMaxOrderByAggregateInputSchema: z.ZodType = z.object({ +export const Picture_linesMaxOrderByAggregateInputSchema: z.ZodType = z.object({ id: z.lazy(() => SortOrderSchema).optional(), - reportId: z.lazy(() => SortOrderSchema).optional(), - url: z.lazy(() => SortOrderSchema).optional(), + pictureId: z.lazy(() => SortOrderSchema).optional(), + lines: z.lazy(() => SortOrderSchema).optional(), createdAt: z.lazy(() => SortOrderSchema).optional() }).strict(); -export const PicturesMinOrderByAggregateInputSchema: z.ZodType = z.object({ +export const Picture_linesMinOrderByAggregateInputSchema: z.ZodType = z.object({ id: z.lazy(() => SortOrderSchema).optional(), - reportId: z.lazy(() => SortOrderSchema).optional(), - url: z.lazy(() => SortOrderSchema).optional(), + pictureId: z.lazy(() => SortOrderSchema).optional(), + lines: z.lazy(() => SortOrderSchema).optional(), createdAt: z.lazy(() => SortOrderSchema).optional() }).strict(); @@ -1995,6 +2139,42 @@ export const DateTimeNullableWithAggregatesFilterSchema: z.ZodType NestedDateTimeNullableFilterSchema).optional() }).strict(); +export const Picture_linesListRelationFilterSchema: z.ZodType = z.object({ + every: z.lazy(() => Picture_linesWhereInputSchema).optional(), + some: z.lazy(() => Picture_linesWhereInputSchema).optional(), + none: z.lazy(() => Picture_linesWhereInputSchema).optional() +}).strict(); + +export const ReportRelationFilterSchema: z.ZodType = z.object({ + is: z.lazy(() => ReportWhereInputSchema).optional().nullable(), + isNot: z.lazy(() => ReportWhereInputSchema).optional().nullable() +}).strict(); + +export const Picture_linesOrderByRelationAggregateInputSchema: z.ZodType = z.object({ + _count: z.lazy(() => SortOrderSchema).optional() +}).strict(); + +export const PicturesCountOrderByAggregateInputSchema: z.ZodType = z.object({ + id: z.lazy(() => SortOrderSchema).optional(), + reportId: z.lazy(() => SortOrderSchema).optional(), + url: z.lazy(() => SortOrderSchema).optional(), + createdAt: z.lazy(() => SortOrderSchema).optional() +}).strict(); + +export const PicturesMaxOrderByAggregateInputSchema: z.ZodType = z.object({ + id: z.lazy(() => SortOrderSchema).optional(), + reportId: z.lazy(() => SortOrderSchema).optional(), + url: z.lazy(() => SortOrderSchema).optional(), + createdAt: z.lazy(() => SortOrderSchema).optional() +}).strict(); + +export const PicturesMinOrderByAggregateInputSchema: z.ZodType = z.object({ + id: z.lazy(() => SortOrderSchema).optional(), + reportId: z.lazy(() => SortOrderSchema).optional(), + url: z.lazy(() => SortOrderSchema).optional(), + createdAt: z.lazy(() => SortOrderSchema).optional() +}).strict(); + export const DateTimeFilterSchema: z.ZodType = z.object({ equals: z.coerce.date().optional(), in: z.coerce.date().array().optional(), @@ -2355,14 +2535,58 @@ export const UserUpdateOneRequiredWithoutDelegation_delegation_delegatedToTouser update: z.union([ z.lazy(() => UserUpdateWithoutDelegation_delegation_delegatedToTouserInputSchema),z.lazy(() => UserUncheckedUpdateWithoutDelegation_delegation_delegatedToTouserInputSchema) ]).optional(), }).strict(); +export const PicturesCreateNestedOneWithoutPicture_linesInputSchema: z.ZodType = z.object({ + create: z.union([ z.lazy(() => PicturesCreateWithoutPicture_linesInputSchema),z.lazy(() => PicturesUncheckedCreateWithoutPicture_linesInputSchema) ]).optional(), + connectOrCreate: z.lazy(() => PicturesCreateOrConnectWithoutPicture_linesInputSchema).optional(), + connect: z.lazy(() => PicturesWhereUniqueInputSchema).optional() +}).strict(); + +export const NullableDateTimeFieldUpdateOperationsInputSchema: z.ZodType = z.object({ + set: z.coerce.date().optional().nullable() +}).strict(); + +export const PicturesUpdateOneWithoutPicture_linesNestedInputSchema: z.ZodType = z.object({ + create: z.union([ z.lazy(() => PicturesCreateWithoutPicture_linesInputSchema),z.lazy(() => PicturesUncheckedCreateWithoutPicture_linesInputSchema) ]).optional(), + connectOrCreate: z.lazy(() => PicturesCreateOrConnectWithoutPicture_linesInputSchema).optional(), + upsert: z.lazy(() => PicturesUpsertWithoutPicture_linesInputSchema).optional(), + disconnect: z.boolean().optional(), + delete: z.boolean().optional(), + connect: z.lazy(() => PicturesWhereUniqueInputSchema).optional(), + update: z.union([ z.lazy(() => PicturesUpdateWithoutPicture_linesInputSchema),z.lazy(() => PicturesUncheckedUpdateWithoutPicture_linesInputSchema) ]).optional(), +}).strict(); + +export const Picture_linesCreateNestedManyWithoutPicturesInputSchema: z.ZodType = z.object({ + create: z.union([ z.lazy(() => Picture_linesCreateWithoutPicturesInputSchema),z.lazy(() => Picture_linesCreateWithoutPicturesInputSchema).array(),z.lazy(() => Picture_linesUncheckedCreateWithoutPicturesInputSchema),z.lazy(() => Picture_linesUncheckedCreateWithoutPicturesInputSchema).array() ]).optional(), + connectOrCreate: z.union([ z.lazy(() => Picture_linesCreateOrConnectWithoutPicturesInputSchema),z.lazy(() => Picture_linesCreateOrConnectWithoutPicturesInputSchema).array() ]).optional(), + createMany: z.lazy(() => Picture_linesCreateManyPicturesInputEnvelopeSchema).optional(), + connect: z.union([ z.lazy(() => Picture_linesWhereUniqueInputSchema),z.lazy(() => Picture_linesWhereUniqueInputSchema).array() ]).optional(), +}).strict(); + export const ReportCreateNestedOneWithoutPicturesInputSchema: z.ZodType = z.object({ create: z.union([ z.lazy(() => ReportCreateWithoutPicturesInputSchema),z.lazy(() => ReportUncheckedCreateWithoutPicturesInputSchema) ]).optional(), connectOrCreate: z.lazy(() => ReportCreateOrConnectWithoutPicturesInputSchema).optional(), connect: z.lazy(() => ReportWhereUniqueInputSchema).optional() }).strict(); -export const NullableDateTimeFieldUpdateOperationsInputSchema: z.ZodType = z.object({ - set: z.coerce.date().optional().nullable() +export const Picture_linesUncheckedCreateNestedManyWithoutPicturesInputSchema: z.ZodType = z.object({ + create: z.union([ z.lazy(() => Picture_linesCreateWithoutPicturesInputSchema),z.lazy(() => Picture_linesCreateWithoutPicturesInputSchema).array(),z.lazy(() => Picture_linesUncheckedCreateWithoutPicturesInputSchema),z.lazy(() => Picture_linesUncheckedCreateWithoutPicturesInputSchema).array() ]).optional(), + connectOrCreate: z.union([ z.lazy(() => Picture_linesCreateOrConnectWithoutPicturesInputSchema),z.lazy(() => Picture_linesCreateOrConnectWithoutPicturesInputSchema).array() ]).optional(), + createMany: z.lazy(() => Picture_linesCreateManyPicturesInputEnvelopeSchema).optional(), + connect: z.union([ z.lazy(() => Picture_linesWhereUniqueInputSchema),z.lazy(() => Picture_linesWhereUniqueInputSchema).array() ]).optional(), +}).strict(); + +export const Picture_linesUpdateManyWithoutPicturesNestedInputSchema: z.ZodType = z.object({ + create: z.union([ z.lazy(() => Picture_linesCreateWithoutPicturesInputSchema),z.lazy(() => Picture_linesCreateWithoutPicturesInputSchema).array(),z.lazy(() => Picture_linesUncheckedCreateWithoutPicturesInputSchema),z.lazy(() => Picture_linesUncheckedCreateWithoutPicturesInputSchema).array() ]).optional(), + connectOrCreate: z.union([ z.lazy(() => Picture_linesCreateOrConnectWithoutPicturesInputSchema),z.lazy(() => Picture_linesCreateOrConnectWithoutPicturesInputSchema).array() ]).optional(), + upsert: z.union([ z.lazy(() => Picture_linesUpsertWithWhereUniqueWithoutPicturesInputSchema),z.lazy(() => Picture_linesUpsertWithWhereUniqueWithoutPicturesInputSchema).array() ]).optional(), + createMany: z.lazy(() => Picture_linesCreateManyPicturesInputEnvelopeSchema).optional(), + set: z.union([ z.lazy(() => Picture_linesWhereUniqueInputSchema),z.lazy(() => Picture_linesWhereUniqueInputSchema).array() ]).optional(), + disconnect: z.union([ z.lazy(() => Picture_linesWhereUniqueInputSchema),z.lazy(() => Picture_linesWhereUniqueInputSchema).array() ]).optional(), + delete: z.union([ z.lazy(() => Picture_linesWhereUniqueInputSchema),z.lazy(() => Picture_linesWhereUniqueInputSchema).array() ]).optional(), + connect: z.union([ z.lazy(() => Picture_linesWhereUniqueInputSchema),z.lazy(() => Picture_linesWhereUniqueInputSchema).array() ]).optional(), + update: z.union([ z.lazy(() => Picture_linesUpdateWithWhereUniqueWithoutPicturesInputSchema),z.lazy(() => Picture_linesUpdateWithWhereUniqueWithoutPicturesInputSchema).array() ]).optional(), + updateMany: z.union([ z.lazy(() => Picture_linesUpdateManyWithWhereWithoutPicturesInputSchema),z.lazy(() => Picture_linesUpdateManyWithWhereWithoutPicturesInputSchema).array() ]).optional(), + deleteMany: z.union([ z.lazy(() => Picture_linesScalarWhereInputSchema),z.lazy(() => Picture_linesScalarWhereInputSchema).array() ]).optional(), }).strict(); export const ReportUpdateOneWithoutPicturesNestedInputSchema: z.ZodType = z.object({ @@ -2375,6 +2599,20 @@ export const ReportUpdateOneWithoutPicturesNestedInputSchema: z.ZodType ReportUpdateWithoutPicturesInputSchema),z.lazy(() => ReportUncheckedUpdateWithoutPicturesInputSchema) ]).optional(), }).strict(); +export const Picture_linesUncheckedUpdateManyWithoutPicturesNestedInputSchema: z.ZodType = z.object({ + create: z.union([ z.lazy(() => Picture_linesCreateWithoutPicturesInputSchema),z.lazy(() => Picture_linesCreateWithoutPicturesInputSchema).array(),z.lazy(() => Picture_linesUncheckedCreateWithoutPicturesInputSchema),z.lazy(() => Picture_linesUncheckedCreateWithoutPicturesInputSchema).array() ]).optional(), + connectOrCreate: z.union([ z.lazy(() => Picture_linesCreateOrConnectWithoutPicturesInputSchema),z.lazy(() => Picture_linesCreateOrConnectWithoutPicturesInputSchema).array() ]).optional(), + upsert: z.union([ z.lazy(() => Picture_linesUpsertWithWhereUniqueWithoutPicturesInputSchema),z.lazy(() => Picture_linesUpsertWithWhereUniqueWithoutPicturesInputSchema).array() ]).optional(), + createMany: z.lazy(() => Picture_linesCreateManyPicturesInputEnvelopeSchema).optional(), + set: z.union([ z.lazy(() => Picture_linesWhereUniqueInputSchema),z.lazy(() => Picture_linesWhereUniqueInputSchema).array() ]).optional(), + disconnect: z.union([ z.lazy(() => Picture_linesWhereUniqueInputSchema),z.lazy(() => Picture_linesWhereUniqueInputSchema).array() ]).optional(), + delete: z.union([ z.lazy(() => Picture_linesWhereUniqueInputSchema),z.lazy(() => Picture_linesWhereUniqueInputSchema).array() ]).optional(), + connect: z.union([ z.lazy(() => Picture_linesWhereUniqueInputSchema),z.lazy(() => Picture_linesWhereUniqueInputSchema).array() ]).optional(), + update: z.union([ z.lazy(() => Picture_linesUpdateWithWhereUniqueWithoutPicturesInputSchema),z.lazy(() => Picture_linesUpdateWithWhereUniqueWithoutPicturesInputSchema).array() ]).optional(), + updateMany: z.union([ z.lazy(() => Picture_linesUpdateManyWithWhereWithoutPicturesInputSchema),z.lazy(() => Picture_linesUpdateManyWithWhereWithoutPicturesInputSchema).array() ]).optional(), + deleteMany: z.union([ z.lazy(() => Picture_linesScalarWhereInputSchema),z.lazy(() => Picture_linesScalarWhereInputSchema).array() ]).optional(), +}).strict(); + export const PicturesCreateNestedManyWithoutReportInputSchema: z.ZodType = z.object({ create: z.union([ z.lazy(() => PicturesCreateWithoutReportInputSchema),z.lazy(() => PicturesCreateWithoutReportInputSchema).array(),z.lazy(() => PicturesUncheckedCreateWithoutReportInputSchema),z.lazy(() => PicturesUncheckedCreateWithoutReportInputSchema).array() ]).optional(), connectOrCreate: z.union([ z.lazy(() => PicturesCreateOrConnectWithoutReportInputSchema),z.lazy(() => PicturesCreateOrConnectWithoutReportInputSchema).array() ]).optional(), @@ -2968,6 +3206,66 @@ export const UserUncheckedUpdateWithoutDelegation_delegation_delegatedToTouserIn report: z.lazy(() => ReportUncheckedUpdateManyWithoutUserNestedInputSchema).optional() }).strict(); +export const PicturesCreateWithoutPicture_linesInputSchema: z.ZodType = z.object({ + id: z.string(), + url: z.string().optional().nullable(), + createdAt: z.coerce.date().optional().nullable(), + report: z.lazy(() => ReportCreateNestedOneWithoutPicturesInputSchema).optional() +}).strict(); + +export const PicturesUncheckedCreateWithoutPicture_linesInputSchema: z.ZodType = z.object({ + id: z.string(), + reportId: z.string().optional().nullable(), + url: z.string().optional().nullable(), + createdAt: z.coerce.date().optional().nullable() +}).strict(); + +export const PicturesCreateOrConnectWithoutPicture_linesInputSchema: z.ZodType = z.object({ + where: z.lazy(() => PicturesWhereUniqueInputSchema), + create: z.union([ z.lazy(() => PicturesCreateWithoutPicture_linesInputSchema),z.lazy(() => PicturesUncheckedCreateWithoutPicture_linesInputSchema) ]), +}).strict(); + +export const PicturesUpsertWithoutPicture_linesInputSchema: z.ZodType = z.object({ + update: z.union([ z.lazy(() => PicturesUpdateWithoutPicture_linesInputSchema),z.lazy(() => PicturesUncheckedUpdateWithoutPicture_linesInputSchema) ]), + create: z.union([ z.lazy(() => PicturesCreateWithoutPicture_linesInputSchema),z.lazy(() => PicturesUncheckedCreateWithoutPicture_linesInputSchema) ]), +}).strict(); + +export const PicturesUpdateWithoutPicture_linesInputSchema: z.ZodType = z.object({ + id: z.union([ z.string(),z.lazy(() => StringFieldUpdateOperationsInputSchema) ]).optional(), + url: z.union([ z.string(),z.lazy(() => NullableStringFieldUpdateOperationsInputSchema) ]).optional().nullable(), + createdAt: z.union([ z.coerce.date(),z.lazy(() => NullableDateTimeFieldUpdateOperationsInputSchema) ]).optional().nullable(), + report: z.lazy(() => ReportUpdateOneWithoutPicturesNestedInputSchema).optional() +}).strict(); + +export const PicturesUncheckedUpdateWithoutPicture_linesInputSchema: z.ZodType = z.object({ + id: z.union([ z.string(),z.lazy(() => StringFieldUpdateOperationsInputSchema) ]).optional(), + reportId: z.union([ z.string(),z.lazy(() => NullableStringFieldUpdateOperationsInputSchema) ]).optional().nullable(), + url: z.union([ z.string(),z.lazy(() => NullableStringFieldUpdateOperationsInputSchema) ]).optional().nullable(), + createdAt: z.union([ z.coerce.date(),z.lazy(() => NullableDateTimeFieldUpdateOperationsInputSchema) ]).optional().nullable(), +}).strict(); + +export const Picture_linesCreateWithoutPicturesInputSchema: z.ZodType = z.object({ + id: z.string(), + lines: z.string(), + createdAt: z.coerce.date().optional().nullable() +}).strict(); + +export const Picture_linesUncheckedCreateWithoutPicturesInputSchema: z.ZodType = z.object({ + id: z.string(), + lines: z.string(), + createdAt: z.coerce.date().optional().nullable() +}).strict(); + +export const Picture_linesCreateOrConnectWithoutPicturesInputSchema: z.ZodType = z.object({ + where: z.lazy(() => Picture_linesWhereUniqueInputSchema), + create: z.union([ z.lazy(() => Picture_linesCreateWithoutPicturesInputSchema),z.lazy(() => Picture_linesUncheckedCreateWithoutPicturesInputSchema) ]), +}).strict(); + +export const Picture_linesCreateManyPicturesInputEnvelopeSchema: z.ZodType = z.object({ + data: z.lazy(() => Picture_linesCreateManyPicturesInputSchema).array(), + skipDuplicates: z.boolean().optional() +}).strict(); + export const ReportCreateWithoutPicturesInputSchema: z.ZodType = z.object({ id: z.string(), title: z.string().optional().nullable(), @@ -3027,6 +3325,32 @@ export const ReportCreateOrConnectWithoutPicturesInputSchema: z.ZodType ReportCreateWithoutPicturesInputSchema),z.lazy(() => ReportUncheckedCreateWithoutPicturesInputSchema) ]), }).strict(); +export const Picture_linesUpsertWithWhereUniqueWithoutPicturesInputSchema: z.ZodType = z.object({ + where: z.lazy(() => Picture_linesWhereUniqueInputSchema), + update: z.union([ z.lazy(() => Picture_linesUpdateWithoutPicturesInputSchema),z.lazy(() => Picture_linesUncheckedUpdateWithoutPicturesInputSchema) ]), + create: z.union([ z.lazy(() => Picture_linesCreateWithoutPicturesInputSchema),z.lazy(() => Picture_linesUncheckedCreateWithoutPicturesInputSchema) ]), +}).strict(); + +export const Picture_linesUpdateWithWhereUniqueWithoutPicturesInputSchema: z.ZodType = z.object({ + where: z.lazy(() => Picture_linesWhereUniqueInputSchema), + data: z.union([ z.lazy(() => Picture_linesUpdateWithoutPicturesInputSchema),z.lazy(() => Picture_linesUncheckedUpdateWithoutPicturesInputSchema) ]), +}).strict(); + +export const Picture_linesUpdateManyWithWhereWithoutPicturesInputSchema: z.ZodType = z.object({ + where: z.lazy(() => Picture_linesScalarWhereInputSchema), + data: z.union([ z.lazy(() => Picture_linesUpdateManyMutationInputSchema),z.lazy(() => Picture_linesUncheckedUpdateManyWithoutPicture_linesInputSchema) ]), +}).strict(); + +export const Picture_linesScalarWhereInputSchema: z.ZodType = z.object({ + AND: z.union([ z.lazy(() => Picture_linesScalarWhereInputSchema),z.lazy(() => Picture_linesScalarWhereInputSchema).array() ]).optional(), + OR: z.lazy(() => Picture_linesScalarWhereInputSchema).array().optional(), + NOT: z.union([ z.lazy(() => Picture_linesScalarWhereInputSchema),z.lazy(() => Picture_linesScalarWhereInputSchema).array() ]).optional(), + id: z.union([ z.lazy(() => StringFilterSchema),z.string() ]).optional(), + pictureId: z.union([ z.lazy(() => StringNullableFilterSchema),z.string() ]).optional().nullable(), + lines: z.union([ z.lazy(() => StringFilterSchema),z.string() ]).optional(), + createdAt: z.union([ z.lazy(() => DateTimeNullableFilterSchema),z.coerce.date() ]).optional().nullable(), +}).strict(); + export const ReportUpsertWithoutPicturesInputSchema: z.ZodType = z.object({ update: z.union([ z.lazy(() => ReportUpdateWithoutPicturesInputSchema),z.lazy(() => ReportUncheckedUpdateWithoutPicturesInputSchema) ]), create: z.union([ z.lazy(() => ReportCreateWithoutPicturesInputSchema),z.lazy(() => ReportUncheckedCreateWithoutPicturesInputSchema) ]), @@ -3089,13 +3413,15 @@ export const ReportUncheckedUpdateWithoutPicturesInputSchema: z.ZodType = z.object({ id: z.string(), url: z.string().optional().nullable(), - createdAt: z.coerce.date().optional().nullable() + createdAt: z.coerce.date().optional().nullable(), + picture_lines: z.lazy(() => Picture_linesCreateNestedManyWithoutPicturesInputSchema).optional() }).strict(); export const PicturesUncheckedCreateWithoutReportInputSchema: z.ZodType = z.object({ id: z.string(), url: z.string().optional().nullable(), - createdAt: z.coerce.date().optional().nullable() + createdAt: z.coerce.date().optional().nullable(), + picture_lines: z.lazy(() => Picture_linesUncheckedCreateNestedManyWithoutPicturesInputSchema).optional() }).strict(); export const PicturesCreateOrConnectWithoutReportInputSchema: z.ZodType = z.object({ @@ -3649,6 +3975,30 @@ export const UdapUncheckedUpdateWithoutUserInputSchema: z.ZodType NullableStringFieldUpdateOperationsInputSchema) ]).optional().nullable(), }).strict(); +export const Picture_linesCreateManyPicturesInputSchema: z.ZodType = z.object({ + id: z.string(), + lines: z.string(), + createdAt: z.coerce.date().optional().nullable() +}).strict(); + +export const Picture_linesUpdateWithoutPicturesInputSchema: z.ZodType = z.object({ + id: z.union([ z.string(),z.lazy(() => StringFieldUpdateOperationsInputSchema) ]).optional(), + lines: z.union([ z.string(),z.lazy(() => StringFieldUpdateOperationsInputSchema) ]).optional(), + createdAt: z.union([ z.coerce.date(),z.lazy(() => NullableDateTimeFieldUpdateOperationsInputSchema) ]).optional().nullable(), +}).strict(); + +export const Picture_linesUncheckedUpdateWithoutPicturesInputSchema: z.ZodType = z.object({ + id: z.union([ z.string(),z.lazy(() => StringFieldUpdateOperationsInputSchema) ]).optional(), + lines: z.union([ z.string(),z.lazy(() => StringFieldUpdateOperationsInputSchema) ]).optional(), + createdAt: z.union([ z.coerce.date(),z.lazy(() => NullableDateTimeFieldUpdateOperationsInputSchema) ]).optional().nullable(), +}).strict(); + +export const Picture_linesUncheckedUpdateManyWithoutPicture_linesInputSchema: z.ZodType = z.object({ + id: z.union([ z.string(),z.lazy(() => StringFieldUpdateOperationsInputSchema) ]).optional(), + lines: z.union([ z.string(),z.lazy(() => StringFieldUpdateOperationsInputSchema) ]).optional(), + createdAt: z.union([ z.coerce.date(),z.lazy(() => NullableDateTimeFieldUpdateOperationsInputSchema) ]).optional().nullable(), +}).strict(); + export const PicturesCreateManyReportInputSchema: z.ZodType = z.object({ id: z.string(), url: z.string().optional().nullable(), @@ -3664,12 +4014,14 @@ export const PicturesUpdateWithoutReportInputSchema: z.ZodType StringFieldUpdateOperationsInputSchema) ]).optional(), url: z.union([ z.string(),z.lazy(() => NullableStringFieldUpdateOperationsInputSchema) ]).optional().nullable(), createdAt: z.union([ z.coerce.date(),z.lazy(() => NullableDateTimeFieldUpdateOperationsInputSchema) ]).optional().nullable(), + picture_lines: z.lazy(() => Picture_linesUpdateManyWithoutPicturesNestedInputSchema).optional() }).strict(); export const PicturesUncheckedUpdateWithoutReportInputSchema: z.ZodType = z.object({ id: z.union([ z.string(),z.lazy(() => StringFieldUpdateOperationsInputSchema) ]).optional(), url: z.union([ z.string(),z.lazy(() => NullableStringFieldUpdateOperationsInputSchema) ]).optional().nullable(), createdAt: z.union([ z.coerce.date(),z.lazy(() => NullableDateTimeFieldUpdateOperationsInputSchema) ]).optional().nullable(), + picture_lines: z.lazy(() => Picture_linesUncheckedUpdateManyWithoutPicturesNestedInputSchema).optional() }).strict(); export const PicturesUncheckedUpdateManyWithoutPicturesInputSchema: z.ZodType = z.object({ @@ -4092,6 +4444,68 @@ export const Pdf_snapshotFindUniqueOrThrowArgsSchema: z.ZodType = z.object({ + select: Picture_linesSelectSchema.optional(), + include: Picture_linesIncludeSchema.optional(), + where: Picture_linesWhereInputSchema.optional(), + orderBy: z.union([ Picture_linesOrderByWithRelationInputSchema.array(),Picture_linesOrderByWithRelationInputSchema ]).optional(), + cursor: Picture_linesWhereUniqueInputSchema.optional(), + take: z.number().optional(), + skip: z.number().optional(), + distinct: Picture_linesScalarFieldEnumSchema.array().optional(), +}).strict() as z.ZodType + +export const Picture_linesFindFirstOrThrowArgsSchema: z.ZodType = z.object({ + select: Picture_linesSelectSchema.optional(), + include: Picture_linesIncludeSchema.optional(), + where: Picture_linesWhereInputSchema.optional(), + orderBy: z.union([ Picture_linesOrderByWithRelationInputSchema.array(),Picture_linesOrderByWithRelationInputSchema ]).optional(), + cursor: Picture_linesWhereUniqueInputSchema.optional(), + take: z.number().optional(), + skip: z.number().optional(), + distinct: Picture_linesScalarFieldEnumSchema.array().optional(), +}).strict() as z.ZodType + +export const Picture_linesFindManyArgsSchema: z.ZodType = z.object({ + select: Picture_linesSelectSchema.optional(), + include: Picture_linesIncludeSchema.optional(), + where: Picture_linesWhereInputSchema.optional(), + orderBy: z.union([ Picture_linesOrderByWithRelationInputSchema.array(),Picture_linesOrderByWithRelationInputSchema ]).optional(), + cursor: Picture_linesWhereUniqueInputSchema.optional(), + take: z.number().optional(), + skip: z.number().optional(), + distinct: Picture_linesScalarFieldEnumSchema.array().optional(), +}).strict() as z.ZodType + +export const Picture_linesAggregateArgsSchema: z.ZodType = z.object({ + where: Picture_linesWhereInputSchema.optional(), + orderBy: z.union([ Picture_linesOrderByWithRelationInputSchema.array(),Picture_linesOrderByWithRelationInputSchema ]).optional(), + cursor: Picture_linesWhereUniqueInputSchema.optional(), + take: z.number().optional(), + skip: z.number().optional(), +}).strict() as z.ZodType + +export const Picture_linesGroupByArgsSchema: z.ZodType = z.object({ + where: Picture_linesWhereInputSchema.optional(), + orderBy: z.union([ Picture_linesOrderByWithAggregationInputSchema.array(),Picture_linesOrderByWithAggregationInputSchema ]).optional(), + by: Picture_linesScalarFieldEnumSchema.array(), + having: Picture_linesScalarWhereWithAggregatesInputSchema.optional(), + take: z.number().optional(), + skip: z.number().optional(), +}).strict() as z.ZodType + +export const Picture_linesFindUniqueArgsSchema: z.ZodType = z.object({ + select: Picture_linesSelectSchema.optional(), + include: Picture_linesIncludeSchema.optional(), + where: Picture_linesWhereUniqueInputSchema, +}).strict() as z.ZodType + +export const Picture_linesFindUniqueOrThrowArgsSchema: z.ZodType = z.object({ + select: Picture_linesSelectSchema.optional(), + include: Picture_linesIncludeSchema.optional(), + where: Picture_linesWhereUniqueInputSchema, +}).strict() as z.ZodType + export const PicturesFindFirstArgsSchema: z.ZodType = z.object({ select: PicturesSelectSchema.optional(), include: PicturesIncludeSchema.optional(), @@ -4611,6 +5025,47 @@ export const Pdf_snapshotDeleteManyArgsSchema: z.ZodType = z.object({ + select: Picture_linesSelectSchema.optional(), + include: Picture_linesIncludeSchema.optional(), + data: z.union([ Picture_linesCreateInputSchema,Picture_linesUncheckedCreateInputSchema ]), +}).strict() as z.ZodType + +export const Picture_linesUpsertArgsSchema: z.ZodType = z.object({ + select: Picture_linesSelectSchema.optional(), + include: Picture_linesIncludeSchema.optional(), + where: Picture_linesWhereUniqueInputSchema, + create: z.union([ Picture_linesCreateInputSchema,Picture_linesUncheckedCreateInputSchema ]), + update: z.union([ Picture_linesUpdateInputSchema,Picture_linesUncheckedUpdateInputSchema ]), +}).strict() as z.ZodType + +export const Picture_linesCreateManyArgsSchema: z.ZodType = z.object({ + data: Picture_linesCreateManyInputSchema.array(), + skipDuplicates: z.boolean().optional(), +}).strict() as z.ZodType + +export const Picture_linesDeleteArgsSchema: z.ZodType = z.object({ + select: Picture_linesSelectSchema.optional(), + include: Picture_linesIncludeSchema.optional(), + where: Picture_linesWhereUniqueInputSchema, +}).strict() as z.ZodType + +export const Picture_linesUpdateArgsSchema: z.ZodType = z.object({ + select: Picture_linesSelectSchema.optional(), + include: Picture_linesIncludeSchema.optional(), + data: z.union([ Picture_linesUpdateInputSchema,Picture_linesUncheckedUpdateInputSchema ]), + where: Picture_linesWhereUniqueInputSchema, +}).strict() as z.ZodType + +export const Picture_linesUpdateManyArgsSchema: z.ZodType = z.object({ + data: z.union([ Picture_linesUpdateManyMutationInputSchema,Picture_linesUncheckedUpdateManyInputSchema ]), + where: Picture_linesWhereInputSchema.optional(), +}).strict() as z.ZodType + +export const Picture_linesDeleteManyArgsSchema: z.ZodType = z.object({ + where: Picture_linesWhereInputSchema.optional(), +}).strict() as z.ZodType + export const PicturesCreateArgsSchema: z.ZodType = z.object({ select: PicturesSelectSchema.optional(), include: PicturesIncludeSchema.optional(), @@ -4873,6 +5328,11 @@ interface Pdf_snapshotGetPayload extends HKT { readonly type: Omit, "Please either choose `select` or `include`"> } +interface Picture_linesGetPayload extends HKT { + readonly _A?: boolean | null | undefined | Prisma.Picture_linesArgs + readonly type: Omit, "Please either choose `select` or `include`"> +} + interface PicturesGetPayload extends HKT { readonly _A?: boolean | null | undefined | Prisma.PicturesArgs readonly type: Omit, "Please either choose `select` or `include`"> @@ -5094,6 +5554,52 @@ export const tableSchemas = { Prisma.Pdf_snapshotScalarFieldEnum, Pdf_snapshotGetPayload >, + picture_lines: { + fields: new Map([ + [ + "id", + "TEXT" + ], + [ + "pictureId", + "TEXT" + ], + [ + "lines", + "TEXT" + ], + [ + "createdAt", + "TIMESTAMP" + ] + ]), + relations: [ + new Relation("pictures", "pictureId", "id", "pictures", "Picture_linesToPictures", "one"), + ], + modelSchema: (Picture_linesCreateInputSchema as any) + .partial() + .or((Picture_linesUncheckedCreateInputSchema as any).partial()), + createSchema: Picture_linesCreateArgsSchema, + createManySchema: Picture_linesCreateManyArgsSchema, + findUniqueSchema: Picture_linesFindUniqueArgsSchema, + findSchema: Picture_linesFindFirstArgsSchema, + updateSchema: Picture_linesUpdateArgsSchema, + updateManySchema: Picture_linesUpdateManyArgsSchema, + upsertSchema: Picture_linesUpsertArgsSchema, + deleteSchema: Picture_linesDeleteArgsSchema, + deleteManySchema: Picture_linesDeleteManyArgsSchema + } as TableSchema< + z.infer, + Prisma.Picture_linesCreateArgs['data'], + Prisma.Picture_linesUpdateArgs['data'], + Prisma.Picture_linesFindFirstArgs['select'], + Prisma.Picture_linesFindFirstArgs['where'], + Prisma.Picture_linesFindUniqueArgs['where'], + Omit, + Prisma.Picture_linesFindFirstArgs['orderBy'], + Prisma.Picture_linesScalarFieldEnum, + Picture_linesGetPayload + >, pictures: { fields: new Map([ [ @@ -5114,6 +5620,7 @@ export const tableSchemas = { ] ]), relations: [ + new Relation("picture_lines", "", "", "picture_lines", "Picture_linesToPictures", "many"), new Relation("report", "reportId", "id", "report", "PicturesToReport", "one"), ], modelSchema: (PicturesCreateInputSchema as any) diff --git a/packages/electric-client/src/generated/client/migrations.ts b/packages/electric-client/src/generated/client/migrations.ts index 045b2dd..a76a889 100644 --- a/packages/electric-client/src/generated/client/migrations.ts +++ b/packages/electric-client/src/generated/client/migrations.ts @@ -253,5 +253,24 @@ export default [ "CREATE TRIGGER compensation_update_main_tmp_pictures_reportId_into_oplog\n AFTER UPDATE ON \"main\".\"tmp_pictures\"\n WHEN 1 = (SELECT flag from _electric_trigger_settings WHERE namespace = 'main' AND tablename = 'tmp_pictures') AND\n 1 = (SELECT value from _electric_meta WHERE key = 'compensations')\nBEGIN\n INSERT INTO _electric_oplog (namespace, tablename, optype, primaryKey, newRow, oldRow, timestamp)\n SELECT 'main', 'report', 'COMPENSATION', json_patch('{}', json_object('id', \"id\")), json_object('id', \"id\"), NULL, NULL\n FROM \"main\".\"report\" WHERE \"id\" = new.\"reportId\";\nEND;" ], "version": "908" + }, + { + "statements": [ + "CREATE TABLE \"picture_lines\" (\n \"id\" TEXT NOT NULL,\n \"pictureId\" TEXT,\n \"lines\" TEXT NOT NULL,\n \"createdAt\" TEXT,\n CONSTRAINT \"picture_lines_pictureId_fkey\" FOREIGN KEY (\"pictureId\") REFERENCES \"pictures\" (\"id\") ON DELETE CASCADE,\n CONSTRAINT \"picture_lines_pkey\" PRIMARY KEY (\"id\")\n) WITHOUT ROWID;\n", + "INSERT OR IGNORE INTO _electric_trigger_settings (namespace, tablename, flag) VALUES ('main', 'picture_lines', 1);", + "DROP TRIGGER IF EXISTS update_ensure_main_picture_lines_primarykey;", + "CREATE TRIGGER update_ensure_main_picture_lines_primarykey\n BEFORE UPDATE ON \"main\".\"picture_lines\"\nBEGIN\n SELECT\n CASE\n WHEN old.\"id\" != new.\"id\" THEN\n \t\tRAISE (ABORT, 'cannot change the value of column id as it belongs to the primary key')\n END;\nEND;", + "DROP TRIGGER IF EXISTS insert_main_picture_lines_into_oplog;", + "CREATE TRIGGER insert_main_picture_lines_into_oplog\n AFTER INSERT ON \"main\".\"picture_lines\"\n WHEN 1 = (SELECT flag from _electric_trigger_settings WHERE namespace = 'main' AND tablename = 'picture_lines')\nBEGIN\n INSERT INTO _electric_oplog (namespace, tablename, optype, primaryKey, newRow, oldRow, timestamp)\n VALUES ('main', 'picture_lines', 'INSERT', json_patch('{}', json_object('id', new.\"id\")), json_object('createdAt', new.\"createdAt\", 'id', new.\"id\", 'lines', new.\"lines\", 'pictureId', new.\"pictureId\"), NULL, NULL);\nEND;", + "DROP TRIGGER IF EXISTS update_main_picture_lines_into_oplog;", + "CREATE TRIGGER update_main_picture_lines_into_oplog\n AFTER UPDATE ON \"main\".\"picture_lines\"\n WHEN 1 = (SELECT flag from _electric_trigger_settings WHERE namespace = 'main' AND tablename = 'picture_lines')\nBEGIN\n INSERT INTO _electric_oplog (namespace, tablename, optype, primaryKey, newRow, oldRow, timestamp)\n VALUES ('main', 'picture_lines', 'UPDATE', json_patch('{}', json_object('id', new.\"id\")), json_object('createdAt', new.\"createdAt\", 'id', new.\"id\", 'lines', new.\"lines\", 'pictureId', new.\"pictureId\"), json_object('createdAt', old.\"createdAt\", 'id', old.\"id\", 'lines', old.\"lines\", 'pictureId', old.\"pictureId\"), NULL);\nEND;", + "DROP TRIGGER IF EXISTS delete_main_picture_lines_into_oplog;", + "CREATE TRIGGER delete_main_picture_lines_into_oplog\n AFTER DELETE ON \"main\".\"picture_lines\"\n WHEN 1 = (SELECT flag from _electric_trigger_settings WHERE namespace = 'main' AND tablename = 'picture_lines')\nBEGIN\n INSERT INTO _electric_oplog (namespace, tablename, optype, primaryKey, newRow, oldRow, timestamp)\n VALUES ('main', 'picture_lines', 'DELETE', json_patch('{}', json_object('id', old.\"id\")), NULL, json_object('createdAt', old.\"createdAt\", 'id', old.\"id\", 'lines', old.\"lines\", 'pictureId', old.\"pictureId\"), NULL);\nEND;", + "DROP TRIGGER IF EXISTS compensation_insert_main_picture_lines_pictureId_into_oplog;", + "CREATE TRIGGER compensation_insert_main_picture_lines_pictureId_into_oplog\n AFTER INSERT ON \"main\".\"picture_lines\"\n WHEN 1 = (SELECT flag from _electric_trigger_settings WHERE namespace = 'main' AND tablename = 'picture_lines') AND\n 1 = (SELECT value from _electric_meta WHERE key = 'compensations')\nBEGIN\n INSERT INTO _electric_oplog (namespace, tablename, optype, primaryKey, newRow, oldRow, timestamp)\n SELECT 'main', 'pictures', 'COMPENSATION', json_patch('{}', json_object('id', \"id\")), json_object('id', \"id\"), NULL, NULL\n FROM \"main\".\"pictures\" WHERE \"id\" = new.\"pictureId\";\nEND;", + "DROP TRIGGER IF EXISTS compensation_update_main_picture_lines_pictureId_into_oplog;", + "CREATE TRIGGER compensation_update_main_picture_lines_pictureId_into_oplog\n AFTER UPDATE ON \"main\".\"picture_lines\"\n WHEN 1 = (SELECT flag from _electric_trigger_settings WHERE namespace = 'main' AND tablename = 'picture_lines') AND\n 1 = (SELECT value from _electric_meta WHERE key = 'compensations')\nBEGIN\n INSERT INTO _electric_oplog (namespace, tablename, optype, primaryKey, newRow, oldRow, timestamp)\n SELECT 'main', 'pictures', 'COMPENSATION', json_patch('{}', json_object('id', \"id\")), json_object('id', \"id\"), NULL, NULL\n FROM \"main\".\"pictures\" WHERE \"id\" = new.\"pictureId\";\nEND;" + ], + "version": "909" } ] \ No newline at end of file diff --git a/packages/electric-client/src/generated/client/pg-migrations.ts b/packages/electric-client/src/generated/client/pg-migrations.ts index e1f5c86..8116b66 100644 --- a/packages/electric-client/src/generated/client/pg-migrations.ts +++ b/packages/electric-client/src/generated/client/pg-migrations.ts @@ -333,5 +333,30 @@ export default [ "CREATE TRIGGER compensation_update_public_tmp_pictures_reportId_into_oplog\n AFTER UPDATE ON \"public\".\"tmp_pictures\"\n FOR EACH ROW\n EXECUTE FUNCTION compensation_update_public_tmp_pictures_reportId_into_oplog_function();" ], "version": "908" + }, + { + "statements": [ + "CREATE TABLE picture_lines (\n id text NOT NULL,\n \"pictureId\" text,\n lines text NOT NULL,\n \"createdAt\" timestamp without time zone,\n CONSTRAINT picture_lines_pkey PRIMARY KEY (id),\n CONSTRAINT \"picture_lines_pictureId_fkey\" FOREIGN KEY (\"pictureId\") REFERENCES pictures(id) ON DELETE CASCADE\n)", + "INSERT INTO \"public\".\"_electric_trigger_settings\" (\"namespace\", \"tablename\", \"flag\")\n VALUES ('public', 'picture_lines', 1)\n ON CONFLICT DO NOTHING;", + "DROP TRIGGER IF EXISTS update_ensure_public_picture_lines_primarykey ON \"public\".\"picture_lines\";", + "CREATE OR REPLACE FUNCTION update_ensure_public_picture_lines_primarykey_function()\nRETURNS TRIGGER AS $$\nBEGIN\n IF OLD.\"id\" IS DISTINCT FROM NEW.\"id\" THEN\n RAISE EXCEPTION 'Cannot change the value of column id as it belongs to the primary key';\n END IF;\n RETURN NEW;\nEND;\n$$ LANGUAGE plpgsql;", + "CREATE TRIGGER update_ensure_public_picture_lines_primarykey\n BEFORE UPDATE ON \"public\".\"picture_lines\"\n FOR EACH ROW\n EXECUTE FUNCTION update_ensure_public_picture_lines_primarykey_function();", + "DROP TRIGGER IF EXISTS insert_public_picture_lines_into_oplog ON \"public\".\"picture_lines\";", + " CREATE OR REPLACE FUNCTION insert_public_picture_lines_into_oplog_function()\n RETURNS TRIGGER AS $$\n BEGIN\n DECLARE\n flag_value INTEGER;\n BEGIN\n -- Get the flag value from _electric_trigger_settings\n SELECT flag INTO flag_value FROM \"public\"._electric_trigger_settings WHERE namespace = 'public' AND tablename = 'picture_lines';\n\n IF flag_value = 1 THEN\n -- Insert into _electric_oplog\n INSERT INTO \"public\"._electric_oplog (namespace, tablename, optype, \"primaryKey\", \"newRow\", \"oldRow\", timestamp)\n VALUES (\n 'public',\n 'picture_lines',\n 'INSERT',\n json_strip_nulls(json_build_object('id', new.\"id\")),\n jsonb_build_object('createdAt', new.\"createdAt\", 'id', new.\"id\", 'lines', new.\"lines\", 'pictureId', new.\"pictureId\"),\n NULL,\n NULL\n );\n END IF;\n\n RETURN NEW;\n END;\n END;\n $$ LANGUAGE plpgsql;", + "CREATE TRIGGER insert_public_picture_lines_into_oplog\n AFTER INSERT ON \"public\".\"picture_lines\"\n FOR EACH ROW\n EXECUTE FUNCTION insert_public_picture_lines_into_oplog_function();", + "DROP TRIGGER IF EXISTS update_public_picture_lines_into_oplog ON \"public\".\"picture_lines\";", + " CREATE OR REPLACE FUNCTION update_public_picture_lines_into_oplog_function()\n RETURNS TRIGGER AS $$\n BEGIN\n DECLARE\n flag_value INTEGER;\n BEGIN\n -- Get the flag value from _electric_trigger_settings\n SELECT flag INTO flag_value FROM \"public\"._electric_trigger_settings WHERE namespace = 'public' AND tablename = 'picture_lines';\n\n IF flag_value = 1 THEN\n -- Insert into _electric_oplog\n INSERT INTO \"public\"._electric_oplog (namespace, tablename, optype, \"primaryKey\", \"newRow\", \"oldRow\", timestamp)\n VALUES (\n 'public',\n 'picture_lines',\n 'UPDATE',\n json_strip_nulls(json_build_object('id', new.\"id\")),\n jsonb_build_object('createdAt', new.\"createdAt\", 'id', new.\"id\", 'lines', new.\"lines\", 'pictureId', new.\"pictureId\"),\n jsonb_build_object('createdAt', old.\"createdAt\", 'id', old.\"id\", 'lines', old.\"lines\", 'pictureId', old.\"pictureId\"),\n NULL\n );\n END IF;\n\n RETURN NEW;\n END;\n END;\n $$ LANGUAGE plpgsql;", + "CREATE TRIGGER update_public_picture_lines_into_oplog\n AFTER UPDATE ON \"public\".\"picture_lines\"\n FOR EACH ROW\n EXECUTE FUNCTION update_public_picture_lines_into_oplog_function();", + "DROP TRIGGER IF EXISTS delete_public_picture_lines_into_oplog ON \"public\".\"picture_lines\";", + " CREATE OR REPLACE FUNCTION delete_public_picture_lines_into_oplog_function()\n RETURNS TRIGGER AS $$\n BEGIN\n DECLARE\n flag_value INTEGER;\n BEGIN\n -- Get the flag value from _electric_trigger_settings\n SELECT flag INTO flag_value FROM \"public\"._electric_trigger_settings WHERE namespace = 'public' AND tablename = 'picture_lines';\n\n IF flag_value = 1 THEN\n -- Insert into _electric_oplog\n INSERT INTO \"public\"._electric_oplog (namespace, tablename, optype, \"primaryKey\", \"newRow\", \"oldRow\", timestamp)\n VALUES (\n 'public',\n 'picture_lines',\n 'DELETE',\n json_strip_nulls(json_build_object('id', old.\"id\")),\n NULL,\n jsonb_build_object('createdAt', old.\"createdAt\", 'id', old.\"id\", 'lines', old.\"lines\", 'pictureId', old.\"pictureId\"),\n NULL\n );\n END IF;\n\n RETURN NEW;\n END;\n END;\n $$ LANGUAGE plpgsql;", + "CREATE TRIGGER delete_public_picture_lines_into_oplog\n AFTER DELETE ON \"public\".\"picture_lines\"\n FOR EACH ROW\n EXECUTE FUNCTION delete_public_picture_lines_into_oplog_function();", + "DROP TRIGGER IF EXISTS compensation_insert_public_picture_lines_pictureId_into_oplog ON \"public\".\"picture_lines\";", + " CREATE OR REPLACE FUNCTION compensation_insert_public_picture_lines_pictureId_into_oplog_function()\n RETURNS TRIGGER AS $$\n BEGIN\n DECLARE\n flag_value INTEGER;\n meta_value INTEGER;\n BEGIN\n SELECT flag INTO flag_value FROM \"public\"._electric_trigger_settings WHERE namespace = 'public' AND tablename = 'picture_lines';\n\n SELECT value INTO meta_value FROM \"public\"._electric_meta WHERE key = 'compensations';\n\n IF flag_value = 1 AND meta_value = 1 THEN\n INSERT INTO \"public\"._electric_oplog (namespace, tablename, optype, \"primaryKey\", \"newRow\", \"oldRow\", timestamp)\n SELECT\n 'public',\n 'pictures',\n 'COMPENSATION',\n json_strip_nulls(json_strip_nulls(json_build_object('id', \"id\"))),\n jsonb_build_object('id', \"id\"),\n NULL,\n NULL\n FROM \"public\".\"pictures\"\n WHERE \"id\" = NEW.\"pictureId\";\n END IF;\n\n RETURN NEW;\n END;\n END;\n $$ LANGUAGE plpgsql;", + "CREATE TRIGGER compensation_insert_public_picture_lines_pictureId_into_oplog\n AFTER INSERT ON \"public\".\"picture_lines\"\n FOR EACH ROW\n EXECUTE FUNCTION compensation_insert_public_picture_lines_pictureId_into_oplog_function();", + "DROP TRIGGER IF EXISTS compensation_update_public_picture_lines_pictureId_into_oplog ON \"public\".\"picture_lines\";", + " CREATE OR REPLACE FUNCTION compensation_update_public_picture_lines_pictureId_into_oplog_function()\n RETURNS TRIGGER AS $$\n BEGIN\n DECLARE\n flag_value INTEGER;\n meta_value INTEGER;\n BEGIN\n SELECT flag INTO flag_value FROM \"public\"._electric_trigger_settings WHERE namespace = 'public' AND tablename = 'picture_lines';\n\n SELECT value INTO meta_value FROM \"public\"._electric_meta WHERE key = 'compensations';\n\n IF flag_value = 1 AND meta_value = 1 THEN\n INSERT INTO \"public\"._electric_oplog (namespace, tablename, optype, \"primaryKey\", \"newRow\", \"oldRow\", timestamp)\n SELECT\n 'public',\n 'pictures',\n 'COMPENSATION',\n json_strip_nulls(json_strip_nulls(json_build_object('id', \"id\"))),\n jsonb_build_object('id', \"id\"),\n NULL,\n NULL\n FROM \"public\".\"pictures\"\n WHERE \"id\" = NEW.\"pictureId\";\n END IF;\n\n RETURN NEW;\n END;\n END;\n $$ LANGUAGE plpgsql;", + "CREATE TRIGGER compensation_update_public_picture_lines_pictureId_into_oplog\n AFTER UPDATE ON \"public\".\"picture_lines\"\n FOR EACH ROW\n EXECUTE FUNCTION compensation_update_public_picture_lines_pictureId_into_oplog_function();" + ], + "version": "909" } ] \ No newline at end of file diff --git a/packages/electric-client/src/generated/client/prismaClient.d.ts b/packages/electric-client/src/generated/client/prismaClient.d.ts index 3de8f63..108406e 100644 --- a/packages/electric-client/src/generated/client/prismaClient.d.ts +++ b/packages/electric-client/src/generated/client/prismaClient.d.ts @@ -88,9 +88,29 @@ export type Pdf_snapshotPayload +export type Picture_linesPayload = { + name: "Picture_lines" + objects: { + pictures: PicturesPayload | null + } + scalars: $Extensions.GetResult<{ + id: string + pictureId: string | null + lines: string + createdAt: Date | null + }, ExtArgs["result"]["picture_lines"]> + composites: {} +} + +/** + * Model Picture_lines + * + */ +export type Picture_lines = runtime.Types.DefaultSelection export type PicturesPayload = { name: "Pictures" objects: { + picture_lines: Picture_linesPayload[] report: ReportPayload | null } scalars: $Extensions.GetResult<{ @@ -405,6 +425,16 @@ export class PrismaClient< */ get pdf_snapshot(): Prisma.Pdf_snapshotDelegate; + /** + * `prisma.picture_lines`: Exposes CRUD operations for the **Picture_lines** model. + * Example usage: + * ```ts + * // Fetch zero or more Picture_lines + * const picture_lines = await prisma.picture_lines.findMany() + * ``` + */ + get picture_lines(): Prisma.Picture_linesDelegate; + /** * `prisma.pictures`: Exposes CRUD operations for the **Pictures** model. * Example usage: @@ -951,6 +981,7 @@ export type InputJsonValue = null | string | number | boolean | InputJsonObject Clause_v2: 'Clause_v2', Delegation: 'Delegation', Pdf_snapshot: 'Pdf_snapshot', + Picture_lines: 'Picture_lines', Pictures: 'Pictures', Report: 'Report', Service_instructeurs: 'Service_instructeurs', @@ -973,7 +1004,7 @@ export type InputJsonValue = null | string | number | boolean | InputJsonObject export type TypeMap = { meta: { - modelProps: 'clause' | 'clause_v2' | 'delegation' | 'pdf_snapshot' | 'pictures' | 'report' | 'service_instructeurs' | 'tmp_pictures' | 'udap' | 'user' + modelProps: 'clause' | 'clause_v2' | 'delegation' | 'pdf_snapshot' | 'picture_lines' | 'pictures' | 'report' | 'service_instructeurs' | 'tmp_pictures' | 'udap' | 'user' txIsolationLevel: Prisma.TransactionIsolationLevel }, model: { @@ -1237,6 +1268,71 @@ export type InputJsonValue = null | string | number | boolean | InputJsonObject } } } + Picture_lines: { + payload: Picture_linesPayload + operations: { + findUnique: { + args: Prisma.Picture_linesFindUniqueArgs, + result: $Utils.PayloadToResult | null + } + findUniqueOrThrow: { + args: Prisma.Picture_linesFindUniqueOrThrowArgs, + result: $Utils.PayloadToResult + } + findFirst: { + args: Prisma.Picture_linesFindFirstArgs, + result: $Utils.PayloadToResult | null + } + findFirstOrThrow: { + args: Prisma.Picture_linesFindFirstOrThrowArgs, + result: $Utils.PayloadToResult + } + findMany: { + args: Prisma.Picture_linesFindManyArgs, + result: $Utils.PayloadToResult[] + } + create: { + args: Prisma.Picture_linesCreateArgs, + result: $Utils.PayloadToResult + } + createMany: { + args: Prisma.Picture_linesCreateManyArgs, + result: Prisma.BatchPayload + } + delete: { + args: Prisma.Picture_linesDeleteArgs, + result: $Utils.PayloadToResult + } + update: { + args: Prisma.Picture_linesUpdateArgs, + result: $Utils.PayloadToResult + } + deleteMany: { + args: Prisma.Picture_linesDeleteManyArgs, + result: Prisma.BatchPayload + } + updateMany: { + args: Prisma.Picture_linesUpdateManyArgs, + result: Prisma.BatchPayload + } + upsert: { + args: Prisma.Picture_linesUpsertArgs, + result: $Utils.PayloadToResult + } + aggregate: { + args: Prisma.Picture_linesAggregateArgs, + result: $Utils.Optional + } + groupBy: { + args: Prisma.Picture_linesGroupByArgs, + result: $Utils.Optional[] + } + count: { + args: Prisma.Picture_linesCountArgs, + result: $Utils.Optional | number + } + } + } Pictures: { payload: PicturesPayload operations: { @@ -1803,6 +1899,41 @@ export type InputJsonValue = null | string | number | boolean | InputJsonObject */ + /** + * Count Type PicturesCountOutputType + */ + + + export type PicturesCountOutputType = { + picture_lines: number + } + + export type PicturesCountOutputTypeSelect = { + picture_lines?: boolean | PicturesCountOutputTypeCountPicture_linesArgs + } + + // Custom InputTypes + + /** + * PicturesCountOutputType without action + */ + export type PicturesCountOutputTypeArgs = { + /** + * Select specific fields to fetch from the PicturesCountOutputType + */ + select?: PicturesCountOutputTypeSelect | null + } + + + /** + * PicturesCountOutputType without action + */ + export type PicturesCountOutputTypeCountPicture_linesArgs = { + where?: Picture_linesWhereInput + } + + + /** * Count Type ReportCountOutputType */ @@ -5403,119 +5534,1034 @@ export type InputJsonValue = null | string | number | boolean | InputJsonObject */ export type Pdf_snapshotCreateArgs = { /** - * Select specific fields to fetch from the Pdf_snapshot + * Select specific fields to fetch from the Pdf_snapshot + */ + select?: Pdf_snapshotSelect | null + /** + * The data needed to create a Pdf_snapshot. + */ + data: XOR + } + + + /** + * Pdf_snapshot createMany + */ + export type Pdf_snapshotCreateManyArgs = { + /** + * The data used to create many Pdf_snapshots. + */ + data: Enumerable + skipDuplicates?: boolean + } + + + /** + * Pdf_snapshot update + */ + export type Pdf_snapshotUpdateArgs = { + /** + * Select specific fields to fetch from the Pdf_snapshot + */ + select?: Pdf_snapshotSelect | null + /** + * The data needed to update a Pdf_snapshot. + */ + data: XOR + /** + * Choose, which Pdf_snapshot to update. + */ + where: Pdf_snapshotWhereUniqueInput + } + + + /** + * Pdf_snapshot updateMany + */ + export type Pdf_snapshotUpdateManyArgs = { + /** + * The data used to update Pdf_snapshots. + */ + data: XOR + /** + * Filter which Pdf_snapshots to update + */ + where?: Pdf_snapshotWhereInput + } + + + /** + * Pdf_snapshot upsert + */ + export type Pdf_snapshotUpsertArgs = { + /** + * Select specific fields to fetch from the Pdf_snapshot + */ + select?: Pdf_snapshotSelect | null + /** + * The filter to search for the Pdf_snapshot to update in case it exists. + */ + where: Pdf_snapshotWhereUniqueInput + /** + * In case the Pdf_snapshot found by the `where` argument doesn't exist, create a new Pdf_snapshot with this data. + */ + create: XOR + /** + * In case the Pdf_snapshot was found with the provided `where` argument, update it with this data. + */ + update: XOR + } + + + /** + * Pdf_snapshot delete + */ + export type Pdf_snapshotDeleteArgs = { + /** + * Select specific fields to fetch from the Pdf_snapshot + */ + select?: Pdf_snapshotSelect | null + /** + * Filter which Pdf_snapshot to delete. + */ + where: Pdf_snapshotWhereUniqueInput + } + + + /** + * Pdf_snapshot deleteMany + */ + export type Pdf_snapshotDeleteManyArgs = { + /** + * Filter which Pdf_snapshots to delete + */ + where?: Pdf_snapshotWhereInput + } + + + /** + * Pdf_snapshot without action + */ + export type Pdf_snapshotArgs = { + /** + * Select specific fields to fetch from the Pdf_snapshot + */ + select?: Pdf_snapshotSelect | null + } + + + + /** + * Model Picture_lines + */ + + + export type AggregatePicture_lines = { + _count: Picture_linesCountAggregateOutputType | null + _min: Picture_linesMinAggregateOutputType | null + _max: Picture_linesMaxAggregateOutputType | null + } + + export type Picture_linesMinAggregateOutputType = { + id: string | null + pictureId: string | null + lines: string | null + createdAt: Date | null + } + + export type Picture_linesMaxAggregateOutputType = { + id: string | null + pictureId: string | null + lines: string | null + createdAt: Date | null + } + + export type Picture_linesCountAggregateOutputType = { + id: number + pictureId: number + lines: number + createdAt: number + _all: number + } + + + export type Picture_linesMinAggregateInputType = { + id?: true + pictureId?: true + lines?: true + createdAt?: true + } + + export type Picture_linesMaxAggregateInputType = { + id?: true + pictureId?: true + lines?: true + createdAt?: true + } + + export type Picture_linesCountAggregateInputType = { + id?: true + pictureId?: true + lines?: true + createdAt?: true + _all?: true + } + + export type Picture_linesAggregateArgs = { + /** + * Filter which Picture_lines to aggregate. + */ + where?: Picture_linesWhereInput + /** + * {@link https://www.prisma.io/docs/concepts/components/prisma-client/sorting Sorting Docs} + * + * Determine the order of Picture_lines to fetch. + */ + orderBy?: Enumerable + /** + * {@link https://www.prisma.io/docs/concepts/components/prisma-client/pagination#cursor-based-pagination Cursor Docs} + * + * Sets the start position + */ + cursor?: Picture_linesWhereUniqueInput + /** + * {@link https://www.prisma.io/docs/concepts/components/prisma-client/pagination Pagination Docs} + * + * Take `±n` Picture_lines from the position of the cursor. + */ + take?: number + /** + * {@link https://www.prisma.io/docs/concepts/components/prisma-client/pagination Pagination Docs} + * + * Skip the first `n` Picture_lines. + */ + skip?: number + /** + * {@link https://www.prisma.io/docs/concepts/components/prisma-client/aggregations Aggregation Docs} + * + * Count returned Picture_lines + **/ + _count?: true | Picture_linesCountAggregateInputType + /** + * {@link https://www.prisma.io/docs/concepts/components/prisma-client/aggregations Aggregation Docs} + * + * Select which fields to find the minimum value + **/ + _min?: Picture_linesMinAggregateInputType + /** + * {@link https://www.prisma.io/docs/concepts/components/prisma-client/aggregations Aggregation Docs} + * + * Select which fields to find the maximum value + **/ + _max?: Picture_linesMaxAggregateInputType + } + + export type GetPicture_linesAggregateType = { + [P in keyof T & keyof AggregatePicture_lines]: P extends '_count' | 'count' + ? T[P] extends true + ? number + : GetScalarType + : GetScalarType + } + + + + + export type Picture_linesGroupByArgs = { + where?: Picture_linesWhereInput + orderBy?: Enumerable + by: Picture_linesScalarFieldEnum[] + having?: Picture_linesScalarWhereWithAggregatesInput + take?: number + skip?: number + _count?: Picture_linesCountAggregateInputType | true + _min?: Picture_linesMinAggregateInputType + _max?: Picture_linesMaxAggregateInputType + } + + + export type Picture_linesGroupByOutputType = { + id: string + pictureId: string | null + lines: string + createdAt: Date | null + _count: Picture_linesCountAggregateOutputType | null + _min: Picture_linesMinAggregateOutputType | null + _max: Picture_linesMaxAggregateOutputType | null + } + + type GetPicture_linesGroupByPayload = Prisma.PrismaPromise< + Array< + PickArray & + { + [P in ((keyof T) & (keyof Picture_linesGroupByOutputType))]: P extends '_count' + ? T[P] extends boolean + ? number + : GetScalarType + : GetScalarType + } + > + > + + + export type Picture_linesSelect = $Extensions.GetSelect<{ + id?: boolean + pictureId?: boolean + lines?: boolean + createdAt?: boolean + pictures?: boolean | PicturesArgs + }, ExtArgs["result"]["picture_lines"]> + + export type Picture_linesSelectScalar = { + id?: boolean + pictureId?: boolean + lines?: boolean + createdAt?: boolean + } + + export type Picture_linesInclude = { + pictures?: boolean | PicturesArgs + } + + + type Picture_linesGetPayload = $Types.GetResult + + type Picture_linesCountArgs = + Omit & { + select?: Picture_linesCountAggregateInputType | true + } + + export interface Picture_linesDelegate { + [K: symbol]: { types: Prisma.TypeMap['model']['Picture_lines'], meta: { name: 'Picture_lines' } } + /** + * Find zero or one Picture_lines that matches the filter. + * @param {Picture_linesFindUniqueArgs} args - Arguments to find a Picture_lines + * @example + * // Get one Picture_lines + * const picture_lines = await prisma.picture_lines.findUnique({ + * where: { + * // ... provide filter here + * } + * }) + **/ + findUnique, LocalRejectSettings = T["rejectOnNotFound"] extends RejectOnNotFound ? T['rejectOnNotFound'] : undefined>( + args: SelectSubset> + ): HasReject extends True ? Prisma__Picture_linesClient<$Types.GetResult, T, 'findUnique', never>, never, ExtArgs> : Prisma__Picture_linesClient<$Types.GetResult, T, 'findUnique', never> | null, null, ExtArgs> + + /** + * Find one Picture_lines that matches the filter or throw an error with `error.code='P2025'` + * if no matches were found. + * @param {Picture_linesFindUniqueOrThrowArgs} args - Arguments to find a Picture_lines + * @example + * // Get one Picture_lines + * const picture_lines = await prisma.picture_lines.findUniqueOrThrow({ + * where: { + * // ... provide filter here + * } + * }) + **/ + findUniqueOrThrow>( + args?: SelectSubset> + ): Prisma__Picture_linesClient<$Types.GetResult, T, 'findUniqueOrThrow', never>, never, ExtArgs> + + /** + * Find the first Picture_lines that matches the filter. + * Note, that providing `undefined` is treated as the value not being there. + * Read more here: https://pris.ly/d/null-undefined + * @param {Picture_linesFindFirstArgs} args - Arguments to find a Picture_lines + * @example + * // Get one Picture_lines + * const picture_lines = await prisma.picture_lines.findFirst({ + * where: { + * // ... provide filter here + * } + * }) + **/ + findFirst, LocalRejectSettings = T["rejectOnNotFound"] extends RejectOnNotFound ? T['rejectOnNotFound'] : undefined>( + args?: SelectSubset> + ): HasReject extends True ? Prisma__Picture_linesClient<$Types.GetResult, T, 'findFirst', never>, never, ExtArgs> : Prisma__Picture_linesClient<$Types.GetResult, T, 'findFirst', never> | null, null, ExtArgs> + + /** + * Find the first Picture_lines that matches the filter or + * throw `NotFoundError` if no matches were found. + * Note, that providing `undefined` is treated as the value not being there. + * Read more here: https://pris.ly/d/null-undefined + * @param {Picture_linesFindFirstOrThrowArgs} args - Arguments to find a Picture_lines + * @example + * // Get one Picture_lines + * const picture_lines = await prisma.picture_lines.findFirstOrThrow({ + * where: { + * // ... provide filter here + * } + * }) + **/ + findFirstOrThrow>( + args?: SelectSubset> + ): Prisma__Picture_linesClient<$Types.GetResult, T, 'findFirstOrThrow', never>, never, ExtArgs> + + /** + * Find zero or more Picture_lines that matches the filter. + * Note, that providing `undefined` is treated as the value not being there. + * Read more here: https://pris.ly/d/null-undefined + * @param {Picture_linesFindManyArgs=} args - Arguments to filter and select certain fields only. + * @example + * // Get all Picture_lines + * const picture_lines = await prisma.picture_lines.findMany() + * + * // Get first 10 Picture_lines + * const picture_lines = await prisma.picture_lines.findMany({ take: 10 }) + * + * // Only select the `id` + * const picture_linesWithIdOnly = await prisma.picture_lines.findMany({ select: { id: true } }) + * + **/ + findMany>( + args?: SelectSubset> + ): Prisma.PrismaPromise<$Types.GetResult, T, 'findMany', never>> + + /** + * Create a Picture_lines. + * @param {Picture_linesCreateArgs} args - Arguments to create a Picture_lines. + * @example + * // Create one Picture_lines + * const Picture_lines = await prisma.picture_lines.create({ + * data: { + * // ... data to create a Picture_lines + * } + * }) + * + **/ + create>( + args: SelectSubset> + ): Prisma__Picture_linesClient<$Types.GetResult, T, 'create', never>, never, ExtArgs> + + /** + * Create many Picture_lines. + * @param {Picture_linesCreateManyArgs} args - Arguments to create many Picture_lines. + * @example + * // Create many Picture_lines + * const picture_lines = await prisma.picture_lines.createMany({ + * data: { + * // ... provide data here + * } + * }) + * + **/ + createMany>( + args?: SelectSubset> + ): Prisma.PrismaPromise + + /** + * Delete a Picture_lines. + * @param {Picture_linesDeleteArgs} args - Arguments to delete one Picture_lines. + * @example + * // Delete one Picture_lines + * const Picture_lines = await prisma.picture_lines.delete({ + * where: { + * // ... filter to delete one Picture_lines + * } + * }) + * + **/ + delete>( + args: SelectSubset> + ): Prisma__Picture_linesClient<$Types.GetResult, T, 'delete', never>, never, ExtArgs> + + /** + * Update one Picture_lines. + * @param {Picture_linesUpdateArgs} args - Arguments to update one Picture_lines. + * @example + * // Update one Picture_lines + * const picture_lines = await prisma.picture_lines.update({ + * where: { + * // ... provide filter here + * }, + * data: { + * // ... provide data here + * } + * }) + * + **/ + update>( + args: SelectSubset> + ): Prisma__Picture_linesClient<$Types.GetResult, T, 'update', never>, never, ExtArgs> + + /** + * Delete zero or more Picture_lines. + * @param {Picture_linesDeleteManyArgs} args - Arguments to filter Picture_lines to delete. + * @example + * // Delete a few Picture_lines + * const { count } = await prisma.picture_lines.deleteMany({ + * where: { + * // ... provide filter here + * } + * }) + * + **/ + deleteMany>( + args?: SelectSubset> + ): Prisma.PrismaPromise + + /** + * Update zero or more Picture_lines. + * Note, that providing `undefined` is treated as the value not being there. + * Read more here: https://pris.ly/d/null-undefined + * @param {Picture_linesUpdateManyArgs} args - Arguments to update one or more rows. + * @example + * // Update many Picture_lines + * const picture_lines = await prisma.picture_lines.updateMany({ + * where: { + * // ... provide filter here + * }, + * data: { + * // ... provide data here + * } + * }) + * + **/ + updateMany>( + args: SelectSubset> + ): Prisma.PrismaPromise + + /** + * Create or update one Picture_lines. + * @param {Picture_linesUpsertArgs} args - Arguments to update or create a Picture_lines. + * @example + * // Update or create a Picture_lines + * const picture_lines = await prisma.picture_lines.upsert({ + * create: { + * // ... data to create a Picture_lines + * }, + * update: { + * // ... in case it already exists, update + * }, + * where: { + * // ... the filter for the Picture_lines we want to update + * } + * }) + **/ + upsert>( + args: SelectSubset> + ): Prisma__Picture_linesClient<$Types.GetResult, T, 'upsert', never>, never, ExtArgs> + + /** + * Count the number of Picture_lines. + * Note, that providing `undefined` is treated as the value not being there. + * Read more here: https://pris.ly/d/null-undefined + * @param {Picture_linesCountArgs} args - Arguments to filter Picture_lines to count. + * @example + * // Count the number of Picture_lines + * const count = await prisma.picture_lines.count({ + * where: { + * // ... the filter for the Picture_lines we want to count + * } + * }) + **/ + count( + args?: Subset, + ): Prisma.PrismaPromise< + T extends $Utils.Record<'select', any> + ? T['select'] extends true + ? number + : GetScalarType + : number + > + + /** + * Allows you to perform aggregations operations on a Picture_lines. + * Note, that providing `undefined` is treated as the value not being there. + * Read more here: https://pris.ly/d/null-undefined + * @param {Picture_linesAggregateArgs} args - Select which aggregations you would like to apply and on what fields. + * @example + * // Ordered by age ascending + * // Where email contains prisma.io + * // Limited to the 10 users + * const aggregations = await prisma.user.aggregate({ + * _avg: { + * age: true, + * }, + * where: { + * email: { + * contains: "prisma.io", + * }, + * }, + * orderBy: { + * age: "asc", + * }, + * take: 10, + * }) + **/ + aggregate(args: Subset): Prisma.PrismaPromise> + + /** + * Group by Picture_lines. + * Note, that providing `undefined` is treated as the value not being there. + * Read more here: https://pris.ly/d/null-undefined + * @param {Picture_linesGroupByArgs} args - Group by arguments. + * @example + * // Group by city, order by createdAt, get count + * const result = await prisma.user.groupBy({ + * by: ['city', 'createdAt'], + * orderBy: { + * createdAt: true + * }, + * _count: { + * _all: true + * }, + * }) + * + **/ + groupBy< + T extends Picture_linesGroupByArgs, + HasSelectOrTake extends Or< + Extends<'skip', Keys>, + Extends<'take', Keys> + >, + OrderByArg extends True extends HasSelectOrTake + ? { orderBy: Picture_linesGroupByArgs['orderBy'] } + : { orderBy?: Picture_linesGroupByArgs['orderBy'] }, + OrderFields extends ExcludeUnderscoreKeys>>, + ByFields extends TupleToUnion, + ByValid extends Has, + HavingFields extends GetHavingFields, + HavingValid extends Has, + ByEmpty extends T['by'] extends never[] ? True : False, + InputErrors extends ByEmpty extends True + ? `Error: "by" must not be empty.` + : HavingValid extends False + ? { + [P in HavingFields]: P extends ByFields + ? never + : P extends string + ? `Error: Field "${P}" used in "having" needs to be provided in "by".` + : [ + Error, + 'Field ', + P, + ` in "having" needs to be provided in "by"`, + ] + }[HavingFields] + : 'take' extends Keys + ? 'orderBy' extends Keys + ? ByValid extends True + ? {} + : { + [P in OrderFields]: P extends ByFields + ? never + : `Error: Field "${P}" in "orderBy" needs to be provided in "by"` + }[OrderFields] + : 'Error: If you provide "take", you also need to provide "orderBy"' + : 'skip' extends Keys + ? 'orderBy' extends Keys + ? ByValid extends True + ? {} + : { + [P in OrderFields]: P extends ByFields + ? never + : `Error: Field "${P}" in "orderBy" needs to be provided in "by"` + }[OrderFields] + : 'Error: If you provide "skip", you also need to provide "orderBy"' + : ByValid extends True + ? {} + : { + [P in OrderFields]: P extends ByFields + ? never + : `Error: Field "${P}" in "orderBy" needs to be provided in "by"` + }[OrderFields] + >(args: SubsetIntersection & InputErrors): {} extends InputErrors ? GetPicture_linesGroupByPayload : Prisma.PrismaPromise + + } + + /** + * The delegate class that acts as a "Promise-like" for Picture_lines. + * Why is this prefixed with `Prisma__`? + * Because we want to prevent naming conflicts as mentioned in + * https://github.com/prisma/prisma-client-js/issues/707 + */ + export class Prisma__Picture_linesClient implements Prisma.PrismaPromise { + private readonly _dmmf; + private readonly _queryType; + private readonly _rootField; + private readonly _clientMethod; + private readonly _args; + private readonly _dataPath; + private readonly _errorFormat; + private readonly _measurePerformance?; + private _isList; + private _callsite; + private _requestPromise?; + readonly [Symbol.toStringTag]: 'PrismaPromise'; + constructor(_dmmf: runtime.DMMFClass, _queryType: 'query' | 'mutation', _rootField: string, _clientMethod: string, _args: any, _dataPath: string[], _errorFormat: ErrorFormat, _measurePerformance?: boolean | undefined, _isList?: boolean); + + pictures = {}>(args?: Subset>): Prisma__PicturesClient<$Types.GetResult, T, 'findUnique', never> | Null, never, ExtArgs>; + + private get _document(); + /** + * Attaches callbacks for the resolution and/or rejection of the Promise. + * @param onfulfilled The callback to execute when the Promise is resolved. + * @param onrejected The callback to execute when the Promise is rejected. + * @returns A Promise for the completion of which ever callback is executed. + */ + then(onfulfilled?: ((value: T) => TResult1 | PromiseLike) | undefined | null, onrejected?: ((reason: any) => TResult2 | PromiseLike) | undefined | null): Promise; + /** + * Attaches a callback for only the rejection of the Promise. + * @param onrejected The callback to execute when the Promise is rejected. + * @returns A Promise for the completion of the callback. + */ + catch(onrejected?: ((reason: any) => TResult | PromiseLike) | undefined | null): Promise; + /** + * Attaches a callback that is invoked when the Promise is settled (fulfilled or rejected). The + * resolved value cannot be modified from the callback. + * @param onfinally The callback to execute when the Promise is settled (fulfilled or rejected). + * @returns A Promise for the completion of the callback. + */ + finally(onfinally?: (() => void) | undefined | null): Promise; + } + + + + // Custom InputTypes + + /** + * Picture_lines base type for findUnique actions + */ + export type Picture_linesFindUniqueArgsBase = { + /** + * Select specific fields to fetch from the Picture_lines + */ + select?: Picture_linesSelect | null + /** + * Choose, which related nodes to fetch as well. + */ + include?: Picture_linesInclude | null + /** + * Filter, which Picture_lines to fetch. + */ + where: Picture_linesWhereUniqueInput + } + + /** + * Picture_lines findUnique + */ + export interface Picture_linesFindUniqueArgs extends Picture_linesFindUniqueArgsBase { + /** + * Throw an Error if query returns no results + * @deprecated since 4.0.0: use `findUniqueOrThrow` method instead + */ + rejectOnNotFound?: RejectOnNotFound + } + + + /** + * Picture_lines findUniqueOrThrow + */ + export type Picture_linesFindUniqueOrThrowArgs = { + /** + * Select specific fields to fetch from the Picture_lines + */ + select?: Picture_linesSelect | null + /** + * Choose, which related nodes to fetch as well. + */ + include?: Picture_linesInclude | null + /** + * Filter, which Picture_lines to fetch. + */ + where: Picture_linesWhereUniqueInput + } + + + /** + * Picture_lines base type for findFirst actions + */ + export type Picture_linesFindFirstArgsBase = { + /** + * Select specific fields to fetch from the Picture_lines + */ + select?: Picture_linesSelect | null + /** + * Choose, which related nodes to fetch as well. + */ + include?: Picture_linesInclude | null + /** + * Filter, which Picture_lines to fetch. + */ + where?: Picture_linesWhereInput + /** + * {@link https://www.prisma.io/docs/concepts/components/prisma-client/sorting Sorting Docs} + * + * Determine the order of Picture_lines to fetch. + */ + orderBy?: Enumerable + /** + * {@link https://www.prisma.io/docs/concepts/components/prisma-client/pagination#cursor-based-pagination Cursor Docs} + * + * Sets the position for searching for Picture_lines. + */ + cursor?: Picture_linesWhereUniqueInput + /** + * {@link https://www.prisma.io/docs/concepts/components/prisma-client/pagination Pagination Docs} + * + * Take `±n` Picture_lines from the position of the cursor. + */ + take?: number + /** + * {@link https://www.prisma.io/docs/concepts/components/prisma-client/pagination Pagination Docs} + * + * Skip the first `n` Picture_lines. + */ + skip?: number + /** + * {@link https://www.prisma.io/docs/concepts/components/prisma-client/distinct Distinct Docs} + * + * Filter by unique combinations of Picture_lines. + */ + distinct?: Enumerable + } + + /** + * Picture_lines findFirst + */ + export interface Picture_linesFindFirstArgs extends Picture_linesFindFirstArgsBase { + /** + * Throw an Error if query returns no results + * @deprecated since 4.0.0: use `findFirstOrThrow` method instead + */ + rejectOnNotFound?: RejectOnNotFound + } + + + /** + * Picture_lines findFirstOrThrow + */ + export type Picture_linesFindFirstOrThrowArgs = { + /** + * Select specific fields to fetch from the Picture_lines + */ + select?: Picture_linesSelect | null + /** + * Choose, which related nodes to fetch as well. + */ + include?: Picture_linesInclude | null + /** + * Filter, which Picture_lines to fetch. + */ + where?: Picture_linesWhereInput + /** + * {@link https://www.prisma.io/docs/concepts/components/prisma-client/sorting Sorting Docs} + * + * Determine the order of Picture_lines to fetch. + */ + orderBy?: Enumerable + /** + * {@link https://www.prisma.io/docs/concepts/components/prisma-client/pagination#cursor-based-pagination Cursor Docs} + * + * Sets the position for searching for Picture_lines. + */ + cursor?: Picture_linesWhereUniqueInput + /** + * {@link https://www.prisma.io/docs/concepts/components/prisma-client/pagination Pagination Docs} + * + * Take `±n` Picture_lines from the position of the cursor. + */ + take?: number + /** + * {@link https://www.prisma.io/docs/concepts/components/prisma-client/pagination Pagination Docs} + * + * Skip the first `n` Picture_lines. + */ + skip?: number + /** + * {@link https://www.prisma.io/docs/concepts/components/prisma-client/distinct Distinct Docs} + * + * Filter by unique combinations of Picture_lines. + */ + distinct?: Enumerable + } + + + /** + * Picture_lines findMany + */ + export type Picture_linesFindManyArgs = { + /** + * Select specific fields to fetch from the Picture_lines + */ + select?: Picture_linesSelect | null + /** + * Choose, which related nodes to fetch as well. + */ + include?: Picture_linesInclude | null + /** + * Filter, which Picture_lines to fetch. + */ + where?: Picture_linesWhereInput + /** + * {@link https://www.prisma.io/docs/concepts/components/prisma-client/sorting Sorting Docs} + * + * Determine the order of Picture_lines to fetch. + */ + orderBy?: Enumerable + /** + * {@link https://www.prisma.io/docs/concepts/components/prisma-client/pagination#cursor-based-pagination Cursor Docs} + * + * Sets the position for listing Picture_lines. + */ + cursor?: Picture_linesWhereUniqueInput + /** + * {@link https://www.prisma.io/docs/concepts/components/prisma-client/pagination Pagination Docs} + * + * Take `±n` Picture_lines from the position of the cursor. + */ + take?: number + /** + * {@link https://www.prisma.io/docs/concepts/components/prisma-client/pagination Pagination Docs} + * + * Skip the first `n` Picture_lines. + */ + skip?: number + distinct?: Enumerable + } + + + /** + * Picture_lines create + */ + export type Picture_linesCreateArgs = { + /** + * Select specific fields to fetch from the Picture_lines */ - select?: Pdf_snapshotSelect | null + select?: Picture_linesSelect | null /** - * The data needed to create a Pdf_snapshot. + * Choose, which related nodes to fetch as well. */ - data: XOR + include?: Picture_linesInclude | null + /** + * The data needed to create a Picture_lines. + */ + data: XOR } /** - * Pdf_snapshot createMany + * Picture_lines createMany */ - export type Pdf_snapshotCreateManyArgs = { + export type Picture_linesCreateManyArgs = { /** - * The data used to create many Pdf_snapshots. + * The data used to create many Picture_lines. */ - data: Enumerable + data: Enumerable skipDuplicates?: boolean } /** - * Pdf_snapshot update + * Picture_lines update */ - export type Pdf_snapshotUpdateArgs = { + export type Picture_linesUpdateArgs = { /** - * Select specific fields to fetch from the Pdf_snapshot + * Select specific fields to fetch from the Picture_lines */ - select?: Pdf_snapshotSelect | null + select?: Picture_linesSelect | null /** - * The data needed to update a Pdf_snapshot. + * Choose, which related nodes to fetch as well. */ - data: XOR + include?: Picture_linesInclude | null /** - * Choose, which Pdf_snapshot to update. + * The data needed to update a Picture_lines. */ - where: Pdf_snapshotWhereUniqueInput + data: XOR + /** + * Choose, which Picture_lines to update. + */ + where: Picture_linesWhereUniqueInput } /** - * Pdf_snapshot updateMany + * Picture_lines updateMany */ - export type Pdf_snapshotUpdateManyArgs = { + export type Picture_linesUpdateManyArgs = { /** - * The data used to update Pdf_snapshots. + * The data used to update Picture_lines. */ - data: XOR + data: XOR /** - * Filter which Pdf_snapshots to update + * Filter which Picture_lines to update */ - where?: Pdf_snapshotWhereInput + where?: Picture_linesWhereInput } /** - * Pdf_snapshot upsert + * Picture_lines upsert */ - export type Pdf_snapshotUpsertArgs = { + export type Picture_linesUpsertArgs = { /** - * Select specific fields to fetch from the Pdf_snapshot + * Select specific fields to fetch from the Picture_lines */ - select?: Pdf_snapshotSelect | null + select?: Picture_linesSelect | null /** - * The filter to search for the Pdf_snapshot to update in case it exists. + * Choose, which related nodes to fetch as well. */ - where: Pdf_snapshotWhereUniqueInput + include?: Picture_linesInclude | null /** - * In case the Pdf_snapshot found by the `where` argument doesn't exist, create a new Pdf_snapshot with this data. + * The filter to search for the Picture_lines to update in case it exists. */ - create: XOR + where: Picture_linesWhereUniqueInput /** - * In case the Pdf_snapshot was found with the provided `where` argument, update it with this data. + * In case the Picture_lines found by the `where` argument doesn't exist, create a new Picture_lines with this data. */ - update: XOR + create: XOR + /** + * In case the Picture_lines was found with the provided `where` argument, update it with this data. + */ + update: XOR } /** - * Pdf_snapshot delete + * Picture_lines delete */ - export type Pdf_snapshotDeleteArgs = { + export type Picture_linesDeleteArgs = { /** - * Select specific fields to fetch from the Pdf_snapshot + * Select specific fields to fetch from the Picture_lines */ - select?: Pdf_snapshotSelect | null + select?: Picture_linesSelect | null /** - * Filter which Pdf_snapshot to delete. + * Choose, which related nodes to fetch as well. */ - where: Pdf_snapshotWhereUniqueInput + include?: Picture_linesInclude | null + /** + * Filter which Picture_lines to delete. + */ + where: Picture_linesWhereUniqueInput } /** - * Pdf_snapshot deleteMany + * Picture_lines deleteMany */ - export type Pdf_snapshotDeleteManyArgs = { + export type Picture_linesDeleteManyArgs = { /** - * Filter which Pdf_snapshots to delete + * Filter which Picture_lines to delete */ - where?: Pdf_snapshotWhereInput + where?: Picture_linesWhereInput } /** - * Pdf_snapshot without action + * Picture_lines without action */ - export type Pdf_snapshotArgs = { + export type Picture_linesArgs = { /** - * Select specific fields to fetch from the Pdf_snapshot + * Select specific fields to fetch from the Picture_lines */ - select?: Pdf_snapshotSelect | null + select?: Picture_linesSelect | null + /** + * Choose, which related nodes to fetch as well. + */ + include?: Picture_linesInclude | null } @@ -5678,7 +6724,9 @@ export type InputJsonValue = null | string | number | boolean | InputJsonObject reportId?: boolean url?: boolean createdAt?: boolean + picture_lines?: boolean | Pictures$picture_linesArgs report?: boolean | ReportArgs + _count?: boolean | PicturesCountOutputTypeArgs }, ExtArgs["result"]["pictures"]> export type PicturesSelectScalar = { @@ -5689,7 +6737,9 @@ export type InputJsonValue = null | string | number | boolean | InputJsonObject } export type PicturesInclude = { + picture_lines?: boolean | Pictures$picture_linesArgs report?: boolean | ReportArgs + _count?: boolean | PicturesCountOutputTypeArgs } @@ -6062,6 +7112,8 @@ export type InputJsonValue = null | string | number | boolean | InputJsonObject readonly [Symbol.toStringTag]: 'PrismaPromise'; constructor(_dmmf: runtime.DMMFClass, _queryType: 'query' | 'mutation', _rootField: string, _clientMethod: string, _args: any, _dataPath: string[], _errorFormat: ErrorFormat, _measurePerformance?: boolean | undefined, _isList?: boolean); + picture_lines = {}>(args?: Subset>): Prisma.PrismaPromise<$Types.GetResult, T, 'findMany', never>| Null>; + report = {}>(args?: Subset>): Prisma__ReportClient<$Types.GetResult, T, 'findUnique', never> | Null, never, ExtArgs>; private get _document(); @@ -6419,6 +7471,27 @@ export type InputJsonValue = null | string | number | boolean | InputJsonObject } + /** + * Pictures.picture_lines + */ + export type Pictures$picture_linesArgs = { + /** + * Select specific fields to fetch from the Picture_lines + */ + select?: Picture_linesSelect | null + /** + * Choose, which related nodes to fetch as well. + */ + include?: Picture_linesInclude | null + where?: Picture_linesWhereInput + orderBy?: Enumerable + cursor?: Picture_linesWhereUniqueInput + take?: number + skip?: number + distinct?: Enumerable + } + + /** * Pictures without action */ @@ -11492,6 +12565,16 @@ export type InputJsonValue = null | string | number | boolean | InputJsonObject export type Pdf_snapshotScalarFieldEnum = (typeof Pdf_snapshotScalarFieldEnum)[keyof typeof Pdf_snapshotScalarFieldEnum] + export const Picture_linesScalarFieldEnum: { + id: 'id', + pictureId: 'pictureId', + lines: 'lines', + createdAt: 'createdAt' + }; + + export type Picture_linesScalarFieldEnum = (typeof Picture_linesScalarFieldEnum)[keyof typeof Picture_linesScalarFieldEnum] + + export const PicturesScalarFieldEnum: { id: 'id', reportId: 'reportId', @@ -11787,6 +12870,49 @@ export type InputJsonValue = null | string | number | boolean | InputJsonObject user_id?: StringNullableWithAggregatesFilter | string | null } + export type Picture_linesWhereInput = { + AND?: Enumerable + OR?: Enumerable + NOT?: Enumerable + id?: StringFilter | string + pictureId?: StringNullableFilter | string | null + lines?: StringFilter | string + createdAt?: DateTimeNullableFilter | Date | string | null + pictures?: XOR | null + } + + export type Picture_linesOrderByWithRelationInput = { + id?: SortOrder + pictureId?: SortOrderInput | SortOrder + lines?: SortOrder + createdAt?: SortOrderInput | SortOrder + pictures?: PicturesOrderByWithRelationInput + } + + export type Picture_linesWhereUniqueInput = { + id?: string + } + + export type Picture_linesOrderByWithAggregationInput = { + id?: SortOrder + pictureId?: SortOrderInput | SortOrder + lines?: SortOrder + createdAt?: SortOrderInput | SortOrder + _count?: Picture_linesCountOrderByAggregateInput + _max?: Picture_linesMaxOrderByAggregateInput + _min?: Picture_linesMinOrderByAggregateInput + } + + export type Picture_linesScalarWhereWithAggregatesInput = { + AND?: Enumerable + OR?: Enumerable + NOT?: Enumerable + id?: StringWithAggregatesFilter | string + pictureId?: StringNullableWithAggregatesFilter | string | null + lines?: StringWithAggregatesFilter | string + createdAt?: DateTimeNullableWithAggregatesFilter | Date | string | null + } + export type PicturesWhereInput = { AND?: Enumerable OR?: Enumerable @@ -11795,6 +12921,7 @@ export type InputJsonValue = null | string | number | boolean | InputJsonObject reportId?: StringNullableFilter | string | null url?: StringNullableFilter | string | null createdAt?: DateTimeNullableFilter | Date | string | null + picture_lines?: Picture_linesListRelationFilter report?: XOR | null } @@ -11803,6 +12930,7 @@ export type InputJsonValue = null | string | number | boolean | InputJsonObject reportId?: SortOrderInput | SortOrder url?: SortOrderInput | SortOrder createdAt?: SortOrderInput | SortOrder + picture_lines?: Picture_linesOrderByRelationAggregateInput report?: ReportOrderByWithRelationInput } @@ -12378,10 +13506,59 @@ export type InputJsonValue = null | string | number | boolean | InputJsonObject user_id?: NullableStringFieldUpdateOperationsInput | string | null } + export type Picture_linesCreateInput = { + id: string + lines: string + createdAt?: Date | string | null + pictures?: PicturesCreateNestedOneWithoutPicture_linesInput + } + + export type Picture_linesUncheckedCreateInput = { + id: string + pictureId?: string | null + lines: string + createdAt?: Date | string | null + } + + export type Picture_linesUpdateInput = { + id?: StringFieldUpdateOperationsInput | string + lines?: StringFieldUpdateOperationsInput | string + createdAt?: NullableDateTimeFieldUpdateOperationsInput | Date | string | null + pictures?: PicturesUpdateOneWithoutPicture_linesNestedInput + } + + export type Picture_linesUncheckedUpdateInput = { + id?: StringFieldUpdateOperationsInput | string + pictureId?: NullableStringFieldUpdateOperationsInput | string | null + lines?: StringFieldUpdateOperationsInput | string + createdAt?: NullableDateTimeFieldUpdateOperationsInput | Date | string | null + } + + export type Picture_linesCreateManyInput = { + id: string + pictureId?: string | null + lines: string + createdAt?: Date | string | null + } + + export type Picture_linesUpdateManyMutationInput = { + id?: StringFieldUpdateOperationsInput | string + lines?: StringFieldUpdateOperationsInput | string + createdAt?: NullableDateTimeFieldUpdateOperationsInput | Date | string | null + } + + export type Picture_linesUncheckedUpdateManyInput = { + id?: StringFieldUpdateOperationsInput | string + pictureId?: NullableStringFieldUpdateOperationsInput | string | null + lines?: StringFieldUpdateOperationsInput | string + createdAt?: NullableDateTimeFieldUpdateOperationsInput | Date | string | null + } + export type PicturesCreateInput = { id: string url?: string | null createdAt?: Date | string | null + picture_lines?: Picture_linesCreateNestedManyWithoutPicturesInput report?: ReportCreateNestedOneWithoutPicturesInput } @@ -12390,12 +13567,14 @@ export type InputJsonValue = null | string | number | boolean | InputJsonObject reportId?: string | null url?: string | null createdAt?: Date | string | null + picture_lines?: Picture_linesUncheckedCreateNestedManyWithoutPicturesInput } export type PicturesUpdateInput = { id?: StringFieldUpdateOperationsInput | string url?: NullableStringFieldUpdateOperationsInput | string | null createdAt?: NullableDateTimeFieldUpdateOperationsInput | Date | string | null + picture_lines?: Picture_linesUpdateManyWithoutPicturesNestedInput report?: ReportUpdateOneWithoutPicturesNestedInput } @@ -12404,6 +13583,7 @@ export type InputJsonValue = null | string | number | boolean | InputJsonObject reportId?: NullableStringFieldUpdateOperationsInput | string | null url?: NullableStringFieldUpdateOperationsInput | string | null createdAt?: NullableDateTimeFieldUpdateOperationsInput | Date | string | null + picture_lines?: Picture_linesUncheckedUpdateManyWithoutPicturesNestedInput } export type PicturesCreateManyInput = { @@ -13124,29 +14304,29 @@ export type InputJsonValue = null | string | number | boolean | InputJsonObject not?: NestedDateTimeNullableFilter | Date | string | null } - export type ReportRelationFilter = { - is?: ReportWhereInput | null - isNot?: ReportWhereInput | null + export type PicturesRelationFilter = { + is?: PicturesWhereInput | null + isNot?: PicturesWhereInput | null } - export type PicturesCountOrderByAggregateInput = { + export type Picture_linesCountOrderByAggregateInput = { id?: SortOrder - reportId?: SortOrder - url?: SortOrder + pictureId?: SortOrder + lines?: SortOrder createdAt?: SortOrder } - export type PicturesMaxOrderByAggregateInput = { + export type Picture_linesMaxOrderByAggregateInput = { id?: SortOrder - reportId?: SortOrder - url?: SortOrder + pictureId?: SortOrder + lines?: SortOrder createdAt?: SortOrder } - export type PicturesMinOrderByAggregateInput = { + export type Picture_linesMinOrderByAggregateInput = { id?: SortOrder - reportId?: SortOrder - url?: SortOrder + pictureId?: SortOrder + lines?: SortOrder createdAt?: SortOrder } @@ -13164,6 +14344,42 @@ export type InputJsonValue = null | string | number | boolean | InputJsonObject _max?: NestedDateTimeNullableFilter } + export type Picture_linesListRelationFilter = { + every?: Picture_linesWhereInput + some?: Picture_linesWhereInput + none?: Picture_linesWhereInput + } + + export type ReportRelationFilter = { + is?: ReportWhereInput | null + isNot?: ReportWhereInput | null + } + + export type Picture_linesOrderByRelationAggregateInput = { + _count?: SortOrder + } + + export type PicturesCountOrderByAggregateInput = { + id?: SortOrder + reportId?: SortOrder + url?: SortOrder + createdAt?: SortOrder + } + + export type PicturesMaxOrderByAggregateInput = { + id?: SortOrder + reportId?: SortOrder + url?: SortOrder + createdAt?: SortOrder + } + + export type PicturesMinOrderByAggregateInput = { + id?: SortOrder + reportId?: SortOrder + url?: SortOrder + createdAt?: SortOrder + } + export type DateTimeFilter = { equals?: Date | string in?: Enumerable | Enumerable | Date | string @@ -13524,14 +14740,58 @@ export type InputJsonValue = null | string | number | boolean | InputJsonObject update?: XOR } + export type PicturesCreateNestedOneWithoutPicture_linesInput = { + create?: XOR + connectOrCreate?: PicturesCreateOrConnectWithoutPicture_linesInput + connect?: PicturesWhereUniqueInput + } + + export type NullableDateTimeFieldUpdateOperationsInput = { + set?: Date | string | null + } + + export type PicturesUpdateOneWithoutPicture_linesNestedInput = { + create?: XOR + connectOrCreate?: PicturesCreateOrConnectWithoutPicture_linesInput + upsert?: PicturesUpsertWithoutPicture_linesInput + disconnect?: boolean + delete?: boolean + connect?: PicturesWhereUniqueInput + update?: XOR + } + + export type Picture_linesCreateNestedManyWithoutPicturesInput = { + create?: XOR, Enumerable> + connectOrCreate?: Enumerable + createMany?: Picture_linesCreateManyPicturesInputEnvelope + connect?: Enumerable + } + export type ReportCreateNestedOneWithoutPicturesInput = { create?: XOR connectOrCreate?: ReportCreateOrConnectWithoutPicturesInput connect?: ReportWhereUniqueInput } - export type NullableDateTimeFieldUpdateOperationsInput = { - set?: Date | string | null + export type Picture_linesUncheckedCreateNestedManyWithoutPicturesInput = { + create?: XOR, Enumerable> + connectOrCreate?: Enumerable + createMany?: Picture_linesCreateManyPicturesInputEnvelope + connect?: Enumerable + } + + export type Picture_linesUpdateManyWithoutPicturesNestedInput = { + create?: XOR, Enumerable> + connectOrCreate?: Enumerable + upsert?: Enumerable + createMany?: Picture_linesCreateManyPicturesInputEnvelope + set?: Enumerable + disconnect?: Enumerable + delete?: Enumerable + connect?: Enumerable + update?: Enumerable + updateMany?: Enumerable + deleteMany?: Enumerable } export type ReportUpdateOneWithoutPicturesNestedInput = { @@ -13544,6 +14804,20 @@ export type InputJsonValue = null | string | number | boolean | InputJsonObject update?: XOR } + export type Picture_linesUncheckedUpdateManyWithoutPicturesNestedInput = { + create?: XOR, Enumerable> + connectOrCreate?: Enumerable + upsert?: Enumerable + createMany?: Picture_linesCreateManyPicturesInputEnvelope + set?: Enumerable + disconnect?: Enumerable + delete?: Enumerable + connect?: Enumerable + update?: Enumerable + updateMany?: Enumerable + deleteMany?: Enumerable + } + export type PicturesCreateNestedManyWithoutReportInput = { create?: XOR, Enumerable> connectOrCreate?: Enumerable @@ -14137,6 +15411,66 @@ export type InputJsonValue = null | string | number | boolean | InputJsonObject report?: ReportUncheckedUpdateManyWithoutUserNestedInput } + export type PicturesCreateWithoutPicture_linesInput = { + id: string + url?: string | null + createdAt?: Date | string | null + report?: ReportCreateNestedOneWithoutPicturesInput + } + + export type PicturesUncheckedCreateWithoutPicture_linesInput = { + id: string + reportId?: string | null + url?: string | null + createdAt?: Date | string | null + } + + export type PicturesCreateOrConnectWithoutPicture_linesInput = { + where: PicturesWhereUniqueInput + create: XOR + } + + export type PicturesUpsertWithoutPicture_linesInput = { + update: XOR + create: XOR + } + + export type PicturesUpdateWithoutPicture_linesInput = { + id?: StringFieldUpdateOperationsInput | string + url?: NullableStringFieldUpdateOperationsInput | string | null + createdAt?: NullableDateTimeFieldUpdateOperationsInput | Date | string | null + report?: ReportUpdateOneWithoutPicturesNestedInput + } + + export type PicturesUncheckedUpdateWithoutPicture_linesInput = { + id?: StringFieldUpdateOperationsInput | string + reportId?: NullableStringFieldUpdateOperationsInput | string | null + url?: NullableStringFieldUpdateOperationsInput | string | null + createdAt?: NullableDateTimeFieldUpdateOperationsInput | Date | string | null + } + + export type Picture_linesCreateWithoutPicturesInput = { + id: string + lines: string + createdAt?: Date | string | null + } + + export type Picture_linesUncheckedCreateWithoutPicturesInput = { + id: string + lines: string + createdAt?: Date | string | null + } + + export type Picture_linesCreateOrConnectWithoutPicturesInput = { + where: Picture_linesWhereUniqueInput + create: XOR + } + + export type Picture_linesCreateManyPicturesInputEnvelope = { + data: Enumerable + skipDuplicates?: boolean + } + export type ReportCreateWithoutPicturesInput = { id: string title?: string | null @@ -14196,6 +15530,32 @@ export type InputJsonValue = null | string | number | boolean | InputJsonObject create: XOR } + export type Picture_linesUpsertWithWhereUniqueWithoutPicturesInput = { + where: Picture_linesWhereUniqueInput + update: XOR + create: XOR + } + + export type Picture_linesUpdateWithWhereUniqueWithoutPicturesInput = { + where: Picture_linesWhereUniqueInput + data: XOR + } + + export type Picture_linesUpdateManyWithWhereWithoutPicturesInput = { + where: Picture_linesScalarWhereInput + data: XOR + } + + export type Picture_linesScalarWhereInput = { + AND?: Enumerable + OR?: Enumerable + NOT?: Enumerable + id?: StringFilter | string + pictureId?: StringNullableFilter | string | null + lines?: StringFilter | string + createdAt?: DateTimeNullableFilter | Date | string | null + } + export type ReportUpsertWithoutPicturesInput = { update: XOR create: XOR @@ -14259,12 +15619,14 @@ export type InputJsonValue = null | string | number | boolean | InputJsonObject id: string url?: string | null createdAt?: Date | string | null + picture_lines?: Picture_linesCreateNestedManyWithoutPicturesInput } export type PicturesUncheckedCreateWithoutReportInput = { id: string url?: string | null createdAt?: Date | string | null + picture_lines?: Picture_linesUncheckedCreateNestedManyWithoutPicturesInput } export type PicturesCreateOrConnectWithoutReportInput = { @@ -14818,6 +16180,30 @@ export type InputJsonValue = null | string | number | boolean | InputJsonObject udap_text?: NullableStringFieldUpdateOperationsInput | string | null } + export type Picture_linesCreateManyPicturesInput = { + id: string + lines: string + createdAt?: Date | string | null + } + + export type Picture_linesUpdateWithoutPicturesInput = { + id?: StringFieldUpdateOperationsInput | string + lines?: StringFieldUpdateOperationsInput | string + createdAt?: NullableDateTimeFieldUpdateOperationsInput | Date | string | null + } + + export type Picture_linesUncheckedUpdateWithoutPicturesInput = { + id?: StringFieldUpdateOperationsInput | string + lines?: StringFieldUpdateOperationsInput | string + createdAt?: NullableDateTimeFieldUpdateOperationsInput | Date | string | null + } + + export type Picture_linesUncheckedUpdateManyWithoutPicture_linesInput = { + id?: StringFieldUpdateOperationsInput | string + lines?: StringFieldUpdateOperationsInput | string + createdAt?: NullableDateTimeFieldUpdateOperationsInput | Date | string | null + } + export type PicturesCreateManyReportInput = { id: string url?: string | null @@ -14833,12 +16219,14 @@ export type InputJsonValue = null | string | number | boolean | InputJsonObject id?: StringFieldUpdateOperationsInput | string url?: NullableStringFieldUpdateOperationsInput | string | null createdAt?: NullableDateTimeFieldUpdateOperationsInput | Date | string | null + picture_lines?: Picture_linesUpdateManyWithoutPicturesNestedInput } export type PicturesUncheckedUpdateWithoutReportInput = { id?: StringFieldUpdateOperationsInput | string url?: NullableStringFieldUpdateOperationsInput | string | null createdAt?: NullableDateTimeFieldUpdateOperationsInput | Date | string | null + picture_lines?: Picture_linesUncheckedUpdateManyWithoutPicturesNestedInput } export type PicturesUncheckedUpdateManyWithoutPicturesInput = { diff --git a/packages/electric-client/src/generated/typebox/index.ts b/packages/electric-client/src/generated/typebox/index.ts index 67b4d91..cf5f77a 100644 --- a/packages/electric-client/src/generated/typebox/index.ts +++ b/packages/electric-client/src/generated/typebox/index.ts @@ -1,7 +1,7 @@ export * from './atdatabases_migrations_applied'; export * from './atdatabases_migrations_appliedInput'; -export * from './atdatabases_migrations_version'; export * from './atdatabases_migrations_versionInput'; +export * from './atdatabases_migrations_version'; export * from './clause'; export * from './clauseInput'; export * from './report'; diff --git a/packages/frontend/src/features/upload/DrawingCanvas.tsx b/packages/frontend/src/features/upload/DrawingCanvas.tsx index 8c0972a..fa55eab 100644 --- a/packages/frontend/src/features/upload/DrawingCanvas.tsx +++ b/packages/frontend/src/features/upload/DrawingCanvas.tsx @@ -1,87 +1,370 @@ -import { Flex, styled } from "#styled-system/jsx"; -import { useEffect, useRef, useState } from "react"; +import { Flex, Stack, styled } from "#styled-system/jsx"; +import { fr } from "@codegouvfr/react-dsfr"; +import React, { useState, useRef, useEffect } from "react"; +import { css, cva } from "#styled-system/css"; +import Button from "@codegouvfr/react-dsfr/Button"; +import { db } from "../../db"; +import { v4 } from "uuid"; +import { Picture_lines } from "@cr-vif/electric-client/frontend"; + +type DrawEvent = React.MouseEvent | React.TouchEvent; + +export const ImageCanvas = ({ + url, + pictureId, + lines: dbLines, + containerRef, + closeModal, +}: { + lines: Array<{ points: Array<{ x: number; y: number }>; color: string }>; + url: string; + containerRef: any; + pictureId: string; + closeModal: () => void; +}) => { + const [tool, setTool] = useState("draw"); + const [lines, setLines] = useState; color: string }>>([]); + const [scale, setScale] = useState(1); + const [offset, setOffset] = useState({ x: 0, y: 0 }); + const [state, setState] = useState<"idle" | "drawing" | "hold">("idle"); + const [startPan, setStartPan] = useState<{ x: number; y: number } | null>(null); + const [activeColor, setActiveColor] = useState(colors[0]); -export const DrawingCanvas = ({ imageUrl }: { imageUrl: string }) => { const canvasRef = useRef(null); - const [color, setColor] = useState("#FF0000"); - const [lineWidth, setLineWidth] = useState(5); + const imageRef = useRef(null); + const contextRef = useRef(null); - const getCoordinates = (e: DrawEvent) => { - const canvas = canvasRef.current!; + console.log(containerRef?.current?.getBoundingClientRect()); - const rect = canvas.getBoundingClientRect(); - const scaleX = canvas.width / rect.width; - const scaleY = canvas.height / rect.height; - - if ("touches" in e) { - const touch = e.touches[0]; - return { - offsetX: (touch.clientX - rect.left) * scaleX, - offsetY: (touch.clientY - rect.top) * scaleY, - }; + const isDrawing = state === "drawing" || state === "hold"; + + useEffect(() => { + if (dbLines) { + setLines(dbLines); } + }, [dbLines]); + + const setColor = (color: string) => { + contextRef.current!.strokeStyle = color; + setActiveColor(color); + }; + + useEffect(() => { + const canvas = canvasRef.current!; + const context = canvas.getContext("2d")!; + + const boundingRect = containerRef?.current?.getBoundingClientRect(); + if (!boundingRect) return; + + const dpr = window.devicePixelRatio || 1; + canvas.width = boundingRect.width * dpr; + canvas.height = boundingRect.height * dpr; + context.scale(dpr, dpr); + context.strokeStyle = activeColor; + canvas.style.width = "100%"; + canvas.style.height = "100%"; + + contextRef.current = context; + + const image = new Image(); + image.src = url; + image.onload = () => { + imageRef.current = image; + const boundingRect = containerRef?.current?.getBoundingClientRect(); - return { - offsetX: (e.clientX - rect.left) * scaleX, - offsetY: (e.clientY - rect.top) * scaleY, + const scaleX = boundingRect.width / image.width; + const scaleY = boundingRect.height / image.height; + const initialScale = Math.min(scaleX, scaleY); + + const xOffset = (boundingRect.width - image.width * initialScale) / 2; + const yOffset = (boundingRect.height - image.height * initialScale) / 2; + + setScale(initialScale); + setOffset({ x: xOffset, y: yOffset }); + drawCanvas(); }; + }, [url]); + + const drawCanvas = () => { + const ctx = contextRef.current!; + const canvas = canvasRef.current!; + + ctx.clearRect(0, 0, canvas.width, canvas.height); + + ctx.save(); + + ctx.translate(offset.x, offset.y); + ctx.scale(scale, scale); + + const width = imageRef.current?.width || 0; + const height = imageRef.current?.height || 0; + + if (imageRef.current) { + ctx.drawImage(imageRef.current, 0, 0, width, height); + } + + lines.forEach((line) => { + ctx.beginPath(); + ctx.strokeStyle = line.color; + ctx.lineWidth = 5 / scale; + ctx.lineCap = "round"; + ctx.lineJoin = "round"; + + line.points.forEach((point, index) => { + if (index === 0) { + ctx.moveTo(point.x, point.y); + } else { + ctx.lineTo(point.x, point.y); + } + }); + ctx.stroke(); + }); + + ctx.restore(); + }; + + useEffect(() => { + drawCanvas(); + }, [scale, offset, lines]); + + const isWithinImageBounds = (x: number, y: number) => { + if (!imageRef.current) return false; + + return x >= 0 && x <= imageRef.current.width && y >= 0 && y <= imageRef.current.height; }; - const startDrawing = (e: DrawEvent) => { - const ctx = canvasRef.current!.getContext("2d")!; - const { offsetX, offsetY } = getCoordinates(e); + // const getMousePos = (e) => { + // const clientX = "clientX" in e ? e.clientX : e.touches[0].clientX; + // const clientY = "clientY" in e ? e.clientY : e.touches[0].clientY; + + // const canvas = canvasRef.current!; + // const rect = canvas.getBoundingClientRect(); + // const x = (clientX - rect.left - offset.x) / scale; + // const y = (clientY - rect.top - offset.y) / scale; + // return { x, y }; + // }; + const getMousePos = (e) => { + const canvas = canvasRef.current!; + const rect = canvas.getBoundingClientRect(); + const dpr = window.devicePixelRatio || 1; - ctx.beginPath(); - ctx.moveTo(offsetX, offsetY); + const clientX = e.touches ? e.touches[0].clientX : e.clientX; + const clientY = e.touches ? e.touches[0].clientY : e.clientY; - ctx.globalCompositeOperation = "source-over"; + const x = ((clientX - rect.left) * (canvas.width / rect.width / dpr) - offset.x) / scale; + const y = ((clientY - rect.top) * (canvas.height / rect.height / dpr) - offset.y) / scale; - ctx.strokeStyle = color; - ctx.lineWidth = lineWidth; - ctx.lineCap = "round"; + return { x, y }; }; + const handleMouseDown = (e) => { + const clientX = "clientX" in e ? e.clientX : e.touches[0].clientX; + const clientY = "clientY" in e ? e.clientY : e.touches[0].clientY; + const pos = getMousePos(e); + + if (tool === "draw") { + if (!isWithinImageBounds(pos.x, pos.y)) { + return; + } - const stopDrawing = () => { - const ctx = canvasRef.current!.getContext("2d")!; - ctx.closePath(); + setState("drawing"); + setLines([...lines, { points: [pos], color: activeColor }]); + } else if (tool === "move") { + setStartPan({ x: clientX - offset.x, y: clientY - offset.y }); + } }; - const draw = (e: DrawEvent) => { - const ctx = canvasRef.current!.getContext("2d")!; + const handleMouseMove = (e) => { + const pos = getMousePos(e); + + if (isDrawing) { + if (!isWithinImageBounds(pos.x, pos.y)) { + setState("hold"); + return; + } - const { offsetX, offsetY } = getCoordinates(e); - ctx.lineTo(offsetX, offsetY); - ctx.stroke(); + setState("drawing"); + + const lastLine = [...lines]; + lastLine[lastLine.length - 1].points.push(pos); + setLines(lastLine); + } else if (startPan) { + const clientX = "clientX" in e ? e.clientX : e.touches[0].clientX; + const clientY = "clientY" in e ? e.clientY : e.touches[0].clientY; + + setOffset({ + x: clientX - startPan.x, + y: clientY - startPan.y, + }); + } }; - const clearCanvas = () => { - const ctx = canvasRef.current!.getContext("2d")!; - const img = new Image(); - img.onload = () => { - ctx.clearRect(0, 0, canvasRef.current!.width, canvasRef.current!.height); - ctx.drawImage(img, 0, 0); - }; - img.src = imageUrl; + const handleMouseUp = () => { + setState("idle"); + setStartPan(null); }; - useEffect(() => { - clearCanvas(); - }, [imageUrl]); + const handleWheel = (e) => { + // e.preventDefault(); + // const scaleBy = 1.1; + // const newScale = e.deltaY < 0 ? scale * scaleBy : scale / scaleBy; + // // Calculate zoom point + // const pos = getMousePos(e); + // const newOffset = { + // x: offset.x - pos.x * (newScale - scale), + // y: offset.y - pos.y * (newScale - scale), + // }; + // setScale(newScale); + // setOffset(newOffset); + }; + + const handleUndo = () => { + setLines(lines.slice(0, -1)); + }; + + // const [lastDistance, setLastDistance] = useState(null); + // const getDistance = (touches) => { + // return Math.hypot(touches[0].clientX - touches[1].clientX, touches[0].clientY - touches[1].clientY); + // }; + + const handleTouchStart = (e) => { + // if (e.touches.length === 2) { + // e.preventDefault(); + // setLastDistance(getDistance(e.touches)); + // } else { + handleMouseDown(e); + // } + }; + + const handleTouchMove = (e) => { + // if (e.touches.length === 2) { + // e.preventDefault(); + + // const newDistance = getDistance(e.touches); + // if (lastDistance) { + // const delta = newDistance - lastDistance; + // const scaleChange = delta > 0 ? 1.01 : 0.99; + // setScale(scale * scaleChange); + // } + // setLastDistance(newDistance); + // } else { + handleMouseMove(e); + // } + }; + + const handleTouchEnd = (e) => { + // setLastDistance(null); + handleMouseUp(e); + }; + + const handleSave = async () => { + const existingLines = await db.picture_lines.findFirst({ where: { pictureId } }); + if (existingLines) { + await db.picture_lines.update({ + where: { id: existingLines.id }, + data: { lines: JSON.stringify(lines) }, + }); + } else { + await db.picture_lines.create({ + data: { id: v4(), pictureId, lines: JSON.stringify(lines) }, + }); + } + closeModal(); + }; return ( - - - + + {/* + onClick={() => setScale(scale * 1.1)} + + + onClick={() => setScale(scale / 1.1)} + + + onClick={handleUndo} + disabled={lines.length === 0} + +*/} + + {/* @ts-ignore */} + */} + + + + + + + + + {colors.map((color) => ( + setColor(color)} + display="flex" + justifyContent="center" + alignItems="center" + w="40px" + h="40px" + > + + + + + ))} + + + ); }; -type DrawEvent = React.MouseEvent | React.TouchEvent; +const colorButtton = cva({ + base: { + display: "flex", + justifyContent: "center", + alignItems: "center", + borderRadius: "50%", + w: "20px", + h: "20px", + }, + variants: { + active: { + true: { + w: "40px", + h: "40px", + }, + }, + }, +}); + +const colors = ["#000AFF", "#FF3F3F", "#FF8A00", "#FFD600", "#3DFF7F", "white", "black"]; diff --git a/packages/frontend/src/features/upload/UploadImage.tsx b/packages/frontend/src/features/upload/UploadImage.tsx index 8b595d6..a825897 100644 --- a/packages/frontend/src/features/upload/UploadImage.tsx +++ b/packages/frontend/src/features/upload/UploadImage.tsx @@ -14,7 +14,7 @@ import Badge from "@codegouvfr/react-dsfr/Badge"; import Button from "@codegouvfr/react-dsfr/Button"; import { css } from "#styled-system/css"; import { createModal } from "@codegouvfr/react-dsfr/Modal"; -import { DrawingCanvas } from "./DrawingCanvas"; +import { ImageCanvas } from "./DrawingCanvas"; import { api } from "../../api"; const modal = createModal({ @@ -25,7 +25,20 @@ const modal = createModal({ export const UploadImage = ({ reportId }: { reportId: string }) => { const [statusMap, setStatusMap] = useState>({}); const [selectedPicture, setSelectedPicture] = useState<{ id: string; url: string } | null>(null); + + // const linesQuery = useLiveQuery(db.picture_lines.liveMany({ where: { pictureId: selectedPicture?.id } })); + + const linesQuery = useQuery({ + queryKey: ["lines", selectedPicture?.id], + queryFn: async () => { + const pictureLines = await db.picture_lines.findFirst({ where: { pictureId: selectedPicture?.id } }); + return JSON.parse(pictureLines?.lines ?? "[]"); + }, + enabled: !!selectedPicture, + }); + const ref = useRef(null); + const containerRef = useRef(null); const uploadImageMutation = useMutation(async (file: File) => { const picId = v4(); @@ -76,9 +89,29 @@ export const UploadImage = ({ reportId }: { reportId: string }) => { return ( <> - - {selectedPicture ? : null} - + + {selectedPicture ? ( + setSelectedPicture(null)} + pictureId={selectedPicture.id} + url={selectedPicture.url} + containerRef={containerRef} + lines={linesQuery.data} + /> + ) : null} +