@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.
Files changed (52) hide show
  1. package/dist/channels.js +30 -4
  2. package/dist/channels.js.map +1 -1
  3. package/dist/channels.mjs +44 -12
  4. package/dist/channels.mjs.map +1 -1
  5. package/dist/commands.d.mts +10 -1
  6. package/dist/commands.d.ts +10 -1
  7. package/dist/commands.js +28 -2
  8. package/dist/commands.js.map +1 -1
  9. package/dist/commands.mjs +34 -8
  10. package/dist/commands.mjs.map +1 -1
  11. package/dist/custom-docs.js +15 -1
  12. package/dist/custom-docs.js.map +1 -1
  13. package/dist/custom-docs.mjs +26 -9
  14. package/dist/custom-docs.mjs.map +1 -1
  15. package/dist/domains.js +27 -1
  16. package/dist/domains.js.map +1 -1
  17. package/dist/domains.mjs +34 -8
  18. package/dist/domains.mjs.map +1 -1
  19. package/dist/eventcatalog.js +30 -4
  20. package/dist/eventcatalog.js.map +1 -1
  21. package/dist/eventcatalog.mjs +57 -31
  22. package/dist/eventcatalog.mjs.map +1 -1
  23. package/dist/events.d.mts +10 -1
  24. package/dist/events.d.ts +10 -1
  25. package/dist/events.js +28 -2
  26. package/dist/events.js.map +1 -1
  27. package/dist/events.mjs +34 -8
  28. package/dist/events.mjs.map +1 -1
  29. package/dist/index.d.mts +12 -3
  30. package/dist/index.d.ts +12 -3
  31. package/dist/index.js +30 -4
  32. package/dist/index.js.map +1 -1
  33. package/dist/index.mjs +57 -31
  34. package/dist/index.mjs.map +1 -1
  35. package/dist/queries.d.mts +10 -1
  36. package/dist/queries.d.ts +10 -1
  37. package/dist/queries.js +28 -2
  38. package/dist/queries.js.map +1 -1
  39. package/dist/queries.mjs +34 -8
  40. package/dist/queries.mjs.map +1 -1
  41. package/dist/services.js +27 -1
  42. package/dist/services.js.map +1 -1
  43. package/dist/services.mjs +33 -7
  44. package/dist/services.mjs.map +1 -1
  45. package/dist/teams.mjs +7 -6
  46. package/dist/teams.mjs.map +1 -1
  47. package/dist/types.d.d.mts +3 -0
  48. package/dist/types.d.d.ts +3 -0
  49. package/dist/types.d.js.map +1 -1
  50. package/dist/users.mjs +7 -6
  51. package/dist/users.mjs.map +1 -1
  52. package/package.json +1 -1
