import { PrismaInput, PrismaInputSchema, autoManyRelation, autoProperty, autoRelation, manyReference, manyRelation, object, prismaSchemaBuilder, property, reference, relation, } from '.'; export type Scalars = { ID: { input: string; output: string }; String: { input: string; output: string }; Boolean: { input: boolean; output: boolean }; Int: { input: number; output: number }; Float: { input: number; output: number }; /** The `BigInt` scalar type represents non-fractional signed whole numeric values. */ BigInt: { input: string; output: string }; /** A date-time string at UTC, such as 2019-12-03T09:54:33Z, compliant with the date-time format. */ DateTime: { input: string; output: string }; }; export type StringInput = { set?: InputMaybe; }; export type Maybe = T | null; export type InputMaybe = Maybe; export type ConnectRelationInput = { id?: InputMaybe; }; export type EntityIdInput = { id?: Scalars['String']['input'] | null; }; export type Simple = { id: string; fname: string; fsecondeName?: string | null | undefined; }; export type Person = { id: string; name: string; addresses: Address[]; addressesIds: EntityIdInput[]; organisation: Organisation; }; export type Address = { id: string; address: string; }; export type Organisation = { id: string; description: string; person: EntityIdInput[]; personIds: EntityIdInput[]; simple: Simple; simpleId: EntityIdInput; simples: Simple[]; simplesIds: EntityIdInput[]; }; export type SimpleCreateInput = { name?: InputMaybe; }; export type SimpleUpdateInput = { name?: InputMaybe; secondName?: InputMaybe; }; export type PersonCreateInput = { addresses?: AddressCreateNestedManyWithoutPersonInput | null; name?: InputMaybe; organisation?: InputMaybe; }; export type PersonCreateNestedManyWithoutOrganisationInput = { connect?: InputMaybe>; disconnect?: InputMaybe>; }; export type PersonUpdateInput = { addresses?: InputMaybe; name?: InputMaybe; organisation?: InputMaybe; }; export type AddressCreateNestedManyWithoutPersonInput = { connect?: InputMaybe>; create?: InputMaybe>; disconnect?: InputMaybe>; update?: InputMaybe>; }; export type AddressCreateWithoutPersonInput = { address?: InputMaybe; }; export type AddressUpdateInput = { address?: InputMaybe; }; export type AddressUpdateWithWhereUniqueWithoutPersonInput = { data?: InputMaybe; where?: EntityIdInput | null; }; export type OrganisationCreateInput = { description?: InputMaybe; person?: InputMaybe; simple?: InputMaybe; simples?: InputMaybe; }; export type OrganisationCreateNestedOneWithoutPersonInput = { connect?: InputMaybe; }; export type OrganisationUpdateInput = { description?: InputMaybe; person?: InputMaybe; simple?: InputMaybe; simples?: InputMaybe; }; export type OrganisationUpdateNestedOneWithoutPersonInput = { connect?: InputMaybe; disconnect?: InputMaybe; }; export type SimpleCreateNestedOneWithoutOrganisationInput = { connect?: InputMaybe; create?: InputMaybe; }; export type SimpleCreateWithoutOrganisationInput = { name?: InputMaybe; }; export type SimpleCreateNestedManyWithoutOrganisationInput = { connect?: InputMaybe>; create?: InputMaybe>; // disconnect?: InputMaybe>; update?: InputMaybe< Array >; }; export type SimpleUpdateWithWhereUniqueWithoutOrganisationInput = { data?: InputMaybe; where?: EntityIdInput | null; }; export type SimpleUpdateNestedOneWithoutOrganisationInput = { connect?: InputMaybe; create?: InputMaybe; disconnect?: InputMaybe; update?: InputMaybe; }; export type SimpleUpdateWithoutOrganisationInput = { name?: InputMaybe; }; const simpleSchema = prismaSchemaBuilder< SimpleCreateInput, SimpleUpdateInput, Simple >({ props: { name: property((m) => m?.fname, { set: true }), // name: { // __typename: 'Property', // pick: (m) => m?.name, // } // name: property((m) => m?.fname), }, create: {}, update: { secondName: property((m) => m?.fsecondeName), }, }); export const personSchema = prismaSchemaBuilder< PersonCreateInput, PersonUpdateInput, Person >({ props: { name: property((m) => m?.name, { set: true }), addresses: manyRelation( () => addressSchema.relation(), (m) => m?.addresses, // BUG m should be typeof person[address] (m) => (m?.id ? { id: m.id || '' } : undefined), ), // addressesIds: manyReference((m) => m?.addressesIds), organisation: reference((m) => m?.organisation), // organisationId: reference( // (m) => m?.organisation && { id: m.organisation.id || '' }, // ), }, create: { // name: property((m) => m?.name), }, update: { // name: property((m) => m?.name), }, }); const addressSchema = prismaSchemaBuilder< AddressCreateWithoutPersonInput, AddressUpdateInput, Address >({ props: { address: property((m) => { return m?.address; }), // address: { // pick: (m) => m?.address, // map: (p) => { // p.value; // console.log('value', p.value); // return ''; // }, // __typename: 'Property', // }, }, create: {}, update: {}, }); // type Nullable = { // [P in keyof T]: T[P] | null; // }; // type a = { name?: string | null }; // type b = { // id?: string | null; // name?: boolean | null; // sdafs?: string | null; // }; // type c = Nullable> extends Nullable> ? true : false; export const organisationCreateMapper: PrismaInputSchema< PrismaInput, { id: string; description: string; person: { id: string; }[]; simple: { id: string; name: string; }; simpleId: { id: string; // ida?: string; }; simples: Array<{ id: string; name?: string; }>; simplesIds: Array<{ id: string; }>; } > = { mapper: object(), properties: { description: autoProperty(), person: manyReference((m) => m?.person), // personIds: manyReference((m) => m?.person), simple: autoRelation(() => simpleSchema.relation()), // simpleId: autoReference(), simples: autoManyRelation(() => simpleSchema.relation(), { foreignKey: 'id', }), }, }; export const organisationUpdateMapper: PrismaInputSchema< PrismaInput, Organisation > = { mapper: object(), properties: { description: property((m) => m?.description), person: manyReference((m) => m?.person), simple: relation( (m) => m?.simple, () => simpleSchema.relation(), ), simples: manyRelation( () => simpleSchema.relation(), (m) => m?.simples, (m) => ({ id: m?.id || '' }), ), }, };