From 16200e0f417b8f2246dba1966ff19b24a3a54dcb Mon Sep 17 00:00:00 2001 From: tkqubo Date: Mon, 1 Feb 2016 01:30:28 +0900 Subject: [PATCH 1/3] add typings for resource --- asana/asana-tests.ts | 2 +- asana/asana.d.ts | 514 +++++++++++++++++++++++++++++++++---------- 2 files changed, 397 insertions(+), 119 deletions(-) diff --git a/asana/asana-tests.ts b/asana/asana-tests.ts index 050fbb36f..c1531ec9d 100644 --- a/asana/asana-tests.ts +++ b/asana/asana-tests.ts @@ -36,7 +36,7 @@ client.useOauth({ // https://github.com/Asana/node-asana#collections // Collections -let tagId: string = null; +let tagId: number = null; client.tasks.findByTag(tagId, { limit: 5 }).then((collection: any) => { console.log(collection.data); // [ .. array of up to 5 task objects .. ] diff --git a/asana/asana.d.ts b/asana/asana.d.ts index 85e202788..1746a60e1 100644 --- a/asana/asana.d.ts +++ b/asana/asana.d.ts @@ -8,8 +8,6 @@ declare module "asana" { import * as Promise from 'bluebird'; - import {CoreOptions} from 'request'; - import * as request from 'request'; namespace asana { var Client: ClientStatic; @@ -781,6 +779,26 @@ declare module "asana" { } namespace resources { + interface AttachmentsStatic { + /** + * @param dispatcher + */ + new (dispatcher: Dispatcher): Attachments; + } + + namespace Attachments { + interface Type extends IdAndName { + created_at: string; + permanent_url: string; + download_url: string; + view_url: string; + host: string; + parent: IdAndName; + } + } + + var Attachments: AttachmentsStatic; + /** * An _attachment_ object represents any file attached to a task in Asana, * whether it's an uploaded file or one associated via a third-party service @@ -788,12 +806,7 @@ declare module "asana" { * @class * @param {Dispatcher} dispatcher The API dispatcher */ - class Attachments extends Resource { - /** - * @param dispatcher - */ - constructor(dispatcher: Dispatcher); - + interface Attachments extends Resource { /** * * Returns the full record for a single attachment. * * @param {String} attachment Globally unique identifier for the attachment. @@ -805,7 +818,7 @@ declare module "asana" { * @param dispatchOptions? * @return */ - findById(attachment: string, params?: any, dispatchOptions?: any): Promise; + findById(attachment: number, params?: Params, dispatchOptions?: any): Promise; /** * * Returns the compact records for all attachments on the task. @@ -818,9 +831,19 @@ declare module "asana" { * @param dispatchOptions? * @return */ - findByTask(task: string, params?: any, dispatchOptions?: any): Promise; + findByTask(task: number, params?: PaginationParams, dispatchOptions?: any): Promise>; } + interface EventsStatic { + /** + * @param dispatcher + * @return + */ + new (dispatcher: Dispatcher): Events; + } + + var Events: EventsStatic; + /** * An _event_ is an object representing a change to a resource that was observed * by an event subscription. @@ -850,14 +873,68 @@ declare module "asana" { * @class * @param {Dispatcher} dispatcher The API dispatcher */ - class Events extends Resource { + interface Events extends Resource { } + + interface ProjectsStatic { /** * @param dispatcher - * @return */ - constructor(dispatcher: Dispatcher); + new (dispatcher: Dispatcher): Projects; } + namespace Projects { + interface Type extends IdAndName { + created_at: string; + modified_at: string; + due_date: string; + current_status: Status; + public: boolean; + archived: boolean; + notes: string; + color: string; + workspace: IdAndName; + team: IdAndName; + members: IdAndName[]; + followers: IdAndName[]; + } + + interface CreateParams { + name?: string; + team?: number; + public?: boolean; + due_date: string; + notes?: string; + color?: string; + } + + interface FollowersParams { + followers: (number|string)[]; + } + + interface MembersParams { + members: (number|string)[]; + } + + interface Status { + color: string; + text: string; + html_text: string; + modified_at: string; + author: IdAndName; + } + + interface FindAllParams extends PaginationParams { + team?: number; + archived?: boolean; + } + + interface FindByParams extends PaginationParams { + archived?: boolean; + } + } + + var Projects: ProjectsStatic; + /** * A _project_ represents a prioritized list of tasks in Asana. It exists in a * single workspace or organization and is accessible to a subset of users in @@ -870,12 +947,7 @@ declare module "asana" { * @class * @param {Dispatcher} dispatcher The API dispatcher */ - class Projects extends Resource { - /** - * @param dispatcher - */ - constructor(dispatcher: Dispatcher); - + interface Projects extends Resource { /** * * Creates a new project in a workspace or team. * * @@ -898,7 +970,7 @@ declare module "asana" { * @param dispatchOptions? * @return */ - create(data: any, dispatchOptions?: any): Promise; + create(data: Projects.CreateParams & { workspace: number }, dispatchOptions?: any): Promise; /** * * If the workspace for your project _is_ an organization, you must also @@ -914,7 +986,7 @@ declare module "asana" { * @param dispatchOptions? * @return */ - createInWorkspace(workspace: string, data: any, dispatchOptions?: any): Promise; + createInWorkspace(workspace: number, data: Projects.CreateParams, dispatchOptions?: any): Promise; /** * * Creates a project shared with the given team. @@ -929,7 +1001,7 @@ declare module "asana" { * @param dispatchOptions? * @return */ - createInTeam(team: string, data: any, dispatchOptions?: any): Promise; + createInTeam(team: number, data: Projects.CreateParams, dispatchOptions?: any): Promise; /** * * Returns the complete project record for a single project. @@ -942,7 +1014,7 @@ declare module "asana" { * @param dispatchOptions? * @return */ - findById(project: string, params?: any, dispatchOptions?: any): Promise; + findById(project: number, params?: Params, dispatchOptions?: any): Promise; /** * * A specific, existing project can be updated by making a PUT request on the @@ -963,7 +1035,7 @@ declare module "asana" { * @param dispatchOptions? * @return */ - update(project: string, data: any, dispatchOptions?: any): Promise; + update(project: number, data: Projects.CreateParams, dispatchOptions?: any): Promise; /** * * A specific, existing project can be deleted by making a DELETE request @@ -977,7 +1049,7 @@ declare module "asana" { * @param dispatchOptions? * @return */ - delete(project: string, dispatchOptions?: any): Promise; + delete(project: number, dispatchOptions?: any): Promise; /** * * Returns the compact project records for some filtered set of projects. @@ -993,7 +1065,7 @@ declare module "asana" { * @param dispatchOptions? * @return */ - findAll(params?: any, dispatchOptions?: any): Promise; + findAll(params?: Projects.FindAllParams, dispatchOptions?: any): Promise>; /** * * Returns the compact project records for all projects in the workspace. @@ -1008,7 +1080,7 @@ declare module "asana" { * @param dispatchOptions? * @return */ - findByWorkspace(workspace: string, params?: any, dispatchOptions?: any): Promise; + findByWorkspace(workspace: number, params?: Projects.FindByParams, dispatchOptions?: any): Promise>; /** * * Returns the compact project records for all projects in the team. @@ -1023,7 +1095,7 @@ declare module "asana" { * @param dispatchOptions? * @return */ - findByTeam(team: string, params?: any, dispatchOptions?: any): Promise; + findByTeam(team: number, params?: Projects.FindByParams, dispatchOptions?: any): Promise>; /** * * Returns compact records for all sections in the specified project. @@ -1036,7 +1108,7 @@ declare module "asana" { * @param dispatchOptions? * @return */ - sections(project: string, params?: any, dispatchOptions?: any): Promise; + sections(project: number, params?: PaginationParams, dispatchOptions?: any): Promise>; /** * * Returns the compact task records for all tasks within the given project, @@ -1050,7 +1122,7 @@ declare module "asana" { * @param dispatchOptions? * @return */ - tasks(project: string, params?: any, dispatchOptions?: any): Promise; + tasks(project: number, params?: PaginationParams, dispatchOptions?: any): Promise>; /** * * Adds the specified list of users as followers to the project. Followers are a subset of members, therefore if @@ -1066,7 +1138,7 @@ declare module "asana" { * @param dispatchOptions? * @return */ - addFollowers(project: string, data: any, dispatchOptions?: any): Promise; + addFollowers(project: number, data: Projects.FollowersParams, dispatchOptions?: any): Promise; /** * * Removes the specified list of users from following the project, this will not affect project membership status. @@ -1081,7 +1153,7 @@ declare module "asana" { * @param dispatchOptions? * @return */ - removeFollowers(project: string, data: any, dispatchOptions?: any): Promise; + removeFollowers(project: number, data: Projects.FollowersParams, dispatchOptions?: any): Promise; /** * * Adds the specified list of users as members of the project. Returns the updated project record. @@ -1095,7 +1167,7 @@ declare module "asana" { * @param dispatchOptions? * @return */ - addMembers(project: string, data: any, dispatchOptions?: any): Promise; + addMembers(project: number, data: Projects.MembersParams, dispatchOptions?: any): Promise; /** * * Removes the specified list of members from the project. Returns the updated project record. @@ -1109,9 +1181,34 @@ declare module "asana" { * @param dispatchOptions? * @return */ - removeMembers(project: string, data: any, dispatchOptions?: any): Promise; + removeMembers(project: number, data: Projects.MembersParams, dispatchOptions?: any): Promise; } + interface StoriesStatic { + /** + * @param dispatcher + */ + new (dispatcher: Dispatcher): Stories; + } + + namespace Stories { + interface ShortType extends IdAndName { + created_at: string; + created_by: IdAndName; + type: string; + text: string; + } + + interface Type extends ShortType { + html_text: string; + source: string; + target: IdAndName; + hearts: Type[]; + } + } + + var Stories: StoriesStatic; + /** * A _story_ represents an activity associated with an object in the Asana * system. Stories are generated by the system whenever users take actions such @@ -1123,13 +1220,7 @@ declare module "asana" { * @class * @param {Dispatcher} dispatcher The API dispatcher */ - class Stories extends Resource { - /** - * - * @param dispatcher - */ - constructor(dispatcher: Dispatcher); - + interface Stories extends Resource { /** * * Returns the compact records for all stories on the task. * * @param {String} task Globally unique identifier for the task. @@ -1141,7 +1232,7 @@ declare module "asana" { * @param dispatchOptions? * @return */ - findByTask(task: string, params?: any, dispatchOptions?: any): Promise; + findByTask(task: number, params?: PaginationParams, dispatchOptions?: any): Promise>; /** * * Returns the full record for a single story. @@ -1154,7 +1245,7 @@ declare module "asana" { * @param dispatchOptions? * @return */ - findById(story: string, params?: any, dispatchOptions?: any): Promise; + findById(story: number, params?: Params, dispatchOptions?: any): Promise; /** * * Adds a comment to a task. The comment will be authored by the @@ -1172,9 +1263,33 @@ declare module "asana" { * @param dispatchOptions? * @return */ - createOnTask(task: string, data: any, dispatchOptions?: any): Promise; + createOnTask(task: string, data: any, dispatchOptions?: any): Promise>; } + interface TagsStatic { + /** + * @param dispatcher + */ + new (dispatcher: Dispatcher): Tags; + } + + namespace Tags { + interface Type extends IdAndName { + created_at: string; + notes: string; + workspace: IdAndName; + color: string; + followers: IdAndName[]; + } + + interface FindAllParams extends PaginationParams { + team?: number; + archived?: boolean; + } + } + + var Tags: TagsStatic; + /** * A _tag_ is a label that can be attached to any task in Asana. It exists in a * single workspace or organization. @@ -1186,12 +1301,7 @@ declare module "asana" { * @class * @param {Dispatcher} dispatcher The API dispatcher */ - class Tags extends Resource { - /** - * @param dispatcher - */ - constructor(dispatcher: Dispatcher); - + interface Tags extends Resource { /** * * Creates a new tag in a workspace or organization. * * @@ -1209,7 +1319,7 @@ declare module "asana" { * @param dispatchOptions? * @return */ - create(data: any, dispatchOptions?: any): Promise; + create(data: Tags.Type & { workspace: string }, dispatchOptions?: any): Promise; /** * * Creates a new tag in a workspace or organization. @@ -1229,7 +1339,7 @@ declare module "asana" { * @param dispatchOptions? * @return */ - createInWorkspace(workspace: string, data: any, dispatchOptions?: any): Promise; + createInWorkspace(workspace: number, data: Tags.Type, dispatchOptions?: any): Promise; /** * * Returns the complete tag record for a single tag. @@ -1242,7 +1352,7 @@ declare module "asana" { * @param dispatchOptions? * @return */ - findById(tag: string, params?: any, dispatchOptions?: any): Promise; + findById(tag: number, params?: Params, dispatchOptions?: any): Promise; /** * * Updates the properties of a tag. Only the fields provided in the `data` @@ -1262,7 +1372,7 @@ declare module "asana" { * @param dispatchOptions? * @return */ - update(tag: string, data: any, dispatchOptions?: any): Promise; + update(tag: number, data: Tags.Type, dispatchOptions?: any): Promise; /** * * A specific, existing tag can be deleted by making a DELETE request @@ -1276,7 +1386,7 @@ declare module "asana" { * @param dispatchOptions? * @return */ - delete(tag: string, dispatchOptions?: any): Promise; + delete(tag: number, dispatchOptions?: any): Promise; /** * * Returns the compact tag records for some filtered set of tags. @@ -1292,7 +1402,7 @@ declare module "asana" { * @param dispatchOptions? * @return */ - findAll(params?: any, dispatchOptions?: any): Promise; + findAll(params?: Tags.FindAllParams, dispatchOptions?: any): Promise>; /** * * Returns the compact tag records for all tags in the workspace. @@ -1305,7 +1415,7 @@ declare module "asana" { * @param dispatchOptions? * @return */ - findByWorkspace(workspace: string, params?: any, dispatchOptions?: any): Promise; + findByWorkspace(workspace: number, params?: PaginationParams, dispatchOptions?: any): Promise>; /** * * Returns the compact task records for all tasks with the given tag. @@ -1319,9 +1429,77 @@ declare module "asana" { * @param dispatchOptions? * @return */ - getTasksWithTag(tag: string, params?: any, dispatchOptions?: any): Promise; + getTasksWithTag(tag: number, params?: PaginationParams, dispatchOptions?: any): Promise>; } + interface TasksStatic { + /** + * @param dispatcher + */ + new (dispatcher: Dispatcher): Tasks; + } + + namespace Tasks { + interface Type extends IdAndName { + created_at: string; + modified_at: string; + completed_at: string; + completed: boolean; + due_on: string; + due_at: string; + assignee_status: string; + assignee: IdAndName; + notes: string; + workspace: IdAndName; + num_hearts: number; + hearted: boolean; + parent: IdAndName; + tags: IdAndName[]; + projects: IdAndName[]; + memberships: Membership[]; + followers: IdAndName[]; + } + + interface CreateParams { + name: string; + completed?: boolean; + hearted?: boolean; + notes?: string; + } + + interface FollowersParams { + followers: (number|string)[]; + } + + interface AddProjectParams { + project: number; + insertBefore?: number; + insertAfter?: number; + section?: number; + } + + interface RemoveProjectParams { + project: number; + } + + interface TagParams { + tag: string; + } + + interface CommentParams { + text: string; + } + + interface FindAllParams extends PaginationParams { + assignee?: number; + workspace: number; + completed_since?: string; + modified_since?: string; + } + } + + var Tasks: TasksStatic; + /** * The _task_ is the basic object around which many operations in Asana are * centered. In the Asana application, multiple tasks populate the middle pane @@ -1330,12 +1508,7 @@ declare module "asana" { * @class * @param {Dispatcher} dispatcher The API dispatcher */ - class Tasks extends Resource { - /** - * @param dispatcher - */ - constructor(dispatcher: Dispatcher); - + interface Tasks extends Resource { /** * * Creating a new task is as easy as POSTing to the `/tasks` endpoint * * with a data block containing the fields you'd like to set on the task. @@ -1352,7 +1525,7 @@ declare module "asana" { * @param dispatchOptions? * @return */ - create(data: any, dispatchOptions?: any): Promise; + create(data: Tasks.CreateParams & { workspace: string }, dispatchOptions?: any): Promise; /** * * Creating a new task is as easy as POSTing to the `/tasks` endpoint @@ -1371,7 +1544,7 @@ declare module "asana" { * @param dispatchOptions? * @return */ - createInWorkspace(workspace: string, data: any, dispatchOptions?: any): Promise; + createInWorkspace(workspace: number, data: Tasks.CreateParams, dispatchOptions?: any): Promise; /** * * Returns the complete task record for a single task. @@ -1384,7 +1557,7 @@ declare module "asana" { * @param dispatchOptions? * @return */ - findById(task: string, params?: any, dispatchOptions?: any): Promise; + findById(task: number, params?: Params, dispatchOptions?: any): Promise; /** * * A specific, existing task can be updated by making a PUT request on the @@ -1405,7 +1578,7 @@ declare module "asana" { * @param dispatchOptions? * @return */ - update(task: string, data: any, dispatchOptions?: any): Promise; + update(task: number, data: Tasks.CreateParams, dispatchOptions?: any): Promise; /** * * A specific, existing task can be deleted by making a DELETE request on the @@ -1421,7 +1594,7 @@ declare module "asana" { * @param dispatchOptions? * @return */ - delete(task: string, dispatchOptions?: any): Promise; + delete(task: number, dispatchOptions?: any): Promise; /** * * Returns the compact task records for all tasks within the given project, @@ -1435,7 +1608,7 @@ declare module "asana" { * @param dispatchOptions? * @return */ - findByProject(projectId: string, params?: any, dispatchOptions?: any): Promise; + findByProject(projectId: number, params?: PaginationParams, dispatchOptions?: any): Promise>; /** * * Returns the compact task records for all tasks with the given tag. @@ -1448,7 +1621,7 @@ declare module "asana" { * @param dispatchOptions? * @return */ - findByTag(tag: string, params?: any, dispatchOptions?: any): Promise; + findByTag(tag: number, params?: PaginationParams, dispatchOptions?: any): Promise>; /** * * Returns the compact task records for some filtered set of tasks. Use one @@ -1465,7 +1638,7 @@ declare module "asana" { * @param dispatchOptions? * @return */ - findAll(params?: any, dispatchOptions?: any): Promise; + findAll(params?: Tasks.FindAllParams, dispatchOptions?: any): Promise>; /** * * Adds each of the specified followers to the task, if they are not already @@ -1480,7 +1653,7 @@ declare module "asana" { * @param dispatchOptions? * @return */ - addFollowers(task: string, data: any, dispatchOptions?: any): Promise; + addFollowers(task: number, data: Tasks.FollowersParams, dispatchOptions?: any): Promise; /** * * Removes each of the specified followers from the task if they are @@ -1495,7 +1668,7 @@ declare module "asana" { * @param dispatchOptions? * @return */ - removeFollowers(task: string, data: any, dispatchOptions?: any): Promise; + removeFollowers(task: number, data: Tasks.FollowersParams, dispatchOptions?: any): Promise; /** * * Returns a compact representation of all of the projects the task is in. @@ -1508,7 +1681,7 @@ declare module "asana" { * @param dispatchOptions? * @return */ - projects(task: string, params?: any, dispatchOptions?: any): Promise; + projects(task: number, params?: PaginationParams, dispatchOptions?: any): Promise>; /** * * Adds the task to the specified project, in the optional location @@ -1535,7 +1708,7 @@ declare module "asana" { * @param dispatchOptions? * @return */ - addProject(task: string, data: any, dispatchOptions?: any): Promise; + addProject(task: number, data: Tasks.AddProjectParams, dispatchOptions?: any): Promise<{}>; /** * * Removes the task from the specified project. The task will still exist @@ -1552,7 +1725,7 @@ declare module "asana" { * @param dispatchOptions? * @return */ - removeProject(task: string, data: any, dispatchOptions?: any): Promise; + removeProject(task: number, data: Tasks.RemoveProjectParams, dispatchOptions?: any): Promise<{}>; /** * * Returns a compact representation of all of the tags the task has. @@ -1565,7 +1738,7 @@ declare module "asana" { * @param dispatchOptions? * @return */ - tags(task: string, params?: any, dispatchOptions?: any): Promise; + tags(task: number, params?: PaginationParams, dispatchOptions?: any): Promise>; /** * * Adds a tag to a task. Returns an empty data block. @@ -1579,7 +1752,7 @@ declare module "asana" { * @param dispatchOptions? * @return */ - addTag(task: string, data: any, dispatchOptions?: any): Promise; + addTag(task: number, data: Tasks.TagParams, dispatchOptions?: any): Promise<{}>; /** * * Removes a tag from the task. Returns an empty data block. @@ -1593,7 +1766,7 @@ declare module "asana" { * @param dispatchOptions? * @return */ - removeTag(task: string, data: any, dispatchOptions?: any): Promise; + removeTag(task: number, data: Tasks.TagParams, dispatchOptions?: any): Promise<{}>; /** * * Returns a compact representation of all of the subtasks of a task. @@ -1606,7 +1779,7 @@ declare module "asana" { * @param dispatchOptions? * @return */ - subtasks(task: string, params?: any, dispatchOptions?: any): Promise; + subtasks(task: number, params?: PaginationParams, dispatchOptions?: any): Promise>; /** * * Creates a new subtask and adds it to the parent task. Returns the full record @@ -1620,7 +1793,7 @@ declare module "asana" { * @param dispatchOptions? * @return */ - addSubtask(task: string, data: any, dispatchOptions?: any): Promise; + addSubtask(task: number, data: Tasks.CreateParams, dispatchOptions?: any): Promise; /** * * Returns a compact representation of all of the stories on the task. @@ -1633,7 +1806,7 @@ declare module "asana" { * @param dispatchOptions? * @return */ - stories(task: string, params?: any, dispatchOptions?: any): Promise; + stories(task: number, params?: PaginationParams, dispatchOptions?: any): Promise>; /** * * Adds a comment to a task. The comment will be authored by the @@ -1651,21 +1824,31 @@ declare module "asana" { * @param dispatchOptions? * @return */ - addComment(task: string, data: any, dispatchOptions?: any): Promise; + addComment(task: number, data: Tasks.CommentParams, dispatchOptions?: any): Promise; } + interface TeamsStatic { + /** + * @param dispatcher + */ + new (dispatcher: Dispatcher): Teams; + } + + namespace Teams { + interface Type extends IdAndName { + organization: IdAndName; + } + } + + var Teams: TeamsStatic; + /** * A _team_ is used to group related projects and people together within an * organization. Each project in an organization is associated with a team. * @class * @param {Dispatcher} dispatcher The API dispatcher */ - class Teams extends Resource { - /** - * @param dispatcher - */ - constructor(dispatcher: Dispatcher); - + interface Teams extends Resource { /** * * Returns the full record for a single team. * * @param {String} team Globally unique identifier for the team. @@ -1677,7 +1860,7 @@ declare module "asana" { * @param dispatchOptions? * @return */ - findById(team: string, params?: any, dispatchOptions?: any): Promise; + findById(team: number, params?: Params, dispatchOptions?: any): Promise; /** * * Returns the compact records for all teams in the organization visible to @@ -1691,7 +1874,7 @@ declare module "asana" { * @param dispatchOptions? * @return */ - findByOrganization(organization: string, params?: any, dispatchOptions?: any): Promise; + findByOrganization(organization: number, params?: Params, dispatchOptions?: any): Promise; /** * * Returns the compact records for all users that are members of the team. @@ -1704,7 +1887,7 @@ declare module "asana" { * @param dispatchOptions? * @return */ - users(team: string, params?: any, dispatchOptions?: any): Promise; + users(team: number, params?: Params, dispatchOptions?: any): Promise; /** * * The user making this call must be a member of the team in order to add others. @@ -1723,7 +1906,7 @@ declare module "asana" { * @param dispatchOptions? * @return */ - addUser(team: string, data: any, dispatchOptions?: any): Promise; + addUser(team: string, data: UserParams, dispatchOptions?: any): Promise; /** * * The user to remove can be referenced by their globally unique user ID or their email address. @@ -1740,9 +1923,30 @@ declare module "asana" { * @param dispatchOptions? * @return */ - removeUser(team: string, data: any, dispatchOptions?: any): Promise; + removeUser(team: string, data: UserParams, dispatchOptions?: any): Promise; } + interface UsersStatic { + /** + * @param dispatcher + */ + new (dispatcher: Dispatcher): Users; + } + + namespace Users { + interface FindAllParams extends PaginationParams { + workspace: number; + } + + interface Type extends IdAndName { + email: string; + workspaces: IdAndName[]; + photo: { [key: string]: string }; + } + } + + var Users: UsersStatic; + /** * A _user_ object represents an account in Asana that can be given access to * various workspaces, projects, and tasks. @@ -1753,12 +1957,7 @@ declare module "asana" { * @class * @param {Dispatcher} dispatcher The API dispatcher */ - class Users extends Resource { - /** - * @param dispatcher - */ - constructor(dispatcher: Dispatcher); - + interface Users extends Resource { /** * * Returns the full user record for the currently authenticated user. * * @param {Object} [params] Parameters for the request @@ -1768,7 +1967,7 @@ declare module "asana" { * @param dispatchOptions? * @return */ - me(params?: any, dispatchOptions?: any): Promise; + me(params?: Params, dispatchOptions?: any): Promise; /** * * Returns the full user record for the single user with the provided ID. @@ -1783,7 +1982,7 @@ declare module "asana" { * @param dispatchOptions? * @return */ - findById(user: string, params?: any, dispatchOptions?: any): Promise; + findById(user: string|number, params?: Params, dispatchOptions?: any): Promise; /** * * Returns the user records for all users in the specified workspace or @@ -1797,7 +1996,7 @@ declare module "asana" { * @param dispatchOptions? * @return */ - findByWorkspace(workspace: string, params?: any, dispatchOptions?: any): Promise; + findByWorkspace(workspace: number, params?: Params, dispatchOptions?: any): Promise>; /** * * Returns the user records for all users in all workspaces and organizations @@ -1807,11 +2006,11 @@ declare module "asana" { * * @param {String} [params.workspace] The workspace or organization to filter users on. * * @param {Object} [dispatchOptions] Options, if any, to pass the dispatcher for the request * * @return {Promise} The response from the API - * @param params? + * @param params * @param dispatchOptions? * @return */ - findAll(params?: any, dispatchOptions?: any): Promise; + findAll(params: Users.FindAllParams, dispatchOptions?: any): Promise; } /** @@ -1941,6 +2140,32 @@ declare module "asana" { deleteById(webhook: string, dispatchOptions?: any): Promise; } + interface WorkspacesStatic { + /** + * @param dispatcher + */ + new (dispatcher: Dispatcher): Workspaces; + } + + namespace Workspaces { + interface ShortType extends IdAndName { + id_organization?: boolean; + } + + interface Type extends IdAndName { + id_organization: boolean; + email_domains: string[]; + } + + interface TypeaheadParams { + type: string; + query?: string; + count?: number; + } + } + + var Workspaces: WorkspacesStatic; + /** * A _workspace_ is the highest-level organizational unit in Asana. All projects * and tasks have an associated workspace. @@ -1959,12 +2184,7 @@ declare module "asana" { * @class * @param {Dispatcher} dispatcher The API dispatcher */ - class Workspaces extends Resource { - /** - * @param dispatcher - */ - constructor(dispatcher: Dispatcher); - + interface Workspaces extends Resource { /** * * Returns the full workspace record for a single workspace. * * @param {String} workspace Globally unique identifier for the workspace or organization. @@ -1976,7 +2196,7 @@ declare module "asana" { * @param dispatchOptions? * @return */ - findById(workspace: string, params?: any, dispatchOptions?: any): Promise; + findById(workspace: number, params?: Params, dispatchOptions?: any): Promise; /** * * Returns the compact records for all workspaces visible to the authorized user. @@ -1987,7 +2207,7 @@ declare module "asana" { * @param dispatchOptions? * @return */ - findAll(params?: any, dispatchOptions?: any): Promise; + findAll(params?: PaginationParams, dispatchOptions?: any): Promise>; /** * * A specific, existing workspace can be updated by making a PUT request on @@ -2006,7 +2226,7 @@ declare module "asana" { * @param dispatchOptions? * @return */ - update(workspace: string, data: any, dispatchOptions?: any): Promise; + update(workspace: number, data: { name?: string }, dispatchOptions?: any): Promise; /** * * Retrieves objects in the workspace based on an auto-completion/typeahead @@ -2032,7 +2252,7 @@ declare module "asana" { * @param dispatchOptions? * @return */ - typeahead(workspace: string, params?: any, dispatchOptions?: any): Promise; + typeahead(workspace: number, params?: Workspaces.TypeaheadParams, dispatchOptions?: any): Promise; /** * * The user can be referenced by their globally unique user ID or their email address. @@ -2049,7 +2269,7 @@ declare module "asana" { * @param dispatchOptions? * @return */ - addUser(workspace: string, data: any, dispatchOptions?: any): Promise; + addUser(workspace: number, data: UserParams, dispatchOptions?: any): Promise; /** * * The user making this call must be an admin in the workspace. @@ -2066,7 +2286,7 @@ declare module "asana" { * @param dispatchOptions? * @return */ - removeUser(workspace: string, data: any, dispatchOptions?: any): Promise; + removeUser(workspace: number, data: UserParams, dispatchOptions?: any): Promise; } interface ResourceStatic { @@ -2189,6 +2409,64 @@ declare module "asana" { */ dispatchDelete(path: string, dispatchOptions?: any): Promise; } + + interface CollectionBase { + data: T[]; + _response: { + data: T[]; + next_page?: NextPage; + }; + _dispatcher: { + authenticator: { + apiKey: string; + }; + asanaBaseUrl: string; + retryOnRateLimit: boolean; + requestTimeout: number; + _cachedVersionInfo: VersionInfo; + } + + } + + type Collection = CollectionBase; + + interface NextPage { + offset: string; + uri: string; + path: string; + } + + interface VersionInfo { + version: string; + language: string; + language_version: string; + os: string; + os_version: string; + } + + interface IdAndName { + id: number; + name: string; + } + + interface PaginationParams extends Params { + limit?: number; + offset?: string; + } + + interface Params { + opt_fields?: string; + opt_expand?: string; + } + + interface UserParams { + user: string|number; + } + + interface Membership { + project: IdAndName; + section: IdAndName; + } } var VERSION: string; From 6a468d54f6848258a0d1c7971c80a348eeae213d Mon Sep 17 00:00:00 2001 From: tkqubo Date: Mon, 1 Feb 2016 01:39:35 +0900 Subject: [PATCH 2/3] docs: fix comments for method parameters to match the actual type --- asana/asana.d.ts | 156 +++++++++++++++++++++++------------------------ 1 file changed, 78 insertions(+), 78 deletions(-) diff --git a/asana/asana.d.ts b/asana/asana.d.ts index 1746a60e1..513312ff7 100644 --- a/asana/asana.d.ts +++ b/asana/asana.d.ts @@ -809,7 +809,7 @@ declare module "asana" { interface Attachments extends Resource { /** * * Returns the full record for a single attachment. - * * @param {String} attachment Globally unique identifier for the attachment. + * * @param {Number} attachment Globally unique identifier for the attachment. * * @param {Object} [params] Parameters for the request * * @param {Object} [dispatchOptions] Options, if any, to pass the dispatcher for the request * * @return {Promise} The requested resource @@ -822,7 +822,7 @@ declare module "asana" { /** * * Returns the compact records for all attachments on the task. - * * @param {String} task Globally unique identifier for the task. + * * @param {Number} task Globally unique identifier for the task. * * @param {Object} [params] Parameters for the request * * @param {Object} [dispatchOptions] Options, if any, to pass the dispatcher for the request * * @return {Promise} The response from the API @@ -977,7 +977,7 @@ declare module "asana" { * * supply a `team` to share the project with. * * * * Returns the full record of the newly created project. - * * @param {String} workspace The workspace or organization to create the project in. + * * @param {Number} workspace The workspace or organization to create the project in. * * @param {Object} data Data for the request * * @param {Object} [dispatchOptions] Options, if any, to pass the dispatcher for the request * * @return {Promise} The response from the API @@ -992,7 +992,7 @@ declare module "asana" { * * Creates a project shared with the given team. * * * * Returns the full record of the newly created project. - * * @param {String} team The team to create the project in. + * * @param {Number} team The team to create the project in. * * @param {Object} data Data for the request * * @param {Object} [dispatchOptions] Options, if any, to pass the dispatcher for the request * * @return {Promise} The response from the API @@ -1005,7 +1005,7 @@ declare module "asana" { /** * * Returns the complete project record for a single project. - * * @param {String} project The project to get. + * * @param {Number} project The project to get. * * @param {Object} [params] Parameters for the request * * @param {Object} [dispatchOptions] Options, if any, to pass the dispatcher for the request * * @return {Promise} The requested resource @@ -1026,7 +1026,7 @@ declare module "asana" { * * you last retrieved the task. * * * * Returns the complete updated project record. - * * @param {String} project The project to update. + * * @param {Number} project The project to update. * * @param {Object} data Data for the request * * @param {Object} [dispatchOptions] Options, if any, to pass the dispatcher for the request * * @return {Promise} The response from the API @@ -1042,7 +1042,7 @@ declare module "asana" { * * on the URL for that project. * * * * Returns an empty data record. - * * @param {String} project The project to delete. + * * @param {Number} project The project to delete. * * @param {Object} [dispatchOptions] Options, if any, to pass the dispatcher for the request * * @return {Promise} The response from the API * @param project @@ -1069,7 +1069,7 @@ declare module "asana" { /** * * Returns the compact project records for all projects in the workspace. - * * @param {String} workspace The workspace or organization to find projects in. + * * @param {Number} workspace The workspace or organization to find projects in. * * @param {Object} [params] Parameters for the request * * @param {Boolean} [params.archived] Only return projects whose `archived` field takes on the value of * * this parameter. @@ -1084,7 +1084,7 @@ declare module "asana" { /** * * Returns the compact project records for all projects in the team. - * * @param {String} team The team to find projects in. + * * @param {Number} team The team to find projects in. * * @param {Object} [params] Parameters for the request * * @param {Boolean} [params.archived] Only return projects whose `archived` field takes on the value of * * this parameter. @@ -1099,7 +1099,7 @@ declare module "asana" { /** * * Returns compact records for all sections in the specified project. - * * @param {String} project The project to get sections from. + * * @param {Number} project The project to get sections from. * * @param {Object} [params] Parameters for the request * * @param {Object} [dispatchOptions] Options, if any, to pass the dispatcher for the request * * @return {Promise} The response from the API @@ -1113,7 +1113,7 @@ declare module "asana" { /** * * Returns the compact task records for all tasks within the given project, * * ordered by their priority within the project. Tasks can exist in more than one project at a time. - * * @param {String} project The project in which to search for tasks. + * * @param {Number} project The project in which to search for tasks. * * @param {Object} [params] Parameters for the request * * @param {Object} [dispatchOptions] Options, if any, to pass the dispatcher for the request * * @return {Promise} The response from the API @@ -1128,7 +1128,7 @@ declare module "asana" { * * Adds the specified list of users as followers to the project. Followers are a subset of members, therefore if * * the users are not already members of the project they will also become members as a result of this operation. * * Returns the updated project record. - * * @param {String} project The project to add followers to. + * * @param {Number} project The project to add followers to. * * @param {Object} data Data for the request * * @param {Array} data.followers An array of followers to add to the project. * * @param {Object} [dispatchOptions] Options, if any, to pass the dispatcher for the request @@ -1143,7 +1143,7 @@ declare module "asana" { /** * * Removes the specified list of users from following the project, this will not affect project membership status. * * Returns the updated project record. - * * @param {String} project The project to remove followers from. + * * @param {Number} project The project to remove followers from. * * @param {Object} data Data for the request * * @param {Array} data.followers An array of followers to remove from the project. * * @param {Object} [dispatchOptions] Options, if any, to pass the dispatcher for the request @@ -1157,7 +1157,7 @@ declare module "asana" { /** * * Adds the specified list of users as members of the project. Returns the updated project record. - * * @param {String} project The project to add members to. + * * @param {Number} project The project to add members to. * * @param {Object} data Data for the request * * @param {Array} data.members An array of members to add to the project. * * @param {Object} [dispatchOptions] Options, if any, to pass the dispatcher for the request @@ -1171,7 +1171,7 @@ declare module "asana" { /** * * Removes the specified list of members from the project. Returns the updated project record. - * * @param {String} project The project to remove members from. + * * @param {Number} project The project to remove members from. * * @param {Object} data Data for the request * * @param {Array} data.members An array of members to remove from the project. * * @param {Object} [dispatchOptions] Options, if any, to pass the dispatcher for the request @@ -1223,7 +1223,7 @@ declare module "asana" { interface Stories extends Resource { /** * * Returns the compact records for all stories on the task. - * * @param {String} task Globally unique identifier for the task. + * * @param {Number} task Globally unique identifier for the task. * * @param {Object} [params] Parameters for the request * * @param {Object} [dispatchOptions] Options, if any, to pass the dispatcher for the request * * @return {Promise} The response from the API @@ -1236,7 +1236,7 @@ declare module "asana" { /** * * Returns the full record for a single story. - * * @param {String} story Globally unique identifier for the story. + * * @param {Number} story Globally unique identifier for the story. * * @param {Object} [params] Parameters for the request * * @param {Object} [dispatchOptions] Options, if any, to pass the dispatcher for the request * * @return {Promise} The requested resource @@ -1253,7 +1253,7 @@ declare module "asana" { * * the request. * * * * Returns the full record for the new story added to the task. - * * @param {String} task Globally unique identifier for the task. + * * @param {Number} task Globally unique identifier for the task. * * @param {Object} data Data for the request * * @param {String} data.text The plain text of the comment to add. * * @param {Object} [dispatchOptions] Options, if any, to pass the dispatcher for the request @@ -1263,7 +1263,7 @@ declare module "asana" { * @param dispatchOptions? * @return */ - createOnTask(task: string, data: any, dispatchOptions?: any): Promise>; + createOnTask(task: number, data: any, dispatchOptions?: any): Promise>; } interface TagsStatic { @@ -1330,7 +1330,7 @@ declare module "asana" { * * organization. * * * * Returns the full record of the newly created tag. - * * @param {String} workspace The workspace or organization to create the tag in. + * * @param {Number} workspace The workspace or organization to create the tag in. * * @param {Object} data Data for the request * * @param {Object} [dispatchOptions] Options, if any, to pass the dispatcher for the request * * @return {Promise} The response from the API @@ -1343,7 +1343,7 @@ declare module "asana" { /** * * Returns the complete tag record for a single tag. - * * @param {String} tag The tag to get. + * * @param {Number} tag The tag to get. * * @param {Object} [params] Parameters for the request * * @param {Object} [dispatchOptions] Options, if any, to pass the dispatcher for the request * * @return {Promise} The requested resource @@ -1363,7 +1363,7 @@ declare module "asana" { * * you last retrieved the task. * * * * Returns the complete updated tag record. - * * @param {String} tag The tag to update. + * * @param {Number} tag The tag to update. * * @param {Object} data Data for the request * * @param {Object} [dispatchOptions] Options, if any, to pass the dispatcher for the request * * @return {Promise} The response from the API @@ -1379,7 +1379,7 @@ declare module "asana" { * * on the URL for that tag. * * * * Returns an empty data record. - * * @param {String} tag The tag to delete. + * * @param {Number} tag The tag to delete. * * @param {Object} [dispatchOptions] Options, if any, to pass the dispatcher for the request * * @return {Promise} The response from the API * @param tag @@ -1406,7 +1406,7 @@ declare module "asana" { /** * * Returns the compact tag records for all tags in the workspace. - * * @param {String} workspace The workspace or organization to find tags in. + * * @param {Number} workspace The workspace or organization to find tags in. * * @param {Object} [params] Parameters for the request * * @param {Object} [dispatchOptions] Options, if any, to pass the dispatcher for the request * * @return {Promise} The response from the API @@ -1420,7 +1420,7 @@ declare module "asana" { /** * * Returns the compact task records for all tasks with the given tag. * * Tasks can have more than one tag at a time. - * * @param {String} tag The tag to fetch tasks from. + * * @param {Number} tag The tag to fetch tasks from. * * @param {Object} [params] Parameters for the request * * @param {Object} [dispatchOptions] Options, if any, to pass the dispatcher for the request * * @return {Promise} The response from the API @@ -1518,7 +1518,7 @@ declare module "asana" { * * workspace cannot be changed once set. The workspace need not be set * * explicitly if you specify a `project` or a `parent` task instead. * * @param {Object} data Data for the request - * * @param {String} [data.workspace] The workspace to create a task in. + * * @param {Number} [data.workspace] The workspace to create a task in. * * @param {Object} [dispatchOptions] Options, if any, to pass the dispatcher for the request * * @return {Promise} The response from the API * @param data @@ -1535,7 +1535,7 @@ declare module "asana" { * * Every task is required to be created in a specific workspace, and this * * workspace cannot be changed once set. The workspace need not be set * * explicitly if you specify a `project` or a `parent` task instead. - * * @param {String} workspace The workspace to create a task in. + * * @param {Number} workspace The workspace to create a task in. * * @param {Object} data Data for the request * * @param {Object} [dispatchOptions] Options, if any, to pass the dispatcher for the request * * @return {Promise} The response from the API @@ -1548,7 +1548,7 @@ declare module "asana" { /** * * Returns the complete task record for a single task. - * * @param {String} task The task to get. + * * @param {Number} task The task to get. * * @param {Object} [params] Parameters for the request * * @param {Object} [dispatchOptions] Options, if any, to pass the dispatcher for the request * * @return {Promise} The requested resource @@ -1569,7 +1569,7 @@ declare module "asana" { * * you last retrieved the task. * * * * Returns the complete updated task record. - * * @param {String} task The task to update. + * * @param {Number} task The task to update. * * @param {Object} data Data for the request * * @param {Object} [dispatchOptions] Options, if any, to pass the dispatcher for the request * * @return {Promise} The response from the API @@ -1587,7 +1587,7 @@ declare module "asana" { * * of 30 days; afterward they are completely removed from the system. * * * * Returns an empty data record. - * * @param {String} task The task to delete. + * * @param {Number} task The task to delete. * * @param {Object} [dispatchOptions] Options, if any, to pass the dispatcher for the request * * @return {Promise} The response from the API * @param task @@ -1599,7 +1599,7 @@ declare module "asana" { /** * * Returns the compact task records for all tasks within the given project, * * ordered by their priority within the project. - * * @param {String} projectId The project in which to search for tasks. + * * @param {Number} projectId The project in which to search for tasks. * * @param {Object} [params] Parameters for the request * * @param {Object} [dispatchOptions] Options, if any, to pass the dispatcher for the request * * @return {Promise} The response from the API @@ -1612,7 +1612,7 @@ declare module "asana" { /** * * Returns the compact task records for all tasks with the given tag. - * * @param {String} tag The tag in which to search for tasks. + * * @param {Number} tag The tag in which to search for tasks. * * @param {Object} [params] Parameters for the request * * @param {Object} [dispatchOptions] Options, if any, to pass the dispatcher for the request * * @return {Promise} The response from the API @@ -1627,11 +1627,11 @@ declare module "asana" { * * Returns the compact task records for some filtered set of tasks. Use one * * or more of the parameters provided to filter the tasks returned. * * @param {Object} [params] Parameters for the request - * * @param {String} [params.assignee] The assignee to filter tasks on. - * * @param {String} [params.workspace] The workspace or organization to filter tasks on. - * * @param {String} [params.completed_since] Only return tasks that are either incomplete or that have been + * * @param {Number} [params.assignee] The assignee to filter tasks on. + * * @param {Number} [params.workspace] The workspace or organization to filter tasks on. + * * @param {Number} [params.completed_since] Only return tasks that are either incomplete or that have been * * completed since this time. - * * @param {String} [params.modified_since] Only return tasks that have been modified since the given time. + * * @param {Number} [params.modified_since] Only return tasks that have been modified since the given time. * * @param {Object} [dispatchOptions] Options, if any, to pass the dispatcher for the request * * @return {Promise} The response from the API * @param params? @@ -1643,7 +1643,7 @@ declare module "asana" { /** * * Adds each of the specified followers to the task, if they are not already * * following. Returns the complete, updated record for the affected task. - * * @param {String} task The task to add followers to. + * * @param {Number} task The task to add followers to. * * @param {Object} data Data for the request * * @param {Array} data.followers An array of followers to add to the task. * * @param {Object} [dispatchOptions] Options, if any, to pass the dispatcher for the request @@ -1658,7 +1658,7 @@ declare module "asana" { /** * * Removes each of the specified followers from the task if they are * * following. Returns the complete, updated record for the affected task. - * * @param {String} task The task to remove followers from. + * * @param {Number} task The task to remove followers from. * * @param {Object} data Data for the request * * @param {Array} data.followers An array of followers to remove from the task. * * @param {Object} [dispatchOptions] Options, if any, to pass the dispatcher for the request @@ -1672,7 +1672,7 @@ declare module "asana" { /** * * Returns a compact representation of all of the projects the task is in. - * * @param {String} task The task to get projects on. + * * @param {Number} task The task to get projects on. * * @param {Object} [params] Parameters for the request * * @param {Object} [dispatchOptions] Options, if any, to pass the dispatcher for the request * * @return {Promise} The response from the API @@ -1692,14 +1692,14 @@ declare module "asana" { * * already contains it. * * * * Returns an empty data block. - * * @param {String} task The task to add to a project. + * * @param {Number} task The task to add to a project. * * @param {Object} data Data for the request - * * @param {String} data.project The project to add the task to. - * * @param {String} [data.insertAfter] A task in the project to insert the task after, or `null` to + * * @param {Number} data.project The project to add the task to. + * * @param {Number} [data.insertAfter] A task in the project to insert the task after, or `null` to * * insert at the beginning of the list. - * * @param {String} [data.insertBefore] A task in the project to insert the task before, or `null` to + * * @param {Number} [data.insertBefore] A task in the project to insert the task before, or `null` to * * insert at the end of the list. - * * @param {String} [data.section] A section in the project to insert the task into. The task will be + * * @param {Number} [data.section] A section in the project to insert the task into. The task will be * * inserted at the top of the section. * * @param {Object} [dispatchOptions] Options, if any, to pass the dispatcher for the request * * @return {Promise} The response from the API @@ -1715,9 +1715,9 @@ declare module "asana" { * * in the system, but it will not be in the project anymore. * * * * Returns an empty data block. - * * @param {String} task The task to remove from a project. + * * @param {Number} task The task to remove from a project. * * @param {Object} data Data for the request - * * @param {String} data.project The project to remove the task from. + * * @param {Number} data.project The project to remove the task from. * * @param {Object} [dispatchOptions] Options, if any, to pass the dispatcher for the request * * @return {Promise} The response from the API * @param task @@ -1729,7 +1729,7 @@ declare module "asana" { /** * * Returns a compact representation of all of the tags the task has. - * * @param {String} task The task to get tags on. + * * @param {Number} task The task to get tags on. * * @param {Object} [params] Parameters for the request * * @param {Object} [dispatchOptions] Options, if any, to pass the dispatcher for the request * * @return {Promise} The response from the API @@ -1742,9 +1742,9 @@ declare module "asana" { /** * * Adds a tag to a task. Returns an empty data block. - * * @param {String} task The task to add a tag to. + * * @param {Number} task The task to add a tag to. * * @param {Object} data Data for the request - * * @param {String} data.tag The tag to add to the task. + * * @param {Number} data.tag The tag to add to the task. * * @param {Object} [dispatchOptions] Options, if any, to pass the dispatcher for the request * * @return {Promise} The response from the API * @param task @@ -1756,7 +1756,7 @@ declare module "asana" { /** * * Removes a tag from the task. Returns an empty data block. - * * @param {String} task The task to remove a tag from. + * * @param {Number} task The task to remove a tag from. * * @param {Object} data Data for the request * * @param {String} data.tag The tag to remove from the task. * * @param {Object} [dispatchOptions] Options, if any, to pass the dispatcher for the request @@ -1770,7 +1770,7 @@ declare module "asana" { /** * * Returns a compact representation of all of the subtasks of a task. - * * @param {String} task The task to get the subtasks of. + * * @param {Number} task The task to get the subtasks of. * * @param {Object} [params] Parameters for the request * * @param {Object} [dispatchOptions] Options, if any, to pass the dispatcher for the request * * @return {Promise} The response from the API @@ -1784,7 +1784,7 @@ declare module "asana" { /** * * Creates a new subtask and adds it to the parent task. Returns the full record * * for the newly created subtask. - * * @param {String} task The task to add a subtask to. + * * @param {Number} task The task to add a subtask to. * * @param {Object} data Data for the request * * @param {Object} [dispatchOptions] Options, if any, to pass the dispatcher for the request * * @return {Promise} The response from the API @@ -1797,7 +1797,7 @@ declare module "asana" { /** * * Returns a compact representation of all of the stories on the task. - * * @param {String} task The task containing the stories to get. + * * @param {Number} task The task containing the stories to get. * * @param {Object} [params] Parameters for the request * * @param {Object} [dispatchOptions] Options, if any, to pass the dispatcher for the request * * @return {Promise} The response from the API @@ -1814,7 +1814,7 @@ declare module "asana" { * * the request. * * * * Returns the full record for the new story added to the task. - * * @param {String} task Globally unique identifier for the task. + * * @param {Number} task Globally unique identifier for the task. * * @param {Object} data Data for the request * * @param {String} data.text The plain text of the comment to add. * * @param {Object} [dispatchOptions] Options, if any, to pass the dispatcher for the request @@ -1851,7 +1851,7 @@ declare module "asana" { interface Teams extends Resource { /** * * Returns the full record for a single team. - * * @param {String} team Globally unique identifier for the team. + * * @param {Number} team Globally unique identifier for the team. * * @param {Object} [params] Parameters for the request * * @param {Object} [dispatchOptions] Options, if any, to pass the dispatcher for the request * * @return {Promise} The requested resource @@ -1865,7 +1865,7 @@ declare module "asana" { /** * * Returns the compact records for all teams in the organization visible to * * the authorized user. - * * @param {String} organization Globally unique identifier for the workspace or organization. + * * @param {Number} organization Globally unique identifier for the workspace or organization. * * @param {Object} [params] Parameters for the request * * @param {Object} [dispatchOptions] Options, if any, to pass the dispatcher for the request * * @return {Promise} The response from the API @@ -1878,7 +1878,7 @@ declare module "asana" { /** * * Returns the compact records for all users that are members of the team. - * * @param {String} team Globally unique identifier for the team. + * * @param {Number} team Globally unique identifier for the team. * * @param {Object} [params] Parameters for the request * * @param {Object} [dispatchOptions] Options, if any, to pass the dispatcher for the request * * @return {Promise} The response from the API @@ -1894,9 +1894,9 @@ declare module "asana" { * * The user to add must exist in the same organization as the team in order to be added. * * The user to add can be referenced by their globally unique user ID or their email address. * * Returns the full user record for the added user. - * * @param {String} team Globally unique identifier for the team. + * * @param {Number} team Globally unique identifier for the team. * * @param {Object} data Data for the request - * * @param {String} data.user An identifier for the user. Can be one of an email address, + * * @param {Number|String} data.user An identifier for the user. Can be one of an email address, * * the globally unique identifier for the user, or the keyword `me` * * to indicate the current user making the request. * * @param {Object} [dispatchOptions] Options, if any, to pass the dispatcher for the request @@ -1906,14 +1906,14 @@ declare module "asana" { * @param dispatchOptions? * @return */ - addUser(team: string, data: UserParams, dispatchOptions?: any): Promise; + addUser(team: number, data: UserParams, dispatchOptions?: any): Promise; /** * * The user to remove can be referenced by their globally unique user ID or their email address. * * Removes the user from the specified team. Returns an empty data record. - * * @param {String} team Globally unique identifier for the team. + * * @param {Number} team Globally unique identifier for the team. * * @param {Object} data Data for the request - * * @param {String} data.user An identifier for the user. Can be one of an email address, + * * @param {Number|String} data.user An identifier for the user. Can be one of an email address, * * the globally unique identifier for the user, or the keyword `me` * * to indicate the current user making the request. * * @param {Object} [dispatchOptions] Options, if any, to pass the dispatcher for the request @@ -1923,7 +1923,7 @@ declare module "asana" { * @param dispatchOptions? * @return */ - removeUser(team: string, data: UserParams, dispatchOptions?: any): Promise; + removeUser(team: number, data: UserParams, dispatchOptions?: any): Promise; } interface UsersStatic { @@ -1971,7 +1971,7 @@ declare module "asana" { /** * * Returns the full user record for the single user with the provided ID. - * * @param {String} user An identifier for the user. Can be one of an email address, + * * @param {Number|String} user An identifier for the user. Can be one of an email address, * * the globally unique identifier for the user, or the keyword `me` * * to indicate the current user making the request. * * @param {Object} [params] Parameters for the request @@ -1987,7 +1987,7 @@ declare module "asana" { /** * * Returns the user records for all users in the specified workspace or * * organization. - * * @param {String} workspace The workspace in which to get users. + * * @param {Number} workspace The workspace in which to get users. * * @param {Object} [params] Parameters for the request * * @param {Object} [dispatchOptions] Options, if any, to pass the dispatcher for the request * * @return {Promise} The response from the API @@ -2003,7 +2003,7 @@ declare module "asana" { * * accessible to the authenticated user. Accepts an optional workspace ID * * parameter. * * @param {Object} [params] Parameters for the request - * * @param {String} [params.workspace] The workspace or organization to filter users on. + * * @param {Number} [params.workspace] The workspace or organization to filter users on. * * @param {Object} [dispatchOptions] Options, if any, to pass the dispatcher for the request * * @return {Promise} The response from the API * @param params @@ -2085,7 +2085,7 @@ declare module "asana" { * * fail to setup, and you will receive an error in response to your attempt * * to create it. This means you need to be able to receive and complete the * * webhook *while* the POST request is in-flight. - * * @param {String} resource A resource ID to subscribe to. The resource can be a task or project. + * * @param {Number} resource A resource ID to subscribe to. The resource can be a task or project. * * @param {String} target The URL to receive the HTTP POST. * * @param {Object} data Data for the request * * @param {Object} [dispatchOptions] Options, if any, to pass the dispatcher for the request @@ -2096,14 +2096,14 @@ declare module "asana" { * @param dispatchOptions? * @return */ - create(resource: string, target: string, data: any, dispatchOptions?: any): Promise; + create(resource: number, target: string, data: any, dispatchOptions?: any): Promise; /** * * Returns the compact representation of all webhooks your app has * * registered for the authenticated user in the given workspace. - * * @param {String} workspace The workspace to query for webhooks in. + * * @param {Number} workspace The workspace to query for webhooks in. * * @param {Object} [params] Parameters for the request - * * @param {String} [params.resource] Only return webhooks for the given resource. + * * @param {Number} [params.resource] Only return webhooks for the given resource. * * @param {Object} [dispatchOptions] Options, if any, to pass the dispatcher for the request * * @return {Promise} The response from the API * @param workspace @@ -2111,7 +2111,7 @@ declare module "asana" { * @param dispatchOptions? * @return */ - getAll(workspace: string, params?: any, dispatchOptions?: any): Promise; + getAll(workspace: number, params?: any, dispatchOptions?: any): Promise; /** * * Returns the full record for the given webhook. @@ -2187,7 +2187,7 @@ declare module "asana" { interface Workspaces extends Resource { /** * * Returns the full workspace record for a single workspace. - * * @param {String} workspace Globally unique identifier for the workspace or organization. + * * @param {Number} workspace Globally unique identifier for the workspace or organization. * * @param {Object} [params] Parameters for the request * * @param {Object} [dispatchOptions] Options, if any, to pass the dispatcher for the request * * @return {Promise} The requested resource @@ -2217,7 +2217,7 @@ declare module "asana" { * * Currently the only field that can be modified for a workspace is its `name`. * * * * Returns the complete, updated workspace record. - * * @param {String} workspace The workspace to update. + * * @param {Number} workspace The workspace to update. * * @param {Object} data Data for the request * * @param {Object} [dispatchOptions] Options, if any, to pass the dispatcher for the request * * @return {Promise} The response from the API @@ -2234,7 +2234,7 @@ declare module "asana" { * * not rely on this API to provide extremely accurate search results. The * * result set is limited to a single page of results with a maximum size, * * so you won't be able to fetch large numbers of results. - * * @param {String} workspace The workspace to fetch objects from. + * * @param {Number} workspace The workspace to fetch objects from. * * @param {Object} [params] Parameters for the request * * @param {String} params.type The type of values the typeahead should return. * * Note that unlike in the names of endpoints, the types listed here are @@ -2257,9 +2257,9 @@ declare module "asana" { /** * * The user can be referenced by their globally unique user ID or their email address. * * Returns the full user record for the invited user. - * * @param {String} workspace The workspace or organization to invite the user to. + * * @param {Number} workspace The workspace or organization to invite the user to. * * @param {Object} data Data for the request - * * @param {String} data.user An identifier for the user. Can be one of an email address, + * * @param {Number|String} data.user An identifier for the user. Can be one of an email address, * * the globally unique identifier for the user, or the keyword `me` * * to indicate the current user making the request. * * @param {Object} [dispatchOptions] Options, if any, to pass the dispatcher for the request @@ -2274,9 +2274,9 @@ declare module "asana" { /** * * The user making this call must be an admin in the workspace. * * Returns an empty data record. - * * @param {String} workspace The workspace or organization to invite the user to. + * * @param {Number} workspace The workspace or organization to invite the user to. * * @param {Object} data Data for the request - * * @param {String} data.user An identifier for the user. Can be one of an email address, + * * @param {Number|String} data.user An identifier for the user. Can be one of an email address, * * the globally unique identifier for the user, or the keyword `me` * * to indicate the current user making the request. * * @param {Object} [dispatchOptions] Options, if any, to pass the dispatcher for the request From c71391b68861270b62306adcd8321d8896e2df70 Mon Sep 17 00:00:00 2001 From: tkqubo Date: Sun, 7 Feb 2016 02:36:16 +0900 Subject: [PATCH 3/3] fix: class names --- asana/asana.d.ts | 115 +++++++++++++++++++++++------------------------ 1 file changed, 57 insertions(+), 58 deletions(-) diff --git a/asana/asana.d.ts b/asana/asana.d.ts index 513312ff7..ff840700e 100644 --- a/asana/asana.d.ts +++ b/asana/asana.d.ts @@ -787,13 +787,13 @@ declare module "asana" { } namespace Attachments { - interface Type extends IdAndName { + interface Type extends Resource { created_at: string; permanent_url: string; download_url: string; view_url: string; host: string; - parent: IdAndName; + parent: Resource; } } @@ -831,7 +831,7 @@ declare module "asana" { * @param dispatchOptions? * @return */ - findByTask(task: number, params?: PaginationParams, dispatchOptions?: any): Promise>; + findByTask(task: number, params?: PaginationParams, dispatchOptions?: any): Promise>; } interface EventsStatic { @@ -883,7 +883,7 @@ declare module "asana" { } namespace Projects { - interface Type extends IdAndName { + interface Type extends Resource { created_at: string; modified_at: string; due_date: string; @@ -892,10 +892,10 @@ declare module "asana" { archived: boolean; notes: string; color: string; - workspace: IdAndName; - team: IdAndName; - members: IdAndName[]; - followers: IdAndName[]; + workspace: Resource; + team: Resource; + members: Resource[]; + followers: Resource[]; } interface CreateParams { @@ -920,7 +920,7 @@ declare module "asana" { text: string; html_text: string; modified_at: string; - author: IdAndName; + author: Resource; } interface FindAllParams extends PaginationParams { @@ -1065,7 +1065,7 @@ declare module "asana" { * @param dispatchOptions? * @return */ - findAll(params?: Projects.FindAllParams, dispatchOptions?: any): Promise>; + findAll(params?: Projects.FindAllParams, dispatchOptions?: any): Promise>; /** * * Returns the compact project records for all projects in the workspace. @@ -1080,7 +1080,7 @@ declare module "asana" { * @param dispatchOptions? * @return */ - findByWorkspace(workspace: number, params?: Projects.FindByParams, dispatchOptions?: any): Promise>; + findByWorkspace(workspace: number, params?: Projects.FindByParams, dispatchOptions?: any): Promise>; /** * * Returns the compact project records for all projects in the team. @@ -1095,7 +1095,7 @@ declare module "asana" { * @param dispatchOptions? * @return */ - findByTeam(team: number, params?: Projects.FindByParams, dispatchOptions?: any): Promise>; + findByTeam(team: number, params?: Projects.FindByParams, dispatchOptions?: any): Promise>; /** * * Returns compact records for all sections in the specified project. @@ -1108,7 +1108,7 @@ declare module "asana" { * @param dispatchOptions? * @return */ - sections(project: number, params?: PaginationParams, dispatchOptions?: any): Promise>; + sections(project: number, params?: PaginationParams, dispatchOptions?: any): Promise>; /** * * Returns the compact task records for all tasks within the given project, @@ -1122,7 +1122,7 @@ declare module "asana" { * @param dispatchOptions? * @return */ - tasks(project: number, params?: PaginationParams, dispatchOptions?: any): Promise>; + tasks(project: number, params?: PaginationParams, dispatchOptions?: any): Promise>; /** * * Adds the specified list of users as followers to the project. Followers are a subset of members, therefore if @@ -1192,9 +1192,9 @@ declare module "asana" { } namespace Stories { - interface ShortType extends IdAndName { + interface ShortType extends Resource { created_at: string; - created_by: IdAndName; + created_by: Resource; type: string; text: string; } @@ -1202,7 +1202,7 @@ declare module "asana" { interface Type extends ShortType { html_text: string; source: string; - target: IdAndName; + target: Resource; hearts: Type[]; } } @@ -1232,7 +1232,7 @@ declare module "asana" { * @param dispatchOptions? * @return */ - findByTask(task: number, params?: PaginationParams, dispatchOptions?: any): Promise>; + findByTask(task: number, params?: PaginationParams, dispatchOptions?: any): Promise>; /** * * Returns the full record for a single story. @@ -1263,7 +1263,7 @@ declare module "asana" { * @param dispatchOptions? * @return */ - createOnTask(task: number, data: any, dispatchOptions?: any): Promise>; + createOnTask(task: number, data: any, dispatchOptions?: any): Promise>; } interface TagsStatic { @@ -1274,12 +1274,12 @@ declare module "asana" { } namespace Tags { - interface Type extends IdAndName { + interface Type extends Resource { created_at: string; notes: string; - workspace: IdAndName; + workspace: Resource; color: string; - followers: IdAndName[]; + followers: Resource[]; } interface FindAllParams extends PaginationParams { @@ -1402,7 +1402,7 @@ declare module "asana" { * @param dispatchOptions? * @return */ - findAll(params?: Tags.FindAllParams, dispatchOptions?: any): Promise>; + findAll(params?: Tags.FindAllParams, dispatchOptions?: any): Promise>; /** * * Returns the compact tag records for all tags in the workspace. @@ -1415,7 +1415,7 @@ declare module "asana" { * @param dispatchOptions? * @return */ - findByWorkspace(workspace: number, params?: PaginationParams, dispatchOptions?: any): Promise>; + findByWorkspace(workspace: number, params?: PaginationParams, dispatchOptions?: any): Promise>; /** * * Returns the compact task records for all tasks with the given tag. @@ -1429,7 +1429,7 @@ declare module "asana" { * @param dispatchOptions? * @return */ - getTasksWithTag(tag: number, params?: PaginationParams, dispatchOptions?: any): Promise>; + getTasksWithTag(tag: number, params?: PaginationParams, dispatchOptions?: any): Promise>; } interface TasksStatic { @@ -1440,7 +1440,7 @@ declare module "asana" { } namespace Tasks { - interface Type extends IdAndName { + interface Type extends Resource { created_at: string; modified_at: string; completed_at: string; @@ -1448,16 +1448,16 @@ declare module "asana" { due_on: string; due_at: string; assignee_status: string; - assignee: IdAndName; + assignee: Resource; notes: string; - workspace: IdAndName; + workspace: Resource; num_hearts: number; hearted: boolean; - parent: IdAndName; - tags: IdAndName[]; - projects: IdAndName[]; + parent: Resource; + tags: Resource[]; + projects: Resource[]; memberships: Membership[]; - followers: IdAndName[]; + followers: Resource[]; } interface CreateParams { @@ -1608,7 +1608,7 @@ declare module "asana" { * @param dispatchOptions? * @return */ - findByProject(projectId: number, params?: PaginationParams, dispatchOptions?: any): Promise>; + findByProject(projectId: number, params?: PaginationParams, dispatchOptions?: any): Promise>; /** * * Returns the compact task records for all tasks with the given tag. @@ -1621,7 +1621,7 @@ declare module "asana" { * @param dispatchOptions? * @return */ - findByTag(tag: number, params?: PaginationParams, dispatchOptions?: any): Promise>; + findByTag(tag: number, params?: PaginationParams, dispatchOptions?: any): Promise>; /** * * Returns the compact task records for some filtered set of tasks. Use one @@ -1638,7 +1638,7 @@ declare module "asana" { * @param dispatchOptions? * @return */ - findAll(params?: Tasks.FindAllParams, dispatchOptions?: any): Promise>; + findAll(params?: Tasks.FindAllParams, dispatchOptions?: any): Promise>; /** * * Adds each of the specified followers to the task, if they are not already @@ -1681,7 +1681,7 @@ declare module "asana" { * @param dispatchOptions? * @return */ - projects(task: number, params?: PaginationParams, dispatchOptions?: any): Promise>; + projects(task: number, params?: PaginationParams, dispatchOptions?: any): Promise>; /** * * Adds the task to the specified project, in the optional location @@ -1738,7 +1738,7 @@ declare module "asana" { * @param dispatchOptions? * @return */ - tags(task: number, params?: PaginationParams, dispatchOptions?: any): Promise>; + tags(task: number, params?: PaginationParams, dispatchOptions?: any): Promise>; /** * * Adds a tag to a task. Returns an empty data block. @@ -1779,7 +1779,7 @@ declare module "asana" { * @param dispatchOptions? * @return */ - subtasks(task: number, params?: PaginationParams, dispatchOptions?: any): Promise>; + subtasks(task: number, params?: PaginationParams, dispatchOptions?: any): Promise>; /** * * Creates a new subtask and adds it to the parent task. Returns the full record @@ -1806,7 +1806,7 @@ declare module "asana" { * @param dispatchOptions? * @return */ - stories(task: number, params?: PaginationParams, dispatchOptions?: any): Promise>; + stories(task: number, params?: PaginationParams, dispatchOptions?: any): Promise>; /** * * Adds a comment to a task. The comment will be authored by the @@ -1835,8 +1835,8 @@ declare module "asana" { } namespace Teams { - interface Type extends IdAndName { - organization: IdAndName; + interface Type extends Resource { + organization: Resource; } } @@ -1874,7 +1874,7 @@ declare module "asana" { * @param dispatchOptions? * @return */ - findByOrganization(organization: number, params?: Params, dispatchOptions?: any): Promise; + findByOrganization(organization: number, params?: Params, dispatchOptions?: any): Promise; /** * * Returns the compact records for all users that are members of the team. @@ -1887,7 +1887,7 @@ declare module "asana" { * @param dispatchOptions? * @return */ - users(team: number, params?: Params, dispatchOptions?: any): Promise; + users(team: number, params?: Params, dispatchOptions?: any): Promise; /** * * The user making this call must be a member of the team in order to add others. @@ -1938,9 +1938,9 @@ declare module "asana" { workspace: number; } - interface Type extends IdAndName { + interface Type extends Resource { email: string; - workspaces: IdAndName[]; + workspaces: Resource[]; photo: { [key: string]: string }; } } @@ -1996,7 +1996,7 @@ declare module "asana" { * @param dispatchOptions? * @return */ - findByWorkspace(workspace: number, params?: Params, dispatchOptions?: any): Promise>; + findByWorkspace(workspace: number, params?: Params, dispatchOptions?: any): Promise>; /** * * Returns the user records for all users in all workspaces and organizations @@ -2010,7 +2010,7 @@ declare module "asana" { * @param dispatchOptions? * @return */ - findAll(params: Users.FindAllParams, dispatchOptions?: any): Promise; + findAll(params: Users.FindAllParams, dispatchOptions?: any): Promise; } /** @@ -2148,11 +2148,11 @@ declare module "asana" { } namespace Workspaces { - interface ShortType extends IdAndName { + interface ShortType extends Resource { id_organization?: boolean; } - interface Type extends IdAndName { + interface Type extends Resource { id_organization: boolean; email_domains: string[]; } @@ -2207,7 +2207,7 @@ declare module "asana" { * @param dispatchOptions? * @return */ - findAll(params?: PaginationParams, dispatchOptions?: any): Promise>; + findAll(params?: PaginationParams, dispatchOptions?: any): Promise>; /** * * A specific, existing workspace can be updated by making a PUT request on @@ -2252,7 +2252,7 @@ declare module "asana" { * @param dispatchOptions? * @return */ - typeahead(workspace: number, params?: Workspaces.TypeaheadParams, dispatchOptions?: any): Promise; + typeahead(workspace: number, params?: Workspaces.TypeaheadParams, dispatchOptions?: any): Promise; /** * * The user can be referenced by their globally unique user ID or their email address. @@ -2308,7 +2308,7 @@ declare module "asana" { * @param {Object} [query] The query params * @param {Object} [dispatchOptions] Options for handling the request and * response. See `Dispatcher.dispatch`. - * @return {Promise} The Collection response for the request + * @return {Promise} The Collection response for the request * @param dispatcher * @param path * @param query? @@ -2410,7 +2410,7 @@ declare module "asana" { dispatchDelete(path: string, dispatchOptions?: any): Promise; } - interface CollectionBase { + interface ResourceList { data: T[]; _response: { data: T[]; @@ -2425,10 +2425,9 @@ declare module "asana" { requestTimeout: number; _cachedVersionInfo: VersionInfo; } - } - type Collection = CollectionBase; + type SimpleResourceList = ResourceList; interface NextPage { offset: string; @@ -2444,7 +2443,7 @@ declare module "asana" { os_version: string; } - interface IdAndName { + interface Resource { id: number; name: string; } @@ -2464,8 +2463,8 @@ declare module "asana" { } interface Membership { - project: IdAndName; - section: IdAndName; + project: Resource; + section: Resource; } }