@eventcatalog/sdk 2.16.0 → 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
@@ -360,6 +360,86 @@ interface ToDSLOptions {
360
360
  hydrate?: boolean;
361
361
  }
362
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
+
363
443
  /**
364
444
  * Init the SDK for EventCatalog
365
445
  *
@@ -395,7 +475,13 @@ declare const _default: (path: string) => {
395
475
  writeEvent: (event: Event, options?: {
396
476
  path?: string;
397
477
  override?: boolean;
398
- 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;
399
485
  format?: "md" | "mdx";
400
486
  }) => Promise<void>;
401
487
  /**
@@ -840,7 +926,14 @@ declare const _default: (path: string) => {
840
926
  version?: string;
841
927
  direction?: string;
842
928
  }, options?: {
843
- 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;
844
937
  format?: "md" | "mdx";
845
938
  override?: boolean;
846
939
  }) => Promise<void>;
@@ -1710,7 +1803,11 @@ declare const _default: (path: string) => {
1710
1803
  *
1711
1804
  */
1712
1805
  writeDiagram: (diagram: Diagram, options?: {
1713
- 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;
1714
1811
  override?: boolean;
1715
1812
  versionExistingContent?: boolean;
1716
1813
  format?: "md" | "mdx";
@@ -1770,7 +1867,10 @@ declare const _default: (path: string) => {
1770
1867
  * const dsl = await sdk.toDSL(services, { type: 'service', hydrate: true });
1771
1868
  * ```
1772
1869
  */
1870
+ createSnapshot: (options?: SnapshotOptions) => Promise<SnapshotResult>;
1871
+ diffSnapshots: (snapshotAPath: string, snapshotBPath: string) => Promise<SnapshotDiff>;
1872
+ listSnapshots: () => Promise<SnapshotMeta[]>;
1773
1873
  toDSL: (resource: (Event | Command | Query | Service | Domain) | (Event | Command | Query | Service | Domain)[], options: ToDSLOptions) => Promise<string>;
1774
1874
  };
1775
1875
 
1776
- export { type Badge, type BaseSchema, type Changelog, 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
@@ -360,6 +360,86 @@ interface ToDSLOptions {
360
360
  hydrate?: boolean;
361
361
  }
362
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
+
363
443
  /**
364
444
  * Init the SDK for EventCatalog
365
445
  *
@@ -395,7 +475,13 @@ declare const _default: (path: string) => {
395
475
  writeEvent: (event: Event, options?: {
396
476
  path?: string;
397
477
  override?: boolean;
398
- 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;
399
485
  format?: "md" | "mdx";
400
486
  }) => Promise<void>;
401
487
  /**
@@ -840,7 +926,14 @@ declare const _default: (path: string) => {
840
926
  version?: string;
841
927
  direction?: string;
842
928
  }, options?: {
843
- 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;
844
937
  format?: "md" | "mdx";
845
938
  override?: boolean;
846
939
  }) => Promise<void>;
@@ -1710,7 +1803,11 @@ declare const _default: (path: string) => {
1710
1803
  *
1711
1804
  */
1712
1805
  writeDiagram: (diagram: Diagram, options?: {
1713
- 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;
1714
1811
  override?: boolean;
1715
1812
  versionExistingContent?: boolean;
1716
1813
  format?: "md" | "mdx";
@@ -1770,7 +1867,10 @@ declare const _default: (path: string) => {
1770
1867
  * const dsl = await sdk.toDSL(services, { type: 'service', hydrate: true });
1771
1868
  * ```
1772
1869
  */
1870
+ createSnapshot: (options?: SnapshotOptions) => Promise<SnapshotResult>;
1871
+ diffSnapshots: (snapshotAPath: string, snapshotBPath: string) => Promise<SnapshotDiff>;
1872
+ listSnapshots: () => Promise<SnapshotMeta[]>;
1773
1873
  toDSL: (resource: (Event | Command | Query | Service | Domain) | (Event | Command | Query | Service | Domain)[], options: ToDSLOptions) => Promise<string>;
1774
1874
  };
1775
1875
 
1776
- export { type Badge, type BaseSchema, type Changelog, 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 };