Skip to content

Commit 431824b

Browse files
authored
Merge branch 'main' into PORT-15928-track-status-of-ai-driven-pull-requests
2 parents 1963713 + b7651e2 commit 431824b

21 files changed

+1343
-2061
lines changed

docs/actions-and-automations/setup-backend/create-update-entity/create-update-entity.md

Lines changed: 108 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,6 @@
1+
import Tabs from "@theme/Tabs"
2+
import TabItem from "@theme/TabItem"
3+
14
# Create/update entity
25

36
In some cases, we don't want to run complex logic via a workflow or pipeline, but rather want our backend to simply create or update an entity in our software catalog.
@@ -33,15 +36,15 @@ To use this backend type, you will need to define the following fields:
3336
| `team` | The team/s this entity will belong to. |
3437
| `icon` | The icon of the entity. |
3538
| `properties` | The properties of the entity, in `"key":"value"` pairs where the key is the property's identifier, and the value is its value. |
36-
| `relations` | The relations of the entity, in `"key":"value"` pairs where the key is the relation's identifier, and the value is the related entity's identifier. |
39+
| `relations` | The relations of the entity, in `"key":"value"` pairs where the key is the relation's identifier, and the value is the related entity's identifier (for single relations) or an array of identifiers (for "many" relations). |
3740

3841
### Use jq to map the entity
3942

4043
All fields in the `mapping` object can be mapped using `jq` expressions, by wrapping the value in double curly braces `{{ }}`.
4144

4245
For example, say we want to assign the initiator of the action to a new entity when it is created, we can take his email from the action run object and assign it to a property named `assignee`:
4346

44-
```json
47+
```json showLineNumbers
4548
{
4649
"identifier": "someTaskEntity",
4750
"title": "Some Task",
@@ -55,3 +58,106 @@ For example, say we want to assign the initiator of the action to a new entity w
5558
:::tip Test your mapping
5659
You can use the `Test JQ` button in the bottom-left corner to test your mapping against the action's schema.
5760
:::
61+
62+
## Map entity relations
63+
64+
When creating or updating entities, you often need to establish relations with other entities. The mapping approach depends on whether you're dealing with single or multiple entity inputs.
65+
66+
67+
<Tabs groupId="relation-mapping" defaultValue="single" values={[
68+
{label: "Single Entity", value: "single"},
69+
{label: "Array Entity", value: "array"},
70+
{label: "Flexible Mapping", value: "flexible"}
71+
]}>
72+
73+
<TabItem value="single">
74+
75+
For a single entity relation, map the entity identifier directly:
76+
77+
```json showLineNumbers
78+
{
79+
"identifier": "myServiceEntity",
80+
"title": "My Service",
81+
"properties": {},
82+
"relations": {
83+
"domain": "{{ .inputs.domain }}"
84+
}
85+
}
86+
```
87+
88+
</TabItem>
89+
90+
<TabItem value="array">
91+
92+
When your action accepts [array entity inputs](/docs/actions-and-automations/create-self-service-experiences/setup-ui-for-action/user-inputs/entity.md#array), you need to extract the identifiers from the array using the `map(.identifier)` pattern:
93+
94+
```json showLineNumbers
95+
{
96+
"identifier": "myUserEntity",
97+
"title": "My User",
98+
"properties": {},
99+
"relations": {
100+
"skills": "{{ .inputs.skills | map(.identifier) }}"
101+
}
102+
}
103+
```
104+
105+
:::info Array entity inputs
106+
When users select multiple entities from an [entity array input](/docs/actions-and-automations/create-self-service-experiences/setup-ui-for-action/user-inputs/entity.md#array), the input contains an array of entity objects. Each object includes both `identifier` and `title` properties, but relations can only reference entity identifiers.
107+
:::
108+
109+
</TabItem>
110+
111+
<TabItem value="flexible">
112+
113+
For maximum flexibility, you can create a conditional mapping that handles both single entity and array entity inputs:
114+
115+
```json showLineNumbers
116+
{
117+
"identifier": "myProjectEntity",
118+
"title": "My Project",
119+
"properties": {},
120+
"relations": {
121+
"dependencies": "{{ .inputs.dependencies | if type == \"array\" then map(.identifier) else .identifier end }}"
122+
}
123+
}
124+
```
125+
126+
This pattern automatically:
127+
- Extracts identifiers from arrays when multiple entities are selected
128+
- Uses the identifier directly when a single entity is selected
129+
130+
</TabItem>
131+
132+
</Tabs>
133+
134+
135+
### Common use cases
136+
137+
Here are some typical scenarios for mapping array relations:
138+
139+
**Mapping skills to a user:**
140+
```json showLineNumbers
141+
"relations": {
142+
"skills": "{{ .inputs.selectedSkills | map(.identifier) }}"
143+
}
144+
```
145+
146+
**Mapping team members to a project:**
147+
```json showLineNumbers
148+
"relations": {
149+
"members": "{{ .inputs.teamMembers | map(.identifier) }}"
150+
}
151+
```
152+
153+
**Mapping dependencies between services:**
154+
```json showLineNumbers
155+
"relations": {
156+
"dependsOn": "{{ .inputs.dependencies | map(.identifier) }}"
157+
}
158+
```
159+
160+
161+
:::info Entity titles in relations
162+
Relations can only reference entity **identifiers**, not titles. Even though entity objects contain both `identifier` and `title` properties, you must always use `.identifier` when mapping to relations.
163+
:::

docs/api-reference/aggregate-entities-over-time.api.mdx

Lines changed: 2 additions & 2 deletions
Large diffs are not rendered by default.

docs/api-reference/aggregate-entities.api.mdx

Lines changed: 2 additions & 2 deletions
Large diffs are not rendered by default.

docs/api-reference/change-a-blueprint.api.mdx

Lines changed: 3 additions & 3 deletions
Large diffs are not rendered by default.

docs/api-reference/change-an-action-automation.api.mdx

Lines changed: 2 additions & 2 deletions
Large diffs are not rendered by default.

docs/api-reference/create-a-blueprint.api.mdx

Lines changed: 3 additions & 3 deletions
Large diffs are not rendered by default.

0 commit comments

Comments
 (0)