@eventcatalog/sdk 2.13.1 → 2.13.2

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.
@@ -0,0 +1,1714 @@
1
+ // Base type for all resources (domains, services and messages)
2
+ interface BaseSchema {
3
+ id: string;
4
+ name: string;
5
+ summary?: string;
6
+ version: string;
7
+ badges?: Badge[];
8
+ sidebar?: {
9
+ badge?: string;
10
+ };
11
+ owners?: string[];
12
+ schemaPath?: string;
13
+ markdown: string;
14
+ repository?: {
15
+ language?: string;
16
+ url?: string;
17
+ };
18
+ deprecated?:
19
+ | boolean
20
+ | {
21
+ date?: string;
22
+ message?: string;
23
+ };
24
+ styles?: {
25
+ icon?: string;
26
+ node?: {
27
+ color?: string;
28
+ label?: string;
29
+ };
30
+ };
31
+ attachments?:
32
+ | string[]
33
+ | {
34
+ url: string;
35
+ title?: string;
36
+ type?: string;
37
+ description?: string;
38
+ icon?: string;
39
+ }[];
40
+ resourceGroups?: ResourceGroup[];
41
+ diagrams?: ResourcePointer[];
42
+ editUrl?: string;
43
+ draft?: boolean | { title?: string; message?: string };
44
+ // SDK types
45
+ schema?: any;
46
+ }
47
+
48
+ type ResourcePointer = {
49
+ id: string;
50
+ version?: string;
51
+ type?: string;
52
+ };
53
+
54
+ type SendsPointer = {
55
+ id: string;
56
+ version?: string;
57
+ to?: ChannelPointer[];
58
+ };
59
+
60
+ type ReceivesPointer = {
61
+ id: string;
62
+ version?: string;
63
+ from?: ChannelPointer[];
64
+ };
65
+
66
+ interface ResourceGroup {
67
+ id?: string;
68
+ title?: string;
69
+ items: ResourcePointer[];
70
+ limit?: number;
71
+ sidebar?: boolean;
72
+ }
73
+
74
+ interface ChannelPointer extends ResourcePointer {
75
+ parameters?: Record<string, string>;
76
+ }
77
+
78
+ type Message = Event | Command | Query;
79
+
80
+ interface CustomDoc {
81
+ title: string;
82
+ summary: string;
83
+ slug?: string;
84
+ sidebar?: {
85
+ label: string;
86
+ order: number;
87
+ };
88
+ owners?: string[];
89
+ badges?: Badge[];
90
+ fileName?: string;
91
+ markdown: string;
92
+ }
93
+
94
+ interface MessageDetailsPanelProperty {
95
+ producers?: DetailPanelProperty;
96
+ consumers?: DetailPanelProperty;
97
+ channels?: DetailPanelProperty;
98
+ versions?: DetailPanelProperty;
99
+ repository?: DetailPanelProperty;
100
+ }
101
+
102
+ interface Event extends BaseSchema {
103
+ channels?: ChannelPointer[];
104
+ detailsPanel?: MessageDetailsPanelProperty;
105
+ }
106
+ interface Command extends BaseSchema {
107
+ channels?: ChannelPointer[];
108
+ detailsPanel?: MessageDetailsPanelProperty;
109
+ }
110
+ interface Query extends BaseSchema {
111
+ channels?: ChannelPointer[];
112
+ detailsPanel?: MessageDetailsPanelProperty;
113
+ }
114
+ interface Channel extends BaseSchema {
115
+ address?: string;
116
+ protocols?: string[];
117
+ routes?: ChannelPointer[];
118
+ detailsPanel?: {
119
+ producers?: DetailPanelProperty;
120
+ consumers?: DetailPanelProperty;
121
+ messages?: DetailPanelProperty;
122
+ protocols?: DetailPanelProperty;
123
+ versions?: DetailPanelProperty;
124
+ repository?: DetailPanelProperty;
125
+ owners?: DetailPanelProperty;
126
+ changelog?: DetailPanelProperty;
127
+ };
128
+ // parameters?: Record<string, Parameter>;
129
+ parameters?: {
130
+ [key: string]: {
131
+ enum?: string[];
132
+ default?: string;
133
+ examples?: string[];
134
+ description?: string;
135
+ };
136
+ };
137
+ }
138
+
139
+ interface Specifications {
140
+ asyncapiPath?: string;
141
+ openapiPath?: string;
142
+ graphqlPath?: string;
143
+ }
144
+
145
+ interface Specification {
146
+ type: 'openapi' | 'asyncapi' | 'graphql';
147
+ path: string;
148
+ name?: string;
149
+ }
150
+
151
+ interface Service extends BaseSchema {
152
+ sends?: SendsPointer[];
153
+ receives?: ReceivesPointer[];
154
+ entities?: ResourcePointer[];
155
+ writesTo?: ResourcePointer[];
156
+ readsFrom?: ResourcePointer[];
157
+ specifications?: Specifications | Specification[];
158
+ detailsPanel?: {
159
+ domains?: DetailPanelProperty;
160
+ messages?: DetailPanelProperty;
161
+ versions?: DetailPanelProperty;
162
+ specifications?: DetailPanelProperty;
163
+ entities?: DetailPanelProperty;
164
+ repository?: DetailPanelProperty;
165
+ owners?: DetailPanelProperty;
166
+ changelog?: DetailPanelProperty;
167
+ };
168
+ }
169
+
170
+ interface Domain extends BaseSchema {
171
+ services?: ResourcePointer[];
172
+ domains?: ResourcePointer[];
173
+ entities?: ResourcePointer[];
174
+ dataProducts?: ResourcePointer[];
175
+ sends?: SendsPointer[];
176
+ receives?: ReceivesPointer[];
177
+ detailsPanel?: {
178
+ parentDomains?: DetailPanelProperty;
179
+ subdomains?: DetailPanelProperty;
180
+ services?: DetailPanelProperty;
181
+ entities?: DetailPanelProperty;
182
+ messages?: DetailPanelProperty;
183
+ ubiquitousLanguage?: DetailPanelProperty;
184
+ repository?: DetailPanelProperty;
185
+ versions?: DetailPanelProperty;
186
+ owners?: DetailPanelProperty;
187
+ changelog?: DetailPanelProperty;
188
+ };
189
+ }
190
+
191
+ interface Team {
192
+ id: string;
193
+ name: string;
194
+ summary?: string;
195
+ email?: string;
196
+ hidden?: boolean;
197
+ slackDirectMessageUrl?: string;
198
+ members?: User[];
199
+ ownedCommands?: Command[];
200
+ ownedServices?: Service[];
201
+ ownedEvents?: Event[];
202
+ markdown: string;
203
+ }
204
+
205
+ interface User {
206
+ id: string;
207
+ name: string;
208
+ avatarUrl: string;
209
+ role?: string;
210
+ hidden?: boolean;
211
+ email?: string;
212
+ slackDirectMessageUrl?: string;
213
+ ownedServices?: Service[];
214
+ ownedEvents?: Event[];
215
+ ownedCommands?: Command[];
216
+ associatedTeams?: Team[];
217
+ markdown: string;
218
+ }
219
+
220
+ interface Badge {
221
+ content: string;
222
+ backgroundColor: string;
223
+ textColor: string;
224
+ icon?: string;
225
+ }
226
+
227
+ interface UbiquitousLanguage {
228
+ id: string;
229
+ name: string;
230
+ summary?: string;
231
+ description?: string;
232
+ icon?: string;
233
+ }
234
+
235
+ interface UbiquitousLanguageDictionary {
236
+ dictionary: UbiquitousLanguage[];
237
+ }
238
+
239
+ interface DetailPanelProperty {
240
+ visible: boolean;
241
+ }
242
+
243
+ interface Entity extends BaseSchema {
244
+ aggregateRoot?: boolean;
245
+ identifier?: string;
246
+ properties?: {
247
+ name: string;
248
+ type: string;
249
+ required?: boolean;
250
+ description?: string;
251
+ references?: string;
252
+ referencesIdentifier?: string;
253
+ relationType?: string;
254
+ }[];
255
+ detailsPanel?: {
256
+ domains?: DetailPanelProperty;
257
+ services?: DetailPanelProperty;
258
+ messages?: DetailPanelProperty;
259
+ versions?: DetailPanelProperty;
260
+ owners?: DetailPanelProperty;
261
+ changelog?: DetailPanelProperty;
262
+ };
263
+ }
264
+
265
+ interface Diagram extends BaseSchema {
266
+ detailsPanel?: {
267
+ versions?: DetailPanelProperty;
268
+ owners?: DetailPanelProperty;
269
+ changelog?: DetailPanelProperty;
270
+ attachments?: DetailPanelProperty;
271
+ };
272
+ }
273
+
274
+ type DataProductOutputPointer = {
275
+ id: string;
276
+ version?: string;
277
+ contract?: {
278
+ path: string;
279
+ name: string;
280
+ type?: string;
281
+ };
282
+ };
283
+
284
+ interface DataProduct extends BaseSchema {
285
+ inputs?: ResourcePointer[];
286
+ outputs?: DataProductOutputPointer[];
287
+ detailsPanel?: {
288
+ domains?: DetailPanelProperty;
289
+ inputs?: DetailPanelProperty;
290
+ outputs?: DetailPanelProperty;
291
+ versions?: DetailPanelProperty;
292
+ repository?: DetailPanelProperty;
293
+ owners?: DetailPanelProperty;
294
+ changelog?: DetailPanelProperty;
295
+ };
296
+ }
297
+
298
+ declare enum DataClassification {
299
+ Public = 'public',
300
+ Internal = 'internal',
301
+ Confidential = 'confidential',
302
+ Regulated = 'regulated',
303
+ }
304
+
305
+ interface Container extends BaseSchema {
306
+ container_type: 'database' | 'cache' | 'objectStore' | 'searchIndex' | 'dataWarehouse' | 'dataLake' | 'externalSaaS' | 'other';
307
+ technology?: string;
308
+ authoritative?: boolean;
309
+ access_mode?: string;
310
+ classification?: DataClassification;
311
+ residency?: string;
312
+ retention?: string;
313
+ detailsPanel?: {
314
+ versions?: DetailPanelProperty;
315
+ repository?: DetailPanelProperty;
316
+ owners?: DetailPanelProperty;
317
+ changelog?: DetailPanelProperty;
318
+ };
319
+ }
320
+
321
+ type EventCatalog = {
322
+ version: string;
323
+ catalogVersion: string;
324
+ createdAt: string;
325
+ resources: {
326
+ domains?: ExportedResource<Domain>[];
327
+ services?: ExportedResource<Service>[];
328
+ messages?: {
329
+ events?: ExportedResource<Event>[];
330
+ queries?: ExportedResource<Query>[];
331
+ commands?: ExportedResource<Command>[];
332
+ };
333
+ teams?: ExportedResource<Team>[];
334
+ users?: ExportedResource<User>[];
335
+ channels?: ExportedResource<Channel>[];
336
+ customDocs?: ExportedResource<CustomDoc>[];
337
+ };
338
+ };
339
+
340
+ /**
341
+ * Init the SDK for EventCatalog
342
+ *
343
+ * @param path - The path to the EventCatalog directory
344
+ *
345
+ */
346
+ declare const _default: (path: string) => {
347
+ /**
348
+ * Returns an events from EventCatalog
349
+ * @param id - The id of the event to retrieve
350
+ * @param version - Optional id of the version to get (supports semver)
351
+ * @returns Event|Undefined
352
+ */
353
+ getEvent: (id: string, version?: string, options?: {
354
+ attachSchema?: boolean;
355
+ }) => Promise<Event>;
356
+ /**
357
+ * Returns all events from EventCatalog
358
+ * @param latestOnly - optional boolean, set to true to get only latest versions
359
+ * @returns Event[]|Undefined
360
+ */
361
+ getEvents: (options?: {
362
+ latestOnly?: boolean;
363
+ attachSchema?: boolean;
364
+ }) => Promise<Event[]>;
365
+ /**
366
+ * Adds an event to EventCatalog
367
+ *
368
+ * @param event - The event to write
369
+ * @param options - Optional options to write the event
370
+ *
371
+ */
372
+ writeEvent: (event: Event, options?: {
373
+ path?: string;
374
+ override?: boolean;
375
+ versionExistingContent?: boolean;
376
+ format?: "md" | "mdx";
377
+ }) => Promise<void>;
378
+ /**
379
+ * Adds an event to a service in EventCatalog
380
+ *
381
+ * @param event - The event to write to the service
382
+ * @param service - The service and it's id to write to the event to
383
+ * @param options - Optional options to write the event
384
+ *
385
+ */
386
+ writeEventToService: (event: Event, service: {
387
+ id: string;
388
+ version?: string;
389
+ }, options?: {
390
+ path?: string;
391
+ format?: "md" | "mdx";
392
+ override?: boolean;
393
+ }) => Promise<void>;
394
+ /**
395
+ * Remove an event to EventCatalog (modeled on the standard POSIX rm utility)
396
+ *
397
+ * @param path - The path to your event, e.g. `/Inventory/InventoryAdjusted`
398
+ *
399
+ */
400
+ rmEvent: (path: string) => Promise<void>;
401
+ /**
402
+ * Remove an event by an Event id
403
+ *
404
+ * @param id - The id of the event you want to remove
405
+ *
406
+ */
407
+ rmEventById: (id: string, version?: string, persistFiles?: boolean) => Promise<void>;
408
+ /**
409
+ * Moves a given event id to the version directory
410
+ * @param directory
411
+ */
412
+ versionEvent: (id: string) => Promise<void>;
413
+ /**
414
+ * Adds a file to the given event
415
+ * @param id - The id of the event to add the file to
416
+ * @param file - File contents to add including the content and the file name
417
+ * @param version - Optional version of the event to add the file to
418
+ * @returns
419
+ */
420
+ addFileToEvent: (id: string, file: {
421
+ content: string;
422
+ fileName: string;
423
+ }, version?: string, options?: {
424
+ path?: string;
425
+ }) => Promise<void>;
426
+ /**
427
+ * Adds a schema to the given event
428
+ * @param id - The id of the event to add the schema to
429
+ * @param schema - Schema contents to add including the content and the file name
430
+ * @param version - Optional version of the event to add the schema to
431
+ * @returns
432
+ */
433
+ addSchemaToEvent: (id: string, schema: {
434
+ schema: string;
435
+ fileName: string;
436
+ }, version?: string, options?: {
437
+ path?: string;
438
+ }) => Promise<void>;
439
+ /**
440
+ * Check to see if an event version exists
441
+ * @param id - The id of the event
442
+ * @param version - The version of the event (supports semver)
443
+ * @returns
444
+ */
445
+ eventHasVersion: (id: string, version?: string) => Promise<boolean>;
446
+ /**
447
+ * ================================
448
+ * Commands
449
+ * ================================
450
+ */
451
+ /**
452
+ * Returns a command from EventCatalog
453
+ * @param id - The id of the command to retrieve
454
+ * @param version - Optional id of the version to get (supports semver)
455
+ * @returns Command|Undefined
456
+ */
457
+ getCommand: (id: string, version?: string, options?: {
458
+ attachSchema?: boolean;
459
+ }) => Promise<Command>;
460
+ /**
461
+ * Returns all commands from EventCatalog
462
+ * @param latestOnly - optional boolean, set to true to get only latest versions
463
+ * @returns Command[]|Undefined
464
+ */
465
+ getCommands: (options?: {
466
+ latestOnly?: boolean;
467
+ attachSchema?: boolean;
468
+ }) => Promise<Command[]>;
469
+ /**
470
+ * Adds an command to EventCatalog
471
+ *
472
+ * @param command - The command to write
473
+ * @param options - Optional options to write the command
474
+ *
475
+ */
476
+ writeCommand: (command: Command, options?: {
477
+ path?: string;
478
+ override?: boolean;
479
+ versionExistingContent?: boolean;
480
+ format?: "md" | "mdx";
481
+ }) => Promise<void>;
482
+ /**
483
+ * Adds a command to a service in EventCatalog
484
+ *
485
+ * @param command - The command to write to the service
486
+ * @param service - The service and it's id to write to the command to
487
+ * @param options - Optional options to write the command
488
+ *
489
+ */
490
+ writeCommandToService: (command: Command, service: {
491
+ id: string;
492
+ version?: string;
493
+ }, options?: {
494
+ path?: string;
495
+ format?: "md" | "mdx";
496
+ override?: boolean;
497
+ }) => Promise<void>;
498
+ /**
499
+ * Remove an command to EventCatalog (modeled on the standard POSIX rm utility)
500
+ *
501
+ * @param path - The path to your command, e.g. `/Inventory/InventoryAdjusted`
502
+ *
503
+ */
504
+ rmCommand: (path: string) => Promise<void>;
505
+ /**
506
+ * Remove an command by an Event id
507
+ *
508
+ * @param id - The id of the command you want to remove
509
+ *
510
+ */
511
+ rmCommandById: (id: string, version?: string, persistFiles?: boolean) => Promise<void>;
512
+ /**
513
+ * Moves a given command id to the version directory
514
+ * @param directory
515
+ */
516
+ versionCommand: (id: string) => Promise<void>;
517
+ /**
518
+ * Adds a file to the given command
519
+ * @param id - The id of the command to add the file to
520
+ * @param file - File contents to add including the content and the file name
521
+ * @param version - Optional version of the command to add the file to
522
+ * @returns
523
+ */
524
+ addFileToCommand: (id: string, file: {
525
+ content: string;
526
+ fileName: string;
527
+ }, version?: string, options?: {
528
+ path?: string;
529
+ }) => Promise<void>;
530
+ /**
531
+ * Adds a schema to the given command
532
+ * @param id - The id of the command to add the schema to
533
+ * @param schema - Schema contents to add including the content and the file name
534
+ * @param version - Optional version of the command to add the schema to
535
+ * @returns
536
+ */
537
+ addSchemaToCommand: (id: string, schema: {
538
+ schema: string;
539
+ fileName: string;
540
+ }, version?: string, options?: {
541
+ path?: string;
542
+ }) => Promise<void>;
543
+ /**
544
+ * Check to see if a command version exists
545
+ * @param id - The id of the command
546
+ * @param version - The version of the command (supports semver)
547
+ * @returns
548
+ */
549
+ commandHasVersion: (id: string, version?: string) => Promise<boolean>;
550
+ /**
551
+ * ================================
552
+ * Queries
553
+ * ================================
554
+ */
555
+ /**
556
+ * Returns a query from EventCatalog
557
+ * @param id - The id of the query to retrieve
558
+ * @param version - Optional id of the version to get (supports semver)
559
+ * @returns Query|Undefined
560
+ */
561
+ getQuery: (id: string, version?: string, options?: {
562
+ attachSchema?: boolean;
563
+ }) => Promise<Query>;
564
+ /**
565
+ * Returns all queries from EventCatalog
566
+ * @param latestOnly - optional boolean, set to true to get only latest versions
567
+ * @returns Query[]|Undefined
568
+ */
569
+ getQueries: (options?: {
570
+ latestOnly?: boolean;
571
+ attachSchema?: boolean;
572
+ }) => Promise<Query[]>;
573
+ /**
574
+ * Adds a query to EventCatalog
575
+ *
576
+ * @param query - The query to write
577
+ * @param options - Optional options to write the event
578
+ *
579
+ */
580
+ writeQuery: (query: Query, options?: {
581
+ path?: string;
582
+ override?: boolean;
583
+ versionExistingContent?: boolean;
584
+ format?: "md" | "mdx";
585
+ }) => Promise<void>;
586
+ /**
587
+ * Adds a query to a service in EventCatalog
588
+ *
589
+ * @param query - The query to write to the service
590
+ * @param service - The service and it's id to write to the query to
591
+ * @param options - Optional options to write the query
592
+ *
593
+ */
594
+ writeQueryToService: (query: Query, service: {
595
+ id: string;
596
+ version?: string;
597
+ }, options?: {
598
+ path?: string;
599
+ format?: "md" | "mdx";
600
+ override?: boolean;
601
+ }) => Promise<void>;
602
+ /**
603
+ * Remove an query to EventCatalog (modeled on the standard POSIX rm utility)
604
+ *
605
+ * @param path - The path to your query, e.g. `/Orders/GetOrder`
606
+ *
607
+ */
608
+ rmQuery: (path: string) => Promise<void>;
609
+ /**
610
+ * Remove a query by a Query id
611
+ *
612
+ * @param id - The id of the query you want to remove
613
+ *
614
+ */
615
+ rmQueryById: (id: string, version?: string, persistFiles?: boolean) => Promise<void>;
616
+ /**
617
+ * Moves a given query id to the version directory
618
+ * @param directory
619
+ */
620
+ versionQuery: (id: string) => Promise<void>;
621
+ /**
622
+ * Adds a file to the given query
623
+ * @param id - The id of the query to add the file to
624
+ * @param file - File contents to add including the content and the file name
625
+ * @param version - Optional version of the query to add the file to
626
+ * @returns
627
+ */
628
+ addFileToQuery: (id: string, file: {
629
+ content: string;
630
+ fileName: string;
631
+ }, version?: string, options?: {
632
+ path?: string;
633
+ }) => Promise<void>;
634
+ /**
635
+ * Adds a schema to the given query
636
+ * @param id - The id of the query to add the schema to
637
+ * @param schema - Schema contents to add including the content and the file name
638
+ * @param version - Optional version of the query to add the schema to
639
+ * @returns
640
+ */
641
+ addSchemaToQuery: (id: string, schema: {
642
+ schema: string;
643
+ fileName: string;
644
+ }, version?: string, options?: {
645
+ path?: string;
646
+ }) => Promise<void>;
647
+ /**
648
+ * Check to see if an query version exists
649
+ * @param id - The id of the query
650
+ * @param version - The version of the query (supports semver)
651
+ * @returns
652
+ */
653
+ queryHasVersion: (id: string, version?: string) => Promise<boolean>;
654
+ /**
655
+ * ================================
656
+ * Channels
657
+ * ================================
658
+ */
659
+ /**
660
+ * Returns a channel from EventCatalog
661
+ * @param id - The id of the channel to retrieve
662
+ * @param version - Optional id of the version to get (supports semver)
663
+ * @returns Channel|Undefined
664
+ */
665
+ getChannel: (id: string, version?: string) => Promise<Channel>;
666
+ /**
667
+ * Returns all channels from EventCatalog
668
+ * @param latestOnly - optional boolean, set to true to get only latest versions
669
+ * @returns Channel[]|Undefined
670
+ */
671
+ getChannels: (options?: {
672
+ latestOnly?: boolean;
673
+ }) => Promise<Channel[]>;
674
+ /**
675
+ * Adds an channel to EventCatalog
676
+ *
677
+ * @param command - The channel to write
678
+ * @param options - Optional options to write the channel
679
+ *
680
+ */
681
+ writeChannel: (channel: Channel, options?: {
682
+ path?: string;
683
+ override?: boolean;
684
+ versionExistingContent?: boolean;
685
+ format?: "md" | "mdx";
686
+ }) => Promise<void>;
687
+ /**
688
+ * Remove an channel to EventCatalog (modeled on the standard POSIX rm utility)
689
+ *
690
+ * @param path - The path to your channel, e.g. `/Inventory/InventoryAdjusted`
691
+ *
692
+ */
693
+ rmChannel: (path: string) => Promise<void>;
694
+ /**
695
+ * Remove an channel by an Event id
696
+ *
697
+ * @param id - The id of the channel you want to remove
698
+ *
699
+ */
700
+ rmChannelById: (id: string, version?: string, persistFiles?: boolean) => Promise<void>;
701
+ /**
702
+ * Moves a given channel id to the version directory
703
+ * @param directory
704
+ */
705
+ versionChannel: (id: string) => Promise<void>;
706
+ /**
707
+ * Check to see if a channel version exists
708
+ * @param id - The id of the channel
709
+ * @param version - The version of the channel (supports semver)
710
+ * @returns
711
+ */
712
+ channelHasVersion: (id: string, version?: string) => Promise<boolean>;
713
+ /**
714
+ * Add a channel to an event
715
+ *
716
+ * Optionally specify a version to add the channel to a specific version of the event.
717
+ *
718
+ * @example
719
+ * ```ts
720
+ * import utils from '@eventcatalog/utils';
721
+ *
722
+ * const { addEventToChannel } = utils('/path/to/eventcatalog');
723
+ *
724
+ * // adds a new event (InventoryUpdatedEvent) to the inventory.{env}.events channel
725
+ * await addEventToChannel('inventory.{env}.events channel', { id: 'InventoryUpdatedEvent', version: '2.0.0', parameters: { env: 'dev' } });
726
+ *
727
+ * ```
728
+ */
729
+ addEventToChannel: (id: string, _message: {
730
+ id: string;
731
+ version: string;
732
+ parameters?: {
733
+ [key: string]: string;
734
+ };
735
+ }, version?: string) => Promise<void>;
736
+ /**
737
+ * Add a channel to an command
738
+ *
739
+ * Optionally specify a version to add the channel to a specific version of the command.
740
+ *
741
+ * @example
742
+ * ```ts
743
+ * import utils from '@eventcatalog/utils';
744
+ *
745
+ * const { addCommandToChannel } = utils('/path/to/eventcatalog');
746
+ *
747
+ * // adds a new command (UpdateInventory) to the inventory.{env}.events channel
748
+ * await addCommandToChannel('inventory.{env}.events channel', { id: 'UpdateInventory', version: '2.0.0', parameters: { env: 'dev' } });
749
+ *
750
+ * ```
751
+ */
752
+ addCommandToChannel: (id: string, _message: {
753
+ id: string;
754
+ version: string;
755
+ parameters?: {
756
+ [key: string]: string;
757
+ };
758
+ }, version?: string) => Promise<void>;
759
+ /**
760
+ * Add a channel to an query
761
+ *
762
+ * Optionally specify a version to add the channel to a specific version of the query.
763
+ *
764
+ * @example
765
+ * ```ts
766
+ * import utils from '@eventcatalog/utils';
767
+ *
768
+ * const { addQueryToChannel } = utils('/path/to/eventcatalog');
769
+ *
770
+ * // adds a new query (GetInventory) to the inventory.{env}.events channel
771
+ * await addQueryToChannel('inventory.{env}.events channel', { id: 'GetInventory', version: '2.0.0', parameters: { env: 'dev' } });
772
+ *
773
+ * ```
774
+ */
775
+ addQueryToChannel: (id: string, _message: {
776
+ id: string;
777
+ version: string;
778
+ parameters?: {
779
+ [key: string]: string;
780
+ };
781
+ }, version?: string) => Promise<void>;
782
+ /**
783
+ * ================================
784
+ * SERVICES
785
+ * ================================
786
+ */
787
+ /**
788
+ * Adds a service to EventCatalog
789
+ *
790
+ * @param service - The service to write
791
+ * @param options - Optional options to write the event
792
+ *
793
+ */
794
+ writeService: (service: Service, options?: {
795
+ path?: string;
796
+ override?: boolean;
797
+ versionExistingContent?: boolean;
798
+ format?: "md" | "mdx";
799
+ }) => Promise<void>;
800
+ /**
801
+ * Adds a versioned service to EventCatalog
802
+ *
803
+ * @param service - The service to write
804
+ *
805
+ */
806
+ writeVersionedService: (service: Service) => Promise<void>;
807
+ /**
808
+ * Adds a service to a domain in EventCatalog
809
+ *
810
+ * @param service - The service to write
811
+ * @param domain - The domain to add the service to
812
+ * @param options - Optional options to write the event
813
+ *
814
+ */
815
+ writeServiceToDomain: (service: Service, domain: {
816
+ id: string;
817
+ version?: string;
818
+ direction
819
+ /**
820
+ * Adds a command to a service in EventCatalog
821
+ *
822
+ * @param command - The command to write to the service
823
+ * @param service - The service and it's id to write to the command to
824
+ * @param options - Optional options to write the command
825
+ *
826
+ */
827
+ ? /**
828
+ * Adds a command to a service in EventCatalog
829
+ *
830
+ * @param command - The command to write to the service
831
+ * @param service - The service and it's id to write to the command to
832
+ * @param options - Optional options to write the command
833
+ *
834
+ */: string;
835
+ }, options?: {
836
+ path?: string;
837
+ format?: "md" | "mdx";
838
+ override?: boolean;
839
+ }) => Promise<void>;
840
+ /**
841
+ * Returns a service from EventCatalog
842
+ * @param id - The id of the service to retrieve
843
+ * @param version - Optional id of the version to get (supports semver)
844
+ * @returns Service|Undefined
845
+ */
846
+ getService: (id: string, version?: string) => Promise<Service>;
847
+ /**
848
+ * Returns a service from EventCatalog by it's path.
849
+ * @param path - The path to the service to retrieve
850
+ * @returns Service|Undefined
851
+ */
852
+ getServiceByPath: (path: string) => Promise<Service>;
853
+ /**
854
+ * Returns all services from EventCatalog
855
+ * @param latestOnly - optional boolean, set to true to get only latest versions
856
+ * @returns Service[]|Undefined
857
+ */
858
+ getServices: (options?: {
859
+ latestOnly?: boolean;
860
+ }) => Promise<Service[]>;
861
+ /**
862
+ * Moves a given service id to the version directory
863
+ * @param directory
864
+ */
865
+ versionService: (id: string) => Promise<void>;
866
+ /**
867
+ * Remove a service from EventCatalog (modeled on the standard POSIX rm utility)
868
+ *
869
+ * @param path - The path to your service, e.g. `/InventoryService`
870
+ *
871
+ */
872
+ rmService: (path: string) => Promise<void>;
873
+ /**
874
+ * Remove an service by an service id
875
+ *
876
+ * @param id - The id of the service you want to remove
877
+ *
878
+ */
879
+ rmServiceById: (id: string, version?: string, persistFiles?: boolean) => Promise<void>;
880
+ /**
881
+ * Adds a file to the given service
882
+ * @param id - The id of the service to add the file to
883
+ * @param file - File contents to add including the content and the file name
884
+ * @param version - Optional version of the service to add the file to
885
+ * @returns
886
+ */
887
+ addFileToService: (id: string, file: {
888
+ content: string;
889
+ fileName: string;
890
+ }, version?: string) => Promise<void>;
891
+ /**
892
+ * Returns the specifications for a given service
893
+ * @param id - The id of the service to retrieve the specifications for
894
+ * @param version - Optional version of the service
895
+ * @returns
896
+ */
897
+ getSpecificationFilesForService: (id: string, version?: string) => Promise<any>;
898
+ /**
899
+ * Check to see if a service version exists
900
+ * @param id - The id of the service
901
+ * @param version - The version of the service (supports semver)
902
+ * @returns
903
+ */
904
+ serviceHasVersion: (id: string, version?: string) => Promise<boolean>;
905
+ /**
906
+ * Add an event to a service by it's id.
907
+ *
908
+ * Optionally specify a version to add the event to a specific version of the service.
909
+ *
910
+ * @example
911
+ * ```ts
912
+ * import utils from '@eventcatalog/utils';
913
+ *
914
+ * const { addEventToService } = utils('/path/to/eventcatalog');
915
+ *
916
+ * // adds a new event (InventoryUpdatedEvent) that the InventoryService will send
917
+ * await addEventToService('InventoryService', 'sends', { event: 'InventoryUpdatedEvent', version: '2.0.0' });
918
+ *
919
+ * // adds a new event (OrderComplete) that the InventoryService will receive
920
+ * await addEventToService('InventoryService', 'receives', { event: 'OrderComplete', version: '2.0.0' });
921
+ *
922
+ * ```
923
+ */
924
+ addEventToService: (id: string, direction: string, event: {
925
+ id: string;
926
+ version: string;
927
+ }, version?: string) => Promise<void>;
928
+ /**
929
+ * Add a data store to a service by it's id.
930
+ *
931
+ * Optionally specify a version to add the data store to a specific version of the service.
932
+ *
933
+ * @example
934
+ * ```ts
935
+ * import utils from '@eventcatalog/utils';
936
+ *
937
+ * const { addDataStoreToService } = utils('/path/to/eventcatalog');
938
+ *
939
+ * // adds a new data store (orders-db) that the InventoryService will write to
940
+ * await addDataStoreToService('InventoryService', 'writesTo', { id: 'orders-db', version: '2.0.0' });
941
+ *
942
+ * ```
943
+ */
944
+ addDataStoreToService: (id: string, operation: "writesTo" | "readsFrom", dataStore: {
945
+ id: string;
946
+ version: string;
947
+ }, version?: string) => Promise<void>;
948
+ /**
949
+ * Add a command to a service by it's id.
950
+ *
951
+ * Optionally specify a version to add the event to a specific version of the service.
952
+ *
953
+ * @example
954
+ * ```ts
955
+ * import utils from '@eventcatalog/utils';
956
+ *
957
+ * const { addCommandToService } = utils('/path/to/eventcatalog');
958
+ *
959
+ * // adds a new command (UpdateInventoryCommand) that the InventoryService will send
960
+ * await addCommandToService('InventoryService', 'sends', { command: 'UpdateInventoryCommand', version: '2.0.0' });
961
+ *
962
+ * // adds a new command (VerifyInventory) that the InventoryService will receive
963
+ * await addCommandToService('InventoryService', 'receives', { command: 'VerifyInventory', version: '2.0.0' });
964
+ *
965
+ * ```
966
+ */
967
+ addCommandToService: (id: string, direction: string, event: {
968
+ id: string;
969
+ version: string;
970
+ }, version?: string) => Promise<void>;
971
+ /**
972
+ * Add a query to a service by it's id.
973
+ *
974
+ * Optionally specify a version to add the event to a specific version of the service.
975
+ *
976
+ * @example
977
+ * ```ts
978
+ * import utils from '@eventcatalog/utils';
979
+ *
980
+ * const { addQueryToService } = utils('/path/to/eventcatalog');
981
+ *
982
+ * // adds a new query (UpdateInventory) that the InventoryService will send
983
+ * await addQueryToService('InventoryService', 'sends', { command: 'UpdateInventory', version: '2.0.0' });
984
+ *
985
+ * // adds a new command (VerifyInventory) that the InventoryService will receive
986
+ * await addQueryToService('InventoryService', 'receives', { command: 'VerifyInventory', version: '2.0.0' });
987
+ *
988
+ * ```
989
+ */
990
+ addQueryToService: (id: string, direction: string, event: {
991
+ id: string;
992
+ version: string;
993
+ }, version?: string) => Promise<void>;
994
+ /**
995
+ * Add an entity to a service by its id.
996
+ *
997
+ * @example
998
+ * ```ts
999
+ * import utils from '@eventcatalog/utils';
1000
+ *
1001
+ * const { addEntityToService } = utils('/path/to/eventcatalog');
1002
+ *
1003
+ * // adds a new entity (User) to the InventoryService
1004
+ * await addEntityToService('InventoryService', { id: 'User', version: '1.0.0' });
1005
+ *
1006
+ * // adds a new entity (Product) to a specific version of the InventoryService
1007
+ * await addEntityToService('InventoryService', { id: 'Product', version: '1.0.0' }, '2.0.0');
1008
+ *
1009
+ * ```
1010
+ */
1011
+ addEntityToService: (id: string, entity: {
1012
+ id: string;
1013
+ version: string;
1014
+ }, version?: string) => Promise<void>;
1015
+ /**
1016
+ * Check to see if a service exists by it's path.
1017
+ *
1018
+ * @example
1019
+ * ```ts
1020
+ * import utils from '@eventcatalog/utils';
1021
+ *
1022
+ * const { isService } = utils('/path/to/eventcatalog');
1023
+ *
1024
+ * // returns true if the path is a service
1025
+ * await isService('/services/InventoryService/index.mdx');
1026
+ * ```
1027
+ *
1028
+ * @param path - The path to the service to check
1029
+ * @returns boolean
1030
+ */
1031
+ isService: (path: string) => Promise<boolean>;
1032
+ /**
1033
+ * Converts a file to a service.
1034
+ * @param file - The file to convert to a service.
1035
+ * @returns The service.
1036
+ */
1037
+ toService: (file: string) => Promise<Service>;
1038
+ /**
1039
+ * ================================
1040
+ * Domains
1041
+ * ================================
1042
+ */
1043
+ /**
1044
+ * Adds a domain to EventCatalog
1045
+ *
1046
+ * @param domain - The domain to write
1047
+ * @param options - Optional options to write the event
1048
+ *
1049
+ */
1050
+ writeDomain: (domain: Domain, options?: {
1051
+ path?: string;
1052
+ override?: boolean;
1053
+ versionExistingContent?: boolean;
1054
+ format?: "md" | "mdx";
1055
+ }) => Promise<void>;
1056
+ /**
1057
+ * Returns a domain from EventCatalog
1058
+ * @param id - The id of the domain to retrieve
1059
+ * @param version - Optional id of the version to get (supports semver)
1060
+ * @returns Domain|Undefined
1061
+ */
1062
+ getDomain: (id: string, version?: string) => Promise<Domain>;
1063
+ /**
1064
+ * Returns all domains from EventCatalog
1065
+ * @param latestOnly - optional boolean, set to true to get only latest versions
1066
+ * @returns Domain[]|Undefined
1067
+ */
1068
+ getDomains: (options?: {
1069
+ latestOnly?: boolean;
1070
+ }) => Promise<Domain[]>;
1071
+ /**
1072
+ * Moves a given domain id to the version directory
1073
+ * @param directory
1074
+ */
1075
+ versionDomain: (id: string) => Promise<void>;
1076
+ /**
1077
+ * Remove a domain from EventCatalog (modeled on the standard POSIX rm utility)
1078
+ *
1079
+ * @param path - The path to your domain, e.g. `/Payment`
1080
+ *
1081
+ */
1082
+ rmDomain: (path: string) => Promise<void>;
1083
+ /**
1084
+ * Remove an service by an domain id
1085
+ *
1086
+ * @param id - The id of the domain you want to remove
1087
+ *
1088
+ */
1089
+ rmDomainById: (id: string, version?: string, persistFiles?: boolean) => Promise<void>;
1090
+ /**
1091
+ * Adds a file to the given domain
1092
+ * @param id - The id of the domain to add the file to
1093
+ * @param file - File contents to add including the content and the file name
1094
+ * @param version - Optional version of the domain to add the file to
1095
+ * @returns
1096
+ */
1097
+ addFileToDomain: (id: string, file: {
1098
+ content: string;
1099
+ fileName: string;
1100
+ }, version?: string) => Promise<void>;
1101
+ /**
1102
+ * Adds an ubiquitous language dictionary to a domain
1103
+ * @param id - The id of the domain to add the ubiquitous language to
1104
+ * @param ubiquitousLanguageDictionary - The ubiquitous language dictionary to add
1105
+ * @param version - Optional version of the domain to add the ubiquitous language to
1106
+ */
1107
+ addUbiquitousLanguageToDomain: (id: string, ubiquitousLanguageDictionary: UbiquitousLanguageDictionary, version?: string) => Promise<void>;
1108
+ /**
1109
+ * Get the ubiquitous language dictionary from a domain
1110
+ * @param id - The id of the domain to get the ubiquitous language from
1111
+ * @param version - Optional version of the domain to get the ubiquitous language from
1112
+ * @returns
1113
+ */
1114
+ getUbiquitousLanguageFromDomain: (id: string, version?: string) => Promise<{
1115
+ markdown: any;
1116
+ } | undefined>;
1117
+ /**
1118
+ * Check to see if a domain version exists
1119
+ * @param id - The id of the domain
1120
+ * @param version - The version of the domain (supports semver)
1121
+ * @returns
1122
+ */
1123
+ domainHasVersion: (id: string, version?: string) => Promise<boolean>;
1124
+ /**
1125
+ * Adds a given service to a domain
1126
+ * @param id - The id of the domain
1127
+ * @param service - The id and version of the service to add
1128
+ * @param version - (Optional) The version of the domain to add the service to
1129
+ * @returns
1130
+ */
1131
+ addServiceToDomain: (id: string, service: {
1132
+ id: string;
1133
+ version: string;
1134
+ }, version?: string) => Promise<void>;
1135
+ /**
1136
+ * Adds a given subdomain to a domain
1137
+ * @param id - The id of the domain
1138
+ * @param subDomain - The id and version of the subdomain to add
1139
+ * @param version - (Optional) The version of the domain to add the subdomain to
1140
+ * @returns
1141
+ */
1142
+ addSubDomainToDomain: (id: string, subDomain: {
1143
+ id: string;
1144
+ version: string;
1145
+ }, version?: string) => Promise<void>;
1146
+ /**
1147
+ * Adds an entity to a domain
1148
+ * @param id - The id of the domain
1149
+ * @param entity - The id and version of the entity to add
1150
+ * @param version - (Optional) The version of the domain to add the entity to
1151
+ * @returns
1152
+ */
1153
+ addEntityToDomain: (id: string, entity: {
1154
+ id: string;
1155
+ version: string;
1156
+ }, version?: string) => Promise<void>;
1157
+ /**
1158
+ * Add an event to a domain by its id.
1159
+ *
1160
+ * @example
1161
+ * ```ts
1162
+ * import utils from '@eventcatalog/utils';
1163
+ *
1164
+ * const { addEventToDomain } = utils('/path/to/eventcatalog');
1165
+ *
1166
+ * // adds a new event (OrderCreated) that the Orders domain will send
1167
+ * await addEventToDomain('Orders', 'sends', { id: 'OrderCreated', version: '2.0.0' });
1168
+ *
1169
+ * // adds a new event (PaymentProcessed) that the Orders domain will receive
1170
+ * await addEventToDomain('Orders', 'receives', { id: 'PaymentProcessed', version: '2.0.0' });
1171
+ *
1172
+ * ```
1173
+ */
1174
+ addEventToDomain: (id: string, direction: string, message: {
1175
+ id: string;
1176
+ version: string;
1177
+ }, version?: string) => Promise<void>;
1178
+ /**
1179
+ * Add a command to a domain by its id.
1180
+ *
1181
+ * @example
1182
+ * ```ts
1183
+ * import utils from '@eventcatalog/utils';
1184
+ *
1185
+ * const { addCommandToDomain } = utils('/path/to/eventcatalog');
1186
+ *
1187
+ * // adds a new command (ProcessOrder) that the Orders domain will send
1188
+ * await addCommandToDomain('Orders', 'sends', { id: 'ProcessOrder', version: '2.0.0' });
1189
+ *
1190
+ * // adds a new command (CancelOrder) that the Orders domain will receive
1191
+ * await addCommandToDomain('Orders', 'receives', { id: 'CancelOrder', version: '2.0.0' });
1192
+ *
1193
+ * ```
1194
+ */
1195
+ addCommandToDomain: (id: string, direction: string, message: {
1196
+ id: string;
1197
+ version: string;
1198
+ }, version?: string) => Promise<void>;
1199
+ /**
1200
+ * Add a query to a domain by its id.
1201
+ *
1202
+ * @example
1203
+ * ```ts
1204
+ * import utils from '@eventcatalog/utils';
1205
+ *
1206
+ * const { addQueryToDomain } = utils('/path/to/eventcatalog');
1207
+ *
1208
+ * // adds a new query (GetOrderStatus) that the Orders domain will send
1209
+ * await addQueryToDomain('Orders', 'sends', { id: 'GetOrderStatus', version: '2.0.0' });
1210
+ *
1211
+ * // adds a new query (GetInventory) that the Orders domain will receive
1212
+ * await addQueryToDomain('Orders', 'receives', { id: 'GetInventory', version: '2.0.0' });
1213
+ *
1214
+ * ```
1215
+ */
1216
+ addQueryToDomain: (id: string, direction: string, message: {
1217
+ id: string;
1218
+ version: string;
1219
+ }, version?: string) => Promise<void>;
1220
+ /**
1221
+ * ================================
1222
+ * Teams
1223
+ * ================================
1224
+ */
1225
+ /**
1226
+ * Adds a team to EventCatalog
1227
+ *
1228
+ * @param team - The team to write
1229
+ * @param options - Optional options to write the team
1230
+ *
1231
+ */
1232
+ writeTeam: (team: Team, options?: {
1233
+ override?: boolean;
1234
+ }) => Promise<void>;
1235
+ /**
1236
+ * Returns a team from EventCatalog
1237
+ * @param id - The id of the team to retrieve
1238
+ * @returns Team|Undefined
1239
+ */
1240
+ getTeam: (id: string) => Promise<Team | undefined>;
1241
+ /**
1242
+ * Returns all teams from EventCatalog
1243
+ * @returns Team[]|Undefined
1244
+ */
1245
+ getTeams: (options?: {}) => Promise<Team[]>;
1246
+ /**
1247
+ * Remove a team by the team id
1248
+ *
1249
+ * @param id - The id of the team you want to remove
1250
+ *
1251
+ */
1252
+ rmTeamById: (id: string) => Promise<void>;
1253
+ /**
1254
+ * ================================
1255
+ * Users
1256
+ * ================================
1257
+ */
1258
+ /**
1259
+ * Adds a user to EventCatalog
1260
+ *
1261
+ * @param user - The user to write
1262
+ * @param options - Optional options to write the user
1263
+ *
1264
+ */
1265
+ writeUser: (user: User, options?: {
1266
+ override?: boolean;
1267
+ }) => Promise<void>;
1268
+ /**
1269
+ * Returns a user from EventCatalog
1270
+ * @param id - The id of the user to retrieve
1271
+ * @returns User|Undefined
1272
+ */
1273
+ getUser: (id: string) => Promise<User | undefined>;
1274
+ /**
1275
+ * Returns all user from EventCatalog
1276
+ * @returns User[]|Undefined
1277
+ */
1278
+ getUsers: (options?: {}) => Promise<User[]>;
1279
+ /**
1280
+ * Remove a user by the user id
1281
+ *
1282
+ * @param id - The id of the user you want to remove
1283
+ *
1284
+ */
1285
+ rmUserById: (id: string) => Promise<void>;
1286
+ /**
1287
+ * ================================
1288
+ * Custom Docs
1289
+ * ================================
1290
+ */
1291
+ /**
1292
+ * Returns a custom doc from EventCatalog
1293
+ * @param path - The path to the custom doc to retrieve
1294
+ * @returns CustomDoc|Undefined
1295
+ */
1296
+ getCustomDoc: (filePath: string) => Promise<CustomDoc | undefined>;
1297
+ /**
1298
+ * Returns all custom docs from EventCatalog
1299
+ * @param options - Optional options to get custom docs from a specific path
1300
+ * @returns CustomDoc[]|Undefined
1301
+ */
1302
+ getCustomDocs: (options?: {
1303
+ path?: string;
1304
+ }) => Promise<CustomDoc[]>;
1305
+ /**
1306
+ * Writes a custom doc to EventCatalog
1307
+ * @param customDoc - The custom doc to write
1308
+ * @param options - Optional options to write the custom doc
1309
+ *
1310
+ */
1311
+ writeCustomDoc: (customDoc: CustomDoc, options?: {
1312
+ path?: string;
1313
+ }) => Promise<void>;
1314
+ /**
1315
+ * Removes a custom doc from EventCatalog
1316
+ * @param path - The path to the custom doc to remove
1317
+ *
1318
+ */
1319
+ rmCustomDoc: (filePath: string) => Promise<void>;
1320
+ /**
1321
+ * Dumps the catalog to a JSON file.
1322
+ * @param directory - The directory to dump the catalog to
1323
+ * @returns A JSON file with the catalog
1324
+ */
1325
+ dumpCatalog: (options?: {
1326
+ includeMarkdown?: boolean;
1327
+ }) => Promise<EventCatalog>;
1328
+ /**
1329
+ * Returns the event catalog configuration file.
1330
+ * The event catalog configuration file is the file that contains the configuration for the event catalog.
1331
+ *
1332
+ * @param directory - The directory of the catalog.
1333
+ * @returns A JSON object with the configuration for the event catalog.
1334
+ */
1335
+ getEventCatalogConfigurationFile: () => Promise<any>;
1336
+ /**
1337
+ * ================================
1338
+ * Resources Utils
1339
+ * ================================
1340
+ */
1341
+ /**
1342
+ * Returns the path to a given resource by id and version
1343
+ */
1344
+ getResourcePath: (catalogDir: string, id: string, version?: string) => Promise<{
1345
+ fullPath: string;
1346
+ relativePath: string;
1347
+ directory: string;
1348
+ } | undefined>;
1349
+ /**
1350
+ * Returns the folder name of a given resource
1351
+ */
1352
+ getResourceFolderName: (catalogDir: string, id: string, version?: string) => Promise<string | undefined>;
1353
+ /**
1354
+ * ================================
1355
+ * General Message Utils
1356
+ * ================================
1357
+ */
1358
+ /**
1359
+ * Returns a message from EventCatalog by a given schema path.
1360
+ *
1361
+ * @param path - The path to the message to retrieve
1362
+ * @returns Message|Undefined
1363
+ */
1364
+ getMessageBySchemaPath: (path: string, options?: {
1365
+ attachSchema?: boolean;
1366
+ }) => Promise<Message>;
1367
+ /**
1368
+ * Returns the producers and consumers (services) for a given message
1369
+ * @param id - The id of the message to get the producers and consumers for
1370
+ * @param version - Optional version of the message
1371
+ * @returns { producers: Service[], consumers: Service[] }
1372
+ */
1373
+ getProducersAndConsumersForMessage: (id: string, version?: string, options?: {
1374
+ latestOnly?: boolean;
1375
+ }) => Promise<{
1376
+ producers: Service[];
1377
+ consumers: Service[];
1378
+ }>;
1379
+ /**
1380
+ * Returns the consumers of a given schema path
1381
+ * @param path - The path to the schema to get the consumers for
1382
+ * @returns Service[]
1383
+ */
1384
+ getConsumersOfSchema: (path: string) => Promise<Service[]>;
1385
+ /**
1386
+ * Returns the producers of a given schema path
1387
+ * @param path - The path to the schema to get the producers for
1388
+ * @returns Service[]
1389
+ */
1390
+ getProducersOfSchema: (path: string) => Promise<Service[]>;
1391
+ /**
1392
+ * Returns the owners for a given resource (e.g domain, service, event, command, query, etc.)
1393
+ * @param id - The id of the resource to get the owners for
1394
+ * @param version - Optional version of the resource
1395
+ * @returns { owners: User[] }
1396
+ */
1397
+ getOwnersForResource: (id: string, version?: string) => Promise<Team[]>;
1398
+ /**
1399
+ * ================================
1400
+ * Entities
1401
+ * ================================
1402
+ */
1403
+ /**
1404
+ * Returns an entity from EventCatalog
1405
+ * @param id - The id of the entity to retrieve
1406
+ * @param version - Optional id of the version to get (supports semver)
1407
+ * @returns Entity|Undefined
1408
+ */
1409
+ getEntity: (id: string, version?: string) => Promise<Entity>;
1410
+ /**
1411
+ * Returns all entities from EventCatalog
1412
+ * @param latestOnly - optional boolean, set to true to get only latest versions
1413
+ * @returns Entity[]|Undefined
1414
+ */
1415
+ getEntities: (options?: {
1416
+ latestOnly?: boolean;
1417
+ }) => Promise<Entity[]>;
1418
+ /**
1419
+ * Adds an entity to EventCatalog
1420
+ *
1421
+ * @param entity - The entity to write
1422
+ * @param options - Optional options to write the entity
1423
+ *
1424
+ */
1425
+ writeEntity: (entity: Entity, options?: {
1426
+ path?: string;
1427
+ override?: boolean;
1428
+ versionExistingContent?: boolean;
1429
+ format?: "md" | "mdx";
1430
+ }) => Promise<void>;
1431
+ /**
1432
+ * Remove an entity from EventCatalog (modeled on the standard POSIX rm utility)
1433
+ *
1434
+ * @param path - The path to your entity, e.g. `/User`
1435
+ *
1436
+ */
1437
+ rmEntity: (path: string) => Promise<void>;
1438
+ /**
1439
+ * Remove an entity by an entity id
1440
+ *
1441
+ * @param id - The id of the entity you want to remove
1442
+ *
1443
+ */
1444
+ rmEntityById: (id: string, version?: string, persistFiles?: boolean) => Promise<void>;
1445
+ /**
1446
+ * Moves a given entity id to the version directory
1447
+ * @param id - The id of the entity to version
1448
+ */
1449
+ versionEntity: (id: string) => Promise<void>;
1450
+ /**
1451
+ * Check to see if an entity version exists
1452
+ * @param id - The id of the entity
1453
+ * @param version - The version of the entity (supports semver)
1454
+ * @returns
1455
+ */
1456
+ entityHasVersion: (id: string, version?: string) => Promise<boolean>;
1457
+ /**
1458
+ * ================================
1459
+ * Data Stores
1460
+ * ================================
1461
+ */
1462
+ /**
1463
+ * Adds a data store to EventCatalog
1464
+ * @param dataStore - The data store to write
1465
+ * @param options - Optional options to write the data store
1466
+ *
1467
+ */
1468
+ writeDataStore: (data: Container, options?: {
1469
+ path?: string;
1470
+ override?: boolean;
1471
+ versionExistingContent?: boolean;
1472
+ format?: "md" | "mdx";
1473
+ }) => Promise<void>;
1474
+ /**
1475
+ * Returns a data store from EventCatalog
1476
+ * @param id - The id of the data store to retrieve
1477
+ * @param version - Optional id of the version to get (supports semver)
1478
+ * @returns Container|Undefined
1479
+ */
1480
+ getDataStore: (id: string, version?: string) => Promise<Container>;
1481
+ /**
1482
+ * Returns all data stores from EventCatalog
1483
+ * @param latestOnly - optional boolean, set to true to get only latest versions
1484
+ * @returns Container[]|Undefined
1485
+ */
1486
+ getDataStores: (options?: {
1487
+ latestOnly?: boolean;
1488
+ }) => Promise<Container[]>;
1489
+ /**
1490
+ * Version a data store by its id
1491
+ * @param id - The id of the data store to version
1492
+ */
1493
+ versionDataStore: (id: string) => Promise<void>;
1494
+ /**
1495
+ * Remove a data store by its path
1496
+ * @param path - The path to the data store to remove
1497
+ */
1498
+ rmDataStore: (path: string) => Promise<void>;
1499
+ /**
1500
+ * Remove a data store by its id
1501
+ * @param id - The id of the data store to remove
1502
+ */
1503
+ rmDataStoreById: (id: string, version?: string, persistFiles?: boolean) => Promise<void>;
1504
+ /**
1505
+ * Check to see if a data store version exists
1506
+ * @param id - The id of the data store
1507
+ * @param version - The version of the data store (supports semver)
1508
+ * @returns
1509
+ */
1510
+ dataStoreHasVersion: (id: string, version?: string) => Promise<boolean>;
1511
+ /**
1512
+ * Adds a file to a data store by its id
1513
+ * @param id - The id of the data store to add the file to
1514
+ * @param file - File contents to add including the content and the file name
1515
+ * @param version - Optional version of the data store to add the file to
1516
+ * @returns
1517
+ */
1518
+ addFileToDataStore: (id: string, file: {
1519
+ content: string;
1520
+ fileName: string;
1521
+ }, version?: string) => Promise<void>;
1522
+ /**
1523
+ * Writes a data store to a service by its id
1524
+ * @param dataStore - The data store to write
1525
+ * @param service - The service to write the data store to
1526
+ * @returns
1527
+ */
1528
+ writeDataStoreToService: (container: Container, service: {
1529
+ id: string;
1530
+ version?: string;
1531
+ }, options?: {
1532
+ path?: string;
1533
+ format?: "md" | "mdx";
1534
+ override?: boolean;
1535
+ }) => Promise<void>;
1536
+ /**
1537
+ * ================================
1538
+ * Data Products
1539
+ * ================================
1540
+ */
1541
+ /**
1542
+ * Adds a data product to EventCatalog
1543
+ * @param dataProduct - The data product to write
1544
+ * @param options - Optional options to write the data product
1545
+ *
1546
+ */
1547
+ writeDataProduct: (dataProduct: DataProduct, options?: {
1548
+ path?: string;
1549
+ override?: boolean;
1550
+ versionExistingContent?: boolean;
1551
+ format?: "md" | "mdx";
1552
+ }) => Promise<void>;
1553
+ /**
1554
+ * Writes a data product to a domain in EventCatalog
1555
+ * @param dataProduct - The data product to write
1556
+ * @param domain - The domain to write the data product to
1557
+ * @param options - Optional options to write the data product
1558
+ *
1559
+ */
1560
+ writeDataProductToDomain: (dataProduct: DataProduct, domain: {
1561
+ id: string;
1562
+ version?: string;
1563
+ }, options?: {
1564
+ path?: string;
1565
+ format?: "md" | "mdx";
1566
+ override?: boolean;
1567
+ }) => Promise<void>;
1568
+ /**
1569
+ * Returns a data product from EventCatalog
1570
+ * @param id - The id of the data product to retrieve
1571
+ * @param version - Optional id of the version to get (supports semver)
1572
+ * @returns DataProduct|Undefined
1573
+ */
1574
+ getDataProduct: (id: string, version?: string) => Promise<DataProduct>;
1575
+ /**
1576
+ * Returns all data products from EventCatalog
1577
+ * @param latestOnly - optional boolean, set to true to get only latest versions
1578
+ * @returns DataProduct[]|Undefined
1579
+ */
1580
+ getDataProducts: (options?: {
1581
+ latestOnly?: boolean;
1582
+ }) => Promise<DataProduct[]>;
1583
+ /**
1584
+ * Version a data product by its id
1585
+ * @param id - The id of the data product to version
1586
+ */
1587
+ versionDataProduct: (id: string) => Promise<void>;
1588
+ /**
1589
+ * Remove a data product by its path
1590
+ * @param path - The path to the data product to remove
1591
+ */
1592
+ rmDataProduct: (path: string) => Promise<void>;
1593
+ /**
1594
+ * Remove a data product by its id
1595
+ * @param id - The id of the data product to remove
1596
+ * @param version - Optional version of the data product to remove
1597
+ */
1598
+ rmDataProductById: (id: string, version?: string, persistFiles?: boolean) => Promise<void>;
1599
+ /**
1600
+ * Check to see if a data product version exists
1601
+ * @param id - The id of the data product
1602
+ * @param version - The version of the data product (supports semver)
1603
+ * @returns
1604
+ */
1605
+ dataProductHasVersion: (id: string, version?: string) => Promise<boolean>;
1606
+ /**
1607
+ * Adds a file to a data product by its id
1608
+ * @param id - The id of the data product to add the file to
1609
+ * @param file - File contents to add including the content and the file name
1610
+ * @param version - Optional version of the data product to add the file to
1611
+ * @returns
1612
+ */
1613
+ addFileToDataProduct: (id: string, file: {
1614
+ content: string;
1615
+ fileName: string;
1616
+ }, version?: string) => Promise<void>;
1617
+ /**
1618
+ * Adds a data product to a domain
1619
+ * @param id - The id of the domain
1620
+ * @param dataProduct - The id and version of the data product to add
1621
+ * @param version - (Optional) The version of the domain to add the data product to
1622
+ * @returns
1623
+ */
1624
+ addDataProductToDomain: (id: string, dataProduct: {
1625
+ id: string;
1626
+ version: string;
1627
+ }, version?: string) => Promise<void>;
1628
+ /**
1629
+ * ================================
1630
+ * Diagrams
1631
+ * ================================
1632
+ */
1633
+ /**
1634
+ * Returns a diagram from EventCatalog
1635
+ * @param id - The id of the diagram to retrieve
1636
+ * @param version - Optional id of the version to get (supports semver)
1637
+ * @returns Diagram|Undefined
1638
+ */
1639
+ getDiagram: (id: string, version?: string) => Promise<Diagram>;
1640
+ /**
1641
+ * Returns all diagrams from EventCatalog
1642
+ * @param latestOnly - optional boolean, set to true to get only latest versions
1643
+ * @returns Diagram[]|Undefined
1644
+ */
1645
+ getDiagrams: (options?: {
1646
+ latestOnly?: boolean;
1647
+ }) => Promise<Diagram[]>;
1648
+ /**
1649
+ * Adds a diagram to EventCatalog
1650
+ *
1651
+ * @param diagram - The diagram to write
1652
+ * @param options - Optional options to write the diagram
1653
+ *
1654
+ */
1655
+ writeDiagram: (diagram: Diagram, options?: {
1656
+ path
1657
+ /**
1658
+ * Adds an event to EventCatalog
1659
+ *
1660
+ * @param event - The event to write
1661
+ * @param options - Optional options to write the event
1662
+ *
1663
+ */
1664
+ ? /**
1665
+ * Adds an event to EventCatalog
1666
+ *
1667
+ * @param event - The event to write
1668
+ * @param options - Optional options to write the event
1669
+ *
1670
+ */: string;
1671
+ override?: boolean;
1672
+ versionExistingContent?: boolean;
1673
+ format?: "md" | "mdx";
1674
+ }) => Promise<void>;
1675
+ /**
1676
+ * Remove a diagram from EventCatalog (modeled on the standard POSIX rm utility)
1677
+ *
1678
+ * @param path - The path to your diagram, e.g. `/ArchitectureDiagram`
1679
+ *
1680
+ */
1681
+ rmDiagram: (path: string) => Promise<void>;
1682
+ /**
1683
+ * Remove a diagram by a diagram id
1684
+ *
1685
+ * @param id - The id of the diagram you want to remove
1686
+ *
1687
+ */
1688
+ rmDiagramById: (id: string, version?: string, persistFiles?: boolean) => Promise<void>;
1689
+ /**
1690
+ * Moves a given diagram id to the version directory
1691
+ * @param id - The id of the diagram to version
1692
+ */
1693
+ versionDiagram: (id: string) => Promise<void>;
1694
+ /**
1695
+ * Check to see if a diagram version exists
1696
+ * @param id - The id of the diagram
1697
+ * @param version - The version of the diagram (supports semver)
1698
+ * @returns
1699
+ */
1700
+ diagramHasVersion: (id: string, version?: string) => Promise<boolean>;
1701
+ /**
1702
+ * Adds a file to the given diagram
1703
+ * @param id - The id of the diagram to add the file to
1704
+ * @param file - File contents to add including the content and the file name
1705
+ * @param version - Optional version of the diagram to add the file to
1706
+ * @returns
1707
+ */
1708
+ addFileToDiagram: (id: string, file: {
1709
+ content: string;
1710
+ fileName: string;
1711
+ }, version?: string) => Promise<void>;
1712
+ };
1713
+
1714
+ export { type Badge, type BaseSchema, type Channel, type ChannelPointer, type Command, type Container, type CustomDoc, type DataProduct, type DataProductOutputPointer, type Diagram, type Domain, type Entity, type Event, type EventCatalog, type Message, type Query, type ReceivesPointer, type ResourceGroup, type ResourcePointer, type SendsPointer, type Service, type Specification, type Specifications, type Team, type UbiquitousLanguage, type UbiquitousLanguageDictionary, type User, _default as default };