@eventcatalog/sdk 2.17.4 → 2.18.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/dist/index.d.mts CHANGED
@@ -54,12 +54,14 @@ type ResourcePointer = {
54
54
  type SendsPointer = {
55
55
  id: string;
56
56
  version?: string;
57
+ fields?: string[];
57
58
  to?: ChannelPointer[];
58
59
  };
59
60
 
60
61
  type ReceivesPointer = {
61
62
  id: string;
62
63
  version?: string;
64
+ fields?: string[];
63
65
  from?: ChannelPointer[];
64
66
  };
65
67
 
@@ -103,6 +105,9 @@ interface MessageDetailsPanelProperty {
103
105
  channels?: DetailPanelProperty;
104
106
  versions?: DetailPanelProperty;
105
107
  repository?: DetailPanelProperty;
108
+ owners?: DetailPanelProperty;
109
+ changelog?: DetailPanelProperty;
110
+ attachments?: DetailPanelProperty;
106
111
  }
107
112
 
108
113
  interface Event extends BaseSchema {
@@ -1047,6 +1052,12 @@ declare const _default: (path: string) => {
1047
1052
  addEventToService: (id: string, direction: string, event: {
1048
1053
  id: string;
1049
1054
  version: string;
1055
+ fields? /**
1056
+ * Remove an channel to EventCatalog (modeled on the standard POSIX rm utility)
1057
+ *
1058
+ * @param path - The path to your channel, e.g. `/Inventory/InventoryAdjusted`
1059
+ *
1060
+ */: string[];
1050
1061
  }, version?: string) => Promise<void>;
1051
1062
  /**
1052
1063
  * Add a data store to a service by it's id.
@@ -1090,6 +1101,12 @@ declare const _default: (path: string) => {
1090
1101
  addCommandToService: (id: string, direction: string, event: {
1091
1102
  id: string;
1092
1103
  version: string;
1104
+ fields? /**
1105
+ * Remove an channel to EventCatalog (modeled on the standard POSIX rm utility)
1106
+ *
1107
+ * @param path - The path to your channel, e.g. `/Inventory/InventoryAdjusted`
1108
+ *
1109
+ */: string[];
1093
1110
  }, version?: string) => Promise<void>;
1094
1111
  /**
1095
1112
  * Add a query to a service by it's id.
@@ -1113,6 +1130,12 @@ declare const _default: (path: string) => {
1113
1130
  addQueryToService: (id: string, direction: string, event: {
1114
1131
  id: string;
1115
1132
  version: string;
1133
+ fields? /**
1134
+ * Remove an channel to EventCatalog (modeled on the standard POSIX rm utility)
1135
+ *
1136
+ * @param path - The path to your channel, e.g. `/Inventory/InventoryAdjusted`
1137
+ *
1138
+ */: string[];
1116
1139
  }, version?: string) => Promise<void>;
1117
1140
  /**
1118
1141
  * Add an entity to a service by its id.
@@ -1297,6 +1320,25 @@ declare const _default: (path: string) => {
1297
1320
  addEventToDomain: (id: string, direction: string, message: {
1298
1321
  id: string;
1299
1322
  version: string;
1323
+ fields? /**
1324
+ * Add an event to a service by it's id.
1325
+ *
1326
+ * Optionally specify a version to add the event to a specific version of the service.
1327
+ *
1328
+ * @example
1329
+ * ```ts
1330
+ * import utils from '@eventcatalog/utils';
1331
+ *
1332
+ * const { addEventToService } = utils('/path/to/eventcatalog');
1333
+ *
1334
+ * // adds a new event (InventoryUpdatedEvent) that the InventoryService will send
1335
+ * await addEventToService('InventoryService', 'sends', { event: 'InventoryUpdatedEvent', version: '2.0.0' });
1336
+ *
1337
+ * // adds a new event (OrderComplete) that the InventoryService will receive
1338
+ * await addEventToService('InventoryService', 'receives', { event: 'OrderComplete', version: '2.0.0' });
1339
+ *
1340
+ * ```
1341
+ */: string[];
1300
1342
  }, version?: string) => Promise<void>;
