Skip to content

Preview a base model's rules together

POST
/models/{modelId}/origin-mapping/previews
curl --request POST \
--url https://api.modeldesk.io/models/2489E9AD-2EE2-8E00-8EC9-32D5F69181C0/origin-mapping/previews \
--header 'Authorization: Bearer <token>' \
--header 'Content-Type: application/json' \
--data '{ "rules": [ { "type": "ElementMappingRule", "id": "2489E9AD-2EE2-8E00-8EC9-32D5F69181C0", "name": "example", "description": "example", "nestedRules": [ { "type": "ElementMappingRule", "targetType": "example", "targetTraits": [ "example" ], "sourcePath": "example", "sourceElementIds": [ "2489E9AD-2EE2-8E00-8EC9-32D5F69181C0" ], "root": false, "targetOwnedRelation": "example", "originModelId": "2489E9AD-2EE2-8E00-8EC9-32D5F69181C0" } ], "targetOwnerId": "2489E9AD-2EE2-8E00-8EC9-32D5F69181C0", "targetType": "example", "targetTraits": [ "example" ], "sourcePath": "example", "sourceElementIds": [ "2489E9AD-2EE2-8E00-8EC9-32D5F69181C0" ], "root": false, "targetOwnedRelation": "example", "originModelId": "2489E9AD-2EE2-8E00-8EC9-32D5F69181C0" } ] }'

Preview the top-level rules of one base model together, in the one run a generation from that base model makes, without persisting changes, and answer each rule with its part of that run. A rule the run starts at alone is answered as the single-rule preview answers it; beside other rules, with what the generation makes of it, which can hold more than its single-rule preview: the run’s scope holds every rule’s pins, and its relation rules find the output of every rule. A rule whose preview fails is left out of the answer rather than failing the others.

modelId
required
string format: uuid
Media typeapplication/json
object
rules
required

The top-level element rules to preview, each with its id and all reading the same base model. Rules the target model stores beside them run as stored.

Array
>= 1 items
ElementMappingRule
object
type
required

The type of mapping rule (discriminator for polymorphism).

string
Allowed values: ElementMappingRule AttributeMappingRule RelationMappingRule
id

Unique identifier for this rule. Can be client-provided or server-generated.

string format: uuid
name

The rule’s name, where it has one. A stored mapping names its rules; a rule it writes without one is stored under what it produces.

string
description

The author’s note on this rule. Stored as the rule element’s description; a blank note is stored as no note, so saving a rule with the text cleared leaves it without one.

string
nestedRules

Nested mapping rules owned by this rule. Order matters - rules are executed in list order.

Array

A mapping rule, discriminated by its own type.

One of: discriminator: type
ElementMappingRule
object
type
required

The type of mapping rule (discriminator for polymorphism).

string
Allowed values: ElementMappingRule AttributeMappingRule RelationMappingRule
id

Unique identifier for this rule. Can be client-provided or server-generated.

string format: uuid
name

The rule’s name, where it has one. A stored mapping names its rules; a rule it writes without one is stored under what it produces.

string
description

The author’s note on this rule. Stored as the rule element’s description; a blank note is stored as no note, so saving a rule with the text cleared leaves it without one.

string
nestedRules
Array recursive
targetOwnerId

Optional reference to an existing element to attach this rule’s output to.

string format: uuid
type
required
string
Allowed value: ElementMappingRule
targetType
required

The target element type to create for each matched source element.

string
>= 1 characters
targetTraits

The traits each created element carries beside targetType. Where an owned relation holds the element, the relation decides its form: its default trait is added where the element carries no member of the default’s exclusive group, and replaces a member the relation refuses. Absent when the rule names none.

Array<string>
sourcePath

Path expression to select source elements. Mutually exclusive with sourceElementIds.

string
sourceElementIds

Explicit source element IDs to map. Mutually exclusive with sourcePath.

Array<string>
root

Whether the mapped elements are root elements in the target model.

boolean
targetOwnedRelation

Target owned relation name for nested element mappings. Required when nested under another element mapping.

string
originModelId
required

Reference to the origin model from which source elements are selected.

string format: uuid
targetOwnerId

Optional reference to an existing element to attach this rule’s output to.

string format: uuid
type
required
string
Allowed value: ElementMappingRule
targetType
required

The target element type to create for each matched source element.

string
>= 1 characters
targetTraits

The traits each created element carries beside targetType. Where an owned relation holds the element, the relation decides its form: its default trait is added where the element carries no member of the default’s exclusive group, and replaces a member the relation refuses. Absent when the rule names none.

Array<string>
sourcePath

Path expression to select source elements. Mutually exclusive with sourceElementIds.

