Releases: xmtp/xmtp-js
@xmtp/agent-sdk@2.2.0
Minor Changes
- da8658f: Added transaction utility functions
@xmtp/cli@0.1.0
Rebuilt CLI using oclif.
@xmtp/agent-sdk@2.1.0
Minor Changes
- 126833a: Added PerformanceMonitor middleware
@xmtp/node-sdk@5.3.0
Added contentType field to enriched replies.
type EnrichedReply<T = unknown, U = unknown> = {
referenceId: string;
content: T;
contentType: ContentTypeId | undefined;
inReplyTo: DecodedMessage<U> | null;
};Use this new field to get the content type of a reply's content.
import { encodeText, contentTypeText } from "@xmtp/node-sdk";
const textMessageId = await group.sendText("hi");
const replyMessageId = await group.sendReply({
content: encodeText("hello"),
reference: textMessageId,
});
const reply: DecodedMessage<EnrichedReply> =
client.conversations.getMessageById(replyMessageId);
// access reply's content type
expect(reply.content.contentType).toEqual(contentTypeText());@xmtp/cli@0.0.6
Patch Changes
- Updated dependencies [a87b56b]
- @xmtp/agent-sdk@2.0.2
@xmtp/browser-sdk@6.3.0
Added contentType method to enriched replies.
type EnrichedReply<T = unknown, U = unknown> = {
referenceId: string;
content: T;
contentType: () => Promise<ContentTypeId | undefined>;
inReplyTo: DecodedMessage<U> | null;
};Use this new method to get the content type of a reply's content.
import { encodeText, contentTypeText } from "@xmtp/browser-sdk";
const textMessageId = await group.sendText("hi");
const replyMessageId = await group.sendReply({
content: await encodeText("hello"),
reference: textMessageId,
});
const reply: DecodedMessage<EnrichedReply> =
await client.conversations.getMessageById(replyMessageId);
// access reply's content type
expect(await reply.content.contentType()).toEqual(await contentTypeText());@xmtp/agent-sdk@2.0.2
Patch Changes
- a87b56b: Added help command configuration to CommandRouter middleware
@xmtp/cli@0.0.5
Patch Changes
- Updated dependencies [e100655]
- @xmtp/agent-sdk@2.0.1
@xmtp/agent-sdk@2.0.1
Patch Changes
- e100655: Added native events from Node SDK
@xmtp/node-sdk@5.2.0
This release introduces new features and critical bug fixes. If you've been building on a previous release, this one should be a drop-in replacement. Update as soon as possible to take advantage of these enhancements and fixes.
Message type guards
New utility functions have been added to help identify message content types. These type guards provide a convenient way to check message types and narrow TypeScript types when working with decoded messages.
import {
isText,
isMarkdown,
isReaction,
isReply,
isTextReply,
isAttachment,
isRemoteAttachment,
isMultiRemoteAttachment,
isTransactionReference,
isReadReceipt,
isGroupUpdated,
isWalletSendCalls,
isActions,
isIntent,
} from "@xmtp/node-sdk";
const messages = await group.messages();
for (const message of messages) {
if (isText(message)) {
// message.content is narrowed to string
console.log(message.content);
}
if (isReaction(message)) {
// message.content is narrowed to Reaction
console.log(message.content.content);
}
if (isTextReply(message)) {
// message.content is narrowed to EnrichedReply<string>
console.log(message.content.content);
}
}Stream deleted messages
The streamMessageDeletions method has been deprecated and will be removed in a future release. Use the new streamDeletedMessages method. This new method streams the entire decoded message of deleted messages rather than just the message ID.
const deletedMessagesStream =
await client.conversations.streamDeletedMessages();
for await (const message of deletedMessagesStream) {
// message is a DecodedMessage
}Improved streaming method types
The return types of streamAllMessages, streamAllGroupMessages, streamAllDmMessages, and stream (for conversations) have been simplified. These methods now return only converted values (DecodedMessage or Group/Dm) instead of a union type that could include raw or undefined values.
Previously, when a streamed value couldn't be converted, the raw value or undefined was returned. Now, unconvertible values are filtered out with a warning logged to the console. This makes the stream output more predictable and type-safe.
Actions and intent content type serialization
The actions and intent content types were not being serialized properly. This release ensures that these content types are backwards-compatible with all clients using these content types.