@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/index.mjs
CHANGED
|
@@ -9,7 +9,7 @@ import { join as join3 } from "node:path";
|
|
|
9
9
|
import { globSync } from "glob";
|
|
10
10
|
import fsSync from "node:fs";
|
|
11
11
|
import { copy } from "fs-extra";
|
|
12
|
-
import { join } from "node:path";
|
|
12
|
+
import { join, dirname } from "node:path";
|
|
13
13
|
import matter from "gray-matter";
|
|
14
14
|
import { satisfies, validRange, valid } from "semver";
|
|
15
15
|
var versionExists = async (catalogDir, id, version) => {
|
|
@@ -44,7 +44,8 @@ var findFileById = async (catalogDir, id, version) => {
|
|
|
44
44
|
var getFiles = async (pattern, ignore = "") => {
|
|
45
45
|
try {
|
|
46
46
|
const ignoreList = Array.isArray(ignore) ? ignore : [ignore];
|
|
47
|
-
const
|
|
47
|
+
const baseDir = pattern.includes("**") ? pattern.split("**")[0] : dirname(pattern);
|
|
48
|
+
const files = globSync(pattern, { cwd: baseDir, ignore: ["node_modules/**", ...ignoreList] });
|
|
48
49
|
return files;
|
|
49
50
|
} catch (error) {
|
|
50
51
|
throw new Error(`Error finding files: ${error}`);
|
|
@@ -96,7 +97,7 @@ var uniqueVersions = (messages) => {
|
|
|
96
97
|
};
|
|
97
98
|
|
|
98
99
|
// src/internal/resources.ts
|
|
99
|
-
import { dirname, join as join2 } from "path";
|
|
100
|
+
import { dirname as dirname2, join as join2 } from "path";
|
|
100
101
|
import matter2 from "gray-matter";
|
|
101
102
|
import fs from "node:fs/promises";
|
|
102
103
|
import fsSync2 from "node:fs";
|
|
@@ -109,7 +110,7 @@ var versionResource = async (catalogDir, id) => {
|
|
|
109
110
|
throw new Error(`No resource found with id: ${id}`);
|
|
110
111
|
}
|
|
111
112
|
const file = matchedFiles[0];
|
|
112
|
-
const sourceDirectory =
|
|
113
|
+
const sourceDirectory = dirname2(file);
|
|
113
114
|
const { data: { version = "0.0.1" } = {} } = matter2.read(file);
|
|
114
115
|
const targetDirectory = getVersionedDirectory(sourceDirectory, version);
|
|
115
116
|
fsSync2.mkdirSync(targetDirectory, { recursive: true });
|
|
@@ -182,7 +183,7 @@ var getResourcePath = async (catalogDir, id, version) => {
|
|
|
182
183
|
return {
|
|
183
184
|
fullPath: file,
|
|
184
185
|
relativePath: file.replace(catalogDir, ""),
|
|
185
|
-
directory:
|
|
186
|
+
directory: dirname2(file.replace(catalogDir, ""))
|
|
186
187
|
};
|
|
187
188
|
};
|
|
188
189
|
var getResources = async (catalogDir, {
|
|
@@ -218,7 +219,7 @@ var rmResourceById = async (catalogDir, id, version, options) => {
|
|
|
218
219
|
} else {
|
|
219
220
|
await Promise.all(
|
|
220
221
|
matchedFiles.map(async (file) => {
|
|
221
|
-
const directory =
|
|
222
|
+
const directory = dirname2(file);
|
|
222
223
|
await fs.rm(directory, { recursive: true, force: true });
|
|
223
224
|
})
|
|
224
225
|
);
|
|
@@ -227,14 +228,14 @@ var rmResourceById = async (catalogDir, id, version, options) => {
|
|
|
227
228
|
var addFileToResource = async (catalogDir, id, file, version) => {
|
|
228
229
|
const pathToResource = await findFileById(catalogDir, id, version);
|
|
229
230
|
if (!pathToResource) throw new Error("Cannot find directory to write file to");
|
|
230
|
-
fsSync2.writeFileSync(join2(
|
|
231
|
+
fsSync2.writeFileSync(join2(dirname2(pathToResource), file.fileName), file.content);
|
|
231
232
|
};
|
|
232
233
|
var getFileFromResource = async (catalogDir, id, file, version) => {
|
|
233
234
|
const pathToResource = await findFileById(catalogDir, id, version);
|
|
234
235
|
if (!pathToResource) throw new Error("Cannot find directory of resource");
|
|
235
|
-
const exists = await fs.access(join2(
|
|
236
|
+
const exists = await fs.access(join2(dirname2(pathToResource), file.fileName)).then(() => true).catch(() => false);
|
|
236
237
|
if (!exists) throw new Error(`File ${file.fileName} does not exist in resource ${id} v(${version})`);
|
|
237
|
-
return fsSync2.readFileSync(join2(
|
|
238
|
+
return fsSync2.readFileSync(join2(dirname2(pathToResource), file.fileName), "utf-8");
|
|
238
239
|
};
|
|
239
240
|
var getVersionedDirectory = (sourceDirectory, version) => {
|
|
240
241
|
return join2(sourceDirectory, "versioned", version);
|
|
@@ -331,7 +332,7 @@ var queryHasVersion = (directory) => async (id, version) => {
|
|
|
331
332
|
|
|
332
333
|
// src/services.ts
|
|
333
334
|
import fs5 from "node:fs/promises";
|
|
334
|
-
import { join as join6, dirname as
|
|
335
|
+
import { join as join6, dirname as dirname4 } from "node:path";
|
|
335
336
|
var getService = (directory) => async (id, version) => getResource(directory, id, version, { type: "service" });
|
|
336
337
|
var getServices = (directory) => async (options) => getResources(directory, {
|
|
337
338
|
type: "services",
|
|
@@ -378,7 +379,7 @@ var getSpecificationFilesForService = (directory) => async (id, version) => {
|
|
|
378
379
|
throw new Error(`Specification file name for ${specFile} is undefined`);
|
|
379
380
|
}
|
|
380
381
|
const rawFile = await getFileFromResource(directory, id, { fileName }, version);
|
|
381
|
-
return { key: specFile, content: rawFile, fileName, path: join6(
|
|
382
|
+
return { key: specFile, content: rawFile, fileName, path: join6(dirname4(filePathToService), fileName) };
|
|
382
383
|
});
|
|
383
384
|
specs = await Promise.all(getSpecs);
|
|
384
385
|
}
|