@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.mjs
CHANGED
|
@@ -106,7 +106,7 @@ var versionResource = async (catalogDir, id) => {
|
|
|
106
106
|
const files = await getFiles(`${catalogDir}/**/index.{md,mdx}`);
|
|
107
107
|
const matchedFiles = await searchFilesForId(files, id);
|
|
108
108
|
if (matchedFiles.length === 0) {
|
|
109
|
-
throw new Error(`No
|
|
109
|
+
throw new Error(`No resource found with id: ${id}`);
|
|
110
110
|
}
|
|
111
111
|
const file = matchedFiles[0];
|
|
112
112
|
const sourceDirectory = dirname(file);
|
|
@@ -176,6 +176,15 @@ var getResource = async (catalogDir, id, version, options) => {
|
|
|
176
176
|
markdown: content.trim()
|
|
177
177
|
};
|
|
178
178
|
};
|
|
179
|
+
var getResourcePath = async (catalogDir, id, version) => {
|
|
180
|
+
const file = await findFileById(catalogDir, id, version);
|
|
181
|
+
if (!file) return;
|
|
182
|
+
return {
|
|
183
|
+
fullPath: file,
|
|
184
|
+
relativePath: file.replace(catalogDir, ""),
|
|
185
|
+
directory: dirname(file.replace(catalogDir, ""))
|
|
186
|
+
};
|
|
187
|
+
};
|
|
179
188
|
var getResources = async (catalogDir, {
|
|
180
189
|
type,
|
|
181
190
|
latestOnly = false,
|
|
@@ -236,7 +245,11 @@ var getEvent = (directory) => async (id, version) => getResource(directory, id,
|
|
|
236
245
|
var getEvents = (directory) => async (options) => getResources(directory, { type: "events", ...options });
|
|
237
246
|
var writeEvent = (directory) => async (event, options = { path: "", override: false }) => writeResource(directory, { ...event }, { ...options, type: "event" });
|
|
238
247
|
var writeEventToService = (directory) => async (event, service, options = { path: "" }) => {
|
|
239
|
-
|
|
248
|
+
const resourcePath = await getResourcePath(directory, service.id, service.version);
|
|
249
|
+
if (!resourcePath) {
|
|
250
|
+
throw new Error("Service not found");
|
|
251
|
+
}
|
|
252
|
+
let pathForEvent = service.version && service.version !== "latest" ? `${resourcePath.directory}/versioned/${service.version}/events` : `${resourcePath.directory}/events`;
|
|
240
253
|
pathForEvent = join3(pathForEvent, event.id);
|
|
241
254
|
await writeResource(directory, { ...event }, { ...options, path: pathForEvent, type: "event" });
|
|
242
255
|
};
|
|
@@ -263,9 +276,13 @@ var getCommand = (directory) => async (id, version) => getResource(directory, id
|
|
|
263
276
|
var getCommands = (directory) => async (options) => getResources(directory, { type: "commands", ...options });
|
|
264
277
|
var writeCommand = (directory) => async (command, options = { path: "" }) => writeResource(directory, { ...command }, { ...options, type: "command" });
|
|
265
278
|
var writeCommandToService = (directory) => async (command, service, options = { path: "" }) => {
|
|
266
|
-
|
|
267
|
-
|
|
268
|
-
|
|
279
|
+
const resourcePath = await getResourcePath(directory, service.id, service.version);
|
|
280
|
+
if (!resourcePath) {
|
|
281
|
+
throw new Error("Service not found");
|
|
282
|
+
}
|
|
283
|
+
let pathForCommand = service.version && service.version !== "latest" ? `${resourcePath.directory}/versioned/${service.version}/commands` : `${resourcePath.directory}/commands`;
|
|
284
|
+
pathForCommand = join4(pathForCommand, command.id);
|
|
285
|
+
await writeResource(directory, { ...command }, { ...options, path: pathForCommand, type: "command" });
|
|
269
286
|
};
|
|
270
287
|
var rmCommand = (directory) => async (path3) => {
|
|
271
288
|
await fs3.rm(join4(directory, path3), { recursive: true });
|
|
@@ -288,7 +305,11 @@ var getQuery = (directory) => async (id, version) => getResource(directory, id,
|
|
|
288
305
|
var writeQuery = (directory) => async (query, options = { path: "" }) => writeResource(directory, { ...query }, { ...options, type: "query" });
|
|
289
306
|
var getQueries = (directory) => async (options) => getResources(directory, { type: "queries", ...options });
|
|
290
307
|
var writeQueryToService = (directory) => async (query, service, options = { path: "" }) => {
|
|
291
|
-
|
|
308
|
+
const resourcePath = await getResourcePath(directory, service.id, service.version);
|
|
309
|
+
if (!resourcePath) {
|
|
310
|
+
throw new Error("Service not found");
|
|
311
|
+
}
|
|
312
|
+
let pathForQuery = service.version && service.version !== "latest" ? `${resourcePath.directory}/versioned/${service.version}/queries` : `${resourcePath.directory}/queries`;
|
|
292
313
|
pathForQuery = join5(pathForQuery, query.id);
|
|
293
314
|
await writeResource(directory, { ...query }, { ...options, path: pathForQuery, type: "query" });
|
|
294
315
|
};
|
|
@@ -310,7 +331,7 @@ var queryHasVersion = (directory) => async (id, version) => {
|
|
|
310
331
|
|
|
311
332
|
// src/services.ts
|
|
312
333
|
import fs5 from "node:fs/promises";
|
|
313
|
-
import { join as join6, dirname as
|
|
334
|
+
import { join as join6, dirname as dirname3 } from "node:path";
|
|
314
335
|
var getService = (directory) => async (id, version) => getResource(directory, id, version, { type: "service" });
|
|
315
336
|
var getServices = (directory) => async (options) => getResources(directory, {
|
|
316
337
|
type: "services",
|
|
@@ -357,7 +378,7 @@ var getSpecificationFilesForService = (directory) => async (id, version) => {
|
|
|
357
378
|
throw new Error(`Specification file name for ${specFile} is undefined`);
|
|
358
379
|
}
|
|
359
380
|
const rawFile = await getFileFromResource(directory, id, { fileName }, version);
|
|
360
|
-
return { key: specFile, content: rawFile, fileName, path: join6(
|
|
381
|
+
return { key: specFile, content: rawFile, fileName, path: join6(dirname3(filePathToService), fileName) };
|
|
361
382
|
});
|
|
362
383
|
specs = await Promise.all(getSpecs);
|
|
363
384
|
}
|
|
@@ -673,7 +694,7 @@ var index_default = (path3) => {
|
|
|
673
694
|
* @param options - Optional options to write the event
|
|
674
695
|
*
|
|
675
696
|
*/
|
|
676
|
-
writeEventToService: writeEventToService(join12(path3
|
|
697
|
+
writeEventToService: writeEventToService(join12(path3)),
|
|
677
698
|
/**
|
|
678
699
|
* Remove an event to EventCatalog (modeled on the standard POSIX rm utility)
|
|
679
700
|
*
|
|
@@ -750,7 +771,7 @@ var index_default = (path3) => {
|
|
|
750
771
|
* @param options - Optional options to write the command
|
|
751
772
|
*
|
|
752
773
|
*/
|
|
753
|
-
writeCommandToService: writeCommandToService(join12(path3
|
|
774
|
+
writeCommandToService: writeCommandToService(join12(path3)),
|
|
754
775
|
/**
|
|
755
776
|
* Remove an command to EventCatalog (modeled on the standard POSIX rm utility)
|
|
756
777
|
*
|
|
@@ -827,7 +848,7 @@ var index_default = (path3) => {
|
|
|
827
848
|
* @param options - Optional options to write the query
|
|
828
849
|
*
|
|
829
850
|
*/
|
|
830
|
-
writeQueryToService: writeQueryToService(join12(path3
|
|
851
|
+
writeQueryToService: writeQueryToService(join12(path3)),
|
|
831
852
|
/**
|
|
832
853
|
* Remove an query to EventCatalog (modeled on the standard POSIX rm utility)
|
|
833
854
|
*
|