@kaddo/cli 3.83.0 → 3.84.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-DNuMsvZr.js"></script>
|
|
9
9
|
<link rel="stylesheet" crossorigin href="/assets/index-DNkI-1xG.css">
|
|
10
10
|
</head>
|
|
11
11
|
<body>
|
|
@@ -86,6 +86,9 @@ import {
|
|
|
86
86
|
getExternalWorkItem as coreGetExternalWorkItem,
|
|
87
87
|
previewImport as corePreviewImport,
|
|
88
88
|
importExternalWorkItem as coreImportExternalWorkItem,
|
|
89
|
+
discoverExternalWorkItems as coreDiscoverExternalWorkItems,
|
|
90
|
+
getIntegrationFilters as coreGetIntegrationFilters,
|
|
91
|
+
updateIntegrationFilters as coreUpdateIntegrationFilters,
|
|
89
92
|
IntegrationError,
|
|
90
93
|
IntegrationServiceError,
|
|
91
94
|
WorkItemWriteError,
|
|
@@ -375,7 +378,7 @@ async function getIntegrationStatus(dir, id) {
|
|
|
375
378
|
}
|
|
376
379
|
async function getExternalWorkItems(dir, id, opts) {
|
|
377
380
|
try {
|
|
378
|
-
return await coreListExternalWorkItems(dir, id, { cursor: opts.cursor, pageSize: opts.pageSize, filters:
|
|
381
|
+
return await coreListExternalWorkItems(dir, id, { cursor: opts.cursor, pageSize: opts.pageSize, filters: opts.filters });
|
|
379
382
|
} catch (err) {
|
|
380
383
|
mapIntegrationError(err);
|
|
381
384
|
}
|
|
@@ -471,6 +474,27 @@ async function removeIntegrationSecretAdmin(dir, id, secretName) {
|
|
|
471
474
|
mapIntegrationError(err);
|
|
472
475
|
}
|
|
473
476
|
}
|
|
477
|
+
async function discoverExternalWorkItemsAdmin(dir, opts) {
|
|
478
|
+
try {
|
|
479
|
+
return await coreDiscoverExternalWorkItems(dir, opts);
|
|
480
|
+
} catch (err) {
|
|
481
|
+
mapIntegrationError(err);
|
|
482
|
+
}
|
|
483
|
+
}
|
|
484
|
+
function getIntegrationFiltersAdmin(dir, id) {
|
|
485
|
+
try {
|
|
486
|
+
return coreGetIntegrationFilters(dir, id);
|
|
487
|
+
} catch (err) {
|
|
488
|
+
mapIntegrationError(err);
|
|
489
|
+
}
|
|
490
|
+
}
|
|
491
|
+
function updateIntegrationFiltersAdmin(dir, id, filters) {
|
|
492
|
+
try {
|
|
493
|
+
return coreUpdateIntegrationFilters(dir, id, filters);
|
|
494
|
+
} catch (err) {
|
|
495
|
+
mapIntegrationError(err);
|
|
496
|
+
}
|
|
497
|
+
}
|
|
474
498
|
|
|
475
499
|
// src/contracts/schemas.ts
|
|
476
500
|
import { z } from "zod";
|
|
@@ -1038,12 +1062,20 @@ async function createAdminServer(opts) {
|
|
|
1038
1062
|
);
|
|
1039
1063
|
app.get(
|
|
1040
1064
|
"/api/v1/admin/integrations/:id/work-items",
|
|
1041
|
-
async (request, reply) =>
|
|
1042
|
-
|
|
1043
|
-
|
|
1044
|
-
|
|
1045
|
-
|
|
1046
|
-
|
|
1065
|
+
async (request, reply) => {
|
|
1066
|
+
const q = request.query;
|
|
1067
|
+
const filters = {};
|
|
1068
|
+
if (q.statuses) filters.statuses = q.statuses.split(",");
|
|
1069
|
+
if (q.types) filters.types = q.types.split(",");
|
|
1070
|
+
if (q.labels) filters.labels = q.labels.split(",");
|
|
1071
|
+
if (q.assignees) filters.assignees = q.assignees.split(",");
|
|
1072
|
+
if (q.search) filters.search = q.search;
|
|
1073
|
+
return asyncCore(reply, () => getExternalWorkItems(projectDir, request.params.id, {
|
|
1074
|
+
cursor: q.cursor,
|
|
1075
|
+
pageSize: q.pageSize ? Number.parseInt(q.pageSize, 10) : void 0,
|
|
1076
|
+
filters: Object.keys(filters).length ? filters : void 0
|
|
1077
|
+
}));
|
|
1078
|
+
}
|
|
1047
1079
|
);
|
|
1048
1080
|
app.get(
|
|
1049
1081
|
"/api/v1/admin/integrations/:id/work-items/:externalId",
|
|
@@ -1061,6 +1093,35 @@ async function createAdminServer(opts) {
|
|
|
1061
1093
|
return asyncCore(reply, () => importIntegrationWorkItem(projectDir, request.params.id, request.params.externalId, { type }));
|
|
1062
1094
|
}
|
|
1063
1095
|
);
|
|
1096
|
+
app.get(
|
|
1097
|
+
"/api/v1/admin/integrations/discover",
|
|
1098
|
+
async (request, reply) => {
|
|
1099
|
+
const q = request.query;
|
|
1100
|
+
const filters = {};
|
|
1101
|
+
if (q.statuses) filters.statuses = q.statuses.split(",");
|
|
1102
|
+
if (q.types) filters.types = q.types.split(",");
|
|
1103
|
+
if (q.labels) filters.labels = q.labels.split(",");
|
|
1104
|
+
if (q.assignees) filters.assignees = q.assignees.split(",");
|
|
1105
|
+
if (q.search) filters.search = q.search;
|
|
1106
|
+
return asyncCore(reply, () => discoverExternalWorkItemsAdmin(projectDir, {
|
|
1107
|
+
filters: Object.keys(filters).length ? filters : void 0,
|
|
1108
|
+
pageSize: q.pageSize ? Number.parseInt(q.pageSize, 10) : void 0,
|
|
1109
|
+
integrationIds: q.integrationIds ? q.integrationIds.split(",") : void 0
|
|
1110
|
+
}));
|
|
1111
|
+
}
|
|
1112
|
+
);
|
|
1113
|
+
app.get("/api/v1/admin/integrations/:id/filters", async (request, reply) => {
|
|
1114
|
+
try {
|
|
1115
|
+
return getIntegrationFiltersAdmin(projectDir, request.params.id);
|
|
1116
|
+
} catch (err) {
|
|
1117
|
+
if (err instanceof CoreError) return reply.code(statusForCode(err.code)).send({ error: { code: err.code, message: err.message } });
|
|
1118
|
+
throw err;
|
|
1119
|
+
}
|
|
1120
|
+
});
|
|
1121
|
+
app.put(
|
|
1122
|
+
"/api/v1/admin/integrations/:id/filters",
|
|
1123
|
+
async (request, reply) => writeHandler(reply, () => updateIntegrationFiltersAdmin(projectDir, request.params.id, request.body ?? {}))
|
|
1124
|
+
);
|
|
1064
1125
|
app.get("/api/v1/admin/knowledge/inventory", coreRoute(getKnowledgeInventory));
|
|
1065
1126
|
app.get("/api/v1/admin/knowledge/artifact/:artifactId", async (request) => {
|
|
1066
1127
|
try {
|
package/dist/core.js
CHANGED
|
@@ -9480,6 +9480,51 @@ function parseSecrets(raw, id, findings) {
|
|
|
9480
9480
|
}
|
|
9481
9481
|
return secrets;
|
|
9482
9482
|
}
|
|
9483
|
+
function toStringArray3(raw) {
|
|
9484
|
+
if (raw == null) return void 0;
|
|
9485
|
+
if (Array.isArray(raw)) return raw.filter((v) => typeof v === "string" && v.trim() !== "").map((v) => v.trim());
|
|
9486
|
+
if (typeof raw === "string" && raw.trim()) return [raw.trim()];
|
|
9487
|
+
return void 0;
|
|
9488
|
+
}
|
|
9489
|
+
function parseFilters(raw) {
|
|
9490
|
+
if (raw == null || typeof raw !== "object" || Array.isArray(raw)) return void 0;
|
|
9491
|
+
const o = raw;
|
|
9492
|
+
const filters = {};
|
|
9493
|
+
let hasAny = false;
|
|
9494
|
+
const types = toStringArray3(o.types);
|
|
9495
|
+
if (types?.length) {
|
|
9496
|
+
filters.types = types;
|
|
9497
|
+
hasAny = true;
|
|
9498
|
+
}
|
|
9499
|
+
const statuses = toStringArray3(o.statuses);
|
|
9500
|
+
if (statuses?.length) {
|
|
9501
|
+
filters.statuses = statuses;
|
|
9502
|
+
hasAny = true;
|
|
9503
|
+
}
|
|
9504
|
+
const labels = toStringArray3(o.labels);
|
|
9505
|
+
if (labels?.length) {
|
|
9506
|
+
filters.labels = labels;
|
|
9507
|
+
hasAny = true;
|
|
9508
|
+
}
|
|
9509
|
+
const assignees = toStringArray3(o.assignees);
|
|
9510
|
+
if (assignees?.length) {
|
|
9511
|
+
filters.assignees = assignees;
|
|
9512
|
+
hasAny = true;
|
|
9513
|
+
}
|
|
9514
|
+
if (typeof o.updatedAfter === "string" && o.updatedAfter.trim()) {
|
|
9515
|
+
filters.updatedAfter = o.updatedAfter.trim();
|
|
9516
|
+
hasAny = true;
|
|
9517
|
+
}
|
|
9518
|
+
if (typeof o.search === "string" && o.search.trim()) {
|
|
9519
|
+
filters.search = o.search.trim();
|
|
9520
|
+
hasAny = true;
|
|
9521
|
+
}
|
|
9522
|
+
if (typeof o.providerQuery === "string" && o.providerQuery.trim()) {
|
|
9523
|
+
filters.providerQuery = o.providerQuery.trim();
|
|
9524
|
+
hasAny = true;
|
|
9525
|
+
}
|
|
9526
|
+
return hasAny ? filters : void 0;
|
|
9527
|
+
}
|
|
9483
9528
|
function parseIntegrationsConfig(raw, opts) {
|
|
9484
9529
|
const findings = [];
|
|
9485
9530
|
const integrations = [];
|
|
@@ -9513,8 +9558,9 @@ function parseIntegrationsConfig(raw, opts) {
|
|
|
9513
9558
|
const config = o.config && typeof o.config === "object" && !Array.isArray(o.config) ? o.config : {};
|
|
9514
9559
|
const credentials = parseCredentials(o.credentials, id, findings);
|
|
9515
9560
|
const secrets = parseSecrets(o.secrets, id, findings);
|
|
9561
|
+
const filters = parseFilters(o.filters);
|
|
9516
9562
|
const timeoutMs = typeof o.timeout_ms === "number" ? o.timeout_ms : typeof o.timeoutMs === "number" ? o.timeoutMs : void 0;
|
|
9517
|
-
integrations.push({ id, adapter, enabled, config, credentials, secrets, timeoutMs });
|
|
9563
|
+
integrations.push({ id, adapter, enabled, config, credentials, secrets, filters, timeoutMs });
|
|
9518
9564
|
}
|
|
9519
9565
|
return { integrations, findings };
|
|
9520
9566
|
}
|
|
@@ -9551,6 +9597,7 @@ function serializeIntegrationsConfig(integrations) {
|
|
|
9551
9597
|
entry.credentials = creds;
|
|
9552
9598
|
}
|
|
9553
9599
|
if (Object.keys(i.secrets).length > 0) entry.secrets = i.secrets;
|
|
9600
|
+
if (i.filters && Object.keys(i.filters).length > 0) entry.filters = i.filters;
|
|
9554
9601
|
if (i.timeoutMs !== void 0) entry.timeout_ms = i.timeoutMs;
|
|
9555
9602
|
return entry;
|
|
9556
9603
|
})
|
|
@@ -9564,9 +9611,24 @@ function integrationConfigFromInput(input) {
|
|
|
9564
9611
|
config: input.config ?? {},
|
|
9565
9612
|
credentials: {},
|
|
9566
9613
|
secrets: input.secrets ?? {},
|
|
9614
|
+
filters: input.filters,
|
|
9567
9615
|
timeoutMs: input.timeoutMs
|
|
9568
9616
|
};
|
|
9569
9617
|
}
|
|
9618
|
+
function mergeFilters(base, overlay) {
|
|
9619
|
+
if (!base && !overlay) return {};
|
|
9620
|
+
if (!base) return { ...overlay };
|
|
9621
|
+
if (!overlay) return { ...base };
|
|
9622
|
+
return {
|
|
9623
|
+
types: overlay.types?.length ? overlay.types : base.types,
|
|
9624
|
+
statuses: overlay.statuses?.length ? overlay.statuses : base.statuses,
|
|
9625
|
+
labels: overlay.labels?.length ? overlay.labels : base.labels,
|
|
9626
|
+
assignees: overlay.assignees?.length ? overlay.assignees : base.assignees,
|
|
9627
|
+
updatedAfter: overlay.updatedAfter ?? base.updatedAfter,
|
|
9628
|
+
search: overlay.search ?? base.search,
|
|
9629
|
+
providerQuery: overlay.providerQuery ?? base.providerQuery
|
|
9630
|
+
};
|
|
9631
|
+
}
|
|
9570
9632
|
|
|
9571
9633
|
// ../integrations/src/preview.ts
|
|
9572
9634
|
function buildImportPreview(item, opts) {
|
|
@@ -9707,6 +9769,7 @@ var DEFAULT_ITEMS = [
|
|
|
9707
9769
|
status: "Open",
|
|
9708
9770
|
url: "https://example.test/mock/EXT-001",
|
|
9709
9771
|
labels: ["registration", "beta"],
|
|
9772
|
+
assignees: [{ name: "Alice" }],
|
|
9710
9773
|
createdAt: "2026-01-05T10:00:00.000Z",
|
|
9711
9774
|
updatedAt: "2026-02-01T09:30:00.000Z",
|
|
9712
9775
|
rawMetadata: { board: "delivery" }
|
|
@@ -9720,8 +9783,86 @@ var DEFAULT_ITEMS = [
|
|
|
9720
9783
|
status: "To Do",
|
|
9721
9784
|
url: "https://example.test/mock/EXT-002",
|
|
9722
9785
|
labels: ["onboarding"],
|
|
9786
|
+
assignees: [{ name: "Bob" }],
|
|
9723
9787
|
createdAt: "2026-01-08T12:00:00.000Z",
|
|
9724
9788
|
updatedAt: "2026-01-20T15:00:00.000Z"
|
|
9789
|
+
},
|
|
9790
|
+
{
|
|
9791
|
+
externalId: "EXT-003",
|
|
9792
|
+
provider: MOCK_ADAPTER_ID,
|
|
9793
|
+
title: "Fix authentication error on mobile",
|
|
9794
|
+
description: "Users on iOS 17 see a blank screen after OAuth redirect.",
|
|
9795
|
+
type: "Bug",
|
|
9796
|
+
status: "In Progress",
|
|
9797
|
+
url: "https://example.test/mock/EXT-003",
|
|
9798
|
+
labels: ["auth", "mobile", "critical"],
|
|
9799
|
+
assignees: [{ name: "Alice" }],
|
|
9800
|
+
createdAt: "2026-02-10T08:00:00.000Z",
|
|
9801
|
+
updatedAt: "2026-03-01T14:00:00.000Z"
|
|
9802
|
+
},
|
|
9803
|
+
{
|
|
9804
|
+
externalId: "EXT-004",
|
|
9805
|
+
provider: MOCK_ADAPTER_ID,
|
|
9806
|
+
title: "Design system token audit",
|
|
9807
|
+
description: "Review and consolidate design tokens across the component library.",
|
|
9808
|
+
type: "Task",
|
|
9809
|
+
status: "To Do",
|
|
9810
|
+
url: "https://example.test/mock/EXT-004",
|
|
9811
|
+
labels: ["frontend", "design-system"],
|
|
9812
|
+
createdAt: "2026-02-15T10:00:00.000Z",
|
|
9813
|
+
updatedAt: "2026-02-20T11:00:00.000Z"
|
|
9814
|
+
},
|
|
9815
|
+
{
|
|
9816
|
+
externalId: "EXT-005",
|
|
9817
|
+
provider: MOCK_ADAPTER_ID,
|
|
9818
|
+
title: "Migrate billing service to new payment gateway",
|
|
9819
|
+
description: "Stripe v2 migration \u2014 switch from legacy Charges API to Payment Intents.",
|
|
9820
|
+
type: "Epic",
|
|
9821
|
+
status: "Open",
|
|
9822
|
+
url: "https://example.test/mock/EXT-005",
|
|
9823
|
+
labels: ["billing", "backend", "migration"],
|
|
9824
|
+
assignees: [{ name: "Carol" }],
|
|
9825
|
+
createdAt: "2026-01-20T09:00:00.000Z",
|
|
9826
|
+
updatedAt: "2026-03-05T16:00:00.000Z"
|
|
9827
|
+
},
|
|
9828
|
+
{
|
|
9829
|
+
externalId: "EXT-006",
|
|
9830
|
+
provider: MOCK_ADAPTER_ID,
|
|
9831
|
+
title: "Add CSV export to reports",
|
|
9832
|
+
description: "Users need to export analytics reports as CSV for external tools.",
|
|
9833
|
+
type: "Feature",
|
|
9834
|
+
status: "In Progress",
|
|
9835
|
+
url: "https://example.test/mock/EXT-006",
|
|
9836
|
+
labels: ["reports", "backend"],
|
|
9837
|
+
assignees: [{ name: "Bob" }],
|
|
9838
|
+
createdAt: "2026-02-25T13:00:00.000Z",
|
|
9839
|
+
updatedAt: "2026-03-10T10:00:00.000Z"
|
|
9840
|
+
},
|
|
9841
|
+
{
|
|
9842
|
+
externalId: "EXT-007",
|
|
9843
|
+
provider: MOCK_ADAPTER_ID,
|
|
9844
|
+
title: "Improve search relevance scoring",
|
|
9845
|
+
description: "Tweak TF-IDF weights and add trigram matching for better search results.",
|
|
9846
|
+
type: "Task",
|
|
9847
|
+
status: "Done",
|
|
9848
|
+
url: "https://example.test/mock/EXT-007",
|
|
9849
|
+
labels: ["search", "backend"],
|
|
9850
|
+
assignees: [{ name: "Alice" }],
|
|
9851
|
+
createdAt: "2026-01-12T07:00:00.000Z",
|
|
9852
|
+
updatedAt: "2026-02-28T17:00:00.000Z"
|
|
9853
|
+
},
|
|
9854
|
+
{
|
|
9855
|
+
externalId: "EXT-008",
|
|
9856
|
+
provider: MOCK_ADAPTER_ID,
|
|
9857
|
+
title: "Set up E2E test pipeline",
|
|
9858
|
+
description: "Configure Playwright tests running on every PR via GitHub Actions.",
|
|
9859
|
+
type: "Task",
|
|
9860
|
+
status: "Done",
|
|
9861
|
+
url: "https://example.test/mock/EXT-008",
|
|
9862
|
+
labels: ["testing", "ci"],
|
|
9863
|
+
assignees: [{ name: "Carol" }],
|
|
9864
|
+
createdAt: "2026-01-30T11:00:00.000Z",
|
|
9865
|
+
updatedAt: "2026-02-15T09:00:00.000Z"
|
|
9725
9866
|
}
|
|
9726
9867
|
];
|
|
9727
9868
|
function simulationOf(context, fallback) {
|
|
@@ -9753,6 +9894,16 @@ function createMockAdapter(opts = {}) {
|
|
|
9753
9894
|
displayName: "Mock Work Source",
|
|
9754
9895
|
version: "1.0.0",
|
|
9755
9896
|
description: "Deterministic offline reference adapter for validating the integration foundation.",
|
|
9897
|
+
icon: "mock",
|
|
9898
|
+
filterCapabilities: {
|
|
9899
|
+
types: { supported: true, multiple: true },
|
|
9900
|
+
statuses: { supported: true, multiple: true },
|
|
9901
|
+
labels: { supported: true, multiple: true },
|
|
9902
|
+
assignees: { supported: true, multiple: true },
|
|
9903
|
+
updatedAfter: { supported: true },
|
|
9904
|
+
search: { supported: true },
|
|
9905
|
+
providerQuery: { supported: false }
|
|
9906
|
+
},
|
|
9756
9907
|
configSchema: {
|
|
9757
9908
|
simulate: {
|
|
9758
9909
|
type: "select",
|
|
@@ -9799,9 +9950,24 @@ function createMockAdapter(opts = {}) {
|
|
|
9799
9950
|
readFailure(simulationOf(request.context, defaultSim));
|
|
9800
9951
|
let pool = items;
|
|
9801
9952
|
const f = request.filters;
|
|
9802
|
-
if (f?.
|
|
9803
|
-
|
|
9804
|
-
|
|
9953
|
+
if (f?.statuses?.length) {
|
|
9954
|
+
const lower = f.statuses.map((s) => s.toLowerCase());
|
|
9955
|
+
pool = pool.filter((i) => lower.includes((i.status ?? "").toLowerCase()));
|
|
9956
|
+
}
|
|
9957
|
+
if (f?.types?.length) {
|
|
9958
|
+
const lower = f.types.map((t) => t.toLowerCase());
|
|
9959
|
+
pool = pool.filter((i) => lower.includes((i.type ?? "").toLowerCase()));
|
|
9960
|
+
}
|
|
9961
|
+
if (f?.labels?.length) {
|
|
9962
|
+
const lower = f.labels.map((l) => l.toLowerCase());
|
|
9963
|
+
pool = pool.filter((i) => i.labels?.some((il) => lower.includes(il.toLowerCase())));
|
|
9964
|
+
}
|
|
9965
|
+
if (f?.assignees?.length) {
|
|
9966
|
+
const lower = f.assignees.map((a) => a.toLowerCase());
|
|
9967
|
+
pool = pool.filter((i) => i.assignees?.some((a) => lower.includes((a.name ?? "").toLowerCase())));
|
|
9968
|
+
}
|
|
9969
|
+
if (f?.search) pool = pool.filter((i) => `${i.title} ${i.description ?? ""}`.toLowerCase().includes(f.search.toLowerCase()));
|
|
9970
|
+
if (f?.updatedAfter) pool = pool.filter((i) => (i.updatedAt ?? "") >= f.updatedAfter);
|
|
9805
9971
|
const size = Math.max(1, request.pageSize ?? defaultPageSize);
|
|
9806
9972
|
const start = request.cursor ? Math.max(0, Number.parseInt(request.cursor, 10) || 0) : 0;
|
|
9807
9973
|
const slice = pool.slice(start, start + size);
|
|
@@ -9882,6 +10048,7 @@ function listIntegrations(dir) {
|
|
|
9882
10048
|
credentialRefs: Object.values(integration.credentials).map((c) => c.env),
|
|
9883
10049
|
secretRefs: Object.values(integration.secrets),
|
|
9884
10050
|
secretStatus: {},
|
|
10051
|
+
filters: integration.filters,
|
|
9885
10052
|
findings: findings.filter((f) => f.id === integration.id)
|
|
9886
10053
|
};
|
|
9887
10054
|
});
|
|
@@ -9902,6 +10069,7 @@ function getIntegration(dir, id) {
|
|
|
9902
10069
|
credentialRefs: Object.values(integration.credentials).map((c) => c.env),
|
|
9903
10070
|
secretRefs: Object.values(integration.secrets),
|
|
9904
10071
|
secretStatus: {},
|
|
10072
|
+
filters: integration.filters,
|
|
9905
10073
|
findings: findings.filter((f) => f.id === integration.id)
|
|
9906
10074
|
};
|
|
9907
10075
|
}
|
|
@@ -9925,8 +10093,10 @@ function getAvailableIntegrationTypes() {
|
|
|
9925
10093
|
id: a.id,
|
|
9926
10094
|
displayName: a.metadata.displayName,
|
|
9927
10095
|
description: a.metadata.description,
|
|
10096
|
+
icon: a.metadata.icon,
|
|
9928
10097
|
configSchema: a.metadata.configSchema ?? {},
|
|
9929
10098
|
secretSchema: a.metadata.secretSchema ?? {},
|
|
10099
|
+
filterCapabilities: a.metadata.filterCapabilities,
|
|
9930
10100
|
capabilities: a.capabilities
|
|
9931
10101
|
}));
|
|
9932
10102
|
}
|
|
@@ -10064,12 +10234,101 @@ function statusOf(connection) {
|
|
|
10064
10234
|
return "invalid-config";
|
|
10065
10235
|
}
|
|
10066
10236
|
}
|
|
10237
|
+
function getIntegrationFilters(dir, id) {
|
|
10238
|
+
const { integration } = requireIntegration(dir, id);
|
|
10239
|
+
return integration.filters ?? {};
|
|
10240
|
+
}
|
|
10241
|
+
function updateIntegrationFilters(dir, id, filters) {
|
|
10242
|
+
const { integrations } = loadIntegrations(dir);
|
|
10243
|
+
const idx = integrations.findIndex((i) => i.id === id);
|
|
10244
|
+
if (idx < 0) throw new IntegrationServiceError("INTEGRATION_NOT_CONFIGURED", `No integration "${id}" is configured.`);
|
|
10245
|
+
const clean = {};
|
|
10246
|
+
let hasAny = false;
|
|
10247
|
+
if (filters.types?.length) {
|
|
10248
|
+
clean.types = filters.types;
|
|
10249
|
+
hasAny = true;
|
|
10250
|
+
}
|
|
10251
|
+
if (filters.statuses?.length) {
|
|
10252
|
+
clean.statuses = filters.statuses;
|
|
10253
|
+
hasAny = true;
|
|
10254
|
+
}
|
|
10255
|
+
if (filters.labels?.length) {
|
|
10256
|
+
clean.labels = filters.labels;
|
|
10257
|
+
hasAny = true;
|
|
10258
|
+
}
|
|
10259
|
+
if (filters.assignees?.length) {
|
|
10260
|
+
clean.assignees = filters.assignees;
|
|
10261
|
+
hasAny = true;
|
|
10262
|
+
}
|
|
10263
|
+
if (filters.updatedAfter) {
|
|
10264
|
+
clean.updatedAfter = filters.updatedAfter;
|
|
10265
|
+
hasAny = true;
|
|
10266
|
+
}
|
|
10267
|
+
if (filters.search) {
|
|
10268
|
+
clean.search = filters.search;
|
|
10269
|
+
hasAny = true;
|
|
10270
|
+
}
|
|
10271
|
+
if (filters.providerQuery) {
|
|
10272
|
+
clean.providerQuery = filters.providerQuery;
|
|
10273
|
+
hasAny = true;
|
|
10274
|
+
}
|
|
10275
|
+
integrations[idx].filters = hasAny ? clean : void 0;
|
|
10276
|
+
saveIntegrations(dir, integrations);
|
|
10277
|
+
return getIntegration(dir, id);
|
|
10278
|
+
}
|
|
10279
|
+
async function discoverExternalWorkItems(dir, opts = {}, env = process.env) {
|
|
10280
|
+
const { integrations, findings } = loadIntegrations(dir);
|
|
10281
|
+
const candidates = integrations.filter((i) => {
|
|
10282
|
+
if (!i.enabled) return false;
|
|
10283
|
+
if (configStatus(i, findings) === "invalid-config") return false;
|
|
10284
|
+
if (opts.integrationIds?.length && !opts.integrationIds.includes(i.id)) return false;
|
|
10285
|
+
const adapter = registry.get(i.adapter);
|
|
10286
|
+
return adapter?.capabilities.workItems.list === true;
|
|
10287
|
+
});
|
|
10288
|
+
const settled = await Promise.allSettled(
|
|
10289
|
+
candidates.map(async (integration) => {
|
|
10290
|
+
const adapter = resolveAdapter(integration);
|
|
10291
|
+
const { context } = await buildContextWithSecrets(dir, integration, env);
|
|
10292
|
+
const filters = mergeFilters(integration.filters, opts.filters);
|
|
10293
|
+
const page = await withTimeout(
|
|
10294
|
+
adapter.listWorkItems({ context, pageSize: opts.pageSize, filters }),
|
|
10295
|
+
context.timeoutMs
|
|
10296
|
+
);
|
|
10297
|
+
return {
|
|
10298
|
+
integrationId: integration.id,
|
|
10299
|
+
adapter: integration.adapter,
|
|
10300
|
+
displayName: adapter.metadata.displayName,
|
|
10301
|
+
icon: adapter.metadata.icon,
|
|
10302
|
+
items: page.items,
|
|
10303
|
+
hasMore: page.hasMore,
|
|
10304
|
+
nextCursor: page.nextCursor
|
|
10305
|
+
};
|
|
10306
|
+
})
|
|
10307
|
+
);
|
|
10308
|
+
const results = settled.map((s, i) => {
|
|
10309
|
+
if (s.status === "fulfilled") return s.value;
|
|
10310
|
+
const integration = candidates[i];
|
|
10311
|
+
const adapter = registry.get(integration.adapter);
|
|
10312
|
+
const msg = s.reason instanceof IntegrationError ? s.reason.safeMessage : "An unexpected error occurred.";
|
|
10313
|
+
return {
|
|
10314
|
+
integrationId: integration.id,
|
|
10315
|
+
adapter: integration.adapter,
|
|
10316
|
+
displayName: adapter?.metadata.displayName ?? integration.adapter,
|
|
10317
|
+
icon: adapter?.metadata.icon,
|
|
10318
|
+
items: [],
|
|
10319
|
+
hasMore: false,
|
|
10320
|
+
error: msg
|
|
10321
|
+
};
|
|
10322
|
+
});
|
|
10323
|
+
return { results, totalItems: results.reduce((sum, r) => sum + r.items.length, 0) };
|
|
10324
|
+
}
|
|
10067
10325
|
async function listExternalWorkItems(dir, id, opts = {}, env = process.env) {
|
|
10068
10326
|
const { integration } = requireIntegration(dir, id);
|
|
10069
10327
|
const adapter = resolveAdapter(integration);
|
|
10070
10328
|
if (!adapter.capabilities.workItems.list) throw integrationError("UNSUPPORTED_CAPABILITY", `Adapter "${adapter.id}" cannot list work items.`);
|
|
10071
10329
|
const { context } = await buildContextWithSecrets(dir, integration, env);
|
|
10072
|
-
|
|
10330
|
+
const filters = mergeFilters(integration.filters, opts.filters);
|
|
10331
|
+
return withTimeout(adapter.listWorkItems({ context, cursor: opts.cursor, pageSize: opts.pageSize, filters }), context.timeoutMs);
|
|
10073
10332
|
}
|
|
10074
10333
|
async function getExternalWorkItem(dir, id, externalId, env = process.env) {
|
|
10075
10334
|
const { integration } = requireIntegration(dir, id);
|
|
@@ -10144,6 +10403,7 @@ export {
|
|
|
10144
10403
|
cwd,
|
|
10145
10404
|
deleteIntegration,
|
|
10146
10405
|
disableIntegration,
|
|
10406
|
+
discoverExternalWorkItems,
|
|
10147
10407
|
discoverKnowledge,
|
|
10148
10408
|
discoverWorkItems,
|
|
10149
10409
|
enableIntegration,
|
|
@@ -10154,6 +10414,7 @@ export {
|
|
|
10154
10414
|
getExternalWorkItem,
|
|
10155
10415
|
getImpactCandidates,
|
|
10156
10416
|
getIntegration,
|
|
10417
|
+
getIntegrationFilters,
|
|
10157
10418
|
getIntegrationSecretStatus,
|
|
10158
10419
|
getSystemMapProjection,
|
|
10159
10420
|
getSystemNeighbors,
|
|
@@ -10184,6 +10445,7 @@ export {
|
|
|
10184
10445
|
topologyRevision,
|
|
10185
10446
|
transitionWorkItem,
|
|
10186
10447
|
updateIntegration,
|
|
10448
|
+
updateIntegrationFilters,
|
|
10187
10449
|
updateWorkItem,
|
|
10188
10450
|
validateSystemTopology,
|
|
10189
10451
|
validateTopologyProposal,
|