From 325fd3a8f5e9c5ae300edaab6158466931f37650 Mon Sep 17 00:00:00 2001 From: Guilherme Gazzo Date: Tue, 25 Jun 2024 19:27:44 -0300 Subject: [PATCH 1/4] use LayoutBlock instead of Block --- src/definition/messages/IMessage.ts | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/src/definition/messages/IMessage.ts b/src/definition/messages/IMessage.ts index afbc21b86..d7ea63574 100644 --- a/src/definition/messages/IMessage.ts +++ b/src/definition/messages/IMessage.ts @@ -1,4 +1,4 @@ -import type { Block } from '@rocket.chat/ui-kit'; +import type { LayoutBlock } from '@rocket.chat/ui-kit'; import type { IRoom } from '../rooms'; import type { IBlock } from '../uikit'; @@ -26,7 +26,7 @@ export interface IMessage { groupable?: boolean; parseUrls?: boolean; customFields?: { [key: string]: any }; - blocks?: Array; + blocks?: Array; starred?: Array<{ _id: string }>; pinned?: boolean; pinnedAt?: Date; From 735984f7acd227b09a4d036df45ee87f51a30eef Mon Sep 17 00:00:00 2001 From: Guilherme Gazzo Date: Tue, 25 Jun 2024 19:33:26 -0300 Subject: [PATCH 2/4] .. --- src/server/accessors/MessageBuilder.ts | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/src/server/accessors/MessageBuilder.ts b/src/server/accessors/MessageBuilder.ts index e10bb9fac..91b865728 100644 --- a/src/server/accessors/MessageBuilder.ts +++ b/src/server/accessors/MessageBuilder.ts @@ -1,4 +1,4 @@ -import type { Block } from '@rocket.chat/ui-kit'; +import type { LayoutBlock } from '@rocket.chat/ui-kit'; import type { IMessageBuilder } from '../../definition/accessors'; import type { IMessage, IMessageAttachment } from '../../definition/messages'; @@ -177,7 +177,7 @@ export class MessageBuilder implements IMessageBuilder { return this.msg; } - public addBlocks(blocks: BlockBuilder | Array) { + public addBlocks(blocks: BlockBuilder | Array) { if (!Array.isArray(this.msg.blocks)) { this.msg.blocks = []; } @@ -191,7 +191,7 @@ export class MessageBuilder implements IMessageBuilder { return this; } - public setBlocks(blocks: BlockBuilder | Array) { + public setBlocks(blocks: BlockBuilder | Array) { if (blocks instanceof BlockBuilder) { this.msg.blocks = blocks.getBlocks(); } else { From fc5cef5a41a6f9069ddb75635a9485c27fb9ef9d Mon Sep 17 00:00:00 2001 From: Guilherme Gazzo Date: Tue, 25 Jun 2024 19:39:48 -0300 Subject: [PATCH 3/4] .. --- src/definition/uikit/IUIKitSurface.ts | 4 ++-- src/server/misc/UIHelper.ts | 6 +++--- 2 files changed, 5 insertions(+), 5 deletions(-) diff --git a/src/definition/uikit/IUIKitSurface.ts b/src/definition/uikit/IUIKitSurface.ts index c0ea164b6..61bd1bf33 100644 --- a/src/definition/uikit/IUIKitSurface.ts +++ b/src/definition/uikit/IUIKitSurface.ts @@ -1,4 +1,4 @@ -import type { Block, ButtonElement, TextObject } from '@rocket.chat/ui-kit'; +import type { ButtonElement, LayoutBlock, TextObject } from '@rocket.chat/ui-kit'; import type { IBlock, IButtonElement, ITextObject } from './blocks'; @@ -13,7 +13,7 @@ export interface IUIKitSurface { id: string; type: UIKitSurfaceType; title: ITextObject | TextObject; - blocks: Array; + blocks: Array; close?: IButtonElement | ButtonElement; submit?: IButtonElement | ButtonElement; state?: object; diff --git a/src/server/misc/UIHelper.ts b/src/server/misc/UIHelper.ts index a6054d2dc..833a22dae 100644 --- a/src/server/misc/UIHelper.ts +++ b/src/server/misc/UIHelper.ts @@ -1,4 +1,4 @@ -import type { Block } from '@rocket.chat/ui-kit'; +import type { LayoutBlock } from '@rocket.chat/ui-kit'; import { v4 as uuid } from 'uuid'; import type { IBlock } from '../../definition/uikit'; @@ -10,8 +10,8 @@ export class UIHelper { * @param appId the appId that will be assigned to * @returns the array of block with the ids properties assigned */ - public static assignIds(blocks: Array, appId: string): Array { - blocks.forEach((block: (IBlock | Block) & { appId?: string; blockId?: string; elements?: Array }) => { + public static assignIds(blocks: Array, appId: string): Array { + blocks.forEach((block: (IBlock | LayoutBlock) & { appId?: string; blockId?: string; elements?: Array }) => { if (!block.appId) { block.appId = appId; } From f9fcc993c95ed4e1309a966506817dd9ed56c713 Mon Sep 17 00:00:00 2001 From: Guilherme Gazzo Date: Tue, 25 Jun 2024 19:49:42 -0300 Subject: [PATCH 4/4] chore: missing typings --- deno-runtime/lib/accessors/builders/MessageBuilder.ts | 6 +++--- src/definition/accessors/IMessageBuilder.ts | 8 ++++---- src/server/messages/Message.ts | 4 ++-- 3 files changed, 9 insertions(+), 9 deletions(-) diff --git a/deno-runtime/lib/accessors/builders/MessageBuilder.ts b/deno-runtime/lib/accessors/builders/MessageBuilder.ts index f01725819..98cd919f7 100644 --- a/deno-runtime/lib/accessors/builders/MessageBuilder.ts +++ b/deno-runtime/lib/accessors/builders/MessageBuilder.ts @@ -1,4 +1,4 @@ -import { Block } from '@rocket.chat/ui-kit'; +import { LayoutBlock } from '@rocket.chat/ui-kit'; import type { IMessageBuilder } from '@rocket.chat/apps-engine/definition/accessors/IMessageBuilder.ts'; import type { RocketChatAssociationModel as _RocketChatAssociationModel } from '@rocket.chat/apps-engine/definition/metadata/RocketChatAssociations.ts'; @@ -184,7 +184,7 @@ export class MessageBuilder implements IMessageBuilder { return this.msg; } - public addBlocks(blocks: BlockBuilder | Array) { + public addBlocks(blocks: BlockBuilder | Array) { if (!Array.isArray(this.msg.blocks)) { this.msg.blocks = []; } @@ -198,7 +198,7 @@ export class MessageBuilder implements IMessageBuilder { return this as IMessageBuilder; } - public setBlocks(blocks: BlockBuilder | Array) { + public setBlocks(blocks: BlockBuilder | Array) { if (blocks instanceof BlockBuilder) { this.msg.blocks = blocks.getBlocks(); } else { diff --git a/src/definition/accessors/IMessageBuilder.ts b/src/definition/accessors/IMessageBuilder.ts index c02760f2e..024a4b123 100644 --- a/src/definition/accessors/IMessageBuilder.ts +++ b/src/definition/accessors/IMessageBuilder.ts @@ -1,4 +1,4 @@ -import type { Block } from '@rocket.chat/ui-kit'; +import type { LayoutBlock } from '@rocket.chat/ui-kit'; import type { IMessage, IMessageAttachment } from '../messages'; import type { RocketChatAssociationModel } from '../metadata'; @@ -210,19 +210,19 @@ export interface IMessageBuilder { * Adds a block collection to the message's * own collection */ - addBlocks(blocks: BlockBuilder | Array): IMessageBuilder; + addBlocks(blocks: BlockBuilder | Array): IMessageBuilder; /** * Sets the block collection of the message * * @param blocks */ - setBlocks(blocks: BlockBuilder | Array): IMessageBuilder; + setBlocks(blocks: BlockBuilder | Array): IMessageBuilder; /** * Gets the block collection of the message */ - getBlocks(): Array; + getBlocks(): Array; /** * Adds a custom field to the message. diff --git a/src/server/messages/Message.ts b/src/server/messages/Message.ts index 2993181f7..b4c020259 100644 --- a/src/server/messages/Message.ts +++ b/src/server/messages/Message.ts @@ -1,4 +1,4 @@ -import type { Block } from '@rocket.chat/ui-kit'; +import type { LayoutBlock } from '@rocket.chat/ui-kit'; import type { IMessage, IMessageAttachment, IMessageFile, IMessageReactions } from '../../definition/messages'; import type { IUser, IUserLookup } from '../../definition/users'; @@ -40,7 +40,7 @@ export class Message implements IMessage { public file?: IMessageFile; - public blocks?: Array; + public blocks?: Array; public starred?: Array<{ _id: string }>;