Base class for all Shortcut resources. Provides methods for creating, updating, and deleting resources.

Remarks

Related: StoriesService for the service managing stories.

Story

Hierarchy (view full)

Implements

Constructors

Properties

_labels: Label[] = []
appUrl: string
archived: boolean
availableOperations: ResourceOperation[] = ...

The available operations for the resource, any not in this list will raise an error when called

blocked: boolean
blocker: boolean
branches: object[]
changedFields: string[] = []

Fields that have been changed, used to determine what to update. It is not recommended to access this property directly.

comments: default[]
commits: object[]
completed: boolean
completedAt: null | Date
completedAtOverride: null | Date
createFields: string[] = []

Fields that are used when creating a new resource

createdAt: Date
customFields: default[]
deadline: null | Date
description: string
entityType: string
epicId: null | number
estimate: null | number
externalId: null | string
externalLinks: string[]
files: object[]
followerIds: string[]
groupId: null | string
groupMentionIds: string[]
id: number
iterationId: null | number
labelIds: number[]
leadTime: number
linkedFiles: object[]
memberMentionIds: string[]
mentionIds: string[]
movedAt: null | Date
name: string
ownerIds: string[]
position: number
previousIterationIds: number[]
projectId: null | number
pullRequests: PullRequestInterface[]
requestedById: string
service: BaseService<BaseResource<default>, default> | BaseSearchableService<BaseResource<default>, default>
started: boolean
startedAt: null | Date
startedAtOverride: null | Date
stats: object
storyLinks: default[]
storyTemplateId: null | string
storyType: string
syncedItem: object
tasks: default[]
unresolvedBlockerComments: number[]
updatedAt: null | Date
workflowId: number
workflowStateId: number
baseUrl: string = 'https://api.app.shortcut.com/api/v3/stories'

Accessors

  • get labels(): Label[]
  • Returns Label[]

  • set labels(labels): void
  • Set the labels associated with the story. In order for creating/updating of stories to work properly with labels, you must set the labels to a new array of labels, rather than modifying the existing array. This allows the Story class to track changes to the labels.

    Parameters

    Returns void

  • get team(): null | Promise<Team>
  • Get the team assigned to the story, labelled as "Group" in the Shortcut API

    Returns null | Promise<Team>

  • get workflow(): Promise<WorkflowStateInterface>
  • Returns Promise<WorkflowStateInterface>

Methods

  • This method can be overridden by derived classes to perform any necessary operations before saving the resource

    Returns Promise<void>

  • Adds a subtask to the story, these are visible in Shortcut as a to-do list of items that need to be completed.

    Parameters

    • task: string

    Returns Promise<void>

  • Provide a story or story ID to indicate that this work blocks another story from being ready to start.

    Parameters

    Returns Promise<void>

  • Parameters

    • comment: string

    Returns Promise<default>

  • Create a new instance of the resource, using the current object's properties. Use the xCreateData interface to determine which fields are available for creation.

    Returns Promise<Story>

    • A Promise that resolves with the newly created instance.

    Throws

    • Throws an error if the HTTP request fails.
  • Calculates the cycle time of a story in hours.

    Returns number

    • The cycle time in hours.

    Throws

    • If the story is not completed or has not been started.
  • Delete the current instance of the resource.

    Returns Promise<void>

    • A Promise that resolves when the resource has been deleted.

    Throws

    • Throws an error if the HTTP request fails.
  • Provide a story or story ID to indicate that this story is duplicative of another story.

    Parameters

    Returns Promise<void>

  • Provide a story or story ID to indicate that this story is related to another story.

    Parameters

    Returns Promise<void>

  • Save the current instance of the resource. If the resource already exists (has an ID), it will be updated. Otherwise, it will be created using the fields createFields.

    Returns Promise<void>

  • Get the state of the story, i.e. Finished, Started, Unstarted

    Returns Promise<WorkflowStateType>

  • Calculates the time a story has been in development in hours.

    Returns Promise<number>

    • The time in development in hours.

    Throws

    • If the story is already finished or not started.
  • Update the current instance of the resource with the changed fields.

    Returns Promise<void>

    • A Promise that resolves when the resource has been updated.

    Throws

    • Throws an error if the HTTP request fails.
  • Get the history of workflow changes for the story as a flat array. See FlatHistory for the structure of the flat history. This is useful for making calculations or determining when specific events occurred as it reduces the complexity of the history data. Note however that there is additional network overhead in fetching the history data. There is an initial request to fetch all workflow history, and each subsequent Member is fetched individually.

    Returns Promise<FlatHistory[]>