@elevasis/sdk 1.27.0 → 1.28.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.js CHANGED
@@ -344,6 +344,17 @@ function compileOrganizationOntology(model) {
344
344
  function childSystemsOf2(system) {
345
345
  return system.systems ?? system.subsystems ?? {};
346
346
  }
347
+ function getSystem(model, path) {
348
+ const segments = path.split(".");
349
+ let current = model.systems;
350
+ let node;
351
+ for (const seg of segments) {
352
+ node = current[seg];
353
+ if (node === void 0) return void 0;
354
+ current = childSystemsOf2(node);
355
+ }
356
+ return node;
357
+ }
347
358
  function listAllSystems(model) {
348
359
  const results = [];
349
360
  function walk(map, prefix) {
@@ -585,6 +596,26 @@ var SystemUiSchema = z.object({
585
596
  icon: IconNameSchema.optional(),
586
597
  order: z.number().int().optional()
587
598
  });
599
+ var SystemInterfaceKeySchema = ModelIdSchema;
600
+ var SystemInterfaceLifecycleSchema = z.enum(["draft", "active", "disabled", "deprecated", "archived"]).meta({ label: "System interface lifecycle", color: "teal" });
601
+ var SystemInterfaceReadinessProfileSchema = z.string().trim().min(1).max(200).regex(
602
+ /^[a-z0-9][a-z0-9-]*(?:\.[a-z0-9][a-z0-9-]*)*(?:\.[a-z0-9][a-z0-9-]*)?$/,
603
+ 'Readiness profiles must use dotted lowercase identifiers (e.g. "sales.lead-gen.api")'
604
+ );
605
+ var SystemInterfaceResourceScopeSchema = z.array(ModelIdSchema).default([]);
606
+ var SystemApiInterfaceSchema = z.object({
607
+ lifecycle: SystemInterfaceLifecycleSchema.default("active"),
608
+ readinessProfile: SystemInterfaceReadinessProfileSchema.optional(),
609
+ /**
610
+ * Resource ids that participate in this API interface. This scopes readiness
611
+ * derivation without duplicating authored required/provided contract refs.
612
+ */
613
+ resourceIds: SystemInterfaceResourceScopeSchema.optional()
614
+ }).strict();
615
+ var SystemInterfaceRefSchema = z.object({
616
+ systemPath: SystemPathSchema,
617
+ interfaceKey: SystemInterfaceKeySchema
618
+ }).strict();
588
619
  var JsonValueSchema = z.lazy(
589
620
  () => z.union([
590
621
  z.string(),
@@ -623,6 +654,8 @@ var SystemEntrySchema = z.object({
623
654
  policies: z.array(ModelIdSchema.meta({ ref: "policy" })).default([]).optional(),
624
655
  /** Optional goals this system contributes to. */
625
656
  drivesGoals: z.array(ModelIdSchema.meta({ ref: "goal" })).default([]).optional(),
657
+ /** Thin API runtime-boundary marker. Readiness is derived from scoped resources and topology. */
658
+ apiInterface: SystemApiInterfaceSchema.optional(),
626
659
  /** @deprecated Use lifecycle. Accepted for one publish cycle. */
627
660
  status: SystemStatusSchema.optional(),
628
661
  /** @deprecated Use ui.path. Kept for one-cycle Feature compatibility. */
@@ -889,6 +922,15 @@ var OmTopologyMetadataSchema = z.record(z.string().trim().min(1).max(120), JsonV
889
922
  }
890
923
  visit(metadata, []);
891
924
  });
925
+ var OmTopologySystemInterfaceGrantSchema = z.object({
926
+ consumer: SystemInterfaceRefSchema,
927
+ provider: SystemInterfaceRefSchema,
928
+ resourceIds: z.array(ResourceIdSchema).default([]),
929
+ ontologyIds: z.array(OntologyIdSchema).default([])
930
+ }).strict();
931
+ z.object({
932
+ systemInterfaceGrant: OmTopologySystemInterfaceGrantSchema
933
+ }).strict();
892
934
  var OmTopologyRelationshipSchema = z.object({
893
935
  from: OmTopologyNodeRefSchema,
894
936
  kind: OmTopologyRelationshipKindSchema,
@@ -1530,6 +1572,586 @@ function validateModelConfig(config) {
1530
1572
  }
1531
1573
  }
1532
1574
 
1575
+ // ../core/src/business/acquisition/ontology-validation.ts
1576
+ var LEAD_GEN_API_INTERFACE = {
1577
+ systemPath: "sales.lead-gen",
1578
+ interfaceKey: "api",
1579
+ readinessProfile: "sales.lead-gen.api"
1580
+ };
1581
+ var CRM_API_INTERFACE = {
1582
+ systemPath: "sales.crm",
1583
+ interfaceKey: "api",
1584
+ readinessProfile: "sales.crm.api"
1585
+ };
1586
+ var LEAD_GEN_CRM_HANDOFF_INTERFACE = {
1587
+ systemPath: "sales.lead-gen",
1588
+ interfaceKey: "crm-handoff",
1589
+ readinessProfile: "sales.lead-gen.crm-handoff"
1590
+ };
1591
+ var LEAD_GEN_API_READINESS_LABEL = LEAD_GEN_API_INTERFACE.readinessProfile;
1592
+ var CRM_API_READINESS_LABEL = CRM_API_INTERFACE.readinessProfile;
1593
+ var LEAD_GEN_LIST_OBJECT_ONTOLOGY_ID = formatOntologyId({
1594
+ scope: "sales.lead-gen",
1595
+ kind: "object",
1596
+ localId: "list"
1597
+ });
1598
+ var LEAD_GEN_COMPANY_OBJECT_ONTOLOGY_ID = formatOntologyId({
1599
+ scope: "sales.lead-gen",
1600
+ kind: "object",
1601
+ localId: "company"
1602
+ });
1603
+ var LEAD_GEN_CONTACT_OBJECT_ONTOLOGY_ID = formatOntologyId({
1604
+ scope: "sales.lead-gen",
1605
+ kind: "object",
1606
+ localId: "contact"
1607
+ });
1608
+ var LEAD_GEN_BUILD_TEMPLATE_CATALOG_ONTOLOGY_ID = formatOntologyId({
1609
+ scope: "sales.lead-gen",
1610
+ kind: "catalog",
1611
+ localId: "build-template"
1612
+ });
1613
+ var LEAD_GEN_COMPANY_STAGE_CATALOG_ONTOLOGY_ID = formatOntologyId({
1614
+ scope: "sales.lead-gen",
1615
+ kind: "catalog",
1616
+ localId: "company-stage"
1617
+ });
1618
+ var LEAD_GEN_CONTACT_STAGE_CATALOG_ONTOLOGY_ID = formatOntologyId({
1619
+ scope: "sales.lead-gen",
1620
+ kind: "catalog",
1621
+ localId: "contact-stage"
1622
+ });
1623
+ var CRM_PIPELINE_CATALOG_ONTOLOGY_ID = formatOntologyId({
1624
+ scope: "sales.crm",
1625
+ kind: "catalog",
1626
+ localId: "crm.pipeline"
1627
+ });
1628
+ var LEAD_GEN_STAGE_CATALOG_ONTOLOGY_ID = formatOntologyId({
1629
+ scope: "sales.lead-gen",
1630
+ kind: "catalog",
1631
+ localId: "lead-gen.stage-catalog"
1632
+ });
1633
+ var SystemInterfaceReadinessError = class extends Error {
1634
+ code;
1635
+ statusCode = 503;
1636
+ systemPath;
1637
+ interfaceKey;
1638
+ readinessProfile;
1639
+ issues;
1640
+ constructor(result) {
1641
+ const firstIssue = result.issues[0];
1642
+ super(formatInterfaceReadinessFailure(result));
1643
+ this.name = "SystemInterfaceReadinessError";
1644
+ this.code = firstIssue?.family ?? "SYSTEM_INTERFACE_NOT_READY";
1645
+ this.systemPath = result.systemPath;
1646
+ this.interfaceKey = result.interfaceKey;
1647
+ this.readinessProfile = result.readinessProfile;
1648
+ this.issues = result.issues;
1649
+ }
1650
+ };
1651
+ function createLeadGenStageCatalog(model) {
1652
+ return {
1653
+ id: LEAD_GEN_STAGE_CATALOG_ONTOLOGY_ID,
1654
+ label: "Lead Gen Processing Stages",
1655
+ ownerSystemId: "sales.lead-gen",
1656
+ kind: "processing-stage-catalog",
1657
+ entries: Object.fromEntries(
1658
+ Object.entries(getLeadGenStageCatalog(model)).map(([key, entry]) => [
1659
+ key,
1660
+ {
1661
+ ...entry
1662
+ }
1663
+ ])
1664
+ ),
1665
+ legacyCatalogKey: "LEAD_GEN_STAGE_CATALOG"
1666
+ };
1667
+ }
1668
+ function isPlainRecord(value) {
1669
+ return Boolean(value) && typeof value === "object" && !Array.isArray(value);
1670
+ }
1671
+ function addReadinessIssue(issues, family, code, message, details = {}) {
1672
+ issues.push({
1673
+ family,
1674
+ code,
1675
+ message,
1676
+ ...details
1677
+ });
1678
+ }
1679
+ function formatInterfaceIdentity(systemPath, interfaceKey) {
1680
+ return `${systemPath}/${interfaceKey}`;
1681
+ }
1682
+ function profileForInterface(systemPath, interfaceKey, readinessProfile) {
1683
+ return readinessProfile ?? `${systemPath}.${interfaceKey}`;
1684
+ }
1685
+ function readinessMarkerPath(context) {
1686
+ return context.interfaceKey === "api" ? `systems.${context.systemPath}.apiInterface` : `systems.${context.systemPath}.derivedCrmHandoffReadiness`;
1687
+ }
1688
+ function formatInterfaceReadinessFailure(result) {
1689
+ const identity = formatInterfaceIdentity(result.systemPath, result.interfaceKey);
1690
+ const issueSummary = result.issues.map((issue) => `${issue.family}:${issue.code}: ${issue.message}`).join("; ");
1691
+ return `${identity} readiness failed${result.readinessProfile ? ` (${result.readinessProfile})` : ""}: ${issueSummary}`;
1692
+ }
1693
+ function throwIfInterfaceNotReady(result) {
1694
+ if (result.ready) return;
1695
+ throw new SystemInterfaceReadinessError(result);
1696
+ }
1697
+ function getActiveScopedResources(model, resourceIds, issues, context) {
1698
+ const resources = [];
1699
+ for (const [index, resourceId] of resourceIds.entries()) {
1700
+ const resource = model.resources?.[resourceId];
1701
+ const path = `${readinessMarkerPath(context)}.resourceIds.${index}`;
1702
+ if (resource === void 0) {
1703
+ addReadinessIssue(
1704
+ issues,
1705
+ "SYSTEM_INTERFACE_NOT_READY",
1706
+ "missing-resource",
1707
+ `System Interface "${formatInterfaceIdentity(context.systemPath, context.interfaceKey)}" scopes missing resource "${resourceId}".`,
1708
+ { path, ref: resourceId }
1709
+ );
1710
+ continue;
1711
+ }
1712
+ if (resource.systemPath !== context.systemPath) {
1713
+ addReadinessIssue(
1714
+ issues,
1715
+ "SYSTEM_INTERFACE_INVALID",
1716
+ "resource-system-mismatch",
1717
+ `System Interface "${formatInterfaceIdentity(context.systemPath, context.interfaceKey)}" scopes resource "${resourceId}" from system "${resource.systemPath}".`,
1718
+ { path, ref: resourceId }
1719
+ );
1720
+ continue;
1721
+ }
1722
+ if (resource.status !== "active") {
1723
+ addReadinessIssue(
1724
+ issues,
1725
+ "SYSTEM_INTERFACE_NOT_READY",
1726
+ "inactive-resource",
1727
+ `System Interface "${formatInterfaceIdentity(context.systemPath, context.interfaceKey)}" scopes inactive resource "${resourceId}".`,
1728
+ { path, ref: resourceId }
1729
+ );
1730
+ continue;
1731
+ }
1732
+ resources.push(resource);
1733
+ }
1734
+ return resources;
1735
+ }
1736
+ function resourceBindingIds(resources, key) {
1737
+ return new Set(resources.flatMap((resource) => resource.ontology?.[key] ?? []));
1738
+ }
1739
+ function requireScopedBinding(issues, boundIds, bindingKey, ontologyId, context) {
1740
+ if (boundIds.has(ontologyId)) return;
1741
+ addReadinessIssue(
1742
+ issues,
1743
+ "SYSTEM_INTERFACE_NOT_READY",
1744
+ "missing-resource-binding",
1745
+ `System Interface "${formatInterfaceIdentity(context.systemPath, context.interfaceKey)}" has no active scoped resource with ontology.${bindingKey} binding "${ontologyId}".`,
1746
+ { path: `${readinessMarkerPath(context)}.resourceIds`, ref: ontologyId }
1747
+ );
1748
+ }
1749
+ function ontologyOwnerMatches(ontologyId, expectedSystemPath, catalog) {
1750
+ if (catalog?.ownerSystemId !== void 0) return catalog.ownerSystemId === expectedSystemPath;
1751
+ return parseOntologyId(ontologyId).scope === expectedSystemPath;
1752
+ }
1753
+ function requireObjectReadiness(issues, index, objectId, context) {
1754
+ const object = index.ontology.objectTypes[objectId];
1755
+ if (object === void 0) {
1756
+ addReadinessIssue(
1757
+ issues,
1758
+ "SYSTEM_INTERFACE_NOT_READY",
1759
+ "missing-object",
1760
+ `System Interface "${formatInterfaceIdentity(context.systemPath, context.interfaceKey)}" is missing required object type "${objectId}".`,
1761
+ { ref: objectId }
1762
+ );
1763
+ return;
1764
+ }
1765
+ const ownerSystemId = object.ownerSystemId ?? parseOntologyId(objectId).scope;
1766
+ if (ownerSystemId !== context.systemPath) {
1767
+ addReadinessIssue(
1768
+ issues,
1769
+ "SYSTEM_INTERFACE_INVALID",
1770
+ "foreign-object",
1771
+ `System Interface "${formatInterfaceIdentity(context.systemPath, context.interfaceKey)}" requires object "${objectId}" owned by "${ownerSystemId}".`,
1772
+ { ref: objectId }
1773
+ );
1774
+ }
1775
+ }
1776
+ function requireCatalogReadiness(issues, index, catalogId, context) {
1777
+ const catalog = index.ontology.catalogTypes[catalogId];
1778
+ if (catalog === void 0) {
1779
+ addReadinessIssue(
1780
+ issues,
1781
+ "SYSTEM_INTERFACE_NOT_READY",
1782
+ "missing-catalog",
1783
+ `System Interface "${formatInterfaceIdentity(context.systemPath, context.interfaceKey)}" is missing required catalog "${catalogId}".`,
1784
+ { ref: catalogId }
1785
+ );
1786
+ return void 0;
1787
+ }
1788
+ if (context.allowForeignOwner !== true && !ontologyOwnerMatches(catalogId, context.systemPath, catalog)) {
1789
+ addReadinessIssue(
1790
+ issues,
1791
+ "SYSTEM_INTERFACE_INVALID",
1792
+ "foreign-catalog",
1793
+ `System Interface "${formatInterfaceIdentity(context.systemPath, context.interfaceKey)}" requires catalog "${catalogId}" owned by "${catalog.ownerSystemId ?? parseOntologyId(catalogId).scope}".`,
1794
+ { ref: catalogId }
1795
+ );
1796
+ }
1797
+ if (Object.keys(getCatalogEntries(catalog)).length === 0) {
1798
+ addReadinessIssue(
1799
+ issues,
1800
+ "SYSTEM_INTERFACE_NOT_READY",
1801
+ "empty-catalog",
1802
+ `System Interface "${formatInterfaceIdentity(context.systemPath, context.interfaceKey)}" requires catalog entries for "${catalogId}".`,
1803
+ { ref: catalogId }
1804
+ );
1805
+ }
1806
+ return catalog;
1807
+ }
1808
+ function requireLeadGenInterfaceReadiness(issues, index, resources, context) {
1809
+ const reads = resourceBindingIds(resources, "reads");
1810
+ const catalogs = resourceBindingIds(resources, "usesCatalogs");
1811
+ for (const objectId of [
1812
+ LEAD_GEN_LIST_OBJECT_ONTOLOGY_ID,
1813
+ LEAD_GEN_COMPANY_OBJECT_ONTOLOGY_ID,
1814
+ LEAD_GEN_CONTACT_OBJECT_ONTOLOGY_ID
1815
+ ]) {
1816
+ requireObjectReadiness(issues, index, objectId, context);
1817
+ requireScopedBinding(issues, reads, "reads", objectId, context);
1818
+ }
1819
+ for (const catalogId of [
1820
+ LEAD_GEN_BUILD_TEMPLATE_CATALOG_ONTOLOGY_ID,
1821
+ LEAD_GEN_COMPANY_STAGE_CATALOG_ONTOLOGY_ID,
1822
+ LEAD_GEN_CONTACT_STAGE_CATALOG_ONTOLOGY_ID
1823
+ ]) {
1824
+ requireCatalogReadiness(issues, index, catalogId, context);
1825
+ requireScopedBinding(issues, catalogs, "usesCatalogs", catalogId, context);
1826
+ }
1827
+ const templateStepCatalog = findLeadGenTemplateStepCatalog(index);
1828
+ if (templateStepCatalog === void 0) {
1829
+ addReadinessIssue(
1830
+ issues,
1831
+ "SYSTEM_INTERFACE_NOT_READY",
1832
+ "missing-template-step-catalog",
1833
+ `System Interface "${formatInterfaceIdentity(context.systemPath, context.interfaceKey)}" is missing a lead-gen template-step catalog.`
1834
+ );
1835
+ } else {
1836
+ requireCatalogReadiness(issues, index, templateStepCatalog.id, context);
1837
+ requireScopedBinding(issues, catalogs, "usesCatalogs", templateStepCatalog.id, context);
1838
+ }
1839
+ const leadGenStageCatalog = requireCatalogReadiness(issues, index, LEAD_GEN_STAGE_CATALOG_ONTOLOGY_ID, context);
1840
+ return leadGenStageCatalog;
1841
+ }
1842
+ function requireCrmInterfaceReadiness(issues, index, resources, context) {
1843
+ const catalogs = resourceBindingIds(resources, "usesCatalogs");
1844
+ const crmPipelineCatalog = requireCatalogReadiness(issues, index, CRM_PIPELINE_CATALOG_ONTOLOGY_ID, context);
1845
+ requireScopedBinding(issues, catalogs, "usesCatalogs", CRM_PIPELINE_CATALOG_ONTOLOGY_ID, context);
1846
+ return crmPipelineCatalog;
1847
+ }
1848
+ function findSystemInterfaceGrant(model, consumer, provider) {
1849
+ return Object.values(model.topology?.relationships ?? {}).find((relationship) => {
1850
+ const grant = relationship.metadata?.["systemInterfaceGrant"];
1851
+ if (!isPlainRecord(grant) || !isPlainRecord(grant.consumer) || !isPlainRecord(grant.provider)) return false;
1852
+ return grant.consumer.systemPath === consumer.systemPath && grant.consumer.interfaceKey === consumer.interfaceKey && grant.provider.systemPath === provider.systemPath && grant.provider.interfaceKey === provider.interfaceKey;
1853
+ });
1854
+ }
1855
+ function requireHandoffBridgeReadiness(issues, model, context) {
1856
+ const crmResult = computeInterfaceReadiness(model, CRM_API_INTERFACE);
1857
+ if (!crmResult.ready) {
1858
+ for (const issue of crmResult.issues) {
1859
+ addReadinessIssue(
1860
+ issues,
1861
+ "SYSTEM_BRIDGE_NOT_READY",
1862
+ issue.code,
1863
+ `Provider interface ${formatInterfaceIdentity(CRM_API_INTERFACE.systemPath, CRM_API_INTERFACE.interfaceKey)} is not ready: ${issue.message}`,
1864
+ { path: issue.path, ref: issue.ref }
1865
+ );
1866
+ }
1867
+ }
1868
+ const bridgeGrant = findSystemInterfaceGrant(model, context, CRM_API_INTERFACE);
1869
+ if (bridgeGrant === void 0) {
1870
+ addReadinessIssue(
1871
+ issues,
1872
+ "SYSTEM_BRIDGE_NOT_READY",
1873
+ "missing-topology-grant",
1874
+ `System Interface "${formatInterfaceIdentity(context.systemPath, context.interfaceKey)}" requires a scoped topology grant to "${formatInterfaceIdentity(CRM_API_INTERFACE.systemPath, CRM_API_INTERFACE.interfaceKey)}".`
1875
+ );
1876
+ }
1877
+ return bridgeGrant;
1878
+ }
1879
+ function getLeadGenCrmHandoffResourceIds(model) {
1880
+ return Object.values(model.resources ?? {}).filter(
1881
+ (resource) => resource.systemPath === LEAD_GEN_CRM_HANDOFF_INTERFACE.systemPath && resource.ontology?.usesCatalogs?.includes(CRM_PIPELINE_CATALOG_ONTOLOGY_ID) === true
1882
+ ).map((resource) => resource.id);
1883
+ }
1884
+ function getSystemInterfaceReadinessMarker(model, request) {
1885
+ const system = getSystem(model, request.systemPath);
1886
+ if (system === void 0) return void 0;
1887
+ if (request.interfaceKey === LEAD_GEN_API_INTERFACE.interfaceKey) {
1888
+ return system.apiInterface;
1889
+ }
1890
+ if (request.systemPath === LEAD_GEN_CRM_HANDOFF_INTERFACE.systemPath && request.interfaceKey === LEAD_GEN_CRM_HANDOFF_INTERFACE.interfaceKey) {
1891
+ return {
1892
+ lifecycle: "active",
1893
+ readinessProfile: LEAD_GEN_CRM_HANDOFF_INTERFACE.readinessProfile,
1894
+ resourceIds: getLeadGenCrmHandoffResourceIds(model)
1895
+ };
1896
+ }
1897
+ return void 0;
1898
+ }
1899
+ function mergeLeadGenDerivedCatalogs(model) {
1900
+ const baseCatalogTypes = model.ontology?.catalogTypes ?? {};
1901
+ const derivedCatalogTypes = {};
1902
+ if (baseCatalogTypes[LEAD_GEN_STAGE_CATALOG_ONTOLOGY_ID] === void 0) {
1903
+ derivedCatalogTypes[LEAD_GEN_STAGE_CATALOG_ONTOLOGY_ID] = createLeadGenStageCatalog(model);
1904
+ }
1905
+ if (Object.keys(derivedCatalogTypes).length === 0) return model;
1906
+ return {
1907
+ ...model,
1908
+ ontology: {
1909
+ ...model.ontology ?? {},
1910
+ catalogTypes: {
1911
+ ...baseCatalogTypes,
1912
+ ...derivedCatalogTypes
1913
+ }
1914
+ }
1915
+ };
1916
+ }
1917
+ function compileBusinessOntology(model, contractId) {
1918
+ const compilation = compileOrganizationOntology(mergeLeadGenDerivedCatalogs(model));
1919
+ if (compilation.diagnostics.length > 0) {
1920
+ const summary = compilation.diagnostics.map((diagnostic) => diagnostic.message).join("; ");
1921
+ throw new Error(`${contractId} ontology validation index failed to compile: ${summary}`);
1922
+ }
1923
+ return {
1924
+ ontology: compilation.ontology,
1925
+ actionTypesByLegacyId: indexActionTypesByLegacyId(compilation.ontology.actionTypes)
1926
+ };
1927
+ }
1928
+ function tryCompileBusinessOntology(model, readinessProfile, issues) {
1929
+ try {
1930
+ return compileBusinessOntology(model, readinessProfile);
1931
+ } catch (error) {
1932
+ addReadinessIssue(
1933
+ issues,
1934
+ "SYSTEM_INTERFACE_INVALID",
1935
+ "ontology-compile-failed",
1936
+ error instanceof Error ? error.message : String(error)
1937
+ );
1938
+ return void 0;
1939
+ }
1940
+ }
1941
+ function computeInterfaceReadiness(model, request) {
1942
+ const issues = [];
1943
+ const system = getSystem(model, request.systemPath);
1944
+ const systemInterface = getSystemInterfaceReadinessMarker(model, request);
1945
+ const readinessProfile = systemInterface === void 0 ? void 0 : profileForInterface(request.systemPath, request.interfaceKey, systemInterface.readinessProfile);
1946
+ const scopedResourceIds = systemInterface?.resourceIds ?? [];
1947
+ if (system === void 0) {
1948
+ addReadinessIssue(
1949
+ issues,
1950
+ "SYSTEM_INTERFACE_MISSING",
1951
+ "missing-system",
1952
+ `System "${request.systemPath}" is missing.`,
1953
+ { ref: request.systemPath }
1954
+ );
1955
+ return { ready: false, systemPath: request.systemPath, interfaceKey: request.interfaceKey, scopedResourceIds, issues };
1956
+ }
1957
+ if (systemInterface === void 0) {
1958
+ addReadinessIssue(
1959
+ issues,
1960
+ "SYSTEM_INTERFACE_MISSING",
1961
+ "missing-interface",
1962
+ `System "${request.systemPath}" does not declare interface "${request.interfaceKey}".`,
1963
+ { path: readinessMarkerPath(request) }
1964
+ );
1965
+ return { ready: false, systemPath: request.systemPath, interfaceKey: request.interfaceKey, scopedResourceIds, issues };
1966
+ }
1967
+ if (systemInterface.lifecycle !== "active") {
1968
+ addReadinessIssue(
1969
+ issues,
1970
+ "SYSTEM_INTERFACE_DISABLED",
1971
+ "inactive-interface",
1972
+ `System Interface "${formatInterfaceIdentity(request.systemPath, request.interfaceKey)}" lifecycle is "${systemInterface.lifecycle}".`,
1973
+ { path: `${readinessMarkerPath(request)}.lifecycle` }
1974
+ );
1975
+ }
1976
+ const supportedProfiles = [
1977
+ LEAD_GEN_API_INTERFACE.readinessProfile,
1978
+ CRM_API_INTERFACE.readinessProfile,
1979
+ LEAD_GEN_CRM_HANDOFF_INTERFACE.readinessProfile
1980
+ ];
1981
+ const supportedProfile = readinessProfile !== void 0 && supportedProfiles.some((profile) => profile === readinessProfile);
1982
+ if (!supportedProfile) {
1983
+ addReadinessIssue(
1984
+ issues,
1985
+ "SYSTEM_INTERFACE_INVALID",
1986
+ "unknown-readiness-profile",
1987
+ `System Interface "${formatInterfaceIdentity(request.systemPath, request.interfaceKey)}" references unknown readiness profile "${readinessProfile}".`,
1988
+ { path: `${readinessMarkerPath(request)}.readinessProfile`, ref: readinessProfile }
1989
+ );
1990
+ return {
1991
+ ready: false,
1992
+ systemPath: request.systemPath,
1993
+ interfaceKey: request.interfaceKey,
1994
+ readinessProfile,
1995
+ scopedResourceIds,
1996
+ issues
1997
+ };
1998
+ }
1999
+ if (scopedResourceIds.length === 0) {
2000
+ addReadinessIssue(
2001
+ issues,
2002
+ "SYSTEM_INTERFACE_NOT_READY",
2003
+ "missing-scoped-resources",
2004
+ `System Interface "${formatInterfaceIdentity(request.systemPath, request.interfaceKey)}" must scope at least one active resource.`,
2005
+ { path: `${readinessMarkerPath(request)}.resourceIds` }
2006
+ );
2007
+ }
2008
+ const checkedReadinessProfile = readinessProfile;
2009
+ if (checkedReadinessProfile === void 0) {
2010
+ throw new Error("Supported readiness profile unexpectedly resolved to undefined");
2011
+ }
2012
+ const resources = getActiveScopedResources(model, scopedResourceIds, issues, request);
2013
+ const index = tryCompileBusinessOntology(model, checkedReadinessProfile, issues);
2014
+ if (index !== void 0) {
2015
+ if (checkedReadinessProfile === LEAD_GEN_API_INTERFACE.readinessProfile) {
2016
+ requireLeadGenInterfaceReadiness(issues, index, resources, request);
2017
+ } else if (checkedReadinessProfile === CRM_API_INTERFACE.readinessProfile) {
2018
+ requireCrmInterfaceReadiness(issues, index, resources, request);
2019
+ } else if (checkedReadinessProfile === LEAD_GEN_CRM_HANDOFF_INTERFACE.readinessProfile) {
2020
+ requireLeadGenInterfaceReadiness(issues, index, resources, request);
2021
+ requireCrmInterfaceReadiness(issues, index, resources, { ...request, allowForeignOwner: true });
2022
+ requireHandoffBridgeReadiness(issues, model, request);
2023
+ }
2024
+ }
2025
+ return {
2026
+ ready: issues.length === 0,
2027
+ systemPath: request.systemPath,
2028
+ interfaceKey: request.interfaceKey,
2029
+ readinessProfile,
2030
+ scopedResourceIds,
2031
+ issues
2032
+ };
2033
+ }
2034
+ function requireObjectType(index, objectId, contractId) {
2035
+ if (index.ontology.objectTypes[objectId] === void 0) {
2036
+ throw new Error(`${contractId} is missing required object type: ${objectId}`);
2037
+ }
2038
+ }
2039
+ function requireCatalog(index, catalogId, contractId) {
2040
+ const catalog = index.ontology.catalogTypes[catalogId];
2041
+ if (catalog === void 0) {
2042
+ throw new Error(`${contractId} is missing required catalog: ${catalogId}`);
2043
+ }
2044
+ return catalog;
2045
+ }
2046
+ function requireCatalogEntries(catalog, contractId) {
2047
+ if (Object.keys(getCatalogEntries(catalog)).length === 0) {
2048
+ throw new Error(`${contractId} requires catalog entries for ${catalog.id}`);
2049
+ }
2050
+ }
2051
+ function findLeadGenTemplateStepCatalog(index) {
2052
+ return Object.values(index.ontology.catalogTypes).find(
2053
+ (catalog) => catalog.ownerSystemId === "sales.lead-gen" && catalog.kind === "template-step" && catalog.appliesTo === LEAD_GEN_LIST_OBJECT_ONTOLOGY_ID
2054
+ );
2055
+ }
2056
+ function requireLeadGenApiReadiness(index) {
2057
+ requireObjectType(index, LEAD_GEN_LIST_OBJECT_ONTOLOGY_ID, LEAD_GEN_API_READINESS_LABEL);
2058
+ requireObjectType(index, LEAD_GEN_COMPANY_OBJECT_ONTOLOGY_ID, LEAD_GEN_API_READINESS_LABEL);
2059
+ requireObjectType(index, LEAD_GEN_CONTACT_OBJECT_ONTOLOGY_ID, LEAD_GEN_API_READINESS_LABEL);
2060
+ requireCatalogEntries(
2061
+ requireCatalog(index, LEAD_GEN_BUILD_TEMPLATE_CATALOG_ONTOLOGY_ID, LEAD_GEN_API_READINESS_LABEL),
2062
+ LEAD_GEN_API_READINESS_LABEL
2063
+ );
2064
+ requireCatalogEntries(
2065
+ requireCatalog(index, LEAD_GEN_COMPANY_STAGE_CATALOG_ONTOLOGY_ID, LEAD_GEN_API_READINESS_LABEL),
2066
+ LEAD_GEN_API_READINESS_LABEL
2067
+ );
2068
+ requireCatalogEntries(
2069
+ requireCatalog(index, LEAD_GEN_CONTACT_STAGE_CATALOG_ONTOLOGY_ID, LEAD_GEN_API_READINESS_LABEL),
2070
+ LEAD_GEN_API_READINESS_LABEL
2071
+ );
2072
+ const templateStepCatalog = findLeadGenTemplateStepCatalog(index);
2073
+ if (templateStepCatalog === void 0) {
2074
+ throw new Error(`${LEAD_GEN_API_READINESS_LABEL} is missing a lead-gen template-step catalog`);
2075
+ }
2076
+ requireCatalogEntries(templateStepCatalog, LEAD_GEN_API_READINESS_LABEL);
2077
+ const leadGenStageCatalog = requireCatalog(index, LEAD_GEN_STAGE_CATALOG_ONTOLOGY_ID, LEAD_GEN_API_READINESS_LABEL);
2078
+ requireCatalogEntries(leadGenStageCatalog, LEAD_GEN_API_READINESS_LABEL);
2079
+ return leadGenStageCatalog;
2080
+ }
2081
+ function requireCrmApiReadiness(index) {
2082
+ const crmPipelineCatalog = requireCatalog(index, CRM_PIPELINE_CATALOG_ONTOLOGY_ID, CRM_API_READINESS_LABEL);
2083
+ requireCatalogEntries(crmPipelineCatalog, CRM_API_READINESS_LABEL);
2084
+ return crmPipelineCatalog;
2085
+ }
2086
+ function compileBusinessOntologyValidationIndex(model) {
2087
+ throwIfInterfaceNotReady(computeInterfaceReadiness(model, LEAD_GEN_API_INTERFACE));
2088
+ throwIfInterfaceNotReady(computeInterfaceReadiness(model, CRM_API_INTERFACE));
2089
+ const index = compileBusinessOntology(model, "legacy acquisition business ontology");
2090
+ return {
2091
+ ...index,
2092
+ leadGenStageCatalog: requireLeadGenApiReadiness(index),
2093
+ crmPipelineCatalog: requireCrmApiReadiness(index)
2094
+ };
2095
+ }
2096
+ function indexActionTypesByLegacyId(actionTypes) {
2097
+ const byLegacyId = {};
2098
+ for (const actionType of Object.values(actionTypes)) {
2099
+ const legacyActionId = actionType["legacyActionId"];
2100
+ if (typeof legacyActionId === "string") {
2101
+ byLegacyId[legacyActionId] = actionType;
2102
+ }
2103
+ }
2104
+ return byLegacyId;
2105
+ }
2106
+ function getCatalogEntries(catalog) {
2107
+ return isPlainRecord(catalog.entries) ? catalog.entries : {};
2108
+ }
2109
+ function asLeadGenStageEntry(key, value) {
2110
+ const record = isPlainRecord(value) ? value : {};
2111
+ const entity = record.entity === "contact" ? "contact" : "company";
2112
+ const additionalEntities = Array.isArray(record.additionalEntities) ? record.additionalEntities.filter(
2113
+ (item) => item === "company" || item === "contact"
2114
+ ) : void 0;
2115
+ const recordEntity = record.recordEntity === "company" || record.recordEntity === "contact" ? record.recordEntity : void 0;
2116
+ const recordStageKey = typeof record.recordStageKey === "string" ? record.recordStageKey : void 0;
2117
+ return {
2118
+ key: typeof record.key === "string" ? record.key : key,
2119
+ label: typeof record.label === "string" ? record.label : key,
2120
+ description: typeof record.description === "string" ? record.description : "",
2121
+ order: typeof record.order === "number" ? record.order : 0,
2122
+ entity,
2123
+ ...additionalEntities !== void 0 ? { additionalEntities } : {},
2124
+ ...recordEntity !== void 0 ? { recordEntity } : {},
2125
+ ...recordStageKey !== void 0 ? { recordStageKey } : {}
2126
+ };
2127
+ }
2128
+ function createLeadGenStageValidators(index) {
2129
+ const getCatalog = () => Object.fromEntries(
2130
+ Object.entries(getCatalogEntries(index.leadGenStageCatalog)).map(([key, value]) => [
2131
+ key,
2132
+ asLeadGenStageEntry(key, value)
2133
+ ])
2134
+ );
2135
+ const getEntry = (stageKey) => getCatalog()[stageKey];
2136
+ return {
2137
+ getLeadGenStageCatalog: getCatalog,
2138
+ getLeadGenStageEntry: getEntry,
2139
+ isLeadGenStageKey: (stageKey) => getEntry(stageKey) !== void 0,
2140
+ isLeadGenStageValidForEntity: (stageKey, entity) => {
2141
+ const stage = getEntry(stageKey);
2142
+ return stage !== void 0 && (stage.entity === entity || stage.additionalEntities?.includes(entity) === true);
2143
+ },
2144
+ isLeadGenRecordStageValidForEntity: (stageKey, entity) => {
2145
+ const stage = getEntry(stageKey);
2146
+ return stage !== void 0 && (stage.entity === entity || stage.additionalEntities?.includes(entity) === true || stage.recordEntity === entity);
2147
+ },
2148
+ resolveLeadGenRecordStageKey: (stageKey, entity) => {
2149
+ const stage = getEntry(stageKey);
2150
+ return stage?.recordEntity === entity && stage.recordStageKey ? stage.recordStageKey : stageKey;
2151
+ }
2152
+ };
2153
+ }
2154
+
1533
2155
  // ../core/src/platform/registry/validation.ts
1534
2156
  var RegistryValidationError = class extends Error {
1535
2157
  constructor(orgName, resourceId, field, message) {
@@ -1620,7 +2242,7 @@ function ontologyIndexForKind(index, kind) {
1620
2242
  function sameJson(left, right) {
1621
2243
  return JSON.stringify(left ?? null) === JSON.stringify(right ?? null);
1622
2244
  }
1623
- function addOntologyBindingIssues(issues, orgName, resource, ontologyIndex) {
2245
+ function addOntologyBindingIssues(issues, orgName, resource, ontologyIndex, organizationModel) {
1624
2246
  const binding = resource.ontology;
1625
2247
  if (binding === void 0) return;
1626
2248
  const hasOperationalOntologyBinding = binding.primaryAction !== void 0 || (binding.reads?.length ?? 0) > 0 || (binding.writes?.length ?? 0) > 0 || (binding.usesCatalogs?.length ?? 0) > 0 || (binding.emits?.length ?? 0) > 0;
@@ -1663,6 +2285,45 @@ function addOntologyBindingIssues(issues, orgName, resource, ontologyIndex) {
1663
2285
  validateRefs("writes", "object", binding.writes);
1664
2286
  validateRefs("usesCatalogs", "catalog", binding.usesCatalogs);
1665
2287
  validateRefs("emits", "event", binding.emits);
2288
+ addOntologyTopologyGrantIssues(issues, orgName, resource, organizationModel);
2289
+ }
2290
+ function addOntologyTopologyGrantIssues(issues, orgName, resource, organizationModel) {
2291
+ const binding = resource.ontology;
2292
+ if (binding === void 0) return;
2293
+ const refs = [
2294
+ ...binding.actions ?? [],
2295
+ ...binding.primaryAction !== void 0 ? [binding.primaryAction] : [],
2296
+ ...binding.reads ?? [],
2297
+ ...binding.writes ?? [],
2298
+ ...binding.usesCatalogs ?? [],
2299
+ ...binding.emits ?? []
2300
+ ];
2301
+ for (const ontologyId of new Set(refs)) {
2302
+ const parsed = parseOntologyId(ontologyId);
2303
+ if (parsed.isGlobal || parsed.scope === resource.systemPath) continue;
2304
+ if (hasScopedTopologyGrant(organizationModel, resource, parsed.scope, ontologyId)) continue;
2305
+ const missingGrant = `systemInterfaceGrant(${resource.systemPath} -> ${parsed.scope}, resourceIds: ["${resource.id}"], ontologyIds: ["${ontologyId}"])`;
2306
+ addGovernanceIssue(
2307
+ issues,
2308
+ "ontology-topology-grant-missing",
2309
+ orgName,
2310
+ resource.id,
2311
+ `[${orgName}] Resource '${resource.id}' in system '${resource.systemPath}' references ontology '${ontologyId}' from system '${parsed.scope}' without scoped topology grant '${missingGrant}'.`
2312
+ );
2313
+ }
2314
+ }
2315
+ function hasScopedTopologyGrant(organizationModel, resource, targetSystemPath, ontologyId) {
2316
+ return Object.values(organizationModel.topology?.relationships ?? {}).some((relationship) => {
2317
+ if (relationship.kind !== "uses") return false;
2318
+ const grant = relationship.metadata?.["systemInterfaceGrant"];
2319
+ if (!isSystemInterfaceGrantRecord(grant)) return false;
2320
+ return grant.consumer.systemPath === resource.systemPath && grant.provider.systemPath === targetSystemPath && grant.resourceIds.includes(resource.id) && grant.ontologyIds.includes(ontologyId);
2321
+ });
2322
+ }
2323
+ function isSystemInterfaceGrantRecord(value) {
2324
+ if (typeof value !== "object" || value === null) return false;
2325
+ const grant = value;
2326
+ return typeof grant.consumer?.systemPath === "string" && typeof grant.consumer.interfaceKey === "string" && typeof grant.provider?.systemPath === "string" && typeof grant.provider.interfaceKey === "string" && Array.isArray(grant.resourceIds) && grant.resourceIds.every((id) => typeof id === "string") && Array.isArray(grant.ontologyIds) && grant.ontologyIds.every((id) => typeof id === "string");
1666
2327
  }
1667
2328
  function addTopologyIssues(issues, orgName, deployment, organizationModel, systemsById, omResourcesById, ontologyIndex) {
1668
2329
  const relationships = organizationModel.topology?.relationships;
@@ -1777,7 +2438,7 @@ function validateResourceGovernance(orgName, deployment, organizationModel = dep
1777
2438
  `[${orgName}] Resource '${resource.id}' ontology descriptor mismatch between code and OM.`
1778
2439
  );
1779
2440
  }
1780
- addOntologyBindingIssues(issues, orgName, resource, ontologyIndex);
2441
+ addOntologyBindingIssues(issues, orgName, resource, ontologyIndex, organizationModel);
1781
2442
  }
1782
2443
  for (const runtimeResource of runtimeResources) {
1783
2444
  const omResource = omResourcesById.get(runtimeResource.resourceId);
@@ -1827,6 +2488,41 @@ function validateResourceGovernance(orgName, deployment, organizationModel = dep
1827
2488
  issues
1828
2489
  };
1829
2490
  }
2491
+ function addSystemInterfaceIssue(issues, orgName, systemPath, interfaceKey, issue) {
2492
+ issues.push({
2493
+ type: issue.family,
2494
+ orgName,
2495
+ systemPath,
2496
+ interfaceKey,
2497
+ code: issue.code,
2498
+ path: issue.path,
2499
+ ref: issue.ref,
2500
+ message: `[${orgName}] ${issue.family}:${issue.code}: ${issue.message}`
2501
+ });
2502
+ }
2503
+ function validateDeclaredSystemInterfaceReadiness(orgName, organizationModel) {
2504
+ const issues = [];
2505
+ if (organizationModel === void 0) return { valid: true, issues };
2506
+ const model = organizationModel;
2507
+ for (const { path, system } of listAllSystems(model)) {
2508
+ if (system.apiInterface === void 0) continue;
2509
+ const interfaceKey = "api";
2510
+ const result = computeInterfaceReadiness(model, { systemPath: path, interfaceKey });
2511
+ for (const issue of result.issues) {
2512
+ addSystemInterfaceIssue(issues, orgName, path, interfaceKey, issue);
2513
+ }
2514
+ }
2515
+ if (issues.length > 0) {
2516
+ const first = issues[0];
2517
+ throw new RegistryValidationError(
2518
+ first.orgName,
2519
+ `${first.systemPath}/${first.interfaceKey}`,
2520
+ first.path ?? "organizationModel.systems.apiInterface",
2521
+ first.message
2522
+ );
2523
+ }
2524
+ return { valid: true, issues };
2525
+ }
1830
2526
  function validateDeploymentSpec(orgName, resources) {
1831
2527
  const seenIds = /* @__PURE__ */ new Set();
1832
2528
  resources.workflows?.forEach((workflow) => {
@@ -1864,6 +2560,7 @@ function validateDeploymentSpec(orgName, resources) {
1864
2560
  }
1865
2561
  });
1866
2562
  validateResourceGovernance(orgName, resources);
2563
+ validateDeclaredSystemInterfaceReadiness(orgName, resources.organizationModel);
1867
2564
  }
1868
2565
  function validateResourceModelConfig(orgName, resourceId, modelConfig) {
1869
2566
  try {
@@ -6119,132 +6816,6 @@ function deriveActions(deal, actions = []) {
6119
6816
  return actions.filter((a) => a.isAvailableFor(deal)).map(({ key, label, payloadSchema }) => ({ key, label, payloadSchema }));
6120
6817
  }
6121
6818
 
6122
- // ../core/src/business/acquisition/ontology-validation.ts
6123
- var CRM_PIPELINE_CATALOG_ONTOLOGY_ID = formatOntologyId({
6124
- scope: "sales.crm",
6125
- kind: "catalog",
6126
- localId: "crm.pipeline"
6127
- });
6128
- var LEAD_GEN_STAGE_CATALOG_ONTOLOGY_ID = formatOntologyId({
6129
- scope: "sales.lead-gen",
6130
- kind: "catalog",
6131
- localId: "lead-gen.stage-catalog"
6132
- });
6133
- function createLeadGenStageCatalog(model) {
6134
- return {
6135
- id: LEAD_GEN_STAGE_CATALOG_ONTOLOGY_ID,
6136
- label: "Lead Gen Processing Stages",
6137
- ownerSystemId: "sales.lead-gen",
6138
- kind: "processing-stage-catalog",
6139
- entries: Object.fromEntries(
6140
- Object.entries(getLeadGenStageCatalog(model)).map(([key, entry]) => [
6141
- key,
6142
- {
6143
- ...entry
6144
- }
6145
- ])
6146
- ),
6147
- legacyCatalogKey: "LEAD_GEN_STAGE_CATALOG"
6148
- };
6149
- }
6150
- function isPlainRecord(value) {
6151
- return Boolean(value) && typeof value === "object" && !Array.isArray(value);
6152
- }
6153
- function mergeBridgeCatalogs(model) {
6154
- const baseCatalogTypes = model.ontology?.catalogTypes ?? {};
6155
- const bridgeCatalogTypes = {};
6156
- if (baseCatalogTypes[LEAD_GEN_STAGE_CATALOG_ONTOLOGY_ID] === void 0) {
6157
- bridgeCatalogTypes[LEAD_GEN_STAGE_CATALOG_ONTOLOGY_ID] = createLeadGenStageCatalog(model);
6158
- }
6159
- if (Object.keys(bridgeCatalogTypes).length === 0) return model;
6160
- return {
6161
- ...model,
6162
- ontology: {
6163
- ...model.ontology ?? {},
6164
- catalogTypes: {
6165
- ...baseCatalogTypes,
6166
- ...bridgeCatalogTypes
6167
- }
6168
- }
6169
- };
6170
- }
6171
- function compileBusinessOntologyValidationIndex(model) {
6172
- const compilation = compileOrganizationOntology(mergeBridgeCatalogs(model));
6173
- if (compilation.diagnostics.length > 0) {
6174
- const summary = compilation.diagnostics.map((diagnostic) => diagnostic.message).join("; ");
6175
- throw new Error(`Business ontology validation index failed to compile: ${summary}`);
6176
- }
6177
- const crmPipelineCatalog = compilation.ontology.catalogTypes[CRM_PIPELINE_CATALOG_ONTOLOGY_ID];
6178
- const leadGenStageCatalog = compilation.ontology.catalogTypes[LEAD_GEN_STAGE_CATALOG_ONTOLOGY_ID];
6179
- if (crmPipelineCatalog === void 0 || leadGenStageCatalog === void 0) {
6180
- throw new Error("Business ontology validation index is missing CRM or lead-gen catalog bridge records");
6181
- }
6182
- return {
6183
- ontology: compilation.ontology,
6184
- crmPipelineCatalog,
6185
- leadGenStageCatalog,
6186
- actionTypesByLegacyId: indexActionTypesByLegacyId(compilation.ontology.actionTypes)
6187
- };
6188
- }
6189
- function indexActionTypesByLegacyId(actionTypes) {
6190
- const byLegacyId = {};
6191
- for (const actionType of Object.values(actionTypes)) {
6192
- const legacyActionId = actionType["legacyActionId"];
6193
- if (typeof legacyActionId === "string") {
6194
- byLegacyId[legacyActionId] = actionType;
6195
- }
6196
- }
6197
- return byLegacyId;
6198
- }
6199
- function getCatalogEntries(catalog) {
6200
- return isPlainRecord(catalog.entries) ? catalog.entries : {};
6201
- }
6202
- function asLeadGenStageEntry(key, value) {
6203
- const record = isPlainRecord(value) ? value : {};
6204
- const entity = record.entity === "contact" ? "contact" : "company";
6205
- const additionalEntities = Array.isArray(record.additionalEntities) ? record.additionalEntities.filter(
6206
- (item) => item === "company" || item === "contact"
6207
- ) : void 0;
6208
- const recordEntity = record.recordEntity === "company" || record.recordEntity === "contact" ? record.recordEntity : void 0;
6209
- const recordStageKey = typeof record.recordStageKey === "string" ? record.recordStageKey : void 0;
6210
- return {
6211
- key: typeof record.key === "string" ? record.key : key,
6212
- label: typeof record.label === "string" ? record.label : key,
6213
- description: typeof record.description === "string" ? record.description : "",
6214
- order: typeof record.order === "number" ? record.order : 0,
6215
- entity,
6216
- ...additionalEntities !== void 0 ? { additionalEntities } : {},
6217
- ...recordEntity !== void 0 ? { recordEntity } : {},
6218
- ...recordStageKey !== void 0 ? { recordStageKey } : {}
6219
- };
6220
- }
6221
- function createLeadGenStageValidators(index) {
6222
- const getCatalog = () => Object.fromEntries(
6223
- Object.entries(getCatalogEntries(index.leadGenStageCatalog)).map(([key, value]) => [
6224
- key,
6225
- asLeadGenStageEntry(key, value)
6226
- ])
6227
- );
6228
- const getEntry = (stageKey) => getCatalog()[stageKey];
6229
- return {
6230
- getLeadGenStageCatalog: getCatalog,
6231
- getLeadGenStageEntry: getEntry,
6232
- isLeadGenStageKey: (stageKey) => getEntry(stageKey) !== void 0,
6233
- isLeadGenStageValidForEntity: (stageKey, entity) => {
6234
- const stage = getEntry(stageKey);
6235
- return stage !== void 0 && (stage.entity === entity || stage.additionalEntities?.includes(entity) === true);
6236
- },
6237
- isLeadGenRecordStageValidForEntity: (stageKey, entity) => {
6238
- const stage = getEntry(stageKey);
6239
- return stage !== void 0 && (stage.entity === entity || stage.additionalEntities?.includes(entity) === true || stage.recordEntity === entity);
6240
- },
6241
- resolveLeadGenRecordStageKey: (stageKey, entity) => {
6242
- const stage = getEntry(stageKey);
6243
- return stage?.recordEntity === entity && stage.recordStageKey ? stage.recordStageKey : stageKey;
6244
- }
6245
- };
6246
- }
6247
-
6248
6819
  // src/project-deployment-spec.ts
6249
6820
  function toSdkResourceDescriptor(resource, getResourceOntologyBinding) {
6250
6821
  const ontologyBinding = getResourceOntologyBinding?.(resource.id);
@@ -6345,4 +6916,4 @@ function projectDeploymentSpec(options) {
6345
6916
  }
6346
6917
  var ListBuilderStageKeySchema = z.string().min(1);
6347
6918
 
6348
- export { ActivityEventSchema, BuildPlanSnapshotStepSchema, ProspectingBuildTemplateSchema as BuildTemplateSchema, ContractRefResolutionError, CrmStageKeySchema, CrmStateKeySchema, EmailSchema, ExecutionError, ListBuilderStageKeySchema, ProcessingStageStatusSchema, RegistryValidationError, ResourceRegistry, StepType, ToolingError, bindResourceDescriptor, compileBusinessOntologyValidationIndex, concurrentPool, createLeadGenStageValidators, defineContract, defineResource, defineResourceOntology, defineResources, defineStep, defineTopology, defineTopologyRelationship, defineWorkflow, deriveActions, diagnosticOutput, integrationInput, isZodType, parseTopologyNodeRef, projectDeploymentSpec, projectTopologyRelationships, resolveContractRef, runDiagnostic, splitName, toSdkResourceDescriptor, topologyRef, topologyRelationship, validateResourceGovernance, withPlatformIntegrationResourceDescriptor, withPlatformIntegrationResourceDescriptors, withPlatformResourceDescriptor, withPlatformResourceDescriptors };
6919
+ export { ActivityEventSchema, BuildPlanSnapshotStepSchema, ProspectingBuildTemplateSchema as BuildTemplateSchema, ContractRefResolutionError, CrmStageKeySchema, CrmStateKeySchema, EmailSchema, ExecutionError, ListBuilderStageKeySchema, ProcessingStageStatusSchema, RegistryValidationError, ResourceRegistry, StepType, ToolingError, bindResourceDescriptor, compileBusinessOntologyValidationIndex, concurrentPool, createLeadGenStageValidators, defineContract, defineResource, defineResourceOntology, defineResources, defineStep, defineTopology, defineTopologyRelationship, defineWorkflow, deriveActions, diagnosticOutput, integrationInput, isZodType, parseTopologyNodeRef, projectDeploymentSpec, projectTopologyRelationships, resolveContractRef, runDiagnostic, splitName, toSdkResourceDescriptor, topologyRef, topologyRelationship, validateDeclaredSystemInterfaceReadiness, validateResourceGovernance, withPlatformIntegrationResourceDescriptor, withPlatformIntegrationResourceDescriptors, withPlatformResourceDescriptor, withPlatformResourceDescriptors };