@eventcatalog/sdk 2.6.8 → 2.7.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.js CHANGED
@@ -33,7 +33,7 @@ __export(index_exports, {
33
33
  default: () => index_default
34
34
  });
35
35
  module.exports = __toCommonJS(index_exports);
36
- var import_node_path14 = require("path");
36
+ var import_node_path15 = require("path");
37
37
 
38
38
  // src/events.ts
39
39
  var import_promises2 = __toESM(require("fs/promises"));
@@ -552,6 +552,28 @@ var isService = (directory) => async (path5) => {
552
552
  return !!service && segments.includes("services");
553
553
  };
554
554
  var toService = (directory) => async (file) => toResource(directory, file);
555
+ var addEntityToService = (directory) => async (id, entity, version) => {
556
+ let service = await getService(directory)(id, version);
557
+ const servicePath = await getResourcePath(directory, id, version);
558
+ const extension = (0, import_node_path5.extname)(servicePath?.fullPath || "");
559
+ if (service.entities === void 0) {
560
+ service.entities = [];
561
+ }
562
+ for (let i = 0; i < service.entities.length; i++) {
563
+ if (service.entities[i].id === entity.id && service.entities[i].version === entity.version) {
564
+ return;
565
+ }
566
+ }
567
+ service.entities.push({ id: entity.id, version: entity.version });
568
+ const existingResource = await findFileById(directory, id, version);
569
+ if (!existingResource) {
570
+ throw new Error(`Cannot find service ${id} in the catalog`);
571
+ }
572
+ const path5 = existingResource.split(/[\\/]+services/)[0];
573
+ const pathToResource = (0, import_node_path5.join)(path5, "services");
574
+ await rmServiceById(directory)(id, version);
575
+ await writeService(pathToResource)(service, { format: extension === ".md" ? "md" : "mdx" });
576
+ };
555
577
 
556
578
  // src/domains.ts
557
579
  var import_promises6 = __toESM(require("fs/promises"));
@@ -635,6 +657,21 @@ var addSubDomainToDomain = (directory) => async (id, subDomain, version) => {
635
657
  await rmDomainById(directory)(id, version, true);
636
658
  await writeDomain(directory)(domain, { format: extension === ".md" ? "md" : "mdx" });
637
659
  };
660
+ var addEntityToDomain = (directory) => async (id, entity, version) => {
661
+ let domain = await getDomain(directory)(id, version);
662
+ const domainPath = await getResourcePath(directory, id, version);
663
+ const extension = import_node_path6.default.extname(domainPath?.fullPath || "");
664
+ if (domain.entities === void 0) {
665
+ domain.entities = [];
666
+ }
667
+ const entityExistsInList = domain.entities.some((e) => e.id === entity.id && e.version === entity.version);
668
+ if (entityExistsInList) {
669
+ return;
670
+ }
671
+ domain.entities.push(entity);
672
+ await rmDomainById(directory)(id, version, true);
673
+ await writeDomain(directory)(domain, { format: extension === ".md" ? "md" : "mdx" });
674
+ };
638
675
 
639
676
  // src/channels.ts
640
677
  var import_promises7 = __toESM(require("fs/promises"));
@@ -1033,6 +1070,28 @@ var dumpCatalog = (directory) => async (options) => {
1033
1070
  };
1034
1071
  };
1035
1072
 
1073
+ // src/entities.ts
1074
+ var import_promises10 = __toESM(require("fs/promises"));
1075
+ var import_node_path14 = require("path");
1076
+ var getEntity = (directory) => async (id, version) => getResource(directory, id, version, { type: "entity" });
1077
+ var getEntities = (directory) => async (options) => getResources(directory, { type: "entities", latestOnly: options?.latestOnly });
1078
+ var writeEntity = (directory) => async (entity, options = {
1079
+ path: "",
1080
+ override: false,
1081
+ format: "mdx"
1082
+ }) => writeResource(directory, { ...entity }, { ...options, type: "entity" });
1083
+ var rmEntity = (directory) => async (path5) => {
1084
+ await import_promises10.default.rm((0, import_node_path14.join)(directory, path5), { recursive: true });
1085
+ };
1086
+ var rmEntityById = (directory) => async (id, version, persistFiles) => {
1087
+ await rmResourceById(directory, id, version, { type: "entity", persistFiles });
1088
+ };
1089
+ var versionEntity = (directory) => async (id) => versionResource(directory, id);
1090
+ var entityHasVersion = (directory) => async (id, version) => {
1091
+ const file = await findFileById(directory, id, version);
1092
+ return !!file;
1093
+ };
1094
+
1036
1095
  // src/index.ts
