feat: types sync + dépendance googleapis
This commit is contained in:
@@ -0,0 +1,67 @@
|
||||
export type SyncChangeType = 'create' | 'update' | 'deactivate' | 'unchanged'
|
||||
|
||||
/** Produit normalisé depuis Google Sheets */
|
||||
export interface SyncProduct {
|
||||
ref: string // ex: "REF-1042" (colonne A telle quelle)
|
||||
handle: string // ref normalisée en handle Shopify: "ref-1042"
|
||||
title: string // colonne B
|
||||
description: string // colonne C (texte brut, stocké en body_html)
|
||||
price: string // colonne D — "29.99" (2 décimales)
|
||||
stock: number // colonne E — info affichage uniquement (non synchronisé)
|
||||
status: 'active' | 'draft' // colonne F : "inactif"/"inactif" → draft, tout autre → active
|
||||
}
|
||||
|
||||
/** Produit Shopify enrichi pour la comparaison */
|
||||
export interface ShopifyProductFull extends SyncProduct {
|
||||
shopifyId: string // ID numérique Shopify (string)
|
||||
}
|
||||
|
||||
/** Un changement unitaire calculé par computeDiff */
|
||||
export interface SyncChange {
|
||||
type: SyncChangeType
|
||||
ref: string
|
||||
sheetProduct?: SyncProduct // présent pour create + update
|
||||
shopifyProduct?: ShopifyProductFull // présent pour update + deactivate
|
||||
changedFields?: Array<{ // présent pour update uniquement
|
||||
field: string
|
||||
from: string
|
||||
to: string
|
||||
}>
|
||||
}
|
||||
|
||||
/** Résultat complet du diff */
|
||||
export interface DiffResult {
|
||||
changes: SyncChange[]
|
||||
summary: {
|
||||
create: number
|
||||
update: number
|
||||
deactivate: number
|
||||
unchanged: number
|
||||
}
|
||||
}
|
||||
|
||||
/** Une entrée du log d'exécution */
|
||||
export interface SyncLogEntry {
|
||||
ref: string
|
||||
action: 'create' | 'update' | 'deactivate'
|
||||
status: 'success' | 'error'
|
||||
message: string
|
||||
}
|
||||
|
||||
/** Un événement NDJSON streamé par /api/sync/execute */
|
||||
export type SyncStreamEvent =
|
||||
| { type: 'progress'; current: number; total: number; message: string }
|
||||
| { type: 'done'; summary: { created: number; updated: number; deactivated: number; errors: number; status: 'success' | 'partial' | 'error' } }
|
||||
|
||||
/** Une entrée d'historique (depuis SyncRun Prisma) */
|
||||
export interface SyncHistoryEntry {
|
||||
id: string
|
||||
createdAt: string // ISO string
|
||||
userName: string
|
||||
status: 'success' | 'partial' | 'error'
|
||||
created: number
|
||||
updated: number
|
||||
deactivated: number
|
||||
errors: number
|
||||
log: SyncLogEntry[]
|
||||
}
|
||||
Reference in New Issue
Block a user