@kaddo/cli 3.88.2 → 3.88.3
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/core.js +45 -14
- package/dist/index.js +45 -14
- package/package.json +1 -1
package/dist/core.js
CHANGED
|
@@ -10126,7 +10126,7 @@ function buildJql(filters) {
|
|
|
10126
10126
|
if (filters?.updatedAfter) clauses.push(`updated >= ${escapeJql(filters.updatedAfter)}`);
|
|
10127
10127
|
if (filters?.search) clauses.push(`(summary ~ ${escapeJql(filters.search)} OR description ~ ${escapeJql(filters.search)})`);
|
|
10128
10128
|
if (filters?.providerQuery) clauses.push(`(${filters.providerQuery})`);
|
|
10129
|
-
return clauses.join(" AND ")
|
|
10129
|
+
return clauses.join(" AND ");
|
|
10130
10130
|
}
|
|
10131
10131
|
function normalizeBaseUrl(raw) {
|
|
10132
10132
|
let url = raw.trim();
|
|
@@ -10137,6 +10137,24 @@ function authHeader(email, token) {
|
|
|
10137
10137
|
const encoded = typeof Buffer !== "undefined" ? Buffer.from(`${email}:${token}`).toString("base64") : btoa(`${email}:${token}`);
|
|
10138
10138
|
return `Basic ${encoded}`;
|
|
10139
10139
|
}
|
|
10140
|
+
async function handleJiraResponse(res) {
|
|
10141
|
+
if (res.status === 401) throw integrationError("INTEGRATION_UNAUTHORIZED");
|
|
10142
|
+
if (res.status === 403) throw integrationError("INTEGRATION_FORBIDDEN");
|
|
10143
|
+
if (res.status === 404) throw integrationError("INTEGRATION_NOT_FOUND");
|
|
10144
|
+
if (res.status === 410) throw integrationError("INTEGRATION_UNAVAILABLE", "Jira API endpoint deprecated (410 Gone).");
|
|
10145
|
+
if (res.status === 429) throw integrationError("INTEGRATION_RATE_LIMITED");
|
|
10146
|
+
if (res.status >= 500) throw integrationError("INTEGRATION_UNAVAILABLE");
|
|
10147
|
+
if (!res.ok) {
|
|
10148
|
+
let detail = "";
|
|
10149
|
+
try {
|
|
10150
|
+
const body = await res.json();
|
|
10151
|
+
detail = body.errorMessages?.[0] ?? "";
|
|
10152
|
+
} catch {
|
|
10153
|
+
}
|
|
10154
|
+
throw integrationError("INTEGRATION_PROVIDER_ERROR", detail || `Jira responded with status ${res.status}.`);
|
|
10155
|
+
}
|
|
10156
|
+
return await res.json();
|
|
10157
|
+
}
|
|
10140
10158
|
async function jiraFetch(baseUrl, path4, auth, timeoutMs, params) {
|
|
10141
10159
|
const url = new URL(path4, baseUrl + "/");
|
|
10142
10160
|
if (params) for (const [k, v] of Object.entries(params)) url.searchParams.set(k, v);
|
|
@@ -10148,14 +10166,26 @@ async function jiraFetch(baseUrl, path4, auth, timeoutMs, params) {
|
|
|
10148
10166
|
headers: { Authorization: auth, Accept: "application/json" },
|
|
10149
10167
|
signal: controller.signal
|
|
10150
10168
|
});
|
|
10151
|
-
|
|
10152
|
-
|
|
10153
|
-
if (
|
|
10154
|
-
|
|
10155
|
-
|
|
10156
|
-
|
|
10157
|
-
|
|
10158
|
-
|
|
10169
|
+
return await handleJiraResponse(res);
|
|
10170
|
+
} catch (err) {
|
|
10171
|
+
if (err instanceof Error && err.name === "AbortError") throw integrationError("INTEGRATION_TIMEOUT");
|
|
10172
|
+
throw normalizeProviderError(err);
|
|
10173
|
+
} finally {
|
|
10174
|
+
clearTimeout(timer);
|
|
10175
|
+
}
|
|
10176
|
+
}
|
|
10177
|
+
async function jiraPost(baseUrl, path4, auth, timeoutMs, body) {
|
|
10178
|
+
const url = new URL(path4, baseUrl + "/");
|
|
10179
|
+
const controller = new AbortController();
|
|
10180
|
+
const timer = setTimeout(() => controller.abort(), timeoutMs);
|
|
10181
|
+
try {
|
|
10182
|
+
const res = await fetch(url.toString(), {
|
|
10183
|
+
method: "POST",
|
|
10184
|
+
headers: { Authorization: auth, Accept: "application/json", "Content-Type": "application/json" },
|
|
10185
|
+
body: JSON.stringify(body),
|
|
10186
|
+
signal: controller.signal
|
|
10187
|
+
});
|
|
10188
|
+
return await handleJiraResponse(res);
|
|
10159
10189
|
} catch (err) {
|
|
10160
10190
|
if (err instanceof Error && err.name === "AbortError") throw integrationError("INTEGRATION_TIMEOUT");
|
|
10161
10191
|
throw normalizeProviderError(err);
|
|
@@ -10276,11 +10306,12 @@ function createJiraAdapter() {
|
|
|
10276
10306
|
const pageSize = Math.min(Math.max(1, request.pageSize ?? DEFAULT_PAGE_SIZE), 100);
|
|
10277
10307
|
const startAt = request.cursor ? Math.max(0, Number.parseInt(request.cursor, 10) || 0) : 0;
|
|
10278
10308
|
try {
|
|
10279
|
-
const
|
|
10280
|
-
|
|
10281
|
-
|
|
10282
|
-
|
|
10283
|
-
|
|
10309
|
+
const fullJql = jql ? jql + " ORDER BY updated DESC" : "ORDER BY updated DESC";
|
|
10310
|
+
const data = await jiraPost(baseUrl, "/rest/api/3/search/jql", auth, request.context.timeoutMs, {
|
|
10311
|
+
jql: fullJql,
|
|
10312
|
+
startAt,
|
|
10313
|
+
maxResults: pageSize,
|
|
10314
|
+
fields: SEARCH_FIELDS.split(",")
|
|
10284
10315
|
});
|
|
10285
10316
|
const items = data.issues.map((issue) => normalizeIssue(issue, baseUrl, request.context.integrationId));
|
|
10286
10317
|
const nextStart = data.startAt + data.issues.length;
|
package/dist/index.js
CHANGED
|
@@ -18202,7 +18202,7 @@ function buildJql(filters) {
|
|
|
18202
18202
|
if (filters?.updatedAfter) clauses.push(`updated >= ${escapeJql(filters.updatedAfter)}`);
|
|
18203
18203
|
if (filters?.search) clauses.push(`(summary ~ ${escapeJql(filters.search)} OR description ~ ${escapeJql(filters.search)})`);
|
|
18204
18204
|
if (filters?.providerQuery) clauses.push(`(${filters.providerQuery})`);
|
|
18205
|
-
return clauses.join(" AND ")
|
|
18205
|
+
return clauses.join(" AND ");
|
|
18206
18206
|
}
|
|
18207
18207
|
function normalizeBaseUrl(raw) {
|
|
18208
18208
|
let url = raw.trim();
|
|
@@ -18213,6 +18213,24 @@ function authHeader(email, token) {
|
|
|
18213
18213
|
const encoded = typeof Buffer !== "undefined" ? Buffer.from(`${email}:${token}`).toString("base64") : btoa(`${email}:${token}`);
|
|
18214
18214
|
return `Basic ${encoded}`;
|
|
18215
18215
|
}
|
|
18216
|
+
async function handleJiraResponse(res) {
|
|
18217
|
+
if (res.status === 401) throw integrationError("INTEGRATION_UNAUTHORIZED");
|
|
18218
|
+
if (res.status === 403) throw integrationError("INTEGRATION_FORBIDDEN");
|
|
18219
|
+
if (res.status === 404) throw integrationError("INTEGRATION_NOT_FOUND");
|
|
18220
|
+
if (res.status === 410) throw integrationError("INTEGRATION_UNAVAILABLE", "Jira API endpoint deprecated (410 Gone).");
|
|
18221
|
+
if (res.status === 429) throw integrationError("INTEGRATION_RATE_LIMITED");
|
|
18222
|
+
if (res.status >= 500) throw integrationError("INTEGRATION_UNAVAILABLE");
|
|
18223
|
+
if (!res.ok) {
|
|
18224
|
+
let detail = "";
|
|
18225
|
+
try {
|
|
18226
|
+
const body = await res.json();
|
|
18227
|
+
detail = body.errorMessages?.[0] ?? "";
|
|
18228
|
+
} catch {
|
|
18229
|
+
}
|
|
18230
|
+
throw integrationError("INTEGRATION_PROVIDER_ERROR", detail || `Jira responded with status ${res.status}.`);
|
|
18231
|
+
}
|
|
18232
|
+
return await res.json();
|
|
18233
|
+
}
|
|
18216
18234
|
async function jiraFetch(baseUrl, path11, auth, timeoutMs, params) {
|
|
18217
18235
|
const url = new URL(path11, baseUrl + "/");
|
|
18218
18236
|
if (params) for (const [k, v] of Object.entries(params)) url.searchParams.set(k, v);
|
|
@@ -18224,14 +18242,26 @@ async function jiraFetch(baseUrl, path11, auth, timeoutMs, params) {
|
|
|
18224
18242
|
headers: { Authorization: auth, Accept: "application/json" },
|
|
18225
18243
|
signal: controller.signal
|
|
18226
18244
|
});
|
|
18227
|
-
|
|
18228
|
-
|
|
18229
|
-
if (
|
|
18230
|
-
|
|
18231
|
-
|
|
18232
|
-
|
|
18233
|
-
|
|
18234
|
-
|
|
18245
|
+
return await handleJiraResponse(res);
|
|
18246
|
+
} catch (err) {
|
|
18247
|
+
if (err instanceof Error && err.name === "AbortError") throw integrationError("INTEGRATION_TIMEOUT");
|
|
18248
|
+
throw normalizeProviderError(err);
|
|
18249
|
+
} finally {
|
|
18250
|
+
clearTimeout(timer);
|
|
18251
|
+
}
|
|
18252
|
+
}
|
|
18253
|
+
async function jiraPost(baseUrl, path11, auth, timeoutMs, body) {
|
|
18254
|
+
const url = new URL(path11, baseUrl + "/");
|
|
18255
|
+
const controller = new AbortController();
|
|
18256
|
+
const timer = setTimeout(() => controller.abort(), timeoutMs);
|
|
18257
|
+
try {
|
|
18258
|
+
const res = await fetch(url.toString(), {
|
|
18259
|
+
method: "POST",
|
|
18260
|
+
headers: { Authorization: auth, Accept: "application/json", "Content-Type": "application/json" },
|
|
18261
|
+
body: JSON.stringify(body),
|
|
18262
|
+
signal: controller.signal
|
|
18263
|
+
});
|
|
18264
|
+
return await handleJiraResponse(res);
|
|
18235
18265
|
} catch (err) {
|
|
18236
18266
|
if (err instanceof Error && err.name === "AbortError") throw integrationError("INTEGRATION_TIMEOUT");
|
|
18237
18267
|
throw normalizeProviderError(err);
|
|
@@ -18352,11 +18382,12 @@ function createJiraAdapter() {
|
|
|
18352
18382
|
const pageSize = Math.min(Math.max(1, request.pageSize ?? DEFAULT_PAGE_SIZE), 100);
|
|
18353
18383
|
const startAt = request.cursor ? Math.max(0, Number.parseInt(request.cursor, 10) || 0) : 0;
|
|
18354
18384
|
try {
|
|
18355
|
-
const
|
|
18356
|
-
|
|
18357
|
-
|
|
18358
|
-
|
|
18359
|
-
|
|
18385
|
+
const fullJql = jql ? jql + " ORDER BY updated DESC" : "ORDER BY updated DESC";
|
|
18386
|
+
const data = await jiraPost(baseUrl, "/rest/api/3/search/jql", auth, request.context.timeoutMs, {
|
|
18387
|
+
jql: fullJql,
|
|
18388
|
+
startAt,
|
|
18389
|
+
maxResults: pageSize,
|
|
18390
|
+
fields: SEARCH_FIELDS.split(",")
|
|
18360
18391
|
});
|
|
18361
18392
|
const items = data.issues.map((issue) => normalizeIssue(issue, baseUrl, request.context.integrationId));
|
|
18362
18393
|
const nextStart = data.startAt + data.issues.length;
|