Skip to content

Commit

Permalink
update transforms docs
Browse files Browse the repository at this point in the history
  • Loading branch information
vordimous committed Sep 17, 2024
1 parent 663d160 commit 7bfcf37
Show file tree
Hide file tree
Showing 6 changed files with 46 additions and 22 deletions.
7 changes: 7 additions & 0 deletions .check-schema/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -27,6 +27,7 @@ const main = async () => {
if (i.enum) type = "`enum`" + ` [ ${i.enum.map((e) => ("`" + e + "`")).join(", ")} ]`;
if (i.items?.enum) type = `${"`array`"}${i.items.enum ? " of `enum`" + ` [ ${i.items.enum.map((e) => ("`" + e + "`")).join(", ")} ]` : ""}`;
else if (i.items) type = `${"`array`"}${(i.items.type ? " of `" + (i.items.type) + "`" : "")}`;
// else if (i.oneOf?.filter(({ items }) => items?.length).length) type = "`array` of `object`";
if (patternProperties) type = OBJECT_MAP_TYPE + type;
return type;
}
Expand Down Expand Up @@ -149,6 +150,12 @@ const main = async () => {
.forEach(({ properties, required }) =>
props.push(...getObjProps(k, properties, [...(i.required || []), ...(required || [])]))
);
var oneOfItems = i.oneOf?.filter(({ items }) => items?.length)
?.reduce((a, b) => ([ ...a, ...b.items ]), []);
if (oneOfItems?.length) {
props.push(...getObjProps(`${k}[]`, oneOfItems.reduce((a, b) => ({ ...a, ...b.properties }), {}), []))
}

i.additionalProperties?.oneOf?.filter(({ properties }) => !!properties)
.forEach(({ properties, required }) =>
props.push(...getObjProps(k, properties, required))
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,35 @@
#### topics[].transforms

> `array`
Extract key or value attributes from the typed Kafka message to apply to the Kafka message id or Kafka headers. The `extract-key` property must come before the `extract-headers` property if they both exist.

```yaml
transforms:
- extract-key: ${message.key.id}
```
```yaml
transforms:
- extract-headers:
my-kafka-header: ${message.value.test}
```
```yaml
transforms:
- extract-key: ${message.value.id}
- extract-headers:
my-kafka-header: ${message.value.test}
```
#### transforms[].extract-key
> `string` | Pattern: `^\\$\\{message\\..(key|value)\\.([A-Za-z_][A-Za-z0-9_]*)\\}$`

Use a part of the Kafka message as the Kafka message key.

#### transforms[].extract-headers

> `object` as map of named `string` properties | Pattern: `^\\$\\{message\\..(key|value)\\.([A-Za-z_][A-Za-z0-9_]*)\\}$`

Use a part of the Kafka message as a Kafka message header.
10 changes: 1 addition & 9 deletions src/reference/config/bindings/asyncapi/client.md
Original file line number Diff line number Diff line change
Expand Up @@ -53,15 +53,7 @@ Topic configuration.

Fetch offset to use for new consumers

#### topics[].transforms

> `array` of `object`

<!-- todo: Dev input -->

#### transforms[].extract-key

> `string` | Pattern: `^\\$\\{message\\..(key|value)\\.([A-Za-z_][A-Za-z0-9_]*)\\}$`
<!-- @include: ../.partials/options-kafka-topics-transforms.md -->

#### transforms[].extract-headers

Expand Down
6 changes: 1 addition & 5 deletions src/reference/config/bindings/asyncapi/proxy.md
Original file line number Diff line number Diff line change
Expand Up @@ -53,11 +53,7 @@ Topic configuration.

Fetch offset to use for new consumers

#### topics[].transforms

> `array`

<!-- todo: Dev input -->
<!-- @include: ../.partials/options-kafka-topics-transforms.md -->

#### kafka.sasl

Expand Down
6 changes: 1 addition & 5 deletions src/reference/config/bindings/asyncapi/server.md
Original file line number Diff line number Diff line change
Expand Up @@ -53,11 +53,7 @@ Topic configuration.

Fetch offset to use for new consumers

#### topics[].transforms

> `array`

<!-- todo: Dev input -->
<!-- @include: ../.partials/options-kafka-topics-transforms.md -->

#### kafka.sasl

Expand Down
4 changes: 1 addition & 3 deletions src/reference/config/bindings/kafka/cache_server.md
Original file line number Diff line number Diff line change
Expand Up @@ -48,9 +48,7 @@ Topic configuration.

Fetch offset to use for new consumers

#### topics[].transforms

> `array`
<!-- @include: ../.partials/options-kafka-topics-transforms.md -->

<!-- @include: ./.partials/routes.md -->
<!-- @include: ../.partials/exit.md -->
Expand Down

0 comments on commit 7bfcf37

Please sign in to comment.