Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
8 changes: 4 additions & 4 deletions src/commands/initiatives/entity.ts
Original file line number Diff line number Diff line change
Expand Up @@ -9,10 +9,8 @@ import {
parseLimit,
} from "../../common/output.js";
import {
type InitiativeCreateInput,
type InitiativeSortInput,
InitiativeStatus,
type InitiativeUpdateInput,
type ListInitiativesQueryVariables,
PaginationNulls,
PaginationOrderBy,
Expand Down Expand Up @@ -40,10 +38,12 @@ import {
} from "../../services/discussion-service.js";
import {
archiveInitiative,
type CreateInitiativeInput,
createInitiative,
deleteInitiative,
getInitiative,
listInitiatives,
type UpdateInitiativeInput,
unarchiveInitiative,
updateInitiative,
} from "../../services/initiative-service.js";
Expand Down Expand Up @@ -853,7 +853,7 @@ export function setupInitiativeEntityCommands(initiatives: Command): void {
];
const ctx = createContext(getRootOpts(command));

const input: InitiativeCreateInput = { name };
const input: CreateInitiativeInput = { name };

if (options.description !== undefined) {
input.description = options.description;
Expand Down Expand Up @@ -906,7 +906,7 @@ export function setupInitiativeEntityCommands(initiatives: Command): void {
const ctx = createContext(getRootOpts(command));
const initiativeId = await resolveInitiativeId(ctx.sdk, initiative);

const input: InitiativeUpdateInput = {};
const input: UpdateInitiativeInput = {};

if (options.name !== undefined) {
input.name = options.name;
Expand Down
12 changes: 5 additions & 7 deletions src/commands/issues.ts
Original file line number Diff line number Diff line change
Expand Up @@ -17,11 +17,7 @@ import {
import { handleCommand, outputSuccess, parseLimit } from "../common/output.js";
import { resolveFilterOptions } from "../common/resolve-filters.js";
import { type DomainMeta, formatDomainUsage } from "../common/usage.js";
import {
type IssueCreateInput,
IssueRelationType,
type IssueUpdateInput,
} from "../gql/graphql.js";
import { IssueRelationType } from "../gql/graphql.js";
import { resolveCycleId } from "../resolvers/cycle-resolver.js";
import {
resolveIssueEstimateContext,
Expand Down Expand Up @@ -61,6 +57,7 @@ import {
} from "../services/issue-relation-service.js";
import {
archiveIssue,
type CreateIssueInput,
createIssue,
deleteIssue,
getIssue,
Expand All @@ -75,6 +72,7 @@ import {
getIssueWithReactions,
listIssues,
searchIssues,
type UpdateIssueInput,
unarchiveIssue,
updateIssue,
} from "../services/issue-service.js";
Expand Down Expand Up @@ -1032,7 +1030,7 @@ export function setupIssuesCommands(program: Command): void {
});
}

const input: IssueCreateInput = {
const input: CreateIssueInput = {
title,
teamId,
};
Expand Down Expand Up @@ -1237,7 +1235,7 @@ export function setupIssuesCommands(program: Command): void {
? await getIssue(ctx.gql, resolvedIssueId)
: undefined;

const input: IssueUpdateInput = {};
const input: UpdateIssueInput = {};

if (options.title) {
input.title = options.title;
Expand Down
7 changes: 4 additions & 3 deletions src/commands/projects.ts
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,6 @@ import { resolveReactionEmojiInput } from "../common/emoji.js";
import { invalidParameterError } from "../common/errors.js";
import { handleCommand, outputSuccess, parseLimit } from "../common/output.js";
import { type DomainMeta, formatDomainUsage } from "../common/usage.js";
import type { ProjectCreateInput, ProjectUpdateInput } from "../gql/graphql.js";
import {
resolveProjectId,
resolveProjectLabelIds,
Expand All @@ -31,10 +30,12 @@ import {
} from "../services/discussion-service.js";
import {
archiveProject,
type CreateProjectInput,
createProject,
deleteProject,
getProject,
listProjects,
type UpdateProjectInput,
unarchiveProject,
updateProject,
} from "../services/project-service.js";
Expand Down Expand Up @@ -526,7 +527,7 @@ export function setupProjectsCommands(program: Command): void {
teamNames.map((t) => resolveTeamId(ctx.sdk, t)),
);

const input: ProjectCreateInput = {
const input: CreateProjectInput = {
name,
teamIds,
};
Expand Down Expand Up @@ -610,7 +611,7 @@ export function setupProjectsCommands(program: Command): void {

const projectId = await resolveProjectId(ctx.sdk, project);

const input: ProjectUpdateInput = {};
const input: UpdateProjectInput = {};

if (options.name) {
input.name = options.name;
Expand Down
30 changes: 26 additions & 4 deletions src/services/initiative-service.ts
Original file line number Diff line number Diff line change
Expand Up @@ -30,6 +30,26 @@ import {
type UpdateInitiativeMutation,
} from "../gql/graphql.js";

export interface CreateInitiativeInput {
name: string;
description?: string;
content?: string;
ownerId?: string;
status?: InitiativeCreateInput["status"];
targetDate?: string;
sortOrder?: number;
}

export interface UpdateInitiativeInput {
name?: string;
description?: string;
content?: string;
ownerId?: string;
status?: InitiativeUpdateInput["status"];
targetDate?: string;
sortOrder?: number;
}

export interface InitiativeListOptions {
limit?: number;
after?: string;
Expand Down Expand Up @@ -90,12 +110,13 @@ export async function getInitiative(

export async function createInitiative(
client: GraphQLClient,
input: InitiativeCreateInput,
input: CreateInitiativeInput,
): Promise<CreatedInitiative> {
const graphqlInput: InitiativeCreateInput = { ...input };
const result = await client.request<CreateInitiativeMutation>(
CreateInitiativeDocument,
{
input,
input: graphqlInput,
},
);

Expand All @@ -109,7 +130,7 @@ export async function createInitiative(
export async function updateInitiative(
client: GraphQLClient,
id: string,
input: InitiativeUpdateInput,
input: UpdateInitiativeInput,
): Promise<UpdatedInitiative> {
const hasAtLeastOneField = Object.values(input).some(
(value) => value !== undefined,
Expand All @@ -122,11 +143,12 @@ export async function updateInitiative(
);
}

const graphqlInput: InitiativeUpdateInput = { ...input };
const result = await client.request<UpdateInitiativeMutation>(
UpdateInitiativeDocument,
{
id,
input,
input: graphqlInput,
},
);

Expand Down
41 changes: 37 additions & 4 deletions src/services/issue-service.ts
Original file line number Diff line number Diff line change
Expand Up @@ -58,6 +58,37 @@ import {
} from "../gql/graphql.js";
import { normalizeReactions } from "./reaction-service.js";

export interface CreateIssueInput {
title: string;
teamId: string;
description?: string;
assigneeId?: string;
priority?: number;
estimate?: number;
projectId?: string;
labelIds?: string[];
projectMilestoneId?: string;
cycleId?: string;
stateId?: string;
parentId?: string;
dueDate?: string;
}

export interface UpdateIssueInput {
title?: string;
description?: string;
stateId?: string;
priority?: number;
estimate?: number | null;
assigneeId?: string;
projectId?: string;
labelIds?: string[];
parentId?: string | null;
projectMilestoneId?: string | null;
cycleId?: string | null;
dueDate?: string | null;
}

const NON_COMPLETED_ISSUES_FILTER: IssueFilter = {
state: { type: { neq: "completed" } },
};
Expand Down Expand Up @@ -396,11 +427,12 @@ export async function searchIssues(

export async function createIssue(
client: GraphQLClient,
input: IssueCreateInput,
input: CreateIssueInput,
): Promise<CreatedIssue> {
const graphqlInput: IssueCreateInput = { ...input };
const result = await client.request<CreateIssueMutation>(
CreateIssueDocument,
{ input },
{ input: graphqlInput },
);
if (!result.issueCreate.success || !result.issueCreate.issue) {
throw new Error("Failed to create issue");
Expand All @@ -411,11 +443,12 @@ export async function createIssue(
export async function updateIssue(
client: GraphQLClient,
id: string,
input: IssueUpdateInput,
input: UpdateIssueInput,
): Promise<UpdatedIssue> {
const graphqlInput: IssueUpdateInput = { ...input };
const result = await client.request<UpdateIssueMutation>(
UpdateIssueDocument,
{ id, input },
{ id, input: graphqlInput },
);
if (!result.issueUpdate.success || !result.issueUpdate.issue) {
throw new Error("Failed to update issue");
Expand Down
38 changes: 34 additions & 4 deletions src/services/project-service.ts
Original file line number Diff line number Diff line change
Expand Up @@ -29,6 +29,34 @@ import {
type UpdateProjectMutation,
} from "../gql/graphql.js";

export interface CreateProjectInput {
name: string;
teamIds: string[];
description?: string;
content?: string;
leadId?: string;
memberIds?: string[];
priority?: number;
statusId?: string;
startDate?: string;
targetDate?: string;
labelIds?: string[];
}

export interface UpdateProjectInput {
name?: string;
description?: string;
content?: string;
leadId?: string;
memberIds?: string[];
priority?: number;
statusId?: string;
startDate?: string;
targetDate?: string;
teamIds?: string[];
labelIds?: string[];
}

export async function listProjects(
client: GraphQLClient,
options: PaginationOptions = {},
Expand Down Expand Up @@ -62,11 +90,12 @@ export async function getProject(

export async function createProject(
client: GraphQLClient,
input: ProjectCreateInput,
input: CreateProjectInput,
): Promise<CreatedProject> {
const graphqlInput: ProjectCreateInput = { ...input };
const result = await client.request<CreateProjectMutation>(
CreateProjectDocument,
{ input },
{ input: graphqlInput },
);

if (!result.projectCreate.success || !result.projectCreate.project) {
Expand All @@ -79,11 +108,12 @@ export async function createProject(
export async function updateProject(
client: GraphQLClient,
id: string,
input: ProjectUpdateInput,
input: UpdateProjectInput,
): Promise<UpdatedProject> {
const graphqlInput: ProjectUpdateInput = { ...input };
const result = await client.request<UpdateProjectMutation>(
UpdateProjectDocument,
{ id, input },
{ id, input: graphqlInput },
);

if (!result.projectUpdate.success || !result.projectUpdate.project) {
Expand Down