Cartamatic POS SDK

Referencia API

Todas las funciones, clases, métodos y tipos públicos expuestos por @cartamatic/pos-sdk.

Esta página lista la superficie pública actual del package @cartamatic/pos-sdk.

Exports Runtime

ExportTipoUso principal
createPosClientfunciónCrear la fachada provider-neutral que usan las apps.
createToteatClientfunciónCrear cliente Toteat directo para tests, adapter work o diagnóstico.
parseToteatWebhookfunciónParsear webhooks Toteat soportados.
redactToteatCredentialsfunciónRedactar objetos con credenciales Toteat.
redactToteatUrlfunciónRedactar query params sensibles en URLs Toteat.
TOTEAT_REDACTED_VALUEconstanteValor usado por helpers de redacción: [REDACTED].

createPosClient

const createPosClient = (options: CreatePosClientOptions): PosClient;

Crea un cliente POS neutral por proveedor. Es la función que debe usar código de producto.

const pos = createPosClient({
  provider: "toteat",
  toteat: {
    restaurantId,
    localId,
    userId,
    apiToken
  }
});

CreatePosClientOptions:

type CreatePosClientOptions = {
  provider: PosProviderId;
  toteat?: ToteatClientOptions;
};

Si provider es "toteat" y no se entrega toteat, lanza Error.

createToteatClient

const createToteatClient = (options: ToteatClientOptions): PosClient;

Crea una implementación Toteat del mismo PosClient. Úsala solo para tests, adapter work o diagnóstico específico de provider.

ToteatClientOptions:

type ToteatClientOptions = {
  restaurantId: string;
  localId: string;
  userId: string;
  apiToken: string;
  baseUrl?: string;
  environment?: "production" | "development";
  fetch?: FetchLike;
  readRetry?: false | PosRetryOptions;
  requestTimeoutMs?: number;
};

PosClient

type PosClient = {
  provider: PosProviderId;
  capabilities: PosCapabilities;
  accounting: PosAccountingClient;
  catalog: PosCatalogClient;
  fiscal: PosFiscalClient;
  inventory: PosInventoryClient;
  orders: PosOrdersClient;
  purchases: PosPurchasesClient;
  raw: PosRawClient;
  sales: PosSalesClient;
  shifts: PosShiftsClient;
  tables: PosTablesClient;
};

Métodos Del Cliente

NamespaceMétodoFirmaRetorno
cataloggetProducts(options?: GetProductsOptions)Promise<PosProduct[]>
tablesgetTables()Promise<PosTable[]>
shiftsgetCurrentShiftStatus()Promise<PosShiftStatus>
orderscreateOrder(options: CreateOrderOptions)Promise<PosOrderSubmissionResult>
ordersgetOrderStatus(options: GetOrderStatusOptions)Promise<PosOrderStatus>
ordersgetCancellationReport(options: GetOrderCancellationReportOptions)Promise<PosOrderCancellation[]>
ordersnotifyDispatch(options: NotifyOrderDispatchOptions)Promise<PosOrderDispatchResult>
salesgetSales(options: GetSalesOptions)Promise<PosSale[]>
salesgetSalesByWaiter(options: GetSalesByWaiterOptions)Promise<PosSalesByWaiterReport[]>
salesgetCollection(options: GetCollectionOptions)Promise<PosCollectionReport>
fiscalgetFiscalDocuments(options: GetFiscalDocumentsOptions)Promise<PosFiscalDocument[]>
inventorygetInventoryState(options: GetInventoryStateOptions)Promise<PosInventoryState>
accountinggetAccountingMovements(options: GetAccountingMovementsOptions)Promise<PosAccountingMovements>
purchasescreatePurchaseMovement(options: CreatePurchaseMovementOptions)Promise<PosPurchaseMovementResult>
rawrequest<TResponse>(path: string, options?: RawRequestOptions)Promise<TResponse>

Opciones Por Método

catalog.getProducts

type GetProductsOptions = {
  activeProducts?: boolean;
};

Lee productos y devuelve PosProduct[].

orders.getOrderStatus

type GetOrderStatusOptions = {
  orderId: string;
  detailType?: "ONLY_STATUS" | "ALL_INFORMATION" | "DELIVERY_INFORMATION";
};

Consulta una orden por ID provider.

orders.createOrder

type CreateOrderOptions = {
  order: PosCreateOrderPayload;
  returnOrderDetail?: boolean;
};

order debe ser un objeto no vacío. El SDK conserva una forma abierta porque faltan fixtures reales para confirmar el shape completo de document.

orders.notifyDispatch

