@eventcatalog/sdk 2.8.0 → 2.8.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.
@@ -1,9 +1,9 @@
1
1
  // src/eventcatalog.ts
2
- import fs11 from "fs";
3
- import path4, { join as join15 } from "path";
2
+ import fs12 from "fs";
3
+ import path4, { join as join16 } from "path";
4
4
 
5
5
  // src/index.ts
6
- import { join as join14 } from "path";
6
+ import { join as join15 } from "path";
7
7
 
8
8
  // src/events.ts
9
9
  import fs2 from "fs/promises";
@@ -996,6 +996,38 @@ var entityHasVersion = (directory) => async (id, version) => {
996
996
  return !!file;
997
997
  };
998
998
 
999
+ // src/containers.ts
1000
+ import fs11 from "fs/promises";
1001
+ import { join as join14 } from "path";
1002
+ var getContainer = (directory) => async (id, version) => getResource(directory, id, version, { type: "container" });
1003
+ var getContainers = (directory) => async (options) => getResources(directory, { type: "containers", latestOnly: options?.latestOnly });
1004
+ var writeContainer = (directory) => async (data, options = {
1005
+ path: "",
1006
+ override: false,
1007
+ format: "mdx"
1008
+ }) => writeResource(directory, { ...data }, { ...options, type: "container" });
1009
+ var versionContainer = (directory) => async (id) => versionResource(directory, id);
1010
+ var rmContainer = (directory) => async (path5) => {
1011
+ await fs11.rm(join14(directory, path5), { recursive: true });
1012
+ };
1013
+ var rmContainerById = (directory) => async (id, version, persistFiles) => {
1014
+ await rmResourceById(directory, id, version, { type: "container", persistFiles });
1015
+ };
1016
+ var containerHasVersion = (directory) => async (id, version) => {
1017
+ const file = await findFileById(directory, id, version);
1018
+ return !!file;
1019
+ };
1020
+ var addFileToContainer = (directory) => async (id, file, version) => addFileToResource(directory, id, file, version);
1021
+ var writeContainerToService = (directory) => async (container, service, options = { path: "", format: "mdx", override: false }) => {
1022
+ const resourcePath = await getResourcePath(directory, service.id, service.version);
1023
+ if (!resourcePath) {
1024
+ throw new Error("Service not found");
1025
+ }
1026
+ let pathForContainer = service.version && service.version !== "latest" ? `${resourcePath.directory}/versioned/${service.version}/containers` : `${resourcePath.directory}/containers`;
1027
+ pathForContainer = join14(pathForContainer, container.id);
1028
+ await writeResource(directory, { ...container }, { ...options, path: pathForContainer, type: "container" });
1029
+ };
1030
+
999
1031
  // src/index.ts
