@eventcatalog/sdk 2.2.6 → 2.2.7
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.js +2 -1
- package/dist/channels.js.map +1 -1
- package/dist/channels.mjs +6 -5
- package/dist/channels.mjs.map +1 -1
- package/dist/commands.js +2 -1
- package/dist/commands.js.map +1 -1
- package/dist/commands.mjs +8 -7
- package/dist/commands.mjs.map +1 -1
- package/dist/custom-docs.js +2 -1
- package/dist/custom-docs.js.map +1 -1
- package/dist/custom-docs.mjs +5 -3
- package/dist/custom-docs.mjs.map +1 -1
- package/dist/domains.js +2 -1
- package/dist/domains.js.map +1 -1
- package/dist/domains.mjs +7 -6
- package/dist/domains.mjs.map +1 -1
- package/dist/eventcatalog.js +2 -1
- package/dist/eventcatalog.js.map +1 -1
- package/dist/eventcatalog.mjs +12 -11
- package/dist/eventcatalog.mjs.map +1 -1
- package/dist/events.js +2 -1
- package/dist/events.js.map +1 -1
- package/dist/events.mjs +8 -7
- package/dist/events.mjs.map +1 -1
- package/dist/index.js +2 -1
- package/dist/index.js.map +1 -1
- package/dist/index.mjs +12 -11
- package/dist/index.mjs.map +1 -1
- package/dist/queries.js +2 -1
- package/dist/queries.js.map +1 -1
- package/dist/queries.mjs +8 -7
- package/dist/queries.mjs.map +1 -1
- package/dist/services.js +2 -1
- package/dist/services.js.map +1 -1
- package/dist/services.mjs +11 -10
- package/dist/services.mjs.map +1 -1
- package/dist/teams.js +2 -1
- package/dist/teams.js.map +1 -1
- package/dist/teams.mjs +7 -5
- package/dist/teams.mjs.map +1 -1
- package/dist/users.js +2 -1
- package/dist/users.js.map +1 -1
- package/dist/users.mjs +7 -5
- package/dist/users.mjs.map +1 -1
- package/package.json +1 -1
package/dist/eventcatalog.mjs
CHANGED
|
@@ -13,7 +13,7 @@ import { join as join3 } from "node:path";
|
|
|
13
13
|
import { globSync } from "glob";
|
|
14
14
|
import fsSync from "node:fs";
|
|
15
15
|
import { copy } from "fs-extra";
|
|
16
|
-
import { join } from "node:path";
|
|
16
|
+
import { join, dirname } from "node:path";
|
|
17
17
|
import matter from "gray-matter";
|
|
18
18
|
import { satisfies, validRange, valid } from "semver";
|
|
19
19
|
var versionExists = async (catalogDir, id, version) => {
|
|
@@ -48,7 +48,8 @@ var findFileById = async (catalogDir, id, version) => {
|
|
|
48
48
|
var getFiles = async (pattern, ignore = "") => {
|
|
49
49
|
try {
|
|
50
50
|
const ignoreList = Array.isArray(ignore) ? ignore : [ignore];
|
|
51
|
-
const
|
|
51
|
+
const baseDir = pattern.includes("**") ? pattern.split("**")[0] : dirname(pattern);
|
|
52
|
+
const files = globSync(pattern, { cwd: baseDir, ignore: ["node_modules/**", ...ignoreList] });
|
|
52
53
|
return files;
|
|
53
54
|
} catch (error) {
|
|
54
55
|
throw new Error(`Error finding files: ${error}`);
|
|
@@ -100,7 +101,7 @@ var uniqueVersions = (messages) => {
|
|
|
100
101
|
};
|
|
101
102
|
|
|
102
103
|
// src/internal/resources.ts
|
|
103
|
-
import { dirname, join as join2 } from "path";
|
|
104
|
+
import { dirname as dirname2, join as join2 } from "path";
|
|
104
105
|
import matter2 from "gray-matter";
|
|
105
106
|
import fs from "node:fs/promises";
|
|
106
107
|
import fsSync2 from "node:fs";
|
|
@@ -113,7 +114,7 @@ var versionResource = async (catalogDir, id) => {
|
|
|
113
114
|
throw new Error(`No resource found with id: ${id}`);
|
|
114
115
|
}
|
|
115
116
|
const file = matchedFiles[0];
|
|
116
|
-
const sourceDirectory =
|
|
117
|
+
const sourceDirectory = dirname2(file);
|
|
117
118
|
const { data: { version = "0.0.1" } = {} } = matter2.read(file);
|
|
118
119
|
const targetDirectory = getVersionedDirectory(sourceDirectory, version);
|
|
119
120
|
fsSync2.mkdirSync(targetDirectory, { recursive: true });
|
|
@@ -186,7 +187,7 @@ var getResourcePath = async (catalogDir, id, version) => {
|
|
|
186
187
|
return {
|
|
187
188
|
fullPath: file,
|
|
188
189
|
relativePath: file.replace(catalogDir, ""),
|
|
189
|
-
directory:
|
|
190
|
+
directory: dirname2(file.replace(catalogDir, ""))
|
|
190
191
|
};
|
|
191
192
|
};
|
|
192
193
|
var getResources = async (catalogDir, {
|
|
@@ -222,7 +223,7 @@ var rmResourceById = async (catalogDir, id, version, options) => {
|
|
|
222
223
|
} else {
|
|
223
224
|
await Promise.all(
|
|
224
225
|
matchedFiles.map(async (file) => {
|
|
225
|
-
const directory =
|
|
226
|
+
const directory = dirname2(file);
|
|
226
227
|
await fs.rm(directory, { recursive: true, force: true });
|
|
227
228
|
})
|
|
228
229
|
);
|
|
@@ -231,14 +232,14 @@ var rmResourceById = async (catalogDir, id, version, options) => {
|
|
|
231
232
|
var addFileToResource = async (catalogDir, id, file, version) => {
|
|
232
233
|
const pathToResource = await findFileById(catalogDir, id, version);
|
|
233
234
|
if (!pathToResource) throw new Error("Cannot find directory to write file to");
|
|
234
|
-
fsSync2.writeFileSync(join2(
|
|
235
|
+
fsSync2.writeFileSync(join2(dirname2(pathToResource), file.fileName), file.content);
|
|
235
236
|
};
|
|
236
237
|
var getFileFromResource = async (catalogDir, id, file, version) => {
|
|
237
238
|
const pathToResource = await findFileById(catalogDir, id, version);
|
|
238
239
|
if (!pathToResource) throw new Error("Cannot find directory of resource");
|
|
239
|
-
const exists = await fs.access(join2(
|
|
240
|
+
const exists = await fs.access(join2(dirname2(pathToResource), file.fileName)).then(() => true).catch(() => false);
|
|
240
241
|
if (!exists) throw new Error(`File ${file.fileName} does not exist in resource ${id} v(${version})`);
|
|
241
|
-
return fsSync2.readFileSync(join2(
|
|
242
|
+
return fsSync2.readFileSync(join2(dirname2(pathToResource), file.fileName), "utf-8");
|
|
242
243
|
};
|
|
243
244
|
var getVersionedDirectory = (sourceDirectory, version) => {
|
|
244
245
|
return join2(sourceDirectory, "versioned", version);
|
|
@@ -335,7 +336,7 @@ var queryHasVersion = (directory) => async (id, version) => {
|
|
|
335
336
|
|
|
336
337
|
// src/services.ts
|
|
337
338
|
import fs5 from "node:fs/promises";
|
|
338
|
-
import { join as join6, dirname as
|
|
339
|
+
import { join as join6, dirname as dirname4 } from "node:path";
|
|
339
340
|
var getService = (directory) => async (id, version) => getResource(directory, id, version, { type: "service" });
|
|
340
341
|
var getServices = (directory) => async (options) => getResources(directory, {
|
|
341
342
|
type: "services",
|
|
@@ -382,7 +383,7 @@ var getSpecificationFilesForService = (directory) => async (id, version) => {
|
|
|
382
383
|
throw new Error(`Specification file name for ${specFile} is undefined`);
|
|
383
384
|
}
|
|
384
385
|
const rawFile = await getFileFromResource(directory, id, { fileName }, version);
|
|
385
|
-
return { key: specFile, content: rawFile, fileName, path: join6(
|
|
386
|
+
return { key: specFile, content: rawFile, fileName, path: join6(dirname4(filePathToService), fileName) };
|
|
386
387
|
});
|
|
387
388
|
specs = await Promise.all(getSpecs);
|
|
388
389
|
}
|