dref
v1.0.0
specification.json

Mapping examples

Real mapsFrom definitions pulled from the reference domains. A mapping lives on the model it imports into and holds only the mapping — which incoming fields to read, where they land, and an optional transform chain. Validate the incoming object against its own source model first.

2 mappings
StripeStripe PaymentIntentPaymentIntent · Commerce/orders mapsFrom
SourceTransform chainTarget
id1:1id
status1:1status
order_id1:1orderId
payment_method1:1paymentMethodId
amount
divide(100)
amount
currency
upperCase
currency
description
trim
description
created
formatDate(unix)
createdAt
Mapping definition
{
  "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
SourceTransform chainTarget
item_id1:1productId
location_code
prefix(wh_)
warehouseId
on_hand
toNumber
quantityOnHand
reserved
toNumber
quantityReserved
reorder_point
toNumber
reorderPoint
last_updated
formatDate(unix)
updatedAt
Mapping definition
{
  "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"
        }
      ]
    }
  ]
}

Each bare string (like "id") is a 1:1 copy onto a same-named target property. Objects rename or reshape: { "{ from": "created", "to": "createdAt", "transform": [...] }" } moves created to createdAt. The formatDate step takes only the source format ("unix" or a dref token pattern); output comes from the domain's defaults.formats for the field type, else ISO 8601 — with named "iso8601"/"epoch"/"epochMillis" forcing that output form.