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