Skip to content

Commit 42cc73d

Browse files
docs: update spectrum-ts documentation for v3.1.0 (#84)
Co-authored-by: github-actions[bot] <41898282+github-actions[bot]@users.noreply.github.com>
1 parent ce08b7f commit 42cc73d

3 files changed

Lines changed: 30 additions & 6 deletions

File tree

docs-src/spectrum-ts/custom-platforms.mdx.vel

Lines changed: 24 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -107,6 +107,30 @@ export const myPlatform = definePlatform("my-platform", {
107107
| `message.schema` | No | Zod schema for extra properties on incoming messages. |
108108
| `static` | No | Constants attached to the platform object (e.g. tapback names). |
109109

110+
## Message direction
111+
112+
Records yielded from `messages` are wrapped as inbound, and records returned from `send` are wrapped as outbound. When a provider knows the actual direction of a record, it can set `direction` on the raw record and Spectrum will use it instead of the wrapping context:
113+
114+
```ts
115+
yield {
116+
id: reactionEvent.id,
117+
content: {
118+
type: "reaction",
119+
emoji: reactionEvent.emoji,
120+
target: {
121+
id: reactionEvent.targetId,
122+
content: { type: "text", text: reactionEvent.targetText },
123+
direction: "outbound",
124+
space: { id: reactionEvent.channelId },
125+
},
126+
},
127+
sender: { id: reactionEvent.userId },
128+
space: { id: reactionEvent.channelId },
129+
};
130+
```
131+
132+
This matters for nested records like reaction targets: the outer reaction is inbound (someone reacted) but the target may be outbound (they reacted to a message you sent). Without `direction`, nested targets default to the outer record's direction.
133+
110134
## Event producers
111135

112136
Every event generator receives `{ client, config, store }` and returns an `AsyncIterable`. The signature is <TypeTooltip name="EventProducer" type={`{{ ep.signature }}`} />.

package.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -28,7 +28,7 @@
2828
"eslint-plugin-format": "^2.0.1",
2929
"husky": "^9.1.7",
3030
"oxfmt": "^0.44.0",
31-
"spectrum-ts": "3.0.0",
31+
"spectrum-ts": "3.1.0",
3232
"tsx": "^4.21.0",
3333
"typescript": "^5.9.3"
3434
}

pnpm-lock.yaml

Lines changed: 5 additions & 5 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

0 commit comments

Comments
 (0)