@eventcatalog/sdk 2.9.6 → 2.9.8

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 (59) hide show
  1. package/dist/channels.js +1 -1
  2. package/dist/channels.js.map +1 -1
  3. package/dist/channels.mjs +15 -14
  4. package/dist/channels.mjs.map +1 -1
  5. package/dist/commands.d.mts +6 -2
  6. package/dist/commands.d.ts +6 -2
  7. package/dist/commands.js +17 -6
  8. package/dist/commands.js.map +1 -1
  9. package/dist/commands.mjs +29 -17
  10. package/dist/commands.mjs.map +1 -1
  11. package/dist/containers.js +14 -3
  12. package/dist/containers.js.map +1 -1
  13. package/dist/containers.mjs +26 -14
  14. package/dist/containers.mjs.map +1 -1
  15. package/dist/custom-docs.js.map +1 -1
  16. package/dist/custom-docs.mjs.map +1 -1
  17. package/dist/data-stores.js +14 -3
  18. package/dist/data-stores.js.map +1 -1
  19. package/dist/data-stores.mjs +26 -14
  20. package/dist/data-stores.mjs.map +1 -1
  21. package/dist/domains.js +14 -3
  22. package/dist/domains.js.map +1 -1
  23. package/dist/domains.mjs +33 -21
  24. package/dist/domains.mjs.map +1 -1
  25. package/dist/entities.js +1 -1
  26. package/dist/entities.js.map +1 -1
  27. package/dist/entities.mjs +13 -12
  28. package/dist/entities.mjs.map +1 -1
  29. package/dist/eventcatalog.js +23 -12
  30. package/dist/eventcatalog.js.map +1 -1
  31. package/dist/eventcatalog.mjs +23 -12
  32. package/dist/eventcatalog.mjs.map +1 -1
  33. package/dist/events.d.mts +6 -2
  34. package/dist/events.d.ts +6 -2
  35. package/dist/events.js +17 -6
  36. package/dist/events.js.map +1 -1
  37. package/dist/events.mjs +29 -17
  38. package/dist/events.mjs.map +1 -1
  39. package/dist/index.d.mts +18 -6
  40. package/dist/index.d.ts +18 -6
  41. package/dist/index.js +23 -12
  42. package/dist/index.js.map +1 -1
  43. package/dist/index.mjs +23 -12
  44. package/dist/index.mjs.map +1 -1
  45. package/dist/messages.js.map +1 -1
  46. package/dist/messages.mjs.map +1 -1
  47. package/dist/queries.d.mts +6 -2
  48. package/dist/queries.d.ts +6 -2
  49. package/dist/queries.js +17 -6
  50. package/dist/queries.js.map +1 -1
  51. package/dist/queries.mjs +29 -17
  52. package/dist/queries.mjs.map +1 -1
  53. package/dist/services.js +14 -3
  54. package/dist/services.js.map +1 -1
  55. package/dist/services.mjs +39 -27
  56. package/dist/services.mjs.map +1 -1
  57. package/dist/teams.js.map +1 -1
  58. package/dist/teams.mjs.map +1 -1
  59. package/package.json +3 -3
