@eventcatalog/sdk 2.15.1 → 2.17.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.
package/dist/index.d.mts CHANGED
@@ -235,6 +235,12 @@ interface Badge {
235
235
  icon?: string;
236
236
  }
237
237
 
238
+ interface Changelog {
239
+ createdAt: Date | string;
240
+ badges?: Badge[];
241
+ markdown: string;
242
+ }
243
+
238
244
  interface UbiquitousLanguage {
239
245
  id: string;
240
246
  name: string;
@@ -354,6 +360,86 @@ interface ToDSLOptions {
354
360
  hydrate?: boolean;
355
361
  }
356
362
 
363
+ type SnapshotGitInfo = {
364
+ branch: string;
365
+ commit: string;
366
+ dirty: boolean;
367
+ };
368
+ type SnapshotResources = {
369
+ domains: Record<string, any>[];
370
+ services: Record<string, any>[];
371
+ messages: {
372
+ events: Record<string, any>[];
373
+ commands: Record<string, any>[];
374
+ queries: Record<string, any>[];
375
+ };
376
+ channels: Record<string, any>[];
377
+ };
378
+ type CatalogSnapshot = {
379
+ snapshotVersion: string;
380
+ catalogVersion: string;
381
+ label: string;
382
+ createdAt: string;
383
+ git?: SnapshotGitInfo;
384
+ resources: SnapshotResources;
385
+ };
386
+ type SnapshotOptions = {
387
+ label?: string;
388
+ outputDir?: string;
389
+ git?: SnapshotGitInfo;
390
+ };
391
+ type SnapshotResult = {
392
+ filePath: string;
393
+ snapshot: CatalogSnapshot;
394
+ };
395
+ type SnapshotMeta = {
396
+ label: string;
397
+ createdAt: string;
398
+ filePath: string;
399
+ git?: SnapshotGitInfo;
400
+ };
401
+ type SnapshotResourceType = 'event' | 'command' | 'query' | 'service' | 'domain' | 'channel';
402
+ type ResourceChangeType = 'added' | 'removed' | 'modified' | 'versioned';
403
+ type ResourceChange = {
404
+ resourceId: string;
405
+ version: string;
406
+ type: SnapshotResourceType;
407
+ changeType: ResourceChangeType;
408
+ changedFields?: string[];
409
+ previousVersion?: string;
410
+ newVersion?: string;
411
+ };
412
+ type RelationshipChange = {
413
+ serviceId: string;
414
+ serviceVersion: string;
415
+ resourceId: string;
416
+ resourceVersion?: string;
417
+ direction: 'sends' | 'receives';
418
+ changeType: 'added' | 'removed';
419
+ };
420
+ type DiffSummary = {
421
+ totalChanges: number;
422
+ resourcesAdded: number;
423
+ resourcesRemoved: number;
424
+ resourcesModified: number;
425
+ resourcesVersioned: number;
426
+ relationshipsAdded: number;
427
+ relationshipsRemoved: number;
428
+ };
429
+ type SnapshotDiff = {
430
+ snapshotA: {
431
+ label: string;
432
+ createdAt: string;
433
+ };
434
+ snapshotB: {
435
+ label: string;
436
+ createdAt: string;
437
+ };
438
+ summary: DiffSummary;
439
+ resources: ResourceChange[];
440
+ relationships: RelationshipChange[];
441
+ };
442
+
357
443
  /**
358
444
  * Init the SDK for EventCatalog
359
445
  *
@@ -389,7 +475,13 @@ declare const _default: (path: string) => {
389
475
  writeEvent: (event: Event, options?: {
390
476
  path?: string;
391
477
  override?: boolean;
392
- versionExistingContent?: boolean;
478
+ versionExistingContent? /**
479
+ * Adds an event to EventCatalog
480
+ *
481
+ * @param event - The event to write
482
+ * @param options - Optional options to write the event
483
+ *
484
+ */: boolean;
393
485
  format?: "md" | "mdx";
394
486
  }) => Promise<void>;
395
487
  /**
@@ -746,18 +838,7 @@ declare const _default: (path: string) => {
746
838
  addEventToChannel: (id: string, _message: {
747
839
  id: string;
748
840
  version: string;
749
- parameters
750
- /**
751
- * Returns a query from EventCatalog
752
- * @param id - The id of the query to retrieve
753
- * @param version - Optional id of the version to get (supports semver)
754
- * @returns Query|Undefined
755
- */
756
- ? /**
757
- * ================================
758
- * Queries
759
- * ================================
760
- */: {
841
+ parameters?: {
761
842
  [key: string]: string;
762
843
  };
763
844
  }, version?: string) => Promise<void>;