string
sourceElementIds

Explicit source element IDs to map. Mutually exclusive with sourcePath.

Array<string>
root

Whether the mapped elements are root elements in the target model.

boolean
targetOwnedRelation

Target owned relation name for nested element mappings. Required when nested under another element mapping.

string
originModelId
required

Reference to the origin model from which source elements are selected.

string format: uuid

OK

Media typeapplication/json
object
previews
required

Each rule’s preview by rule id, in the order the rules were submitted. A rule whose preview failed is absent.

object
key
additional properties
object
ruleId
required

The ID of the rule that was previewed.

string format: uuid
generatedElements
required

The elements that would be generated by this rule.

Array<object>
object
id
required
string format: uuid
type
required
string
external
boolean
attributes
object
key
additional properties
array
relations
object
key
additional properties
object
key
additional properties
Array<object>
object
id
required
string format: uuid
owned
required
boolean
modelId

Owning model of the referenced element when it differs from the containing model (cross-model reference, e.g. a lineage base element). Omitted for same-model references.

string format: uuid
extensionLayer

The values the element holds that its type declares no property for; absent when none.

Array

A value an element holds under no binding its type declares, kept so a round trip loses nothing.

One of: discriminator: kind
attribute
object
kind
required
string
Allowed value: attribute
key
string
lexicalValue
string
typeIdentifier
string
qualifiers
object
key
additional properties
string
lineage

Where an element was derived from: the source and rules models, and per property the source values it read.

object
sourceModels
Array<object>
object
modelId
string format: uuid
commitId
string format: uuid
rulesModels
Array<object>
object
modelId
string format: uuid
commitId
string format: uuid
generatedBy
object
id
required
string format: uuid
owned
required
boolean
modelId

Owning model of the referenced element when it differs from the containing model (cross-model reference, e.g. a lineage base element). Omitted for same-model references.

string format: uuid
properties
Array<object>
object
propertyName
string
propertyType
string
Allowed values: ATTRIBUTE RELATION
sources
Array<object>
object
sourceModelId
string format: uuid
sourceElementId
string format: uuid
sourceProperty
string
propertyType
string
Allowed values: ATTRIBUTE RELATION
role
string
Allowed values: PRIMARY VALUE_READ
usedRule
object
id
required
string format: uuid
owned
required
boolean
modelId

Owning model of the referenced element when it differs from the containing model (cross-model reference, e.g. a lineage base element). Omitted for same-model references.

string format: uuid
sourceElementIds
required

Source element IDs that would be mapped.

Array<string>
reversibility
required

How reversible the previewed rule’s value mappings are, per target attribute. The rule editor renders these grades and their assumption sentences verbatim rather than deriving its own, which is why the preview always answers with them.

object
overall
required

The weakest finding; the rule as a whole is no better than this.

string
Allowed values: REVERSIBLE REVERSIBLE_WITH_IDENTITY_STORE REVERSIBLE_WITH_PROVENANCE CONDITIONALLY_REVERSIBLE NOT_REVERSIBLE
findings
required
Array<object>
object
ruleId

The attribute rule whose value mapping this classifies. One rule can write a target attribute through several attribute rules, so the attribute alone does not say which one a finding is about.

string format: uuid
targetAttribute
required
string
reversibility
required

REVERSIBLE — the derived value determines the base value on its own. REVERSIBLE_WITH_IDENTITY_STORE — it determines it only together with the stored links, which resolve which base element the value came from. REVERSIBLE_WITH_PROVENANCE — it does not determine the base value, but every value that fed it is recorded per run, so reversing it is a lookup of those inputs rather than an attempt to undo the computation. CONDITIONALLY_REVERSIBLE — it determines the base value only while an assumption about the data holds. No classifier arm answers this today, because a step that reads the base records what it read; it remains for content no run recorded. NOT_REVERSIBLE — nothing to reverse to, or nothing recorded to look up: a value the base model never held, or a query in a language whose value projection cannot run.

string
Allowed values: REVERSIBLE REVERSIBLE_WITH_IDENTITY_STORE REVERSIBLE_WITH_PROVENANCE CONDITIONALLY_REVERSIBLE NOT_REVERSIBLE
reason
required

Why it classifies that way, phrased for the authoring UI.

string
assumption

What a reader without this record has to take on trust, composed from the query the author wrote — “If voornaam or achternaam contains a space, this value cannot be split back into its parts.” Independent of the grade: the grade says whether the derivation can be reversed here, which for anything a run records is yes, while this says what the same value costs someone holding only the value. Absent when it costs them nothing, which is most findings, and always absent on a NOT_REVERSIBLE finding — nothing was recorded there, so there is no record for a reader to be holding the value without. Render it verbatim rather than deriving your own wording.

