@kaddo/cli 3.81.0 → 3.83.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-xgxqXGxn.js"></script>
8
+ <script type="module" crossorigin src="/assets/index-CsOMxNTw.js"></script>
9
9
  <link rel="stylesheet" crossorigin href="/assets/index-DNkI-1xG.css">
10
10
  </head>
11
11
  <body>
@@ -70,6 +70,24 @@ import {
70
70
  buildRefinementHandoff as coreBuildRefinementHandoff,
71
71
  getSystemMapProjection as coreGetSystemMapProjection,
72
72
  buildTopologyEnrichmentHandoff as coreBuildTopologyHandoff,
73
+ listIntegrations as coreListIntegrations,
74
+ getIntegration as coreGetIntegration,
75
+ getIntegrationSecretStatus as coreGetIntegrationSecretStatus,
76
+ getAvailableIntegrationTypes as coreGetAvailableIntegrationTypes,
77
+ createIntegration as coreCreateIntegration,
78
+ updateIntegration as coreUpdateIntegration,
79
+ deleteIntegration as coreDeleteIntegration,
80
+ enableIntegration as coreEnableIntegration,
81
+ disableIntegration as coreDisableIntegration,
82
+ setIntegrationSecret as coreSetIntegrationSecret,
83
+ removeIntegrationSecret as coreRemoveIntegrationSecret,
84
+ verifyIntegration as coreVerifyIntegration,
85
+ listExternalWorkItems as coreListExternalWorkItems,
86
+ getExternalWorkItem as coreGetExternalWorkItem,
87
+ previewImport as corePreviewImport,
88
+ importExternalWorkItem as coreImportExternalWorkItem,
89
+ IntegrationError,
90
+ IntegrationServiceError,
73
91
  WorkItemWriteError,
74
92
  exists,
75
93
  join,
@@ -335,6 +353,124 @@ var CoreError = class extends Error {
335
353
  }
336
354
  code;
337
355
  };
