feat(sync): harden the Hiboutik sync, share rate limits across instances, update dependencies (#4)

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
This commit is contained in:
2026-11-08 13:45:08 +00:00
parent 8c8a2ccf15
commit cc3dcd3f0a
62 changed files with 1546 additions and 639 deletions

View File

@@ -1,40 +1,39 @@
/**
* Sale as returned by Hiboutik `GET /sales/:sale_id`, with its lines.
* Only the fields used by the sync are typed: the payload also carries many computed copies (dates split in parts,
* totals by tax, customer and store details...).
*/
export interface SaleHiboutikDto {
sale_id: number;
/** Local time, "YYYY-MM-DD HH:mm:ss". */
created_at: string;
/** Local time, "0000-00-00 00:00:00" while the sale is not completed. */
completed_at: string;
store_id: number;
customer_id: number;
currency: string;
/** Decimal as a string, taxes included. */
total: string;
/** Payment type code, e.g. "CB", "ESP", "WEB". */
payment: string;
/** 1 for a quotation. */
quotation: number;
line_items: SaleLineHiboutikDto[];
}
import { z } from 'zod';
import { hiboutikDecimal, hiboutikId, hiboutikInt, hiboutikList, hiboutikRef, hiboutikText } from './hiboutik.schema';
/** Line of a {@link SaleHiboutikDto}: a snapshot of the product at sale time. */
export interface SaleLineHiboutikDto {
line_item_id: number;
product_id: number;
/** Line of a sale: a snapshot of the product at sale time. */
export const saleLineHiboutikSchema = z.object({
product_id: hiboutikRef,
/** Hiboutik size id, 0 for a product without sizes. */
product_size: number;
product_size: hiboutikRef,
/** Negative for a returned item. */
quantity: number;
product_model: string;
product_barcode: string;
quantity: hiboutikInt,
product_model: hiboutikText,
product_barcode: hiboutikText,
/** Size name, empty for a product without sizes. */
size_name: string;
/** Unit price before discount, taxes included (decimal as a string). */
item_unit_gross_wo_discount: string;
/** Unit price actually paid, discount deducted, taxes included (decimal as a string). */
item_unit_gross: string;
}
size_name: hiboutikText,
/** Unit price actually paid, discount deducted, taxes included. */
item_unit_gross: hiboutikDecimal,
});
/**
* Sale as returned by Hiboutik `GET /sales/:sale_id`, with its lines. Only the fields used by the sync: the payload
* also carries many computed copies (dates split in parts, totals by tax, customer and store details...).
*/
export const saleHiboutikSchema = z.object({
sale_id: hiboutikId,
/** French local time, "YYYY-MM-DD HH:mm:ss". */
created_at: hiboutikText,
/** French local time, "0000-00-00 00:00:00" while the sale is not completed. */
completed_at: hiboutikText,
/** 0 for an anonymous sale. */
customer_id: hiboutikRef,
/** Taxes included. */
total: hiboutikDecimal,
/** 1 for a quotation. */
quotation: hiboutikInt,
line_items: hiboutikList(saleLineHiboutikSchema),
});
export type SaleLineHiboutikDto = z.output<typeof saleLineHiboutikSchema>;
export type SaleHiboutikDto = z.output<typeof saleHiboutikSchema>;