@eventcatalog/sdk 2.3.6 → 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 +40 -5
- package/dist/eventcatalog.js.map +1 -1
- package/dist/eventcatalog.mjs +67 -32
- 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 +26 -9
- package/dist/index.d.ts +26 -9
- package/dist/index.js +40 -5
- package/dist/index.js.map +1 -1
- package/dist/index.mjs +67 -32
- 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/eventcatalog.mjs
CHANGED
|
@@ -1,19 +1,19 @@
|
|
|
1
1
|
// src/eventcatalog.ts
|
|
2
2
|
import fs10 from "fs";
|
|
3
|
-
import path3, { join as join13 } from "
|
|
3
|
+
import path3, { join as join13 } from "path";
|
|
4
4
|
|
|
5
5
|
// src/index.ts
|
|
6
|
-
import { join as join12 } from "
|
|
6
|
+
import { join as join12 } from "path";
|
|
7
7
|
|
|
8
8
|
// src/events.ts
|
|
9
|
-
import fs2 from "
|
|
10
|
-
import { join as join3 } from "
|
|
9
|
+
import fs2 from "fs/promises";
|
|
10
|
+
import { join as join3 } from "path";
|
|
11
11
|
|
|
12
12
|
// src/internal/utils.ts
|
|
13
13
|
import { globSync } from "glob";
|
|
14
|
-
import fsSync from "
|
|
14
|
+
import fsSync from "fs";
|
|
15
15
|
import { copy } from "fs-extra";
|
|
16
|
-
import { join, dirname, normalize, resolve, relative } from "
|
|
16
|
+
import { join, dirname, normalize, resolve, relative } from "path";
|
|
17
17
|
import matter from "gray-matter";
|
|
18
18
|
import { satisfies, validRange, valid } from "semver";
|
|
19
19
|
var versionExists = async (catalogDir, id, version) => {
|
|
@@ -119,8 +119,8 @@ var uniqueVersions = (messages) => {
|
|
|
119
119
|
// src/internal/resources.ts
|
|
120
120
|
import { dirname as dirname2, join as join2 } from "path";
|
|
121
121
|
import matter2 from "gray-matter";
|
|
122
|
-
import fs from "
|
|
123
|
-
import fsSync2 from "
|
|
122
|
+
import fs from "fs/promises";
|
|
123
|
+
import fsSync2 from "fs";
|
|
124
124
|
import { satisfies as satisfies2 } from "semver";
|
|
125
125
|
import { lock, unlock } from "proper-lockfile";
|
|
126
126
|
var versionResource = async (catalogDir, id) => {
|
|
@@ -191,9 +191,22 @@ var writeResource = async (catalogDir, resource, options = {
|
|
|
191
191
|
}
|
|
192
192
|
};
|
|
193
193
|
var getResource = async (catalogDir, id, version, options) => {
|
|
194
|
+
const attachSchema = options?.attachSchema || false;
|
|
194
195
|
const file = await findFileById(catalogDir, id, version);
|
|
195
196
|
if (!file) return;
|
|
196
197
|
const { data, content } = matter2.read(file);
|
|
198
|
+
if (attachSchema && data?.schemaPath) {
|
|
199
|
+
const resourceDirectory = dirname2(file);
|
|
200
|
+
const pathToSchema = join2(resourceDirectory, data.schemaPath);
|
|
201
|
+
if (fsSync2.existsSync(pathToSchema)) {
|
|
202
|
+
const schema = fsSync2.readFileSync(pathToSchema, "utf8");
|
|
203
|
+
try {
|
|
204
|
+
data.schema = JSON.parse(schema);
|
|
205
|
+
} catch (error) {
|
|
206
|
+
data.schema = schema;
|
|
207
|
+
}
|
|
208
|
+
}
|
|
209
|
+
}
|
|
197
210
|
return {
|
|
198
211
|
...data,
|
|
199
212
|
markdown: content.trim()
|
|
@@ -212,7 +225,8 @@ var getResources = async (catalogDir, {
|
|
|
212
225
|
type,
|
|
213
226
|
latestOnly = false,
|
|
214
227
|
ignore = [],
|
|
215
|
-
pattern = ""
|
|
228
|
+
pattern = "",
|
|
229
|
+
attachSchema = false
|
|
216
230
|
}) => {
|
|
217
231
|
const ignoreList = latestOnly ? `**/versioned/**` : "";
|
|
218
232
|
const filePattern = pattern || `${catalogDir}/**/${type}/**/index.{md,mdx}`;
|
|
@@ -220,6 +234,18 @@ var getResources = async (catalogDir, {
|
|
|
220
234
|
if (files.length === 0) return;
|
|
221
235
|
return files.map((file) => {
|
|
222
236
|
const { data, content } = matter2.read(file);
|
|
237
|
+
if (attachSchema && data?.schemaPath) {
|
|
238
|
+
const resourceDirectory = dirname2(file);
|
|
239
|
+
const pathToSchema = join2(resourceDirectory, data.schemaPath);
|
|
240
|
+
if (fsSync2.existsSync(pathToSchema)) {
|
|
241
|
+
const schema = fsSync2.readFileSync(pathToSchema, "utf8");
|
|
242
|
+
try {
|
|
243
|
+
data.schema = JSON.parse(schema);
|
|
244
|
+
} catch (error) {
|
|
245
|
+
data.schema = schema;
|
|
246
|
+
}
|
|
247
|
+
}
|
|
248
|
+
}
|
|
223
249
|
return {
|
|
224
250
|
...data,
|
|
225
251
|
markdown: content.trim()
|
|
@@ -270,7 +296,7 @@ var getVersionedDirectory = (sourceDirectory, version) => {
|
|
|
270
296
|
};
|
|
271
297
|
|
|
272
298
|
// src/events.ts
|
|
273
|
-
var getEvent = (directory) => async (id, version) => getResource(directory, id, version, { type: "event" });
|
|
299
|
+
var getEvent = (directory) => async (id, version, options) => getResource(directory, id, version, { type: "event", ...options });
|
|
274
300
|
var getEvents = (directory) => async (options) => getResources(directory, { type: "events", ...options });
|
|
275
301
|
var writeEvent = (directory) => async (event, options = {
|
|
276
302
|
path: "",
|
|
@@ -303,9 +329,9 @@ var eventHasVersion = (directory) => async (id, version) => {
|
|
|
303
329
|
};
|
|
304
330
|
|
|
305
331
|
// src/commands.ts
|
|
306
|
-
import fs3 from "
|
|
307
|
-
import { join as join4 } from "
|
|
308
|
-
var getCommand = (directory) => async (id, version) => getResource(directory, id, version, { type: "command" });
|
|
332
|
+
import fs3 from "fs/promises";
|
|
333
|
+
import { join as join4 } from "path";
|
|
334
|
+
var getCommand = (directory) => async (id, version, options) => getResource(directory, id, version, { type: "command", ...options });
|
|
309
335
|
var getCommands = (directory) => async (options) => getResources(directory, { type: "commands", ...options });
|
|
310
336
|
var writeCommand = (directory) => async (command, options = {
|
|
311
337
|
path: "",
|
|
@@ -337,9 +363,9 @@ var commandHasVersion = (directory) => async (id, version) => {
|
|
|
337
363
|
};
|
|
338
364
|
|
|
339
365
|
// src/queries.ts
|
|
340
|
-
import fs4 from "
|
|
341
|
-
import { join as join5 } from "
|
|
342
|
-
var getQuery = (directory) => async (id, version) => getResource(directory, id, version, { type: "query" });
|
|
366
|
+
import fs4 from "fs/promises";
|
|
367
|
+
import { join as join5 } from "path";
|
|
368
|
+
var getQuery = (directory) => async (id, version, options) => getResource(directory, id, version, { type: "query", ...options });
|
|
343
369
|
var writeQuery = (directory) => async (query, options = {
|
|
344
370
|
path: "",
|
|
345
371
|
override: false,
|
|
@@ -373,8 +399,8 @@ var queryHasVersion = (directory) => async (id, version) => {
|
|
|
373
399
|
};
|
|
374
400
|
|
|
375
401
|
// src/services.ts
|
|
376
|
-
import fs5 from "
|
|
377
|
-
import { join as join6, dirname as dirname4, extname } from "
|
|
402
|
+
import fs5 from "fs/promises";
|
|
403
|
+
import { join as join6, dirname as dirname4, extname } from "path";
|
|
378
404
|
var getService = (directory) => async (id, version) => getResource(directory, id, version, { type: "service" });
|
|
379
405
|
var getServices = (directory) => async (options) => getResources(directory, {
|
|
380
406
|
type: "services",
|
|
@@ -473,9 +499,9 @@ var serviceHasVersion = (directory) => async (id, version) => {
|
|
|
473
499
|
};
|
|
474
500
|
|
|
475
501
|
// src/domains.ts
|
|
476
|
-
import fs6 from "
|
|
477
|
-
import path, { join as join7 } from "
|
|
478
|
-
import fsSync3 from "
|
|
502
|
+
import fs6 from "fs/promises";
|
|
503
|
+
import path, { join as join7 } from "path";
|
|
504
|
+
import fsSync3 from "fs";
|
|
479
505
|
import matter3 from "gray-matter";
|
|
480
506
|
var getDomain = (directory) => async (id, version) => getResource(directory, id, version, { type: "domain" });
|
|
481
507
|
var getDomains = (directory) => async (options) => getResources(directory, {
|
|
@@ -556,8 +582,8 @@ var addSubDomainToDomain = (directory) => async (id, subDomain, version) => {
|
|
|
556
582
|
};
|
|
557
583
|
|
|
558
584
|
// src/channels.ts
|
|
559
|
-
import fs7 from "
|
|
560
|
-
import { join as join8, extname as extname2 } from "
|
|
585
|
+
import fs7 from "fs/promises";
|
|
586
|
+
import { join as join8, extname as extname2 } from "path";
|
|
561
587
|
var getChannel = (directory) => async (id, version) => getResource(directory, id, version, { type: "channel" });
|
|
562
588
|
var getChannels = (directory) => async (options) => getResources(directory, { type: "channels", ...options });
|
|
563
589
|
var writeChannel = (directory) => async (channel, options = { path: "" }) => writeResource(directory, { ...channel }, { ...options, type: "channel" });
|
|
@@ -610,9 +636,9 @@ var addMessageToChannel = (directory, collection) => async (id, _message, versio
|
|
|
610
636
|
};
|
|
611
637
|
|
|
612
638
|
// src/custom-docs.ts
|
|
613
|
-
import path2, { join as join9 } from "
|
|
614
|
-
import fsSync4 from "
|
|
615
|
-
import fs8 from "
|
|
639
|
+
import path2, { join as join9 } from "path";
|
|
640
|
+
import fsSync4 from "fs";
|
|
641
|
+
import fs8 from "fs/promises";
|
|
616
642
|
import matter4 from "gray-matter";
|
|
617
643
|
import slugify from "slugify";
|
|
618
644
|
var getCustomDoc = (directory) => async (filePath) => {
|
|
@@ -646,9 +672,9 @@ var rmCustomDoc = (directory) => async (filePath) => {
|
|
|
646
672
|
};
|
|
647
673
|
|
|
648
674
|
// src/teams.ts
|
|
649
|
-
import fs9 from "
|
|
650
|
-
import fsSync5 from "
|
|
651
|
-
import { join as join10 } from "
|
|
675
|
+
import fs9 from "fs/promises";
|
|
676
|
+
import fsSync5 from "fs";
|
|
677
|
+
import { join as join10 } from "path";
|
|
652
678
|
import matter5 from "gray-matter";
|
|
653
679
|
var getTeam = (catalogDir) => async (id) => {
|
|
654
680
|
const files = await getFiles(`${catalogDir}/${id}.{md,mdx}`);
|
|
@@ -692,8 +718,8 @@ var rmTeamById = (catalogDir) => async (id) => {
|
|
|
692
718
|
};
|
|
693
719
|
|
|
694
720
|
// src/users.ts
|
|
695
|
-
import fsSync6 from "
|
|
696
|
-
import { join as join11 } from "
|
|
721
|
+
import fsSync6 from "fs";
|
|
722
|
+
import { join as join11 } from "path";
|
|
697
723
|
import matter6 from "gray-matter";
|
|
698
724
|
var getUser = (catalogDir) => async (id) => {
|
|
699
725
|
const files = await getFiles(`${catalogDir}/${id}.{md,mdx}`);
|
|
@@ -1400,7 +1426,16 @@ var index_default = (path4) => {
|
|
|
1400
1426
|
* @param directory - The directory to dump the catalog to
|
|
1401
1427
|
* @returns A JSON file with the catalog
|
|
1402
1428
|
*/
|
|
1403
|
-
dumpCatalog: dumpCatalog(join12(path4))
|
|
1429
|
+
dumpCatalog: dumpCatalog(join12(path4)),
|
|
1430
|
+
/**
|
|
1431
|
+
* ================================
|
|
1432
|
+
* Resources Utils
|
|
1433
|
+
* ================================
|
|
1434
|
+
*/
|
|
1435
|
+
/**
|
|
1436
|
+
* Returns the path to a given resource by id and version
|
|
1437
|
+
*/
|
|
1438
|
+
getResourcePath
|
|
1404
1439
|
};
|
|
1405
1440
|
};
|
|
1406
1441
|
|