package/dist/index.d.mts CHANGED
@@ -84,7 +84,9 @@ declare const _default: (path: string) => {
84
84
  addFileToEvent: (id: string, file: {
85
85
  content: string;
86
86
  fileName: string;
87
- }, version?: string) => Promise<void>;
87
+ }, version?: string, options?: {
88
+ path?: string;
89
+ }) => Promise<void>;
88
90
  /**
89
91
  * Adds a schema to the given event
90
92
  * @param id - The id of the event to add the schema to
@@ -95,7 +97,9 @@ declare const _default: (path: string) => {
95
97
  addSchemaToEvent: (id: string, schema: {
96
98
  schema: string;
97
99
  fileName: string;
98
- }, version?: string) => Promise<void>;
100
+ }, version?: string, options?: {
101
+ path?: string;
102
+ }) => Promise<void>;
99
103
  /**
100
104
  * Check to see if an event version exists
101
105
  * @param id - The id of the event
@@ -184,7 +188,9 @@ declare const _default: (path: string) => {
184
188
  addFileToCommand: (id: string, file: {
185
189
  content: string;
186
190
  fileName: string;
187
- }, version?: string) => Promise<void>;
191
+ }, version?: string, options?: {
192
+ path?: string;
193
+ }) => Promise<void>;
188
194
  /**
189
195
  * Adds a schema to the given command
190
196
  * @param id - The id of the command to add the schema to
@@ -195,7 +201,9 @@ declare const _default: (path: string) => {
195
201
  addSchemaToCommand: (id: string, schema: {
196
202
  schema: string;
197
203
  fileName: string;
198
- }, version?: string) => Promise<void>;
204
+ }, version?: string, options?: {
205
+ path?: string;
206
+ }) => Promise<void>;
199
207
  /**
200
208
  * Check to see if a command version exists
201
209
  * @param id - The id of the command
@@ -284,7 +292,9 @@ declare const _default: (path: string) => {
284
292
  addFileToQuery: (id: string, file: {
285
293
  content: string;
286
294
  fileName: string;
287
- }, version?: string) => Promise<void>;
295
+ }, version?: string, options?: {
296
+ path?: string;
297
+ }) => Promise<void>;
288
298
  /**
289
299
  * Adds a schema to the given query
290
300
  * @param id - The id of the query to add the schema to
@@ -295,7 +305,9 @@ declare const _default: (path: string) => {
295
305
  addSchemaToQuery: (id: string, schema: {
296
306
  schema: string;
297
307
  fileName: string;
298
- }, version?: string) => Promise<void>;
308
+ }, version?: string, options?: {
309
+ path?: string;
310
+ }) => Promise<void>;
299
311
  /**
300
312
  * Check to see if an query version exists
301
313
  * @param id - The id of the query
package/dist/index.d.ts CHANGED
@@ -84,7 +84,9 @@ declare const _default: (path: string) => {
84
84
  addFileToEvent: (id: string, file: {
85
85
  content: string;
86
86
  fileName: string;
87
- }, version?: string) => Promise<void>;
87
+ }, version?: string, options?: {
88
+ path?: string;
89
+ }) => Promise<void>;
88
90
  /**
89
91
  * Adds a schema to the given event
90
92
  * @param id - The id of the event to add the schema to
@@ -95,7 +97,9 @@ declare const _default: (path: string) => {
95
97
  addSchemaToEvent: (id: string, schema: {
96
98
  schema: string;
97
99
  fileName: string;
98
- }, version?: string) => Promise<void>;
100
+ }, version?: string, options?: {
101
+ path?: string;
102
+ }) => Promise<void>;
99
103
  /**
100
104
  * Check to see if an event version exists
101
105
  * @param id - The id of the event
@@ -184,7 +188,9 @@ declare const _default: (path: string) => {
184
188
  addFileToCommand: (id: string, file: {
185
189
  content: string;
186
190
  fileName: string;
187
- }, version?: string) => Promise<void>;
191
+ }, version?: string, options?: {
192
+ path?: string;
193
+ }) => Promise<void>;
188
194
  /**
189
195
  * Adds a schema to the given command
190
196
  * @param id - The id of the command to add the schema to
@@ -195,7 +201,9 @@ declare const _default: (path: string) => {
195
201
  addSchemaToCommand: (id: string, schema: {
196
202
  schema: string;
197
203
  fileName: string;
198
- }, version?: string) => Promise<void>;
204
+ }, version?: string, options?: {
205
+ path?: string;
206
+ }) => Promise<void>;
199
207
  /**
200
208
  * Check to see if a command version exists
201
209
  * @param id - The id of the command
@@ -284,7 +292,9 @@ declare const _default: (path: string) => {
284
292
  addFileToQuery: (id: string, file: {
285
293
  content: string;
286
294
  fileName: string;
287
- }, version?: string) => Promise<void>;
295
+ }, version?: string, options?: {
296
+ path?: string;
297
+ }) => Promise<void>;
288
298
  /**
289
299
  * Adds a schema to the given query
290
300
  * @param id - The id of the query to add the schema to
@@ -295,7 +305,9 @@ declare const _default: (path: string) => {
295
305
  addSchemaToQuery: (id: string, schema: {
296
306
  schema: string;
297
307
  fileName: string;
298
- }, version?: string) => Promise<void>;
308
+ }, version?: string, options?: {
309
+ path?: string;
310
+ }) => Promise<void>;
299
311
  /**
300
312
  * Check to see if an query version exists
301
313
  * @param id - The id of the query
package/dist/index.js CHANGED
@@ -170,7 +170,7 @@ var versionResource = async (catalogDir, id) => {
170
170
  throw new Error(`No resource found with id: ${id}`);
171
171
  }
172
172
  const file = matchedFiles[0];
173
- const sourceDirectory = (0, import_path.dirname)(file).replace(/\/versioned?\/[^/]+\//, "/");
173
+ const sourceDirectory = (0, import_path.dirname)(file).replace(/[/\\]versioned[/\\][^/\\]+[/\\]/, import_node_path3.default.sep);
174
174
  const { data: { version = "0.0.1" } = {} } = import_gray_matter2.default.read(file);
175
175
  const targetDirectory = getVersionedDirectory(sourceDirectory, version);
176
176
  import_node_fs2.default.mkdirSync(targetDirectory, { recursive: true });
@@ -346,8 +346,19 @@ var waitForFileRemoval = async (path6, maxRetries = 50, delay = 10) => {
346
346
  }
347
347
  throw new Error(`File/directory ${path6} was not removed after ${maxRetries} attempts`);
348
348
  };
349
- var addFileToResource = async (catalogDir, id, file, version) => {
350
- const pathToResource = await findFileById(catalogDir, id, version);
349
+ var addFileToResource = async (catalogDir, id, file, version, options) => {
350
+ let pathToResource;
351
+ if (options?.path) {
352
+ const mdxPath = (0, import_path.join)(catalogDir, options.path, "index.mdx");
353
+ const mdPath = (0, import_path.join)(catalogDir, options.path, "index.md");
354
+ if (import_node_fs2.default.existsSync(mdxPath)) {
355
+ pathToResource = mdxPath;
356
+ } else if (import_node_fs2.default.existsSync(mdPath)) {
357
+ pathToResource = mdPath;
358
+ }
359
+ } else {
360
+ pathToResource = await findFileById(catalogDir, id, version);
361
+ }
351
362
  if (!pathToResource) throw new Error("Cannot find directory to write file to");
352
363
  let fileContent = file.content.trim();
353
364
  try {
@@ -398,9 +409,9 @@ var rmEventById = (directory) => async (id, version, persistFiles) => {
398
409
  await rmResourceById(directory, id, version, { type: "event", persistFiles });
399
410
  };
400
411
  var versionEvent = (directory) => async (id) => versionResource(directory, id);
401
- var addFileToEvent = (directory) => async (id, file, version) => addFileToResource(directory, id, file, version);
402
- var addSchemaToEvent = (directory) => async (id, schema, version) => {
403
- await addFileToEvent(directory)(id, { content: schema.schema, fileName: schema.fileName }, version);
412
+ var addFileToEvent = (directory) => async (id, file, version, options) => addFileToResource(directory, id, file, version, options);
413
+ var addSchemaToEvent = (directory) => async (id, schema, version, options) => {
414
+ await addFileToEvent(directory)(id, { content: schema.schema, fileName: schema.fileName }, version, options);
404
415
  };
405
416
  var eventHasVersion = (directory) => async (id, version) => {
406
417
  const file = await findFileById(directory, id, version);
@@ -432,9 +443,9 @@ var rmCommand = (directory) => async (path6) => {
432
443
  };
433
444
  var rmCommandById = (directory) => async (id, version, persistFiles) => rmResourceById(directory, id, version, { type: "command", persistFiles });
434
445
  var versionCommand = (directory) => async (id) => versionResource(directory, id);
435
- var addFileToCommand = (directory) => async (id, file, version) => addFileToResource(directory, id, file, version);
436
- var addSchemaToCommand = (directory) => async (id, schema, version) => {
437
- await addFileToCommand(directory)(id, { content: schema.schema, fileName: schema.fileName }, version);
446
+ var addFileToCommand = (directory) => async (id, file, version, options) => addFileToResource(directory, id, file, version, options);
447
+ var addSchemaToCommand = (directory) => async (id, schema, version, options) => {
448
+ await addFileToCommand(directory)(id, { content: schema.schema, fileName: schema.fileName }, version, options);
438
449
  };
439
450
  var commandHasVersion = (directory) => async (id, version) => {
440
451
  const file = await findFileById(directory, id, version);
@@ -468,9 +479,9 @@ var rmQueryById = (directory) => async (id, version, persistFiles) => {
468
479
  await rmResourceById(directory, id, version, { type: "query", persistFiles });
469
480
  };
470
481
  var versionQuery = (directory) => async (id) => versionResource(directory, id);
471
- var addFileToQuery = (directory) => async (id, file, version) => addFileToResource(directory, id, file, version);
472
- var addSchemaToQuery = (directory) => async (id, schema, version) => {
473
- await addFileToQuery(directory)(id, { content: schema.schema, fileName: schema.fileName }, version);
482
+ var addFileToQuery = (directory) => async (id, file, version, options) => addFileToResource(directory, id, file, version, options);
483
+ var addSchemaToQuery = (directory) => async (id, schema, version, options) => {
484
+ await addFileToQuery(directory)(id, { content: schema.schema, fileName: schema.fileName }, version, options);
474
485
  };
475
486
  var queryHasVersion = (directory) => async (id, version) => {
476
487
  const file = await findFileById(directory, id, version);