@kaddo/cli 3.88.3 → 3.89.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.
|
@@ -5,7 +5,7 @@
|
|
|
5
5
|
<link rel="icon" type="image/svg+xml" href="/favicon.svg" />
|
|
6
6
|
<meta name="viewport" content="width=device-width, initial-scale=1.0" />
|
|
7
7
|
<title>admin</title>
|
|
8
|
-
<script type="module" crossorigin src="/assets/index-
|
|
8
|
+
<script type="module" crossorigin src="/assets/index-vkZSMwVO.js"></script>
|
|
9
9
|
<link rel="stylesheet" crossorigin href="/assets/index-DNkI-1xG.css">
|
|
10
10
|
</head>
|
|
11
11
|
<body>
|
|
@@ -1115,10 +1115,18 @@ async function createAdminServer(opts) {
|
|
|
1115
1115
|
if (q.labels) filters.labels = q.labels.split(",");
|
|
1116
1116
|
if (q.assignees) filters.assignees = q.assignees.split(",");
|
|
1117
1117
|
if (q.search) filters.search = q.search;
|
|
1118
|
+
let cursors;
|
|
1119
|
+
if (q.cursors) {
|
|
1120
|
+
try {
|
|
1121
|
+
cursors = JSON.parse(q.cursors);
|
|
1122
|
+
} catch {
|
|
1123
|
+
}
|
|
1124
|
+
}
|
|
1118
1125
|
return asyncCore(reply, () => discoverExternalWorkItemsAdmin(projectDir, {
|
|
1119
1126
|
filters: Object.keys(filters).length ? filters : void 0,
|
|
1120
1127
|
pageSize: q.pageSize ? Number.parseInt(q.pageSize, 10) : void 0,
|
|
1121
|
-
integrationIds: q.integrationIds ? q.integrationIds.split(",") : void 0
|
|
1128
|
+
integrationIds: q.integrationIds ? q.integrationIds.split(",") : void 0,
|
|
1129
|
+
cursors
|
|
1122
1130
|
}));
|
|
1123
1131
|
}
|
|
1124
1132
|
);
|
package/dist/core.js
CHANGED
|
@@ -9435,6 +9435,8 @@ function defaultMessageFor(code) {
|
|
|
9435
9435
|
return "The external provider is temporarily unavailable.";
|
|
9436
9436
|
case "INTEGRATION_TIMEOUT":
|
|
9437
9437
|
return "The external provider did not respond in time.";
|
|
9438
|
+
case "INTEGRATION_INVALID_QUERY":
|
|
9439
|
+
return "The query syntax is invalid. Check filter values or JQL.";
|
|
9438
9440
|
case "INTEGRATION_PROVIDER_ERROR":
|
|
9439
9441
|
return "The external provider returned an error.";
|
|
9440
9442
|
case "UNSUPPORTED_CAPABILITY":
|
|
@@ -10146,11 +10148,19 @@ async function handleJiraResponse(res) {
|
|
|
10146
10148
|
if (res.status >= 500) throw integrationError("INTEGRATION_UNAVAILABLE");
|
|
10147
10149
|
if (!res.ok) {
|
|
10148
10150
|
let detail = "";
|
|
10151
|
+
let isJqlError = false;
|
|
10149
10152
|
try {
|
|
10150
10153
|
const body = await res.json();
|
|
10151
|
-
|
|
10154
|
+
const msgs = body.errorMessages?.filter(Boolean) ?? [];
|
|
10155
|
+
const fieldErrs = body.errors ? Object.entries(body.errors).map(([k, v]) => `${k}: ${v}`) : [];
|
|
10156
|
+
detail = [...msgs, ...fieldErrs].join("; ");
|
|
10157
|
+
if (res.status === 400) {
|
|
10158
|
+
const combined = detail.toLowerCase();
|
|
10159
|
+
isJqlError = combined.includes("jql") || combined.includes("query") || combined.includes("field") || combined.includes("clause");
|
|
10160
|
+
}
|
|
10152
10161
|
} catch {
|
|
10153
10162
|
}
|
|
10163
|
+
if (isJqlError) throw integrationError("INTEGRATION_INVALID_QUERY");
|
|
10154
10164
|
throw integrationError("INTEGRATION_PROVIDER_ERROR", detail || `Jira responded with status ${res.status}.`);
|
|
10155
10165
|
}
|
|
10156
10166
|
return await res.json();
|
|
@@ -10304,19 +10314,19 @@ function createJiraAdapter() {
|
|
|
10304
10314
|
const auth = authHeader(email, apiToken);
|
|
10305
10315
|
const jql = buildJql(request.filters);
|
|
10306
10316
|
const pageSize = Math.min(Math.max(1, request.pageSize ?? DEFAULT_PAGE_SIZE), 100);
|
|
10307
|
-
const
|
|
10317
|
+
const nextPageToken = request.cursor || void 0;
|
|
10308
10318
|
try {
|
|
10309
|
-
const fullJql = jql ? jql + " ORDER BY updated DESC" : "ORDER BY updated DESC";
|
|
10310
|
-
const
|
|
10319
|
+
const fullJql = jql ? jql + " ORDER BY updated DESC" : "updated >= -30d ORDER BY updated DESC";
|
|
10320
|
+
const body = {
|
|
10311
10321
|
jql: fullJql,
|
|
10312
|
-
startAt,
|
|
10313
10322
|
maxResults: pageSize,
|
|
10314
10323
|
fields: SEARCH_FIELDS.split(",")
|
|
10315
|
-
}
|
|
10324
|
+
};
|
|
10325
|
+
if (nextPageToken) body.nextPageToken = nextPageToken;
|
|
10326
|
+
const data = await jiraPost(baseUrl, "/rest/api/3/search/jql", auth, request.context.timeoutMs, body);
|
|
10316
10327
|
const items = data.issues.map((issue) => normalizeIssue(issue, baseUrl, request.context.integrationId));
|
|
10317
|
-
const
|
|
10318
|
-
|
|
10319
|
-
return { items, hasMore, ...hasMore ? { nextCursor: String(nextStart) } : {} };
|
|
10328
|
+
const hasMore = data.isLast === false;
|
|
10329
|
+
return { items, hasMore, ...hasMore && data.nextPageToken ? { nextCursor: data.nextPageToken } : {} };
|
|
10320
10330
|
} catch (err) {
|
|
10321
10331
|
throw normalizeProviderError(err);
|
|
10322
10332
|
}
|
|
@@ -10676,8 +10686,9 @@ async function discoverExternalWorkItems(dir, opts = {}, env = process.env) {
|
|
|
10676
10686
|
const adapter = resolveAdapter(integration);
|
|
10677
10687
|
const { context } = await buildContextWithSecrets(dir, integration, env);
|
|
10678
10688
|
const filters = mergeFilters(integration.filters, opts.filters);
|
|
10689
|
+
const cursor = opts.cursors?.[integration.id];
|
|
10679
10690
|
const page = await withTimeout(
|
|
10680
|
-
adapter.listWorkItems({ context, pageSize: opts.pageSize, filters }),
|
|
10691
|
+
adapter.listWorkItems({ context, cursor, pageSize: opts.pageSize, filters }),
|
|
10681
10692
|
context.timeoutMs
|
|
10682
10693
|
);
|
|
10683
10694
|
return {
|
|
@@ -10754,45 +10765,57 @@ function buildImportIndex(dir) {
|
|
|
10754
10765
|
}
|
|
10755
10766
|
return index;
|
|
10756
10767
|
}
|
|
10768
|
+
var importLocks = /* @__PURE__ */ new Set();
|
|
10757
10769
|
async function previewImport(dir, id, externalId, opts = {}, env = process.env) {
|
|
10770
|
+
const { integration } = requireIntegration(dir, id);
|
|
10771
|
+
if (!integration.enabled) throw new IntegrationServiceError("INTEGRATION_DISABLED", `Integration "${id}" is disabled. Enable it before previewing imports.`);
|
|
10758
10772
|
const item = await getExternalWorkItem(dir, id, externalId, env);
|
|
10759
10773
|
if (!item) throw integrationError("INTEGRATION_NOT_FOUND", `External work item "${externalId}" was not found.`);
|
|
10760
10774
|
const preview = buildImportPreview(item, { integrationId: id, type: opts.type });
|
|
10761
10775
|
return { preview, duplicate: findLinkedWorkItem(dir, id, externalId) };
|
|
10762
10776
|
}
|
|
10763
10777
|
async function importExternalWorkItem(dir, id, externalId, opts, env = process.env) {
|
|
10764
|
-
const
|
|
10765
|
-
if (!
|
|
10766
|
-
const
|
|
10767
|
-
|
|
10768
|
-
|
|
10769
|
-
|
|
10778
|
+
const { integration } = requireIntegration(dir, id);
|
|
10779
|
+
if (!integration.enabled) throw new IntegrationServiceError("INTEGRATION_DISABLED", `Integration "${id}" is disabled. Enable it before importing.`);
|
|
10780
|
+
const lockKey = `${id}#${externalId}`;
|
|
10781
|
+
if (importLocks.has(lockKey)) throw new IntegrationServiceError("INTEGRATION_INVALID_INPUT", "Import already in progress for this item.");
|
|
10782
|
+
importLocks.add(lockKey);
|
|
10783
|
+
try {
|
|
10784
|
+
const item = await getExternalWorkItem(dir, id, externalId, env);
|
|
10785
|
+
if (!item) throw integrationError("INTEGRATION_NOT_FOUND", `External work item "${externalId}" was not found.`);
|
|
10786
|
+
const preview = buildImportPreview(item, { integrationId: id, type: opts.type });
|
|
10787
|
+
const existing = findLinkedWorkItem(dir, id, externalId);
|
|
10788
|
+
if (existing) return { workItemId: existing.workItemId, created: false, duplicateOf: existing.workItemId, preview };
|
|
10789
|
+
const intent = item.description ? `${item.title}
|
|
10770
10790
|
|
|
10771
10791
|
${item.description}` : item.title;
|
|
10772
|
-
|
|
10773
|
-
|
|
10774
|
-
|
|
10775
|
-
|
|
10776
|
-
|
|
10777
|
-
|
|
10778
|
-
|
|
10779
|
-
|
|
10780
|
-
|
|
10781
|
-
|
|
10782
|
-
|
|
10783
|
-
|
|
10784
|
-
|
|
10785
|
-
|
|
10786
|
-
|
|
10787
|
-
|
|
10788
|
-
|
|
10789
|
-
|
|
10790
|
-
|
|
10791
|
-
|
|
10792
|
-
|
|
10793
|
-
|
|
10794
|
-
|
|
10795
|
-
|
|
10792
|
+
const created = createWorkItem(dir, {
|
|
10793
|
+
intent,
|
|
10794
|
+
type: opts.type,
|
|
10795
|
+
source: {
|
|
10796
|
+
type: "external",
|
|
10797
|
+
provider: item.provider,
|
|
10798
|
+
integration: id,
|
|
10799
|
+
id: externalId,
|
|
10800
|
+
url: item.url,
|
|
10801
|
+
imported_at: (/* @__PURE__ */ new Date()).toISOString(),
|
|
10802
|
+
external_updated_at: item.updatedAt
|
|
10803
|
+
},
|
|
10804
|
+
originalSnapshot: {
|
|
10805
|
+
title: item.title,
|
|
10806
|
+
description: item.description,
|
|
10807
|
+
type: item.type,
|
|
10808
|
+
status: item.status,
|
|
10809
|
+
labels: item.labels,
|
|
10810
|
+
assignee: item.assignees?.[0]?.name,
|
|
10811
|
+
created_at: item.createdAt,
|
|
10812
|
+
updated_at: item.updatedAt
|
|
10813
|
+
}
|
|
10814
|
+
});
|
|
10815
|
+
return { workItemId: created.id, created: true, preview, path: created.path };
|
|
10816
|
+
} finally {
|
|
10817
|
+
importLocks.delete(lockKey);
|
|
10818
|
+
}
|
|
10796
10819
|
}
|
|
10797
10820
|
export {
|
|
10798
10821
|
INTEGRATIONS_FILE,
|
package/dist/index.js
CHANGED
|
@@ -17593,6 +17593,8 @@ function defaultMessageFor(code) {
|
|
|
17593
17593
|
return "The external provider is temporarily unavailable.";
|
|
17594
17594
|
case "INTEGRATION_TIMEOUT":
|
|
17595
17595
|
return "The external provider did not respond in time.";
|
|
17596
|
+
case "INTEGRATION_INVALID_QUERY":
|
|
17597
|
+
return "The query syntax is invalid. Check filter values or JQL.";
|
|
17596
17598
|
case "INTEGRATION_PROVIDER_ERROR":
|
|
17597
17599
|
return "The external provider returned an error.";
|
|
17598
17600
|
case "UNSUPPORTED_CAPABILITY":
|
|
@@ -18222,11 +18224,19 @@ async function handleJiraResponse(res) {
|
|
|
18222
18224
|
if (res.status >= 500) throw integrationError("INTEGRATION_UNAVAILABLE");
|
|
18223
18225
|
if (!res.ok) {
|
|
18224
18226
|
let detail = "";
|
|
18227
|
+
let isJqlError = false;
|
|
18225
18228
|
try {
|
|
18226
18229
|
const body = await res.json();
|
|
18227
|
-
|
|
18230
|
+
const msgs = body.errorMessages?.filter(Boolean) ?? [];
|
|
18231
|
+
const fieldErrs = body.errors ? Object.entries(body.errors).map(([k, v]) => `${k}: ${v}`) : [];
|
|
18232
|
+
detail = [...msgs, ...fieldErrs].join("; ");
|
|
18233
|
+
if (res.status === 400) {
|
|
18234
|
+
const combined = detail.toLowerCase();
|
|
18235
|
+
isJqlError = combined.includes("jql") || combined.includes("query") || combined.includes("field") || combined.includes("clause");
|
|
18236
|
+
}
|
|
18228
18237
|
} catch {
|
|
18229
18238
|
}
|
|
18239
|
+
if (isJqlError) throw integrationError("INTEGRATION_INVALID_QUERY");
|
|
18230
18240
|
throw integrationError("INTEGRATION_PROVIDER_ERROR", detail || `Jira responded with status ${res.status}.`);
|
|
18231
18241
|
}
|
|
18232
18242
|
return await res.json();
|
|
@@ -18380,19 +18390,19 @@ function createJiraAdapter() {
|
|
|
18380
18390
|
const auth = authHeader(email, apiToken);
|
|
18381
18391
|
const jql = buildJql(request.filters);
|
|
18382
18392
|
const pageSize = Math.min(Math.max(1, request.pageSize ?? DEFAULT_PAGE_SIZE), 100);
|
|
18383
|
-
const
|
|
18393
|
+
const nextPageToken = request.cursor || void 0;
|
|
18384
18394
|
try {
|
|
18385
|
-
const fullJql = jql ? jql + " ORDER BY updated DESC" : "ORDER BY updated DESC";
|
|
18386
|
-
const
|
|
18395
|
+
const fullJql = jql ? jql + " ORDER BY updated DESC" : "updated >= -30d ORDER BY updated DESC";
|
|
18396
|
+
const body = {
|
|
18387
18397
|
jql: fullJql,
|
|
18388
|
-
startAt,
|
|
18389
18398
|
maxResults: pageSize,
|
|
18390
18399
|
fields: SEARCH_FIELDS.split(",")
|
|
18391
|
-
}
|
|
18400
|
+
};
|
|
18401
|
+
if (nextPageToken) body.nextPageToken = nextPageToken;
|
|
18402
|
+
const data = await jiraPost(baseUrl, "/rest/api/3/search/jql", auth, request.context.timeoutMs, body);
|
|
18392
18403
|
const items = data.issues.map((issue) => normalizeIssue(issue, baseUrl, request.context.integrationId));
|
|
18393
|
-
const
|
|
18394
|
-
|
|
18395
|
-
return { items, hasMore, ...hasMore ? { nextCursor: String(nextStart) } : {} };
|
|
18404
|
+
const hasMore = data.isLast === false;
|
|
18405
|
+
return { items, hasMore, ...hasMore && data.nextPageToken ? { nextCursor: data.nextPageToken } : {} };
|
|
18396
18406
|
} catch (err) {
|
|
18397
18407
|
throw normalizeProviderError(err);
|
|
18398
18408
|
}
|
|
@@ -18562,45 +18572,57 @@ function findLinkedWorkItem(dir, integrationId, externalId) {
|
|
|
18562
18572
|
}
|
|
18563
18573
|
return null;
|
|
18564
18574
|
}
|
|
18575
|
+
var importLocks = /* @__PURE__ */ new Set();
|
|
18565
18576
|
async function previewImport(dir, id, externalId, opts = {}, env = process.env) {
|
|
18577
|
+
const { integration } = requireIntegration(dir, id);
|
|
18578
|
+
if (!integration.enabled) throw new IntegrationServiceError("INTEGRATION_DISABLED", `Integration "${id}" is disabled. Enable it before previewing imports.`);
|
|
18566
18579
|
const item = await getExternalWorkItem(dir, id, externalId, env);
|
|
18567
18580
|
if (!item) throw integrationError("INTEGRATION_NOT_FOUND", `External work item "${externalId}" was not found.`);
|
|
18568
18581
|
const preview = buildImportPreview(item, { integrationId: id, type: opts.type });
|
|
18569
18582
|
return { preview, duplicate: findLinkedWorkItem(dir, id, externalId) };
|
|
18570
18583
|
}
|
|
18571
18584
|
async function importExternalWorkItem(dir, id, externalId, opts, env = process.env) {
|
|
18572
|
-
const
|
|
18573
|
-
if (!
|
|
18574
|
-
const
|
|
18575
|
-
|
|
18576
|
-
|
|
18577
|
-
|
|
18585
|
+
const { integration } = requireIntegration(dir, id);
|
|
18586
|
+
if (!integration.enabled) throw new IntegrationServiceError("INTEGRATION_DISABLED", `Integration "${id}" is disabled. Enable it before importing.`);
|
|
18587
|
+
const lockKey = `${id}#${externalId}`;
|
|
18588
|
+
if (importLocks.has(lockKey)) throw new IntegrationServiceError("INTEGRATION_INVALID_INPUT", "Import already in progress for this item.");
|
|
18589
|
+
importLocks.add(lockKey);
|
|
18590
|
+
try {
|
|
18591
|
+
const item = await getExternalWorkItem(dir, id, externalId, env);
|
|
18592
|
+
if (!item) throw integrationError("INTEGRATION_NOT_FOUND", `External work item "${externalId}" was not found.`);
|
|
18593
|
+
const preview = buildImportPreview(item, { integrationId: id, type: opts.type });
|
|
18594
|
+
const existing = findLinkedWorkItem(dir, id, externalId);
|
|
18595
|
+
if (existing) return { workItemId: existing.workItemId, created: false, duplicateOf: existing.workItemId, preview };
|
|
18596
|
+
const intent = item.description ? `${item.title}
|
|
18578
18597
|
|
|
18579
18598
|
${item.description}` : item.title;
|
|
18580
|
-
|
|
18581
|
-
|
|
18582
|
-
|
|
18583
|
-
|
|
18584
|
-
|
|
18585
|
-
|
|
18586
|
-
|
|
18587
|
-
|
|
18588
|
-
|
|
18589
|
-
|
|
18590
|
-
|
|
18591
|
-
|
|
18592
|
-
|
|
18593
|
-
|
|
18594
|
-
|
|
18595
|
-
|
|
18596
|
-
|
|
18597
|
-
|
|
18598
|
-
|
|
18599
|
-
|
|
18600
|
-
|
|
18601
|
-
|
|
18602
|
-
|
|
18603
|
-
|
|
18599
|
+
const created = createWorkItem(dir, {
|
|
18600
|
+
intent,
|
|
18601
|
+
type: opts.type,
|
|
18602
|
+
source: {
|
|
18603
|
+
type: "external",
|
|
18604
|
+
provider: item.provider,
|
|
18605
|
+
integration: id,
|
|
18606
|
+
id: externalId,
|
|
18607
|
+
url: item.url,
|
|
18608
|
+
imported_at: (/* @__PURE__ */ new Date()).toISOString(),
|
|
18609
|
+
external_updated_at: item.updatedAt
|
|
18610
|
+
},
|
|
18611
|
+
originalSnapshot: {
|
|
18612
|
+
title: item.title,
|
|
18613
|
+
description: item.description,
|
|
18614
|
+
type: item.type,
|
|
18615
|
+
status: item.status,
|
|
18616
|
+
labels: item.labels,
|
|
18617
|
+
assignee: item.assignees?.[0]?.name,
|
|
18618
|
+
created_at: item.createdAt,
|
|
18619
|
+
updated_at: item.updatedAt
|
|
18620
|
+
}
|
|
18621
|
+
});
|
|
18622
|
+
return { workItemId: created.id, created: true, preview, path: created.path };
|
|
18623
|
+
} finally {
|
|
18624
|
+
importLocks.delete(lockKey);
|
|
18625
|
+
}
|
|
18604
18626
|
}
|
|
18605
18627
|
|
|
18606
18628
|
// src/commands/integrations.ts
|