string
generatedRelations
required

The relations this rule would write. A preview that answered with elements only would show a relation rule as having done nothing.

Array<object>

One relation a previewed rule would write, and where its target came from.

object
sourceElementId
required

The element the relation is written on — the source end of the edge, and an element the run generates. Despite the name it is unrelated to sourceElementIds on the enclosing result, which means the origin-model elements the rule matched.

string format: uuid
relation
required

Name of the relation written.

string
targetElementId
required

The element the relation points at.

string format: uuid
targetProvenance
required

Where the target came from.

string
Allowed values: GENERATED PREVIOUSLY_GENERATED LINKED EXISTING IN_SCOPE EXTERNAL
ruleIds
required

The relation rules that established the edge, in the order they wrote it. An edge two rules both established is reported once, naming both.

Array<string>
counterpartResolutions
required

One row per source element a counterpart was sought for, so a resolution can be reported per source element rather than only per written edge.

Array<object>

What one source element resolved to, for any relation rule: the counterpart of whatever a navigation reaches, an element named outright, one a join or a target query found, or one another rule generated. One row per source element the rule tried to find a target for; one a guard turned away, or a join read no value on, has none.

object
ruleId
required

The relation rule that resolved it.

string format: uuid
sourceElementId
required

The origin-model element a counterpart was sought for.

string format: uuid
counterparts
required

What it resolved to. Empty means nothing stands for this source element, which cannot be told apart from an element that was generated but whose origin was never recorded — lineage names a source element only inside the property entries a rule writes.

Array<object>

One element that stands for a source element, and on what evidence.

object
elementId
required

The corresponding element.

string format: uuid
provenance
required

The evidence that it corresponds.

string
Allowed values: GENERATED PREVIOUSLY_GENERATED LINKED EXISTING IN_SCOPE EXTERNAL
scope

The identity of the scope snapshot the element lives in, as targetScope lists it. Present only for IN_SCOPE.

string
passedOver
required

Candidates that stronger evidence outranked, so a reader can be told a linked element was passed over rather than have it silently discarded.

Array<object>

One element that stands for a source element, and on what evidence.

object
elementId
required

The corresponding element.

string format: uuid
provenance
required

The evidence that it corresponds.

string
Allowed values: GENERATED PREVIOUSLY_GENERATED LINKED EXISTING IN_SCOPE EXTERNAL
scope

The identity of the scope snapshot the element lives in, as targetScope lists it. Present only for IN_SCOPE.

string
relationRefusals
required

Relations the run refused to write: several distinct targets for a relation holding one, and a target query that answered several candidates, or none with no later rule on the relation to hand the source element to. A preview reports these as data so the refusal can be attributed to the card that caused it; a real generation still fails with 422.

Array<object>

A relation the run refused to write, because one source element resolved several distinct targets for a relation that holds only one.

object
ruleId
required

The refused rule.

string format: uuid
elementId
required

The element the relation would have been written on.

string format: uuid
sourceElementId
required

The origin-model element whose resolution produced several targets.

string format: uuid
relation
required

Name of the relation that holds only one.

string
targetElementIds
required

The distinct targets that were resolved.

Array<string>
message
required

The engine’s own account of the refusal, including the repair.

string
targetScope
required

The run’s target scope in feeder order: every model the previewed run could point into without generating it, and the elements of each its relations landed on. A snapshot the target does not already depend on and a relation landed in is one saving adds as a dependency.

Array<object>

One model a mapping run may point into without generating it: which model at which version, why it is in scope, whether the target already reaches it, and which of its elements the run’s relations landed on.

object
identity
required

What makes the snapshot one — the model and commit, or an external document’s location and metamodel. What a counterpart’s scope names.

string
feeder
required

Why the snapshot is in scope: a built-in element model of the target metamodel, a model the mapping pins, one the target already depends on, or one the base model depends on.

string
Allowed values: BUILT_IN MAPPING_PIN TARGET_DEPENDENCY BASE_MODEL_DEPENDENCY
kind
required

How the snapshot is pinned; only INTERNAL and EXTERNAL are ever declared.

string
Allowed values: INTERNAL EXTERNAL BUILT_IN MANAGED
modelId

The model the snapshot is a version of; absent for an external document.

string | null format: uuid
commitId

The commit it was read at; absent for a built-in and an external document.

string | null format: uuid
versionRef

The version name it was pinned by, absent where it was pinned at a commit.

string | null
location

Where an external document is read from.

string | null
name
required

The model’s name.

string
alreadyDependedOn
required