1301
1343
  /**
1302
1344
  * Add a command to a domain by its id.
@@ -1318,6 +1360,25 @@ declare const _default: (path: string) => {
1318
1360
  addCommandToDomain: (id: string, direction: string, message: {
1319
1361
  id: string;
1320
1362
  version: string;
1363
+ fields? /**
1364
+ * Add an event to a service by it's id.
1365
+ *
1366
+ * Optionally specify a version to add the event to a specific version of the service.
1367
+ *
1368
+ * @example
1369
+ * ```ts
1370
+ * import utils from '@eventcatalog/utils';
1371
+ *
1372
+ * const { addEventToService } = utils('/path/to/eventcatalog');
1373
+ *
1374
+ * // adds a new event (InventoryUpdatedEvent) that the InventoryService will send
1375
+ * await addEventToService('InventoryService', 'sends', { event: 'InventoryUpdatedEvent', version: '2.0.0' });
1376
+ *
1377
+ * // adds a new event (OrderComplete) that the InventoryService will receive
1378
+ * await addEventToService('InventoryService', 'receives', { event: 'OrderComplete', version: '2.0.0' });
1379
+ *
1380
+ * ```
1381
+ */: string[];
1321
1382
  }, version?: string) => Promise<void>;
1322
1383
  /**
1323
1384
  * Add a query to a domain by its id.
@@ -1339,6 +1400,25 @@ declare const _default: (path: string) => {
1339
1400
  addQueryToDomain: (id: string, direction: string, message: {
1340
1401
  id: string;
1341
1402
  version: string;
1403
+ fields? /**
1404
+ * Add an event to a service by it's id.
1405
+ *
1406
+ * Optionally specify a version to add the event to a specific version of the service.
1407
+ *
1408
+ * @example
1409
+ * ```ts
1410
+ * import utils from '@eventcatalog/utils';
1411
+ *
1412
+ * const { addEventToService } = utils('/path/to/eventcatalog');
1413
+ *
1414
+ * // adds a new event (InventoryUpdatedEvent) that the InventoryService will send
1415
+ * await addEventToService('InventoryService', 'sends', { event: 'InventoryUpdatedEvent', version: '2.0.0' });
1416
+ *
1417
+ * // adds a new event (OrderComplete) that the InventoryService will receive
1418
+ * await addEventToService('InventoryService', 'receives', { event: 'OrderComplete', version: '2.0.0' });
1419
+ *
1420
+ * ```
1421
+ */: string[];
1342
1422
  }, version?: string) => Promise<void>;
1343
1423
  /**
1344
1424
  * ================================
package/dist/index.d.ts CHANGED
@@ -54,12 +54,14 @@ type ResourcePointer = {
54
54
  type SendsPointer = {
55
55
  id: string;
56
56
  version?: string;
57
+ fields?: string[];
57
58
  to?: ChannelPointer[];
58
59
  };
59
60
 
60
61
  type ReceivesPointer = {
61
62
  id: string;
62
63
  version?: string;
64
+ fields?: string[];
63
65
  from?: ChannelPointer[];
64
66
  };
65
67
 
@@ -103,6 +105,9 @@ interface MessageDetailsPanelProperty {
103
105
  channels?: DetailPanelProperty;
104
106
  versions?: DetailPanelProperty;
105
107
  repository?: DetailPanelProperty;
108
+ owners?: DetailPanelProperty;
109
+ changelog?: DetailPanelProperty;
110
+ attachments?: DetailPanelProperty;
106
111
  }
107
112
 
108
113
  interface Event extends BaseSchema {
@@ -1047,6 +1052,12 @@ declare const _default: (path: string) => {
1047
1052
  addEventToService: (id: string, direction: string, event: {
1048
1053
  id: string;
1049
1054
  version: string;
1055
+ fields? /**
1056
+ * Remove an channel to EventCatalog (modeled on the standard POSIX rm utility)
1057
+ *
1058
+ * @param path - The path to your channel, e.g. `/Inventory/InventoryAdjusted`
1059
+ *
1060
+ */: string[];
1050
1061
  }, version?: string) => Promise<void>;
