type Asana = {
token: string;
};
/**
* Create a project
* Create a new project in a workspace or team.
Every project is required to be created in a specific workspace or
organization, and this cannot be changed once set. Note that you can use
the `workspace` parameter regardless of whether or not it is an
organization.
If the workspace for your project is an organization, you must also
supply a `team` to share the project with.
Returns the full record of the newly created project.
*/
export async function main(
auth: Asana,
opt_pretty: string | undefined,
opt_fields: string | undefined,
body: {
data?: (({ gid?: string; resource_type?: string; [k: string]: unknown } & {
name?: string;
[k: string]: unknown;
}) & {
archived?: boolean;
color?:
| "dark-pink"
| "dark-green"
| "dark-blue"
| "dark-red"
| "dark-teal"
| "dark-brown"
| "dark-orange"
| "dark-purple"
| "dark-warm-gray"
| "light-pink"
| "light-green"
| "light-blue"
| "light-red"
| "light-teal"
| "light-brown"
| "light-orange"
| "light-purple"
| "light-warm-gray";
created_at?: string;
current_status?: (({
gid?: string;
resource_type?: string;
[k: string]: unknown;
} & { title?: string; [k: string]: unknown }) & {
color: "green" | "yellow" | "red" | "blue";
html_text?: string;
text: string;
[k: string]: unknown;
}) & {
author?: {
gid?: string;
resource_type?: string;
[k: string]: unknown;
} & { name?: string; [k: string]: unknown };
created_at?: string;
created_by?: {
gid?: string;
resource_type?: string;
[k: string]: unknown;
} & { name?: string; [k: string]: unknown };
modified_at?: string;
[k: string]: unknown;
};
current_status_update?: {
gid?: string;
resource_type?: string;
[k: string]: unknown;
} & {
resource_subtype?:
| "project_status_update"
| "portfolio_status_update"
| "goal_status_update";
title?: string;
[k: string]: unknown;
};
custom_field_settings?: (({
gid?: string;
resource_type?: string;
[k: string]: unknown;
} & { [k: string]: unknown }) & {
custom_field?: ((({
gid?: string;
resource_type?: string;
[k: string]: unknown;
} & {
date_value?: {
date?: string;
date_time?: string;
[k: string]: unknown;
};
display_value?: string;
enabled?: boolean;
enum_options?: ({
gid?: string;
resource_type?: string;
[k: string]: unknown;
} & {
color?: string;
enabled?: boolean;
name?: string;
[k: string]: unknown;
})[];
enum_value?: ({
gid?: string;
resource_type?: string;
[k: string]: unknown;
} & {
color?: string;
enabled?: boolean;
name?: string;
[k: string]: unknown;
}) & { [k: string]: unknown };
multi_enum_values?: ({
gid?: string;
resource_type?: string;
[k: string]: unknown;
} & {
color?: string;
enabled?: boolean;
name?: string;
[k: string]: unknown;
})[];
name?: string;
number_value?: number;
resource_subtype?:
| "text"
| "enum"
| "multi_enum"
| "number"
| "date"
| "people";
text_value?: string;
type?: "text" | "enum" | "multi_enum" | "number";
[k: string]: unknown;
}) & {
asana_created_field?:
| "a_v_requirements"
| "account_name"
| "actionable"
| "align_shipping_link"
| "align_status"
| "allotted_time"
| "appointment"
| "approval_stage"
| "approved"
| "article_series"
| "board_committee"
| "browser"
| "campaign_audience"
| "campaign_project_status"
| "campaign_regions"
| "channel_primary"
| "client_topic_type"
| "complete_by"
| "contact"
| "contact_email_address"
| "content_channels"
| "content_channels_needed"
| "content_stage"
| "content_type"
| "contract"
| "contract_status"
| "cost"
| "creation_stage"
| "creative_channel"
| "creative_needed"
| "creative_needs"
| "data_sensitivity"
| "deal_size"
| "delivery_appt"
| "delivery_appt_date"
| "department"
| "department_responsible"
| "design_request_needed"
| "design_request_type"
| "discussion_category"
| "do_this_task"
| "editorial_content_status"
| "editorial_content_tag"
| "editorial_content_type"
| "effort"
| "effort_level"
| "est_completion_date"
| "estimated_time"
| "estimated_value"
| "expected_cost"
| "external_steps_needed"
| "favorite_idea"
| "feedback_type"
| "financial"
| "funding_amount"
| "grant_application_process"
| "hiring_candidate_status"
| "idea_status"
| "ids_link"
| "ids_patient_link"
| "implementation_stage"
| "insurance"
| "interview_area"
| "interview_question_score"
| "itero_scan_link"
| "job_s_applied_to"
| "lab"
| "launch_status"
| "lead_status"
| "localization_language"
| "localization_market_team"
| "localization_status"
| "meeting_minutes"
| "meeting_needed"
| "minutes"
| "mrr"
| "must_localize"
| "name_of_foundation"
| "need_to_follow_up"
| "next_appointment"
| "next_steps_sales"
| "num_people"
| "number_of_user_reports"
| "office_location"
| "onboarding_activity"
| "owner"
| "participants_needed"
| "patient_date_of_birth"
| "patient_email"
| "patient_phone"
| "patient_status"
| "phone_number"
| "planning_category"
| "point_of_contact"
| "position"
| "post_format"
| "prescription"
| "priority"
| "priority_level"
| "product"
| "product_stage"
| "progress"
| "project_size"
| "project_status"
| "proposed_budget"
| "publish_status"
| "reason_for_scan"
| "referral"
| "request_type"
| "research_status"
| "responsible_department"
| "responsible_team"
| "risk_assessment_status"
| "room_name"
| "sales_counterpart"
| "sentiment"
| "shipping_link"
| "social_channels"
| "stage"
| "status"
| "status_design"
| "status_of_initiative"
| "system_setup"
| "task_progress"
| "team"
| "team_marketing"
| "team_responsible"
| "time_it_takes_to_complete_tasks"
| "timeframe"
| "treatment_type"
| "type_work_requests_it"
| "use_agency"
| "user_name"
| "vendor_category"
| "vendor_type"
| "word_count";
currency_code?: string;
custom_label?: string;
custom_label_position?: "prefix" | "suffix";
description?: string;
enum_options?: ({
gid?: string;
resource_type?: string;
[k: string]: unknown;
} & {
color?: string;
enabled?: boolean;
name?: string;
[k: string]: unknown;
})[];
format?: "currency" | "identifier" | "percentage" | "custom" | "none";
has_notifications_enabled?: boolean;
is_global_to_workspace?: boolean;
precision?: number;
[k: string]: unknown;
}) & {
created_by?: {
gid?: string;
resource_type?: string;
[k: string]: unknown;
} & { name?: string; [k: string]: unknown };
people_value?: ({
gid?: string;
resource_type?: string;
[k: string]: unknown;
} & { name?: string; [k: string]: unknown })[];
[k: string]: unknown;
}) & { [k: string]: unknown };
is_important?: boolean;
parent?: ({
gid?: string;
resource_type?: string;
[k: string]: unknown;
} & { name?: string; [k: string]: unknown }) & { [k: string]: unknown };
project?: ({
gid?: string;
resource_type?: string;
[k: string]: unknown;
} & { name?: string; [k: string]: unknown }) & { [k: string]: unknown };
[k: string]: unknown;
})[];
default_view?: "list" | "board" | "calendar" | "timeline";
due_date?: string;
due_on?: string;
html_notes?: string;
is_template?: boolean;
members?: ({
gid?: string;
resource_type?: string;
[k: string]: unknown;
} & { name?: string; [k: string]: unknown })[];
modified_at?: string;
notes?: string;
public?: boolean;
start_on?: string;
workspace?: ({
gid?: string;
resource_type?: string;
[k: string]: unknown;
} & { name?: string; [k: string]: unknown }) & { [k: string]: unknown };
[k: string]: unknown;
}) & {
custom_fields?: { [k: string]: string };
followers?: string;
owner?: string;
team?: string;
[k: string]: unknown;
};
[k: string]: unknown;
}
) {
const url = new URL(`https://app.asana.com/api/1.0/projects`);
for (const [k, v] of [
["opt_pretty", opt_pretty],
["opt_fields", opt_fields],
]) {
if (v !== undefined && v !== "") {
url.searchParams.append(k, v);
}
}
const response = await fetch(url, {
method: "POST",
headers: {
"Content-Type": "application/json",
Authorization: "Bearer " + auth.token,
},
body: JSON.stringify(body),
});
if (!response.ok) {
const text = await response.text();
throw new Error(`${response.status} ${text}`);
}
return await response.json();
}
Submitted by hugo697 400 days ago