type NotifyOrderDispatchOptions = {
  orderId: string;
  platform: string;
  status: string;
  errorMessage?: string | null;
  trackingUrl?: string | null;
};

orderId, platform y status deben ser strings no vacíos.

Fechas De Reportes

Los métodos siguientes usan YYYY-MM-DD y validan máximo 15 días cuando aplica:

type PosDateRangeOptions = {
  startDate: string;
  endDate: string;
};
MétodoOpciones adicionales
sales.getSalesincludeCancelledOrderDetails?: boolean
sales.getSalesByWaiterNinguna
orders.getCancellationReportNinguna
fiscal.getFiscalDocumentsdocumentType?: PosFiscalDocumentType
inventory.getInventoryStateNinguna
accounting.getAccountingMovementsincludeSales?: boolean

sales.getCollection

type GetCollectionOptions = {
  date: string;
};

date usa YYYY-MM-DD.

purchases.createPurchaseMovement

type CreatePurchaseMovementOptions = {
  invoiceNumber: string;
  emissionDate: string;
  providerVat: string;
  invoiceType: string;
  lineDetails: PosPurchaseLineDetail[];
  referenceNumber?: string;
  status?: string;
  comment?: string;
  dueDate?: string;
  accountingDate?: string;
  currency?: string;
  netAmount?: number;
  taxesAmount?: number;
  totalAmount?: number;
  taxes?: PosPurchaseTax[];
};

Campos obligatorios no vacíos: invoiceNumber, emissionDate, providerVat, invoiceType. lineDetails debe tener al menos un item.

raw.request

type RawRequestOptions = {
  method?: "GET" | "POST";
  query?: Record<string, string | number | boolean | null | undefined>;
  body?: unknown;
  retry?: false | PosRetryOptions;
  timeoutMs?: number;
};
type PosRetryOptions = {
  maxRetries?: number;
  delayMs?: number;
  statusCodes?: number[];
};

En Toteat los retries solo aplican a GET. Si method es POST, el retry efectivo es cero.

Modelos Normalizados

TipoUso
PosProductProducto normalizado.
PosTableMesa normalizada.
PosShiftStatusEstado actual de turno.
PosOrderStatusEstado resumido de orden.
PosOrderCancellationItem de reporte de cancelación.
PosOrderSubmissionResultResultado de crear orden.
PosOrderDispatchResultResultado de notificar despacho.
PosSaleVenta normalizada.
PosSalesByWaiterReportReporte de ventas por garzón.
PosCollectionReportRecaudación de un día.
PosFiscalDocumentDocumento fiscal.
PosInventoryStateEstado agregado de inventario.
PosAccountingMovementsMovimientos contables.
PosPurchaseMovementResultResultado de movimiento de compra.
PosProviderStoreReferencia normalizada a bodega/local externo.

Todos los modelos preservan raw: unknown cuando corresponde.

Errores Exportados

ClaseCuándo ocurreMetadata segura
PosValidationErrorInput inválido antes de llamar al provider.provider
PosNetworkErrorTimeout, abort o fallo antes de recibir respuesta.provider, method, path, cause
PosHttpErrorHTTP no exitoso.provider, method, path, status, statusText, responseBody
PosJsonErrorRespuesta HTTP OK con JSON inválido.provider, method, path, responseBody
PosResponseErrorJSON válido pero respuesta provider no exitosa.provider, response

method y path nunca incluyen query string Toteat.

Webhooks Exportados

parseToteatWebhook soporta eventos:

  • order_status_changed
  • shifts_status_changed
  • menu_changed
  • product_transfer

Los tipos exportados incluyen:

  • ParseToteatWebhookOptions
  • ToteatWebhookAuthenticationOptions
  • ToteatWebhookEventType
  • ToteatWebhook
  • ToteatWebhookBase
  • ToteatWebhookEnvelopeBase
  • ToteatOrderStatusChangedWebhook
  • ToteatShiftsStatusChangedWebhook
  • ToteatMenuChangedWebhook
  • ToteatProductTransferWebhook

Tipos Utilitarios Exportados

TipoUso
PosProviderIdProvider soportado: actualmente "toteat".
FetchLikeTransport inyectable compatible con fetch.
JsonObjectExtensiones y payloads abiertos.
PosCapabilitiesMatriz de capacidades por provider.
ToteatEnvironment"production" o "development".
ToteatClientOptionsCredenciales y opciones de construcción Toteat.
ToteatSensitiveQueryParamQuery params Toteat sensibles.
ToteatSensitiveCredentialFieldCampos de credenciales Toteat sensibles.

On this page