356
+ function mapIntegrationError(err) {
357
+ if (err instanceof IntegrationError) throw new CoreError(err.code, err.safeMessage);
358
+ if (err instanceof IntegrationServiceError) throw new CoreError(err.code, err.message);
359
+ throw err;
360
+ }
361
+ function assertExternalId(externalId) {
362
+ if (!externalId || externalId.includes("/") || externalId.includes("\\") || externalId.includes("..")) {
363
+ throw new CoreError("INVALID_EXTERNAL_ID", "Invalid external work item identifier.");
364
+ }
365
+ }
366
+ function getIntegrations(dir) {
367
+ return coreListIntegrations(dir);
368
+ }
369
+ async function getIntegrationStatus(dir, id) {
370
+ try {
371
+ return await coreVerifyIntegration(dir, id);
372
+ } catch (err) {
373
+ mapIntegrationError(err);
374
+ }
375
+ }
376
+ async function getExternalWorkItems(dir, id, opts) {
377
+ try {
378
+ return await coreListExternalWorkItems(dir, id, { cursor: opts.cursor, pageSize: opts.pageSize, filters: { status: opts.status, query: opts.query } });
379
+ } catch (err) {
380
+ mapIntegrationError(err);
381
+ }
382
+ }
383
+ async function getExternalWorkItemDetail(dir, id, externalId) {
384
+ assertExternalId(externalId);
385
+ try {
386
+ return await coreGetExternalWorkItem(dir, id, externalId);
387
+ } catch (err) {
388
+ mapIntegrationError(err);
389
+ }
390
+ }
391
+ async function previewIntegrationImport(dir, id, externalId, opts) {
392
+ assertExternalId(externalId);
393
+ try {
394
+ return await corePreviewImport(dir, id, externalId, { type: opts.type });
395
+ } catch (err) {
396
+ mapIntegrationError(err);
397
+ }
398
+ }
399
+ async function importIntegrationWorkItem(dir, id, externalId, opts) {
400
+ assertExternalId(externalId);
401
+ try {
402
+ return await coreImportExternalWorkItem(dir, id, externalId, { type: opts.type });
403
+ } catch (err) {
404
+ if (err instanceof WorkItemWriteError) throw new CoreError(err.code, err.message);
405
+ mapIntegrationError(err);
406
+ }
407
+ }
408
+ function getIntegrationDetail(dir, id) {
409
+ try {
410
+ return coreGetIntegration(dir, id);
411
+ } catch (err) {
412
+ mapIntegrationError(err);
413
+ }
414
+ }
415
+ async function getIntegrationSecretStatusAdmin(dir, id) {
416
+ try {
417
+ return await coreGetIntegrationSecretStatus(dir, id);
418
+ } catch (err) {
419
+ mapIntegrationError(err);
420
+ }
421
+ }
422
+ function getAvailableIntegrationTypesAdmin() {
423
+ return coreGetAvailableIntegrationTypes();
424
+ }
425
+ function createIntegrationAdmin(dir, body) {
426
+ try {
427
+ return coreCreateIntegration(dir, body);
428
+ } catch (err) {
429
+ mapIntegrationError(err);
430
+ }
431
+ }
432
+ function updateIntegrationAdmin(dir, id, body) {
433
+ try {
434
+ return coreUpdateIntegration(dir, id, body);
435
+ } catch (err) {
436
+ mapIntegrationError(err);
437
+ }
438
+ }
439
+ function deleteIntegrationAdmin(dir, id) {
440
+ try {
441
+ coreDeleteIntegration(dir, id);
442
+ } catch (err) {
443
+ mapIntegrationError(err);
444
+ }
445
+ }
446
+ function enableIntegrationAdmin(dir, id) {
447
+ try {
448
+ return coreEnableIntegration(dir, id);
449
+ } catch (err) {
450
+ mapIntegrationError(err);
451
+ }
452
+ }
453
+ function disableIntegrationAdmin(dir, id) {
454
+ try {
455
+ return coreDisableIntegration(dir, id);
456
+ } catch (err) {
457
+ mapIntegrationError(err);
458
+ }
459
+ }
460
+ async function setIntegrationSecretAdmin(dir, id, secretName, value) {
461
+ try {
462
+ await coreSetIntegrationSecret(dir, id, secretName, value);
463
+ } catch (err) {
464
+ mapIntegrationError(err);
465
+ }
466
+ }
467
+ async function removeIntegrationSecretAdmin(dir, id, secretName) {
468
+ try {
469
+ await coreRemoveIntegrationSecret(dir, id, secretName);
470
+ } catch (err) {
471
+ mapIntegrationError(err);
472
+ }
473
+ }
338
474
 
339
475
  // src/contracts/schemas.ts
340
476
  import { z } from "zod";
