backend/lib/seed/interfaces/components.geo.ts
2025-05-14 21:45:16 +02:00

193 lines
6.2 KiB
TypeScript

import { InputType, Int, Field, ArgsType, ObjectType, Args } from 'type-graphql';
import { Max, IsNotEmpty } from 'class-validator';
import { registerEnumType } from 'type-graphql';
import { AccountTypeEnum } from '@src/accounts/account.components';
import { TranslatableComponent } from '@src/__components/components';
import { ModelCollectionEnum } from '@src/__indexes/__collections';
import { IsRefExist } from '@seed/engine/decorators/db.guard';
import { ScheduleComponent } from './components.dates';
/*
███████╗███╗ ██╗██╗ ██╗███╗ ███╗
██╔════╝████╗ ██║██║ ██║████╗ ████║
█████╗ ██╔██╗ ██║██║ ██║██╔████╔██║
██╔══╝ ██║╚██╗██║██║ ██║██║╚██╔╝██║
███████╗██║ ╚████║╚██████╔╝██║ ╚═╝ ██║
╚══════╝╚═╝ ╚═══╝ ╚═════╝ ╚═╝ ╚═╝
*/
/*
██████╗ ██████╗ ███╗ ███╗██████╗ ██████╗ ███╗ ██╗███████╗███╗ ██╗████████╗███████╗
██╔════╝██╔═══██╗████╗ ████║██╔══██╗██╔═══██╗████╗ ██║██╔════╝████╗ ██║╚══██╔══╝██╔════╝
██║ ██║ ██║██╔████╔██║██████╔╝██║ ██║██╔██╗ ██║█████╗ ██╔██╗ ██║ ██║ ███████╗
██║ ██║ ██║██║╚██╔╝██║██╔═══╝ ██║ ██║██║╚██╗██║██╔══╝ ██║╚██╗██║ ██║ ╚════██║
╚██████╗╚██████╔╝██║ ╚═╝ ██║██║ ╚██████╔╝██║ ╚████║███████╗██║ ╚████║ ██║ ███████║
╚═════╝ ╚═════╝ ╚═╝ ╚═╝╚═╝ ╚═════╝ ╚═╝ ╚═══╝╚══════╝╚═╝ ╚═══╝ ╚═╝ ╚══════╝
*/
/*
* ADDRESS
*/
@InputType('LocComponentInput')
@ObjectType()
export class LocComponent {
@Field()
type: string;
@Field(() => [Number])
coordinates: number[];
}
@InputType('AddressInput')
@ObjectType()
export class AddressComponent {
@Field({ nullable: true })
number?: string;
@Field({ nullable: true })
street?: string;
@Field({ nullable: true })
streetBis?: string;
@Field({ nullable: true })
floor?: string;
@Field({ nullable: true })
box?: string;
@Field({ nullable: true })
zip?: string;
@Field({ nullable: true })
state?: string;
@Field()
city: string;
@Field()
country: string;
returnFullAddress() {
return `${this.number} ${this.street}, ${this.zip} ${this.city} ${this.country}`
}
}
@InputType('AddressStrictInput')
@ObjectType()
export class AddressStrictComponent {
@Field()
number: string;
@Field()
street: string;
@Field()
zip: string;
@Field()
city: string;
@Field()
country: string;
@Field({ nullable: true })
streetBis?: string;
@Field({ nullable: true })
floor?: string;
@Field({ nullable: true })
box?: string;
@Field({ nullable: true })
state?: string;
returnFullAddress() {
return `${this.number} ${this.street}, ${this.zip} ${this.city} ${this.country}`
}
}
@InputType('PlaceInput')
@ObjectType()
export class PlaceComponent {
@Field()
placeId: string;
@Field({ nullable: true })
address: AddressComponent;
@Field(() => LocComponent)
loc: LocComponent;
@Field()
formattedAddress: string;
}
@InputType('PlaceComponentOptionnalInput')
@ObjectType()
export class PlaceComponentOptionnal {
@Field({ nullable: true })
placeId?: string;
@Field(() => AddressComponent, { nullable: true })
address: AddressComponent;
@Field(() => LocComponent, { nullable: true })
loc?: LocComponent;
@Field({ nullable: true })
formattedAddress?: string;
}
@InputType('PlaceComponentOptionnalWithAddressInput')
@ObjectType()
export class PlaceComponentOptionnalWithAddress {
@Field({ nullable: true })
placeId?: string;
@Field(() => AddressStrictComponent)
address: AddressStrictComponent;
@Field(() => LocComponent, { nullable: true })
loc?: LocComponent;
@Field({ nullable: true })
formattedAddress?: string;
}
@InputType('GeolocSearchInput')
@ObjectType()
@ArgsType()
export class GeolocSearchComponent {
@Field()
longitude: number;
@Field()
latitude: number;
@Max(10000)
@Field(() => Int, { nullable: true })
radius = 5000;
}
@InputType('GeolocAddressSearchInput')
@ObjectType()
export class GeolocAddressSearchComponent {
@Field()
formattedAddress: string;
@Max(10000)
@Field(() => Int, { nullable: true })
radius = 5000;
}
@InputType('GeolocPlaceSearchInput')
@ObjectType()
export class GeolocPlaceSearchComponent {
@Field()
placeId: string;
@Max(10000)
@Field(() => Int, { nullable: true })
radius = 5000;
}
@ObjectType()
export class GeolocDistComponent {
@Field({ nullable: true })
calculated?: number;
@Field(() => LocComponent, { nullable: true })
location?: LocComponent;
}
@InputType('PlaceContactInformationInput')
@ObjectType()
export class PlaceContactInformation {
@Field()
phoneNumber: string;
@Field()
email: string;
@Field(() => ScheduleComponent)
openingHours: ScheduleComponent;
}