Skip to content

Commit

Permalink
chore: Updates ContextMenuData to be app-specific
Browse files Browse the repository at this point in the history
  • Loading branch information
scottlovegrove committed Nov 7, 2022
1 parent c783e84 commit cd39634
Show file tree
Hide file tree
Showing 3 changed files with 79 additions and 47 deletions.
50 changes: 3 additions & 47 deletions packages/ui-extensions-core/src/types/data-exchange.ts
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
import type { DoistCard } from '../doist-card'
import type { DoistCardBridge } from './bridges'
import type { TodoistContext, TodoistContextMenuSource } from './todoist'
import type { TwistContext, TwistContextMenuSource } from './twist'
import type { TodoistContext, TodoistContextMenuData } from './todoist'
import type { TwistContext, TwistContextMenuData } from './twist'

/**
* The types of actions that an adaptive card integration can request.
Expand Down Expand Up @@ -34,51 +34,7 @@ export type DoistCardExtensionType = 'composer' | 'context-menu' | `settings`
* `params` field of the `DoistCardAction`. This type will allow you to
* cast that data to something specific.
*/
export type ContextMenuData = {
/**
* The deep link back to the source
*/
url: string
/**
* The id of the source object
*/
sourceId: number | string
/**
* The content that has been sent with the request. This could be
* a conversation message, thread comment, or thread title
*/
content: string
/**
* The content that has been sent with the request. This could be
* a conversation message, thread comment, or thread title, only this
* has been scrubbed of all markdown formatting.
*/
contentPlain: string
} & (
| {
/**
* The source that made the request to the extension
*/
source: TwistContextMenuSource
/**
* The date the content was posted. For threads, this will be the
* date the thread was created.
*/
postedDate: Date
}
| {
/**
* The source that made the request to the extension
*/
source: TodoistContextMenuSource

/**
* The date the content was posted. For projects, this will be null.
* For tasks this will be the date the task was created.
*/
postedDate?: Date
}
)
export type ContextMenuData = TodoistContextMenuData | TwistContextMenuData

/**
* Represents an action that the user has done on the client.
Expand Down
38 changes: 38 additions & 0 deletions packages/ui-extensions-core/src/types/todoist.ts
Original file line number Diff line number Diff line change
Expand Up @@ -30,4 +30,42 @@ export type TodoistContext = {
}
}

/**
* When a context menu extension is triggered, the data will be sent in the
* `params` field of the `DoistCardAction`. This type will allow you to
* cast that data to something specific.
*/
export type TodoistContextMenuData = {
/**
* The deep link back to the source
*/
url: string
/**
* The id of the source object
*/
sourceId: string
/**
* The content that has been sent with the request. This could be
* a conversation message, thread comment, or thread title
*/
content: string
/**
* The content that has been sent with the request. This could be
* a conversation message, thread comment, or thread title, only this
* has been scrubbed of all markdown formatting.
*/
contentPlain: string

/**
* The source that made the request to the extension
*/
source: TodoistContextMenuSource

/**
* The date the content was posted. For projects, this will be null.
* For tasks this will be the date the task was created.
*/
postedDate?: Date
}

export type TodoistContextMenuSource = 'project' | 'task'
38 changes: 38 additions & 0 deletions packages/ui-extensions-core/src/types/twist.ts
Original file line number Diff line number Diff line change
Expand Up @@ -54,3 +54,41 @@ export type TwistContextMessage = TwistMessage
export type TwistContextComment = TwistMessage

export type TwistContextMenuSource = 'message' | 'thread' | 'comment'

/**
* When a context menu extension is triggered, the data will be sent in the
* `params` field of the `DoistCardAction`. This type will allow you to
* cast that data to something specific.
*/
export type TwistContextMenuData = {
/**
* The deep link back to the source
*/
url: string
/**
* The id of the source object
*/
sourceId: number
/**
* The content that has been sent with the request. This could be
* a conversation message, thread comment, or thread title
*/
content: string
/**
* The content that has been sent with the request. This could be
* a conversation message, thread comment, or thread title, only this
* has been scrubbed of all markdown formatting.
*/
contentPlain: string

/**
* The source that made the request to the extension
*/
source: TwistContextMenuSource

/**
* The date the content was posted. For threads, this will be the
* date the thread was created.
*/
postedDate: Date
}

0 comments on commit cd39634

Please sign in to comment.