1051
1062
  /**
1052
1063
  * Add a data store to a service by it's id.
@@ -1090,6 +1101,12 @@ declare const _default: (path: string) => {
1090
1101
  addCommandToService: (id: string, direction: string, event: {
1091
1102
  id: string;
1092
1103
  version: string;
1104
+ fields? /**
1105
+ * Remove an channel to EventCatalog (modeled on the standard POSIX rm utility)
1106
+ *
1107
+ * @param path - The path to your channel, e.g. `/Inventory/InventoryAdjusted`
1108
+ *
1109
+ */: string[];
1093
1110
  }, version?: string) => Promise<void>;
1094
1111
  /**
1095
1112
  * Add a query to a service by it's id.
@@ -1113,6 +1130,12 @@ declare const _default: (path: string) => {
1113
1130
  addQueryToService: (id: string, direction: string, event: {
1114
1131
  id: string;
1115
1132
  version: string;
1133
+ fields? /**
1134
+ * Remove an channel to EventCatalog (modeled on the standard POSIX rm utility)
1135
+ *
1136
+ * @param path - The path to your channel, e.g. `/Inventory/InventoryAdjusted`
1137
+ *
1138
+ */: string[];
1116
1139
  }, version?: string) => Promise<void>;
1117
1140
  /**
1118
1141
  * Add an entity to a service by its id.
@@ -1297,6 +1320,25 @@ declare const _default: (path: string) => {
1297
1320
  addEventToDomain: (id: string, direction: string, message: {
1298
1321
  id: string;
1299
1322
  version: string;
1323
+ fields? /**
1324
+ * Add an event to a service by it's id.
1325
+ *
1326
+ * Optionally specify a version to add the event to a specific version of the service.
1327
+ *
1328
+ * @example
1329
+ * ```ts
1330
+ * import utils from '@eventcatalog/utils';
1331
+ *
1332
+ * const { addEventToService } = utils('/path/to/eventcatalog');
1333
+ *
1334
+ * // adds a new event (InventoryUpdatedEvent) that the InventoryService will send
1335
+ * await addEventToService('InventoryService', 'sends', { event: 'InventoryUpdatedEvent', version: '2.0.0' });
1336
+ *
1337
+ * // adds a new event (OrderComplete) that the InventoryService will receive
1338
+ * await addEventToService('InventoryService', 'receives', { event: 'OrderComplete', version: '2.0.0' });
1339
+ *
1340
+ * ```
1341
+ */: string[];
1300
1342
  }, version?: string) => Promise<void>;
1301
1343
  /**
1302
1344
  * Add a command to a domain by its id.
@@ -1318,6 +1360,25 @@ declare const _default: (path: string) => {
1318
1360
  addCommandToDomain: (id: string, direction: string, message: {
1319
1361
  id: string;
1320
1362
  version: string;
1363
+ fields? /**
1364
+ * Add an event to a service by it's id.
1365
+ *
1366
+ * Optionally specify a version to add the event to a specific version of the service.
1367
+ *
1368
+ * @example
1369
+ * ```ts
1370
+ * import utils from '@eventcatalog/utils';
1371
+ *
1372
+ * const { addEventToService } = utils('/path/to/eventcatalog');
1373
+ *
1374
+ * // adds a new event (InventoryUpdatedEvent) that the InventoryService will send
1375
+ * await addEventToService('InventoryService', 'sends', { event: 'InventoryUpdatedEvent', version: '2.0.0' });
1376
+ *
1377
+ * // adds a new event (OrderComplete) that the InventoryService will receive
1378
+ * await addEventToService('InventoryService', 'receives', { event: 'OrderComplete', version: '2.0.0' });
1379
+ *
1380
+ * ```
1381
+ */: string[];
1321
1382
  }, version?: string) => Promise<void>;
