@eventcatalog/sdk 2.27.4 → 2.28.1

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/LICENSE CHANGED
@@ -22,7 +22,10 @@ SOFTWARE.
22
22
 
23
23
  ---
24
24
 
25
- Note: Source code within `packages/core/eventcatalog/src/enterprise/` is
26
- licensed under the EventCatalog Commercial License and is NOT covered by the
27
- MIT License above. See `packages/core/eventcatalog/src/enterprise/LICENSE`
28
- for the full terms.
25
+ Note: Source code within the following directories is licensed under the
26
+ EventCatalog Commercial License and is NOT covered by the MIT License above:
27
+
28
+ - `packages/core/eventcatalog/src/enterprise/`
29
+ - `packages/core/src/federation/`
30
+
31
+ See the `LICENSE` file in each directory for the full terms.
package/dist/index.d.mts CHANGED
@@ -439,10 +439,12 @@ interface UbiquitousLanguage {
439
439
  summary?: string;
440
440
  description?: string;
441
441
  icon?: string;
442
+ editUrl?: string;
442
443
  }
443
444
 
444
445
  interface UbiquitousLanguageDictionary {
445
446
  dictionary: UbiquitousLanguage[];
447
+ editUrl?: string;
446
448
  }
447
449
 
448
450
  interface DetailPanelProperty {
package/dist/index.d.ts CHANGED
@@ -439,10 +439,12 @@ interface UbiquitousLanguage {
439
439
  summary?: string;
440
440
  description?: string;
441
441
  icon?: string;
442
+ editUrl?: string;
442
443
  }
443
444
 
444
445
  interface UbiquitousLanguageDictionary {
445
446
  dictionary: UbiquitousLanguage[];
447
+ editUrl?: string;
446
448
  }
447
449
 
448
450
  interface DetailPanelProperty {
package/dist/index.js CHANGED
@@ -43,21 +43,37 @@ var import_node_path29 = require("path");
43
43
 
44
44
  // src/dsl/utils.ts
45
45
  var import_glob = require("glob");
46
+
47
+ // src/internal/versions.ts
46
48
  var import_semver = require("semver");
49
+ var NUMERIC_VERSION_PATTERN = /^[vV]?\d+(?:\.\d+){0,2}$/;
50
+ var toComparableVersion = (version) => {
51
+ const strictVersion = (0, import_semver.valid)(version);
52
+ if (strictVersion) return strictVersion;
53
+ if (!NUMERIC_VERSION_PATTERN.test(version)) return void 0;
54
+ return (0, import_semver.coerce)(version) ?? void 0;
55
+ };
56
+ var compareVersions = (left, right) => {
57
+ const leftVersion = toComparableVersion(left);
58
+ const rightVersion = toComparableVersion(right);
59
+ if (!leftVersion || !rightVersion) return void 0;
60
+ return (0, import_semver.compare)(leftVersion, rightVersion);
61
+ };
62
+ var isVersionGreaterThan = (candidate, current) => compareVersions(candidate, current) === 1;
63
+ var versionSatisfiesRange = (version, range) => {
64
+ const comparableVersion = toComparableVersion(version);
65
+ const comparableRange = (0, import_semver.validRange)(range) ?? (0, import_semver.validRange)(range.replace(/V(?=\d)/g, "v"));
66
+ if (!comparableVersion || !comparableRange) return false;
67
+ return (0, import_semver.satisfies)(comparableVersion, comparableRange);
68
+ };
69
+
70
+ // src/dsl/utils.ts
47
71
  function msgVersionMatches(pointerVersion, messageVersion) {
48
72
  if (!pointerVersion) return true;
49
73
  if (!messageVersion) return false;
50
74
  if (pointerVersion === messageVersion) return true;
51
- try {
52
- if ((0, import_semver.validRange)(pointerVersion)) {
53
- if ((0, import_semver.satisfies)(messageVersion, pointerVersion)) return true;
54
- }
55
- if ((0, import_semver.validRange)(messageVersion)) {
56
- if ((0, import_semver.satisfies)(pointerVersion, messageVersion)) return true;
57
- }
58
- } catch {
59
- }
60
- return false;
75
+ if (versionSatisfiesRange(messageVersion, pointerVersion)) return true;
76
+ return versionSatisfiesRange(pointerVersion, messageVersion);
61
77
  }
62
78
  function serializeBaseFields(resource, indent = " ") {
63
79
  const lines = [];
@@ -663,7 +679,6 @@ var import_node_fs = __toESM(require("fs"));
663
679
  var import_fs_extra = require("fs-extra");
664
680
  var import_node_path = require("path");
665
681
  var import_gray_matter = __toESM(require("gray-matter"));
666
- var import_semver3 = require("semver");
667
682
  var _fileIndexCache = null;
668
683
  var _fileIndexCatalogDir = null;
669
684
  var _matterCache = null;
@@ -795,18 +810,12 @@ var findFileById = async (catalogDir, id, version) => {
795
810
  }
796
811
  const exactMatch = entries.find((e) => e.version === version);
797
812
  if (exactMatch) return exactMatch.path;
798
- const semverRange = (0, import_semver3.validRange)(version);
799
- if (semverRange) {
800
- const match = entries.find((e) => {
801
- try {
802
- return (0, import_semver3.satisfies)(e.version, semverRange);
803
- } catch {
804
- return false;
805
- }
806
- });
807
- return match?.path;
813
+ let match;
814
+ for (const entry of entries) {
815
+ if (!versionSatisfiesRange(entry.version, version)) continue;
816
+ if (!match || isVersionGreaterThan(entry.version, match.version)) match = entry;
808
817
  }
809
- return void 0;
818
+ return match?.path;
810
819
  };
811
820
  var getFiles = async (pattern, ignore2 = "") => {
812
821
  try {
@@ -897,7 +906,6 @@ var import_path = require("path");
897
906
  var import_gray_matter2 = __toESM(require("gray-matter"));
898
907
  var import_promises = __toESM(require("fs/promises"));
899
908
  var import_node_fs2 = __toESM(require("fs"));
900
- var import_semver4 = require("semver");
901
909
  var import_proper_lockfile = require("proper-lockfile");
902
910
  var import_node_path2 = require("path");
903
911
  var import_node_path3 = __toESM(require("path"));
@@ -965,7 +973,7 @@ var writeResource = async (catalogDir, resource, options = {
965
973
  if (options.versionExistingContent && !exists) {
966
974
  const currentResource = await getResource(catalogDir, resource.id);
967
975
  if (currentResource) {
968
- if ((0, import_semver4.satisfies)(resource.version, `>${currentResource.version}`)) {
976
+ if (isVersionGreaterThan(resource.version, currentResource.version)) {
969
977
  await versionResource(catalogDir, resource.id);
970
978
  } else {
971
979
  throw new Error(`New version ${resource.version} is not greater than current version ${currentResource.version}`);
@@ -2047,7 +2055,6 @@ var addMessageToChannel = (directory, collection) => async (id, _message, versio
2047
2055
  var import_node_path12 = require("path");
2048
2056
  var import_node_fs4 = __toESM(require("fs"));
2049
2057
  var import_gray_matter4 = __toESM(require("gray-matter"));
2050
- var import_semver5 = require("semver");
2051
2058
  var getMessageBySchemaPath = (directory) => async (path11, options) => {
2052
2059
  const pathToMessage = (0, import_node_path12.dirname)(path11);
2053
2060
  try {
@@ -2088,34 +2095,17 @@ var getProducersAndConsumersForMessage = (directory) => async (id, version, opti
2088
2095
  const producers = [];
2089
2096
  const consumers = [];
2090
2097
  for (const participant of [...services, ...agents, ...domains]) {
2091
- const participantPublishesMessage = participant.sends?.some((_message) => {
2098
+ const matchesMessage = (_message) => {
2092
2099
  if (_message.version) {
2093
- const isParticipantUsingSemverRange = (0, import_semver5.validRange)(_message.version);
2094
- if (isParticipantUsingSemverRange) {
2095
- return _message.id === message.id && (0, import_semver5.satisfies)(message.version, _message.version);
2096
- } else {
2097
- return _message.id === message.id && message.version === _message.version;
2098
- }
2100
+ return _message.id === message.id && (message.version === _message.version || versionSatisfiesRange(message.version, _message.version));
2099
2101
  }
2100
2102
  if (isMessageLatestVersion && _message.id === message.id) {
2101
2103
  return true;
2102
2104
  }
2103
2105
  return false;
2104
- });
2105
- const participantSubscribesToMessage = participant.receives?.some((_message) => {
2106
- if (_message.version) {
2107
- const isParticipantUsingSemverRange = (0, import_semver5.validRange)(_message.version);
2108
- if (isParticipantUsingSemverRange) {
2109
- return _message.id === message.id && (0, import_semver5.satisfies)(message.version, _message.version);
2110
- } else {
2111
- return _message.id === message.id && message.version === _message.version;
2112
- }
2113
- }
2114
- if (isMessageLatestVersion && _message.id === message.id) {
2115
- return true;
2116
- }
2117
- return false;
2118
- });
2106
+ };
2107
+ const participantPublishesMessage = participant.sends?.some(matchesMessage);
2108
+ const participantSubscribesToMessage = participant.receives?.some(matchesMessage);
2119
2109
  if (participantPublishesMessage) {
2120
2110
  producers.push(participant);
2121
2111
  }
@@ -2481,9 +2471,6 @@ var dumpCatalog = (directory) => async (options) => {
2481
2471
  };
2482
2472
  };
2483
2473
 
2484
- // src/graph.ts
2485
- var import_semver6 = require("semver");
2486
-
2487
2474
  // src/adrs.ts
2488
2475
  var import_promises12 = __toESM(require("fs/promises"));
2489
2476
  var import_node_path19 = require("path");
@@ -3289,14 +3276,13 @@ var getGraph = (directory) => {
3289
3276
  const allVersionsIndex = await loadAllVersionsIndex(type);
3290
3277
  const exactMatch = allVersionsIndex.byVersion.get(`${pointer.id}:${pointer.version}`);
3291
3278
  if (exactMatch) return exactMatch;
3292
- const range = (0, import_semver6.validRange)(pointer.version);
3293
- if (!range) return void 0;
3294
3279
  const candidates = allVersionsIndex.byId.get(pointer.id) || [];
3295
- const version = (0, import_semver6.maxSatisfying)(
3296
- candidates.map((resource) => resource.version),
3297
- range
3298
- );
3299
- return candidates.find((resource) => resource.version === version);
3280
+ let match;
3281
+ for (const candidate of candidates) {
3282
+ if (!versionSatisfiesRange(candidate.version, pointer.version)) continue;
3283
+ if (!match || isVersionGreaterThan(candidate.version, match.version)) match = candidate;
3284
+ }
3285
+ return match;
3300
3286
  };
3301
3287
  const resolvePointer = async (pointer, candidateTypes) => {
3302
3288
  const explicitType = normalizeResourceType(pointer.type);
@@ -3338,8 +3324,7 @@ var getGraph = (directory) => {
3338
3324
  const pointerMatchesVersion = (pointer, version) => {
3339
3325
  if (!pointer.version || pointer.version === "latest") return true;
3340
3326
  if (pointer.version === version) return true;
3341
- const range = (0, import_semver6.validRange)(pointer.version);
3342
- return range ? (0, import_semver6.maxSatisfying)([version], range) === version : false;
3327
+ return versionSatisfiesRange(version, pointer.version);
3343
3328
  };
3344
3329
  const getAdrsForResource = async (type, resource) => {
3345
3330
  if (type === "adr") return [];
@@ -3477,7 +3462,6 @@ var import_node_fs9 = __toESM(require("fs"));
3477
3462
  var import_node_path24 = __toESM(require("path"));
3478
3463
  var import_node_crypto = require("crypto");
3479
3464
  var import_node_child_process = require("child_process");
3480
- var import_semver7 = require("semver");
3481
3465
 
3482
3466
  // src/snapshot-diff.ts
3483
3467
  var stableStringify = (value) => {
@@ -3671,11 +3655,16 @@ var pickCoreFields = (resource) => {
3671
3655
  if (resource.schemaHash) picked.schemaHash = resource.schemaHash;
3672
3656
  return picked;
3673
3657
  };
3658
+ var isNewerVersion = (candidate, current) => {
3659
+ const comparison = compareVersions(candidate, current);
3660
+ if (comparison !== void 0) return comparison > 0;
3661
+ return candidate.localeCompare(current) > 0;
3662
+ };
3674
3663
  var deduplicateByLatestVersion = (resources) => {
3675
3664
  const seen = /* @__PURE__ */ new Map();
3676
3665
  for (const r of resources) {
3677
3666
  const existing = seen.get(r.id);
3678
- if (!existing || (0, import_semver7.compare)(r.version, existing.version) > 0) {
3667
+ if (!existing || isNewerVersion(r.version, existing.version)) {
3679
3668
  seen.set(r.id, r);
3680
3669
  }
3681
3670
  }
@@ -3811,7 +3800,6 @@ var import_promises18 = __toESM(require("fs/promises"));
3811
3800
  var import_node_path26 = __toESM(require("path"));
3812
3801
  var import_gray_matter8 = __toESM(require("gray-matter"));
3813
3802
  var import_ignore = __toESM(require("ignore"));
3814
- var import_semver8 = require("semver");
3815
3803
 
3816
3804
  // src/diagrams.ts
3817
3805
  var import_promises17 = __toESM(require("fs/promises"));
@@ -3863,14 +3851,15 @@ var getFlowReferences = (steps) => steps.flatMap((step) => [
3863
3851
  ...step.flow ? [{ kind: "flow", ...step.flow }] : []
3864
3852
  ]);
3865
3853
  var compareText = (left, right) => left < right ? -1 : left > right ? 1 : 0;
3866
- var compareVersions = (left, right) => {
3854
+ var compareVersions2 = (left, right) => {
3867
3855
  if (left === right) return 0;
3868
3856
  if (left === void 0) return 1;
3869
3857
  if (right === void 0) return -1;
3870
- if ((0, import_semver8.valid)(left) && (0, import_semver8.valid)(right)) return (0, import_semver8.rcompare)(left, right);
3858
+ const comparison = compareVersions(left, right);
3859
+ if (comparison !== void 0) return -comparison;
3871
3860
  return compareText(right, left);
3872
3861
  };
3873
- var compareIndexResources = (left, right) => compareText(left.type, right.type) || compareText(left.id, right.id) || compareVersions(left.version, right.version);
3862
+ var compareIndexResources = (left, right) => compareText(left.type, right.type) || compareText(left.id, right.id) || compareVersions2(left.version, right.version);
3874
3863
  var toCatalogPath = (directory, filePath) => import_node_path26.default.relative(directory, filePath).split(import_node_path26.default.sep).join("/");
3875
3864
  var isFederatedPath = (directory, filePath) => toCatalogPath(directory, filePath).startsWith("federated/");
3876
3865
  var loadIgnoreRules = async (directory) => {
@@ -4232,12 +4221,12 @@ var rmChangelog = (catalogDir) => async (id, options = {}) => {
4232
4221
  };
4233
4222
 
4234
4223
  // src/resolve.ts
4235
- var import_semver9 = require("semver");
4236
4224
  var compareText2 = (left, right) => left < right ? -1 : left > right ? 1 : 0;
4237
4225
  var isHigherVersion = (candidate, current) => {
4238
4226
  if (candidate === current || candidate === void 0) return false;
4239
4227
  if (current === void 0) return true;
4240
- if ((0, import_semver9.valid)(candidate) && (0, import_semver9.valid)(current)) return (0, import_semver9.gt)(candidate, current);
4228
+ const comparison = compareVersions(candidate, current);
4229
+ if (comparison !== void 0) return comparison > 0;
4241
4230
  return compareText2(candidate, current) > 0;
4242
4231
  };
4243
4232
  var selectTarget = (candidates, pointerVersion) => {
@@ -4247,10 +4236,8 @@ var selectTarget = (candidates, pointerVersion) => {
4247
4236
  }
4248
4237
  const exactMatch = candidates.find((candidate) => candidate.version === pointerVersion);
4249
4238
  if (exactMatch) return exactMatch;
4250
- const range = (0, import_semver9.validRange)(pointerVersion);
4251
- if (!range) return void 0;
4252
4239
  return candidates.reduce((latest, candidate) => {
4253
- if (candidate.version === void 0 || !(0, import_semver9.valid)(candidate.version) || !(0, import_semver9.satisfies)(candidate.version, range)) return latest;
4240
+ if (candidate.version === void 0 || !versionSatisfiesRange(candidate.version, pointerVersion)) return latest;
4254
4241
  if (latest === void 0 || isHigherVersion(candidate.version, latest.version)) return candidate;
4255
4242
  return latest;
4256
4243
  }, void 0);