Whether the target reaches the snapshot without the run declaring it. False is a snapshot a relation landing in adds as a dependency when the run is saved.

boolean
landed
required

The snapshot’s elements the run’s relations landed on.

Array<object>

One element of a scope snapshot, named as the snapshot’s own metamodel names it.

object
id
required
string format: uuid
type
required
string
label
required
string
generatedElementSources

Generated element ID to the origin element it came from. Carried because the two per-rule maps cannot be zipped positionally: one skips elements with no source and the other does not, so their indices diverge.

object
key
additional properties
string format: uuid
generatedElementOwners

Generated element ID to the generated element that holds it and the relation it is held through. An element placed in something the preview did not generate is absent, so a consumer drawing the output as a tree puts it at the top.

object
key
additional properties
object
id
required
string format: uuid
relation
required
string
generatedCount

Total count of elements that would be generated.

integer

Example

{
"previews": {
"additionalProperty": {
"generatedElements": [
{
"extensionLayer": [
{
"kind": "attribute"
}
],
"lineage": {
"properties": [
{
"propertyType": "ATTRIBUTE",
"sources": [
{
"propertyType": "ATTRIBUTE",
"role": "PRIMARY"
}
]
}
]
}
}
],
"reversibility": {
"overall": "REVERSIBLE",
"findings": [
{
"reversibility": "REVERSIBLE"
}
]
},
"generatedRelations": [
{
"targetProvenance": "GENERATED"
}
],
"counterpartResolutions": [
{
"counterparts": [
{
"provenance": "GENERATED"
}
],
"passedOver": [
{
"provenance": "GENERATED"
}
]
}
],
"targetScope": [
{
"feeder": "BUILT_IN",
"kind": "INTERNAL"
}
]
}
}
}

Bad request

Media typeapplication/problem+json

An RFC 9457 problem document, always sent as application/problem+json.

object
type

Present only on a typed refusal, whose own schema requires it and fixes its value. An untyped problem omits it, which RFC 9457 defines as about:blank: the status and title are all there is to branch on.

string format: uri
title
required
string
status
required
integer
detail
required
string
instance

The path of the request that was refused. Absent when the request was refused before it reached the application’s handlers: a 401 for a missing or unusable access token, and a 403 for a service account whose scopes do not reach the route.

string
violations

Present on a 400 raised by request-body validation, and on a 422 that refuses named fields (a malformed slug or namespace prefix). Each entry names the rejected property, so a client can attach the message to the field that caused it rather than showing one error for the whole form.

Array<object>
object
property
required
string
message
required
string

Example generated

{
"type": "https://example.com",
"title": "example",
"status": 1,
"detail": "example",
"instance": "example",
"violations": [
{
"property": "example",
"message": "example"
}
]
}

Not found

Media typeapplication/problem+json

An RFC 9457 problem document, always sent as application/problem+json.

object
type

Present only on a typed refusal, whose own schema requires it and fixes its value. An untyped problem omits it, which RFC 9457 defines as about:blank: the status and title are all there is to branch on.

string format: uri
title
required
string
status
required
integer
detail
required
string
instance

The path of the request that was refused. Absent when the request was refused before it reached the application’s handlers: a 401 for a missing or unusable access token, and a 403 for a service account whose scopes do not reach the route.

string
violations

Present on a 400 raised by request-body validation, and on a 422 that refuses named fields (a malformed slug or namespace prefix). Each entry names the rejected property, so a client can attach the message to the field that caused it rather than showing one error for the whole form.

Array<object>
object
property
required
string
message
required
string

Example generated

{
"type": "https://example.com",
"title": "example",
"status": 1,
"detail": "example",
"instance": "example",
"violations": [
{
"property": "example",
"message": "example"
}
]
}

Error

Media typeapplication/problem+json

An RFC 9457 problem document, always sent as application/problem+json.

object
type

Present only on a typed refusal, whose own schema requires it and fixes its value. An untyped problem omits it, which RFC 9457 defines as about:blank: the status and title are all there is to branch on.

string format: uri
title
required
string
status
required
integer
detail
required
string
instance

The path of the request that was refused. Absent when the request was refused before it reached the application’s handlers: a 401 for a missing or unusable access token, and a 403 for a service account whose scopes do not reach the route.

string
violations

Present on a 400 raised by request-body validation, and on a 422 that refuses named fields (a malformed slug or namespace prefix). Each entry names the rejected property, so a client can attach the message to the field that caused it rather than showing one error for the whole form.

Array<object>
object
property
required
string
message
required
string

Example generated

{
"type": "https://example.com",
"title": "example",
"status": 1,
"detail": "example",
"instance": "example",
"violations": [
{
"property": "example",
"message": "example"
}
]
}