1037
1096
  var index_default = (path5) => {
1038
1097
  return {
@@ -1042,13 +1101,13 @@ var index_default = (path5) => {
1042
1101
  * @param version - Optional id of the version to get (supports semver)
1043
1102
  * @returns Event|Undefined
1044
1103
  */
1045
- getEvent: getEvent((0, import_node_path14.join)(path5)),
1104
+ getEvent: getEvent((0, import_node_path15.join)(path5)),
1046
1105
  /**
1047
1106
  * Returns all events from EventCatalog
1048
1107
  * @param latestOnly - optional boolean, set to true to get only latest versions
1049
1108
  * @returns Event[]|Undefined
1050
1109
  */
1051
- getEvents: getEvents((0, import_node_path14.join)(path5)),
1110
+ getEvents: getEvents((0, import_node_path15.join)(path5)),
1052
1111
  /**
1053
1112
  * Adds an event to EventCatalog
1054
1113
  *
@@ -1056,7 +1115,7 @@ var index_default = (path5) => {
1056
1115
  * @param options - Optional options to write the event
1057
1116
  *
1058
1117
  */
1059
- writeEvent: writeEvent((0, import_node_path14.join)(path5, "events")),
1118
+ writeEvent: writeEvent((0, import_node_path15.join)(path5, "events")),
1060
1119
  /**
1061
1120
  * Adds an event to a service in EventCatalog
1062
1121
  *
@@ -1065,26 +1124,26 @@ var index_default = (path5) => {
1065
1124
  * @param options - Optional options to write the event
1066
1125
  *
1067
1126
  */
1068
- writeEventToService: writeEventToService((0, import_node_path14.join)(path5)),
1127
+ writeEventToService: writeEventToService((0, import_node_path15.join)(path5)),
1069
1128
  /**
1070
1129
  * Remove an event to EventCatalog (modeled on the standard POSIX rm utility)
1071
1130
  *
1072
1131
  * @param path - The path to your event, e.g. `/Inventory/InventoryAdjusted`
1073
1132
  *
1074
1133
  */
1075
- rmEvent: rmEvent((0, import_node_path14.join)(path5, "events")),
1134
+ rmEvent: rmEvent((0, import_node_path15.join)(path5, "events")),
1076
1135
  /**
1077
1136
  * Remove an event by an Event id
1078
1137
  *
1079
1138
  * @param id - The id of the event you want to remove
1080
1139
  *
1081
1140
  */
1082
- rmEventById: rmEventById((0, import_node_path14.join)(path5)),
1141
+ rmEventById: rmEventById((0, import_node_path15.join)(path5)),
1083
1142
  /**
1084
1143
  * Moves a given event id to the version directory
1085
1144
  * @param directory
1086
1145
  */
1087
- versionEvent: versionEvent((0, import_node_path14.join)(path5)),
1146
+ versionEvent: versionEvent((0, import_node_path15.join)(path5)),
1088
1147
  /**
1089
1148
  * Adds a file to the given event
1090
1149
  * @param id - The id of the event to add the file to
@@ -1092,7 +1151,7 @@ var index_default = (path5) => {
1092
1151
  * @param version - Optional version of the event to add the file to
1093
1152
  * @returns
1094
1153
  */
1095
- addFileToEvent: addFileToEvent((0, import_node_path14.join)(path5)),
1154
+ addFileToEvent: addFileToEvent((0, import_node_path15.join)(path5)),
1096
1155
  /**
1097
1156
  * Adds a schema to the given event
1098
1157
  * @param id - The id of the event to add the schema to
@@ -1100,14 +1159,14 @@ var index_default = (path5) => {
1100
1159
  * @param version - Optional version of the event to add the schema to
1101
1160
  * @returns
1102
1161
  */
1103
- addSchemaToEvent: addSchemaToEvent((0, import_node_path14.join)(path5)),
1162
+ addSchemaToEvent: addSchemaToEvent((0, import_node_path15.join)(path5)),
1104
1163
  /**
1105
1164
  * Check to see if an event version exists
1106
1165
  * @param id - The id of the event
1107
1166
  * @param version - The version of the event (supports semver)
1108
1167
  * @returns
1109
1168
  */
1110
- eventHasVersion: eventHasVersion((0, import_node_path14.join)(path5)),
1169
+ eventHasVersion: eventHasVersion((0, import_node_path15.join)(path5)),
1111
1170
  /**
1112
1171
  * ================================
1113
1172
  * Commands
@@ -1119,13 +1178,13 @@ var index_default = (path5) => {
1119
1178
  * @param version - Optional id of the version to get (supports semver)
1120
1179
  * @returns Command|Undefined
1121
1180
  */
1122
- getCommand: getCommand((0, import_node_path14.join)(path5)),
1181
+ getCommand: getCommand((0, import_node_path15.join)(path5)),
1123
1182
  /**
1124
1183
  * Returns all commands from EventCatalog
1125
1184
  * @param latestOnly - optional boolean, set to true to get only latest versions
1126
1185
  * @returns Command[]|Undefined
1127
1186
  */
1128
- getCommands: getCommands((0, import_node_path14.join)(path5)),
1187
+ getCommands: getCommands((0, import_node_path15.join)(path5)),
1129
1188
  /**
1130
1189
  * Adds an command to EventCatalog
1131
1190
  *
@@ -1133,7 +1192,7 @@ var index_default = (path5) => {
1133
1192
  * @param options - Optional options to write the command
1134
1193
  *
1135
1194
  */
1136
- writeCommand: writeCommand((0, import_node_path14.join)(path5, "commands")),
1195
+ writeCommand: writeCommand((0, import_node_path15.join)(path5, "commands")),
1137
1196
  /**
1138
1197
  * Adds a command to a service in EventCatalog
1139
1198
  *
@@ -1142,26 +1201,26 @@ var index_default = (path5) => {
1142
1201
  * @param options - Optional options to write the command
1143
1202
  *
1144
1203
  */
1145
- writeCommandToService: writeCommandToService((0, import_node_path14.join)(path5)),
1204
+ writeCommandToService: writeCommandToService((0, import_node_path15.join)(path5)),
1146
1205
  /**
1147
1206
  * Remove an command to EventCatalog (modeled on the standard POSIX rm utility)
1148
1207
  *
1149
1208
  * @param path - The path to your command, e.g. `/Inventory/InventoryAdjusted`
1150
1209
  *
1151
1210
  */
1152
- rmCommand: rmCommand((0, import_node_path14.join)(path5, "commands")),
1211
+ rmCommand: rmCommand((0, import_node_path15.join)(path5, "commands")),
1153
1212
  /**
1154
1213
  * Remove an command by an Event id
1155
1214
  *
1156
1215
  * @param id - The id of the command you want to remove
1157
1216
  *
1158
1217
  */
1159
- rmCommandById: rmCommandById((0, import_node_path14.join)(path5)),
1218
+ rmCommandById: rmCommandById((0, import_node_path15.join)(path5)),
1160
1219
  /**
1161
1220
  * Moves a given command id to the version directory
1162
1221
  * @param directory
1163
1222
  */
1164
- versionCommand: versionCommand((0, import_node_path14.join)(path5)),
1223
+ versionCommand: versionCommand((0, import_node_path15.join)(path5)),
1165
1224
  /**
1166
1225
  * Adds a file to the given command
1167
1226
  * @param id - The id of the command to add the file to
@@ -1169,7 +1228,7 @@ var index_default = (path5) => {
1169
1228
  * @param version - Optional version of the command to add the file to
1170
1229
  * @returns
1171
1230
  */
1172
- addFileToCommand: addFileToCommand((0, import_node_path14.join)(path5)),
1231
+ addFileToCommand: addFileToCommand((0, import_node_path15.join)(path5)),
1173
1232
  /**
1174
1233
  * Adds a schema to the given command
1175
1234
  * @param id - The id of the command to add the schema to
@@ -1177,14 +1236,14 @@ var index_default = (path5) => {
1177
1236
  * @param version - Optional version of the command to add the schema to
1178
1237
  * @returns
1179
1238
  */
1180
- addSchemaToCommand: addSchemaToCommand((0, import_node_path14.join)(path5)),
1239
+ addSchemaToCommand: addSchemaToCommand((0, import_node_path15.join)(path5)),
1181
1240
  /**
1182
1241
  * Check to see if a command version exists
1183
1242
  * @param id - The id of the command
1184
1243
  * @param version - The version of the command (supports semver)
1185
1244
  * @returns
1186
1245
  */
1187
- commandHasVersion: commandHasVersion((0, import_node_path14.join)(path5)),
1246
+ commandHasVersion: commandHasVersion((0, import_node_path15.join)(path5)),
1188
1247
  /**
1189
1248
  * ================================
1190
1249
  * Queries
@@ -1196,13 +1255,13 @@ var index_default = (path5) => {
1196
1255
  * @param version - Optional id of the version to get (supports semver)
1197
1256
  * @returns Query|Undefined
1198
1257
  */
1199
- getQuery: getQuery((0, import_node_path14.join)(path5)),
1258
+ getQuery: getQuery((0, import_node_path15.join)(path5)),
1200
1259
  /**
1201
1260
  * Returns all queries from EventCatalog
1202
1261
  * @param latestOnly - optional boolean, set to true to get only latest versions
1203
1262
  * @returns Query[]|Undefined
1204
1263
  */
1205
- getQueries: getQueries((0, import_node_path14.join)(path5)),
1264
+ getQueries: getQueries((0, import_node_path15.join)(path5)),
1206
1265
  /**
1207
1266
  * Adds a query to EventCatalog
1208
1267
  *
@@ -1210,7 +1269,7 @@ var index_default = (path5) => {
1210
1269
  * @param options - Optional options to write the event
1211
1270
  *
1212
1271
  */
1213
- writeQuery: writeQuery((0, import_node_path14.join)(path5, "queries")),
1272
+ writeQuery: writeQuery((0, import_node_path15.join)(path5, "queries")),
1214
1273
  /**
1215
1274
  * Adds a query to a service in EventCatalog
1216
1275
  *
@@ -1219,26 +1278,26 @@ var index_default = (path5) => {
1219
1278
  * @param options - Optional options to write the query
1220
1279
  *
1221
1280
  */
1222
- writeQueryToService: writeQueryToService((0, import_node_path14.join)(path5)),
1281
+ writeQueryToService: writeQueryToService((0, import_node_path15.join)(path5)),
1223
1282
  /**
1224
1283
  * Remove an query to EventCatalog (modeled on the standard POSIX rm utility)
1225
1284
  *
1226
1285
  * @param path - The path to your query, e.g. `/Orders/GetOrder`
1227
1286
  *
1228
1287
  */
1229
- rmQuery: rmQuery((0, import_node_path14.join)(path5, "queries")),
1288
+ rmQuery: rmQuery((0, import_node_path15.join)(path5, "queries")),
1230
1289
  /**
1231
1290
  * Remove a query by a Query id
1232
1291
  *
1233
1292
  * @param id - The id of the query you want to remove
1234
1293
  *
1235
1294
  */
1236
- rmQueryById: rmQueryById((0, import_node_path14.join)(path5)),
1295
+ rmQueryById: rmQueryById((0, import_node_path15.join)(path5)),
1237
1296
  /**
1238
1297
  * Moves a given query id to the version directory
1239
1298
  * @param directory
1240
1299
  */
1241
- versionQuery: versionQuery((0, import_node_path14.join)(path5)),
1300
+ versionQuery: versionQuery((0, import_node_path15.join)(path5)),
1242
1301
  /**
1243
1302
  * Adds a file to the given query
1244
1303
  * @param id - The id of the query to add the file to
@@ -1246,7 +1305,7 @@ var index_default = (path5) => {
1246
1305
  * @param version - Optional version of the query to add the file to
1247
1306
  * @returns
1248
1307
  */
1249
- addFileToQuery: addFileToQuery((0, import_node_path14.join)(path5)),
1308
+ addFileToQuery: addFileToQuery((0, import_node_path15.join)(path5)),
1250
1309
  /**
1251
1310
  * Adds a schema to the given query
1252
1311
  * @param id - The id of the query to add the schema to
@@ -1254,14 +1313,14 @@ var index_default = (path5) => {
1254
1313
  * @param version - Optional version of the query to add the schema to
1255
1314
  * @returns
1256
1315
  */
1257
- addSchemaToQuery: addSchemaToQuery((0, import_node_path14.join)(path5)),
1316
+ addSchemaToQuery: addSchemaToQuery((0, import_node_path15.join)(path5)),
1258
1317
  /**
1259
1318
  * Check to see if an query version exists
1260
1319
  * @param id - The id of the query
1261
1320
  * @param version - The version of the query (supports semver)
1262
1321
  * @returns
1263
1322
  */
1264
- queryHasVersion: queryHasVersion((0, import_node_path14.join)(path5)),
1323
+ queryHasVersion: queryHasVersion((0, import_node_path15.join)(path5)),
1265
1324
  /**
1266
1325
  * ================================
1267
1326
  * Channels
@@ -1273,13 +1332,13 @@ var index_default = (path5) => {
1273
1332
  * @param version - Optional id of the version to get (supports semver)
1274
1333
  * @returns Channel|Undefined
1275
1334
  */
1276
- getChannel: getChannel((0, import_node_path14.join)(path5)),
1335
+ getChannel: getChannel((0, import_node_path15.join)(path5)),
1277
1336
  /**
1278
1337
  * Returns all channels from EventCatalog
1279
1338
  * @param latestOnly - optional boolean, set to true to get only latest versions
1280
1339
  * @returns Channel[]|Undefined
1281
1340
  */
1282
- getChannels: getChannels((0, import_node_path14.join)(path5)),
1341
+ getChannels: getChannels((0, import_node_path15.join)(path5)),
1283
1342
  /**
1284
1343
  * Adds an channel to EventCatalog
1285
1344
  *
@@ -1287,33 +1346,33 @@ var index_default = (path5) => {
1287
1346
  * @param options - Optional options to write the channel
1288
1347
  *
1289
1348
  */
1290
- writeChannel: writeChannel((0, import_node_path14.join)(path5, "channels")),
1349
+ writeChannel: writeChannel((0, import_node_path15.join)(path5, "channels")),
1291
1350
  /**
1292
1351
  * Remove an channel to EventCatalog (modeled on the standard POSIX rm utility)
1293
1352
  *
1294
1353
  * @param path - The path to your channel, e.g. `/Inventory/InventoryAdjusted`
1295
1354
  *
1296
1355
  */
1297
- rmChannel: rmChannel((0, import_node_path14.join)(path5, "channels")),
1356
+ rmChannel: rmChannel((0, import_node_path15.join)(path5, "channels")),
1298
1357
  /**
1299
1358
  * Remove an channel by an Event id
1300
1359
  *
1301
1360
  * @param id - The id of the channel you want to remove
1302
1361
  *
1303
1362
  */
1304
- rmChannelById: rmChannelById((0, import_node_path14.join)(path5)),
1363
+ rmChannelById: rmChannelById((0, import_node_path15.join)(path5)),
1305
1364
  /**
1306
1365
  * Moves a given channel id to the version directory
1307
1366
  * @param directory
1308
1367
  */
1309
- versionChannel: versionChannel((0, import_node_path14.join)(path5)),
1368
+ versionChannel: versionChannel((0, import_node_path15.join)(path5)),
1310
1369
  /**
1311
1370
  * Check to see if a channel version exists
1312
1371
  * @param id - The id of the channel
1313
1372
  * @param version - The version of the channel (supports semver)
1314
1373
  * @returns
1315
1374
  */
1316
- channelHasVersion: channelHasVersion((0, import_node_path14.join)(path5)),
1375
+ channelHasVersion: channelHasVersion((0, import_node_path15.join)(path5)),
1317
1376
  /**
1318
1377
  * Add a channel to an event
1319
1378
  *
@@ -1330,7 +1389,7 @@ var index_default = (path5) => {
1330
1389
  *
1331
1390
  * ```
1332
1391
  */
1333
- addEventToChannel: addMessageToChannel((0, import_node_path14.join)(path5), "events"),
1392
+ addEventToChannel: addMessageToChannel((0, import_node_path15.join)(path5), "events"),
1334
1393
  /**
1335
1394
  * Add a channel to an command
1336
1395
  *
@@ -1347,7 +1406,7 @@ var index_default = (path5) => {
1347
1406
  *
1348
1407
  * ```
1349
1408
  */
1350
- addCommandToChannel: addMessageToChannel((0, import_node_path14.join)(path5), "commands"),
1409
+ addCommandToChannel: addMessageToChannel((0, import_node_path15.join)(path5), "commands"),
1351
1410
  /**
1352
1411
  * Add a channel to an query
1353
1412
  *
@@ -1364,7 +1423,7 @@ var index_default = (path5) => {
1364
1423
  *
1365
1424
  * ```
1366
1425
  */
1367
- addQueryToChannel: addMessageToChannel((0, import_node_path14.join)(path5), "queries"),
1426
+ addQueryToChannel: addMessageToChannel((0, import_node_path15.join)(path5), "queries"),
1368
1427
  /**
1369
1428
  * ================================
1370
1429
  * SERVICES
@@ -1377,14 +1436,14 @@ var index_default = (path5) => {
1377
1436
  * @param options - Optional options to write the event
1378
1437
  *
1379
1438
  */
1380
- writeService: writeService((0, import_node_path14.join)(path5, "services")),
1439
+ writeService: writeService((0, import_node_path15.join)(path5, "services")),
1381
1440
  /**
1382
1441
  * Adds a versioned service to EventCatalog
1383
1442
  *
1384
1443
  * @param service - The service to write
1385
1444
  *
1386
1445
  */
1387
- writeVersionedService: writeVersionedService((0, import_node_path14.join)(path5, "services")),
1446
+ writeVersionedService: writeVersionedService((0, import_node_path15.join)(path5, "services")),
1388
1447
  /**
1389
1448
  * Adds a service to a domain in EventCatalog
1390
1449
  *
@@ -1393,45 +1452,45 @@ var index_default = (path5) => {
1393
1452
  * @param options - Optional options to write the event
1394
1453
  *
1395
1454
  */
1396
- writeServiceToDomain: writeServiceToDomain((0, import_node_path14.join)(path5, "domains")),
1455
+ writeServiceToDomain: writeServiceToDomain((0, import_node_path15.join)(path5, "domains")),
1397
1456
  /**
1398
1457
  * Returns a service from EventCatalog
1399
1458
  * @param id - The id of the service to retrieve
1400
1459
  * @param version - Optional id of the version to get (supports semver)
1401
1460
  * @returns Service|Undefined
1402
1461
  */
1403
- getService: getService((0, import_node_path14.join)(path5)),
1462
+ getService: getService((0, import_node_path15.join)(path5)),
1404
1463
  /**
1405
1464
  * Returns a service from EventCatalog by it's path.
1406
1465
  * @param path - The path to the service to retrieve
1407
1466
  * @returns Service|Undefined
1408
1467
  */
1409
- getServiceByPath: getServiceByPath((0, import_node_path14.join)(path5)),
1468
+ getServiceByPath: getServiceByPath((0, import_node_path15.join)(path5)),
1410
1469
  /**
1411
1470
  * Returns all services from EventCatalog
1412
1471
  * @param latestOnly - optional boolean, set to true to get only latest versions
1413
1472
  * @returns Service[]|Undefined
1414
1473
  */
1415
- getServices: getServices((0, import_node_path14.join)(path5)),
1474
+ getServices: getServices((0, import_node_path15.join)(path5)),
1416
1475
  /**
1417
1476
  * Moves a given service id to the version directory
1418
1477
  * @param directory
1419
1478
  */
1420
- versionService: versionService((0, import_node_path14.join)(path5)),
1479
+ versionService: versionService((0, import_node_path15.join)(path5)),
1421
1480
  /**
1422
1481
  * Remove a service from EventCatalog (modeled on the standard POSIX rm utility)
1423
1482
  *
1424
1483
  * @param path - The path to your service, e.g. `/InventoryService`
1425
1484
  *
1426
1485
  */
1427
- rmService: rmService((0, import_node_path14.join)(path5, "services")),
1486
+ rmService: rmService((0, import_node_path15.join)(path5, "services")),
1428
1487
  /**
1429
1488
  * Remove an service by an service id
1430
1489
  *
1431
1490
  * @param id - The id of the service you want to remove
1432
1491
  *
1433
1492
  */
1434
- rmServiceById: rmServiceById((0, import_node_path14.join)(path5)),
1493
+ rmServiceById: rmServiceById((0, import_node_path15.join)(path5)),
1435
1494
  /**
1436
1495
  * Adds a file to the given service
1437
1496
  * @param id - The id of the service to add the file to
@@ -1439,21 +1498,21 @@ var index_default = (path5) => {
1439
1498
  * @param version - Optional version of the service to add the file to
1440
1499
  * @returns
1441
1500
  */
1442
- addFileToService: addFileToService((0, import_node_path14.join)(path5)),
1501
+ addFileToService: addFileToService((0, import_node_path15.join)(path5)),
1443
1502
  /**
1444
1503
  * Returns the specifications for a given service
1445
1504
  * @param id - The id of the service to retrieve the specifications for
1446
1505
  * @param version - Optional version of the service
1447
1506
  * @returns
1448
1507
  */
1449
- getSpecificationFilesForService: getSpecificationFilesForService((0, import_node_path14.join)(path5)),
1508
+ getSpecificationFilesForService: getSpecificationFilesForService((0, import_node_path15.join)(path5)),
1450
1509
  /**
1451
1510
  * Check to see if a service version exists
1452
1511
  * @param id - The id of the service
1453
1512
  * @param version - The version of the service (supports semver)
1454
1513
  * @returns
1455
1514
  */
1456
- serviceHasVersion: serviceHasVersion((0, import_node_path14.join)(path5)),
1515
+ serviceHasVersion: serviceHasVersion((0, import_node_path15.join)(path5)),
1457
1516
  /**
1458
1517
  * Add an event to a service by it's id.
1459
1518
  *
@@ -1473,7 +1532,7 @@ var index_default = (path5) => {
1473
1532
  *
1474
1533
  * ```
1475
1534
  */
1476
- addEventToService: addMessageToService((0, import_node_path14.join)(path5)),
1535
+ addEventToService: addMessageToService((0, import_node_path15.join)(path5)),
1477
1536
  /**
1478
1537
  * Add a command to a service by it's id.
1479
1538
  *
@@ -1493,7 +1552,7 @@ var index_default = (path5) => {
1493
1552
  *
1494
1553
  * ```
1495
1554
  */
1496
- addCommandToService: addMessageToService((0, import_node_path14.join)(path5)),
1555
+ addCommandToService: addMessageToService((0, import_node_path15.join)(path5)),
1497
1556
  /**
1498
1557
  * Add a query to a service by it's id.
1499
1558
  *
@@ -1513,7 +1572,25 @@ var index_default = (path5) => {
1513
1572
  *
1514
1573
  * ```
1515
1574
  */
1516
- addQueryToService: addMessageToService((0, import_node_path14.join)(path5)),
1575
+ addQueryToService: addMessageToService((0, import_node_path15.join)(path5)),
1576
+ /**
1577
+ * Add an entity to a service by its id.
1578
+ *
1579
+ * @example
1580
+ * ```ts
1581
+ * import utils from '@eventcatalog/utils';
1582
+ *
1583
+ * const { addEntityToService } = utils('/path/to/eventcatalog');
1584
+ *
1585
+ * // adds a new entity (User) to the InventoryService
1586
+ * await addEntityToService('InventoryService', { id: 'User', version: '1.0.0' });
1587
+ *
1588
+ * // adds a new entity (Product) to a specific version of the InventoryService
1589
+ * await addEntityToService('InventoryService', { id: 'Product', version: '1.0.0' }, '2.0.0');
1590
+ *
1591
+ * ```
1592
+ */
1593
+ addEntityToService: addEntityToService((0, import_node_path15.join)(path5)),
1517
1594
  /**
1518
1595
  * Check to see if a service exists by it's path.
1519
1596
  *
@@ -1530,13 +1607,13 @@ var index_default = (path5) => {
1530
1607
  * @param path - The path to the service to check
1531
1608
  * @returns boolean
1532
1609
  */
1533
- isService: isService((0, import_node_path14.join)(path5)),
1610
+ isService: isService((0, import_node_path15.join)(path5)),
1534
1611
  /**
1535
1612
  * Converts a file to a service.
1536
1613
  * @param file - The file to convert to a service.
1537
1614
  * @returns The service.
1538
1615
  */
1539
- toService: toService((0, import_node_path14.join)(path5)),
1616
+ toService: toService((0, import_node_path15.join)(path5)),
1540
1617
  /**
1541
1618
  * ================================
1542
1619
  * Domains
@@ -1549,39 +1626,39 @@ var index_default = (path5) => {
1549
1626
  * @param options - Optional options to write the event
1550
1627
  *
1551
1628
  */
1552
- writeDomain: writeDomain((0, import_node_path14.join)(path5, "domains")),
1629
+ writeDomain: writeDomain((0, import_node_path15.join)(path5, "domains")),
1553
1630
  /**
1554
1631
  * Returns a domain from EventCatalog
1555
1632
  * @param id - The id of the domain to retrieve
1556
1633
  * @param version - Optional id of the version to get (supports semver)
1557
1634
  * @returns Domain|Undefined
1558
1635
  */
1559
- getDomain: getDomain((0, import_node_path14.join)(path5, "domains")),
1636
+ getDomain: getDomain((0, import_node_path15.join)(path5, "domains")),
1560
1637
  /**
1561
1638
  * Returns all domains from EventCatalog
1562
1639
  * @param latestOnly - optional boolean, set to true to get only latest versions
1563
1640
  * @returns Domain[]|Undefined
1564
1641
  */
1565
- getDomains: getDomains((0, import_node_path14.join)(path5)),
1642
+ getDomains: getDomains((0, import_node_path15.join)(path5)),
1566
1643
  /**
1567
1644
  * Moves a given domain id to the version directory
1568
1645
  * @param directory
1569
1646
  */
1570
- versionDomain: versionDomain((0, import_node_path14.join)(path5, "domains")),
1647
+ versionDomain: versionDomain((0, import_node_path15.join)(path5, "domains")),
1571
1648
  /**
1572
1649
  * Remove a domain from EventCatalog (modeled on the standard POSIX rm utility)
1573
1650
  *
1574
1651
  * @param path - The path to your domain, e.g. `/Payment`
1575
1652
  *
1576
1653
  */
1577
- rmDomain: rmDomain((0, import_node_path14.join)(path5, "domains")),
1654
+ rmDomain: rmDomain((0, import_node_path15.join)(path5, "domains")),
1578
1655
  /**
1579
1656
  * Remove an service by an domain id
1580
1657
  *
1581
1658
  * @param id - The id of the domain you want to remove
1582
1659
  *
1583
1660
  */
1584
- rmDomainById: rmDomainById((0, import_node_path14.join)(path5, "domains")),
1661
+ rmDomainById: rmDomainById((0, import_node_path15.join)(path5, "domains")),
1585
1662
  /**
1586
1663
  * Adds a file to the given domain
1587
1664
  * @param id - The id of the domain to add the file to
@@ -1589,28 +1666,28 @@ var index_default = (path5) => {
1589
1666
  * @param version - Optional version of the domain to add the file to
1590
1667
  * @returns
1591
1668
  */
1592
- addFileToDomain: addFileToDomain((0, import_node_path14.join)(path5, "domains")),
1669
+ addFileToDomain: addFileToDomain((0, import_node_path15.join)(path5, "domains")),
1593
1670
  /**
1594
1671
  * Adds an ubiquitous language dictionary to a domain
1595
1672
  * @param id - The id of the domain to add the ubiquitous language to
1596
1673
  * @param ubiquitousLanguageDictionary - The ubiquitous language dictionary to add
1597
1674
  * @param version - Optional version of the domain to add the ubiquitous language to
1598
1675
  */
1599
- addUbiquitousLanguageToDomain: addUbiquitousLanguageToDomain((0, import_node_path14.join)(path5, "domains")),
1676
+ addUbiquitousLanguageToDomain: addUbiquitousLanguageToDomain((0, import_node_path15.join)(path5, "domains")),
1600
1677
  /**
1601
1678
  * Get the ubiquitous language dictionary from a domain
1602
1679
  * @param id - The id of the domain to get the ubiquitous language from
1603
1680
  * @param version - Optional version of the domain to get the ubiquitous language from
1604
1681
  * @returns
1605
1682
  */
1606
- getUbiquitousLanguageFromDomain: getUbiquitousLanguageFromDomain((0, import_node_path14.join)(path5, "domains")),
1683
+ getUbiquitousLanguageFromDomain: getUbiquitousLanguageFromDomain((0, import_node_path15.join)(path5, "domains")),
1607
1684
  /**
1608
1685
  * Check to see if a domain version exists
1609
1686
  * @param id - The id of the domain
1610
1687
  * @param version - The version of the domain (supports semver)
1611
1688
  * @returns
1612
1689
  */
1613
- domainHasVersion: domainHasVersion((0, import_node_path14.join)(path5)),
1690
+ domainHasVersion: domainHasVersion((0, import_node_path15.join)(path5)),
1614
1691
  /**
1615
1692
  * Adds a given service to a domain
1616
1693
  * @param id - The id of the domain
@@ -1618,7 +1695,7 @@ var index_default = (path5) => {
1618
1695
  * @param version - (Optional) The version of the domain to add the service to
1619
1696
  * @returns
1620
1697
  */
1621
- addServiceToDomain: addServiceToDomain((0, import_node_path14.join)(path5, "domains")),
1698
+ addServiceToDomain: addServiceToDomain((0, import_node_path15.join)(path5, "domains")),
1622
1699
  /**
1623
1700
  * Adds a given subdomain to a domain
1624
1701
  * @param id - The id of the domain
@@ -1626,7 +1703,15 @@ var index_default = (path5) => {
1626
1703
  * @param version - (Optional) The version of the domain to add the subdomain to
1627
1704
  * @returns
1628
1705
  */
1629
- addSubDomainToDomain: addSubDomainToDomain((0, import_node_path14.join)(path5, "domains")),
1706
+ addSubDomainToDomain: addSubDomainToDomain((0, import_node_path15.join)(path5, "domains")),
1707
+ /**
1708
+ * Adds an entity to a domain
1709
+ * @param id - The id of the domain
1710
+ * @param entity - The id and version of the entity to add
1711
+ * @param version - (Optional) The version of the domain to add the entity to
1712
+ * @returns
1713
+ */
1714
+ addEntityToDomain: addEntityToDomain((0, import_node_path15.join)(path5, "domains")),
1630
1715
  /**
1631
1716
  * ================================
1632
1717
  * Teams
@@ -1639,25 +1724,25 @@ var index_default = (path5) => {
1639
1724
  * @param options - Optional options to write the team
1640
1725
  *
1641
1726
  */
1642
- writeTeam: writeTeam((0, import_node_path14.join)(path5, "teams")),
1727
+ writeTeam: writeTeam((0, import_node_path15.join)(path5, "teams")),
1643
1728
  /**
1644
1729
  * Returns a team from EventCatalog
1645
1730
  * @param id - The id of the team to retrieve
1646
1731
  * @returns Team|Undefined
1647
1732
  */
1648
- getTeam: getTeam((0, import_node_path14.join)(path5, "teams")),
1733
+ getTeam: getTeam((0, import_node_path15.join)(path5, "teams")),
1649
1734
  /**
1650
1735
  * Returns all teams from EventCatalog
1651
1736
  * @returns Team[]|Undefined
1652
1737
  */
1653
- getTeams: getTeams((0, import_node_path14.join)(path5, "teams")),
1738
+ getTeams: getTeams((0, import_node_path15.join)(path5, "teams")),
1654
1739
  /**
1655
1740
  * Remove a team by the team id
1656
1741
  *
1657
1742
  * @param id - The id of the team you want to remove
1658
1743
  *
1659
1744
  */
1660
- rmTeamById: rmTeamById((0, import_node_path14.join)(path5, "teams")),
1745
+ rmTeamById: rmTeamById((0, import_node_path15.join)(path5, "teams")),
1661
1746
  /**
1662
1747
  * ================================
1663
1748
  * Users
@@ -1670,25 +1755,25 @@ var index_default = (path5) => {
1670
1755
  * @param options - Optional options to write the user
1671
1756
  *
1672
1757
  */
1673
- writeUser: writeUser((0, import_node_path14.join)(path5, "users")),
1758
+ writeUser: writeUser((0, import_node_path15.join)(path5, "users")),
1674
1759
  /**
1675
1760
  * Returns a user from EventCatalog
1676
1761
  * @param id - The id of the user to retrieve
1677
1762
  * @returns User|Undefined
1678
1763
  */
1679
- getUser: getUser((0, import_node_path14.join)(path5, "users")),
1764
+ getUser: getUser((0, import_node_path15.join)(path5, "users")),
1680
1765
  /**
1681
1766
  * Returns all user from EventCatalog
1682
1767
  * @returns User[]|Undefined
1683
1768
  */
1684
- getUsers: getUsers((0, import_node_path14.join)(path5)),
1769
+ getUsers: getUsers((0, import_node_path15.join)(path5)),
1685
1770
  /**
1686
1771
  * Remove a user by the user id
1687
1772
  *
1688
1773
  * @param id - The id of the user you want to remove
1689
1774
  *
1690
1775
  */
1691
- rmUserById: rmUserById((0, import_node_path14.join)(path5, "users")),
1776
+ rmUserById: rmUserById((0, import_node_path15.join)(path5, "users")),
1692
1777
  /**
1693
1778
  * ================================
1694
1779
  * Custom Docs
@@ -1699,32 +1784,32 @@ var index_default = (path5) => {
1699
1784
  * @param path - The path to the custom doc to retrieve
1700
1785
  * @returns CustomDoc|Undefined
1701
1786
  */
1702
- getCustomDoc: getCustomDoc((0, import_node_path14.join)(path5, "docs")),
1787
+ getCustomDoc: getCustomDoc((0, import_node_path15.join)(path5, "docs")),
1703
1788
  /**
1704
1789
  * Returns all custom docs from EventCatalog
1705
1790
  * @param options - Optional options to get custom docs from a specific path
1706
1791
  * @returns CustomDoc[]|Undefined
1707
1792
  */
1708
- getCustomDocs: getCustomDocs((0, import_node_path14.join)(path5, "docs")),
1793
+ getCustomDocs: getCustomDocs((0, import_node_path15.join)(path5, "docs")),
1709
1794
  /**
1710
1795
  * Writes a custom doc to EventCatalog
1711
1796
  * @param customDoc - The custom doc to write
1712
1797
  * @param options - Optional options to write the custom doc
1713
1798
  *
1714
1799
  */
1715
- writeCustomDoc: writeCustomDoc((0, import_node_path14.join)(path5, "docs")),
1800
+ writeCustomDoc: writeCustomDoc((0, import_node_path15.join)(path5, "docs")),
1716
1801
  /**
1717
1802
  * Removes a custom doc from EventCatalog
1718
1803
  * @param path - The path to the custom doc to remove
1719
1804
  *
1720
1805
  */
1721
- rmCustomDoc: rmCustomDoc((0, import_node_path14.join)(path5, "docs")),
1806
+ rmCustomDoc: rmCustomDoc((0, import_node_path15.join)(path5, "docs")),
1722
1807
  /**
1723
1808
  * Dumps the catalog to a JSON file.
1724
1809
  * @param directory - The directory to dump the catalog to
1725
1810
  * @returns A JSON file with the catalog
1726
1811
  */
1727
- dumpCatalog: dumpCatalog((0, import_node_path14.join)(path5)),
1812
+ dumpCatalog: dumpCatalog((0, import_node_path15.join)(path5)),
1728
1813
  /**
1729
1814
  * Returns the event catalog configuration file.
1730
1815
  * The event catalog configuration file is the file that contains the configuration for the event catalog.
@@ -1732,7 +1817,7 @@ var index_default = (path5) => {
1732
1817
  * @param directory - The directory of the catalog.
1733
1818
  * @returns A JSON object with the configuration for the event catalog.
1734
1819
  */
1735
- getEventCatalogConfigurationFile: getEventCatalogConfigurationFile((0, import_node_path14.join)(path5)),
1820
+ getEventCatalogConfigurationFile: getEventCatalogConfigurationFile((0, import_node_path15.join)(path5)),
1736
1821
  /**
1737
1822
  * ================================
1738
1823
  * Resources Utils
@@ -1753,33 +1838,85 @@ var index_default = (path5) => {
1753
1838
  * @param path - The path to the message to retrieve
1754
1839
  * @returns Message|Undefined
1755
1840
  */
1756
- getMessageBySchemaPath: getMessageBySchemaPath((0, import_node_path14.join)(path5)),
1841
+ getMessageBySchemaPath: getMessageBySchemaPath((0, import_node_path15.join)(path5)),
1757
1842
  /**
1758
1843
  * Returns the producers and consumers (services) for a given message
1759
1844
  * @param id - The id of the message to get the producers and consumers for
1760
1845
  * @param version - Optional version of the message
1761
1846
  * @returns { producers: Service[], consumers: Service[] }
1762
1847
  */
1763
- getProducersAndConsumersForMessage: getProducersAndConsumersForMessage((0, import_node_path14.join)(path5)),
1848
+ getProducersAndConsumersForMessage: getProducersAndConsumersForMessage((0, import_node_path15.join)(path5)),
1764
1849
  /**
1765
1850
  * Returns the consumers of a given schema path
1766
1851
  * @param path - The path to the schema to get the consumers for
1767
1852
  * @returns Service[]
1768
1853
  */
1769
- getConsumersOfSchema: getConsumersOfSchema((0, import_node_path14.join)(path5)),
1854
+ getConsumersOfSchema: getConsumersOfSchema((0, import_node_path15.join)(path5)),
1770
1855
  /**
1771
1856
  * Returns the producers of a given schema path
1772
1857
  * @param path - The path to the schema to get the producers for
1773
1858
  * @returns Service[]
1774
1859
  */
1775
- getProducersOfSchema: getProducersOfSchema((0, import_node_path14.join)(path5)),
1860
+ getProducersOfSchema: getProducersOfSchema((0, import_node_path15.join)(path5)),
1776
1861
  /**
1777
1862
  * Returns the owners for a given resource (e.g domain, service, event, command, query, etc.)
1778
1863
  * @param id - The id of the resource to get the owners for
1779
1864
  * @param version - Optional version of the resource
1780
1865
  * @returns { owners: User[] }
1781
1866
  */
1782
- getOwnersForResource: getOwnersForResource((0, import_node_path14.join)(path5))
1867
+ getOwnersForResource: getOwnersForResource((0, import_node_path15.join)(path5)),
1868
+ /**
1869
+ * ================================
1870
+ * Entities
1871
+ * ================================
1872
+ */
1873
+ /**
1874
+ * Returns an entity from EventCatalog
1875
+ * @param id - The id of the entity to retrieve
1876
+ * @param version - Optional id of the version to get (supports semver)
1877
+ * @returns Entity|Undefined
1878
+ */
1879
+ getEntity: getEntity((0, import_node_path15.join)(path5)),
1880
+ /**
1881
+ * Returns all entities from EventCatalog
1882
+ * @param latestOnly - optional boolean, set to true to get only latest versions
1883
+ * @returns Entity[]|Undefined
1884
+ */
1885
+ getEntities: getEntities((0, import_node_path15.join)(path5)),
1886
+ /**
1887
+ * Adds an entity to EventCatalog
1888
+ *
1889
+ * @param entity - The entity to write
1890
+ * @param options - Optional options to write the entity
1891
+ *
1892
+ */
1893
+ writeEntity: writeEntity((0, import_node_path15.join)(path5, "entities")),
1894
+ /**
1895
+ * Remove an entity from EventCatalog (modeled on the standard POSIX rm utility)
1896
+ *
1897
+ * @param path - The path to your entity, e.g. `/User`
1898
+ *
1899
+ */
1900
+ rmEntity: rmEntity((0, import_node_path15.join)(path5, "entities")),
1901
+ /**
1902
+ * Remove an entity by an entity id
1903
+ *
1904
+ * @param id - The id of the entity you want to remove
1905
+ *
1906
+ */
1907
+ rmEntityById: rmEntityById((0, import_node_path15.join)(path5)),
1908
+ /**
1909
+ * Moves a given entity id to the version directory
1910
+ * @param id - The id of the entity to version
1911
+ */
1912
+ versionEntity: versionEntity((0, import_node_path15.join)(path5)),
1913
+ /**
1914
+ * Check to see if an entity version exists
1915
+ * @param id - The id of the entity
1916
+ * @param version - The version of the entity (supports semver)
1917
+ * @returns
1918
+ */
1919
+ entityHasVersion: entityHasVersion((0, import_node_path15.join)(path5))
1783
1920
  };
1784
1921
  };
1785
1922
  //# sourceMappingURL=index.js.map