Migration clients (uuid id, organization_id FK uuid CASCADE, name, email REQUIS, phone, address, siret, notes). Index sur organization_id. Modèle Client avec belongsTo Organization. La relation hasMany Invoice est volontairement omise tant que le domaine Invoice n'est pas câblé. Validators Vine alignés sur le contrat MSW : - create : name 2-120, email requis avec format, siret 14 chiffres si fourni - update : tout optionnel - email REQUIS au create — pivot produit, pas de relance possible sans Endpoints (auth requise, scopés par organizationId du user courant) : - GET /clients?withStats=1&q= : liste filtrée + recherche, enrichissement stats optionnel, tri par actionnabilité (retards d'abord) quand withStats - GET /clients/:id : détail (id en UUID via router.matchers.uuid()) - POST /clients : 201 + détection doublon par nom case-insensitive → 409 avec payload `existing` (le SPA peut proposer "voir le client existant") - PATCH /clients/:id : merge partiel Service ClientStats avec interface bulkComputeClientStats() qui retourne EMPTY pour l'instant — sera vraiment branché quand Invoice arrive. Le contrat reste stable côté SPA, juste les compteurs à 0. Sérialisation : pour les listes avec stats per-item, on instancie le transformer manuellement (`new ClientTransformer(c).toObject()`) plutôt que de passer par BaseTransformer.transform() qui retourne un Item nested non-unwrappable hors clé directe de serialize().
101 lines
3.0 KiB
TypeScript
101 lines
3.0 KiB
TypeScript
/**
|
|
* This file is automatically generated
|
|
* DO NOT EDIT manually
|
|
* Run "node ace migration:run" command to re-generate this file
|
|
*/
|
|
|
|
import { BaseModel, column } from '@adonisjs/lucid/orm'
|
|
import { DateTime } from 'luxon'
|
|
|
|
export class AuthAccessTokenSchema extends BaseModel {
|
|
static $columns = ['abilities', 'createdAt', 'expiresAt', 'hash', 'id', 'lastUsedAt', 'name', 'tokenableId', 'type', 'updatedAt'] as const
|
|
$columns = AuthAccessTokenSchema.$columns
|
|
@column()
|
|
declare abilities: string
|
|
@column.dateTime({ autoCreate: true })
|
|
declare createdAt: DateTime | null
|
|
@column.dateTime()
|
|
declare expiresAt: DateTime | null
|
|
@column()
|
|
declare hash: string
|
|
@column({ isPrimary: true })
|
|
declare id: string
|
|
@column.dateTime()
|
|
declare lastUsedAt: DateTime | null
|
|
@column()
|
|
declare name: string | null
|
|
@column()
|
|
declare tokenableId: string
|
|
@column()
|
|
declare type: string
|
|
@column.dateTime({ autoCreate: true, autoUpdate: true })
|
|
declare updatedAt: DateTime | null
|
|
}
|
|
|
|
export class ClientSchema extends BaseModel {
|
|
static $columns = ['address', 'createdAt', 'email', 'id', 'name', 'notes', 'organizationId', 'phone', 'siret', 'updatedAt'] as const
|
|
$columns = ClientSchema.$columns
|
|
@column()
|
|
declare address: string | null
|
|
@column.dateTime({ autoCreate: true })
|
|
declare createdAt: DateTime
|
|
@column()
|
|
declare email: string
|
|
@column({ isPrimary: true })
|
|
declare id: string
|
|
@column()
|
|
declare name: string
|
|
@column()
|
|
declare notes: string | null
|
|
@column()
|
|
declare organizationId: string
|
|
@column()
|
|
declare phone: string | null
|
|
@column()
|
|
declare siret: string | null
|
|
@column.dateTime({ autoCreate: true, autoUpdate: true })
|
|
declare updatedAt: DateTime | null
|
|
}
|
|
|
|
export class OrganizationSchema extends BaseModel {
|
|
static $columns = ['createdAt', 'id', 'monthlyVolumeBucket', 'name', 'onboardingCompletedAt', 'rubisCount', 'siret', 'updatedAt'] as const
|
|
$columns = OrganizationSchema.$columns
|
|
@column.dateTime({ autoCreate: true })
|
|
declare createdAt: DateTime
|
|
@column({ isPrimary: true })
|
|
declare id: string
|
|
@column()
|
|
declare monthlyVolumeBucket: string | null
|
|
@column()
|
|
declare name: string
|
|
@column.dateTime()
|
|
declare onboardingCompletedAt: DateTime | null
|
|
@column()
|
|
declare rubisCount: number
|
|
@column()
|
|
declare siret: string | null
|
|
@column.dateTime({ autoCreate: true, autoUpdate: true })
|
|
declare updatedAt: DateTime | null
|
|
}
|
|
|
|
export class UserSchema extends BaseModel {
|
|
static $columns = ['createdAt', 'email', 'fullName', 'id', 'organizationId', 'password', 'signature', 'updatedAt'] as const
|
|
$columns = UserSchema.$columns
|
|
@column.dateTime({ autoCreate: true })
|
|
declare createdAt: DateTime
|
|
@column()
|
|
declare email: string
|
|
@column()
|
|
declare fullName: string | null
|
|
@column({ isPrimary: true })
|
|
declare id: string
|
|
@column()
|
|
declare organizationId: string | null
|
|
@column({ serializeAs: null })
|
|
declare password: string
|
|
@column()
|
|
declare signature: string | null
|
|
@column.dateTime({ autoCreate: true, autoUpdate: true })
|
|
declare updatedAt: DateTime | null
|
|
}
|