Skip to content

Core Services

Change Detection (ChangeDetectionService)

The heart of the middleware. Computes field-level diffs between the previous and current version of a record.

  • Supports nested objects (dot notation: address.street)
  • Array comparison with length tracking
  • Float tolerance of 0.0001 to avoid false positives from rounding
  • Automatically excludes volatile fields: prices, purchase_orders, __last_update, write_date, create_date

Product Sync (ProductSyncService)

Processes inbound product data:

  1. Finds existing product by external_id or creates new
  2. Computes changedFields via ChangeDetectionService
  3. Stores currentData and previousData
  4. Calls PriceExtractorService to extract prices into separate table
  5. Calls PurchaseOrderExtractorService to extract POs
  6. Supports batch operations with transaction management

Partner Sync (PartnerSyncService)

Processes partners with hierarchy support:

  • Sorts batch by dependency (parents first)
  • Detects circular references
  • Supports deferred parent resolution (child arrives before parent)
  • resolveUnresolvedParents() handles backfilling

Sale Order Sync (SaleOrderSyncService)

Handles both inbound (from Odoo) and outbound (to Odoo) sale orders. Outbound orders are auto-enqueued to the OutboundQueue via an event listener.

Stock Sync (StockSyncService)

Efficient bulk stock synchronization using SQL-level upserts. Tracks isQuantityChanged flag for delta queries.

Price Extractor (PriceExtractorService)

Solves the 128k update explosion: extracts price data from products into PricelistItem records. Only sets priceChanged=true when the price actually differs from the previous value.

Purchase Order Extractor (PurchaseOrderExtractorService)

Extracts purchase order data from products into PurchaseOrder and PurchaseOrderLine records, preventing product entity bloat.

Failure Registry (FailureRegistryService)

Records sync failures, determines the correct webhook direction (Odoo failure -> notify webshop, and vice versa), and dispatches webhook notifications.

Outbound Queue (OutboundQueueService)

Manages the async sync queue from middleware to Odoo:

  • Prevents duplicate entries for the same entity
  • Status transitions: pending -> processing -> completed/failed
  • Retry support with configurable max attempts

Encryption (EncryptionService)

Encrypts webhook secrets using the APP_SECRET. Used to securely store webhook configuration.