1322
1383
  /**
1323
1384
  * Add a query to a domain by its id.
@@ -1339,6 +1400,25 @@ declare const _default: (path: string) => {
1339
1400
  addQueryToDomain: (id: string, direction: string, message: {
1340
1401
  id: string;
1341
1402
  version: string;
1403
+ fields? /**
1404
+ * Add an event to a service by it's id.
1405
+ *
1406
+ * Optionally specify a version to add the event to a specific version of the service.
1407
+ *
1408
+ * @example
1409
+ * ```ts
1410
+ * import utils from '@eventcatalog/utils';
1411
+ *
1412
+ * const { addEventToService } = utils('/path/to/eventcatalog');
1413
+ *
1414
+ * // adds a new event (InventoryUpdatedEvent) that the InventoryService will send
1415
+ * await addEventToService('InventoryService', 'sends', { event: 'InventoryUpdatedEvent', version: '2.0.0' });
1416
+ *
1417
+ * // adds a new event (OrderComplete) that the InventoryService will receive
1418
+ * await addEventToService('InventoryService', 'receives', { event: 'OrderComplete', version: '2.0.0' });
1419
+ *
1420
+ * ```
1421
+ */: string[];
1342
1422
  }, version?: string) => Promise<void>;
1343
1423
  /**
1344
1424
  * ================================
package/dist/index.js CHANGED
@@ -862,6 +862,11 @@ var copyDir = async (catalogDir, source, target, filter) => {
862
862
  });
863
863
  import_node_fs.default.rmSync(tmpDirectory, { recursive: true });
864
864
  };
865
+ var buildMessagePointer = (message) => {
866
+ const pointer = { id: message.id, version: message.version };
867
+ if (message.fields) pointer.fields = message.fields;
868
+ return pointer;
869
+ };
865
870
  var uniqueVersions = (messages) => {
866
871
  const uniqueSet = /* @__PURE__ */ new Set();
867
872
  return messages.filter((message) => {
@@ -1364,7 +1369,7 @@ var addMessageToService = (directory) => async (id, direction, event, version) =
1364
1369
  return;
1365
1370
  }
1366
1371
  }
1367
- service.sends.push({ id: event.id, version: event.version });
1372
+ service.sends.push(buildMessagePointer(event));
1368
1373
  } else if (direction === "receives") {
1369
1374
  if (service.receives === void 0) {
1370
1375
  service.receives = [];
@@ -1374,7 +1379,7 @@ var addMessageToService = (directory) => async (id, direction, event, version) =
1374
1379
  return;
1375
1380
  }
1376
1381
  }
1377
- service.receives.push({ id: event.id, version: event.version });
1382
+ service.receives.push(buildMessagePointer(event));
1378
1383
  } else {
1379
1384
  throw new Error(`Direction ${direction} is invalid, only 'receives' and 'sends' are supported`);
1380
1385
  }
@@ -1462,6 +1467,14 @@ var import_promises6 = __toESM(require("fs/promises"));
1462
1467
  var import_node_path8 = __toESM(require("path"));
1463
1468
  var import_node_fs3 = __toESM(require("fs"));
1464
1469
  var import_gray_matter3 = __toESM(require("gray-matter"));
1470
+ var resolveDomainWriteDirectory = async (directory, id, version) => {
1471
+ const existingResource = await findFileById(directory, id, version);
1472
+ if (!existingResource) return directory;
1473
+ const normalizedPath = existingResource.replace(/\\/g, "/");
1474
+ const lastDomainsIndex = normalizedPath.lastIndexOf("/domains/");
1475
+ if (lastDomainsIndex === -1) return directory;
1476
+ return existingResource.substring(0, lastDomainsIndex + "/domains".length);
1477
+ };
1465
1478
  var getDomain = (directory) => async (id, version) => getResource(directory, id, version, { type: "domain" });
