@eventcatalog/sdk 2.11.0 → 2.12.1

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 (114) hide show
  1. package/README.md +86 -1
  2. package/dist/cli/index.d.mts +1 -0
  3. package/dist/cli/index.d.ts +1 -0
  4. package/dist/{eventcatalog.js → cli/index.js} +588 -378
  5. package/dist/cli/index.js.map +1 -0
  6. package/dist/{eventcatalog.mjs → cli/index.mjs} +666 -436
  7. package/dist/cli/index.mjs.map +1 -0
  8. package/dist/cli-docs.d.mts +43 -0
  9. package/dist/cli-docs.d.ts +43 -0
  10. package/dist/cli-docs.js +1614 -0
  11. package/dist/cli-docs.js.map +1 -0
  12. package/dist/cli-docs.mjs +1586 -0
  13. package/dist/cli-docs.mjs.map +1 -0
  14. package/dist/index.d.mts +443 -25
  15. package/dist/index.d.ts +443 -25
  16. package/dist/index.js +204 -121
  17. package/dist/index.js.map +1 -1
  18. package/dist/index.mjs +204 -121
  19. package/dist/index.mjs.map +1 -1
  20. package/package.json +13 -4
  21. package/dist/channels.d.mts +0 -214
  22. package/dist/channels.d.ts +0 -214
  23. package/dist/channels.js +0 -432
  24. package/dist/channels.js.map +0 -1
  25. package/dist/channels.mjs +0 -384
  26. package/dist/channels.mjs.map +0 -1
  27. package/dist/commands.d.mts +0 -274
  28. package/dist/commands.d.ts +0 -274
  29. package/dist/commands.js +0 -394
  30. package/dist/commands.js.map +0 -1
  31. package/dist/commands.mjs +0 -350
  32. package/dist/commands.mjs.map +0 -1
  33. package/dist/containers.d.mts +0 -179
  34. package/dist/containers.d.ts +0 -179
  35. package/dist/containers.js +0 -388
  36. package/dist/containers.js.map +0 -1
  37. package/dist/containers.mjs +0 -345
  38. package/dist/containers.mjs.map +0 -1
  39. package/dist/custom-docs.d.mts +0 -89
  40. package/dist/custom-docs.d.ts +0 -89
  41. package/dist/custom-docs.js +0 -164
  42. package/dist/custom-docs.js.map +0 -1
  43. package/dist/custom-docs.mjs +0 -122
  44. package/dist/custom-docs.mjs.map +0 -1
  45. package/dist/data-products.d.mts +0 -225
  46. package/dist/data-products.d.ts +0 -225
  47. package/dist/data-products.js +0 -375
  48. package/dist/data-products.js.map +0 -1
  49. package/dist/data-products.mjs +0 -332
  50. package/dist/data-products.mjs.map +0 -1
  51. package/dist/data-stores.d.mts +0 -179
  52. package/dist/data-stores.d.ts +0 -179
  53. package/dist/data-stores.js +0 -401
  54. package/dist/data-stores.js.map +0 -1
  55. package/dist/data-stores.mjs +0 -356
  56. package/dist/data-stores.mjs.map +0 -1
  57. package/dist/domains.d.mts +0 -347
  58. package/dist/domains.d.ts +0 -347
  59. package/dist/domains.js +0 -547
  60. package/dist/domains.js.map +0 -1
  61. package/dist/domains.mjs +0 -498
  62. package/dist/domains.mjs.map +0 -1
  63. package/dist/entities.d.mts +0 -174
  64. package/dist/entities.d.ts +0 -174
  65. package/dist/entities.js +0 -348
  66. package/dist/entities.js.map +0 -1
  67. package/dist/entities.mjs +0 -307
  68. package/dist/entities.mjs.map +0 -1
  69. package/dist/eventcatalog.d.mts +0 -21
  70. package/dist/eventcatalog.d.ts +0 -21
  71. package/dist/eventcatalog.js.map +0 -1
  72. package/dist/eventcatalog.mjs.map +0 -1
  73. package/dist/events.d.mts +0 -276
  74. package/dist/events.d.ts +0 -276
  75. package/dist/events.js +0 -393
  76. package/dist/events.js.map +0 -1
  77. package/dist/events.mjs +0 -349
  78. package/dist/events.mjs.map +0 -1
  79. package/dist/messages.d.mts +0 -65
  80. package/dist/messages.d.ts +0 -65
  81. package/dist/messages.js +0 -312
  82. package/dist/messages.js.map +0 -1
  83. package/dist/messages.mjs +0 -269
  84. package/dist/messages.mjs.map +0 -1
  85. package/dist/queries.d.mts +0 -276
  86. package/dist/queries.d.ts +0 -276
  87. package/dist/queries.js +0 -394
  88. package/dist/queries.js.map +0 -1
  89. package/dist/queries.mjs +0 -350
  90. package/dist/queries.mjs.map +0 -1
  91. package/dist/services.d.mts +0 -384
  92. package/dist/services.d.ts +0 -384
  93. package/dist/services.js +0 -577
  94. package/dist/services.js.map +0 -1
  95. package/dist/services.mjs +0 -526
  96. package/dist/services.mjs.map +0 -1
  97. package/dist/teams.d.mts +0 -90
  98. package/dist/teams.d.ts +0 -90
  99. package/dist/teams.js +0 -246
  100. package/dist/teams.js.map +0 -1
  101. package/dist/teams.mjs +0 -202
  102. package/dist/teams.mjs.map +0 -1
  103. package/dist/types.d.d.mts +0 -331
  104. package/dist/types.d.d.ts +0 -331
  105. package/dist/types.d.js +0 -19
  106. package/dist/types.d.js.map +0 -1
  107. package/dist/types.d.mjs +0 -1
  108. package/dist/types.d.mjs.map +0 -1
  109. package/dist/users.d.mts +0 -83
  110. package/dist/users.d.ts +0 -83
  111. package/dist/users.js +0 -127
  112. package/dist/users.js.map +0 -1
  113. package/dist/users.mjs +0 -88
  114. package/dist/users.mjs.map +0 -1
