diff --git a/aha.d.ts b/aha.d.ts deleted file mode 100644 index ca157fc..0000000 --- a/aha.d.ts +++ /dev/null @@ -1,2736 +0,0 @@ -declare namespace Aha { - type AvatarSizeEnum_SIZE_16 = 'SIZE_16'; - type AvatarSizeEnum_SIZE_24 = 'SIZE_24'; - type AvatarSizeEnum_SIZE_32 = 'SIZE_32'; - type AvatarSizeEnum_SIZE_40 = 'SIZE_40'; - type AvatarSizeEnum_SIZE_160 = 'SIZE_160'; - interface AvatarSizeEnumEnum { - values: - | AvatarSizeEnum_SIZE_16 - | AvatarSizeEnum_SIZE_24 - | AvatarSizeEnum_SIZE_32 - | AvatarSizeEnum_SIZE_40 - | AvatarSizeEnum_SIZE_160; - - SIZE_16: EnumValue<'AvatarSizeEnum', AvatarSizeEnum_SIZE_16>; - - SIZE_24: EnumValue<'AvatarSizeEnum', AvatarSizeEnum_SIZE_24>; - - SIZE_32: EnumValue<'AvatarSizeEnum', AvatarSizeEnum_SIZE_32>; - - SIZE_40: EnumValue<'AvatarSizeEnum', AvatarSizeEnum_SIZE_40>; - - SIZE_160: EnumValue<'AvatarSizeEnum', AvatarSizeEnum_SIZE_160>; - } - - type EpicOrder_workflowBoardPosition = 'workflowBoardPosition'; - type EpicOrder_createdAt = 'createdAt'; - type EpicOrder_position = 'position'; - interface EpicOrderEnum { - values: - | EpicOrder_workflowBoardPosition - | EpicOrder_createdAt - | EpicOrder_position; - - workflowBoardPosition: EnumValue< - 'EpicOrder', - EpicOrder_workflowBoardPosition - >; - - createdAt: EnumValue<'EpicOrder', EpicOrder_createdAt>; - - position: EnumValue<'EpicOrder', EpicOrder_position>; - } - - type ExtensionFieldableTypeEnum_EPIC = 'EPIC'; - type ExtensionFieldableTypeEnum_FEATURE = 'FEATURE'; - type ExtensionFieldableTypeEnum_REQUIREMENT = 'REQUIREMENT'; - interface ExtensionFieldableTypeEnumEnum { - values: - | ExtensionFieldableTypeEnum_EPIC - | ExtensionFieldableTypeEnum_FEATURE - | ExtensionFieldableTypeEnum_REQUIREMENT; - - EPIC: EnumValue< - 'ExtensionFieldableTypeEnum', - ExtensionFieldableTypeEnum_EPIC - >; - - FEATURE: EnumValue< - 'ExtensionFieldableTypeEnum', - ExtensionFieldableTypeEnum_FEATURE - >; - - REQUIREMENT: EnumValue< - 'ExtensionFieldableTypeEnum', - ExtensionFieldableTypeEnum_REQUIREMENT - >; - } - - type FeatureOrder_workflowBoardPosition = 'workflowBoardPosition'; - type FeatureOrder_createdAt = 'createdAt'; - type FeatureOrder_position = 'position'; - type FeatureOrder_featureBoardPosition = 'featureBoardPosition'; - interface FeatureOrderEnum { - values: - | FeatureOrder_workflowBoardPosition - | FeatureOrder_createdAt - | FeatureOrder_position - | FeatureOrder_featureBoardPosition; - - workflowBoardPosition: EnumValue< - 'FeatureOrder', - FeatureOrder_workflowBoardPosition - >; - - createdAt: EnumValue<'FeatureOrder', FeatureOrder_createdAt>; - - position: EnumValue<'FeatureOrder', FeatureOrder_position>; - - featureBoardPosition: EnumValue< - 'FeatureOrder', - FeatureOrder_featureBoardPosition - >; - } - - type InternalMeaning_NOT_STARTED = 'NOT_STARTED'; - type InternalMeaning_IN_PROGRESS = 'IN_PROGRESS'; - type InternalMeaning_DONE = 'DONE'; - type InternalMeaning_SHIPPED = 'SHIPPED'; - type InternalMeaning_WONT_DO = 'WONT_DO'; - type InternalMeaning_ALREADY_EXISTS = 'ALREADY_EXISTS'; - interface InternalMeaningEnum { - values: - | InternalMeaning_NOT_STARTED - | InternalMeaning_IN_PROGRESS - | InternalMeaning_DONE - | InternalMeaning_SHIPPED - | InternalMeaning_WONT_DO - | InternalMeaning_ALREADY_EXISTS; - - NOT_STARTED: EnumValue<'InternalMeaning', InternalMeaning_NOT_STARTED>; - - IN_PROGRESS: EnumValue<'InternalMeaning', InternalMeaning_IN_PROGRESS>; - - DONE: EnumValue<'InternalMeaning', InternalMeaning_DONE>; - - SHIPPED: EnumValue<'InternalMeaning', InternalMeaning_SHIPPED>; - - WONT_DO: EnumValue<'InternalMeaning', InternalMeaning_WONT_DO>; - - ALREADY_EXISTS: EnumValue< - 'InternalMeaning', - InternalMeaning_ALREADY_EXISTS - >; - } - - type IterationOrder_startDate = 'startDate'; - interface IterationOrderEnum { - values: IterationOrder_startDate; - - startDate: EnumValue<'IterationOrder', IterationOrder_startDate>; - } - - type OrderDirection_ASC = 'ASC'; - type OrderDirection_DESC = 'DESC'; - interface OrderDirectionEnum { - values: OrderDirection_ASC | OrderDirection_DESC; - - ASC: EnumValue<'OrderDirection', OrderDirection_ASC>; - - DESC: EnumValue<'OrderDirection', OrderDirection_DESC>; - } - - type RecordPlacementEnum_TOP = 'TOP'; - type RecordPlacementEnum_BOTTOM = 'BOTTOM'; - interface RecordPlacementEnumEnum { - values: RecordPlacementEnum_TOP | RecordPlacementEnum_BOTTOM; - - TOP: EnumValue<'RecordPlacementEnum', RecordPlacementEnum_TOP>; - - BOTTOM: EnumValue<'RecordPlacementEnum', RecordPlacementEnum_BOTTOM>; - } - - type ReleaseOrder_featuresBoardOrder = 'featuresBoardOrder'; - interface ReleaseOrderEnum { - values: ReleaseOrder_featuresBoardOrder; - - featuresBoardOrder: EnumValue< - 'ReleaseOrder', - ReleaseOrder_featuresBoardOrder - >; - } - - type RequirementOrder_workflowBoardPosition = 'workflowBoardPosition'; - type RequirementOrder_createdAt = 'createdAt'; - type RequirementOrder_position = 'position'; - interface RequirementOrderEnum { - values: - | RequirementOrder_workflowBoardPosition - | RequirementOrder_createdAt - | RequirementOrder_position; - - workflowBoardPosition: EnumValue< - 'RequirementOrder', - RequirementOrder_workflowBoardPosition - >; - - createdAt: EnumValue<'RequirementOrder', RequirementOrder_createdAt>; - - position: EnumValue<'RequirementOrder', RequirementOrder_position>; - } - - type TaskStatusEnum_PENDING = 'PENDING'; - type TaskStatusEnum_COMPLETE = 'COMPLETE'; - type TaskStatusEnum_APPROVED = 'APPROVED'; - type TaskStatusEnum_APPROVED_CONDITIONALLY = 'APPROVED_CONDITIONALLY'; - type TaskStatusEnum_REJECTED = 'REJECTED'; - type TaskStatusEnum_SKIPPED = 'SKIPPED'; - interface TaskStatusEnumEnum { - values: - | TaskStatusEnum_PENDING - | TaskStatusEnum_COMPLETE - | TaskStatusEnum_APPROVED - | TaskStatusEnum_APPROVED_CONDITIONALLY - | TaskStatusEnum_REJECTED - | TaskStatusEnum_SKIPPED; - - PENDING: EnumValue<'TaskStatusEnum', TaskStatusEnum_PENDING>; - - COMPLETE: EnumValue<'TaskStatusEnum', TaskStatusEnum_COMPLETE>; - - APPROVED: EnumValue<'TaskStatusEnum', TaskStatusEnum_APPROVED>; - - APPROVED_CONDITIONALLY: EnumValue< - 'TaskStatusEnum', - TaskStatusEnum_APPROVED_CONDITIONALLY - >; - - REJECTED: EnumValue<'TaskStatusEnum', TaskStatusEnum_REJECTED>; - - SKIPPED: EnumValue<'TaskStatusEnum', TaskStatusEnum_SKIPPED>; - } - - type WorkUnitEnum_MINUTES = 'MINUTES'; - type WorkUnitEnum_POINTS = 'POINTS'; - interface WorkUnitEnumEnum { - values: WorkUnitEnum_MINUTES | WorkUnitEnum_POINTS; - - MINUTES: EnumValue<'WorkUnitEnum', WorkUnitEnum_MINUTES>; - - POINTS: EnumValue<'WorkUnitEnum', WorkUnitEnum_POINTS>; - } - - type ExtensionFieldableSubjectUnion = - | Account - | Epic - | Feature - | Project - | Requirement - | User; - type RecordUnion = Epic | Feature | Requirement; - type TaskableSubjectUnion = Epic | Feature | Iteration | Requirement; - type CapacityEstimateInterface = Epic | Feature | Requirement; - type ExtensionFieldsInterface = - | Account - | Epic - | Feature - | Project - | Requirement - | User; - type ReferenceInterface = Epic | Feature | Release | Requirement; - type TaskableInterface = Epic | Feature | Iteration | Release | Requirement; - type TimestampsInterface = - | Account - | Epic - | Extension - | ExtensionContribution - | ExtensionField - | ExtensionInvocation - | ExtensionLog - | Feature - | Iteration - | Project - | Release - | Requirement - | Task - | TaskUser - | User - | Workflow - | WorkflowStatus; - type UserAssignableInterface = Epic | Feature | Requirement; - type EpicFilters = { - /** - * Only show epics in active releases - */ - active: boolean; - id: Array; - projectId: string; - releaseId: string; - teamId: string; - iterationId: string; - }; - type ExtensionContributionFilters = { - id: Array; - /** - * Filters contributions by identifier. Example: 'aha-develop.github-import.issues' - */ - identifier: string; - /** - * Filters contributions by contribution type: 'commands', 'endpoints', 'events', 'importers', 'settings', or 'views' - */ - contributes: string; - }; - type ExtensionFieldsFilters = { - name: string; - /** - * The record type that the extension field belongs to. - */ - extensionFieldableType: ExtensionFieldableTypeEnumEnum['values']; - /** - * Finds fields for the extension with the specified ID - */ - extensionId: string; - /** - * Finds fields for the extension with the specified identifier. Example: 'aha-develop.github-import' - */ - extensionIdentifier: string; - }; - type ExtensionLogFilters = { - /** - * Return only log lines after the specified date (in ISO8601 format) - */ - createdSince: string; - extensionId: string; - extensionContributionId: string; - extensionInvocationId: string; - }; - type FeatureFilters = { - /** - * Only show features in active releases - */ - active: boolean; - iterationId: string; - id: Array; - projectId: string; - teamId: string; - releaseId: string; - }; - type IterationFilters = { - projectId: string; - /** - * Limit to iterations in the specified statuses. PLANNING: 10, ACTIVE: 20, COMPLETE: 30 - */ - status: Array; - }; - type ReleaseFilters = { - id: Array; - projectId: string; - /** - * Only return active releases - */ - active: boolean; - }; - type RequirementFilters = { - /** - * Only show requirements in active releases - */ - active: boolean; - id: Array; - releaseId: string; - projectId: string; - teamId: string; - iterationId: string; - }; - type TagFilters = { - id: Array; - }; - type UserFilters = { - projectId: string; - id: Array; - }; - /** - * Attributes for Account - * @category Aha! Model Attributes - */ - interface AccountAttributes { - readonly createdAt: string; - readonly id: string; - readonly updatedAt: string; - /** - * Additional data stored by extensions - */ - - readonly extensionFields: Array; - } - - type AccountQuery = Query; - - /** - * Account Aha! model - * - * An Aha! account - * - * Instance type: [[Account]] - * - * @category Aha! Model - */ - interface AccountConstructor { - typename: 'Account'; - - select(names: F[]): AccountQuery; - - select(...names: F[]): AccountQuery; - - blank(attrs: AccountAttributes): Account; - - new (attributes?: Partial): Account; - } - - /** - * Account Aha! model - * - * An Aha! account - * - * Constructor: [[AccountConstructor]] - * - * @category Aha! Model Instance - */ - interface Account - extends ApplicationModel, - AccountAttributes, - HasExtensionFields { - readonly typename: 'Account'; - - readonly query: AccountQuery; - - attributes: AccountAttributes; - } - - /** - * Attributes for BookmarksRecordPosition - * @category Aha! Model Attributes - */ - interface BookmarksRecordPositionAttributes { - /** - * The type of bookmark this position applies to. For example: 'Iteration', 'Bookmarks::WorkflowBoard' - */ - - bookmarkType: string; - readonly id: string; - /** - * The position of the record. Smaller / more negative is higher. - */ - - readonly position: number; - recordId: string; - recordType: string; - } - - type BookmarksRecordPositionQuery = Query; - - /** - * BookmarksRecordPosition Aha! model - * - * The position of a record in a specific bookmark type. This is used to sort records in different ways when they belong to different views. - * - * Instance type: [[BookmarksRecordPosition]] - * - * @category Aha! Model - */ - interface BookmarksRecordPositionConstructor { - typename: 'BookmarksRecordPosition'; - - select( - names: F[] - ): BookmarksRecordPositionQuery; - - select( - ...names: F[] - ): BookmarksRecordPositionQuery; - - blank(attrs: BookmarksRecordPositionAttributes): BookmarksRecordPosition; - - new ( - attributes?: Partial - ): BookmarksRecordPosition; - } - - /** - * BookmarksRecordPosition Aha! model - * - * The position of a record in a specific bookmark type. This is used to sort records in different ways when they belong to different views. - * - * Constructor: [[BookmarksRecordPositionConstructor]] - * - * @category Aha! Model Instance - */ - interface BookmarksRecordPosition - extends ApplicationModel, - BookmarksRecordPositionAttributes { - readonly typename: 'BookmarksRecordPosition'; - - readonly query: BookmarksRecordPositionQuery; - - attributes: BookmarksRecordPositionAttributes; - } - - /** - * Attributes for BookmarksTeamBacklog - * @category Aha! Model Attributes - */ - interface BookmarksTeamBacklogAttributes { - readonly id: string; - /** - * The project / team this backlog applies to - */ - - readonly projectId: string; - readonly records: Array; - } - - type BookmarksTeamBacklogQuery = Query; - - /** - * BookmarksTeamBacklog Aha! model - * - * A reorderable backlog for a team - * - * Instance type: [[BookmarksTeamBacklog]] - * - * @category Aha! Model - */ - interface BookmarksTeamBacklogConstructor { - typename: 'BookmarksTeamBacklog'; - - select( - names: F[] - ): BookmarksTeamBacklogQuery; - - select( - ...names: F[] - ): BookmarksTeamBacklogQuery; - - blank(attrs: BookmarksTeamBacklogAttributes): BookmarksTeamBacklog; - - new ( - attributes?: Partial - ): BookmarksTeamBacklog; - } - - /** - * BookmarksTeamBacklog Aha! model - * - * A reorderable backlog for a team - * - * Constructor: [[BookmarksTeamBacklogConstructor]] - * - * @category Aha! Model Instance - */ - interface BookmarksTeamBacklog - extends ApplicationModel, - BookmarksTeamBacklogAttributes { - readonly typename: 'BookmarksTeamBacklog'; - - readonly query: BookmarksTeamBacklogQuery; - - attributes: BookmarksTeamBacklogAttributes; - } - - /** - * Attributes for BookmarksWorkflowBoard - * @category Aha! Model Attributes - */ - interface BookmarksWorkflowBoardAttributes { - /** - * Currently active filters on the board - */ - - filters: any; - readonly id: string; - /** - * The project or team whose records appear on this board - */ - - readonly projectId: string; - /** - * How to view the board: 'my_work', 'team_work', or 'none' - */ - - view: string; - /** - * The ID of the workflow of the records on this board - */ - - readonly workflowId: string; - /** - * The iteration whose records appear on this board, if applicable - */ - - readonly iteration: Iteration; - readonly records: Array; - } - - type BookmarksWorkflowBoardQuery = Query; - - /** - * BookmarksWorkflowBoard Aha! model - * - * A workflow board for a team or iteration - * - * Instance type: [[BookmarksWorkflowBoard]] - * - * @category Aha! Model - */ - interface BookmarksWorkflowBoardConstructor { - typename: 'BookmarksWorkflowBoard'; - - select( - names: F[] - ): BookmarksWorkflowBoardQuery; - - select( - ...names: F[] - ): BookmarksWorkflowBoardQuery; - - blank(attrs: BookmarksWorkflowBoardAttributes): BookmarksWorkflowBoard; - - new ( - attributes?: Partial - ): BookmarksWorkflowBoard; - } - - /** - * BookmarksWorkflowBoard Aha! model - * - * A workflow board for a team or iteration - * - * Constructor: [[BookmarksWorkflowBoardConstructor]] - * - * @category Aha! Model Instance - */ - interface BookmarksWorkflowBoard - extends ApplicationModel, - BookmarksWorkflowBoardAttributes { - readonly typename: 'BookmarksWorkflowBoard'; - - readonly query: BookmarksWorkflowBoardQuery; - - attributes: BookmarksWorkflowBoardAttributes; - } - - /** - * Attributes for Epic - * @category Aha! Model Attributes - */ - interface EpicAttributes { - readonly commentsCount: number; - readonly createdAt: string; - /** - * Long-form description in HTML - */ - - description: string; - readonly id: string; - name: string; - /** - * Path to the details page - */ - - readonly path: string; - /** - * Position of the epic when a record_position does not apply - */ - - position: number; - /** - * Reference number of the record. Example: DEV-123 - */ - - readonly referenceNum: string; - readonly updatedAt: string; - assignedToUser: User; - iteration: Iteration; - /** - * Originally estimated amount of work - */ - - readonly originalEstimate: Estimate; - readonly project: Project; - release: Release; - /** - * Current estimate of work left to do - */ - - readonly remainingEstimate: Estimate; - /** - * Team this epic belongs to - */ - - team: Project; - /** - * Current team workflow status - */ - - teamWorkflowStatus: WorkflowStatus; - /** - * Amount of work done so far - */ - - readonly workDone: Estimate; - /** - * Current overall workflow status - */ - - workflowStatus: WorkflowStatus; - /** - * The position of a record when it is listed in a specific bookmark type - */ - - readonly bookmarksRecordPositions: Array; - /** - * Additional data stored by extensions - */ - - readonly extensionFields: Array; - readonly features: Array; - readonly tags: Array; - readonly tasks: Array; - } - - type EpicQuery = Query; - - /** - * Epic Aha! model - * - * A high-level record that can contain multiple related features - * - * Instance type: [[Epic]] - * - * @category Aha! Model - */ - interface EpicConstructor { - typename: 'Epic'; - - select(names: F[]): EpicQuery; - - select(...names: F[]): EpicQuery; - - where(filters: Partial): EpicQuery; - - blank(attrs: EpicAttributes): Epic; - - new (attributes?: Partial): Epic; - } - - /** - * Epic Aha! model - * - * A high-level record that can contain multiple related features - * - * Constructor: [[EpicConstructor]] - * - * @category Aha! Model Instance - */ - interface Epic extends ApplicationModel, EpicAttributes, HasExtensionFields { - readonly typename: 'Epic'; - - readonly query: EpicQuery; - - attributes: EpicAttributes; - - order: EpicOrderEnum['values']; - } - - /** - * Attributes for Estimate - * @category Aha! Model Attributes - */ - interface EstimateAttributes { - /** - * A string representation of the estimate. Example: 14p for 14 points - */ - - readonly text: string; - readonly units: WorkUnitEnumEnum['values']; - readonly value: number; - } - - type EstimateQuery = Query; - - /** - * Estimate Aha! model - * - * An estimate of work done or work remaining for a record - * - * Instance type: [[Estimate]] - * - * @category Aha! Model - */ - interface EstimateConstructor { - typename: 'Estimate'; - - select(names: F[]): EstimateQuery; - - select(...names: F[]): EstimateQuery; - - blank(attrs: EstimateAttributes): Estimate; - - new (attributes?: Partial): Estimate; - } - - /** - * Estimate Aha! model - * - * An estimate of work done or work remaining for a record - * - * Constructor: [[EstimateConstructor]] - * - * @category Aha! Model Instance - */ - interface Estimate extends ApplicationModel, EstimateAttributes { - readonly typename: 'Estimate'; - - readonly query: EstimateQuery; - - attributes: EstimateAttributes; - } - - /** - * Attributes for Extension - * @category Aha! Model Attributes - */ - interface ExtensionAttributes { - readonly createdAt: string; - readonly enabled: boolean; - readonly id: string; - readonly identifier: string; - readonly name: string; - readonly updatedAt: string; - readonly extensionLogs: Array; - } - - type ExtensionQuery = Query; - - /** - * Extension Aha! model - * - * - * - * Instance type: [[Extension]] - * - * @category Aha! Model - */ - interface ExtensionConstructor { - typename: 'Extension'; - - select(names: F[]): ExtensionQuery; - - select(...names: F[]): ExtensionQuery; - - blank(attrs: ExtensionAttributes): Extension; - - new (attributes?: Partial): Extension; - } - - /** - * Extension Aha! model - * - * - * - * Constructor: [[ExtensionConstructor]] - * - * @category Aha! Model Instance - */ - interface Extension extends ApplicationModel, ExtensionAttributes { - readonly typename: 'Extension'; - - readonly query: ExtensionQuery; - - attributes: ExtensionAttributes; - } - - /** - * Attributes for ExtensionContribution - * @category Aha! Model Attributes - */ - interface ExtensionContributionAttributes { - readonly createdAt: string; - readonly id: string; - /** - * The identifier of the extensin contribution. Example: 'aha-develop.github-import.issues' - */ - - readonly identifier: string; - readonly name: string; - readonly updatedAt: string; - /** - * The extension providing this contribution - */ - - readonly extension: Extension; - } - - type ExtensionContributionQuery = Query< - ExtensionContribution, - ExtensionContributionFilters - >; - - /** - * ExtensionContribution Aha! model - * - * A contribution provided by an extension - * - * Instance type: [[ExtensionContribution]] - * - * @category Aha! Model - */ - interface ExtensionContributionConstructor { - typename: 'ExtensionContribution'; - - select( - names: F[] - ): ExtensionContributionQuery; - - select( - ...names: F[] - ): ExtensionContributionQuery; - - where( - filters: Partial - ): ExtensionContributionQuery; - - blank(attrs: ExtensionContributionAttributes): ExtensionContribution; - - new ( - attributes?: Partial - ): ExtensionContribution; - } - - /** - * ExtensionContribution Aha! model - * - * A contribution provided by an extension - * - * Constructor: [[ExtensionContributionConstructor]] - * - * @category Aha! Model Instance - */ - interface ExtensionContribution - extends ApplicationModel, - ExtensionContributionAttributes { - readonly typename: 'ExtensionContribution'; - - readonly query: ExtensionContributionQuery; - - attributes: ExtensionContributionAttributes; - } - - /** - * Attributes for ExtensionField - * @category Aha! Model Attributes - */ - interface ExtensionFieldAttributes { - readonly createdAt: string; - /** - * The ID of the object the field is attached to - */ - - extensionFieldableId: string; - /** - * The type of object the field is attached to - */ - - extensionFieldableType: string; - readonly id: string; - name: string; - readonly updatedAt: string; - value: any; - /** - * The extension responsible for this field - */ - - extension: Extension; - readonly extensionFieldable: ExtensionFieldableSubjectUnion; - } - - type ExtensionFieldQuery = Query; - - /** - * ExtensionField Aha! model - * - * Holds data related to an extension - * - * Instance type: [[ExtensionField]] - * - * @category Aha! Model - */ - interface ExtensionFieldConstructor { - typename: 'ExtensionField'; - - select( - names: F[] - ): ExtensionFieldQuery; - - select( - ...names: F[] - ): ExtensionFieldQuery; - - where(filters: Partial): ExtensionFieldQuery; - - blank(attrs: ExtensionFieldAttributes): ExtensionField; - - new (attributes?: Partial): ExtensionField; - } - - /** - * ExtensionField Aha! model - * - * Holds data related to an extension - * - * Constructor: [[ExtensionFieldConstructor]] - * - * @category Aha! Model Instance - */ - interface ExtensionField extends ApplicationModel, ExtensionFieldAttributes { - readonly typename: 'ExtensionField'; - - readonly query: ExtensionFieldQuery; - - attributes: ExtensionFieldAttributes; - } - - /** - * Attributes for ExtensionInvocation - * @category Aha! Model Attributes - */ - interface ExtensionInvocationAttributes { - readonly createdAt: string; - readonly id: string; - readonly updatedAt: string; - /** - * The contribution that was invoked - */ - - readonly extensionContribution: ExtensionContribution; - /** - * Log messages written during this invocation - */ - - readonly extensionLogs: ExtensionLog; - } - - type ExtensionInvocationQuery = Query; - - /** - * ExtensionInvocation Aha! model - * - * A single invocation of an extension contribution - * - * Instance type: [[ExtensionInvocation]] - * - * @category Aha! Model - */ - interface ExtensionInvocationConstructor { - typename: 'ExtensionInvocation'; - - select( - names: F[] - ): ExtensionInvocationQuery; - - select( - ...names: F[] - ): ExtensionInvocationQuery; - - blank(attrs: ExtensionInvocationAttributes): ExtensionInvocation; - - new ( - attributes?: Partial - ): ExtensionInvocation; - } - - /** - * ExtensionInvocation Aha! model - * - * A single invocation of an extension contribution - * - * Constructor: [[ExtensionInvocationConstructor]] - * - * @category Aha! Model Instance - */ - interface ExtensionInvocation - extends ApplicationModel, - ExtensionInvocationAttributes { - readonly typename: 'ExtensionInvocation'; - - readonly query: ExtensionInvocationQuery; - - attributes: ExtensionInvocationAttributes; - } - - /** - * Attributes for ExtensionLog - * @category Aha! Model Attributes - */ - interface ExtensionLogAttributes { - /** - * Structured log messages - */ - - readonly content: any; - readonly createdAt: string; - readonly id: string; - readonly updatedAt: string; - /** - * The contribution that was invoked - */ - - readonly extensionContribution: ExtensionContribution; - /** - * The invocation writing these log messages - */ - - readonly extensionInvocation: ExtensionInvocation; - } - - type ExtensionLogQuery = Query; - - /** - * ExtensionLog Aha! model - * - * Log messages for a single invocation of an extension contribution - * - * Instance type: [[ExtensionLog]] - * - * @category Aha! Model - */ - interface ExtensionLogConstructor { - typename: 'ExtensionLog'; - - select( - names: F[] - ): ExtensionLogQuery; - - select( - ...names: F[] - ): ExtensionLogQuery; - - where(filters: Partial): ExtensionLogQuery; - - blank(attrs: ExtensionLogAttributes): ExtensionLog; - - new (attributes?: Partial): ExtensionLog; - } - - /** - * ExtensionLog Aha! model - * - * Log messages for a single invocation of an extension contribution - * - * Constructor: [[ExtensionLogConstructor]] - * - * @category Aha! Model Instance - */ - interface ExtensionLog extends ApplicationModel, ExtensionLogAttributes { - readonly typename: 'ExtensionLog'; - - readonly query: ExtensionLogQuery; - - attributes: ExtensionLogAttributes; - } - - /** - * Attributes for Feature - * @category Aha! Model Attributes - */ - interface FeatureAttributes { - readonly commentsCount: number; - readonly createdAt: string; - /** - * Long-form description in HTML - */ - - description: string; - readonly id: string; - name: string; - /** - * Path to the details page - */ - - readonly path: string; - /** - * Position of the feature when a record_position does not apply - */ - - position: number; - /** - * Reference number of the record. Example: DEV-123 - */ - - readonly referenceNum: string; - readonly updatedAt: string; - assignedToUser: User; - /** - * Epic this feature belongs to, if present - */ - - epic: Epic; - iteration: Iteration; - /** - * Originally estimated amount of work - */ - - readonly originalEstimate: Estimate; - readonly project: Project; - release: Release; - /** - * Current estimate of work left to do - */ - - readonly remainingEstimate: Estimate; - /** - * Team this feature belongs to - */ - - team: Project; - /** - * Current team workflow status - */ - - teamWorkflowStatus: WorkflowStatus; - /** - * Amount of work done so far - */ - - readonly workDone: Estimate; - /** - * Current overall workflow status - */ - - workflowStatus: WorkflowStatus; - /** - * Position when this feature is listed in a specific bookmark type - */ - - readonly bookmarksRecordPositions: Array; - /** - * Additional data stored by extensions - */ - - readonly extensionFields: Array; - readonly requirements: Array; - readonly tags: Array; - readonly tasks: Array; - } - - type FeatureQuery = Query; - - /** - * Feature Aha! model - * - * A basic record representing work to be done - * - * Instance type: [[Feature]] - * - * @category Aha! Model - */ - interface FeatureConstructor { - typename: 'Feature'; - - select(names: F[]): FeatureQuery; - - select(...names: F[]): FeatureQuery; - - where(filters: Partial): FeatureQuery; - - blank(attrs: FeatureAttributes): Feature; - - new (attributes?: Partial): Feature; - } - - /** - * Feature Aha! model - * - * A basic record representing work to be done - * - * Constructor: [[FeatureConstructor]] - * - * @category Aha! Model Instance - */ - interface Feature - extends ApplicationModel, - FeatureAttributes, - HasExtensionFields { - readonly typename: 'Feature'; - - readonly query: FeatureQuery; - - attributes: FeatureAttributes; - - order: FeatureOrderEnum['values']; - } - - /** - * Attributes for Iteration - * @category Aha! Model Attributes - */ - interface IterationAttributes { - readonly createdAt: string; - /** - * Duration of the iteration, in days - */ - - duration: number; - readonly id: string; - name: string; - startDate: string; - /** - * The iteration status. PLANNING: 10, ACTIVE: 20, COMPLETE: 30 - */ - - status: number; - readonly updatedAt: string; - /** - * Capacity of the iteration - */ - - capacity: Estimate; - /** - * Total amount of work planned when the iteration started - */ - - readonly originalEstimate: Estimate; - project: Project; - /** - * Records scheduled in this iteration - */ - - readonly records: Array; - readonly tasks: Array; - } - - type IterationQuery = Query; - - /** - * Iteration Aha! model - * - * A group of records scheduled during a particular time period - * - * Instance type: [[Iteration]] - * - * @category Aha! Model - */ - interface IterationConstructor { - typename: 'Iteration'; - - select(names: F[]): IterationQuery; - - select(...names: F[]): IterationQuery; - - where(filters: Partial): IterationQuery; - - blank(attrs: IterationAttributes): Iteration; - - new (attributes?: Partial): Iteration; - } - - /** - * Iteration Aha! model - * - * A group of records scheduled during a particular time period - * - * Constructor: [[IterationConstructor]] - * - * @category Aha! Model Instance - */ - interface Iteration extends ApplicationModel, IterationAttributes { - readonly typename: 'Iteration'; - - readonly query: IterationQuery; - - attributes: IterationAttributes; - - order: IterationOrderEnum['values']; - } - - /** - * Attributes for Project - * @category Aha! Model Attributes - */ - interface ProjectAttributes { - /** - * ID of the BookmarksWorkflowBoard correspanding to this team - */ - - readonly backlogBookmarkId: string; - readonly createdAt: string; - readonly id: string; - /** - * True if the project is a team, false if it is a workspace - */ - - readonly isTeam: boolean; - readonly name: string; - readonly updatedAt: string; - /** - * Release new records are created in, by default - */ - - readonly defaultRelease: Release; - /** - * User assigned to records if none is specified - */ - - readonly defaultUser: User; - /** - * Additional data stored by extensions - */ - - readonly extensionFields: Array; - readonly releases: Array; - /** - * Users belonging to the project or team - */ - - readonly users: Array; - } - - type ProjectQuery = Query; - - /** - * Project Aha! model - * - * An Aha! workspace or team - * - * Instance type: [[Project]] - * - * @category Aha! Model - */ - interface ProjectConstructor { - typename: 'Project'; - - select(names: F[]): ProjectQuery; - - select(...names: F[]): ProjectQuery; - - blank(attrs: ProjectAttributes): Project; - - new (attributes?: Partial): Project; - } - - /** - * Project Aha! model - * - * An Aha! workspace or team - * - * Constructor: [[ProjectConstructor]] - * - * @category Aha! Model Instance - */ - interface Project - extends ApplicationModel, - ProjectAttributes, - HasExtensionFields { - readonly typename: 'Project'; - - readonly query: ProjectQuery; - - attributes: ProjectAttributes; - } - - /** - * Attributes for Release - * @category Aha! Model Attributes - */ - interface ReleaseAttributes { - readonly createdAt: string; - readonly id: string; - readonly name: string; - /** - * True if the release appears in the parking lot, false if it is a scheduled release - */ - - readonly parkingLot: boolean; - /** - * Path to the details page - */ - - readonly path: string; - readonly position: number; - /** - * Reference number of the record. Example: DEV-123 - */ - - readonly referenceNum: string; - readonly releaseDate: string; - readonly updatedAt: string; - readonly tasks: Array; - } - - type ReleaseQuery = Query; - - /** - * Release Aha! model - * - * A group of records with a release date or theme - * - * Instance type: [[Release]] - * - * @category Aha! Model - */ - interface ReleaseConstructor { - typename: 'Release'; - - select(names: F[]): ReleaseQuery; - - select(...names: F[]): ReleaseQuery; - - where(filters: Partial): ReleaseQuery; - - blank(attrs: ReleaseAttributes): Release; - - new (attributes?: Partial): Release; - } - - /** - * Release Aha! model - * - * A group of records with a release date or theme - * - * Constructor: [[ReleaseConstructor]] - * - * @category Aha! Model Instance - */ - interface Release extends ApplicationModel, ReleaseAttributes { - readonly typename: 'Release'; - - readonly query: ReleaseQuery; - - attributes: ReleaseAttributes; - - order: ReleaseOrderEnum['values']; - } - - /** - * Attributes for Requirement - * @category Aha! Model Attributes - */ - interface RequirementAttributes { - readonly commentsCount: number; - readonly createdAt: string; - /** - * Long-form description in HTML - */ - - description: string; - readonly id: string; - name: string; - /** - * Path to the details page - */ - - readonly path: string; - /** - * Position of the requirement when a record_position does not apply - */ - - position: number; - /** - * Reference number of the record. Example: DEV-123 - */ - - readonly referenceNum: string; - readonly updatedAt: string; - assignedToUser: User; - /** - * Epic this requirement belongs to, if present - */ - - readonly epic: Epic; - /** - * Feature this requirement belongs to, if present - */ - - feature: Feature; - iteration: Iteration; - /** - * Originally estimated amount of work - */ - - readonly originalEstimate: Estimate; - readonly project: Project; - readonly release: Release; - /** - * Current estimate of work left to do - */ - - readonly remainingEstimate: Estimate; - /** - * Team this requirement belongs to - */ - - team: Project; - /** - * Current team workflow status - */ - - teamWorkflowStatus: WorkflowStatus; - /** - * Amount of work done so far - */ - - readonly workDone: Estimate; - /** - * Current overall workflow status - */ - - workflowStatus: WorkflowStatus; - /** - * Position when this record is listed in a specific bookmark type - */ - - readonly bookmarksRecordPositions: Array; - /** - * Additional data stored by extensions - */ - - readonly extensionFields: Array; - readonly tasks: Array; - } - - type RequirementQuery = Query; - - /** - * Requirement Aha! model - * - * A record representing one part of a larger feature - * - * Instance type: [[Requirement]] - * - * @category Aha! Model - */ - interface RequirementConstructor { - typename: 'Requirement'; - - select(names: F[]): RequirementQuery; - - select( - ...names: F[] - ): RequirementQuery; - - where(filters: Partial): RequirementQuery; - - blank(attrs: RequirementAttributes): Requirement; - - new (attributes?: Partial): Requirement; - } - - /** - * Requirement Aha! model - * - * A record representing one part of a larger feature - * - * Constructor: [[RequirementConstructor]] - * - * @category Aha! Model Instance - */ - interface Requirement - extends ApplicationModel, - RequirementAttributes, - HasExtensionFields { - readonly typename: 'Requirement'; - - readonly query: RequirementQuery; - - attributes: RequirementAttributes; - - order: RequirementOrderEnum['values']; - } - - /** - * Attributes for Tag - * @category Aha! Model Attributes - */ - interface TagAttributes { - /** - * Hex color converted to decimal - */ - - readonly color: number; - readonly id: string; - readonly name: string; - } - - type TagQuery = Query; - - /** - * Tag Aha! model - * - * A tag on a record - * - * Instance type: [[Tag]] - * - * @category Aha! Model - */ - interface TagConstructor { - typename: 'Tag'; - - select(names: F[]): TagQuery; - - select(...names: F[]): TagQuery; - - where(filters: Partial): TagQuery; - - blank(attrs: TagAttributes): Tag; - - new (attributes?: Partial): Tag; - } - - /** - * Tag Aha! model - * - * A tag on a record - * - * Constructor: [[TagConstructor]] - * - * @category Aha! Model Instance - */ - interface Tag extends ApplicationModel, TagAttributes { - readonly typename: 'Tag'; - - readonly query: TagQuery; - - attributes: TagAttributes; - } - - /** - * Attributes for Task - * @category Aha! Model Attributes - */ - interface TaskAttributes { - body: string; - readonly createdAt: string; - readonly dueDate: string; - readonly id: string; - name: string; - position: number; - status: TaskStatusEnumEnum['values']; - readonly updatedAt: string; - record: TaskableSubjectUnion; - readonly taskUsers: Array; - readonly users: Array; - } - - type TaskQuery = Query; - - /** - * Task Aha! model - * - * - * - * Instance type: [[Task]] - * - * @category Aha! Model - */ - interface TaskConstructor { - typename: 'Task'; - - select(names: F[]): TaskQuery; - - select(...names: F[]): TaskQuery; - - blank(attrs: TaskAttributes): Task; - - new (attributes?: Partial): Task; - } - - /** - * Task Aha! model - * - * - * - * Constructor: [[TaskConstructor]] - * - * @category Aha! Model Instance - */ - interface Task extends ApplicationModel, TaskAttributes { - readonly typename: 'Task'; - - readonly query: TaskQuery; - - attributes: TaskAttributes; - } - - /** - * Attributes for TaskUser - * @category Aha! Model Attributes - */ - interface TaskUserAttributes { - readonly completedDate: string; - readonly createdAt: string; - readonly id: string; - readonly status: TaskStatusEnumEnum['values']; - readonly updatedAt: string; - readonly task: Task; - readonly user: User; - } - - type TaskUserQuery = Query; - - /** - * TaskUser Aha! model - * - * - * - * Instance type: [[TaskUser]] - * - * @category Aha! Model - */ - interface TaskUserConstructor { - typename: 'TaskUser'; - - select(names: F[]): TaskUserQuery; - - select(...names: F[]): TaskUserQuery; - - blank(attrs: TaskUserAttributes): TaskUser; - - new (attributes?: Partial): TaskUser; - } - - /** - * TaskUser Aha! model - * - * - * - * Constructor: [[TaskUserConstructor]] - * - * @category Aha! Model Instance - */ - interface TaskUser extends ApplicationModel, TaskUserAttributes { - readonly typename: 'TaskUser'; - - readonly query: TaskUserQuery; - - attributes: TaskUserAttributes; - } - - /** - * Attributes for User - * @category Aha! Model Attributes - */ - interface UserAttributes { - /** - * URL to the user's avatar. Defaults to 32px - */ - - readonly avatarUrl: string; - readonly createdAt: string; - readonly id: string; - readonly name: string; - /** - * User's selected time zone as IANA time zone database name - */ - - readonly timezone: string; - readonly updatedAt: string; - /** - * Additional data stored by extensions - */ - - readonly extensionFields: Array; - /** - * Projects this user belongs to - */ - - readonly projects: Array; - readonly taskUsers: Array; - } - - type UserQuery = Query; - - /** - * User Aha! model - * - * - * - * Instance type: [[User]] - * - * @category Aha! Model - */ - interface UserConstructor { - typename: 'User'; - - select(names: F[]): UserQuery; - - select(...names: F[]): UserQuery; - - where(filters: Partial): UserQuery; - - blank(attrs: UserAttributes): User; - - new (attributes?: Partial): User; - } - - /** - * User Aha! model - * - * - * - * Constructor: [[UserConstructor]] - * - * @category Aha! Model Instance - */ - interface User extends ApplicationModel, UserAttributes, HasExtensionFields { - readonly typename: 'User'; - - readonly query: UserQuery; - - attributes: UserAttributes; - } - - /** - * Attributes for Workflow - * @category Aha! Model Attributes - */ - interface WorkflowAttributes { - /** - * If true, this is a global status that cannot be edited - */ - - readonly builtIn: boolean; - readonly createdAt: string; - readonly id: string; - readonly name: string; - readonly updatedAt: string; - readonly workflowStatuses: Array; - } - - type WorkflowQuery = Query; - - /** - * Workflow Aha! model - * - * A record workflow - * - * Instance type: [[Workflow]] - * - * @category Aha! Model - */ - interface WorkflowConstructor { - typename: 'Workflow'; - - select(names: F[]): WorkflowQuery; - - select(...names: F[]): WorkflowQuery; - - blank(attrs: WorkflowAttributes): Workflow; - - new (attributes?: Partial): Workflow; - } - - /** - * Workflow Aha! model - * - * A record workflow - * - * Constructor: [[WorkflowConstructor]] - * - * @category Aha! Model Instance - */ - interface Workflow extends ApplicationModel, WorkflowAttributes { - readonly typename: 'Workflow'; - - readonly query: WorkflowQuery; - - attributes: WorkflowAttributes; - } - - /** - * Attributes for WorkflowStatus - * @category Aha! Model Attributes - */ - interface WorkflowStatusAttributes { - /** - * If true, this is a global status that cannot be edited - */ - - readonly builtIn: boolean; - /** - * Hex color converted to decimal - */ - - color: number; - readonly createdAt: string; - readonly id: string; - readonly internalMeaning: InternalMeaningEnum['values']; - name: string; - position: number; - readonly updatedAt: string; - /** - * Workflow containing this status - */ - - workflow: Workflow; - } - - type WorkflowStatusQuery = Query; - - /** - * WorkflowStatus Aha! model - * - * A single status within a workflow - * - * Instance type: [[WorkflowStatus]] - * - * @category Aha! Model - */ - interface WorkflowStatusConstructor { - typename: 'WorkflowStatus'; - - select( - names: F[] - ): WorkflowStatusQuery; - - select( - ...names: F[] - ): WorkflowStatusQuery; - - blank(attrs: WorkflowStatusAttributes): WorkflowStatus; - - new (attributes?: Partial): WorkflowStatus; - } - - /** - * WorkflowStatus Aha! model - * - * A single status within a workflow - * - * Constructor: [[WorkflowStatusConstructor]] - * - * @category Aha! Model Instance - */ - interface WorkflowStatus extends ApplicationModel, WorkflowStatusAttributes { - readonly typename: 'WorkflowStatus'; - - readonly query: WorkflowStatusQuery; - - attributes: WorkflowStatusAttributes; - } - - interface Models { - Account: AccountConstructor; - BookmarksRecordPosition: BookmarksRecordPositionConstructor; - BookmarksTeamBacklog: BookmarksTeamBacklogConstructor; - BookmarksWorkflowBoard: BookmarksWorkflowBoardConstructor; - Epic: EpicConstructor; - Estimate: EstimateConstructor; - Extension: ExtensionConstructor; - ExtensionContribution: ExtensionContributionConstructor; - ExtensionField: ExtensionFieldConstructor; - ExtensionInvocation: ExtensionInvocationConstructor; - ExtensionLog: ExtensionLogConstructor; - Feature: FeatureConstructor; - Iteration: IterationConstructor; - Project: ProjectConstructor; - Release: ReleaseConstructor; - Requirement: RequirementConstructor; - Tag: TagConstructor; - Task: TaskConstructor; - TaskUser: TaskUserConstructor; - User: UserConstructor; - Workflow: WorkflowConstructor; - WorkflowStatus: WorkflowStatusConstructor; - } - interface EnumMap { - AvatarSizeEnum: AvatarSizeEnumEnum; - EpicOrder: EpicOrderEnum; - ExtensionFieldableTypeEnum: ExtensionFieldableTypeEnumEnum; - FeatureOrder: FeatureOrderEnum; - InternalMeaning: InternalMeaningEnum; - IterationOrder: IterationOrderEnum; - OrderDirection: OrderDirectionEnum; - RecordPlacementEnum: RecordPlacementEnumEnum; - ReleaseOrder: ReleaseOrderEnum; - RequirementOrder: RequirementOrderEnum; - TaskStatusEnum: TaskStatusEnumEnum; - WorkUnitEnum: WorkUnitEnumEnum; - } - - type Model = keyof Models; -} - -interface Aha { - models: Aha.Models; - enums: Aha.EnumMap; -} - -declare namespace Aha { - type GetElementType> = T extends (infer U)[] ? U : never; - - type BelongsTos = { - [P in keyof T['attributes'] as T['attributes'][P] extends ApplicationModel - ? P - : never]: T['attributes'][P] extends ApplicationModel - ? T['attributes'][P] - : never; - }; - type HasManys = { - [P in keyof T['attributes'] as T['attributes'][P] extends ApplicationModel[] - ? P - : never]: T['attributes'][P] extends ApplicationModel[] - ? GetElementType - : never; - }; - type Relations = BelongsTos & HasManys; - - type NonRelations = Omit< - T['attributes'], - keyof Relations - >; - - type Subquery< - T extends ApplicationModel, - K extends Relations = Relations - > = { - [P in keyof K]?: Query | Array; - }; - - interface Query { - /** - * Unions this query with another query, using GraphQL union - * types. Should only be used in subqueries. - * - * Example: Epic.select(['id', 'name']) - * .union(Feature.select(['id', 'name'])); - */ - union(query: Query): this; - /** - * Adds a subquery to select deeply nested records. - * - * Example: Workflow.select(['id']).merge({ - * workflowStatuses: WorkflowStatus.select([ - * 'id', - * 'name', - * 'color', - * 'position', - * ]), - * }); - * - * @param subqueries The subqueries to merge into this query, where the key is an attribute name and the value is a Query object. - */ - merge(subqueries: Subquery): this; - /** - * Adds filters to the query - * - * Example: query.where({projectId: 15}) - */ - where(filters: Partial): this; - /** - * Resets the filters on the query - * - * Example: query.rewhere({projectId: 15}) - */ - rewhere(filters: Partial): this; - /** - * Adds a criteria for ordering. Will be added to the end of the order list. - * - * Example: query.order({createdAt: 'ASC'}); - */ - order( - criteria: Record - ): this; - /** - * Resets all criteria for ordering. - * - * Example: query.reorder({createdAt: 'ASC'}); - * - * @param criteria A one-key object where the key is an order attribute name and the value is a direction - */ - reorder( - criteria: Record - ): this; - /** - * Adds `attrs` to the attributes selected by the query. - * - * Example: query.select(['id', 'name']); - * - * @param arguments - * @returns A Query object selecting `attrs` - */ - select(names: F[]): this; - select(...names: F[]): this; - /** - * When paginating, adds `stats` to the page attributes selected by - * the query. - * - * Example: query.stats(['isLastPage']); - */ - stats(attrs: string[]): this; - /** - * When paginating, selects page `pageNumber` - * - * Example: query.page(2) - */ - page(pageNumber: number): this; - /** - * When paginating, sets the number of results per page - * - * Example: query.per(50) - */ - per(perPage: number): this; - /** - * Adds bare, top-level arguments to the query - * - * Example: query.argument({timeout: 1000}) - */ - argument(args: Record): this; - /** - * When called, the query will select a single object instead of multiple. - * - * Example: query.first(); - */ - first(): SingleQuery; - - /** - * Executes this query, finding a single record by ID. - */ - find(id: string): Promise; - /** - * Executes this query. - * - * @returns The requested models, or undefined if it couldn't be found. - */ - all(): Promise; - /** - * Fetch *all* records from multiple pages. `pageCallback` will be - * called for each page as it arrives. If no callback is specified, - * will return all of the records found. If a callback is specified, - * it is assumed that the caller will handle the records, and the - * return value will be empty. - * - * @param [pageCallback] a callback called with a list of records for every page as it arrives - * @returns An array of the requested records, if no callback is given - */ - findInBatches(pageCallback?: Function): Promise; - - readonly model: M; - /** - * Returns the name for the query based on the model used to construct it. - */ - readonly queryName: string; - /** - * Returns the plain string version of the GraphQL query corresponding to this object. - */ - readonly queryString: string; - /** - * Returns the variables to send with the graphql query - */ - readonly queryVariables: Record; - readonly subqueries: Record>; - readonly attrs: Set; - readonly arguments: Record; - readonly filters: Record; - readonly sort: Record; - readonly single: boolean; - readonly unions: Record>; - } - - interface SingleQuery - extends Omit, 'all'> { - all(): Promise; - } - - /** - * Functions for getting and setting extension data for a particular model - */ - interface HasExtensionFields { - getExtensionFields(identifier: string): Promise; - - /** - * Get the value of an extension field on this record. This will return - * null if the value has never been set - * - * @param identifier the extension identifier - * @param fieldName the name of the field - */ - getExtensionField( - identifier: string, - fieldName: string - ): Promise; - - /** - * Set the value of an extension field for this record - * - * @param identifier the extension identifier - * @param fieldName the name of the field - */ - setExtensionField( - identifier: string, - fieldName: string, - value: any - ): Promise; - } - - interface ApplicationModel { - readonly typename: string; - /** - * `true` if the object is an existing record, `false` otherwise. - */ - readonly persisted: boolean; - /** - * A guaranteed unique identifier for the record. Returns internalObjectId if id is falsy (unsaved). - */ - readonly uniqueId: string; - - attributes: {}; - order: string; - - /** - * Clear the value from an extension field for this record - * - * @param identifier the extension identifier - * @param fieldName the name of the field - */ - clearExtensionField(identifier: string, fieldName: string): Promise; - - /** - * `true` if the object's attributes have been modified, `false` otherwise. - */ - isDirty(): boolean; - /** - * Updates or creates this record using a GraphQL mutation. Will use - * the `update{ModelName}` or `create{ModelName}` mutations, - * respectively. Sends all changed attributes and relationships as - * arguments, and, by default, updates attributes using the query used to - * construct this object. - * - * @param options Data used to modify the mutation query. - * - * `options`: - * - args: Bare, top-level (non-attribute) arguments passed along with the mutation. These will be at the same level as `id`, for example. - * - query: A Query object used to override the default query. - * - * @returns `true` if the mutation ran without errors, `false` otherwise. - */ - save(options?: Partial<{ args: any; query: any }>): Promise; - - reload(options?: { query?: Query }): Promise; - - /** - * Load additional attributes from the API: - * - * ``` - * const record = await Feature.select('referenceNum').find('REF-123'); - * record.name => null - * await record.loadAttributes('name'); - * record.name => 'Record 123' - * ``` - */ - loadAttributes>( - ...attributes: F[] - ): Promise; - - /** - * Destroys this record. - * - * @returns `true` if the mutation ran without errors, `false` otherwise. - */ - destroy(): Promise; - - /** - * Sets the attribute `name` to `value`. This function can be used - * even if this object didn't declare a setter for the attribute - * `name`. - */ - setAttribute( - name: K, - value: this['attributes'][K], - flagDirty?: boolean - ): void; - - /** - * Sends a GraphQL mutation request, updating the current object from the response. - * - * @param mutationName The name of the mutation to call - * @param options All data passed along to generate the mutation query. - * - * `options`: - * - args: The arguments passed to the mutation - * - query: The Query object used to update data from the mutation response - * - stringify: When true, will stringify args using Query.stringifyValue - * - cacheId: The key that is expected to be used to cache the result - * - * @returns {Promise} `true` if the mutation ran without errors, `false` otherwise. - */ - mutate( - mutationName: string, - options?: Partial<{ - args: any; - query: any; - stringify: boolean; - cacheId: string; - }> - ): Promise; - - /** - * Returns a shallow duplicate of this record. - */ - dup(): this; - } - - /** - * @deprecated - * @hidden - */ - interface RecordStub extends ApplicationModel { - id: string; - referenceNum: string; - type: string; - } - - interface EnumValue { - type: T; - value: V; - } - - /** - * Access the current settings for an extension - * - * @category Extensions - */ - interface Settings { - get(name: string): Settings | unknown; - } - - /** - * The context for an extension callback - * - * @category Extensions - */ - interface Context { - settings: Settings; - identifier: string; - } - - /** - * @category Extensions - */ - interface UpdateCallback { - (newState: any): Promise; - } - - /** - * @category Extensions - */ - interface RenderExtensionProps { - isUpdate: boolean; - onUnmounted: (callback: () => void) => void; - record?: RecordStub; - fields?: { [index: string]: unknown }; - update?: UpdateCallback; - state?: any; - } - - /** - * @category Extensions - */ - interface RenderExtension { - (props: RenderExtensionProps, context: Context): void | React.ReactNode; - } - - /** - * @category Extensions - */ - interface CommandExtension { - (param: Param, context: Context): void; - } - - /** - * @category Extensions - */ - interface CommandPromptOptions { - placeholder?: string; - default?: string; - } - - /** - * @category Extensions - */ - interface AuthOptions { - reAuth?: boolean; - useCachedRetry?: boolean; - parameters?: unknown; - } - - /** - * @category Extensions - */ - interface AuthData { - token: string; - } - - /** - * @category Extensions - */ - interface AuthCallback { - (authData: AuthData): void; - } - - /** - * @category Extensions Importer - */ - interface ListFiltersEvent { - action: 'listFilters'; - } - - /** - * @category Extensions Importer - */ - interface ListFilter { - title: string; - required: boolean; - type: 'autocomplete' | 'text' | 'select'; - } - - /** - * @category Extensions Importer - */ - interface ListFilters { - [filterName: string]: ListFilter; - } - - /** - * @category Extensions Importer - */ - interface ListFiltersCallback { - /** - * Return a list of available filters - */ - (): ListFilters | Promise; - } - - /** - * @category Extensions Importer - */ - interface FilterValuesEvent { - action: 'filterValues'; - } - - /** - * Some filters will require information from the external server. For - * example, when filtering to an assigned user, you may want to fetch the - * list of users from the system you are importing from. filterValues - * returns the list of possible values for a filter field. - * - * @category Extensions Importer - */ - type FilterValuesCallback = (props: { - filterName: string; - filters: { [index: string]: any }; - }) => Promise; - - /** - * @category Extensions Importer - */ - interface FilterValue { - text?: string; - value: any; - } - - /** - * @category Extensions Importer - */ - interface ListCandidatesEvent { - action: 'listCandidates'; - } - - /** - * @category Extensions Importer - */ - interface ListCandidatesCallback { - (props: { filters: { [index: string]: any }; nextPage?: any }): Promise< - ListCandidate - >; - } - - /** - * @category Extensions Importer - */ - interface ListCandidate { - records: T[]; - nextPage?: any; - } - - /** - * @category Extensions Importer - */ - interface RenderRecordEvent { - action: 'renderRecord'; - } - - /** - * @category Extensions Importer - */ - interface RenderRecordCallback { - (props: { record: T; onUnmounted: () => any }): void; - } - - /** - * @category Extensions Importer - */ - interface ImportRecordEvent { - action: 'importRecord'; - } - - /** - * @category Extensions Importer - */ - interface ImportRecordCallback { - (props: { importRecord: T; ahaRecord: Feature }): Promise; - } - - /** - * @category Extensions Importer - */ - interface ImportRecord { - uniqueId: string; - name: string; - identifier?: string; - url?: string; - } - - /** - * @category Extensions Importer - */ - interface Importer { - on(event: ListFiltersEvent, callback: ListFiltersCallback): void; - on(event: FilterValuesEvent, callback: FilterValuesCallback): void; - on(event: ListCandidatesEvent, callback: ListCandidatesCallback): void; - on(event: RenderRecordEvent, callback: RenderRecordCallback): void; - on(event: ImportRecordEvent, callback: ImportRecordCallback): void; - } - - interface Drawer { - /** - * Get the props for the currently open drawer - */ - getProps(): unknown; - /** - * Show an Aha! record in the drawer - */ - showRecord(record: ReferenceInterface): Promise; - /** - * Show an extension contribution in the drawer - */ - showExtension( - identifier: string, - contribution: string, - props: object - ): Promise; - /** - * Hide the drawer - */ - hide(): void; - } -} - -declare class Aha { - /** - * The current account - */ - readonly account: Aha.Account; - - /** - * Access the drawer - */ - readonly drawer: Aha.Drawer; - - /** - * Register an extension function - * - * @param name - * @param extension - */ - on(name: string, extension: T): void; - on>(name: string, extension: T): void; - - /** - * Request user input - * - * @param prompt - * @param options - */ - commandPrompt( - prompt: string, - options?: Aha.CommandPromptOptions - ): Promise; - /** - * Call a registered extension command - * - * @param name - * @param args - */ - command(name: string, args?: T): void; - - getImporter(identifier: string): Aha.Importer; - - auth(service: string, options: Aha.AuthOptions): Promise; - auth( - service: string, - options: Aha.AuthOptions, - callback?: Aha.AuthCallback - ): void; - - triggerBrowser(event: string, args: any): void; - triggerServer(event: string, args: any): void; - - contextForIdentifier(identifier: string): Aha.Context; - executeExtension( - identifier: string, - code: (context: Aha.Context) => void - ): void; - getEndpoints(identifier: string): Function[]; - render( - elements: React.ReactNode, - node: HTMLElement, - onUnmounted?: (callback: Function) => void - ): void; - - /** - * Sanitize a url. This will remove any embedded javascript and only allow - * certain data types. Any link that comes from outside of Aha! or from user - * input should be sanitized: - * - * ``` - * return Link to record; - * ``` - */ - sanitizeUrl(url: string | undefined): string; -} - -declare const aha: Aha; -declare const csrfToken: () => string; -declare const Env: { [index: string]: string }; - -declare namespace JSX { - interface IntrinsicElements { - 'aha-flex': Partial< - { - className: string; - direction: 'column' | 'row'; - children: React.ReactNode; - wrap: CSSStyleDeclaration['flexWrap']; - } & Pick< - CSSStyleDeclaration, - 'justifyContent' | 'gap' | 'alignItems' | 'alignContent' - > - >; - 'aha-icon': { icon: string }; - 'aha-button': any; - 'aha-menu': any; - 'aha-menu-item': any; - 'aha-action-menu': any; - 'aha-spinner': any; - } -} diff --git a/schema/package-schema.json b/schema/package-schema.json deleted file mode 100644 index a4b9c29..0000000 --- a/schema/package-schema.json +++ /dev/null @@ -1,11 +0,0 @@ -{ - "$schema": "http://json-schema.org/draft-07/schema#", - "title": "JSON schema for Aha! Develop extensions pacakge.json file", - "description": "Validate ahaExtension key in package.json files", - "type": "object", - "properties": { - "ahaExtension": { - "$ref": "./schema.json" - } - } -} diff --git a/schema/schema.json b/schema/schema.json deleted file mode 100644 index 1078a6f..0000000 --- a/schema/schema.json +++ /dev/null @@ -1,218 +0,0 @@ -{ - "$schema": "http://json-schema.org/draft-07/schema#", - "title": "JSON schema for Aha! Develop extensions", - "description": "Validate ahaExtension key in package.json files", - "type": "object", - "additionalProperties": false, - "required": ["contributes"], - "properties": { - "jsxFactory": { - "type": "string" - }, - "cspSources": { - "type": "array", - "items": { "type": "string" } - }, - "contributes": { - "type": "object", - "additionalProperties": false, - "required": [], - "properties": { - "settings": { - "type": "object", - "required": [], - "additionalProperties": { - "$ref": "#/definitions/settingContribution" - } - }, - "views": { - "type": "object", - "additionalProperties": { "$ref": "#/definitions/viewContribution" } - }, - "commands": { - "type": "object", - "additionalProperties": { - "$ref": "#/definitions/commandContribution" - } - }, - "endpoints": { - "type": "object", - "additionalProperties": { - "$ref": "#/definitions/endpointContribution" - } - }, - "events": { - "type": "object", - "additionalProperties": { "$ref": "#/definitions/eventContribution" } - }, - "importers": { - "type": "object", - "additionalProperties": { - "$ref": "#/definitions/importerContribution" - } - } - } - } - }, - "definitions": { - "contribution": { - "type": "object", - "required": ["title"], - "properties": { "title": { "type": "string" } } - }, - "settingContribution": { - "allOf": [ - { "$ref": "#/definitions/contribution" }, - { - "type": "object", - "required": ["scope", "type"], - "properties": { - "scope": { - "type": "array", - "items": { - "type": "string", - "enum": ["account", "user"] - } - }, - "type": { - "type": "string", - "enum": ["boolean", "color", "string", "number"] - }, - "default": {}, - "description": { - "type": "string" - }, - "array": { "type": "boolean" }, - "options": { - "type": "array", - "items": { - "type": "object", - "additionalProperties": false, - "required": ["label", "value"], - "properties": { - "label": { "type": "string" }, - "value": {} - } - } - } - } - } - ] - }, - "codeContribution": { - "allOf": [ - { "$ref": "#/definitions/contribution" }, - { - "type": "object", - "required": ["entryPoint"], - "properties": { - "entryPoint": { "type": "string" } - } - } - ] - }, - "viewPageContribution": { - "allOf": [ - { "$ref": "#/definitions/codeContribution" }, - { - "type": "object", - "required": ["host", "location"], - "properties": { - "host": { "type": "string", "enum": ["page"] }, - "location": { - "type": "object", - "required": ["menu"], - "properties": { "menu": { "type": "string" } } - } - } - } - ] - }, - "viewPanelContribution": { - "allOf": [ - { "$ref": "#/definitions/codeContribution" }, - { - "type": "object", - "required": ["host"], - "properties": { - "host": { "type": "string", "enum": ["panel"] } - } - } - ] - }, - "viewDrawerContribution": { - "allOf": [ - { "$ref": "#/definitions/codeContribution" }, - { - "type": "object", - "required": ["host"], - "properties": { - "host": { "type": "string", "enum": ["drawer"] } - } - } - ] - }, - "viewOtherContribution": { - "allOf": [ - { "$ref": "#/definitions/codeContribution" }, - { - "type": "object", - "required": ["host", "recordTypes"], - "properties": { - "host": { - "type": "string", - "enum": ["attribute", "tab"] - }, - "recordTypes": { - "type": "array", - "items": { - "type": "string", - "enum": ["Feature", "Epic", "Requirement", "Ideas::Idea"] - } - } - } - } - ] - }, - "viewContribution": { - "anyOf": [ - { "$ref": "#/definitions/viewPageContribution" }, - { "$ref": "#/definitions/viewPanelContribution" }, - { "$ref": "#/definitions/viewDrawerContribution" }, - { "$ref": "#/definitions/viewOtherContribution" } - ] - }, - "commandContribution": { - "allOf": [{ "$ref": "#/definitions/codeContribution" }] - }, - "endpointContribution": { - "allOf": [ - { "$ref": "#/definitions/codeContribution" }, - { - "type": "object", - "properties": { - "public": { "type": "boolean" } - } - } - ] - }, - "eventContribution": { - "allOf": [ - { "$ref": "#/definitions/codeContribution" }, - { - "type": "object", - "properties": { - "handles": { - "type": "array", - "items": { "type": "string" }, - "minItems": 1 - } - } - } - ] - }, - "importerContribution": { - "allOf": [{ "$ref": "#/definitions/codeContribution" }] - } - } -} diff --git a/src/commands/extension/create.ts b/src/commands/extension/create.ts index a9cd01f..e630f51 100644 --- a/src/commands/extension/create.ts +++ b/src/commands/extension/create.ts @@ -1,9 +1,8 @@ import ux from 'cli-ux'; import * as fs from 'fs'; import * as inquirer from 'inquirer'; -import * as path from 'path'; import BaseCommand from '../../base'; -import { packageRoot } from '../../utils/package-info'; +import { fetchRemoteTypes } from '../../utils/extension-utils'; import questions from '../../utils/questions'; import templates from '../../utils/templates'; @@ -88,20 +87,6 @@ export default class Create extends BaseCommand { templates.readmeTemplate(extensionAnswers.name) ); - const modulePath = path.join(directoryName, 'node_modules', 'aha-cli'); - fs.mkdirSync(path.join(modulePath, 'schema'), { recursive: true }); - fs.copyFileSync( - path.join(packageRoot(), 'aha.d.ts'), - path.join(modulePath, 'aha.d.ts') - ); - fs.copyFileSync( - path.join(packageRoot(), 'schema', 'schema.json'), - path.join(modulePath, 'schema', 'schema.json') - ); - fs.copyFileSync( - path.join(packageRoot(), 'schema', 'package-schema.json'), - path.join(modulePath, 'schema', 'package-schema.json') - ); fs.writeFileSync( `${directoryName}/tsconfig.json`, templates.tsconfigTemplate() @@ -123,6 +108,8 @@ export default class Create extends BaseCommand { ahaExtensionSchema.contributes ); + await fetchRemoteTypes(directoryName); + ux.action.stop(`Extension created in directory '${directoryName}'`); } } diff --git a/src/commands/extension/install.ts b/src/commands/extension/install.ts index a7ca00f..774a8d4 100644 --- a/src/commands/extension/install.ts +++ b/src/commands/extension/install.ts @@ -1,6 +1,9 @@ import BaseCommand from '../../base'; import { flags } from '@oclif/command'; -import { installExtension } from '../../utils/extension-utils'; +import { + fetchRemoteTypes, + installExtension, +} from '../../utils/extension-utils'; export default class Install extends BaseCommand { static needsAuth = true; @@ -19,5 +22,6 @@ export default class Install extends BaseCommand { async run() { await installExtension(this, this.flags.dumpCode, this.flags.noCache); + await fetchRemoteTypes(); } } diff --git a/src/commands/extension/watch.ts b/src/commands/extension/watch.ts index c922d6a..2ae9645 100644 --- a/src/commands/extension/watch.ts +++ b/src/commands/extension/watch.ts @@ -1,7 +1,10 @@ import BaseCommand from '../../base'; import { flags } from '@oclif/command'; import * as chokidar from 'chokidar'; -import { installExtension } from '../../utils/extension-utils'; +import { + fetchRemoteTypes, + installExtension, +} from '../../utils/extension-utils'; const WAIT_TIMEOUT = 250; export default class Watch extends BaseCommand { @@ -27,6 +30,8 @@ export default class Watch extends BaseCommand { await this.performInstall(); this.log('Watching for changes in the current directory ...'); + await fetchRemoteTypes(); + chokidar .watch('.', { ignoreInitial: true, ignored: '.git' }) .on('all', async (event, changedPath) => { diff --git a/src/utils/extension-utils.ts b/src/utils/extension-utils.ts index d0a81bc..1393799 100644 --- a/src/utils/extension-utils.ts +++ b/src/utils/extension-utils.ts @@ -3,6 +3,8 @@ import ux from 'cli-ux'; import * as esbuild from 'esbuild'; import * as FormData from 'form-data'; import * as fs from 'fs'; +import * as path from 'path'; +import HTTP from 'http-call'; import { Readable } from 'stream'; import { createGzip } from 'zlib'; import BaseCommand from '../base'; @@ -24,6 +26,33 @@ export function identifierFromConfiguration(configuration: any) { return configuration.name.replace('@', '').replace('/', '.'); } +export async function fetchRemoteTypes(extensionRoot = process.cwd()) { + ux.action.start('Downloading JSON schemas and TypeScript types from Aha!'); + + // prettier-ignore + const typings = { + './types/aha-components.d.ts': 'https://cdn.aha.io/assets/extensions/types/aha-components.d.ts', + './types/aha-models.d.ts': 'https://cdn.aha.io/assets/extensions/types/aha-models.d.ts', + './schema/schema.json': 'https://cdn.aha.io/assets/extensions/schema/schema.json', + './schema/package-schema.json': 'https://cdn.aha.io/assets/extensions/schema/package-schema.json', + }; + + const modulePath = path.join(extensionRoot, '.aha-cache'); + + const promises = Object.entries(typings).map(async ([filePath, url]) => { + const absoluteFilePath = path.join(modulePath, filePath); + fs.mkdirSync(path.dirname(absoluteFilePath), { recursive: true }); + const fileStream = fs.createWriteStream(absoluteFilePath); + + const result = await HTTP.get(url, { raw: true }); + result.response.pipe(fileStream); + return new Promise(resolve => fileStream.on('close', resolve)); + }); + + await Promise.all(promises); + ux.action.stop(); +} + function fileNameFromConfiguration(configuration: any) { return `${identifierFromConfiguration(configuration)}-v${ configuration.version diff --git a/src/utils/package-info.ts b/src/utils/package-info.ts deleted file mode 100644 index 866b3f0..0000000 --- a/src/utils/package-info.ts +++ /dev/null @@ -1,28 +0,0 @@ -import * as fs from 'fs'; -import * as path from 'path'; - -let _packageRoot: string; -export function packageRoot() { - if (_packageRoot) return _packageRoot; - - let searchDir = path.resolve(__dirname); - - while (path.dirname(searchDir) !== searchDir) { - try { - if (fs.statSync(path.join(searchDir, 'package.json')).isFile()) { - _packageRoot = searchDir; - return searchDir; - } - } catch (error) {} - - searchDir = path.dirname(searchDir); - } - - throw new Error('Cannot find package root'); -} - -export function packageInfo() { - return JSON.parse( - fs.readFileSync(path.join(packageRoot(), 'package.json')) as any - ); -} diff --git a/src/utils/templates.ts b/src/utils/templates.ts index a8cac92..1278d5c 100644 --- a/src/utils/templates.ts +++ b/src/utils/templates.ts @@ -1,5 +1,3 @@ -import { packageInfo } from './package-info'; - export default { writeContributionTemplates( fs: any, @@ -181,7 +179,6 @@ aha.on({ event: '${event}' }, (arg, { identifier, settings }) => { author: string, ahaExtensionsSchema: { [k: string]: any } ) { - const version = packageInfo().version; const packageJson: { [k: string]: any } = { name: identifier, description: name, @@ -193,7 +190,7 @@ aha.on({ event: '${event}' }, (arg, { identifier, settings }) => { }, license: 'MIT', devDependencies: { - 'aha-cli': version, + '@types/react': '^16.8.0', }, ahaExtension: ahaExtensionsSchema, }; @@ -281,7 +278,7 @@ To learn more about developing Aha! Develop extensions, including the API refere "moduleResolution": "node", "target": "ES6" }, - "include": ["node_modules/aha-cli/aha.d.ts", "src/**/*.ts*"] + "include": [".aha-cache/types", "src"] }`; }, @@ -290,7 +287,7 @@ To learn more about developing Aha! Develop extensions, including the API refere "json.schemas": [ { "fileMatch": ["package.json"], - "url": "./node_modules/aha-cli/schema/package-schema.json" + "url": "./.aha-cache/schema/package-schema.json" } ] }`;