1000
1032
  var index_default = (path5) => {
1001
1033
  return {
@@ -1005,13 +1037,13 @@ var index_default = (path5) => {
1005
1037
  * @param version - Optional id of the version to get (supports semver)
1006
1038
  * @returns Event|Undefined
1007
1039
  */
1008
- getEvent: getEvent(join14(path5)),
1040
+ getEvent: getEvent(join15(path5)),
1009
1041
  /**
1010
1042
  * Returns all events from EventCatalog
1011
1043
  * @param latestOnly - optional boolean, set to true to get only latest versions
1012
1044
  * @returns Event[]|Undefined
1013
1045
  */
1014
- getEvents: getEvents(join14(path5)),
1046
+ getEvents: getEvents(join15(path5)),
1015
1047
  /**
1016
1048
  * Adds an event to EventCatalog
1017
1049
  *
@@ -1019,7 +1051,7 @@ var index_default = (path5) => {
1019
1051
  * @param options - Optional options to write the event
1020
1052
  *
1021
1053
  */
1022
- writeEvent: writeEvent(join14(path5, "events")),
1054
+ writeEvent: writeEvent(join15(path5, "events")),
1023
1055
  /**
1024
1056
  * Adds an event to a service in EventCatalog
1025
1057
  *
@@ -1028,26 +1060,26 @@ var index_default = (path5) => {
1028
1060
  * @param options - Optional options to write the event
1029
1061
  *
1030
1062
  */
1031
- writeEventToService: writeEventToService(join14(path5)),
1063
+ writeEventToService: writeEventToService(join15(path5)),
1032
1064
  /**
1033
1065
  * Remove an event to EventCatalog (modeled on the standard POSIX rm utility)
1034
1066
  *
1035
1067
  * @param path - The path to your event, e.g. `/Inventory/InventoryAdjusted`
1036
1068
  *
1037
1069
  */
1038
- rmEvent: rmEvent(join14(path5, "events")),
1070
+ rmEvent: rmEvent(join15(path5, "events")),
1039
1071
  /**
1040
1072
  * Remove an event by an Event id
1041
1073
  *
1042
1074
  * @param id - The id of the event you want to remove
1043
1075
  *
1044
1076
  */
1045
- rmEventById: rmEventById(join14(path5)),
1077
+ rmEventById: rmEventById(join15(path5)),
1046
1078
  /**
1047
1079
  * Moves a given event id to the version directory
1048
1080
  * @param directory
1049
1081
  */
1050
- versionEvent: versionEvent(join14(path5)),
1082
+ versionEvent: versionEvent(join15(path5)),
1051
1083
  /**
1052
1084
  * Adds a file to the given event
1053
1085
  * @param id - The id of the event to add the file to
@@ -1055,7 +1087,7 @@ var index_default = (path5) => {
1055
1087
  * @param version - Optional version of the event to add the file to
1056
1088
  * @returns
1057
1089
  */
1058
- addFileToEvent: addFileToEvent(join14(path5)),
1090
+ addFileToEvent: addFileToEvent(join15(path5)),
1059
1091
  /**
1060
1092
  * Adds a schema to the given event
1061
1093
  * @param id - The id of the event to add the schema to
@@ -1063,14 +1095,14 @@ var index_default = (path5) => {
1063
1095
  * @param version - Optional version of the event to add the schema to
1064
1096
  * @returns
1065
1097
  */
1066
- addSchemaToEvent: addSchemaToEvent(join14(path5)),
1098
+ addSchemaToEvent: addSchemaToEvent(join15(path5)),
1067
1099
  /**
1068
1100
  * Check to see if an event version exists
1069
1101
  * @param id - The id of the event
1070
1102
  * @param version - The version of the event (supports semver)
1071
1103
  * @returns
1072
1104
  */
1073
- eventHasVersion: eventHasVersion(join14(path5)),
1105
+ eventHasVersion: eventHasVersion(join15(path5)),
1074
1106
  /**
1075
1107
  * ================================
1076
1108
  * Commands
@@ -1082,13 +1114,13 @@ var index_default = (path5) => {
1082
1114
  * @param version - Optional id of the version to get (supports semver)
1083
1115
  * @returns Command|Undefined
1084
1116
  */
1085
- getCommand: getCommand(join14(path5)),
1117
+ getCommand: getCommand(join15(path5)),
1086
1118
  /**
1087
1119
  * Returns all commands from EventCatalog
1088
1120
  * @param latestOnly - optional boolean, set to true to get only latest versions
1089
1121
  * @returns Command[]|Undefined
1090
1122
  */
1091
- getCommands: getCommands(join14(path5)),
1123
+ getCommands: getCommands(join15(path5)),
1092
1124
  /**
1093
1125
  * Adds an command to EventCatalog
1094
1126
  *
@@ -1096,7 +1128,7 @@ var index_default = (path5) => {
1096
1128
  * @param options - Optional options to write the command
1097
1129
  *
1098
1130
  */
1099
- writeCommand: writeCommand(join14(path5, "commands")),
1131
+ writeCommand: writeCommand(join15(path5, "commands")),
1100
1132
  /**
1101
1133
  * Adds a command to a service in EventCatalog
1102
1134
  *
@@ -1105,26 +1137,26 @@ var index_default = (path5) => {
1105
1137
  * @param options - Optional options to write the command
1106
1138
  *
1107
1139
  */
1108
- writeCommandToService: writeCommandToService(join14(path5)),
1140
+ writeCommandToService: writeCommandToService(join15(path5)),
1109
1141
  /**
1110
1142
  * Remove an command to EventCatalog (modeled on the standard POSIX rm utility)
1111
1143
  *
1112
1144
  * @param path - The path to your command, e.g. `/Inventory/InventoryAdjusted`
1113
1145
  *
1114
1146
  */
1115
- rmCommand: rmCommand(join14(path5, "commands")),
1147
+ rmCommand: rmCommand(join15(path5, "commands")),
1116
1148
  /**
1117
1149
  * Remove an command by an Event id
1118
1150
  *
1119
1151
  * @param id - The id of the command you want to remove
1120
1152
  *
1121
1153
  */
1122
- rmCommandById: rmCommandById(join14(path5)),
1154
+ rmCommandById: rmCommandById(join15(path5)),
1123
1155
  /**
1124
1156
  * Moves a given command id to the version directory
1125
1157
  * @param directory
1126
1158
  */
1127
- versionCommand: versionCommand(join14(path5)),
1159
+ versionCommand: versionCommand(join15(path5)),
1128
1160
  /**
1129
1161
  * Adds a file to the given command
1130
1162
  * @param id - The id of the command to add the file to
@@ -1132,7 +1164,7 @@ var index_default = (path5) => {
1132
1164
  * @param version - Optional version of the command to add the file to
1133
1165
  * @returns
1134
1166
  */
1135
- addFileToCommand: addFileToCommand(join14(path5)),
1167
+ addFileToCommand: addFileToCommand(join15(path5)),
1136
1168
  /**
1137
1169
  * Adds a schema to the given command
1138
1170
  * @param id - The id of the command to add the schema to
@@ -1140,14 +1172,14 @@ var index_default = (path5) => {
1140
1172
  * @param version - Optional version of the command to add the schema to
1141
1173
  * @returns
1142
1174
  */
1143
- addSchemaToCommand: addSchemaToCommand(join14(path5)),
1175
+ addSchemaToCommand: addSchemaToCommand(join15(path5)),
1144
1176
  /**
1145
1177
  * Check to see if a command version exists
1146
1178
  * @param id - The id of the command
1147
1179
  * @param version - The version of the command (supports semver)
1148
1180
  * @returns
1149
1181
  */
1150
- commandHasVersion: commandHasVersion(join14(path5)),
1182
+ commandHasVersion: commandHasVersion(join15(path5)),
1151
1183
  /**
1152
1184
  * ================================
1153
1185
  * Queries
@@ -1159,13 +1191,13 @@ var index_default = (path5) => {
1159
1191
  * @param version - Optional id of the version to get (supports semver)
1160
1192
  * @returns Query|Undefined
1161
1193
  */
1162
- getQuery: getQuery(join14(path5)),
1194
+ getQuery: getQuery(join15(path5)),
1163
1195
  /**
1164
1196
  * Returns all queries from EventCatalog
1165
1197
  * @param latestOnly - optional boolean, set to true to get only latest versions
1166
1198
  * @returns Query[]|Undefined
1167
1199
  */
1168
- getQueries: getQueries(join14(path5)),
1200
+ getQueries: getQueries(join15(path5)),
1169
1201
  /**
1170
1202
  * Adds a query to EventCatalog
1171
1203
  *
@@ -1173,7 +1205,7 @@ var index_default = (path5) => {
1173
1205
  * @param options - Optional options to write the event
1174
1206
  *
1175
1207
  */
1176
- writeQuery: writeQuery(join14(path5, "queries")),
1208
+ writeQuery: writeQuery(join15(path5, "queries")),
1177
1209
  /**
1178
1210
  * Adds a query to a service in EventCatalog
1179
1211
  *
@@ -1182,26 +1214,26 @@ var index_default = (path5) => {
1182
1214
  * @param options - Optional options to write the query
1183
1215
  *
1184
1216
  */
1185
- writeQueryToService: writeQueryToService(join14(path5)),
1217
+ writeQueryToService: writeQueryToService(join15(path5)),
1186
1218
  /**
1187
1219
  * Remove an query to EventCatalog (modeled on the standard POSIX rm utility)
1188
1220
  *
1189
1221
  * @param path - The path to your query, e.g. `/Orders/GetOrder`
1190
1222
  *
1191
1223
  */
1192
- rmQuery: rmQuery(join14(path5, "queries")),
1224
+ rmQuery: rmQuery(join15(path5, "queries")),
1193
1225
  /**
1194
1226
  * Remove a query by a Query id
1195
1227
  *
1196
1228
  * @param id - The id of the query you want to remove
1197
1229
  *
1198
1230
  */
1199
- rmQueryById: rmQueryById(join14(path5)),
1231
+ rmQueryById: rmQueryById(join15(path5)),
1200
1232
  /**
1201
1233
  * Moves a given query id to the version directory
1202
1234
  * @param directory
1203
1235
  */
1204
- versionQuery: versionQuery(join14(path5)),
1236
+ versionQuery: versionQuery(join15(path5)),
1205
1237
  /**
1206
1238
  * Adds a file to the given query
1207
1239
  * @param id - The id of the query to add the file to
@@ -1209,7 +1241,7 @@ var index_default = (path5) => {
1209
1241
  * @param version - Optional version of the query to add the file to
1210
1242
  * @returns
1211
1243
  */
1212
- addFileToQuery: addFileToQuery(join14(path5)),
1244
+ addFileToQuery: addFileToQuery(join15(path5)),
1213
1245
  /**
1214
1246
  * Adds a schema to the given query
1215
1247
  * @param id - The id of the query to add the schema to
@@ -1217,14 +1249,14 @@ var index_default = (path5) => {
1217
1249
  * @param version - Optional version of the query to add the schema to
1218
1250
  * @returns
1219
1251
  */
1220
- addSchemaToQuery: addSchemaToQuery(join14(path5)),
1252
+ addSchemaToQuery: addSchemaToQuery(join15(path5)),
1221
1253
  /**
1222
1254
  * Check to see if an query version exists
1223
1255
  * @param id - The id of the query
1224
1256
  * @param version - The version of the query (supports semver)
1225
1257
  * @returns
1226
1258
  */
1227
- queryHasVersion: queryHasVersion(join14(path5)),
1259
+ queryHasVersion: queryHasVersion(join15(path5)),
1228
1260
  /**
1229
1261
  * ================================
1230
1262
  * Channels
@@ -1236,13 +1268,13 @@ var index_default = (path5) => {
1236
1268
  * @param version - Optional id of the version to get (supports semver)
1237
1269
  * @returns Channel|Undefined
1238
1270
  */
1239
- getChannel: getChannel(join14(path5)),
1271
+ getChannel: getChannel(join15(path5)),
1240
1272
  /**
1241
1273
  * Returns all channels from EventCatalog
1242
1274
  * @param latestOnly - optional boolean, set to true to get only latest versions
1243
1275
  * @returns Channel[]|Undefined
1244
1276
  */
1245
- getChannels: getChannels(join14(path5)),
1277
+ getChannels: getChannels(join15(path5)),
1246
1278
  /**
1247
1279
  * Adds an channel to EventCatalog
1248
1280
  *
@@ -1250,33 +1282,33 @@ var index_default = (path5) => {
1250
1282
  * @param options - Optional options to write the channel
1251
1283
  *
1252
1284
  */
1253
- writeChannel: writeChannel(join14(path5, "channels")),
1285
+ writeChannel: writeChannel(join15(path5, "channels")),
1254
1286
  /**
1255
1287
  * Remove an channel to EventCatalog (modeled on the standard POSIX rm utility)
1256
1288
  *
1257
1289
  * @param path - The path to your channel, e.g. `/Inventory/InventoryAdjusted`
1258
1290
  *
1259
1291
  */
1260
- rmChannel: rmChannel(join14(path5, "channels")),
1292
+ rmChannel: rmChannel(join15(path5, "channels")),
1261
1293
  /**
1262
1294
  * Remove an channel by an Event id
1263
1295
  *
1264
1296
  * @param id - The id of the channel you want to remove
1265
1297
  *
1266
1298
  */
1267
- rmChannelById: rmChannelById(join14(path5)),
1299
+ rmChannelById: rmChannelById(join15(path5)),
1268
1300
  /**
1269
1301
  * Moves a given channel id to the version directory
1270
1302
  * @param directory
1271
1303
  */
1272
- versionChannel: versionChannel(join14(path5)),
1304
+ versionChannel: versionChannel(join15(path5)),
1273
1305
  /**
1274
1306
  * Check to see if a channel version exists
1275
1307
  * @param id - The id of the channel
1276
1308
  * @param version - The version of the channel (supports semver)
1277
1309
  * @returns
1278
1310
  */
1279
- channelHasVersion: channelHasVersion(join14(path5)),
1311
+ channelHasVersion: channelHasVersion(join15(path5)),
1280
1312
  /**
1281
1313
  * Add a channel to an event
1282
1314
  *
@@ -1293,7 +1325,7 @@ var index_default = (path5) => {
1293
1325
  *
1294
1326
  * ```
1295
1327
  */
1296
- addEventToChannel: addMessageToChannel(join14(path5), "events"),
1328
+ addEventToChannel: addMessageToChannel(join15(path5), "events"),
1297
1329
  /**
1298
1330
  * Add a channel to an command
1299
1331
  *
@@ -1310,7 +1342,7 @@ var index_default = (path5) => {
1310
1342
  *
1311
1343
  * ```
1312
1344
  */
1313
- addCommandToChannel: addMessageToChannel(join14(path5), "commands"),
1345
+ addCommandToChannel: addMessageToChannel(join15(path5), "commands"),
1314
1346
  /**
1315
1347
  * Add a channel to an query
1316
1348
  *
@@ -1327,7 +1359,7 @@ var index_default = (path5) => {
1327
1359
  *
1328
1360
  * ```
1329
1361
  */
1330
- addQueryToChannel: addMessageToChannel(join14(path5), "queries"),
1362
+ addQueryToChannel: addMessageToChannel(join15(path5), "queries"),
1331
1363
  /**
1332
1364
  * ================================
1333
1365
  * SERVICES
@@ -1340,14 +1372,14 @@ var index_default = (path5) => {
1340
1372
  * @param options - Optional options to write the event
1341
1373
  *
1342
1374
  */
1343
- writeService: writeService(join14(path5, "services")),
1375
+ writeService: writeService(join15(path5, "services")),
1344
1376
  /**
1345
1377
  * Adds a versioned service to EventCatalog
1346
1378
  *
1347
1379
  * @param service - The service to write
1348
1380
  *
1349
1381
  */
1350
- writeVersionedService: writeVersionedService(join14(path5, "services")),
1382
+ writeVersionedService: writeVersionedService(join15(path5, "services")),
1351
1383
  /**
1352
1384
  * Adds a service to a domain in EventCatalog
1353
1385
  *
@@ -1356,45 +1388,45 @@ var index_default = (path5) => {
1356
1388
  * @param options - Optional options to write the event
1357
1389
  *
1358
1390
  */
1359
- writeServiceToDomain: writeServiceToDomain(join14(path5, "domains")),
1391
+ writeServiceToDomain: writeServiceToDomain(join15(path5, "domains")),
1360
1392
  /**
1361
1393
  * Returns a service from EventCatalog
1362
1394
  * @param id - The id of the service to retrieve
1363
1395
  * @param version - Optional id of the version to get (supports semver)
1364
1396
  * @returns Service|Undefined
1365
1397
  */
1366
- getService: getService(join14(path5)),
1398
+ getService: getService(join15(path5)),
1367
1399
  /**
1368
1400
  * Returns a service from EventCatalog by it's path.
1369
1401
  * @param path - The path to the service to retrieve
1370
1402
  * @returns Service|Undefined
1371
1403
  */
1372
- getServiceByPath: getServiceByPath(join14(path5)),
1404
+ getServiceByPath: getServiceByPath(join15(path5)),
1373
1405
  /**
1374
1406
  * Returns all services from EventCatalog
1375
1407
  * @param latestOnly - optional boolean, set to true to get only latest versions
1376
1408
  * @returns Service[]|Undefined
1377
1409
  */
1378
- getServices: getServices(join14(path5)),
1410
+ getServices: getServices(join15(path5)),
1379
1411
  /**
1380
1412
  * Moves a given service id to the version directory
1381
1413
  * @param directory
1382
1414
  */
1383
- versionService: versionService(join14(path5)),
1415
+ versionService: versionService(join15(path5)),
1384
1416
  /**
1385
1417
  * Remove a service from EventCatalog (modeled on the standard POSIX rm utility)
1386
1418
  *
1387
1419
  * @param path - The path to your service, e.g. `/InventoryService`
1388
1420
  *
1389
1421
  */
1390
- rmService: rmService(join14(path5, "services")),
1422
+ rmService: rmService(join15(path5, "services")),
1391
1423
  /**
1392
1424
  * Remove an service by an service id
1393
1425
  *
1394
1426
  * @param id - The id of the service you want to remove
1395
1427
  *
1396
1428
  */
1397
- rmServiceById: rmServiceById(join14(path5)),
1429
+ rmServiceById: rmServiceById(join15(path5)),
1398
1430
  /**
1399
1431
  * Adds a file to the given service
1400
1432
  * @param id - The id of the service to add the file to
@@ -1402,21 +1434,21 @@ var index_default = (path5) => {
1402
1434
  * @param version - Optional version of the service to add the file to
1403
1435
  * @returns
1404
1436
  */
1405
- addFileToService: addFileToService(join14(path5)),
1437
+ addFileToService: addFileToService(join15(path5)),
1406
1438
  /**
1407
1439
  * Returns the specifications for a given service
1408
1440
  * @param id - The id of the service to retrieve the specifications for
1409
1441
  * @param version - Optional version of the service
1410
1442
  * @returns
1411
1443
  */
1412
- getSpecificationFilesForService: getSpecificationFilesForService(join14(path5)),
1444
+ getSpecificationFilesForService: getSpecificationFilesForService(join15(path5)),
1413
1445
  /**
1414
1446
  * Check to see if a service version exists
1415
1447
  * @param id - The id of the service
1416
1448
  * @param version - The version of the service (supports semver)
1417
1449
  * @returns
1418
1450
  */
1419
- serviceHasVersion: serviceHasVersion(join14(path5)),
1451
+ serviceHasVersion: serviceHasVersion(join15(path5)),
1420
1452
  /**
1421
1453
  * Add an event to a service by it's id.
1422
1454
  *
@@ -1436,7 +1468,7 @@ var index_default = (path5) => {
1436
1468
  *
1437
1469
  * ```
1438
1470
  */
1439
- addEventToService: addMessageToService(join14(path5)),
1471
+ addEventToService: addMessageToService(join15(path5)),
1440
1472
  /**
1441
1473
  * Add a command to a service by it's id.
1442
1474
  *
@@ -1456,7 +1488,7 @@ var index_default = (path5) => {
1456
1488
  *
1457
1489
  * ```
1458
1490
  */
1459
- addCommandToService: addMessageToService(join14(path5)),
1491
+ addCommandToService: addMessageToService(join15(path5)),
1460
1492
  /**
1461
1493
  * Add a query to a service by it's id.
1462
1494
  *
@@ -1476,7 +1508,7 @@ var index_default = (path5) => {
1476
1508
  *
1477
1509
  * ```
1478
1510
  */
1479
- addQueryToService: addMessageToService(join14(path5)),
1511
+ addQueryToService: addMessageToService(join15(path5)),
1480
1512
  /**
1481
1513
  * Add an entity to a service by its id.
1482
1514
  *
@@ -1494,7 +1526,7 @@ var index_default = (path5) => {
1494
1526
  *
1495
1527
  * ```
1496
1528
  */
1497
- addEntityToService: addEntityToService(join14(path5)),
1529
+ addEntityToService: addEntityToService(join15(path5)),
1498
1530
  /**
1499
1531
  * Check to see if a service exists by it's path.
1500
1532
  *
@@ -1511,13 +1543,13 @@ var index_default = (path5) => {
1511
1543
  * @param path - The path to the service to check
1512
1544
  * @returns boolean
1513
1545
  */
1514
- isService: isService(join14(path5)),
1546
+ isService: isService(join15(path5)),
1515
1547
  /**
1516
1548
  * Converts a file to a service.
1517
1549
  * @param file - The file to convert to a service.
1518
1550
  * @returns The service.
1519
1551
  */
1520
- toService: toService(join14(path5)),
1552
+ toService: toService(join15(path5)),
1521
1553
  /**
1522
1554
  * ================================
1523
1555
  * Domains
@@ -1530,39 +1562,39 @@ var index_default = (path5) => {
1530
1562
  * @param options - Optional options to write the event
1531
1563
  *
1532
1564
  */
1533
- writeDomain: writeDomain(join14(path5, "domains")),
1565
+ writeDomain: writeDomain(join15(path5, "domains")),
1534
1566
  /**
1535
1567
  * Returns a domain from EventCatalog
1536
1568
  * @param id - The id of the domain to retrieve
1537
1569
  * @param version - Optional id of the version to get (supports semver)
1538
1570
  * @returns Domain|Undefined
1539
1571
  */
1540
- getDomain: getDomain(join14(path5, "domains")),
1572
+ getDomain: getDomain(join15(path5, "domains")),
1541
1573
  /**
1542
1574
  * Returns all domains from EventCatalog
1543
1575
  * @param latestOnly - optional boolean, set to true to get only latest versions
1544
1576
  * @returns Domain[]|Undefined
1545
1577
  */
1546
- getDomains: getDomains(join14(path5)),
1578
+ getDomains: getDomains(join15(path5)),
1547
1579
  /**
1548
1580
  * Moves a given domain id to the version directory
1549
1581
  * @param directory
1550
1582
  */
1551
- versionDomain: versionDomain(join14(path5, "domains")),
1583
+ versionDomain: versionDomain(join15(path5, "domains")),
1552
1584
  /**
1553
1585
  * Remove a domain from EventCatalog (modeled on the standard POSIX rm utility)
1554
1586
  *
1555
1587
  * @param path - The path to your domain, e.g. `/Payment`
1556
1588
  *
1557
1589
  */
1558
- rmDomain: rmDomain(join14(path5, "domains")),
1590
+ rmDomain: rmDomain(join15(path5, "domains")),
1559
1591
  /**
1560
1592
  * Remove an service by an domain id
1561
1593
  *
1562
1594
  * @param id - The id of the domain you want to remove
1563
1595
  *
1564
1596
  */
1565
- rmDomainById: rmDomainById(join14(path5, "domains")),
1597
+ rmDomainById: rmDomainById(join15(path5, "domains")),
1566
1598
  /**
1567
1599
  * Adds a file to the given domain
1568
1600
  * @param id - The id of the domain to add the file to
@@ -1570,28 +1602,28 @@ var index_default = (path5) => {
1570
1602
  * @param version - Optional version of the domain to add the file to
1571
1603
  * @returns
1572
1604
  */
1573
- addFileToDomain: addFileToDomain(join14(path5, "domains")),
1605
+ addFileToDomain: addFileToDomain(join15(path5, "domains")),
1574
1606
  /**
1575
1607
  * Adds an ubiquitous language dictionary to a domain
1576
1608
  * @param id - The id of the domain to add the ubiquitous language to
1577
1609
  * @param ubiquitousLanguageDictionary - The ubiquitous language dictionary to add
1578
1610
  * @param version - Optional version of the domain to add the ubiquitous language to
1579
1611
  */
1580
- addUbiquitousLanguageToDomain: addUbiquitousLanguageToDomain(join14(path5, "domains")),
1612
+ addUbiquitousLanguageToDomain: addUbiquitousLanguageToDomain(join15(path5, "domains")),
1581
1613
  /**
1582
1614
  * Get the ubiquitous language dictionary from a domain
1583
1615
  * @param id - The id of the domain to get the ubiquitous language from
1584
1616
  * @param version - Optional version of the domain to get the ubiquitous language from
1585
1617
  * @returns
1586
1618
  */
1587
- getUbiquitousLanguageFromDomain: getUbiquitousLanguageFromDomain(join14(path5, "domains")),
1619
+ getUbiquitousLanguageFromDomain: getUbiquitousLanguageFromDomain(join15(path5, "domains")),
1588
1620
  /**
1589
1621
  * Check to see if a domain version exists
1590
1622
  * @param id - The id of the domain
1591
1623
  * @param version - The version of the domain (supports semver)
1592
1624
  * @returns
1593
1625
  */
1594
- domainHasVersion: domainHasVersion(join14(path5)),
1626
+ domainHasVersion: domainHasVersion(join15(path5)),
1595
1627
  /**
1596
1628
  * Adds a given service to a domain
1597
1629
  * @param id - The id of the domain
@@ -1599,7 +1631,7 @@ var index_default = (path5) => {
1599
1631
  * @param version - (Optional) The version of the domain to add the service to
1600
1632
  * @returns
1601
1633
  */
1602
- addServiceToDomain: addServiceToDomain(join14(path5, "domains")),
1634
+ addServiceToDomain: addServiceToDomain(join15(path5, "domains")),
1603
1635
  /**
1604
1636
  * Adds a given subdomain to a domain
1605
1637
  * @param id - The id of the domain
@@ -1607,7 +1639,7 @@ var index_default = (path5) => {
1607
1639
  * @param version - (Optional) The version of the domain to add the subdomain to
1608
1640
  * @returns
1609
1641
  */
1610
- addSubDomainToDomain: addSubDomainToDomain(join14(path5, "domains")),
1642
+ addSubDomainToDomain: addSubDomainToDomain(join15(path5, "domains")),
1611
1643
  /**
1612
1644
  * Adds an entity to a domain
1613
1645
  * @param id - The id of the domain
@@ -1615,7 +1647,7 @@ var index_default = (path5) => {
1615
1647
  * @param version - (Optional) The version of the domain to add the entity to
1616
1648
  * @returns
1617
1649
  */
1618
- addEntityToDomain: addEntityToDomain(join14(path5, "domains")),
1650
+ addEntityToDomain: addEntityToDomain(join15(path5, "domains")),
1619
1651
  /**
1620
1652
  * ================================
1621
1653
  * Teams
@@ -1628,25 +1660,25 @@ var index_default = (path5) => {
1628
1660
  * @param options - Optional options to write the team
1629
1661
  *
1630
1662
  */
1631
- writeTeam: writeTeam(join14(path5, "teams")),
1663
+ writeTeam: writeTeam(join15(path5, "teams")),
1632
1664
  /**
1633
1665
  * Returns a team from EventCatalog
1634
1666
  * @param id - The id of the team to retrieve
1635
1667
  * @returns Team|Undefined
1636
1668
  */
1637
- getTeam: getTeam(join14(path5, "teams")),
1669
+ getTeam: getTeam(join15(path5, "teams")),
1638
1670
  /**
1639
1671
  * Returns all teams from EventCatalog
1640
1672
  * @returns Team[]|Undefined
1641
1673
  */
1642
- getTeams: getTeams(join14(path5, "teams")),
1674
+ getTeams: getTeams(join15(path5, "teams")),
1643
1675
  /**
1644
1676
  * Remove a team by the team id
1645
1677
  *
1646
1678
  * @param id - The id of the team you want to remove
1647
1679
  *
1648
1680
  */
1649
- rmTeamById: rmTeamById(join14(path5, "teams")),
1681
+ rmTeamById: rmTeamById(join15(path5, "teams")),
1650
1682
  /**
1651
1683
  * ================================
1652
1684
  * Users
@@ -1659,25 +1691,25 @@ var index_default = (path5) => {
1659
1691
  * @param options - Optional options to write the user
1660
1692
  *
1661
1693
  */
1662
- writeUser: writeUser(join14(path5, "users")),
1694
+ writeUser: writeUser(join15(path5, "users")),
1663
1695
  /**
1664
1696
  * Returns a user from EventCatalog
1665
1697
  * @param id - The id of the user to retrieve
1666
1698
  * @returns User|Undefined
1667
1699
  */
1668
- getUser: getUser(join14(path5, "users")),
1700
+ getUser: getUser(join15(path5, "users")),
1669
1701
  /**
1670
1702
  * Returns all user from EventCatalog
1671
1703
  * @returns User[]|Undefined
1672
1704
  */
1673
- getUsers: getUsers(join14(path5)),
1705
+ getUsers: getUsers(join15(path5)),
1674
1706
  /**
1675
1707
  * Remove a user by the user id
1676
1708
  *
1677
1709
  * @param id - The id of the user you want to remove
1678
1710
  *
1679
1711
  */
1680
- rmUserById: rmUserById(join14(path5, "users")),
1712
+ rmUserById: rmUserById(join15(path5, "users")),
1681
1713
  /**
1682
1714
  * ================================
1683
1715
  * Custom Docs
@@ -1688,32 +1720,32 @@ var index_default = (path5) => {
1688
1720
  * @param path - The path to the custom doc to retrieve
1689
1721
  * @returns CustomDoc|Undefined
1690
1722
  */
1691
- getCustomDoc: getCustomDoc(join14(path5, "docs")),
1723
+ getCustomDoc: getCustomDoc(join15(path5, "docs")),
1692
1724
  /**
1693
1725
  * Returns all custom docs from EventCatalog
1694
1726
  * @param options - Optional options to get custom docs from a specific path
1695
1727
  * @returns CustomDoc[]|Undefined
1696
1728
  */
1697
- getCustomDocs: getCustomDocs(join14(path5, "docs")),
1729
+ getCustomDocs: getCustomDocs(join15(path5, "docs")),
1698
1730
  /**
1699
1731
  * Writes a custom doc to EventCatalog
1700
1732
  * @param customDoc - The custom doc to write
1701
1733
  * @param options - Optional options to write the custom doc
1702
1734
  *
1703
1735
  */
1704
- writeCustomDoc: writeCustomDoc(join14(path5, "docs")),
1736
+ writeCustomDoc: writeCustomDoc(join15(path5, "docs")),
1705
1737
  /**
1706
1738
  * Removes a custom doc from EventCatalog
1707
1739
  * @param path - The path to the custom doc to remove
1708
1740
  *
1709
1741
  */
1710
- rmCustomDoc: rmCustomDoc(join14(path5, "docs")),
1742
+ rmCustomDoc: rmCustomDoc(join15(path5, "docs")),
1711
1743
  /**
1712
1744
  * Dumps the catalog to a JSON file.
1713
1745
  * @param directory - The directory to dump the catalog to
1714
1746
  * @returns A JSON file with the catalog
1715
1747
  */
1716
- dumpCatalog: dumpCatalog(join14(path5)),
1748
+ dumpCatalog: dumpCatalog(join15(path5)),
1717
1749
  /**
1718
1750
  * Returns the event catalog configuration file.
1719
1751
  * The event catalog configuration file is the file that contains the configuration for the event catalog.
@@ -1721,7 +1753,7 @@ var index_default = (path5) => {
1721
1753
  * @param directory - The directory of the catalog.
1722
1754
  * @returns A JSON object with the configuration for the event catalog.
1723
1755
  */
1724
- getEventCatalogConfigurationFile: getEventCatalogConfigurationFile(join14(path5)),
1756
+ getEventCatalogConfigurationFile: getEventCatalogConfigurationFile(join15(path5)),
1725
1757
  /**
1726
1758
  * ================================
1727
1759
  * Resources Utils
@@ -1742,33 +1774,33 @@ var index_default = (path5) => {
1742
1774
  * @param path - The path to the message to retrieve
1743
1775
  * @returns Message|Undefined
1744
1776
  */
1745
- getMessageBySchemaPath: getMessageBySchemaPath(join14(path5)),
1777
+ getMessageBySchemaPath: getMessageBySchemaPath(join15(path5)),
1746
1778
  /**
1747
1779
  * Returns the producers and consumers (services) for a given message
1748
1780
  * @param id - The id of the message to get the producers and consumers for
1749
1781
  * @param version - Optional version of the message
1750
1782
  * @returns { producers: Service[], consumers: Service[] }
1751
1783
  */
1752
- getProducersAndConsumersForMessage: getProducersAndConsumersForMessage(join14(path5)),
1784
+ getProducersAndConsumersForMessage: getProducersAndConsumersForMessage(join15(path5)),
1753
1785
  /**
1754
1786
  * Returns the consumers of a given schema path
1755
1787
  * @param path - The path to the schema to get the consumers for
1756
1788
  * @returns Service[]
1757
1789
  */
1758
- getConsumersOfSchema: getConsumersOfSchema(join14(path5)),
1790
+ getConsumersOfSchema: getConsumersOfSchema(join15(path5)),
1759
1791
  /**
1760
1792
  * Returns the producers of a given schema path
1761
1793
  * @param path - The path to the schema to get the producers for
1762
1794
  * @returns Service[]
1763
1795
  */
1764
- getProducersOfSchema: getProducersOfSchema(join14(path5)),
1796
+ getProducersOfSchema: getProducersOfSchema(join15(path5)),
1765
1797
  /**
1766
1798
  * Returns the owners for a given resource (e.g domain, service, event, command, query, etc.)
1767
1799
  * @param id - The id of the resource to get the owners for
1768
1800
  * @param version - Optional version of the resource
1769
1801
  * @returns { owners: User[] }
1770
1802
  */
1771
- getOwnersForResource: getOwnersForResource(join14(path5)),
1803
+ getOwnersForResource: getOwnersForResource(join15(path5)),
1772
1804
  /**
1773
1805
  * ================================
1774
1806
  * Entities
@@ -1780,13 +1812,13 @@ var index_default = (path5) => {
1780
1812
  * @param version - Optional id of the version to get (supports semver)
1781
1813
  * @returns Entity|Undefined
1782
1814
  */
1783
- getEntity: getEntity(join14(path5)),
1815
+ getEntity: getEntity(join15(path5)),
1784
1816
  /**
1785
1817
  * Returns all entities from EventCatalog
1786
1818
  * @param latestOnly - optional boolean, set to true to get only latest versions
1787
1819
  * @returns Entity[]|Undefined
1788
1820
  */
1789
- getEntities: getEntities(join14(path5)),
1821
+ getEntities: getEntities(join15(path5)),
1790
1822
  /**
1791
1823
  * Adds an entity to EventCatalog
1792
1824
  *
@@ -1794,33 +1826,95 @@ var index_default = (path5) => {
1794
1826
  * @param options - Optional options to write the entity
1795
1827
  *
1796
1828
  */
1797
- writeEntity: writeEntity(join14(path5, "entities")),
1829
+ writeEntity: writeEntity(join15(path5, "entities")),
1798
1830
  /**
1799
1831
  * Remove an entity from EventCatalog (modeled on the standard POSIX rm utility)
1800
1832
  *
1801
1833
  * @param path - The path to your entity, e.g. `/User`
1802
1834
  *
1803
1835
  */
1804
- rmEntity: rmEntity(join14(path5, "entities")),
1836
+ rmEntity: rmEntity(join15(path5, "entities")),
1805
1837
  /**
1806
1838
  * Remove an entity by an entity id
1807
1839
  *
1808
1840
  * @param id - The id of the entity you want to remove
1809
1841
  *
1810
1842
  */
1811
- rmEntityById: rmEntityById(join14(path5)),
1843
+ rmEntityById: rmEntityById(join15(path5)),
1812
1844
  /**
1813
1845
  * Moves a given entity id to the version directory
1814
1846
  * @param id - The id of the entity to version
1815
1847
  */
1816
- versionEntity: versionEntity(join14(path5)),
1848
+ versionEntity: versionEntity(join15(path5)),
1817
1849
  /**
1818
1850
  * Check to see if an entity version exists
1819
1851
  * @param id - The id of the entity
1820
1852
  * @param version - The version of the entity (supports semver)
1821
1853
  * @returns
1822
1854
  */
1823
- entityHasVersion: entityHasVersion(join14(path5))
1855
+ entityHasVersion: entityHasVersion(join15(path5)),
1856
+ /**
1857
+ * ================================
1858
+ * Data Stores
1859
+ * ================================
1860
+ */
1861
+ /**
1862
+ * Adds a data store to EventCatalog
1863
+ * @param dataStore - The data store to write
1864
+ * @param options - Optional options to write the data store
1865
+ *
1866
+ */
1867
+ writeDataStore: writeContainer(join15(path5, "containers")),
1868
+ /**
1869
+ * Returns a container from EventCatalog
1870
+ * @param id - The id of the container to retrieve
1871
+ * @param version - Optional id of the version to get (supports semver)
1872
+ * @returns Container|Undefined
1873
+ */
1874
+ getDataStore: getContainer(join15(path5)),
1875
+ /**
1876
+ * Returns all data stores from EventCatalog
1877
+ * @param latestOnly - optional boolean, set to true to get only latest versions
1878
+ * @returns Container[]|Undefined
1879
+ */
1880
+ getDataStores: getContainers(join15(path5)),
1881
+ /**
1882
+ * Version a data store by its id
1883
+ * @param id - The id of the data store to version
1884
+ */
1885
+ versionDataStore: versionContainer(join15(path5, "containers")),
1886
+ /**
1887
+ * Remove a data store by its path
1888
+ * @param path - The path to the data store to remove
1889
+ */
1890
+ rmDataStore: rmContainer(join15(path5, "containers")),
1891
+ /**
1892
+ * Remove a data store by its id
1893
+ * @param id - The id of the data store to remove
1894
+ */
1895
+ rmDataStoreById: rmContainerById(join15(path5)),
1896
+ /**
1897
+ * Check to see if a data store version exists
1898
+ * @param id - The id of the data store
1899
+ * @param version - The version of the data store (supports semver)
1900
+ * @returns
1901
+ */
1902
+ dataStoreHasVersion: containerHasVersion(join15(path5)),
1903
+ /**
1904
+ * Adds a file to a data store by its id
1905
+ * @param id - The id of the data store to add the file to
1906
+ * @param file - File contents to add including the content and the file name
1907
+ * @param version - Optional version of the data store to add the file to
1908
+ * @returns
1909
+ */
1910
+ addFileToDataStore: addFileToContainer(join15(path5)),
1911
+ /**
1912
+ * Writes a data store to a service by its id
1913
+ * @param dataStore - The data store to write
1914
+ * @param service - The service to write the data store to
1915
+ * @returns
1916
+ */
1917
+ writeDataStoreToService: writeContainerToService(join15(path5))
1824
1918
  };
1825
1919
  };
1826
1920
 
@@ -1828,7 +1922,7 @@ var index_default = (path5) => {
1828
1922
  var DUMP_VERSION = "0.0.1";
1829
1923
  var getEventCatalogVersion = async (catalogDir) => {
1830
1924
  try {
1831
- const packageJson = fs11.readFileSync(join15(catalogDir, "package.json"), "utf8");
1925
+ const packageJson = fs12.readFileSync(join16(catalogDir, "package.json"), "utf8");
1832
1926
  const packageJsonObject = JSON.parse(packageJson);
1833
1927
  return packageJsonObject["dependencies"]["@eventcatalog/core"];
1834
1928
  } catch (error) {
@@ -1842,8 +1936,8 @@ var hydrateResource = async (catalogDir, resources = [], { attachSchema = false
1842
1936
  let schema = "";
1843
1937
  if (resource.schemaPath && resourcePath?.fullPath) {
1844
1938
  const pathToSchema = path4.join(path4.dirname(resourcePath?.fullPath), resource.schemaPath);
1845
- if (fs11.existsSync(pathToSchema)) {
1846
- schema = fs11.readFileSync(pathToSchema, "utf8");
1939
+ if (fs12.existsSync(pathToSchema)) {
1940
+ schema = fs12.readFileSync(pathToSchema, "utf8");
1847
1941
  }
1848
1942
  }
1849
1943
  const eventcatalog = schema ? { directory: resourcePath?.directory, schema } : { directory: resourcePath?.directory };
@@ -1862,7 +1956,7 @@ var filterCollection = (collection, options) => {
1862
1956
  };
1863
1957
  var getEventCatalogConfigurationFile = (directory) => async () => {
1864
1958
  try {
1865
- const path5 = join15(directory, "eventcatalog.config.js");
1959
+ const path5 = join16(directory, "eventcatalog.config.js");
1866
1960
  const configModule = await import(path5);
1867
1961
  return configModule.default;
1868
1962
  } catch (error) {