@eventcatalog/sdk 2.8.1 → 2.8.3
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/data-stores.d.mts +179 -0
- package/dist/data-stores.d.ts +179 -0
- package/dist/data-stores.js +387 -0
- package/dist/data-stores.js.map +1 -0
- package/dist/data-stores.mjs +342 -0
- package/dist/data-stores.mjs.map +1 -0
- package/dist/eventcatalog.js +75 -11
- package/dist/eventcatalog.js.map +1 -1
- package/dist/eventcatalog.mjs +75 -11
- package/dist/eventcatalog.mjs.map +1 -1
- package/dist/index.d.mts +31 -16
- package/dist/index.d.ts +31 -16
- package/dist/index.js +75 -11
- package/dist/index.js.map +1 -1
- package/dist/index.mjs +75 -11
- package/dist/index.mjs.map +1 -1
- package/dist/messages.js.map +1 -1
- package/dist/messages.mjs.map +1 -1
- package/dist/services.d.mts +25 -1
- package/dist/services.d.ts +25 -1
- package/dist/services.js +38 -0
- package/dist/services.js.map +1 -1
- package/dist/services.mjs +37 -0
- package/dist/services.mjs.map +1 -1
- package/dist/types.d.d.mts +2 -0
- package/dist/types.d.d.ts +2 -0
- package/dist/types.d.js.map +1 -1
- package/package.json +1 -1
package/dist/index.d.mts
CHANGED
|
@@ -151,19 +151,7 @@ declare const _default: (path: string) => {
|
|
|
151
151
|
id: string;
|
|
152
152
|
version?: string;
|
|
153
153
|
}, options?: {
|
|
154
|
-
path
|
|
155
|
-
/**
|
|
156
|
-
* Check to see if an event version exists
|
|
157
|
-
* @param id - The id of the event
|
|
158
|
-
* @param version - The version of the event (supports semver)
|
|
159
|
-
* @returns
|
|
160
|
-
*/
|
|
161
|
-
? /**
|
|
162
|
-
* Check to see if an event version exists
|
|
163
|
-
* @param id - The id of the event
|
|
164
|
-
* @param version - The version of the event (supports semver)
|
|
165
|
-
* @returns
|
|
166
|
-
*/: string;
|
|
154
|
+
path?: string;
|
|
167
155
|
format?: "md" | "mdx";
|
|
168
156
|
override?: boolean;
|
|
169
157
|
}) => Promise<void>;
|
|
@@ -573,6 +561,26 @@ declare const _default: (path: string) => {
|
|
|
573
561
|
id: string;
|
|
574
562
|
version: string;
|
|
575
563
|
}, version?: string) => Promise<void>;
|
|
564
|
+
/**
|
|
565
|
+
* Add a data store to a service by it's id.
|
|
566
|
+
*
|
|
567
|
+
* Optionally specify a version to add the data store to a specific version of the service.
|
|
568
|
+
*
|
|
569
|
+
* @example
|
|
570
|
+
* ```ts
|
|
571
|
+
* import utils from '@eventcatalog/utils';
|
|
572
|
+
*
|
|
573
|
+
* const { addDataStoreToService } = utils('/path/to/eventcatalog');
|
|
574
|
+
*
|
|
575
|
+
* // adds a new data store (orders-db) that the InventoryService will write to
|
|
576
|
+
* await addDataStoreToService('InventoryService', 'writesTo', { id: 'orders-db', version: '2.0.0' });
|
|
577
|
+
*
|
|
578
|
+
* ```
|
|
579
|
+
*/
|
|
580
|
+
addDataStoreToService: (id: string, operation: "writesTo" | "readsFrom", dataStore: {
|
|
581
|
+
id: string;
|
|
582
|
+
version: string;
|
|
583
|
+
}, version?: string) => Promise<void>;
|
|
576
584
|
/**
|
|
577
585
|
* Add a command to a service by it's id.
|
|
578
586
|
*
|
|
@@ -987,7 +995,14 @@ declare const _default: (path: string) => {
|
|
|
987
995
|
path?: string;
|
|
988
996
|
override?: boolean;
|
|
989
997
|
versionExistingContent?: boolean;
|
|
990
|
-
format
|
|
998
|
+
format? /**
|
|
999
|
+
* Adds an event to a service in EventCatalog
|
|
1000
|
+
*
|
|
1001
|
+
* @param event - The event to write to the service
|
|
1002
|
+
* @param service - The service and it's id to write to the event to
|
|
1003
|
+
* @param options - Optional options to write the event
|
|
1004
|
+
*
|
|
1005
|
+
*/: "md" | "mdx";
|
|
991
1006
|
}) => Promise<void>;
|
|
992
1007
|
/**
|
|
993
1008
|
* Remove an entity from EventCatalog (modeled on the standard POSIX rm utility)
|
|
@@ -1033,8 +1048,8 @@ declare const _default: (path: string) => {
|
|
|
1033
1048
|
format?: "md" | "mdx";
|
|
1034
1049
|
}) => Promise<void>;
|
|
1035
1050
|
/**
|
|
1036
|
-
* Returns a
|
|
1037
|
-
* @param id - The id of the
|
|
1051
|
+
* Returns a data store from EventCatalog
|
|
1052
|
+
* @param id - The id of the data store to retrieve
|
|
1038
1053
|
* @param version - Optional id of the version to get (supports semver)
|
|
1039
1054
|
* @returns Container|Undefined
|
|
1040
1055
|
*/
|
package/dist/index.d.ts
CHANGED
|
@@ -151,19 +151,7 @@ declare const _default: (path: string) => {
|
|
|
151
151
|
id: string;
|
|
152
152
|
version?: string;
|
|
153
153
|
}, options?: {
|
|
154
|
-
path
|
|
155
|
-
/**
|
|
156
|
-
* Check to see if an event version exists
|
|
157
|
-
* @param id - The id of the event
|
|
158
|
-
* @param version - The version of the event (supports semver)
|
|
159
|
-
* @returns
|
|
160
|
-
*/
|
|
161
|
-
? /**
|
|
162
|
-
* Check to see if an event version exists
|
|
163
|
-
* @param id - The id of the event
|
|
164
|
-
* @param version - The version of the event (supports semver)
|
|
165
|
-
* @returns
|
|
166
|
-
*/: string;
|
|
154
|
+
path?: string;
|
|
167
155
|
format?: "md" | "mdx";
|
|
168
156
|
override?: boolean;
|
|
169
157
|
}) => Promise<void>;
|
|
@@ -573,6 +561,26 @@ declare const _default: (path: string) => {
|
|
|
573
561
|
id: string;
|
|
574
562
|
version: string;
|
|
575
563
|
}, version?: string) => Promise<void>;
|
|
564
|
+
/**
|
|
565
|
+
* Add a data store to a service by it's id.
|
|
566
|
+
*
|
|
567
|
+
* Optionally specify a version to add the data store to a specific version of the service.
|
|
568
|
+
*
|
|
569
|
+
* @example
|
|
570
|
+
* ```ts
|
|
571
|
+
* import utils from '@eventcatalog/utils';
|
|
572
|
+
*
|
|
573
|
+
* const { addDataStoreToService } = utils('/path/to/eventcatalog');
|
|
574
|
+
*
|
|
575
|
+
* // adds a new data store (orders-db) that the InventoryService will write to
|
|
576
|
+
* await addDataStoreToService('InventoryService', 'writesTo', { id: 'orders-db', version: '2.0.0' });
|
|
577
|
+
*
|
|
578
|
+
* ```
|
|
579
|
+
*/
|
|
580
|
+
addDataStoreToService: (id: string, operation: "writesTo" | "readsFrom", dataStore: {
|
|
581
|
+
id: string;
|
|
582
|
+
version: string;
|
|
583
|
+
}, version?: string) => Promise<void>;
|
|
576
584
|
/**
|
|
577
585
|
* Add a command to a service by it's id.
|
|
578
586
|
*
|
|
@@ -987,7 +995,14 @@ declare const _default: (path: string) => {
|
|
|
987
995
|
path?: string;
|
|
988
996
|
override?: boolean;
|
|
989
997
|
versionExistingContent?: boolean;
|
|
990
|
-
format
|
|
998
|
+
format? /**
|
|
999
|
+
* Adds an event to a service in EventCatalog
|
|
1000
|
+
*
|
|
1001
|
+
* @param event - The event to write to the service
|
|
1002
|
+
* @param service - The service and it's id to write to the event to
|
|
1003
|
+
* @param options - Optional options to write the event
|
|
1004
|
+
*
|
|
1005
|
+
*/: "md" | "mdx";
|
|
991
1006
|
}) => Promise<void>;
|
|
992
1007
|
/**
|
|
993
1008
|
* Remove an entity from EventCatalog (modeled on the standard POSIX rm utility)
|
|
@@ -1033,8 +1048,8 @@ declare const _default: (path: string) => {
|
|
|
1033
1048
|
format?: "md" | "mdx";
|
|
1034
1049
|
}) => Promise<void>;
|
|
1035
1050
|
/**
|
|
1036
|
-
* Returns a
|
|
1037
|
-
* @param id - The id of the
|
|
1051
|
+
* Returns a data store from EventCatalog
|
|
1052
|
+
* @param id - The id of the data store to retrieve
|
|
1038
1053
|
* @param version - Optional id of the version to get (supports semver)
|
|
1039
1054
|
* @returns Container|Undefined
|
|
1040
1055
|
*/
|
package/dist/index.js
CHANGED
|
@@ -605,6 +605,42 @@ var addEntityToService = (directory) => async (id, entity, version) => {
|
|
|
605
605
|
await rmServiceById(directory)(id, version);
|
|
606
606
|
await writeService(pathToResource)(service, { format: extension === ".md" ? "md" : "mdx" });
|
|
607
607
|
};
|
|
608
|
+
var addDataStoreToService = (directory) => async (id, operation, dataStore, version) => {
|
|
609
|
+
let service = await getService(directory)(id, version);
|
|
610
|
+
const servicePath = await getResourcePath(directory, id, version);
|
|
611
|
+
const extension = (0, import_node_path6.extname)(servicePath?.fullPath || "");
|
|
612
|
+
if (operation === "writesTo") {
|
|
613
|
+
if (service.writesTo === void 0) {
|
|
614
|
+
service.writesTo = [];
|
|
615
|
+
}
|
|
616
|
+
for (let i = 0; i < service.writesTo.length; i++) {
|
|
617
|
+
if (service.writesTo[i].id === dataStore.id && service.writesTo[i].version === dataStore.version) {
|
|
618
|
+
return;
|
|
619
|
+
}
|
|
620
|
+
}
|
|
621
|
+
service.writesTo.push({ id: dataStore.id, version: dataStore.version });
|
|
622
|
+
} else if (operation === "readsFrom") {
|
|
623
|
+
if (service.readsFrom === void 0) {
|
|
624
|
+
service.readsFrom = [];
|
|
625
|
+
}
|
|
626
|
+
for (let i = 0; i < service.readsFrom.length; i++) {
|
|
627
|
+
if (service.readsFrom[i].id === dataStore.id && service.readsFrom[i].version === dataStore.version) {
|
|
628
|
+
return;
|
|
629
|
+
}
|
|
630
|
+
}
|
|
631
|
+
service.readsFrom.push({ id: dataStore.id, version: dataStore.version });
|
|
632
|
+
} else {
|
|
633
|
+
throw new Error(`Operation ${operation} is invalid, only 'writesTo' and 'readsFrom' are supported`);
|
|
634
|
+
}
|
|
635
|
+
const existingResource = await findFileById(directory, id, version);
|
|
636
|
+
if (!existingResource) {
|
|
637
|
+
throw new Error(`Cannot find service ${id} in the catalog`);
|
|
638
|
+
}
|
|
639
|
+
const path5 = existingResource.split(/[\\/]+services/)[0];
|
|
640
|
+
const pathToResource = (0, import_node_path6.join)(path5, "services");
|
|
641
|
+
await rmServiceById(directory)(id, version);
|
|
642
|
+
await writeService(pathToResource)(service, { format: extension === ".md" ? "md" : "mdx" });
|
|
643
|
+
};
|
|
608
644
|
|
|
609
645
|
// src/domains.ts
|
|
610
646
|
var import_promises6 = __toESM(require("fs/promises"));
|
|
@@ -1155,6 +1191,17 @@ var writeContainerToService = (directory) => async (container, service, options
|
|
|
1155
1191
|
await writeResource(directory, { ...container }, { ...options, path: pathForContainer, type: "container" });
|
|
1156
1192
|
};
|
|
1157
1193
|
|
|
1194
|
+
// src/data-stores.ts
|
|
1195
|
+
var getDataStore = getContainer;
|
|
1196
|
+
var getDataStores = getContainers;
|
|
1197
|
+
var writeDataStore = writeContainer;
|
|
1198
|
+
var versionDataStore = versionContainer;
|
|
1199
|
+
var rmDataStore = rmContainer;
|
|
1200
|
+
var rmDataStoreById = rmContainerById;
|
|
1201
|
+
var dataStoreHasVersion = containerHasVersion;
|
|
1202
|
+
var addFileToDataStore = addFileToContainer;
|
|
1203
|
+
var writeDataStoreToService = writeContainerToService;
|
|
1204
|
+
|
|
1158
1205
|
// src/index.ts
|
|
1159
1206
|
var index_default = (path5) => {
|
|
1160
1207
|
return {
|
|
@@ -1596,6 +1643,23 @@ var index_default = (path5) => {
|
|
|
1596
1643
|
* ```
|
|
1597
1644
|
*/
|
|
1598
1645
|
addEventToService: addMessageToService((0, import_node_path17.join)(path5)),
|
|
1646
|
+
/**
|
|
1647
|
+
* Add a data store to a service by it's id.
|
|
1648
|
+
*
|
|
1649
|
+
* Optionally specify a version to add the data store to a specific version of the service.
|
|
1650
|
+
*
|
|
1651
|
+
* @example
|
|
1652
|
+
* ```ts
|
|
1653
|
+
* import utils from '@eventcatalog/utils';
|
|
1654
|
+
*
|
|
1655
|
+
* const { addDataStoreToService } = utils('/path/to/eventcatalog');
|
|
1656
|
+
*
|
|
1657
|
+
* // adds a new data store (orders-db) that the InventoryService will write to
|
|
1658
|
+
* await addDataStoreToService('InventoryService', 'writesTo', { id: 'orders-db', version: '2.0.0' });
|
|
1659
|
+
*
|
|
1660
|
+
* ```
|
|
1661
|
+
*/
|
|
1662
|
+
addDataStoreToService: addDataStoreToService((0, import_node_path17.join)(path5)),
|
|
1599
1663
|
/**
|
|
1600
1664
|
* Add a command to a service by it's id.
|
|
1601
1665
|
*
|
|
@@ -1991,42 +2055,42 @@ var index_default = (path5) => {
|
|
|
1991
2055
|
* @param options - Optional options to write the data store
|
|
1992
2056
|
*
|
|
1993
2057
|
*/
|
|
1994
|
-
writeDataStore:
|
|
2058
|
+
writeDataStore: writeDataStore((0, import_node_path17.join)(path5, "containers")),
|
|
1995
2059
|
/**
|
|
1996
|
-
* Returns a
|
|
1997
|
-
* @param id - The id of the
|
|
2060
|
+
* Returns a data store from EventCatalog
|
|
2061
|
+
* @param id - The id of the data store to retrieve
|
|
1998
2062
|
* @param version - Optional id of the version to get (supports semver)
|
|
1999
2063
|
* @returns Container|Undefined
|
|
2000
2064
|
*/
|
|
2001
|
-
getDataStore:
|
|
2065
|
+
getDataStore: getDataStore((0, import_node_path17.join)(path5)),
|
|
2002
2066
|
/**
|
|
2003
2067
|
* Returns all data stores from EventCatalog
|
|
2004
2068
|
* @param latestOnly - optional boolean, set to true to get only latest versions
|
|
2005
2069
|
* @returns Container[]|Undefined
|
|
2006
2070
|
*/
|
|
2007
|
-
getDataStores:
|
|
2071
|
+
getDataStores: getDataStores((0, import_node_path17.join)(path5)),
|
|
2008
2072
|
/**
|
|
2009
2073
|
* Version a data store by its id
|
|
2010
2074
|
* @param id - The id of the data store to version
|
|
2011
2075
|
*/
|
|
2012
|
-
versionDataStore:
|
|
2076
|
+
versionDataStore: versionDataStore((0, import_node_path17.join)(path5, "containers")),
|
|
2013
2077
|
/**
|
|
2014
2078
|
* Remove a data store by its path
|
|
2015
2079
|
* @param path - The path to the data store to remove
|
|
2016
2080
|
*/
|
|
2017
|
-
rmDataStore:
|
|
2081
|
+
rmDataStore: rmDataStore((0, import_node_path17.join)(path5, "containers")),
|
|
2018
2082
|
/**
|
|
2019
2083
|
* Remove a data store by its id
|
|
2020
2084
|
* @param id - The id of the data store to remove
|
|
2021
2085
|
*/
|
|
2022
|
-
rmDataStoreById:
|
|
2086
|
+
rmDataStoreById: rmDataStoreById((0, import_node_path17.join)(path5)),
|
|
2023
2087
|
/**
|
|
2024
2088
|
* Check to see if a data store version exists
|
|
2025
2089
|
* @param id - The id of the data store
|
|
2026
2090
|
* @param version - The version of the data store (supports semver)
|
|
2027
2091
|
* @returns
|
|
2028
2092
|
*/
|
|
2029
|
-
dataStoreHasVersion:
|
|
2093
|
+
dataStoreHasVersion: dataStoreHasVersion((0, import_node_path17.join)(path5)),
|
|
2030
2094
|
/**
|
|
2031
2095
|
* Adds a file to a data store by its id
|
|
2032
2096
|
* @param id - The id of the data store to add the file to
|
|
@@ -2034,14 +2098,14 @@ var index_default = (path5) => {
|
|
|
2034
2098
|
* @param version - Optional version of the data store to add the file to
|
|
2035
2099
|
* @returns
|
|
2036
2100
|
*/
|
|
2037
|
-
addFileToDataStore:
|
|
2101
|
+
addFileToDataStore: addFileToDataStore((0, import_node_path17.join)(path5)),
|
|
2038
2102
|
/**
|
|
2039
2103
|
* Writes a data store to a service by its id
|
|
2040
2104
|
* @param dataStore - The data store to write
|
|
2041
2105
|
* @param service - The service to write the data store to
|
|
2042
2106
|
* @returns
|
|
2043
2107
|
*/
|
|
2044
|
-
writeDataStoreToService:
|
|
2108
|
+
writeDataStoreToService: writeDataStoreToService((0, import_node_path17.join)(path5))
|
|
2045
2109
|
};
|
|
2046
2110
|
};
|
|
2047
2111
|
//# sourceMappingURL=index.js.map
|