Shape and name detection
This is the detail behind layers 2, 3 and 6 of Mapping imported types to standard types, for fields: how a provider's fields that together make a standard type, such as an amount and a currency, are…
This is the detail behind layers 2, 3 and 6 of Mapping imported types to standard types, for fields: how a provider's fields that together make a standard type, such as an amount and a currency, are read as that type, and which fields the importer asks you to check. Layers 4 and 5 are under The scoped review and unconfirmed operations.
- How a provider's shape is decoded at the edge:
wire_parts:. Stripe'samount: 1050, currency: "gbp"decodes toMoney, and no other decoding could do it:wire:anddecode:read one member, andWire.minor_unitsneeds one fixed currency. A field'swire_parts:names, for each part of its standard type, the member of the object holding the field it is read from and written to; the field has no member of its own on the provider's wire, and is written as the contract writes it everywhere else. It is for the standard types made of named parts (Money'samountandcurrency,InstantRange'sstartandend, and the others sent as an object of members) and aPoint, bylatitudeandlongitude, which GeoJSON sends as a pair. Every part is spelled, as text, once (package.wire_invalid), never besidewire:,decode:orencode:. Fields may share a part's member, as a charge's amounts share its currency, but a field of its own can't take one (package.wire_name_invalid); written, two values that share a member and differ stop the call as one that doesn't encode, naming the member. None of a field's members sent isnonewhere the field may be; some missing is a fault naming each. It followswire_name:'s shape. - What the importer maps by shape. Only what the shapes
type.standard_existsmatches name, and only where nothing is guessed but the units: a whole number named asMoney's amount (amount,value,cents,pence,minor,amount_minor) beside a currency (currency,currency_code) of the same optionality isMoneyread from both, the currency's field and its own enumeration gone; a latitude beside a longitude (lat,lng,lon) of the same optionality is aPointnamedlocation(positionorpointwhere that is taken). An object that is only an amount in whole numbers and a currency, or only astartand anendthat are instants, each required and spelled as the contract spells it, isMoneyorInstantRangewherever it is used, and isn't declared, since nothing needs decoding. Any other object of a standard shape is left totype.standard_exists, whose swap needs a decoding an agent writes. - What it leaves to check:
package.standard_candidate. A whole number named like a time (created,updated,deleted,expires,timestamp,time, or ending_at,_timeor_timestamp) may be anInstantsent as seconds or milliseconds; one named like an amount (amount_or_amountbesides the shape's names) beside a currency may beMoney; neither is swapped, since only the documentation says which. Each is a declinable error on the field, in a provider package's public objects, until it says how it is sent or is declined with a reason; so is a latitude beside a longitude that isn't mapped. A number named like a time that is text ("2026-10-20") isn't flagged: the page names whole numbers, and a format says when text is a time. - Fakes. A generated default answer writes a field's parts as their
members, and a
Moneyas the contract sends one, a whole number of minor units in the currency its type fixes orGBP. - The summary. The status grid counts the fields mapped
by formatandby shape; "Mapped by shape" lists each shape mapping and how it is read, since each is a judgement, where a format's is only counted; each guess is under "To check" with its(agent)step.--jsongives every mapping asmapped, withat,standard,byand the members it is readfrom.
The import's own output, for a payment provider's document:
$ jadpo package import openapi tidepay.json✓ Imported tidepay.json into shared/providers/tidepay/v2024_06_20 package Tidepay.v2024_06_20 read from its schemas resources charges operations 1 types 3 standard 4 by shapeMapped by shape Charge.amount Money, read from `amount` and `currency` Charge.fee Money, sent as the standard type Charge.window InstantRange, sent as the standard type Shop.location Point, read from `lat` and `lng`To check May be `Money` in minor units, its currency in `currency`: check the provider's documentation, then make it `Money` read from both with `wire_parts:`, or decline `package.standard_candidate` with the reason (agent) Charge.amount_refunded May be an `Instant` sent as whole seconds: check the provider's documentation, then make it `Instant { wire: Wire.unix_seconds }`, or decline `package.standard_candidate` with the reason (agent) Charge.created✓ imported 1 operation · 3 types · 4 to check→ jadpo check checks the package with the app
(The provider's two findings, its sandbox host and its failures, are left out above.)
Markdown for agents: /docs/shape-and-name-detection.md.Built from Jadpo main at a707efb.