diff --git a/packages/sdk/src/dialect-cloud-api/data-service-dialects-api.ts b/packages/sdk/src/dialect-cloud-api/data-service-dialects-api.ts index c78cd6a2..6bab0288 100644 --- a/packages/sdk/src/dialect-cloud-api/data-service-dialects-api.ts +++ b/packages/sdk/src/dialect-cloud-api/data-service-dialects-api.ts @@ -4,6 +4,7 @@ import { withReThrowingDataServiceError, } from './data-service-api'; import axios from 'axios'; +import type { SmartMessageDto } from './smart-message.dto'; export interface DataServiceDialectsApi { create(command: CreateDialectCommand): Promise; @@ -263,6 +264,7 @@ export class MessageMetadataDto { title?: string; tags?: string[]; actions?: MessageActionDto[]; + smartMessage?: SmartMessageDto; notificationTypeId?: string; } diff --git a/packages/sdk/src/dialect-cloud-api/smart-message-spec.dto.ts b/packages/sdk/src/dialect-cloud-api/smart-message-spec.dto.ts new file mode 100644 index 00000000..72eaffbe --- /dev/null +++ b/packages/sdk/src/dialect-cloud-api/smart-message-spec.dto.ts @@ -0,0 +1,89 @@ +export enum SmartMessageStateDto { + Created = 'CREATED', + ReadyForExecution = 'READY_FOR_EXECUTION', + Executing = 'EXECUTING', + Succeeded = 'SUCCEEDED', + Failed = 'FAILED', + Canceled = 'CANCELED', +} + +export enum ActionType { + SignTransaction = 'SIGN_TRANSACTION', + OpenLink = 'OPEN_LINK', + Cancel = 'CANCEL', // cancel without a transaction, in other words a noop +} + +export class SmartMessageButtonLayoutElementDto { + type!: 'button'; + text!: string; + action!: SmartMessageSpecActionDto; +} + +export class SmartMessageLabelLayoutElementDto { + type!: 'label'; + text!: string; +} + +export class SmartMessageSpecOpenLinkActionDto { + type!: ActionType.OpenLink; + link!: string; +} + +export class SmartMessageSpecSignTransactionActionDto { + humanReadableId!: string; + type!: ActionType.SignTransaction; +} + +export class SmartMessageSpecCancelActionDto { + humanReadableId!: string; + type!: ActionType.Cancel; +} + +export type SmartMessageSpecActionDto = + | SmartMessageSpecOpenLinkActionDto + | SmartMessageSpecSignTransactionActionDto + | SmartMessageSpecCancelActionDto; + +export type SmartMessageLayoutElementDto = + | SmartMessageButtonLayoutElementDto + | SmartMessageLabelLayoutElementDto; + +export class SmartMessageLayoutDto { + icon!: string | null; + description!: string | null; + header!: string | null; + subheader!: string | null; + elements!: SmartMessageLayoutElementDto[][]; +} + +export class SmartMessageContentDto { + state!: SmartMessageStateDto; + layout!: SmartMessageLayoutDto; +} + +export class SmartMessagePreviewParamsDto { + state!: SmartMessageStateDto; +} + +export class SmartMessageSystemParamsDto { + state!: SmartMessageStateDto; + workflowStateHumanReadableId!: string; + createdByWalletAddress!: string; + principalWalletAddress!: string; + updatedByWalletAddress!: string; +} + +export class CreateSmartMessageTransactionCommandDto { + account!: string; + actionHumanReadableId!: string; +} + +export class SmartMessageTransactionDto { + transaction!: string; + message?: string; +} + +export class SubmitSmartMessageTransactionCommandDto { + readonly transaction!: string; + readonly actionHumanReadableId!: string; +} diff --git a/packages/sdk/src/dialect-cloud-api/smart-message.dto.ts b/packages/sdk/src/dialect-cloud-api/smart-message.dto.ts new file mode 100644 index 00000000..cea26d97 --- /dev/null +++ b/packages/sdk/src/dialect-cloud-api/smart-message.dto.ts @@ -0,0 +1,6 @@ +import type { SmartMessageContentDto } from './smart-message-spec.dto'; + +export class SmartMessageDto { + id!: string; + content!: SmartMessageContentDto; +} diff --git a/packages/sdk/src/messaging/messaging.interface.ts b/packages/sdk/src/messaging/messaging.interface.ts index d2e23703..73b6fdbd 100644 --- a/packages/sdk/src/messaging/messaging.interface.ts +++ b/packages/sdk/src/messaging/messaging.interface.ts @@ -1,4 +1,5 @@ import type { AccountAddress } from '../auth/auth.interface'; +import type { SmartMessageDto } from '../dialect-cloud-api/smart-message.dto'; export interface Messaging { type: string; @@ -45,6 +46,7 @@ export interface MessageMetadata { title?: string; // tags?: string[]; actions?: MessageAction[]; + smartMessage?: SmartMessageDto; notificationTypeId?: string; notificationTypeHumanReadableId?: string; }