pipe-kan 0.20.5 → 0.21.1

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.
package/dist/pipe-kan.js CHANGED
@@ -632,6 +632,18 @@ function createApp(opts) {
632
632
  hasChildrenCache = true;
633
633
  childrenError = undefined;
634
634
  }
635
+ function currentStatus(key) {
636
+ const fromPayload = payload.find((issue) => issue.key === key)?.fields?.status?.name;
637
+ return fromPayload ?? issuesToBoard(epicsPayload).epics.find((epic) => epic.key === key)?.status ?? app.board().epics.find((epic) => epic.key === key)?.status;
638
+ }
639
+ async function tryMove(key, status) {
640
+ const current = currentStatus(key);
641
+ if (current === status) {
642
+ return { ok: true, noop: true, error: undefined };
643
+ }
644
+ const result = await cli.move(key, status);
645
+ return result.ok ? { ok: true, noop: false, error: undefined } : { ok: false, noop: false, error: result.error };
646
+ }
635
647
  const app = {
636
648
  get flags() {
637
649
  return flags;
@@ -715,18 +727,20 @@ function createApp(opts) {
715
727
  return stampMissingEpic(issuesToBoard(JSON.parse(await cli.listEpic(epic))), epic);
716
728
  },
717
729
  async move(key, status) {
718
- const fromPayload = payload.find((issue) => issue.key === key)?.fields?.status?.name;
719
- const current = fromPayload ?? issuesToBoard(epicsPayload).epics.find((epic) => epic.key === key)?.status ?? app.board().epics.find((epic) => epic.key === key)?.status;
720
- if (current === status) {
721
- return { ok: true, noop: true, board: app.board() };
722
- }
723
- const result = await cli.move(key, status);
730
+ const result = await tryMove(key, status);
724
731
  if (!result.ok) {
725
732
  return { ok: false, error: result.error, board: app.board() };
726
733
  }
734
+ if (result.noop) {
735
+ return { ok: true, noop: true, board: app.board() };
736
+ }
727
737
  await app.refresh();
728
738
  return { ok: true, board: app.board() };
729
739
  },
740
+ async moveRaw(key, status) {
741
+ const result = await tryMove(key, status);
742
+ return result.ok ? { ok: true, noop: result.noop } : { ok: false, error: result.error };
743
+ },
730
744
  async open(key) {
731
745
  const urlP = cli.open(key);
732
746
  try {
@@ -936,7 +950,14 @@ function handleAppApi(req, res, app) {
936
950
  if (url.pathname === "/api/move" && method === "POST") {
937
951
  reply(req, res, async (text) => {
938
952
  const body = text ? JSON.parse(text) : {};
939
- const result = await app.move(String(body.key ?? ""), String(body.status ?? ""));
953
+ const key = String(body.key ?? "");
954
+ const status = String(body.status ?? "");
955
+ if (body.raw === true) {
956
+ const result = await app.moveRaw(key, status);
957
+ json(res, result.ok ? 200 : 409, result);
958
+ return;
959
+ }
960
+ const result = await app.move(key, status);
940
961
  json(res, result.ok ? 200 : 409, result);
941
962
  });
942
963
  return true;