@eventcatalog/sdk 1.1.4 → 1.2.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/README.md +8 -0
- package/dist/channels.d.mts +167 -0
- package/dist/channels.d.ts +167 -0
- package/dist/channels.js +259 -0
- package/dist/channels.js.map +1 -0
- package/dist/channels.mjs +212 -0
- package/dist/channels.mjs.map +1 -0
- package/dist/index.d.mts +187 -47
- package/dist/index.d.ts +187 -47
- package/dist/index.js +248 -86
- package/dist/index.js.map +1 -1
- package/dist/index.mjs +248 -86
- package/dist/index.mjs.map +1 -1
- package/dist/types.d.d.mts +27 -4
- package/dist/types.d.d.ts +27 -4
- package/dist/types.d.js.map +1 -1
- package/package.json +1 -1
package/dist/index.mjs
CHANGED
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
// src/index.ts
|
|
2
|
-
import { join as
|
|
2
|
+
import { join as join9 } from "node:path";
|
|
3
3
|
|
|
4
4
|
// src/events.ts
|
|
5
5
|
import fs3 from "node:fs/promises";
|
|
@@ -355,6 +355,51 @@ var addServiceToDomain = (directory) => async (id, service, version) => {
|
|
|
355
355
|
await writeDomain(directory)(domain);
|
|
356
356
|
};
|
|
357
357
|
|
|
358
|
+
// src/channels.ts
|
|
359
|
+
import fs8 from "node:fs/promises";
|
|
360
|
+
import { join as join8 } from "node:path";
|
|
361
|
+
var getChannel = (directory) => async (id, version) => getResource(directory, id, version, { type: "channel" });
|
|
362
|
+
var writeChannel = (directory) => async (channel, options = { path: "" }) => writeResource(directory, { ...channel }, { ...options, type: "channel" });
|
|
363
|
+
var rmChannel = (directory) => async (path) => {
|
|
364
|
+
await fs8.rm(join8(directory, path), { recursive: true });
|
|
365
|
+
};
|
|
366
|
+
var rmChannelById = (directory) => async (id, version) => rmResourceById(directory, id, version, { type: "channel" });
|
|
367
|
+
var versionChannel = (directory) => async (id) => versionResource(directory, id);
|
|
368
|
+
var channelHasVersion = (directory) => async (id, version) => {
|
|
369
|
+
const file = await findFileById(directory, id, version);
|
|
370
|
+
return !!file;
|
|
371
|
+
};
|
|
372
|
+
var addMessageToChannel = (directory, collection) => async (id, _message, version) => {
|
|
373
|
+
let channel = await getChannel(directory)(id, version);
|
|
374
|
+
const functions = {
|
|
375
|
+
events: {
|
|
376
|
+
getMessage: getEvent,
|
|
377
|
+
rmMessageById: rmEventById,
|
|
378
|
+
writeMessage: writeEvent
|
|
379
|
+
},
|
|
380
|
+
commands: {
|
|
381
|
+
getMessage: getCommand,
|
|
382
|
+
rmMessageById: rmCommandById,
|
|
383
|
+
writeMessage: writeCommand
|
|
384
|
+
},
|
|
385
|
+
queries: {
|
|
386
|
+
getMessage: getQuery,
|
|
387
|
+
rmMessageById: rmQueryById,
|
|
388
|
+
writeMessage: writeQuery
|
|
389
|
+
}
|
|
390
|
+
};
|
|
391
|
+
const { getMessage, rmMessageById, writeMessage } = functions[collection];
|
|
392
|
+
const message = await getMessage(directory)(_message.id, _message.version);
|
|
393
|
+
if (!message) throw new Error(`Message ${_message.id} with version ${_message.version} not found`);
|
|
394
|
+
if (message.channels === void 0) {
|
|
395
|
+
message.channels = [];
|
|
396
|
+
}
|
|
397
|
+
const channelInfo = { id, version: channel.version, ..._message.parameters && { parameters: _message.parameters } };
|
|
398
|
+
message.channels.push(channelInfo);
|
|
399
|
+
await rmMessageById(directory)(_message.id, _message.version);
|
|
400
|
+
await writeMessage(directory)(message);
|
|
401
|
+
};
|
|
402
|
+
|
|
358
403
|
// src/index.ts
|
|
359
404
|
var src_default = (path) => {
|
|
360
405
|
return {
|
|
@@ -364,7 +409,7 @@ var src_default = (path) => {
|
|
|
364
409
|
* @param version - Optional id of the version to get (supports semver)
|
|
365
410
|
* @returns Event|Undefined
|
|
366
411
|
*/
|
|
367
|
-
getEvent: getEvent(
|
|
412
|
+
getEvent: getEvent(join9(path)),
|
|
368
413
|
/**
|
|
369
414
|
* Adds an event to EventCatalog
|
|
370
415
|
*
|
|
@@ -372,7 +417,7 @@ var src_default = (path) => {
|
|
|
372
417
|
* @param options - Optional options to write the event
|
|
373
418
|
*
|
|
374
419
|
*/
|
|
375
|
-
writeEvent: writeEvent(
|
|
420
|
+
writeEvent: writeEvent(join9(path, "events")),
|
|
376
421
|
/**
|
|
377
422
|
* Adds an event to a service in EventCatalog
|
|
378
423
|
*
|
|
@@ -381,26 +426,26 @@ var src_default = (path) => {
|
|
|
381
426
|
* @param options - Optional options to write the event
|
|
382
427
|
*
|
|
383
428
|
*/
|
|
384
|
-
writeEventToService: writeEventToService(
|
|
429
|
+
writeEventToService: writeEventToService(join9(path, "services")),
|
|
385
430
|
/**
|
|
386
431
|
* Remove an event to EventCatalog (modeled on the standard POSIX rm utility)
|
|
387
432
|
*
|
|
388
433
|
* @param path - The path to your event, e.g. `/Inventory/InventoryAdjusted`
|
|
389
434
|
*
|
|
390
435
|
*/
|
|
391
|
-
rmEvent: rmEvent(
|
|
436
|
+
rmEvent: rmEvent(join9(path, "events")),
|
|
392
437
|
/**
|
|
393
438
|
* Remove an event by an Event id
|
|
394
439
|
*
|
|
395
440
|
* @param id - The id of the event you want to remove
|
|
396
441
|
*
|
|
397
442
|
*/
|
|
398
|
-
rmEventById: rmEventById(
|
|
443
|
+
rmEventById: rmEventById(join9(path)),
|
|
399
444
|
/**
|
|
400
445
|
* Moves a given event id to the version directory
|
|
401
446
|
* @param directory
|
|
402
447
|
*/
|
|
403
|
-
versionEvent: versionEvent(
|
|
448
|
+
versionEvent: versionEvent(join9(path)),
|
|
404
449
|
/**
|
|
405
450
|
* Adds a file to the given event
|
|
406
451
|
* @param id - The id of the event to add the file to
|
|
@@ -408,7 +453,7 @@ var src_default = (path) => {
|
|
|
408
453
|
* @param version - Optional version of the event to add the file to
|
|
409
454
|
* @returns
|
|
410
455
|
*/
|
|
411
|
-
addFileToEvent: addFileToEvent(
|
|
456
|
+
addFileToEvent: addFileToEvent(join9(path)),
|
|
412
457
|
/**
|
|
413
458
|
* Adds a schema to the given event
|
|
414
459
|
* @param id - The id of the event to add the schema to
|
|
@@ -416,14 +461,14 @@ var src_default = (path) => {
|
|
|
416
461
|
* @param version - Optional version of the event to add the schema to
|
|
417
462
|
* @returns
|
|
418
463
|
*/
|
|
419
|
-
addSchemaToEvent: addSchemaToEvent(
|
|
464
|
+
addSchemaToEvent: addSchemaToEvent(join9(path)),
|
|
420
465
|
/**
|
|
421
466
|
* Check to see if an event version exists
|
|
422
467
|
* @param id - The id of the event
|
|
423
468
|
* @param version - The version of the event (supports semver)
|
|
424
469
|
* @returns
|
|
425
470
|
*/
|
|
426
|
-
eventHasVersion: eventHasVersion(
|
|
471
|
+
eventHasVersion: eventHasVersion(join9(path)),
|
|
427
472
|
/**
|
|
428
473
|
* ================================
|
|
429
474
|
* Commands
|
|
@@ -435,7 +480,7 @@ var src_default = (path) => {
|
|
|
435
480
|
* @param version - Optional id of the version to get (supports semver)
|
|
436
481
|
* @returns Command|Undefined
|
|
437
482
|
*/
|
|
438
|
-
getCommand: getCommand(
|
|
483
|
+
getCommand: getCommand(join9(path)),
|
|
439
484
|
/**
|
|
440
485
|
* Adds an command to EventCatalog
|
|
441
486
|
*
|
|
@@ -443,7 +488,7 @@ var src_default = (path) => {
|
|
|
443
488
|
* @param options - Optional options to write the command
|
|
444
489
|
*
|
|
445
490
|
*/
|
|
446
|
-
writeCommand: writeCommand(
|
|
491
|
+
writeCommand: writeCommand(join9(path, "commands")),
|
|
447
492
|
/**
|
|
448
493
|
* Adds a command to a service in EventCatalog
|
|
449
494
|
*
|
|
@@ -452,26 +497,26 @@ var src_default = (path) => {
|
|
|
452
497
|
* @param options - Optional options to write the command
|
|
453
498
|
*
|
|
454
499
|
*/
|
|
455
|
-
writeCommandToService: writeCommandToService(
|
|
500
|
+
writeCommandToService: writeCommandToService(join9(path, "services")),
|
|
456
501
|
/**
|
|
457
502
|
* Remove an command to EventCatalog (modeled on the standard POSIX rm utility)
|
|
458
503
|
*
|
|
459
504
|
* @param path - The path to your command, e.g. `/Inventory/InventoryAdjusted`
|
|
460
505
|
*
|
|
461
506
|
*/
|
|
462
|
-
rmCommand: rmCommand(
|
|
507
|
+
rmCommand: rmCommand(join9(path, "commands")),
|
|
463
508
|
/**
|
|
464
509
|
* Remove an command by an Event id
|
|
465
510
|
*
|
|
466
511
|
* @param id - The id of the command you want to remove
|
|
467
512
|
*
|
|
468
513
|
*/
|
|
469
|
-
rmCommandById: rmCommandById(
|
|
514
|
+
rmCommandById: rmCommandById(join9(path)),
|
|
470
515
|
/**
|
|
471
516
|
* Moves a given command id to the version directory
|
|
472
517
|
* @param directory
|
|
473
518
|
*/
|
|
474
|
-
versionCommand: versionCommand(
|
|
519
|
+
versionCommand: versionCommand(join9(path)),
|
|
475
520
|
/**
|
|
476
521
|
* Adds a file to the given command
|
|
477
522
|
* @param id - The id of the command to add the file to
|
|
@@ -479,7 +524,7 @@ var src_default = (path) => {
|
|
|
479
524
|
* @param version - Optional version of the command to add the file to
|
|
480
525
|
* @returns
|
|
481
526
|
*/
|
|
482
|
-
addFileToCommand: addFileToCommand(
|
|
527
|
+
addFileToCommand: addFileToCommand(join9(path)),
|
|
483
528
|
/**
|
|
484
529
|
* Adds a schema to the given command
|
|
485
530
|
* @param id - The id of the command to add the schema to
|
|
@@ -487,14 +532,14 @@ var src_default = (path) => {
|
|
|
487
532
|
* @param version - Optional version of the command to add the schema to
|
|
488
533
|
* @returns
|
|
489
534
|
*/
|
|
490
|
-
addSchemaToCommand: addSchemaToCommand(
|
|
535
|
+
addSchemaToCommand: addSchemaToCommand(join9(path)),
|
|
491
536
|
/**
|
|
492
537
|
* Check to see if a command version exists
|
|
493
538
|
* @param id - The id of the command
|
|
494
539
|
* @param version - The version of the command (supports semver)
|
|
495
540
|
* @returns
|
|
496
541
|
*/
|
|
497
|
-
commandHasVersion: commandHasVersion(
|
|
542
|
+
commandHasVersion: commandHasVersion(join9(path)),
|
|
498
543
|
/**
|
|
499
544
|
* ================================
|
|
500
545
|
* Queries
|
|
@@ -506,7 +551,7 @@ var src_default = (path) => {
|
|
|
506
551
|
* @param version - Optional id of the version to get (supports semver)
|
|
507
552
|
* @returns Query|Undefined
|
|
508
553
|
*/
|
|
509
|
-
getQuery: getQuery(
|
|
554
|
+
getQuery: getQuery(join9(path)),
|
|
510
555
|
/**
|
|
511
556
|
* Adds a query to EventCatalog
|
|
512
557
|
*
|
|
@@ -514,7 +559,7 @@ var src_default = (path) => {
|
|
|
514
559
|
* @param options - Optional options to write the event
|
|
515
560
|
*
|
|
516
561
|
*/
|
|
517
|
-
writeQuery: writeQuery(
|
|
562
|
+
writeQuery: writeQuery(join9(path, "queries")),
|
|
518
563
|
/**
|
|
519
564
|
* Adds a query to a service in EventCatalog
|
|
520
565
|
*
|
|
@@ -523,26 +568,26 @@ var src_default = (path) => {
|
|
|
523
568
|
* @param options - Optional options to write the query
|
|
524
569
|
*
|
|
525
570
|
*/
|
|
526
|
-
writeQueryToService: writeQueryToService(
|
|
571
|
+
writeQueryToService: writeQueryToService(join9(path, "services")),
|
|
527
572
|
/**
|
|
528
573
|
* Remove an query to EventCatalog (modeled on the standard POSIX rm utility)
|
|
529
574
|
*
|
|
530
575
|
* @param path - The path to your query, e.g. `/Orders/GetOrder`
|
|
531
576
|
*
|
|
532
577
|
*/
|
|
533
|
-
rmQuery: rmQuery(
|
|
578
|
+
rmQuery: rmQuery(join9(path, "queries")),
|
|
534
579
|
/**
|
|
535
580
|
* Remove a query by a Query id
|
|
536
581
|
*
|
|
537
582
|
* @param id - The id of the query you want to remove
|
|
538
583
|
*
|
|
539
584
|
*/
|
|
540
|
-
rmQueryById: rmQueryById(
|
|
585
|
+
rmQueryById: rmQueryById(join9(path)),
|
|
541
586
|
/**
|
|
542
587
|
* Moves a given query id to the version directory
|
|
543
588
|
* @param directory
|
|
544
589
|
*/
|
|
545
|
-
versionQuery: versionQuery(
|
|
590
|
+
versionQuery: versionQuery(join9(path)),
|
|
546
591
|
/**
|
|
547
592
|
* Adds a file to the given query
|
|
548
593
|
* @param id - The id of the query to add the file to
|
|
@@ -550,7 +595,7 @@ var src_default = (path) => {
|
|
|
550
595
|
* @param version - Optional version of the query to add the file to
|
|
551
596
|
* @returns
|
|
552
597
|
*/
|
|
553
|
-
addFileToQuery: addFileToQuery(
|
|
598
|
+
addFileToQuery: addFileToQuery(join9(path)),
|
|
554
599
|
/**
|
|
555
600
|
* Adds a schema to the given query
|
|
556
601
|
* @param id - The id of the query to add the schema to
|
|
@@ -558,14 +603,111 @@ var src_default = (path) => {
|
|
|
558
603
|
* @param version - Optional version of the query to add the schema to
|
|
559
604
|
* @returns
|
|
560
605
|
*/
|
|
561
|
-
addSchemaToQuery: addSchemaToQuery(
|
|
606
|
+
addSchemaToQuery: addSchemaToQuery(join9(path)),
|
|
562
607
|
/**
|
|
563
608
|
* Check to see if an query version exists
|
|
564
609
|
* @param id - The id of the query
|
|
565
610
|
* @param version - The version of the query (supports semver)
|
|
566
611
|
* @returns
|
|
567
612
|
*/
|
|
568
|
-
queryHasVersion: queryHasVersion(
|
|
613
|
+
queryHasVersion: queryHasVersion(join9(path)),
|
|
614
|
+
/**
|
|
615
|
+
* ================================
|
|
616
|
+
* Channels
|
|
617
|
+
* ================================
|
|
618
|
+
*/
|
|
619
|
+
/**
|
|
620
|
+
* Returns a channel from EventCatalog
|
|
621
|
+
* @param id - The id of the channel to retrieve
|
|
622
|
+
* @param version - Optional id of the version to get (supports semver)
|
|
623
|
+
* @returns Channel|Undefined
|
|
624
|
+
*/
|
|
625
|
+
getChannel: getChannel(join9(path)),
|
|
626
|
+
/**
|
|
627
|
+
* Adds an channel to EventCatalog
|
|
628
|
+
*
|
|
629
|
+
* @param command - The channel to write
|
|
630
|
+
* @param options - Optional options to write the channel
|
|
631
|
+
*
|
|
632
|
+
*/
|
|
633
|
+
writeChannel: writeChannel(join9(path, "channels")),
|
|
634
|
+
/**
|
|
635
|
+
* Remove an channel to EventCatalog (modeled on the standard POSIX rm utility)
|
|
636
|
+
*
|
|
637
|
+
* @param path - The path to your channel, e.g. `/Inventory/InventoryAdjusted`
|
|
638
|
+
*
|
|
639
|
+
*/
|
|
640
|
+
rmChannel: rmChannel(join9(path, "channels")),
|
|
641
|
+
/**
|
|
642
|
+
* Remove an channel by an Event id
|
|
643
|
+
*
|
|
644
|
+
* @param id - The id of the channel you want to remove
|
|
645
|
+
*
|
|
646
|
+
*/
|
|
647
|
+
rmChannelById: rmChannelById(join9(path)),
|
|
648
|
+
/**
|
|
649
|
+
* Moves a given channel id to the version directory
|
|
650
|
+
* @param directory
|
|
651
|
+
*/
|
|
652
|
+
versionChannel: versionChannel(join9(path)),
|
|
653
|
+
/**
|
|
654
|
+
* Check to see if a channel version exists
|
|
655
|
+
* @param id - The id of the channel
|
|
656
|
+
* @param version - The version of the channel (supports semver)
|
|
657
|
+
* @returns
|
|
658
|
+
*/
|
|
659
|
+
channelHasVersion: channelHasVersion(join9(path)),
|
|
660
|
+
/**
|
|
661
|
+
* Add a channel to an event
|
|
662
|
+
*
|
|
663
|
+
* Optionally specify a version to add the channel to a specific version of the event.
|
|
664
|
+
*
|
|
665
|
+
* @example
|
|
666
|
+
* ```ts
|
|
667
|
+
* import utils from '@eventcatalog/utils';
|
|
668
|
+
*
|
|
669
|
+
* const { addEventToChannel } = utils('/path/to/eventcatalog');
|
|
670
|
+
*
|
|
671
|
+
* // adds a new event (InventoryUpdatedEvent) to the inventory.{env}.events channel
|
|
672
|
+
* await addEventToChannel('inventory.{env}.events channel', { id: 'InventoryUpdatedEvent', version: '2.0.0', parameters: { env: 'dev' } });
|
|
673
|
+
*
|
|
674
|
+
* ```
|
|
675
|
+
*/
|
|
676
|
+
addEventToChannel: addMessageToChannel(join9(path), "events"),
|
|
677
|
+
/**
|
|
678
|
+
* Add a channel to an command
|
|
679
|
+
*
|
|
680
|
+
* Optionally specify a version to add the channel to a specific version of the command.
|
|
681
|
+
*
|
|
682
|
+
* @example
|
|
683
|
+
* ```ts
|
|
684
|
+
* import utils from '@eventcatalog/utils';
|
|
685
|
+
*
|
|
686
|
+
* const { addCommandToChannel } = utils('/path/to/eventcatalog');
|
|
687
|
+
*
|
|
688
|
+
* // adds a new command (UpdateInventory) to the inventory.{env}.events channel
|
|
689
|
+
* await addCommandToChannel('inventory.{env}.events channel', { id: 'UpdateInventory', version: '2.0.0', parameters: { env: 'dev' } });
|
|
690
|
+
*
|
|
691
|
+
* ```
|
|
692
|
+
*/
|
|
693
|
+
addCommandToChannel: addMessageToChannel(join9(path), "commands"),
|
|
694
|
+
/**
|
|
695
|
+
* Add a channel to an query
|
|
696
|
+
*
|
|
697
|
+
* Optionally specify a version to add the channel to a specific version of the query.
|
|
698
|
+
*
|
|
699
|
+
* @example
|
|
700
|
+
* ```ts
|
|
701
|
+
* import utils from '@eventcatalog/utils';
|
|
702
|
+
*
|
|
703
|
+
* const { addQueryToChannel } = utils('/path/to/eventcatalog');
|
|
704
|
+
*
|
|
705
|
+
* // adds a new query (GetInventory) to the inventory.{env}.events channel
|
|
706
|
+
* await addQueryToChannel('inventory.{env}.events channel', { id: 'GetInventory', version: '2.0.0', parameters: { env: 'dev' } });
|
|
707
|
+
*
|
|
708
|
+
* ```
|
|
709
|
+
*/
|
|
710
|
+
addQueryToChannel: addMessageToChannel(join9(path), "queries"),
|
|
569
711
|
/**
|
|
570
712
|
* ================================
|
|
571
713
|
* SERVICES
|
|
@@ -578,14 +720,14 @@ var src_default = (path) => {
|
|
|
578
720
|
* @param options - Optional options to write the event
|
|
579
721
|
*
|
|
580
722
|
*/
|
|
581
|
-
writeService: writeService(
|
|
723
|
+
writeService: writeService(join9(path, "services")),
|
|
582
724
|
/**
|
|
583
725
|
* Adds a versioned service to EventCatalog
|
|
584
726
|
*
|
|
585
727
|
* @param service - The service to write
|
|
586
728
|
*
|
|
587
729
|
*/
|
|
588
|
-
writeVersionedService: writeVersionedService(
|
|
730
|
+
writeVersionedService: writeVersionedService(join9(path, "services")),
|
|
589
731
|
/**
|
|
590
732
|
* Adds a service to a domain in EventCatalog
|
|
591
733
|
*
|
|
@@ -594,33 +736,33 @@ var src_default = (path) => {
|
|
|
594
736
|
* @param options - Optional options to write the event
|
|
595
737
|
*
|
|
596
738
|
*/
|
|
597
|
-
writeServiceToDomain: writeServiceToDomain(
|
|
739
|
+
writeServiceToDomain: writeServiceToDomain(join9(path, "domains")),
|
|
598
740
|
/**
|
|
599
741
|
* Returns a service from EventCatalog
|
|
600
742
|
* @param id - The id of the service to retrieve
|
|
601
743
|
* @param version - Optional id of the version to get (supports semver)
|
|
602
744
|
* @returns Service|Undefined
|
|
603
745
|
*/
|
|
604
|
-
getService: getService(
|
|
746
|
+
getService: getService(join9(path)),
|
|
605
747
|
/**
|
|
606
748
|
* Moves a given service id to the version directory
|
|
607
749
|
* @param directory
|
|
608
750
|
*/
|
|
609
|
-
versionService: versionService(
|
|
751
|
+
versionService: versionService(join9(path)),
|
|
610
752
|
/**
|
|
611
753
|
* Remove a service from EventCatalog (modeled on the standard POSIX rm utility)
|
|
612
754
|
*
|
|
613
755
|
* @param path - The path to your service, e.g. `/InventoryService`
|
|
614
756
|
*
|
|
615
757
|
*/
|
|
616
|
-
rmService: rmService(
|
|
758
|
+
rmService: rmService(join9(path, "services")),
|
|
617
759
|
/**
|
|
618
760
|
* Remove an service by an service id
|
|
619
761
|
*
|
|
620
762
|
* @param id - The id of the service you want to remove
|
|
621
763
|
*
|
|
622
764
|
*/
|
|
623
|
-
rmServiceById: rmServiceById(
|
|
765
|
+
rmServiceById: rmServiceById(join9(path)),
|
|
624
766
|
/**
|
|
625
767
|
* Adds a file to the given service
|
|
626
768
|
* @param id - The id of the service to add the file to
|
|
@@ -628,21 +770,81 @@ var src_default = (path) => {
|
|
|
628
770
|
* @param version - Optional version of the service to add the file to
|
|
629
771
|
* @returns
|
|
630
772
|
*/
|
|
631
|
-
addFileToService: addFileToService(
|
|
773
|
+
addFileToService: addFileToService(join9(path)),
|
|
632
774
|
/**
|
|
633
775
|
* Returns the specifications for a given service
|
|
634
776
|
* @param id - The id of the service to retrieve the specifications for
|
|
635
777
|
* @param version - Optional version of the service
|
|
636
778
|
* @returns
|
|
637
779
|
*/
|
|
638
|
-
getSpecificationFilesForService: getSpecificationFilesForService(
|
|
780
|
+
getSpecificationFilesForService: getSpecificationFilesForService(join9(path)),
|
|
639
781
|
/**
|
|
640
782
|
* Check to see if a service version exists
|
|
641
783
|
* @param id - The id of the service
|
|
642
784
|
* @param version - The version of the service (supports semver)
|
|
643
785
|
* @returns
|
|
644
786
|
*/
|
|
645
|
-
serviceHasVersion: serviceHasVersion(
|
|
787
|
+
serviceHasVersion: serviceHasVersion(join9(path)),
|
|
788
|
+
/**
|
|
789
|
+
* Add an event to a service by it's id.
|
|
790
|
+
*
|
|
791
|
+
* Optionally specify a version to add the event to a specific version of the service.
|
|
792
|
+
*
|
|
793
|
+
* @example
|
|
794
|
+
* ```ts
|
|
795
|
+
* import utils from '@eventcatalog/utils';
|
|
796
|
+
*
|
|
797
|
+
* const { addEventToService } = utils('/path/to/eventcatalog');
|
|
798
|
+
*
|
|
799
|
+
* // adds a new event (InventoryUpdatedEvent) that the InventoryService will send
|
|
800
|
+
* await addEventToService('InventoryService', 'sends', { event: 'InventoryUpdatedEvent', version: '2.0.0' });
|
|
801
|
+
*
|
|
802
|
+
* // adds a new event (OrderComplete) that the InventoryService will receive
|
|
803
|
+
* await addEventToService('InventoryService', 'receives', { event: 'OrderComplete', version: '2.0.0' });
|
|
804
|
+
*
|
|
805
|
+
* ```
|
|
806
|
+
*/
|
|
807
|
+
addEventToService: addMessageToService(join9(path)),
|
|
808
|
+
/**
|
|
809
|
+
* Add a command to a service by it's id.
|
|
810
|
+
*
|
|
811
|
+
* Optionally specify a version to add the event to a specific version of the service.
|
|
812
|
+
*
|
|
813
|
+
* @example
|
|
814
|
+
* ```ts
|
|
815
|
+
* import utils from '@eventcatalog/utils';
|
|
816
|
+
*
|
|
817
|
+
* const { addCommandToService } = utils('/path/to/eventcatalog');
|
|
818
|
+
*
|
|
819
|
+
* // adds a new command (UpdateInventoryCommand) that the InventoryService will send
|
|
820
|
+
* await addCommandToService('InventoryService', 'sends', { command: 'UpdateInventoryCommand', version: '2.0.0' });
|
|
821
|
+
*
|
|
822
|
+
* // adds a new command (VerifyInventory) that the InventoryService will receive
|
|
823
|
+
* await addCommandToService('InventoryService', 'receives', { command: 'VerifyInventory', version: '2.0.0' });
|
|
824
|
+
*
|
|
825
|
+
* ```
|
|
826
|
+
*/
|
|
827
|
+
addCommandToService: addMessageToService(join9(path)),
|
|
828
|
+
/**
|
|
829
|
+
* Add a query to a service by it's id.
|
|
830
|
+
*
|
|
831
|
+
* Optionally specify a version to add the event to a specific version of the service.
|
|
832
|
+
*
|
|
833
|
+
* @example
|
|
834
|
+
* ```ts
|
|
835
|
+
* import utils from '@eventcatalog/utils';
|
|
836
|
+
*
|
|
837
|
+
* const { addQueryToService } = utils('/path/to/eventcatalog');
|
|
838
|
+
*
|
|
839
|
+
* // adds a new query (UpdateInventory) that the InventoryService will send
|
|
840
|
+
* await addQueryToService('InventoryService', 'sends', { command: 'UpdateInventory', version: '2.0.0' });
|
|
841
|
+
*
|
|
842
|
+
* // adds a new command (VerifyInventory) that the InventoryService will receive
|
|
843
|
+
* await addQueryToService('InventoryService', 'receives', { command: 'VerifyInventory', version: '2.0.0' });
|
|
844
|
+
*
|
|
845
|
+
* ```
|
|
846
|
+
*/
|
|
847
|
+
addQueryToService: addMessageToService(join9(path)),
|
|
646
848
|
/**
|
|
647
849
|
* ================================
|
|
648
850
|
* Domains
|
|
@@ -655,33 +857,33 @@ var src_default = (path) => {
|
|
|
655
857
|
* @param options - Optional options to write the event
|
|
656
858
|
*
|
|
657
859
|
*/
|
|
658
|
-
writeDomain: writeDomain(
|
|
860
|
+
writeDomain: writeDomain(join9(path, "domains")),
|
|
659
861
|
/**
|
|
660
862
|
* Returns a domain from EventCatalog
|
|
661
863
|
* @param id - The id of the domain to retrieve
|
|
662
864
|
* @param version - Optional id of the version to get (supports semver)
|
|
663
865
|
* @returns Domain|Undefined
|
|
664
866
|
*/
|
|
665
|
-
getDomain: getDomain(
|
|
867
|
+
getDomain: getDomain(join9(path, "domains")),
|
|
666
868
|
/**
|
|
667
869
|
* Moves a given domain id to the version directory
|
|
668
870
|
* @param directory
|
|
669
871
|
*/
|
|
670
|
-
versionDomain: versionDomain(
|
|
872
|
+
versionDomain: versionDomain(join9(path, "domains")),
|
|
671
873
|
/**
|
|
672
874
|
* Remove a domain from EventCatalog (modeled on the standard POSIX rm utility)
|
|
673
875
|
*
|
|
674
876
|
* @param path - The path to your domain, e.g. `/Payment`
|
|
675
877
|
*
|
|
676
878
|
*/
|
|
677
|
-
rmDomain: rmDomain(
|
|
879
|
+
rmDomain: rmDomain(join9(path, "domains")),
|
|
678
880
|
/**
|
|
679
881
|
* Remove an service by an domain id
|
|
680
882
|
*
|
|
681
883
|
* @param id - The id of the domain you want to remove
|
|
682
884
|
*
|
|
683
885
|
*/
|
|
684
|
-
rmDomainById: rmDomainById(
|
|
886
|
+
rmDomainById: rmDomainById(join9(path, "domains")),
|
|
685
887
|
/**
|
|
686
888
|
* Adds a file to the given domain
|
|
687
889
|
* @param id - The id of the domain to add the file to
|
|
@@ -689,54 +891,14 @@ var src_default = (path) => {
|
|
|
689
891
|
* @param version - Optional version of the domain to add the file to
|
|
690
892
|
* @returns
|
|
691
893
|
*/
|
|
692
|
-
addFileToDomain: addFileToDomain(
|
|
693
|
-
/**
|
|
694
|
-
* Add an event to a service by it's id.
|
|
695
|
-
*
|
|
696
|
-
* Optionally specify a version to add the event to a specific version of the service.
|
|
697
|
-
*
|
|
698
|
-
* @example
|
|
699
|
-
* ```ts
|
|
700
|
-
* import utils from '@eventcatalog/utils';
|
|
701
|
-
*
|
|
702
|
-
* const { addEventToService } = utils('/path/to/eventcatalog');
|
|
703
|
-
*
|
|
704
|
-
* // adds a new event (InventoryUpdatedEvent) that the InventoryService will send
|
|
705
|
-
* await addEventToService('InventoryService', 'sends', { event: 'InventoryUpdatedEvent', version: '2.0.0' });
|
|
706
|
-
*
|
|
707
|
-
* // adds a new event (OrderComplete) that the InventoryService will receive
|
|
708
|
-
* await addEventToService('InventoryService', 'receives', { event: 'OrderComplete', version: '2.0.0' });
|
|
709
|
-
*
|
|
710
|
-
* ```
|
|
711
|
-
*/
|
|
712
|
-
addEventToService: addMessageToService(join8(path)),
|
|
713
|
-
/**
|
|
714
|
-
* Add a command to a service by it's id.
|
|
715
|
-
*
|
|
716
|
-
* Optionally specify a version to add the event to a specific version of the service.
|
|
717
|
-
*
|
|
718
|
-
* @example
|
|
719
|
-
* ```ts
|
|
720
|
-
* import utils from '@eventcatalog/utils';
|
|
721
|
-
*
|
|
722
|
-
* const { addCommandToService } = utils('/path/to/eventcatalog');
|
|
723
|
-
*
|
|
724
|
-
* // adds a new command (UpdateInventoryCommand) that the InventoryService will send
|
|
725
|
-
* await addCommandToService('InventoryService', 'sends', { command: 'UpdateInventoryCommand', version: '2.0.0' });
|
|
726
|
-
*
|
|
727
|
-
* // adds a new command (VerifyInventory) that the InventoryService will receive
|
|
728
|
-
* await addCommandToService('InventoryService', 'receives', { command: 'VerifyInventory', version: '2.0.0' });
|
|
729
|
-
*
|
|
730
|
-
* ```
|
|
731
|
-
*/
|
|
732
|
-
addCommandToService: addMessageToService(join8(path)),
|
|
894
|
+
addFileToDomain: addFileToDomain(join9(path, "domains")),
|
|
733
895
|
/**
|
|
734
896
|
* Check to see if a domain version exists
|
|
735
897
|
* @param id - The id of the domain
|
|
736
898
|
* @param version - The version of the domain (supports semver)
|
|
737
899
|
* @returns
|
|
738
900
|
*/
|
|
739
|
-
domainHasVersion: domainHasVersion(
|
|
901
|
+
domainHasVersion: domainHasVersion(join9(path)),
|
|
740
902
|
/**
|
|
741
903
|
* Adds a given service to a domain
|
|
742
904
|
* @param id - The id of the domain
|
|
@@ -744,7 +906,7 @@ var src_default = (path) => {
|
|
|
744
906
|
* @param version - (Optional) The version of the domain to add the service to
|
|
745
907
|
* @returns
|
|
746
908
|
*/
|
|
747
|
-
addServiceToDomain: addServiceToDomain(
|
|
909
|
+
addServiceToDomain: addServiceToDomain(join9(path, "domains"))
|
|
748
910
|
};
|
|
749
911
|
};
|
|
750
912
|
export {
|