@eventcatalog/sdk 2.1.2 → 2.2.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/channels.d.mts +1 -1
- package/dist/channels.d.ts +1 -1
- package/dist/channels.js +1 -1
- package/dist/channels.js.map +1 -1
- package/dist/channels.mjs +1 -1
- package/dist/channels.mjs.map +1 -1
- package/dist/commands.d.mts +1 -1
- package/dist/commands.d.ts +1 -1
- package/dist/commands.js +17 -4
- package/dist/commands.js.map +1 -1
- package/dist/commands.mjs +17 -4
- package/dist/commands.mjs.map +1 -1
- package/dist/custom-docs.js.map +1 -1
- package/dist/custom-docs.mjs.map +1 -1
- package/dist/domains.d.mts +1 -1
- package/dist/domains.d.ts +1 -1
- package/dist/domains.js +1 -1
- package/dist/domains.js.map +1 -1
- package/dist/domains.mjs +1 -1
- package/dist/domains.mjs.map +1 -1
- package/dist/events.d.mts +1 -1
- package/dist/events.d.ts +1 -1
- package/dist/events.js +15 -2
- package/dist/events.js.map +1 -1
- package/dist/events.mjs +15 -2
- package/dist/events.mjs.map +1 -1
- package/dist/index.d.mts +6 -6
- package/dist/index.d.ts +6 -6
- package/dist/index.js +30 -9
- package/dist/index.js.map +1 -1
- package/dist/index.mjs +32 -11
- package/dist/index.mjs.map +1 -1
- package/dist/queries.d.mts +1 -1
- package/dist/queries.d.ts +1 -1
- package/dist/queries.js +15 -2
- package/dist/queries.js.map +1 -1
- package/dist/queries.mjs +15 -2
- package/dist/queries.mjs.map +1 -1
- package/dist/services.d.mts +1 -1
- package/dist/services.d.ts +1 -1
- package/dist/services.js +1 -1
- package/dist/services.js.map +1 -1
- package/dist/services.mjs +1 -1
- package/dist/services.mjs.map +1 -1
- package/package.json +1 -1
package/dist/index.d.ts
CHANGED
|
@@ -95,7 +95,7 @@ declare const _default: (path: string) => {
|
|
|
95
95
|
* @param version - The version of the event (supports semver)
|
|
96
96
|
* @returns
|
|
97
97
|
*/
|
|
98
|
-
eventHasVersion: (id: string, version
|
|
98
|
+
eventHasVersion: (id: string, version?: string) => Promise<boolean>;
|
|
99
99
|
/**
|
|
100
100
|
* ================================
|
|
101
101
|
* Commands
|
|
@@ -189,7 +189,7 @@ declare const _default: (path: string) => {
|
|
|
189
189
|
* @param version - The version of the command (supports semver)
|
|
190
190
|
* @returns
|
|
191
191
|
*/
|
|
192
|
-
commandHasVersion: (id: string, version
|
|
192
|
+
commandHasVersion: (id: string, version?: string) => Promise<boolean>;
|
|
193
193
|
/**
|
|
194
194
|
* ================================
|
|
195
195
|
* Queries
|
|
@@ -283,7 +283,7 @@ declare const _default: (path: string) => {
|
|
|
283
283
|
* @param version - The version of the query (supports semver)
|
|
284
284
|
* @returns
|
|
285
285
|
*/
|
|
286
|
-
queryHasVersion: (id: string, version
|
|
286
|
+
queryHasVersion: (id: string, version?: string) => Promise<boolean>;
|
|
287
287
|
/**
|
|
288
288
|
* ================================
|
|
289
289
|
* Channels
|
|
@@ -341,7 +341,7 @@ declare const _default: (path: string) => {
|
|
|
341
341
|
* @param version - The version of the channel (supports semver)
|
|
342
342
|
* @returns
|
|
343
343
|
*/
|
|
344
|
-
channelHasVersion: (id: string, version
|
|
344
|
+
channelHasVersion: (id: string, version?: string) => Promise<boolean>;
|
|
345
345
|
/**
|
|
346
346
|
* Add a channel to an event
|
|
347
347
|
*
|
|
@@ -508,7 +508,7 @@ declare const _default: (path: string) => {
|
|
|
508
508
|
* @param version - The version of the service (supports semver)
|
|
509
509
|
* @returns
|
|
510
510
|
*/
|
|
511
|
-
serviceHasVersion: (id: string, version
|
|
511
|
+
serviceHasVersion: (id: string, version?: string) => Promise<boolean>;
|
|
512
512
|
/**
|
|
513
513
|
* Add an event to a service by it's id.
|
|
514
514
|
*
|
|
@@ -662,7 +662,7 @@ declare const _default: (path: string) => {
|
|
|
662
662
|
* @param version - The version of the domain (supports semver)
|
|
663
663
|
* @returns
|
|
664
664
|
*/
|
|
665
|
-
domainHasVersion: (id: string, version
|
|
665
|
+
domainHasVersion: (id: string, version?: string) => Promise<boolean>;
|
|
666
666
|
/**
|
|
667
667
|
* Adds a given service to a domain
|
|
668
668
|
* @param id - The id of the domain
|
package/dist/index.js
CHANGED
|
@@ -140,7 +140,7 @@ var versionResource = async (catalogDir, id) => {
|
|
|
140
140
|
const files = await getFiles(`${catalogDir}/**/index.{md,mdx}`);
|
|
141
141
|
const matchedFiles = await searchFilesForId(files, id);
|
|
142
142
|
if (matchedFiles.length === 0) {
|
|
143
|
-
throw new Error(`No
|
|
143
|
+
throw new Error(`No resource found with id: ${id}`);
|
|
144
144
|
}
|
|
145
145
|
const file = matchedFiles[0];
|
|
146
146
|
const sourceDirectory = (0, import_path.dirname)(file);
|
|
@@ -210,6 +210,15 @@ var getResource = async (catalogDir, id, version, options) => {
|
|
|
210
210
|
markdown: content.trim()
|
|
211
211
|
};
|
|
212
212
|
};
|
|
213
|
+
var getResourcePath = async (catalogDir, id, version) => {
|
|
214
|
+
const file = await findFileById(catalogDir, id, version);
|
|
215
|
+
if (!file) return;
|
|
216
|
+
return {
|
|
217
|
+
fullPath: file,
|
|
218
|
+
relativePath: file.replace(catalogDir, ""),
|
|
219
|
+
directory: (0, import_path.dirname)(file.replace(catalogDir, ""))
|
|
220
|
+
};
|
|
221
|
+
};
|
|
213
222
|
var getResources = async (catalogDir, {
|
|
214
223
|
type,
|
|
215
224
|
latestOnly = false,
|
|
@@ -270,7 +279,11 @@ var getEvent = (directory) => async (id, version) => getResource(directory, id,
|
|
|
270
279
|
var getEvents = (directory) => async (options) => getResources(directory, { type: "events", ...options });
|
|
271
280
|
var writeEvent = (directory) => async (event, options = { path: "", override: false }) => writeResource(directory, { ...event }, { ...options, type: "event" });
|
|
272
281
|
var writeEventToService = (directory) => async (event, service, options = { path: "" }) => {
|
|
273
|
-
|
|
282
|
+
const resourcePath = await getResourcePath(directory, service.id, service.version);
|
|
283
|
+
if (!resourcePath) {
|
|
284
|
+
throw new Error("Service not found");
|
|
285
|
+
}
|
|
286
|
+
let pathForEvent = service.version && service.version !== "latest" ? `${resourcePath.directory}/versioned/${service.version}/events` : `${resourcePath.directory}/events`;
|
|
274
287
|
pathForEvent = (0, import_node_path2.join)(pathForEvent, event.id);
|
|
275
288
|
await writeResource(directory, { ...event }, { ...options, path: pathForEvent, type: "event" });
|
|
276
289
|
};
|
|
@@ -297,9 +310,13 @@ var getCommand = (directory) => async (id, version) => getResource(directory, id
|
|
|
297
310
|
var getCommands = (directory) => async (options) => getResources(directory, { type: "commands", ...options });
|
|
298
311
|
var writeCommand = (directory) => async (command, options = { path: "" }) => writeResource(directory, { ...command }, { ...options, type: "command" });
|
|
299
312
|
var writeCommandToService = (directory) => async (command, service, options = { path: "" }) => {
|
|
300
|
-
|
|
301
|
-
|
|
302
|
-
|
|
313
|
+
const resourcePath = await getResourcePath(directory, service.id, service.version);
|
|
314
|
+
if (!resourcePath) {
|
|
315
|
+
throw new Error("Service not found");
|
|
316
|
+
}
|
|
317
|
+
let pathForCommand = service.version && service.version !== "latest" ? `${resourcePath.directory}/versioned/${service.version}/commands` : `${resourcePath.directory}/commands`;
|
|
318
|
+
pathForCommand = (0, import_node_path3.join)(pathForCommand, command.id);
|
|
319
|
+
await writeResource(directory, { ...command }, { ...options, path: pathForCommand, type: "command" });
|
|
303
320
|
};
|
|
304
321
|
var rmCommand = (directory) => async (path3) => {
|
|
305
322
|
await import_promises3.default.rm((0, import_node_path3.join)(directory, path3), { recursive: true });
|
|
@@ -322,7 +339,11 @@ var getQuery = (directory) => async (id, version) => getResource(directory, id,
|
|
|
322
339
|
var writeQuery = (directory) => async (query, options = { path: "" }) => writeResource(directory, { ...query }, { ...options, type: "query" });
|
|
323
340
|
var getQueries = (directory) => async (options) => getResources(directory, { type: "queries", ...options });
|
|
324
341
|
var writeQueryToService = (directory) => async (query, service, options = { path: "" }) => {
|
|
325
|
-
|
|
342
|
+
const resourcePath = await getResourcePath(directory, service.id, service.version);
|
|
343
|
+
if (!resourcePath) {
|
|
344
|
+
throw new Error("Service not found");
|
|
345
|
+
}
|
|
346
|
+
let pathForQuery = service.version && service.version !== "latest" ? `${resourcePath.directory}/versioned/${service.version}/queries` : `${resourcePath.directory}/queries`;
|
|
326
347
|
pathForQuery = (0, import_node_path4.join)(pathForQuery, query.id);
|
|
327
348
|
await writeResource(directory, { ...query }, { ...options, path: pathForQuery, type: "query" });
|
|
328
349
|
};
|
|
@@ -707,7 +728,7 @@ var index_default = (path3) => {
|
|
|
707
728
|
* @param options - Optional options to write the event
|
|
708
729
|
*
|
|
709
730
|
*/
|
|
710
|
-
writeEventToService: writeEventToService((0, import_node_path11.join)(path3
|
|
731
|
+
writeEventToService: writeEventToService((0, import_node_path11.join)(path3)),
|
|
711
732
|
/**
|
|
712
733
|
* Remove an event to EventCatalog (modeled on the standard POSIX rm utility)
|
|
713
734
|
*
|
|
@@ -784,7 +805,7 @@ var index_default = (path3) => {
|
|
|
784
805
|
* @param options - Optional options to write the command
|
|
785
806
|
*
|
|
786
807
|
*/
|
|
787
|
-
writeCommandToService: writeCommandToService((0, import_node_path11.join)(path3
|
|
808
|
+
writeCommandToService: writeCommandToService((0, import_node_path11.join)(path3)),
|
|
788
809
|
/**
|
|
789
810
|
* Remove an command to EventCatalog (modeled on the standard POSIX rm utility)
|
|
790
811
|
*
|
|
@@ -861,7 +882,7 @@ var index_default = (path3) => {
|
|
|
861
882
|
* @param options - Optional options to write the query
|
|
862
883
|
*
|
|
863
884
|
*/
|
|
864
|
-
writeQueryToService: writeQueryToService((0, import_node_path11.join)(path3
|
|
885
|
+
writeQueryToService: writeQueryToService((0, import_node_path11.join)(path3)),
|
|
865
886
|
/**
|
|
866
887
|
* Remove an query to EventCatalog (modeled on the standard POSIX rm utility)
|
|
867
888
|
*
|