package/dist/index.d.ts CHANGED
@@ -14,7 +14,9 @@ declare const _default: (path: string) => {
14
14
  * @param version - Optional id of the version to get (supports semver)
15
15
  * @returns Event|Undefined
16
16
  */
17
- getEvent: (id: string, version?: string) => Promise<Event>;
17
+ getEvent: (id: string, version?: string, options?: {
18
+ attachSchema?: boolean;
19
+ }) => Promise<Event>;
18
20
  /**
19
21
  * Returns all events from EventCatalog
20
22
  * @param latestOnly - optional boolean, set to true to get only latest versions
@@ -22,6 +24,7 @@ declare const _default: (path: string) => {
22
24
  */
23
25
  getEvents: (options?: {
24
26
  latestOnly?: boolean;
27
+ attachSchema?: boolean;
25
28
  }) => Promise<Event[]>;
26
29
  /**
27
30
  * Adds an event to EventCatalog
@@ -111,7 +114,9 @@ declare const _default: (path: string) => {
111
114
  * @param version - Optional id of the version to get (supports semver)
112
115
  * @returns Command|Undefined
113
116
  */
114
- getCommand: (id: string, version?: string) => Promise<Command>;
117
+ getCommand: (id: string, version?: string, options?: {
118
+ attachSchema?: boolean;
119
+ }) => Promise<Command>;
115
120
  /**
116
121
  * Returns all commands from EventCatalog
117
122
  * @param latestOnly - optional boolean, set to true to get only latest versions
@@ -119,6 +124,7 @@ declare const _default: (path: string) => {
119
124
  */
120
125
  getCommands: (options?: {
121
126
  latestOnly?: boolean;
127
+ attachSchema?: boolean;
122
128
  }) => Promise<Command[]>;
123
129
  /**
124
130
  * Adds an command to EventCatalog
@@ -208,7 +214,9 @@ declare const _default: (path: string) => {
208
214
  * @param version - Optional id of the version to get (supports semver)
209
215
  * @returns Query|Undefined
210
216
  */
211
- getQuery: (id: string, version?: string) => Promise<Query>;
217
+ getQuery: (id: string, version?: string, options?: {
218
+ attachSchema?: boolean;
219
+ }) => Promise<Query>;
212
220
  /**
213
221
  * Returns all queries from EventCatalog
214
222
  * @param latestOnly - optional boolean, set to true to get only latest versions
@@ -216,6 +224,7 @@ declare const _default: (path: string) => {
216
224
  */
217
225
  getQueries: (options?: {
218
226
  latestOnly?: boolean;
227
+ attachSchema?: boolean;
219
228
  }) => Promise<Query[]>;
220
229
  /**
221
230
  * Adds a query to EventCatalog
package/dist/index.js CHANGED
@@ -221,9 +221,22 @@ var writeResource = async (catalogDir, resource, options = {
221
221
  }
222
222
  };
223
223
  var getResource = async (catalogDir, id, version, options) => {
224
+ const attachSchema = options?.attachSchema || false;
224
225
  const file = await findFileById(catalogDir, id, version);
225
226
  if (!file) return;
226
227
  const { data, content } = import_gray_matter2.default.read(file);
228
+ if (attachSchema && data?.schemaPath) {
229
+ const resourceDirectory = (0, import_path.dirname)(file);
230
+ const pathToSchema = (0, import_path.join)(resourceDirectory, data.schemaPath);
231
+ if (import_node_fs2.default.existsSync(pathToSchema)) {
232
+ const schema = import_node_fs2.default.readFileSync(pathToSchema, "utf8");
233
+ try {
234
+ data.schema = JSON.parse(schema);
235
+ } catch (error) {
236
+ data.schema = schema;
237
+ }
238
+ }
239
+ }
227
240
  return {
228
241
  ...data,
229
242
  markdown: content.trim()
@@ -242,7 +255,8 @@ var getResources = async (catalogDir, {
242
255
  type,
243
256
  latestOnly = false,
244
257
  ignore = [],
245
- pattern = ""
258
+ pattern = "",
259
+ attachSchema = false
246
260
  }) => {
247
261
  const ignoreList = latestOnly ? `**/versioned/**` : "";
248
262
  const filePattern = pattern || `${catalogDir}/**/${type}/**/index.{md,mdx}`;
@@ -250,6 +264,18 @@ var getResources = async (catalogDir, {
250
264
  if (files.length === 0) return;
251
265
  return files.map((file) => {
252
266
  const { data, content } = import_gray_matter2.default.read(file);
267
+ if (attachSchema && data?.schemaPath) {
268
+ const resourceDirectory = (0, import_path.dirname)(file);
269
+ const pathToSchema = (0, import_path.join)(resourceDirectory, data.schemaPath);
270
+ if (import_node_fs2.default.existsSync(pathToSchema)) {
271
+ const schema = import_node_fs2.default.readFileSync(pathToSchema, "utf8");
272
+ try {
273
+ data.schema = JSON.parse(schema);
274
+ } catch (error) {
275
+ data.schema = schema;
276
+ }
277
+ }
278
+ }
253
279
  return {
254
280
  ...data,
255
281
  markdown: content.trim()
@@ -300,7 +326,7 @@ var getVersionedDirectory = (sourceDirectory, version) => {
300
326
  };
301
327
 
302
328
  // src/events.ts
303
- var getEvent = (directory) => async (id, version) => getResource(directory, id, version, { type: "event" });
329
+ var getEvent = (directory) => async (id, version, options) => getResource(directory, id, version, { type: "event", ...options });
304
330
  var getEvents = (directory) => async (options) => getResources(directory, { type: "events", ...options });
305
331
  var writeEvent = (directory) => async (event, options = {
306
332
  path: "",
@@ -335,7 +361,7 @@ var eventHasVersion = (directory) => async (id, version) => {
335
361
  // src/commands.ts
336
362
  var import_promises3 = __toESM(require("fs/promises"));
337
363
  var import_node_path3 = require("path");
338
- var getCommand = (directory) => async (id, version) => getResource(directory, id, version, { type: "command" });
364
+ var getCommand = (directory) => async (id, version, options) => getResource(directory, id, version, { type: "command", ...options });
339
365
  var getCommands = (directory) => async (options) => getResources(directory, { type: "commands", ...options });
340
366
  var writeCommand = (directory) => async (command, options = {
341
367
  path: "",
@@ -369,7 +395,7 @@ var commandHasVersion = (directory) => async (id, version) => {
369
395
  // src/queries.ts
370
396
  var import_promises4 = __toESM(require("fs/promises"));
371
397
  var import_node_path4 = require("path");
372
- var getQuery = (directory) => async (id, version) => getResource(directory, id, version, { type: "query" });
398
+ var getQuery = (directory) => async (id, version, options) => getResource(directory, id, version, { type: "query", ...options });
373
399
  var writeQuery = (directory) => async (query, options = {
374
400
  path: "",
375
401
  override: false,