Skip to main content

Documentation Index

Fetch the complete documentation index at: https://mintlify.com/Carlos-Gnd/FERRED-Inventario-y-Ventas/llms.txt

Use this file to discover all available pages before exploring further.

The sync API provides visibility into the background synchronization process between the local SQLite database and Supabase. Use it to monitor pending operations, identify sync errors, and check connectivity status.
Synchronization happens automatically in the background — you do not need to call any endpoint to trigger it. This API is for monitoring and manual control only.
Before shutting down or going intentionally offline, call GET /api/inventario/sync-pendientes and confirm that pendientes is 0. This ensures all local mutations have been uploaded to Supabase and no data will be lost.

Background sync behavior

The SyncService runs a drain loop in the background with the following characteristics:
  • Interval: every 30 seconds.
  • Batch size: up to 50 SyncLog entries are processed per cycle.
  • Retry limit: each entry is retried up to 5 times before being marked ERROR.
  • Scope: entries are filtered to status = PENDIENTE; entries in SINCRONIZADO or ERROR state are not retried automatically.

GET /api/inventario/status

Quick connectivity check. Returns whether the server can currently reach Supabase. Roles: ADMIN, BODEGA, CAJERO

Response

online
boolean
true if the server successfully reached Supabase; false if operating in offline mode.

GET /api/inventario/sync-pendientes

Returns counts of sync log entries by status for the current user. ADMIN users see all entries across the system; other roles see only their own entries. Roles: All authenticated users

Response

pendientes
number
Number of SyncLog entries with status = PENDIENTE. These are operations that have been recorded locally but not yet pushed to Supabase.
sincronizados
number
Number of entries with status = SINCRONIZADO. These operations have been successfully uploaded.
errores
number
Number of entries with status = ERROR. These operations failed after the maximum number of retry attempts and require manual attention.
online
boolean
Current connectivity status. Reflects the same value as GET /api/inventario/status.
sucursalId
number
The branch ID of the authenticated user. null for ADMIN users without an assigned branch.

GET /api/sync/snapshot/status

Returns the timestamp of the last successful snapshot sync for the authenticated user’s branch, along with current connectivity. Roles: ADMIN, BODEGA, CAJERO

Response

online
boolean
Whether the server can reach Supabase.
sucursalId
number
The branch ID of the authenticated user.
lastSyncAt
string
ISO 8601 timestamp of the last successful snapshot refresh for this branch, or null if no snapshot has been taken yet.

Errors

StatusCondition
400The authenticated user has no branch assigned.

POST /api/sync/snapshot

Manually triggers a snapshot refresh for the authenticated user’s branch. Pulls current data from Supabase into the local SQLite database. Fails if the server is offline. Roles: ADMIN, BODEGA, CAJERO

Query parameters

full
boolean
default:"false"
When true, runs a full bootstrap snapshot (all data). When false (default), runs an incremental refresh that only fetches data changed since the last snapshot.

Response 200

ok
boolean
Always true on success.
counts
object
Number of records synced per table during this snapshot operation. Shape depends on the snapshot implementation.
lastSyncAt
string
ISO 8601 timestamp of the snapshot that was just completed.

Errors

StatusCondition
400The authenticated user has no branch assigned.
503The server is offline — cannot sync without a Supabase connection.

Build docs developers (and LLMs) love