@@ -780,18 +861,7 @@ declare const _default: (path: string) => {
780
861
  addCommandToChannel: (id: string, _message: {
781
862
  id: string;
782
863
  version: string;
783
- parameters
784
- /**
785
- * Returns a query from EventCatalog
786
- * @param id - The id of the query to retrieve
787
- * @param version - Optional id of the version to get (supports semver)
788
- * @returns Query|Undefined
789
- */
790
- ? /**
791
- * ================================
792
- * Queries
793
- * ================================
794
- */: {
864
+ parameters?: {
795
865
  [key: string]: string;
796
866
  };
797
867
  }, version?: string) => Promise<void>;
@@ -814,18 +884,7 @@ declare const _default: (path: string) => {
814
884
  addQueryToChannel: (id: string, _message: {
815
885
  id: string;
816
886
  version: string;
817
- parameters
818
- /**
819
- * Returns a query from EventCatalog
820
- * @param id - The id of the query to retrieve
821
- * @param version - Optional id of the version to get (supports semver)
822
- * @returns Query|Undefined
823
- */
824
- ? /**
825
- * ================================
826
- * Queries
827
- * ================================
828
- */: {
887
+ parameters?: {
829
888
  [key: string]: string;
830
889
  };
831
890
  }, version?: string) => Promise<void>;
@@ -844,15 +903,7 @@ declare const _default: (path: string) => {
844
903
  writeService: (service: Service, options?: {
845
904
  path?: string;
846
905
  override?: boolean;
847
- versionExistingContent
848
- /**
849
- * Moves a given event id to the version directory
850
- * @param directory
851
- */
852
- ? /**
853
- * Moves a given event id to the version directory
854
- * @param directory
855
- */: boolean;
906
+ versionExistingContent?: boolean;
856
907
  format?: "md" | "mdx";
857
908
  }) => Promise<void>;
858
909
  /**
@@ -875,7 +926,14 @@ declare const _default: (path: string) => {
875
926
  version?: string;
876
927
  direction?: string;
877
928
  }, options?: {
878
- path?: string;
929
+ path? /**
930
+ * Adds a command to a service in EventCatalog
931
+ *
932
+ * @param command - The command to write to the service
933
+ * @param service - The service and it's id to write to the command to
934
+ * @param options - Optional options to write the command
935
+ *
936
+ */: string;
879
937
  format?: "md" | "mdx";
880
938
  override?: boolean;
881
939
  }) => Promise<void>;
@@ -1375,6 +1433,56 @@ declare const _default: (path: string) => {
1375
1433
  * @returns A JSON object with the configuration for the event catalog.
1376
1434
  */
1377
1435
  getEventCatalogConfigurationFile: () => Promise<any>;
1436
+ /**
1437
+ * ================================
1438
+ * Changelogs
1439
+ * ================================
1440
+ */
1441
+ /**
1442
+ * Writes a changelog entry to a resource in EventCatalog
1443
+ *
1444
+ * @param id - The id of the resource to write the changelog to
1445
+ * @param changelog - The changelog entry to write
1446
+ * @param options - Optional options (version, format)
1447
+ *
1448
+ */
1449
+ writeChangelog: (id: string, changelog: Changelog, options?: {
1450
+ version?: string;
1451
+ format?: "md" | "mdx";
1452
+ }) => Promise<void>;
1453
+ /**
1454
+ * Appends a changelog entry to an existing changelog for a resource.
1455
+ * If no changelog exists, one is created.
1456
+ *
1457
+ * @param id - The id of the resource to append the changelog to
1458
+ * @param changelog - The changelog entry to append
1459
+ * @param options - Optional options (version, format)
1460
+ *
1461
+ */
1462
+ appendChangelog: (id: string, changelog: Changelog, options?: {
1463
+ version?: string;
1464
+ format?: "md" | "mdx";
1465
+ }) => Promise<void>;
1466
+ /**
1467
+ * Returns the changelog for a resource in EventCatalog
1468
+ *
1469
+ * @param id - The id of the resource to get the changelog for
1470
+ * @param options - Optional options (version)
1471
+ * @returns Changelog|Undefined
1472
+ */
1473
+ getChangelog: (id: string, options?: {
1474
+ version?: string;
1475
+ }) => Promise<Changelog | undefined>;
1476
+ /**
1477
+ * Removes the changelog for a resource in EventCatalog
1478
+ *
1479
+ * @param id - The id of the resource to remove the changelog from
1480
+ * @param options - Optional options (version)
1481
+ *
1482
+ */
1483
+ rmChangelog: (id: string, options?: {
1484
+ version?: string;
1485
+ }) => Promise<void>;
1378
1486
  /**
1379
1487
  * ================================
1380
1488
  * Resources Utils
@@ -1695,7 +1803,11 @@ declare const _default: (path: string) => {
1695
1803
  *
1696
1804
  */
1697
1805
  writeDiagram: (diagram: Diagram, options?: {
1698
- path?: string;
1806
+ path? /**
1807
+ * Returns all events from EventCatalog
1808
+ * @param latestOnly - optional boolean, set to true to get only latest versions
1809
+ * @returns Event[]|Undefined
1810
+ */: string;
1699
1811
  override?: boolean;
1700
1812
  versionExistingContent?: boolean;
1701
1813
  format?: "md" | "mdx";
@@ -1755,7 +1867,10 @@ declare const _default: (path: string) => {
1755
1867
  * const dsl = await sdk.toDSL(services, { type: 'service', hydrate: true });
1756
1868
  * ```
1757
1869
  */
1870
+ createSnapshot: (options?: SnapshotOptions) => Promise<SnapshotResult>;
1871
+ diffSnapshots: (snapshotAPath: string, snapshotBPath: string) => Promise<SnapshotDiff>;
1872
+ listSnapshots: () => Promise<SnapshotMeta[]>;
1758
1873
  toDSL: (resource: (Event | Command | Query | Service | Domain) | (Event | Command | Query | Service | Domain)[], options: ToDSLOptions) => Promise<string>;
1759
1874
  };
1760
1875
 
1761
- 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 Operation, 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 };
1876
+ export { type Badge, type BaseSchema, type CatalogSnapshot, type Changelog, type Channel, type ChannelPointer, type Command, type Container, type CustomDoc, type DataProduct, type DataProductOutputPointer, type Diagram, type DiffSummary, type Domain, type Entity, type Event, type EventCatalog, type Message, type Operation, type Query, type ReceivesPointer, type RelationshipChange, type ResourceChange, type ResourceChangeType, type ResourceGroup, type ResourcePointer, type SendsPointer, type Service, type SnapshotDiff, type SnapshotGitInfo, type SnapshotMeta, type SnapshotOptions, type SnapshotResourceType, type SnapshotResources, type SnapshotResult, type Specification, type Specifications, type Team, type UbiquitousLanguage, type UbiquitousLanguageDictionary, type User, _default as default };
package/dist/index.d.ts CHANGED
@@ -235,6 +235,12 @@ interface Badge {
235
235
  icon?: string;
236
236
  }
237
237
 
238
+ interface Changelog {
239
+ createdAt: Date | string;
240
+ badges?: Badge[];
241
+ markdown: string;
242
+ }
243
+
238
244
  interface UbiquitousLanguage {
239
245
  id: string;
240
246
  name: string;
@@ -354,6 +360,86 @@ interface ToDSLOptions {
354
360
  hydrate?: boolean;
355
361
  }
356
362
 
363
+ type SnapshotGitInfo = {
364
+ branch: string;
365
+ commit: string;
366
+ dirty: boolean;
367
+ };
368
+ type SnapshotResources = {
369
+ domains: Record<string, any>[];
370
+ services: Record<string, any>[];
371
+ messages: {
372
+ events: Record<string, any>[];
373
+ commands: Record<string, any>[];
374
+ queries: Record<string, any>[];
375
+ };
376
+ channels: Record<string, any>[];
377
+ };
378
+ type CatalogSnapshot = {
379
+ snapshotVersion: string;
380
+ catalogVersion: string;
381
+ label: string;
382
+ createdAt: string;
383
+ git?: SnapshotGitInfo;
384
+ resources: SnapshotResources;
385
+ };
386
+ type SnapshotOptions = {
387
+ label?: string;
388
+ outputDir?: string;
389
+ git?: SnapshotGitInfo;
390
+ };
391
+ type SnapshotResult = {
392
+ filePath: string;
393
+ snapshot: CatalogSnapshot;
394
+ };
395
+ type SnapshotMeta = {
396
+ label: string;
397
+ createdAt: string;
398
+ filePath: string;
399
+ git?: SnapshotGitInfo;
400
+ };
401
+ type SnapshotResourceType = 'event' | 'command' | 'query' | 'service' | 'domain' | 'channel';
402
+ type ResourceChangeType = 'added' | 'removed' | 'modified' | 'versioned';
403
+ type ResourceChange = {
404
+ resourceId: string;
405
+ version: string;
406
+ type: SnapshotResourceType;
407
+ changeType: ResourceChangeType;
408
+ changedFields?: string[];
409
+ previousVersion?: string;
410
+ newVersion?: string;
411
+ };
412
+ type RelationshipChange = {
413
+ serviceId: string;
414
+ serviceVersion: string;
415
+ resourceId: string;
416
+ resourceVersion?: string;
417
+ direction: 'sends' | 'receives';
418
+ changeType: 'added' | 'removed';
419
+ };
420
+ type DiffSummary = {
421
+ totalChanges: number;
422
+ resourcesAdded: number;
423
+ resourcesRemoved: number;
424
+ resourcesModified: number;
425
+ resourcesVersioned: number;
426
+ relationshipsAdded: number;
427
+ relationshipsRemoved: number;
428
+ };
429
+ type SnapshotDiff = {
430
+ snapshotA: {
431
+ label: string;
432
+ createdAt: string;
433
+ };
434
+ snapshotB: {
435
+ label: string;
436
+ createdAt: string;
437
+ };
438
+ summary: DiffSummary;
439
+ resources: ResourceChange[];
440
+ relationships: RelationshipChange[];
441
+ };
442
+
357
443
  /**
358
444
  * Init the SDK for EventCatalog
359
445
  *
@@ -389,7 +475,13 @@ declare const _default: (path: string) => {
389
475
  writeEvent: (event: Event, options?: {
390
476
  path?: string;
391
477
  override?: boolean;
392
- versionExistingContent?: boolean;
478
+ versionExistingContent? /**
479
+ * Adds an event to EventCatalog
480
+ *
481
+ * @param event - The event to write
482
+ * @param options - Optional options to write the event
483
+ *
484
+ */: boolean;
393
485
  format?: "md" | "mdx";
394
486
  }) => Promise<void>;
395
487
  /**
@@ -746,18 +838,7 @@ declare const _default: (path: string) => {
746
838
  addEventToChannel: (id: string, _message: {
747
839
  id: string;
748
840
  version: string;
749
- parameters
750
- /**
751
- * Returns a query from EventCatalog
752
- * @param id - The id of the query to retrieve
753
- * @param version - Optional id of the version to get (supports semver)
754
- * @returns Query|Undefined
755
- */
756
- ? /**
757
- * ================================
758
- * Queries
759
- * ================================
760
- */: {
841
+ parameters?: {
761
842
  [key: string]: string;
762
843
  };
763
844
  }, version?: string) => Promise<void>;
@@ -780,18 +861,7 @@ declare const _default: (path: string) => {
780
861
  addCommandToChannel: (id: string, _message: {
781
862
  id: string;
782
863
  version: string;
783
- parameters
784
- /**
785
- * Returns a query from EventCatalog
786
- * @param id - The id of the query to retrieve
787
- * @param version - Optional id of the version to get (supports semver)
788
- * @returns Query|Undefined
789
- */
790
- ? /**
791
- * ================================
792
- * Queries
793
- * ================================
794
- */: {
864
+ parameters?: {
795
865
  [key: string]: string;
796
866
  };
797
867
  }, version?: string) => Promise<void>;
@@ -814,18 +884,7 @@ declare const _default: (path: string) => {
814
884
  addQueryToChannel: (id: string, _message: {
815
885
  id: string;
816
886
  version: string;
817
- parameters
818
- /**
819
- * Returns a query from EventCatalog
820
- * @param id - The id of the query to retrieve
821
- * @param version - Optional id of the version to get (supports semver)
822
- * @returns Query|Undefined
823
- */
824
- ? /**
825
- * ================================
826
- * Queries
827
- * ================================
828
- */: {
887
+ parameters?: {
829
888
  [key: string]: string;
830
889
  };
831
890
  }, version?: string) => Promise<void>;
@@ -844,15 +903,7 @@ declare const _default: (path: string) => {
844
903
  writeService: (service: Service, options?: {
845
904
  path?: string;
846
905
  override?: boolean;
847
- versionExistingContent
848
- /**
849
- * Moves a given event id to the version directory
850
- * @param directory
851
- */
852
- ? /**
853
- * Moves a given event id to the version directory
854
- * @param directory
855
- */: boolean;
906
+ versionExistingContent?: boolean;
856
907
  format?: "md" | "mdx";
857
908
  }) => Promise<void>;
858
909
  /**
@@ -875,7 +926,14 @@ declare const _default: (path: string) => {
875
926
  version?: string;
876
927
  direction?: string;
877
928
  }, options?: {
878
- path?: string;
929
+ path? /**
930
+ * Adds a command to a service in EventCatalog
931
+ *
932
+ * @param command - The command to write to the service
933
+ * @param service - The service and it's id to write to the command to
934
+ * @param options - Optional options to write the command
935
+ *
936
+ */: string;
879
937
  format?: "md" | "mdx";
880
938
  override?: boolean;
881
939
  }) => Promise<void>;
@@ -1375,6 +1433,56 @@ declare const _default: (path: string) => {
1375
1433
  * @returns A JSON object with the configuration for the event catalog.
1376
1434
  */
1377
1435
  getEventCatalogConfigurationFile: () => Promise<any>;
1436
+ /**
1437
+ * ================================
1438
+ * Changelogs
1439
+ * ================================
1440
+ */
1441
+ /**
1442
+ * Writes a changelog entry to a resource in EventCatalog
1443
+ *
1444
+ * @param id - The id of the resource to write the changelog to
1445
+ * @param changelog - The changelog entry to write
1446
+ * @param options - Optional options (version, format)
1447
+ *
1448
+ */
1449
+ writeChangelog: (id: string, changelog: Changelog, options?: {
1450
+ version?: string;
1451
+ format?: "md" | "mdx";
1452
+ }) => Promise<void>;
1453
+ /**
1454
+ * Appends a changelog entry to an existing changelog for a resource.
1455
+ * If no changelog exists, one is created.
1456
+ *
1457
+ * @param id - The id of the resource to append the changelog to
1458
+ * @param changelog - The changelog entry to append
1459
+ * @param options - Optional options (version, format)
1460
+ *
1461
+ */
1462
+ appendChangelog: (id: string, changelog: Changelog, options?: {
1463
+ version?: string;
1464
+ format?: "md" | "mdx";
1465
+ }) => Promise<void>;
1466
+ /**
1467
+ * Returns the changelog for a resource in EventCatalog
1468
+ *
1469
+ * @param id - The id of the resource to get the changelog for
1470
+ * @param options - Optional options (version)
1471
+ * @returns Changelog|Undefined
1472
+ */
1473
+ getChangelog: (id: string, options?: {
1474
+ version?: string;
1475
+ }) => Promise<Changelog | undefined>;
1476
+ /**
1477
+ * Removes the changelog for a resource in EventCatalog
1478
+ *
1479
+ * @param id - The id of the resource to remove the changelog from
1480
+ * @param options - Optional options (version)
1481
+ *
1482
+ */
1483
+ rmChangelog: (id: string, options?: {
1484
+ version?: string;
1485
+ }) => Promise<void>;
1378
1486
  /**
1379
1487
  * ================================
1380
1488
  * Resources Utils
@@ -1695,7 +1803,11 @@ declare const _default: (path: string) => {
1695
1803
  *
1696
1804
  */
1697
1805
  writeDiagram: (diagram: Diagram, options?: {
1698
- path?: string;
1806
+ path? /**
1807
+ * Returns all events from EventCatalog
1808
+ * @param latestOnly - optional boolean, set to true to get only latest versions
1809
+ * @returns Event[]|Undefined
1810
+ */: string;
1699
1811
  override?: boolean;
1700
1812
  versionExistingContent?: boolean;
1701
1813
  format?: "md" | "mdx";
@@ -1755,7 +1867,10 @@ declare const _default: (path: string) => {
1755
1867
  * const dsl = await sdk.toDSL(services, { type: 'service', hydrate: true });
1756
1868
  * ```
1757
1869
  */
1870
+ createSnapshot: (options?: SnapshotOptions) => Promise<SnapshotResult>;
1871
+ diffSnapshots: (snapshotAPath: string, snapshotBPath: string) => Promise<SnapshotDiff>;
1872
+ listSnapshots: () => Promise<SnapshotMeta[]>;
1758
1873
  toDSL: (resource: (Event | Command | Query | Service | Domain) | (Event | Command | Query | Service | Domain)[], options: ToDSLOptions) => Promise<string>;
1759
1874
  };
1760
1875
 
1761
- 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 Operation, 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 };
1876
+ export { type Badge, type BaseSchema, type CatalogSnapshot, type Changelog, type Channel, type ChannelPointer, type Command, type Container, type CustomDoc, type DataProduct, type DataProductOutputPointer, type Diagram, type DiffSummary, type Domain, type Entity, type Event, type EventCatalog, type Message, type Operation, type Query, type ReceivesPointer, type RelationshipChange, type ResourceChange, type ResourceChangeType, type ResourceGroup, type ResourcePointer, type SendsPointer, type Service, type SnapshotDiff, type SnapshotGitInfo, type SnapshotMeta, type SnapshotOptions, type SnapshotResourceType, type SnapshotResources, type SnapshotResult, type Specification, type Specifications, type Team, type UbiquitousLanguage, type UbiquitousLanguageDictionary, type User, _default as default };