pipe-kan 0.21.1 → 0.23.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.
package/dist/pipe-kan.js CHANGED
@@ -20,6 +20,19 @@ function formatDueDate(value) {
20
20
  year: "numeric"
21
21
  });
22
22
  }
23
+ function formatTargetEnd(value) {
24
+ if (typeof value !== "string" || !value)
25
+ return;
26
+ const day = /^(\d{4})-(\d{2})-(\d{2})/.exec(value);
27
+ const date = day ? new Date(Number(day[1]), Number(day[2]) - 1, Number(day[3])) : new Date(value);
28
+ if (Number.isNaN(date.getTime()))
29
+ return;
30
+ return date.toLocaleDateString("en-US", {
31
+ month: "short",
32
+ day: "numeric",
33
+ year: "numeric"
34
+ });
35
+ }
23
36
  function createdAt(fields) {
24
37
  return typeof fields?.created === "string" && fields.created ? fields.created : undefined;
25
38
  }
@@ -88,6 +101,31 @@ function issueAssignee(fields) {
88
101
  }
89
102
  return;
90
103
  }
104
+ function issueTargetEnd(fields) {
105
+ if (!fields)
106
+ return;
107
+ const candidates = [
108
+ fields.targetEnd,
109
+ fields.targetend,
110
+ fields.targetEndDate,
111
+ fields.targetenddate,
112
+ fields["Target End"],
113
+ fields["Target End Date"]
114
+ ];
115
+ const direct = candidates.find((value) => typeof value === "string" && value.trim());
116
+ if (direct)
117
+ return formatTargetEnd(direct);
118
+ for (const [key, value] of Object.entries(fields)) {
119
+ if (!key.startsWith("customfield_"))
120
+ continue;
121
+ if (typeof value === "string" && value.trim()) {
122
+ const formatted = formatTargetEnd(value.trim());
123
+ if (formatted)
124
+ return formatted;
125
+ }
126
+ }
127
+ return;
128
+ }
91
129
  function toEpic(face) {
92
130
  return {
93
131
  key: face.key,
@@ -96,6 +134,7 @@ function toEpic(face) {
96
134
  ...face.priority ? { priority: face.priority } : {},
97
135
  ...face.assignee ? { assignee: face.assignee } : {},
98
136
  ...face.dueDate ? { dueDate: face.dueDate } : {},
137
+ ...face.targetEnd ? { targetEnd: face.targetEnd } : {},
99
138
  ...face.labels ? { labels: face.labels } : {}
100
139
  };
101
140
  }
@@ -104,6 +143,7 @@ function toCard(issue, key) {
104
143
  const priority = typeof issue.fields?.priority?.name === "string" ? issue.fields.priority.name : undefined;
105
144
  const assignee = issueAssignee(issue.fields);
106
145
  const dueDate = formatDueDate(issue.fields?.duedate);
146
+ const targetEnd = issueTargetEnd(issue.fields);
107
147
  const type = issueType(issue.fields);
108
148
  const epic = epicKey(issue.fields);
109
149
  const labels = issueLabels(issue.fields);
@@ -114,6 +154,7 @@ function toCard(issue, key) {
114
154
  ...priority ? { priority } : {},
115
155
  ...assignee ? { assignee } : {},
116
156
  ...dueDate ? { dueDate } : {},
157
+ ...targetEnd ? { targetEnd } : {},
117
158
  ...type ? { type } : {},
118
159
  ...epic ? { epic } : {},
119
160
  ...labels ? { labels } : {},
@@ -174,6 +215,8 @@ function mergeEpics(listed, fromBoard) {
174
215
  }
175
216
  if (!existing.summary && epic.summary)
176
217
  Object.assign(existing, epic);
218
+ if (!existing.targetEnd && epic.targetEnd)
219
+ existing.targetEnd = epic.targetEnd;
177
220
  }
178
221
  return [...byKey.values()];
179
222
  }
@@ -478,6 +521,10 @@ var LEADING = [
478
521
  "priority",
479
522
  "assignee",
480
523
  "duedate",
524
+ "targetend",
525
+ "targetEnd",
526
+ "targetenddate",
527
+ "targetEndDate",
481
528
  "labels",
482
529
  "description"
483
530
  ];
@@ -1015,7 +1062,7 @@ function withPipedBoardContext(board, clientContext = []) {
1015
1062
  return [...pipedBoardContext(board), ...clientContext];
1016
1063
  }
1017
1064
  function formatBoardView(view) {
1018
- const opener = view.kind === "epics" ? "All epics" : "All stories";
1065
+ const opener = view.kind === "epics" ? "All epics" : view.kind === "combined" ? "All combined" : "All stories";
1019
1066
  const scope = view.selectedEpic ? `${opener}, children of ${view.selectedEpic}` : opener;
1020
1067
  const lines = [
1021
1068
  view.scope === "pipe" ? "The user is working with piped Jira issues (the full payload). Answer from these Jira issues. This is not GitHub and not the local source repo." : "The user attached the current Jira Kanban board (visible cards only). Answer from these Jira issues. This is not GitHub and not the local source repo.",
@@ -1058,7 +1105,7 @@ function formatCard(card) {
1058
1105
  const bits = [card.key, card.summary];
1059
1106
  if (card.epic)
1060
1107
  bits.push(`[epic ${card.epic}]`);
1061
- const extras = [card.priority, card.assignee, card.dueDate, card.labels?.join(", ")].filter((value) => Boolean(value));
1108
+ const extras = [card.priority, card.assignee, card.dueDate, card.targetEnd, card.labels?.join(", ")].filter((value) => Boolean(value));
1062
1109
  if (extras.length)
1063
1110
  bits.push(`(${extras.join(", ")})`);
1064
1111
  return bits.join(" ");