@@ -1,384 +0,0 @@
1
- import { Service } from './types.d.js';
2
-
3
- /**
4
- * Returns a service from EventCatalog.
5
- *
6
- * You can optionally specify a version to get a specific version of the service
7
- *
8
- * @example
9
- * ```ts
10
- * import utils from '@eventcatalog/utils';
11
- *
12
- * const { getService } = utils('/path/to/eventcatalog');
13
- *
14
- * // Gets the latest version of the event
15
- * const service = await getService('InventoryService');
16
- *
17
- * // Gets a version of the event
18
- * const service = await getService('InventoryService', '0.0.1');
19
- * ```
20
- */
21
- declare const getService: (directory: string) => (id: string, version?: string) => Promise<Service>;
22
- /**
23
- * Returns a service from EventCatalog by it's path.
24
- *
25
- * @example
26
- * ```ts
27
- * import utils from '@eventcatalog/utils';
28
- *
29
- * const { getServiceByPath } = utils('/path/to/eventcatalog');
30
- *
31
- * // Returns a service from the catalog by it's path
32
- * const service = await getServiceByPath('/services/InventoryService/index.mdx');
33
- * ```
34
- */
35
- declare const getServiceByPath: (directory: string) => (path: string) => Promise<Service>;
36
- /**
37
- * Returns all services from EventCatalog.
38
- *
39
- * You can optionally specify if you want to get the latest version of the services.
40
- *
41
- * @example
42
- * ```ts
43
- * import utils from '@eventcatalog/utils';
44
- *
45
- * const { getServices } = utils('/path/to/eventcatalog');
46
- *
47
- * // Gets all services (and versions) from the catalog
48
- * const services = await getServices();
49
- *
50
- * // Gets all services (only latest version) from the catalog
51
- * const services = await getServices({ latestOnly: true });
52
- * ```
53
- */
54
- declare const getServices: (directory: string) => (options?: {
55
- latestOnly?: boolean;
56
- }) => Promise<Service[]>;
57
- /**
58
- * Write a Service to EventCatalog.
59
- *
60
- * You can optionally overide the path of the Service.
61
- *
62
- * @example
63
- * ```ts
64
- * import utils from '@eventcatalog/utils';
65
- *
66
- * const { writeService } = utils('/path/to/eventcatalog');
67
- *
68
- * // Write a Service
69
- * // Service would be written to services/InventoryService
70
- * await writeService({
71
- * id: 'InventoryService',
72
- * name: 'Inventory Service',
73
- * version: '0.0.1',
74
- * summary: 'Service that handles the inventory',
75
- * markdown: '# Hello world',
76
- * });
77
- *
78
- * // Write a service to the catalog but override the path
79
- * // Service would be written to services/Inventory/InventoryService
80
- * await writeService({
81
- * id: 'InventoryService',
82
- * name: 'Inventory Adjusted',
83
- * version: '0.0.1',
84
- * summary: 'This is a summary',
85
- * markdown: '# Hello world',
86
- * }, { path: "/Inventory/InventoryService"});
87
- *
88
- * // Write a service to the catalog and override the existing content (if there is any)
89
- * await writeService({
90
- * id: 'InventoryService',
91
- * name: 'Inventory Adjusted',
92
- * version: '0.0.1',
93
- * summary: 'This is a summary',
94
- * markdown: '# Hello world',
95
- * }, { override: true });
96
- *
97
- * // Write a service to the catalog and version the previous version
98
- * // only works if the new version is greater than the previous version
99
- * await writeService({
100
- * id: 'InventoryService',
101
- * name: 'Inventory Adjusted',
102
- * version: '0.0.1',
103
- * summary: 'This is a summary',
104
- * markdown: '# Hello world',
105
- * }, { versionExistingContent: true });
106
- *
107
- * ```
108
- */
109
- declare const writeService: (directory: string) => (service: Service, options?: {
110
- path?: string;
111
- override?: boolean;
112
- versionExistingContent?: boolean;
113
- format?: "md" | "mdx";
114
- }) => Promise<void>;
115
- /**
116
- * Write a versioned service to EventCatalog.
117
- *
118
- * You can optionally overide the path of the Service.
119
- *
120
- * @example
121
- * ```ts
122
- * import utils from '@eventcatalog/utils';
123
- *
124
- * const { writeVersionedService } = utils('/path/to/eventcatalog');
125
- *
126
- * // Write a service
127
- * // Service would be written to services/InventoryService/versioned/0.0.1
128
- * await writeVersionedService({
129
- * id: 'InventoryService',
130
- * name: 'Inventory Service',
131
- * version: '0.0.1',
132
- * summary: 'Service that handles the inventory',
133
- * markdown: '# Hello world',
134
- * });
135
- *
136
- * ```
137
- */
138
- declare const writeVersionedService: (directory: string) => (service: Service) => Promise<void>;
139
- /**
140
- * Write a service to a domain in EventCatalog.
141
- *
142
- * @example
143
- * ```ts
144
- * import utils from '@eventcatalog/utils';
145
- *
146
- * const { writeServiceToDomain } = utils('/path/to/eventcatalog');
147
- *
148
- * // Write a service to a domain
149
- * // Service would be written to domains/Shopping/services/InventoryService
150
- * await writeServiceToDomain({
151
- * id: 'InventoryService',
152
- * name: 'Inventory Service',
153
- * version: '0.0.1',
154
- * summary: 'Service that handles the inventory',
155
- * markdown: '# Hello world',
156
- * }, { id: 'Shopping' });
157
- * ```
158
- */
159
- declare const writeServiceToDomain: (directory: string) => (service: Service, domain: {
160
- id: string;
161
- version?: string;
162
- direction?: string;
163
- }, options?: {
164
- path?: string;
165
- format?: "md" | "mdx";
166
- override?: boolean;
167
- }) => Promise<void>;
168
- /**
169
- * Version a service by it's id.
170
- *
171
- * Takes the latest service and moves it to a versioned directory.
172
- * All files with this service are also versioned. (e.g /services/InventoryService/openapi.yml)
173
- *
174
- * @example
175
- * ```ts
176
- * import utils from '@eventcatalog/utils';
177
- *
178
- * const { versionService } = utils('/path/to/eventcatalog');
179
- *
180
- * // moves the latest InventoryService service to a versioned directory
181
- * // the version within that service is used as the version number.
182
- * await versionService('InventoryService');
183
- *
184
- * ```
185
- */
186
- declare const versionService: (directory: string) => (id: string) => Promise<void>;
187
- /**
188
- * Delete a service at it's given path.
189
- *
190
- * @example
191
- * ```ts
192
- * import utils from '@eventcatalog/utils';
193
- *
194
- * const { rmService } = utils('/path/to/eventcatalog');
195
- *
196
- * // Removes the service at services/InventoryService
197
- * await rmService('/InventoryService');
198
- * ```
199
- */
200
- declare const rmService: (directory: string) => (path: string) => Promise<void>;
201
- /**
202
- * Delete a service by it's id.
203
- *
204
- * Optionally specify a version to delete a specific version of the service.
205
- *
206
- * @example
207
- * ```ts
208
- * import utils from '@eventcatalog/utils';
209
- *
210
- * const { rmServiceById } = utils('/path/to/eventcatalog');
211
- *
212
- * // deletes the latest InventoryService event
213
- * await rmServiceById('InventoryService');
214
- *
215
- * // deletes a specific version of the InventoryService event
216
- * await rmServiceById('InventoryService', '0.0.1');
217
- * ```
218
- */
219
- declare const rmServiceById: (directory: string) => (id: string, version?: string, persistFiles?: boolean) => Promise<void>;
220
- /**
221
- * Add a file to a service by it's id.
222
- *
223
- * Optionally specify a version to add a file to a specific version of the service.
224
- *
225
- * @example
226
- * ```ts
227
- * import utils from '@eventcatalog/utils';
228
- *
229
- * const { addFileToService } = utils('/path/to/eventcatalog');
230
- *
231
- * // adds a file to the latest InventoryService event
232
- * await addFileToService('InventoryService', { content: 'Hello world', fileName: 'hello.txt' });
233
- *
234
- * // adds a file to a specific version of the InventoryService event
235
- * await addFileToService('InventoryService', { content: 'Hello world', fileName: 'hello.txt' }, '0.0.1');
236
- *
237
- * ```
238
- */
239
- declare const addFileToService: (directory: string) => (id: string, file: {
240
- content: string;
241
- fileName: string;
242
- }, version?: string) => Promise<void>;
243
- /**
244
- * Returns specification files for a service
245
- *
246
- * Optionally specify a version to of the service
247
- *
248
- * @example
249
- * ```ts
250
- * import utils from '@eventcatalog/utils';
251
- *
252
- * const { getSpecificationFilesForService } = utils('/path/to/eventcatalog');
253
- *
254
- * // returns a list of specification files for a service
255
- * await getSpecificationFilesForService('InventoryService', '0.0.1');
256
- *
257
- * ```
258
- */
259
- declare const getSpecificationFilesForService: (directory: string) => (id: string, version?: string) => Promise<any>;
260
- /**
261
- * Add an event/command to a service by it's id.
262
- *
263
- * Optionally specify a version to add the event to a specific version of the service.
264
- *
265
- * @example
266
- * ```ts
267
- * import utils from '@eventcatalog/utils';
268
- *
269
- * // Adds an event to the service or command to the service
270
- * const { addEventToService, addCommandToService } = utils('/path/to/eventcatalog');
271
- *
272
- * // Adds a new event (InventoryUpdatedEvent) that the InventoryService will send
273
- * await addEventToService('InventoryService', 'sends', { event: 'InventoryUpdatedEvent', version: '2.0.0' });
274
- * * // Adds a new event (OrderComplete) that the InventoryService will receive
275
- * await addEventToService('InventoryService', 'receives', { event: 'OrderComplete', version: '1.0.0' });
276
- *
277
- * // Adds a new command (UpdateInventoryCommand) that the InventoryService will send
278
- * await addCommandToService('InventoryService', 'sends', { command: 'UpdateInventoryCommand', version: '2.0.0' });
279
- * // Adds a new command (VerifyInventory) that the InventoryService will receive
280
- * await addCommandToService('InventoryService', 'receives', { command: 'VerifyInventory', version: '1.0.0' });
281
- *
282
- * ```
283
- */
284
- declare const addMessageToService: (directory: string) => (id: string, direction: string, event: {
285
- id: string;
286
- version: string;
287
- }, version?: string) => Promise<void>;
288
- /**
289
- * Check to see if the catalog has a version for the given service.
290
- *
291
- * @example
292
- * ```ts
293
- * import utils from '@eventcatalog/utils';
294
- *
295
- * const { serviceHasVersion } = utils('/path/to/eventcatalog');
296
- *
297
- * // returns true if version is found for the given event and version (supports semver)
298
- * await serviceHasVersion('InventoryService', '0.0.1');
299
- * await serviceHasVersion('InventoryService', 'latest');
300
- * await serviceHasVersion('InventoryService', '0.0.x');*
301
- *
302
- * ```
303
- */
304
- declare const serviceHasVersion: (directory: string) => (id: string, version?: string) => Promise<boolean>;
305
- /**
306
- * Check to see if the path is a service.
307
- *
308
- * @example
309
- * ```ts
310
- * import utils from '@eventcatalog/utils';
311
- *
312
- * const { isService } = utils('/path/to/eventcatalog');
313
- *
314
- * // returns true if the path is a service
315
- * await isService('/services/InventoryService/index.mdx');
316
- * ```
317
- */
318
- declare const isService: (directory: string) => (path: string) => Promise<boolean>;
319
- /**
320
- * Takes a given raw file and converts it to a service.
321
- *
322
- * @param directory - The directory to convert the file to a service.
323
- * @returns The service.
324
- * @example
325
- * ```ts
326
- * import utils from '@eventcatalog/utils';
327
- *
328
- * const { toService } = utils('/path/to/eventcatalog');
329
- *
330
- * // Read the file from somewhere
331
- * const file = fs.readFileSync('/path/to/services/InventoryService/index.mdx', 'utf8');
332
- *
333
- * // Converts the raw file to a service
334
- * await toService(file);
335
- * ```
336
- */
337
- declare const toService: (directory: string) => (file: string) => Promise<Service>;
338
- /**
339
- * Add an entity to a service by its id.
340
- *
341
- * @example
342
- * ```ts
343
- * import utils from '@eventcatalog/utils';
344
- *
345
- * const { addEntityToService } = utils('/path/to/eventcatalog');
346
- *
347
- * // adds a new entity (User) to the InventoryService
348
- * await addEntityToService('InventoryService', { id: 'User', version: '1.0.0' });
349
- *
350
- * // adds a new entity (Product) to a specific version of the InventoryService
351
- * await addEntityToService('InventoryService', { id: 'Product', version: '1.0.0' }, '2.0.0');
352
- *
353
- * ```
354
- */
355
- declare const addEntityToService: (directory: string) => (id: string, entity: {
356
- id: string;
357
- version: string;
358
- }, version?: string) => Promise<void>;
359
- /**
360
- * Add a data store to a service by it's id.
361
- *
362
- * Optionally specify a version to add the data store to a specific version of the service.
363
- *
364
- * @example
365
- * ```ts
366
- * import utils from '@eventcatalog/utils';
367
- *
368
- * // Adds an data store to the service
369
- * const { addDataStoreToService } = utils('/path/to/eventcatalog');
370
- *
371
- * // Adds a new data store (orders-db) that the InventoryService will write to
372
- * await addDataStoreToService('InventoryService', 'writesTo', { id: 'orders-db', version: '2.0.0' });
373
- *
374
- * * // Adds a new data store (OrderComplete) that the InventoryService will read from
375
- * await addDataStoreToService('InventoryService', 'readsFrom', { id: 'orders-db', version: '1.0.0' });
376
- *
377
- * ```
378
- */
379
- declare const addDataStoreToService: (directory: string) => (id: string, operation: "writesTo" | "readsFrom", dataStore: {
380
- id: string;
381
- version: string;
382
- }, version?: string) => Promise<void>;
383
-
384
- export { addDataStoreToService, addEntityToService, addFileToService, addMessageToService, getService, getServiceByPath, getServices, getSpecificationFilesForService, isService, rmService, rmServiceById, serviceHasVersion, toService, versionService, writeService, writeServiceToDomain, writeVersionedService };