style: apply prettier to chat-sdk-bridge card branch
This commit is contained in:
@@ -15,10 +15,7 @@ interface PostCall {
|
|||||||
|
|
||||||
function makePostCapture() {
|
function makePostCapture() {
|
||||||
const calls: PostCall[] = [];
|
const calls: PostCall[] = [];
|
||||||
const postMessage = async (
|
const postMessage = async (threadId: string, message: AdapterPostableMessage): Promise<RawMessage<unknown>> => {
|
||||||
threadId: string,
|
|
||||||
message: AdapterPostableMessage,
|
|
||||||
): Promise<RawMessage<unknown>> => {
|
|
||||||
calls.push({ threadId, message });
|
calls.push({ threadId, message });
|
||||||
return { id: 'msg-stub', threadId, raw: {} };
|
return { id: 'msg-stub', threadId, raw: {} };
|
||||||
};
|
};
|
||||||
|
|||||||
@@ -407,11 +407,7 @@ export function createChatSdkBridge(config: ChatSdkBridgeConfig): ChannelAdapter
|
|||||||
if (content.type === 'card' && content.card && typeof content.card === 'object') {
|
if (content.type === 'card' && content.card && typeof content.card === 'object') {
|
||||||
const cardSpec = content.card as Record<string, unknown>;
|
const cardSpec = content.card as Record<string, unknown>;
|
||||||
const title = (cardSpec.title as string) || '';
|
const title = (cardSpec.title as string) || '';
|
||||||
const fallbackText =
|
const fallbackText = (content.fallbackText as string) || (cardSpec.description as string) || title || '';
|
||||||
(content.fallbackText as string) ||
|
|
||||||
(cardSpec.description as string) ||
|
|
||||||
title ||
|
|
||||||
'';
|
|
||||||
|
|
||||||
const cardChildren: CardChild[] = [];
|
const cardChildren: CardChild[] = [];
|
||||||
if (typeof cardSpec.description === 'string' && cardSpec.description) {
|
if (typeof cardSpec.description === 'string' && cardSpec.description) {
|
||||||
@@ -432,15 +428,11 @@ export function createChatSdkBridge(config: ChatSdkBridgeConfig): ChannelAdapter
|
|||||||
}
|
}
|
||||||
if (Array.isArray(cardSpec.actions)) {
|
if (Array.isArray(cardSpec.actions)) {
|
||||||
const linkButtons = (cardSpec.actions as Array<Record<string, unknown>>)
|
const linkButtons = (cardSpec.actions as Array<Record<string, unknown>>)
|
||||||
.filter(
|
.filter((a) => typeof a.url === 'string' && a.url && typeof a.label === 'string' && a.label)
|
||||||
(a) => typeof a.url === 'string' && a.url && typeof a.label === 'string' && a.label,
|
|
||||||
)
|
|
||||||
.map((a) => {
|
.map((a) => {
|
||||||
const style = a.style;
|
const style = a.style;
|
||||||
const safeStyle: 'primary' | 'danger' | 'default' | undefined =
|
const safeStyle: 'primary' | 'danger' | 'default' | undefined =
|
||||||
style === 'primary' || style === 'danger' || style === 'default'
|
style === 'primary' || style === 'danger' || style === 'default' ? style : undefined;
|
||||||
? style
|
|
||||||
: undefined;
|
|
||||||
return LinkButton({
|
return LinkButton({
|
||||||
label: a.label as string,
|
label: a.label as string,
|
||||||
url: a.url as string,
|
url: a.url as string,
|
||||||
|
|||||||
Reference in New Issue
Block a user