linear-sdk-cli 0.5.3 → 0.7.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
@@ -23,6 +23,7 @@ import {
23
23
  resolveProjectLabelIds,
24
24
  isUuid,
25
25
  } from "../lib/resolve.js";
26
+ import { resolveProjectStatusId } from "./project-status.js";
26
27
 
27
28
  export interface ProjectRow {
28
29
  id: string;
@@ -291,7 +292,8 @@ export async function createProject(
291
292
  const input: Record<string, any> = { name: opts.name, teamIds };
292
293
  if (opts.description !== undefined) input.description = opts.description;
293
294
  if (opts.content !== undefined) input.content = opts.content;
294
- if (opts.state) input.statusId = await resolveStatusId(client, opts.state);
295
+ if (opts.state)
296
+ input.statusId = await resolveProjectStatusId(client, opts.state, { allowType: true });
295
297
  if (opts.lead) input.leadId = await resolveUserId(client, opts.lead);
296
298
  if (opts.startDate) input.startDate = opts.startDate;
297
299
  if (opts.targetDate) input.targetDate = opts.targetDate;
@@ -335,7 +337,8 @@ export async function updateProject(client: LinearClient, idArg: string, opts: U
335
337
  if (opts.content !== undefined) input.content = opts.content;
336
338
  if (opts.team?.length) input.teamIds = await resolveTeamIds(client, opts.team, undefined);
337
339
  if (opts.lead) input.leadId = await resolveUserId(client, opts.lead);
338
- if (opts.state) input.statusId = await resolveStatusId(client, opts.state);
340
+ if (opts.state)
341
+ input.statusId = await resolveProjectStatusId(client, opts.state, { allowType: true });
339
342
  if (opts.startDate) input.startDate = opts.startDate;
340
343
  if (opts.targetDate) input.targetDate = opts.targetDate;
341
344
  if (opts.priority !== undefined) input.priority = resolvePriority(opts.priority);
@@ -480,26 +483,3 @@ async function resolveTeamIds(
480
483
  }
481
484
  return ids;
482
485
  }
483
-
484
- /** Resolve a project status (by name or type) to a status id. */
485
- async function resolveStatusId(client: LinearClient, input: string): Promise<string> {
486
- if (isUuid(input)) return input;
487
- const conn = await withRetry(() => client.projectStatuses({ first: 250 }));
488
- const statuses = (await collect(conn as any, Infinity)) as Array<{
489
- id: string;
490
- name: string;
491
- type: string;
492
- }>;
493
- const lower = input.toLowerCase();
494
- const byName = statuses.filter((s) => s.name.toLowerCase() === lower);
495
- const matches = byName.length ? byName : statuses.filter((s) => s.type.toLowerCase() === lower);
496
- if (matches.length === 0)
497
- throw notFound(
498
- `No project status '${input}'. Available: ${statuses.map((s) => s.name).join(", ")}`,
499
- );
500
- if (matches.length > 1)
501
- throw ambiguous(
502
- `Multiple project statuses match '${input}': ${matches.map((s) => s.name).join(", ")}`,
503
- );
504
- return matches[0]!.id;
505
- }