@eventcatalog/sdk 2.3.0 → 2.3.2

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.
@@ -487,6 +487,9 @@ var writeDomain = (directory) => async (domain, options = {
487
487
  if (Array.isArray(domain.services)) {
488
488
  resource.services = uniqueVersions(domain.services);
489
489
  }
490
+ if (Array.isArray(domain.domains)) {
491
+ resource.domains = uniqueVersions(domain.domains);
492
+ }
490
493
  return await writeResource(directory, resource, { ...options, type: "domain" });
491
494
  };
492
495
  var versionDomain = (directory) => async (id) => versionResource(directory, id);
@@ -530,6 +533,21 @@ var addServiceToDomain = (directory) => async (id, service, version) => {
530
533
  await rmDomainById(directory)(id, version, true);
531
534
  await writeDomain(directory)(domain, { format: extension === ".md" ? "md" : "mdx" });
532
535
  };
536
+ var addSubDomainToDomain = (directory) => async (id, subDomain, version) => {
537
+ let domain = await getDomain(directory)(id, version);
538
+ const domainPath = await getResourcePath(directory, id, version);
539
+ const extension = path.extname(domainPath?.fullPath || "");
540
+ if (domain.domains === void 0) {
541
+ domain.domains = [];
542
+ }
543
+ const subDomainExistsInList = domain.domains.some((s) => s.id === subDomain.id && s.version === subDomain.version);
544
+ if (subDomainExistsInList) {
545
+ return;
546
+ }
547
+ domain.domains.push(subDomain);
548
+ await rmDomainById(directory)(id, version, true);
549
+ await writeDomain(directory)(domain, { format: extension === ".md" ? "md" : "mdx" });
550
+ };
533
551
 
534
552
  // src/channels.ts
535
553
  import fs7 from "node:fs/promises";
@@ -1271,6 +1289,14 @@ var index_default = (path4) => {
1271
1289
  * @returns
1272
1290
  */
1273
1291
  addServiceToDomain: addServiceToDomain(join12(path4, "domains")),
1292
+ /**
1293
+ * Adds a given subdomain to a domain
1294
+ * @param id - The id of the domain
1295
+ * @param subDomain - The id and version of the subdomain to add
1296
+ * @param version - (Optional) The version of the domain to add the subdomain to
1297
+ * @returns
1298
+ */
1299
+ addSubDomainToDomain: addSubDomainToDomain(join12(path4, "domains")),
1274
1300
  /**
1275
1301
  * ================================
1276
1302
  * Teams