@eventcatalog/sdk 2.3.7 → 2.4.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.js +30 -4
- package/dist/channels.js.map +1 -1
- package/dist/channels.mjs +44 -12
- package/dist/channels.mjs.map +1 -1
- package/dist/commands.d.mts +10 -1
- package/dist/commands.d.ts +10 -1
- package/dist/commands.js +28 -2
- package/dist/commands.js.map +1 -1
- package/dist/commands.mjs +34 -8
- package/dist/commands.mjs.map +1 -1
- package/dist/custom-docs.js +15 -1
- package/dist/custom-docs.js.map +1 -1
- package/dist/custom-docs.mjs +26 -9
- package/dist/custom-docs.mjs.map +1 -1
- package/dist/domains.js +27 -1
- package/dist/domains.js.map +1 -1
- package/dist/domains.mjs +34 -8
- package/dist/domains.mjs.map +1 -1
- package/dist/eventcatalog.js +30 -4
- package/dist/eventcatalog.js.map +1 -1
- package/dist/eventcatalog.mjs +57 -31
- package/dist/eventcatalog.mjs.map +1 -1
- package/dist/events.d.mts +10 -1
- package/dist/events.d.ts +10 -1
- package/dist/events.js +28 -2
- package/dist/events.js.map +1 -1
- package/dist/events.mjs +34 -8
- package/dist/events.mjs.map +1 -1
- package/dist/index.d.mts +12 -3
- package/dist/index.d.ts +12 -3
- package/dist/index.js +30 -4
- package/dist/index.js.map +1 -1
- package/dist/index.mjs +57 -31
- package/dist/index.mjs.map +1 -1
- package/dist/queries.d.mts +10 -1
- package/dist/queries.d.ts +10 -1
- package/dist/queries.js +28 -2
- package/dist/queries.js.map +1 -1
- package/dist/queries.mjs +34 -8
- package/dist/queries.mjs.map +1 -1
- package/dist/services.js +27 -1
- package/dist/services.js.map +1 -1
- package/dist/services.mjs +33 -7
- package/dist/services.mjs.map +1 -1
- package/dist/teams.mjs +7 -6
- package/dist/teams.mjs.map +1 -1
- package/dist/types.d.d.mts +3 -0
- package/dist/types.d.d.ts +3 -0
- package/dist/types.d.js.map +1 -1
- package/dist/users.mjs +7 -6
- package/dist/users.mjs.map +1 -1
- package/package.json +1 -1
package/dist/index.mjs
CHANGED
|
@@ -1,15 +1,15 @@
|
|
|
1
1
|
// src/index.ts
|
|
2
|
-
import { join as join13 } from "
|
|
2
|
+
import { join as join13 } from "path";
|
|
3
3
|
|
|
4
4
|
// src/events.ts
|
|
5
|
-
import fs2 from "
|
|
6
|
-
import { join as join3 } from "
|
|
5
|
+
import fs2 from "fs/promises";
|
|
6
|
+
import { join as join3 } from "path";
|
|
7
7
|
|
|
8
8
|
// src/internal/utils.ts
|
|
9
9
|
import { globSync } from "glob";
|
|
10
|
-
import fsSync from "
|
|
10
|
+
import fsSync from "fs";
|
|
11
11
|
import { copy } from "fs-extra";
|
|
12
|
-
import { join, dirname, normalize, resolve, relative } from "
|
|
12
|
+
import { join, dirname, normalize, resolve, relative } from "path";
|
|
13
13
|
import matter from "gray-matter";
|
|
14
14
|
import { satisfies, validRange, valid } from "semver";
|
|
15
15
|
var versionExists = async (catalogDir, id, version) => {
|
|
@@ -115,8 +115,8 @@ var uniqueVersions = (messages) => {
|
|
|
115
115
|
// src/internal/resources.ts
|
|
116
116
|
import { dirname as dirname2, join as join2 } from "path";
|
|
117
117
|
import matter2 from "gray-matter";
|
|
118
|
-
import fs from "
|
|
119
|
-
import fsSync2 from "
|
|
118
|
+
import fs from "fs/promises";
|
|
119
|
+
import fsSync2 from "fs";
|
|
120
120
|
import { satisfies as satisfies2 } from "semver";
|
|
121
121
|
import { lock, unlock } from "proper-lockfile";
|
|
122
122
|
var versionResource = async (catalogDir, id) => {
|
|
@@ -187,9 +187,22 @@ var writeResource = async (catalogDir, resource, options = {
|
|
|
187
187
|
}
|
|
188
188
|
};
|
|
189
189
|
var getResource = async (catalogDir, id, version, options) => {
|
|
190
|
+
const attachSchema = options?.attachSchema || false;
|
|
190
191
|
const file = await findFileById(catalogDir, id, version);
|
|
191
192
|
if (!file) return;
|
|
192
193
|
const { data, content } = matter2.read(file);
|
|
194
|
+
if (attachSchema && data?.schemaPath) {
|
|
195
|
+
const resourceDirectory = dirname2(file);
|
|
196
|
+
const pathToSchema = join2(resourceDirectory, data.schemaPath);
|
|
197
|
+
if (fsSync2.existsSync(pathToSchema)) {
|
|
198
|
+
const schema = fsSync2.readFileSync(pathToSchema, "utf8");
|
|
199
|
+
try {
|
|
200
|
+
data.schema = JSON.parse(schema);
|
|
201
|
+
} catch (error) {
|
|
202
|
+
data.schema = schema;
|
|
203
|
+
}
|
|
204
|
+
}
|
|
205
|
+
}
|
|
193
206
|
return {
|
|
194
207
|
...data,
|
|
195
208
|
markdown: content.trim()
|
|
@@ -208,7 +221,8 @@ var getResources = async (catalogDir, {
|
|
|
208
221
|
type,
|
|
209
222
|
latestOnly = false,
|
|
210
223
|
ignore = [],
|
|
211
|
-
pattern = ""
|
|
224
|
+
pattern = "",
|
|
225
|
+
attachSchema = false
|
|
212
226
|
}) => {
|
|
213
227
|
const ignoreList = latestOnly ? `**/versioned/**` : "";
|
|
214
228
|
const filePattern = pattern || `${catalogDir}/**/${type}/**/index.{md,mdx}`;
|
|
@@ -216,6 +230,18 @@ var getResources = async (catalogDir, {
|
|
|
216
230
|
if (files.length === 0) return;
|
|
217
231
|
return files.map((file) => {
|
|
218
232
|
const { data, content } = matter2.read(file);
|
|
233
|
+
if (attachSchema && data?.schemaPath) {
|
|
234
|
+
const resourceDirectory = dirname2(file);
|
|
235
|
+
const pathToSchema = join2(resourceDirectory, data.schemaPath);
|
|
236
|
+
if (fsSync2.existsSync(pathToSchema)) {
|
|
237
|
+
const schema = fsSync2.readFileSync(pathToSchema, "utf8");
|
|
238
|
+
try {
|
|
239
|
+
data.schema = JSON.parse(schema);
|
|
240
|
+
} catch (error) {
|
|
241
|
+
data.schema = schema;
|
|
242
|
+
}
|
|
243
|
+
}
|
|
244
|
+
}
|
|
219
245
|
return {
|
|
220
246
|
...data,
|
|
221
247
|
markdown: content.trim()
|
|
@@ -266,7 +292,7 @@ var getVersionedDirectory = (sourceDirectory, version) => {
|
|
|
266
292
|
};
|
|
267
293
|
|
|
268
294
|
// src/events.ts
|
|
269
|
-
var getEvent = (directory) => async (id, version) => getResource(directory, id, version, { type: "event" });
|
|
295
|
+
var getEvent = (directory) => async (id, version, options) => getResource(directory, id, version, { type: "event", ...options });
|
|
270
296
|
var getEvents = (directory) => async (options) => getResources(directory, { type: "events", ...options });
|
|
271
297
|
var writeEvent = (directory) => async (event, options = {
|
|
272
298
|
path: "",
|
|
@@ -299,9 +325,9 @@ var eventHasVersion = (directory) => async (id, version) => {
|
|
|
299
325
|
};
|
|
300
326
|
|
|
301
327
|
// src/commands.ts
|
|
302
|
-
import fs3 from "
|
|
303
|
-
import { join as join4 } from "
|
|
304
|
-
var getCommand = (directory) => async (id, version) => getResource(directory, id, version, { type: "command" });
|
|
328
|
+
import fs3 from "fs/promises";
|
|
329
|
+
import { join as join4 } from "path";
|
|
330
|
+
var getCommand = (directory) => async (id, version, options) => getResource(directory, id, version, { type: "command", ...options });
|
|
305
331
|
var getCommands = (directory) => async (options) => getResources(directory, { type: "commands", ...options });
|
|
306
332
|
var writeCommand = (directory) => async (command, options = {
|
|
307
333
|
path: "",
|
|
@@ -333,9 +359,9 @@ var commandHasVersion = (directory) => async (id, version) => {
|
|
|
333
359
|
};
|
|
334
360
|
|
|
335
361
|
// src/queries.ts
|
|
336
|
-
import fs4 from "
|
|
337
|
-
import { join as join5 } from "
|
|
338
|
-
var getQuery = (directory) => async (id, version) => getResource(directory, id, version, { type: "query" });
|
|
362
|
+
import fs4 from "fs/promises";
|
|
363
|
+
import { join as join5 } from "path";
|
|
364
|
+
var getQuery = (directory) => async (id, version, options) => getResource(directory, id, version, { type: "query", ...options });
|
|
339
365
|
var writeQuery = (directory) => async (query, options = {
|
|
340
366
|
path: "",
|
|
341
367
|
override: false,
|
|
@@ -369,8 +395,8 @@ var queryHasVersion = (directory) => async (id, version) => {
|
|
|
369
395
|
};
|
|
370
396
|
|
|
371
397
|
// src/services.ts
|
|
372
|
-
import fs5 from "
|
|
373
|
-
import { join as join6, dirname as dirname4, extname } from "
|
|
398
|
+
import fs5 from "fs/promises";
|
|
399
|
+
import { join as join6, dirname as dirname4, extname } from "path";
|
|
374
400
|
var getService = (directory) => async (id, version) => getResource(directory, id, version, { type: "service" });
|
|
375
401
|
var getServices = (directory) => async (options) => getResources(directory, {
|
|
376
402
|
type: "services",
|
|
@@ -469,9 +495,9 @@ var serviceHasVersion = (directory) => async (id, version) => {
|
|
|
469
495
|
};
|
|
470
496
|
|
|
471
497
|
// src/domains.ts
|
|
472
|
-
import fs6 from "
|
|
473
|
-
import path, { join as join7 } from "
|
|
474
|
-
import fsSync3 from "
|
|
498
|
+
import fs6 from "fs/promises";
|
|
499
|
+
import path, { join as join7 } from "path";
|
|
500
|
+
import fsSync3 from "fs";
|
|
475
501
|
import matter3 from "gray-matter";
|
|
476
502
|
var getDomain = (directory) => async (id, version) => getResource(directory, id, version, { type: "domain" });
|
|
477
503
|
var getDomains = (directory) => async (options) => getResources(directory, {
|
|
@@ -552,8 +578,8 @@ var addSubDomainToDomain = (directory) => async (id, subDomain, version) => {
|
|
|
552
578
|
};
|
|
553
579
|
|
|
554
580
|
// src/channels.ts
|
|
555
|
-
import fs7 from "
|
|
556
|
-
import { join as join8, extname as extname2 } from "
|
|
581
|
+
import fs7 from "fs/promises";
|
|
582
|
+
import { join as join8, extname as extname2 } from "path";
|
|
557
583
|
var getChannel = (directory) => async (id, version) => getResource(directory, id, version, { type: "channel" });
|
|
558
584
|
var getChannels = (directory) => async (options) => getResources(directory, { type: "channels", ...options });
|
|
559
585
|
var writeChannel = (directory) => async (channel, options = { path: "" }) => writeResource(directory, { ...channel }, { ...options, type: "channel" });
|
|
@@ -607,7 +633,7 @@ var addMessageToChannel = (directory, collection) => async (id, _message, versio
|
|
|
607
633
|
|
|
608
634
|
// src/eventcatalog.ts
|
|
609
635
|
import fs8 from "fs";
|
|
610
|
-
import path2, { join as join9 } from "
|
|
636
|
+
import path2, { join as join9 } from "path";
|
|
611
637
|
var DUMP_VERSION = "0.0.1";
|
|
612
638
|
var getEventCatalogVersion = async (catalogDir) => {
|
|
613
639
|
try {
|
|
@@ -693,9 +719,9 @@ var dumpCatalog = (directory) => async (options) => {
|
|
|
693
719
|
};
|
|
694
720
|
|
|
695
721
|
// src/custom-docs.ts
|
|
696
|
-
import path3, { join as join10 } from "
|
|
697
|
-
import fsSync4 from "
|
|
698
|
-
import fs9 from "
|
|
722
|
+
import path3, { join as join10 } from "path";
|
|
723
|
+
import fsSync4 from "fs";
|
|
724
|
+
import fs9 from "fs/promises";
|
|
699
725
|
import matter4 from "gray-matter";
|
|
700
726
|
import slugify from "slugify";
|
|
701
727
|
var getCustomDoc = (directory) => async (filePath) => {
|
|
@@ -729,9 +755,9 @@ var rmCustomDoc = (directory) => async (filePath) => {
|
|
|
729
755
|
};
|
|
730
756
|
|
|
731
757
|
// src/teams.ts
|
|
732
|
-
import fs10 from "
|
|
733
|
-
import fsSync5 from "
|
|
734
|
-
import { join as join11 } from "
|
|
758
|
+
import fs10 from "fs/promises";
|
|
759
|
+
import fsSync5 from "fs";
|
|
760
|
+
import { join as join11 } from "path";
|
|
735
761
|
import matter5 from "gray-matter";
|
|
736
762
|
var getTeam = (catalogDir) => async (id) => {
|
|
737
763
|
const files = await getFiles(`${catalogDir}/${id}.{md,mdx}`);
|
|
@@ -775,8 +801,8 @@ var rmTeamById = (catalogDir) => async (id) => {
|
|
|
775
801
|
};
|
|
776
802
|
|
|
777
803
|
// src/users.ts
|
|
778
|
-
import fsSync6 from "
|
|
779
|
-
import { join as join12 } from "
|
|
804
|
+
import fsSync6 from "fs";
|
|
805
|
+
import { join as join12 } from "path";
|
|
780
806
|
import matter6 from "gray-matter";
|
|
781
807
|
var getUser = (catalogDir) => async (id) => {
|
|
782
808
|
const files = await getFiles(`${catalogDir}/${id}.{md,mdx}`);
|