@likec4/leanix-bridge 1.55.1 → 1.56.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.
- package/dist/index.mjs +36 -4
- package/package.json +4 -4
package/dist/index.mjs
CHANGED
|
@@ -1,6 +1,7 @@
|
|
|
1
1
|
import { readFileSync } from "node:fs";
|
|
2
2
|
import { dirname, join } from "node:path";
|
|
3
3
|
import { fileURLToPath } from "node:url";
|
|
4
|
+
//#region src/contracts.ts
|
|
4
5
|
/**
|
|
5
6
|
* Canonical bridge contracts for LikeC4 ↔ LeanIX interoperability.
|
|
6
7
|
* LikeC4 remains the semantic source of truth; external IDs are provider-scoped.
|
|
@@ -31,6 +32,8 @@ const BRIDGE_VERSION = readVersion();
|
|
|
31
32
|
const BRIDGE_MANIFEST_VERSION = "1.0";
|
|
32
33
|
/** Provider identifier for LeanIX (single source of truth for external.leanix). */
|
|
33
34
|
const LEANIX_PROVIDER = "leanix";
|
|
35
|
+
//#endregion
|
|
36
|
+
//#region src/mapping.ts
|
|
34
37
|
/** Fallback when element kind is unknown (G25: named constant). */
|
|
35
38
|
const FALLBACK_FACT_SHEET_TYPE = "Application";
|
|
36
39
|
/** Fallback when relation kind is unknown (G25: named constant). */
|
|
@@ -106,7 +109,7 @@ function mergeWithDefault(partial) {
|
|
|
106
109
|
* Uses mapping.factSheetTypes[kind], then 'default', then FALLBACK_FACT_SHEET_TYPE.
|
|
107
110
|
*/
|
|
108
111
|
function getFactSheetType(likec4Kind, mapping) {
|
|
109
|
-
return mapping.factSheetTypes[likec4Kind] ?? mapping.factSheetTypes["default"] ??
|
|
112
|
+
return mapping.factSheetTypes[likec4Kind] ?? mapping.factSheetTypes["default"] ?? "Application";
|
|
110
113
|
}
|
|
111
114
|
/**
|
|
112
115
|
* Returns LeanIX relation type for a LikeC4 relationship kind.
|
|
@@ -114,10 +117,12 @@ function getFactSheetType(likec4Kind, mapping) {
|
|
|
114
117
|
*/
|
|
115
118
|
function getRelationType(likec4Kind, mapping) {
|
|
116
119
|
const kind = likec4Kind ?? "default";
|
|
117
|
-
return mapping.relationTypes[kind] ?? mapping.relationTypes["default"] ??
|
|
120
|
+
return mapping.relationTypes[kind] ?? mapping.relationTypes["default"] ?? "depends on";
|
|
118
121
|
}
|
|
122
|
+
//#endregion
|
|
123
|
+
//#region src/to-bridge-manifest.ts
|
|
119
124
|
const defaultOptions = {
|
|
120
|
-
manifestVersion:
|
|
125
|
+
manifestVersion: "1.0",
|
|
121
126
|
bridgeVersion: BRIDGE_VERSION,
|
|
122
127
|
mappingProfile: "default"
|
|
123
128
|
};
|
|
@@ -172,6 +177,8 @@ function toBridgeManifest(model, options = {}) {
|
|
|
172
177
|
relations: buildManifestRelations(model)
|
|
173
178
|
};
|
|
174
179
|
}
|
|
180
|
+
//#endregion
|
|
181
|
+
//#region src/to-leanix-inventory-dry-run.ts
|
|
175
182
|
/** Builds LeanIX fact sheet dry-run list from model elements and mapping. */
|
|
176
183
|
function buildFactSheetsFromModel(model, mapping) {
|
|
177
184
|
const factSheets = [];
|
|
@@ -225,6 +232,8 @@ function toLeanixInventoryDryRun(model, options = {}) {
|
|
|
225
232
|
relations: buildRelationsFromModel(model, mapping)
|
|
226
233
|
};
|
|
227
234
|
}
|
|
235
|
+
//#endregion
|
|
236
|
+
//#region src/report.ts
|
|
228
237
|
/** Builds error message listing which coherence fields mismatched (projectId, mappingProfile). */
|
|
229
238
|
function buildCoherenceErrorMessage(manifest, leanixDryRun) {
|
|
230
239
|
const mismatches = [];
|
|
@@ -256,6 +265,8 @@ function buildBridgeReport(manifest, leanixDryRun) {
|
|
|
256
265
|
}
|
|
257
266
|
};
|
|
258
267
|
}
|
|
268
|
+
//#endregion
|
|
269
|
+
//#region src/leanix-api-client.ts
|
|
259
270
|
const DEFAULT_BASE_URL = "https://app.leanix.net";
|
|
260
271
|
const DEFAULT_DELAY_MS = 200;
|
|
261
272
|
/** Thrown when the LeanIX API returns errors or non-OK HTTP. */
|
|
@@ -338,6 +349,8 @@ var LeanixApiClient = class {
|
|
|
338
349
|
}
|
|
339
350
|
}
|
|
340
351
|
};
|
|
352
|
+
//#endregion
|
|
353
|
+
//#region src/leanix-graphql-operations.ts
|
|
341
354
|
/** Search fact sheets by name and type (for idempotency). Returns null when not found; throws on API/network error. */
|
|
342
355
|
async function findFactSheetByNameAndType(client, name, type) {
|
|
343
356
|
const edges = (await client.graphql(`
|
|
@@ -448,6 +461,8 @@ async function createRelation(client, sourceFactSheetId, targetFactSheetId, rela
|
|
|
448
461
|
}
|
|
449
462
|
return id;
|
|
450
463
|
}
|
|
464
|
+
//#endregion
|
|
465
|
+
//#region src/sync-to-leanix.ts
|
|
451
466
|
/**
|
|
452
467
|
* Sync bridge manifest + LeanIX dry-run inventory to the LeanIX API.
|
|
453
468
|
* Creates or updates fact sheets and relations; returns manifest with external LeanIX IDs.
|
|
@@ -635,6 +650,8 @@ async function syncToLeanix(manifest, leanixDryRun, client, options = {}) {
|
|
|
635
650
|
errors: [...fsResult.errors, ...relResult.errors]
|
|
636
651
|
};
|
|
637
652
|
}
|
|
653
|
+
//#endregion
|
|
654
|
+
//#region src/drawio-leanix-roundtrip.ts
|
|
638
655
|
/**
|
|
639
656
|
* Draw.io ↔ LeanIX round-trip: mapping between bridge manifest (with LeanIX external IDs)
|
|
640
657
|
* and diagram identity (likec4Id, likec4RelationId).
|
|
@@ -647,7 +664,7 @@ async function syncToLeanix(manifest, leanixDryRun, client, options = {}) {
|
|
|
647
664
|
function collectLikec4IdToLeanixId(manifest) {
|
|
648
665
|
const out = {};
|
|
649
666
|
for (const [canonicalId, entity] of Object.entries(manifest.entities)) {
|
|
650
|
-
const leanixId = entity.external?.[
|
|
667
|
+
const leanixId = entity.external?.["leanix"]?.factSheetId ?? entity.external?.["leanix"]?.externalId;
|
|
651
668
|
if (leanixId) out[canonicalId] = leanixId;
|
|
652
669
|
}
|
|
653
670
|
return out;
|
|
@@ -674,6 +691,8 @@ function manifestToDrawioLeanixMapping(manifest) {
|
|
|
674
691
|
relationKeyToLeanixRelationId: collectRelationKeyToLeanixRelationId(manifest)
|
|
675
692
|
};
|
|
676
693
|
}
|
|
694
|
+
//#endregion
|
|
695
|
+
//#region src/leanix-inventory-snapshot.ts
|
|
677
696
|
const DEFAULT_PAGE_SIZE = 100;
|
|
678
697
|
const DEFAULT_MAX_FACT_SHEETS = 1e3;
|
|
679
698
|
const MAX_GRAPHQL_RETRIES = 3;
|
|
@@ -819,6 +838,8 @@ async function fetchAllRelations(client, factSheetIds) {
|
|
|
819
838
|
}
|
|
820
839
|
return relations;
|
|
821
840
|
}
|
|
841
|
+
//#endregion
|
|
842
|
+
//#region src/reconcile.ts
|
|
822
843
|
/**
|
|
823
844
|
* Reconciliation of LeanIX inventory snapshot with LikeC4 manifest.
|
|
824
845
|
* Produces matched, unmatched (in LikeC4 only / in LeanIX only), and ambiguous pairs.
|
|
@@ -937,6 +958,8 @@ function reconcileInventoryWithManifest(snapshot, manifest, options = {}) {
|
|
|
937
958
|
}
|
|
938
959
|
};
|
|
939
960
|
}
|
|
961
|
+
//#endregion
|
|
962
|
+
//#region src/impact-report.ts
|
|
940
963
|
/**
|
|
941
964
|
* Builds an impact report from a sync plan (read-only).
|
|
942
965
|
* Use before applying sync to understand what would be created/updated.
|
|
@@ -957,6 +980,8 @@ function impactReportFromSyncPlan(plan) {
|
|
|
957
980
|
hasErrors: errors.length > 0
|
|
958
981
|
};
|
|
959
982
|
}
|
|
983
|
+
//#endregion
|
|
984
|
+
//#region src/drift-report.ts
|
|
960
985
|
/**
|
|
961
986
|
* Builds a drift report from a reconciliation result.
|
|
962
987
|
* In_sync: all matched, no unmatched, no ambiguous. Likec4_ahead: only unmatched in LikeC4. Leanix_ahead: only unmatched in LeanIX. Diverged: mixed or ambiguous.
|
|
@@ -994,6 +1019,8 @@ function buildDriftReport(reconciliation) {
|
|
|
994
1019
|
description
|
|
995
1020
|
};
|
|
996
1021
|
}
|
|
1022
|
+
//#endregion
|
|
1023
|
+
//#region src/adr-generation.ts
|
|
997
1024
|
/** Returns date part YYYY-MM-DD from ISO timestamp (G25, G5). Handles short strings defensively. */
|
|
998
1025
|
function formatIsoDateString(iso) {
|
|
999
1026
|
if (typeof iso !== "string" || iso.length < 10) return iso;
|
|
@@ -1058,6 +1085,8 @@ function generateAdrFromDriftReport(drift, options = {}) {
|
|
|
1058
1085
|
""
|
|
1059
1086
|
].join("\n");
|
|
1060
1087
|
}
|
|
1088
|
+
//#endregion
|
|
1089
|
+
//#region src/governance-checks.ts
|
|
1061
1090
|
const DEFAULT_OPTIONS = {
|
|
1062
1091
|
noAmbiguous: true,
|
|
1063
1092
|
allLikec4Matched: false,
|
|
@@ -1093,6 +1122,8 @@ function runGovernanceChecks(reconciliation, options = {}) {
|
|
|
1093
1122
|
checks
|
|
1094
1123
|
};
|
|
1095
1124
|
}
|
|
1125
|
+
//#endregion
|
|
1126
|
+
//#region src/validate.ts
|
|
1096
1127
|
function isRecord(value) {
|
|
1097
1128
|
return typeof value === "object" && value !== null;
|
|
1098
1129
|
}
|
|
@@ -1148,4 +1179,5 @@ function isLeanixInventorySnapshot(obj) {
|
|
|
1148
1179
|
for (const rel of obj["relations"]) if (!isLeanixRelationSnapshotItem(rel)) return false;
|
|
1149
1180
|
return true;
|
|
1150
1181
|
}
|
|
1182
|
+
//#endregion
|
|
1151
1183
|
export { BRIDGE_MANIFEST_VERSION, BRIDGE_VERSION, DEFAULT_LEANIX_MAPPING, FALLBACK_FACT_SHEET_TYPE, FALLBACK_RELATION_TYPE, LEANIX_PROVIDER, LeanixApiClient, LeanixApiError, buildBridgeReport, buildDriftReport, fetchLeanixInventorySnapshot, generateAdrFromDriftReport, generateAdrFromReconciliation, getFactSheetType, getRelationType, impactReportFromSyncPlan, isBridgeManifest, isLeanixInventorySnapshot, manifestToDrawioLeanixMapping, mergeWithDefault, parseLeanixMappingInput, planSyncToLeanix, reconcileInventoryWithManifest, runGovernanceChecks, syncToLeanix, toBridgeManifest, toLeanixInventoryDryRun };
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@likec4/leanix-bridge",
|
|
3
|
-
"version": "1.
|
|
3
|
+
"version": "1.56.0",
|
|
4
4
|
"license": "MIT",
|
|
5
5
|
"bugs": "https://github.com/likec4/likec4/issues",
|
|
6
6
|
"homepage": "https://likec4.dev",
|
|
@@ -38,14 +38,14 @@
|
|
|
38
38
|
},
|
|
39
39
|
"dependencies": {
|
|
40
40
|
"remeda": "^2.33.7",
|
|
41
|
-
"@likec4/core": "1.
|
|
41
|
+
"@likec4/core": "1.56.0"
|
|
42
42
|
},
|
|
43
43
|
"devDependencies": {
|
|
44
|
-
"@types/node": "~22.19.
|
|
44
|
+
"@types/node": "~22.19.17",
|
|
45
45
|
"typescript": "5.9.3",
|
|
46
46
|
"obuild": "0.4.31",
|
|
47
47
|
"vitest": "4.1.3",
|
|
48
|
-
"@likec4/tsconfig": "1.
|
|
48
|
+
"@likec4/tsconfig": "1.56.0",
|
|
49
49
|
"@likec4/devops": "1.42.0"
|
|
50
50
|
},
|
|
51
51
|
"scripts": {
|