Skip to content

Commit

Permalink
fix: Resolve type discrepancies between docs and sample Card data.
Browse files Browse the repository at this point in the history
  • Loading branch information
adam-coster committed Jul 2, 2021
1 parent 3f14158 commit 80b9743
Showing 1 changed file with 20 additions and 31 deletions.
51 changes: 20 additions & 31 deletions src/types/FavroCardTypes.ts
Original file line number Diff line number Diff line change
@@ -1,5 +1,4 @@
import type { DataFavroCardField } from './FavroCustomFieldTypes.js';
import type { OptionFavroTagColor } from './FavroTagTypes.js';
import type { DataFavroCustomFieldLink } from './FavroCustomFieldTypes.js';
import type { OptionWidgetType } from './FavroWidgetTypes.js';

/** {@link https://favro.com/developer/#card-assignment} */
Expand All @@ -8,39 +7,20 @@ interface DataFavroCardAssignment {
completed: boolean;
}

/** {@link https://favro.com/developer/#card-task} */
interface DataFavroCardTask {
name: string;
completed: boolean;
}

/** {@link https://favro.com/developer/#card-custom-fields} */
interface DataFavroCardCustomField {
customFieldId: string;
value: DataFavroCardField;
}

/**
* @note This type has no clear reference in the docs
*
* {@link https://favro.com/developer/#card-tasklist}
*/
interface DataFavroCardTasklist {
name: string;
tasks: (DataFavroCardTask | string)[];
}

/** {@link https://favro.com/developer/#card-tag} */
interface DataFavroCardTag {
name: string;
color: OptionFavroTagColor;
/** A lot of types seem to just use an ID or array of IDs */
value?: string | string[];
/** If a Link type */
link?: DataFavroCustomFieldLink;
}

/** {@link https://favro.com/developer/#card-attachment} */
interface DataFavroCardAttachment {
name: string;
fileURL: string;
thumbnailURL: string;
thumbnailURL?: string;
}

/** {@link https://favro.com/developer/#card-time-on-board} */
Expand All @@ -61,7 +41,16 @@ interface DataFavroCardFavroAttachment {
type: 'card' | OptionWidgetType;
}

/** {@link https://favro.com/developer/#card} */
/**
* Cards are the key data unit in Favro. The docs are unclear
* about which fields are available in what contexts (they
* refer to "these optional fields" in the docs prior to all
* the params captured below as an interface).
*
* Trial and error will be required to figure it all out!
*
* {@link https://favro.com/developer/#card}
*/
export interface DataFavroCard {
/**
* The id of the card. */
Expand All @@ -72,16 +61,16 @@ export interface DataFavroCard {
/**
* The shared id of the widget that this card exists on.
* Only returned if the card does not exist in a todo list. */
widgetCommonId: string;
widgetCommonId?: string;
/**
* The user id of the user of the todo list that this card exists in.
* Only returned if the card exists in a todo list. Otherwise
* widgetCommonId will be returned. */
todoListUserId: string;
todoListUserId?: string;
/**
* Returns 'true' if the card exists in a todo list and has
* been completed by that user. */
todoListCompleted: boolean;
todoListCompleted?: boolean;
/**
* The id of the Kanban column that this card exists in.
* Only returned if the card exists on a widget. */
Expand Down Expand Up @@ -124,7 +113,7 @@ export interface DataFavroCard {
* The tags that are set on the card.
* TODO: Find out if these are strings or objects
*/
tags: DataFavroCardTag[];
tags: string[];
/**
* The sequentialId of the card. Useful for creating human readable links. */
sequentialId: number;
Expand Down

0 comments on commit 80b9743

Please sign in to comment.