@@ -827,6 +963,104 @@ async function createAdminServer(opts) {
827
963
  app.get("/api/v1/admin/findings", coreRoute(getFindings));
828
964
  app.get("/api/v1/admin/system", coreRoute(getSystemMap));
829
965
  app.get("/api/v1/admin/system/topology-handoff", coreRoute(getTopologyHandoff));
966
+ const asyncCore = async (reply, fn) => {
967
+ try {
968
+ return await fn();
969
+ } catch (err) {
970
+ if (err instanceof CoreError) return reply.code(statusForCode(err.code)).send({ error: { code: err.code, message: err.message } });
971
+ throw err;
972
+ }
973
+ };
974
+ app.get("/api/v1/admin/integrations", coreRoute(getIntegrations));
975
+ app.get("/api/v1/admin/integrations/types", coreRoute(() => getAvailableIntegrationTypesAdmin()));
976
+ app.get("/api/v1/admin/integrations/:id", async (request, reply) => {
977
+ try {
978
+ return getIntegrationDetail(projectDir, request.params.id);
979
+ } catch (err) {
980
+ if (err instanceof CoreError) return reply.code(statusForCode(err.code)).send({ error: { code: err.code, message: err.message } });
981
+ throw err;
982
+ }
983
+ });
984
+ app.get(
985
+ "/api/v1/admin/integrations/:id/secrets",
986
+ async (request, reply) => asyncCore(reply, () => getIntegrationSecretStatusAdmin(projectDir, request.params.id))
987
+ );
988
+ app.get(
989
+ "/api/v1/admin/integrations/:id/status",
990
+ async (request, reply) => asyncCore(reply, () => getIntegrationStatus(projectDir, request.params.id))
991
+ );
992
+ app.post(
993
+ "/api/v1/admin/integrations",
994
+ async (request, reply) => {
995
+ const { id, adapter, enabled, config, secrets } = request.body ?? {};
996
+ if (!id || !adapter) return reply.code(400).send({ error: { code: "INVALID_INPUT", message: "id and adapter are required." } });
997
+ return writeHandler(reply, () => createIntegrationAdmin(projectDir, { id, adapter, enabled, config, secrets }));
998
+ }
999
+ );
1000
+ app.put(
1001
+ "/api/v1/admin/integrations/:id",
1002
+ async (request, reply) => writeHandler(reply, () => updateIntegrationAdmin(projectDir, request.params.id, request.body ?? {}))
1003
+ );
1004
+ app.delete("/api/v1/admin/integrations/:id", async (request, reply) => {
1005
+ try {
1006
+ deleteIntegrationAdmin(projectDir, request.params.id);
1007
+ return { ok: true };
1008
+ } catch (err) {
1009
+ if (err instanceof CoreError) return reply.code(statusForCode(err.code)).send({ error: { code: err.code, message: err.message } });
1010
+ throw err;
1011
+ }
1012
+ });
1013
+ app.post(
1014
+ "/api/v1/admin/integrations/:id/enable",
1015
+ async (request, reply) => writeHandler(reply, () => enableIntegrationAdmin(projectDir, request.params.id))
1016
+ );
1017
+ app.post(
1018
+ "/api/v1/admin/integrations/:id/disable",
1019
+ async (request, reply) => writeHandler(reply, () => disableIntegrationAdmin(projectDir, request.params.id))
1020
+ );
1021
+ app.post(
1022
+ "/api/v1/admin/integrations/:id/secrets/:name",
1023
+ async (request, reply) => {
1024
+ const { value } = request.body ?? {};
1025
+ if (!value || typeof value !== "string") return reply.code(400).send({ error: { code: "INVALID_INPUT", message: "A secret value is required." } });
1026
+ return asyncCore(reply, async () => {
1027
+ await setIntegrationSecretAdmin(projectDir, request.params.id, request.params.name, value);
1028
+ return { ok: true };
1029
+ });
1030
+ }
1031
+ );
1032
+ app.delete(
1033
+ "/api/v1/admin/integrations/:id/secrets/:name",
1034
+ async (request, reply) => asyncCore(reply, async () => {
1035
+ await removeIntegrationSecretAdmin(projectDir, request.params.id, request.params.name);
1036
+ return { ok: true };
1037
+ })
1038
+ );
1039
+ app.get(
1040
+ "/api/v1/admin/integrations/:id/work-items",
1041
+ async (request, reply) => asyncCore(reply, () => getExternalWorkItems(projectDir, request.params.id, {
1042
+ cursor: request.query.cursor,
1043
+ pageSize: request.query.pageSize ? Number.parseInt(request.query.pageSize, 10) : void 0,
1044
+ status: request.query.status,
1045
+ query: request.query.query
1046
+ }))
1047
+ );
1048
+ app.get(
1049
+ "/api/v1/admin/integrations/:id/work-items/:externalId",
1050
+ async (request, reply) => asyncCore(reply, () => getExternalWorkItemDetail(projectDir, request.params.id, request.params.externalId))
1051
+ );
1052
+ app.get(
1053
+ "/api/v1/admin/integrations/:id/work-items/:externalId/import-preview",
1054
+ async (request, reply) => asyncCore(reply, () => previewIntegrationImport(projectDir, request.params.id, request.params.externalId, { type: request.query.type }))
1055
+ );
1056
+ app.post(
1057
+ "/api/v1/admin/integrations/:id/work-items/:externalId/import",
1058
+ async (request, reply) => {
1059
+ const type = request.body?.type;
1060
+ if (!type) return reply.code(400).send({ error: { code: "INVALID_INPUT", message: "A Kaddo Work Item type is required to import." } });
1061
+ return asyncCore(reply, () => importIntegrationWorkItem(projectDir, request.params.id, request.params.externalId, { type }));
1062
+ }
1063
+ );
830
1064
  app.get("/api/v1/admin/knowledge/inventory", coreRoute(getKnowledgeInventory));
831
1065
  app.get("/api/v1/admin/knowledge/artifact/:artifactId", async (request) => {
832
1066
  try {