dref
v1.0.0
specification.json

Exemples de mapping

De vraies définitions mapsFrom extraites des domaines de référence. Un mapping vit sur le modèle qu’il importe et ne contient que le mapping — quels champs entrants lire, où ils atterrissent, et une chaîne de transformations facultative. Validez d’abord l’objet entrant contre son propre modèle source.

2 mappings
StripeStripe PaymentIntentPaymentIntent · Commerce/orders mapsFrom
SourceChaîne de transformationsCible
id1:1id
status1:1status
order_id1:1orderId
payment_method1:1paymentMethodId
amount
divide(100)
amount
currency
upperCase
currency
description
trim
description
created
formatDate(unix)
createdAt
Définition du mapping
{
  "name": "Stripe PaymentIntent",
  "provider": "Stripe",
  "version": "1.0.0",
  "description": "Maps a Stripe PaymentIntent API object onto this model.",
  "fields": [
    "id",
    "status",
    {
      "from": "order_id",
      "to": "orderId"
    },
    {
      "from": "payment_method",
      "to": "paymentMethodId"
    },
    {
      "from": "amount",
      "transform": [
        {
          "type": "divide",
          "param": 100
        }
      ]
    },
    {
      "from": "currency",
      "transform": [
        "upperCase"
      ]
    },
    {
      "from": "description",
      "transform": [
        "trim"
      ]
    },
    {
      "from": "created",
      "to": "createdAt",
      "transform": [
        {
          "type": "formatDate",
          "param": "unix"
        }
      ]
    }
  ]
}
WarehouseOSWMS Stock LevelStockLevel · Inventory/stock mapsFrom
SourceChaîne de transformationsCible
item_id1:1productId
location_code
prefix(wh_)
warehouseId
on_hand
toNumber
quantityOnHand
reserved
toNumber
quantityReserved
reorder_point
toNumber
reorderPoint
last_updated
formatDate(unix)
updatedAt
Définition du mapping
{
  "name": "WMS Stock Level",
  "provider": "WarehouseOS",
  "version": "1.2.0",
  "description": "Maps a WarehouseOS inventory snapshot onto this stock level.",
  "fields": [
    {
      "from": "item_id",
      "to": "productId"
    },
    {
      "from": "location_code",
      "to": "warehouseId",
      "transform": [
        {
          "type": "prefix",
          "param": "wh_"
        }
      ]
    },
    {
      "from": "on_hand",
      "to": "quantityOnHand",
      "transform": [
        "toNumber"
      ]
    },
    {
      "from": "reserved",
      "to": "quantityReserved",
      "transform": [
        "toNumber"
      ]
    },
    {
      "from": "reorder_point",
      "to": "reorderPoint",
      "transform": [
        "toNumber"
      ]
    },
    {
      "from": "last_updated",
      "to": "updatedAt",
      "transform": [
        {
          "type": "formatDate",
          "param": "unix"
        }
      ]
    }
  ]
}

Chaque chaîne nue (comme "id") est une copie 1:1 vers une propriété cible de même nom. Les objets renomment ou redéfinissent : { "{ from": "created", "to": "createdAt", "transform": [...] }" } déplace created vers createdAt. L’étape formatDate ne prend que le format source (« unix » ou un motif de jetons dref) ; le format de sortie vient des defaults.formats du domaine pour ce type de champ, sinon ISO 8601 — les paramètres nommés « iso8601 »/« epoch »/« epochMillis » forcent cette forme de sortie.