@kaddo/cli 3.88.4 → 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,13 +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) ?? [];
|
|
10152
10155
|
const fieldErrs = body.errors ? Object.entries(body.errors).map(([k, v]) => `${k}: ${v}`) : [];
|
|
10153
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
|
+
}
|
|
10154
10161
|
} catch {
|
|
10155
10162
|
}
|
|
10163
|
+
if (isJqlError) throw integrationError("INTEGRATION_INVALID_QUERY");
|
|
10156
10164
|
throw integrationError("INTEGRATION_PROVIDER_ERROR", detail || `Jira responded with status ${res.status}.`);
|
|
10157
10165
|
}
|
|
10158
10166
|
return await res.json();
|
|
@@ -10678,8 +10686,9 @@ async function discoverExternalWorkItems(dir, opts = {}, env = process.env) {
|
|
|
10678
10686
|
const adapter = resolveAdapter(integration);
|
|
10679
10687
|
const { context } = await buildContextWithSecrets(dir, integration, env);
|
|
10680
10688
|
const filters = mergeFilters(integration.filters, opts.filters);
|
|
10689
|
+
const cursor = opts.cursors?.[integration.id];
|
|
10681
10690
|
const page = await withTimeout(
|
|
10682
|
-
adapter.listWorkItems({ context, pageSize: opts.pageSize, filters }),
|
|
10691
|
+
adapter.listWorkItems({ context, cursor, pageSize: opts.pageSize, filters }),
|
|
10683
10692
|
context.timeoutMs
|
|
10684
10693
|
);
|
|
10685
10694
|
return {
|
|
@@ -10756,45 +10765,57 @@ function buildImportIndex(dir) {
|
|
|
10756
10765
|
}
|
|
10757
10766
|
return index;
|
|
10758
10767
|
}
|
|
10768
|
+
var importLocks = /* @__PURE__ */ new Set();
|
|
10759
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.`);
|
|
10760
10772
|
const item = await getExternalWorkItem(dir, id, externalId, env);
|
|
10761
10773
|
if (!item) throw integrationError("INTEGRATION_NOT_FOUND", `External work item "${externalId}" was not found.`);
|
|
10762
10774
|
const preview = buildImportPreview(item, { integrationId: id, type: opts.type });
|
|
10763
10775
|
return { preview, duplicate: findLinkedWorkItem(dir, id, externalId) };
|
|
10764
10776
|
}
|
|
10765
10777
|
async function importExternalWorkItem(dir, id, externalId, opts, env = process.env) {
|
|
10766
|
-
const
|
|
10767
|
-
if (!
|
|
10768
|
-
const
|
|
10769
|
-
|
|
10770
|
-
|
|
10771
|
-
|
|
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}
|
|
10772
10790
|
|
|
10773
10791
|
${item.description}` : item.title;
|
|
10774
|
-
|
|
10775
|
-
|
|
10776
|
-
|
|
10777
|
-
|
|
10778
|
-
|
|
10779
|
-
|
|
10780
|
-
|
|
10781
|
-
|
|
10782
|
-
|
|
10783
|
-
|
|
10784
|
-
|
|
10785
|
-
|
|
10786
|
-
|
|
10787
|
-
|
|
10788
|
-
|
|
10789
|
-
|
|
10790
|
-
|
|
10791
|
-
|
|
10792
|
-
|
|
10793
|
-
|
|
10794
|
-
|
|
10795
|
-
|
|
10796
|
-
|
|
10797
|
-
|
|
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
|
+
}
|
|
10798
10819
|
}
|
|
10799
10820
|
export {
|
|
10800
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,13 +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) ?? [];
|
|
18228
18231
|
const fieldErrs = body.errors ? Object.entries(body.errors).map(([k, v]) => `${k}: ${v}`) : [];
|
|
18229
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
|
+
}
|
|
18230
18237
|
} catch {
|
|
18231
18238
|
}
|
|
18239
|
+
if (isJqlError) throw integrationError("INTEGRATION_INVALID_QUERY");
|
|
18232
18240
|
throw integrationError("INTEGRATION_PROVIDER_ERROR", detail || `Jira responded with status ${res.status}.`);
|
|
18233
18241
|
}
|
|
18234
18242
|
return await res.json();
|
|
@@ -18564,45 +18572,57 @@ function findLinkedWorkItem(dir, integrationId, externalId) {
|
|
|
18564
18572
|
}
|
|
18565
18573
|
return null;
|
|
18566
18574
|
}
|
|
18575
|
+
var importLocks = /* @__PURE__ */ new Set();
|
|
18567
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.`);
|
|
18568
18579
|
const item = await getExternalWorkItem(dir, id, externalId, env);
|
|
18569
18580
|
if (!item) throw integrationError("INTEGRATION_NOT_FOUND", `External work item "${externalId}" was not found.`);
|
|
18570
18581
|
const preview = buildImportPreview(item, { integrationId: id, type: opts.type });
|
|
18571
18582
|
return { preview, duplicate: findLinkedWorkItem(dir, id, externalId) };
|
|
18572
18583
|
}
|
|
18573
18584
|
async function importExternalWorkItem(dir, id, externalId, opts, env = process.env) {
|
|
18574
|
-
const
|
|
18575
|
-
if (!
|
|
18576
|
-
const
|
|
18577
|
-
|
|
18578
|
-
|
|
18579
|
-
|
|
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}
|
|
18580
18597
|
|
|
18581
18598
|
${item.description}` : item.title;
|
|
18582
|
-
|
|
18583
|
-
|
|
18584
|
-
|
|
18585
|
-
|
|
18586
|
-
|
|
18587
|
-
|
|
18588
|
-
|
|
18589
|
-
|
|
18590
|
-
|
|
18591
|
-
|
|
18592
|
-
|
|
18593
|
-
|
|
18594
|
-
|
|
18595
|
-
|
|
18596
|
-
|
|
18597
|
-
|
|
18598
|
-
|
|
18599
|
-
|
|
18600
|
-
|
|
18601
|
-
|
|
18602
|
-
|
|
18603
|
-
|
|
18604
|
-
|
|
18605
|
-
|
|
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
|
+
}
|
|
18606
18626
|
}
|
|
18607
18627
|
|
|
18608
18628
|
// src/commands/integrations.ts
|