@eventcatalog/sdk 2.3.0 → 2.3.1

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.mjs CHANGED
@@ -483,6 +483,9 @@ var writeDomain = (directory) => async (domain, options = {
483
483
  if (Array.isArray(domain.services)) {
484
484
  resource.services = uniqueVersions(domain.services);
485
485
  }
486
+ if (Array.isArray(domain.domains)) {
487
+ resource.domains = uniqueVersions(domain.domains);
488
+ }
486
489
  return await writeResource(directory, resource, { ...options, type: "domain" });
487
490
  };
488
491
  var versionDomain = (directory) => async (id) => versionResource(directory, id);
@@ -526,6 +529,21 @@ var addServiceToDomain = (directory) => async (id, service, version) => {
526
529
  await rmDomainById(directory)(id, version, true);
527
530
  await writeDomain(directory)(domain, { format: extension === ".md" ? "md" : "mdx" });
528
531
  };
532
+ var addSubDomainToDomain = (directory) => async (id, subDomain, version) => {
533
+ let domain = await getDomain(directory)(id, version);
534
+ const domainPath = await getResourcePath(directory, id, version);
535
+ const extension = path.extname(domainPath?.fullPath || "");
536
+ if (domain.domains === void 0) {
537
+ domain.domains = [];
538
+ }
539
+ const subDomainExistsInList = domain.domains.some((s) => s.id === subDomain.id && s.version === subDomain.version);
540
+ if (subDomainExistsInList) {
541
+ return;
542
+ }
543
+ domain.domains.push(subDomain);
544
+ await rmDomainById(directory)(id, version, true);
545
+ await writeDomain(directory)(domain, { format: extension === ".md" ? "md" : "mdx" });
546
+ };
529
547
 
530
548
  // src/channels.ts
531
549
  import fs7 from "node:fs/promises";
@@ -1354,6 +1372,14 @@ var index_default = (path4) => {
1354
1372
  * @returns
1355
1373
  */
1356
1374
  addServiceToDomain: addServiceToDomain(join13(path4, "domains")),
1375
+ /**
1376
+ * Adds a given subdomain to a domain
1377
+ * @param id - The id of the domain
1378
+ * @param subDomain - The id and version of the subdomain to add
1379
+ * @param version - (Optional) The version of the domain to add the subdomain to
1380
+ * @returns
1381
+ */
1382
+ addSubDomainToDomain: addSubDomainToDomain(join13(path4, "domains")),
1357
1383
  /**
1358
1384
  * ================================
1359
1385
  * Teams