1466
1479
  var getDomains = (directory) => async (options) => getResources(directory, {
1467
1480
  type: "domains",
@@ -1531,8 +1544,9 @@ var addServiceToDomain = (directory) => async (id, service, version) => {
1531
1544
  return;
1532
1545
  }
1533
1546
  domain.services.push(service);
1547
+ const writeDir = await resolveDomainWriteDirectory(directory, id, version);
1534
1548
  await rmDomainById(directory)(id, version, true);
1535
- await writeDomain(directory)(domain, { format: extension === ".md" ? "md" : "mdx" });
1549
+ await writeDomain(writeDir)(domain, { format: extension === ".md" ? "md" : "mdx" });
1536
1550
  };
1537
1551
  var addSubDomainToDomain = (directory) => async (id, subDomain, version) => {
1538
1552
  let domain = await getDomain(directory)(id, version);
@@ -1546,8 +1560,9 @@ var addSubDomainToDomain = (directory) => async (id, subDomain, version) => {
1546
1560
  return;
1547
1561
  }
1548
1562
  domain.domains.push(subDomain);
1563
+ const writeDir = await resolveDomainWriteDirectory(directory, id, version);
1549
1564
  await rmDomainById(directory)(id, version, true);
1550
- await writeDomain(directory)(domain, { format: extension === ".md" ? "md" : "mdx" });
1565
+ await writeDomain(writeDir)(domain, { format: extension === ".md" ? "md" : "mdx" });
1551
1566
  };
1552
1567
  var addEntityToDomain = (directory) => async (id, entity, version) => {
1553
1568
  let domain = await getDomain(directory)(id, version);
@@ -1561,8 +1576,9 @@ var addEntityToDomain = (directory) => async (id, entity, version) => {
1561
1576
  return;
1562
1577
  }
1563
1578
  domain.entities.push(entity);
1579
+ const writeDir = await resolveDomainWriteDirectory(directory, id, version);
1564
1580
  await rmDomainById(directory)(id, version, true);
1565
- await writeDomain(directory)(domain, { format: extension === ".md" ? "md" : "mdx" });
1581
+ await writeDomain(writeDir)(domain, { format: extension === ".md" ? "md" : "mdx" });
1566
1582
  };
1567
1583
  var addDataProductToDomain = (directory) => async (id, dataProduct, version) => {
1568
1584
  let domain = await getDomain(directory)(id, version);
@@ -1578,8 +1594,9 @@ var addDataProductToDomain = (directory) => async (id, dataProduct, version) =>
1578
1594
  return;
1579
1595
  }
1580
1596
  domain.dataProducts.push(dataProduct);
1597
+ const writeDir = await resolveDomainWriteDirectory(directory, id, version);
1581
1598
  await rmDomainById(directory)(id, version, true);
1582
- await writeDomain(directory)(domain, { format: extension === ".md" ? "md" : "mdx" });
1599
+ await writeDomain(writeDir)(domain, { format: extension === ".md" ? "md" : "mdx" });
1583
1600
  };
1584
1601
  var addMessageToDomain = (directory) => async (id, direction, message, version) => {
1585
1602
  let domain = await getDomain(directory)(id, version);
@@ -1594,7 +1611,7 @@ var addMessageToDomain = (directory) => async (id, direction, message, version)
1594
1611
  return;
1595
1612
  }
1596
1613
  }
1597
- domain.sends.push({ id: message.id, version: message.version });
1614
+ domain.sends.push(buildMessagePointer(message));
1598
1615
  } else if (direction === "receives") {
1599
1616
  if (domain.receives === void 0) {
1600
1617
  domain.receives = [];
@@ -1604,19 +1621,13 @@ var addMessageToDomain = (directory) => async (id, direction, message, version)
1604
1621
  return;
1605
1622
  }
1606
1623
  }
1607
- domain.receives.push({ id: message.id, version: message.version });
1624
+ domain.receives.push(buildMessagePointer(message));
1608
1625
  } else {
1609
1626
  throw new Error(`Direction ${direction} is invalid, only 'receives' and 'sends' are supported`);
1610
1627
  }
1611
- const existingResource = await findFileById(directory, id, version);
1612
- if (!existingResource) {
1613
- throw new Error(`Cannot find domain ${id} in the catalog`);
1614
- }
1615
- const normalizedPath = existingResource.replace(/\\/g, "/");
1616
- const lastDomainsIndex = normalizedPath.lastIndexOf("/domains/");
1617
- const pathToResource = existingResource.substring(0, lastDomainsIndex + "/domains".length);
1628
+ const writeDir = await resolveDomainWriteDirectory(directory, id, version);
1618
1629
  await rmDomainById(directory)(id, version, true);
1619
- await writeDomain(pathToResource)(domain, { format: extension === ".md" ? "md" : "mdx" });
1630
+ await writeDomain(writeDir)(domain, { format: extension === ".md" ? "md" : "mdx" });
1620
1631
  };
1621
1632
 
1622
1633
  // src/channels.ts