@elevasis/ui 2.67.0 → 2.68.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.
Files changed (98) hide show
  1. package/dist/api/index.d.ts +1 -1
  2. package/dist/api/index.js +3 -3
  3. package/dist/app/index.d.ts +1 -6
  4. package/dist/app/index.js +15 -12
  5. package/dist/auth/index.js +10 -12
  6. package/dist/charts/index.js +10 -12
  7. package/dist/chunk-2MTP3H3A.js +425 -0
  8. package/dist/chunk-3KMDHCAR.js +52 -0
  9. package/dist/chunk-3MEXPLWT.js +265 -0
  10. package/dist/{chunk-XNW3O6QW.js → chunk-5NRJ2BLQ.js} +1 -1
  11. package/dist/chunk-75NOC536.js +2162 -0
  12. package/dist/chunk-76IVMVI3.js +1764 -0
  13. package/dist/chunk-AH52XQB7.js +1 -0
  14. package/dist/chunk-BZZCNLT6.js +12 -0
  15. package/dist/chunk-DLR4SDZW.js +51 -0
  16. package/dist/chunk-FK3K2VK2.js +2103 -0
  17. package/dist/chunk-GBXTRSAU.js +37 -0
  18. package/dist/chunk-HJVPVS57.js +1934 -0
  19. package/dist/{chunk-M535KHLW.js → chunk-JC5W55J3.js} +1 -1
  20. package/dist/{chunk-I7BZVVVU.js → chunk-L3HFJFYF.js} +89 -382
  21. package/dist/chunk-LGKLC5MG.js +44 -0
  22. package/dist/{chunk-4DV4ECMG.js → chunk-N7U24M2J.js} +4 -0
  23. package/dist/chunk-NDHMZT2G.js +383 -0
  24. package/dist/chunk-OOACTYRA.js +10 -0
  25. package/dist/chunk-PDHTXPSF.js +12 -0
  26. package/dist/chunk-QYI5BZKM.js +85 -0
  27. package/dist/{chunk-4OEVLV66.js → chunk-R6NMRXNO.js} +112 -147
  28. package/dist/chunk-SIVUCZXQ.js +1194 -0
  29. package/dist/{chunk-JFBZ6XDW.js → chunk-SNZDFCOQ.js} +3 -49
  30. package/dist/chunk-TGPJNKDU.js +1595 -0
  31. package/dist/chunk-TUMSNGTX.js +35 -0
  32. package/dist/chunk-TYKAKJGW.js +67 -0
  33. package/dist/chunk-UD657ICS.js +589 -0
  34. package/dist/chunk-WPIASV3H.js +194 -0
  35. package/dist/chunk-ZFISGKYW.js +39 -0
  36. package/dist/chunk-ZGCWTWBD.js +16127 -0
  37. package/dist/chunk-ZNKZMK2E.js +4528 -0
  38. package/dist/chunk-ZWS3TCQR.js +11032 -0
  39. package/dist/components/chat/index.js +2 -1
  40. package/dist/components/index.d.ts +23 -11
  41. package/dist/components/index.js +2773 -14
  42. package/dist/components/navigation/index.js +11 -12
  43. package/dist/features/auth/index.d.ts +0 -4
  44. package/dist/features/auth/index.js +12 -13
  45. package/dist/features/clients/index.js +14 -12
  46. package/dist/features/crm/index.d.ts +1371 -15
  47. package/dist/features/crm/index.js +15 -12
  48. package/dist/features/dashboard/index.d.ts +1 -2
  49. package/dist/features/dashboard/index.js +15 -12
  50. package/dist/features/delivery/index.d.ts +0 -4
  51. package/dist/features/delivery/index.js +15 -12
  52. package/dist/features/knowledge/index.js +10 -12
  53. package/dist/features/lead-gen/index.d.ts +35 -15
  54. package/dist/features/lead-gen/index.js +16 -12
  55. package/dist/features/monitoring/index.js +15 -12
  56. package/dist/features/monitoring/requests/index.js +13 -13
  57. package/dist/features/operations/index.d.ts +1 -2
  58. package/dist/features/operations/index.js +21 -12
  59. package/dist/features/public-agent-chat/index.js +2 -1
  60. package/dist/features/seo/index.js +2 -1
  61. package/dist/features/settings/index.d.ts +0 -4
  62. package/dist/features/settings/index.js +14 -12
  63. package/dist/hooks/access/index.js +10 -12
  64. package/dist/hooks/delivery/index.d.ts +0 -4
  65. package/dist/hooks/delivery/index.js +2 -23
  66. package/dist/hooks/index.d.ts +13 -7
  67. package/dist/hooks/index.js +10 -12
  68. package/dist/hooks/operations/command-view/utils/transformCommandViewData.d.ts +1 -2
  69. package/dist/hooks/published.d.ts +13 -7
  70. package/dist/hooks/published.js +10 -12
  71. package/dist/initialization/index.d.ts +1 -5
  72. package/dist/knowledge/index.d.ts +1 -2
  73. package/dist/knowledge/index.js +15 -13
  74. package/dist/layout/index.js +14 -12
  75. package/dist/organization/index.d.ts +3 -3
  76. package/dist/organization/index.js +1 -21
  77. package/dist/profile/index.d.ts +0 -4
  78. package/dist/provider/index.d.ts +2 -7
  79. package/dist/provider/index.js +10 -12
  80. package/dist/provider/published.d.ts +2 -7
  81. package/dist/provider/published.js +10 -12
  82. package/dist/supabase/index.d.ts +0 -8
  83. package/dist/test-utils/index.d.ts +5 -0
  84. package/dist/test-utils/index.js +5 -5
  85. package/dist/test-utils/setup-integration.js +1 -1
  86. package/dist/test-utils/setup.js +1 -1
  87. package/dist/theme/index.js +2 -1
  88. package/dist/typeform/index.js +2049 -1
  89. package/dist/types/index.d.ts +13 -7
  90. package/dist/utils/index.d.ts +1 -2
  91. package/dist/utils/index.js +1 -1
  92. package/package.json +4 -4
  93. package/dist/chunk-5TERYXOO.js +0 -51390
  94. package/dist/chunk-AUDNF2Q7.js +0 -2050
  95. package/dist/index.css +0 -659
  96. package/dist/index.d.ts +0 -17888
  97. package/dist/index.js +0 -30
  98. package/dist/{chunk-GMXGDO3I.js → chunk-MISHPEJX.js} +1 -1
@@ -1,4 +1,4 @@
1
- import { GC_TIME_LONG, STALE_TIME_DEFAULT } from './chunk-I7BZVVVU.js';
1
+ import { GC_TIME_LONG, STALE_TIME_DEFAULT } from './chunk-L3HFJFYF.js';
2
2
  import { QueryClient } from '@tanstack/react-query';
3
3
 
4
4
  function createElevasisQueryClient(options = {}) {
@@ -273,14 +273,6 @@ DisplayMetadataSchema.extend({
273
273
  });
274
274
 
275
275
  // ../core/src/organization-model/helpers.ts
276
- function defineDomainRecord(schema, entries) {
277
- return Object.fromEntries(
278
- entries.map((entry) => {
279
- const parsed = schema.parse(entry);
280
- return [parsed.id, parsed];
281
- })
282
- );
283
- }
284
276
  function childSystemsOf(system) {
285
277
  return system.systems ?? system.subsystems ?? {};
286
278
  }
@@ -360,8 +352,8 @@ function getSystemAncestors(model, path) {
360
352
  function listAllSystems(model) {
361
353
  const results = [];
362
354
  function walk(map, prefix) {
363
- for (const [localId2, system] of Object.entries(map)) {
364
- const fullPath = prefix ? `${prefix}.${localId2}` : localId2;
355
+ for (const [localId, system] of Object.entries(map)) {
356
+ const fullPath = prefix ? `${prefix}.${localId}` : localId;
365
357
  results.push({ path: fullPath, system });
366
358
  const childSystems = childSystemsOf(system);
367
359
  if (Object.keys(childSystems).length > 0) {
@@ -420,9 +412,6 @@ var EntitySchema = z.object({
420
412
  var EntitiesDomainSchema = z.record(z.string(), EntitySchema).refine((record) => Object.entries(record).every(([key, entry]) => entry.id === key), {
421
413
  message: "Each entity entry id must match its map key"
422
414
  }).default({});
423
- function defineEntities(entries) {
424
- return defineDomainRecord(EntitySchema, entries);
425
- }
426
415
 
427
416
  // ../core/src/organization-model/domains/actions.ts
428
417
  var ActionResourceIdSchema = z.string().trim().min(1).max(255).regex(/^[A-Za-z0-9]+(?:[-._][A-Za-z0-9]+)*$/, "Resource IDs must use letters, numbers, -, _, or . separators");
@@ -482,9 +471,6 @@ var ActionsDomainSchema = z.record(z.string(), ActionSchema).refine((record) =>
482
471
  message: "Each action entry id must match its map key"
483
472
  }).default({});
484
473
  var DEFAULT_ORGANIZATION_MODEL_ACTIONS = {};
485
- function defineActions(entries) {
486
- return defineDomainRecord(ActionSchema, entries);
487
- }
488
474
  var OntologyKindSchema = z.enum([
489
475
  "object",
490
476
  "link",
@@ -885,17 +871,23 @@ var SystemInterfaceResourceScopeSchema = z.array(ModelIdSchema).default([]);
885
871
  var SystemApiInterfaceReadinessContractSchema = z.object({
886
872
  /** Ontology IDs of object types the interface depends on. */
887
873
  requiredObjects: z.array(z.string().trim().min(1)).default([]),
888
- /** Ontology IDs of catalog types the interface requires (must be non-empty). */
889
- requiredCatalogs: z.array(z.string().trim().min(1)).default([]),
890
- /** Optional ontology kind filters (reserved for future profile extensions). */
891
- requiredKinds: z.array(z.string().trim().min(1)).optional()
874
+ /**
875
+ * Ontology IDs of catalog types the interface requires. Must declare at least one
876
+ * entry a `readinessContract` with no `requiredCatalogs` asserts nothing at all,
877
+ * so it has no `.default([])`; omitting the field is rejected the same as an
878
+ * explicit empty array.
879
+ */
880
+ requiredCatalogs: z.array(z.string().trim().min(1)).min(1)
892
881
  }).strict();
893
882
  var SystemApiInterfaceSchema = z.object({
894
883
  lifecycle: SystemInterfaceLifecycleSchema.default("active"),
895
884
  /**
896
885
  * Open-string profile id. Built-in platform presets are looked up through
897
886
  * the profile registry; custom ids are validated structurally via
898
- * `readinessContract`. Optional `profileForInterface` provides a default.
887
+ * `readinessContract`. Optional at the schema layer, but readiness
888
+ * computation rejects an interface that omits it with a
889
+ * `missing-readiness-profile` diagnostic — there is no positional
890
+ * fallback to `${systemPath}.${interfaceKey}`.
899
891
  */
900
892
  readinessProfile: SystemInterfaceReadinessProfileSchema.optional(),
901
893
  /**
@@ -916,9 +908,6 @@ var _profileRegistry = new Map(
916
908
  { profileId, kind: "built-in" }
917
909
  ])
918
910
  );
919
- function profileForInterface(systemPath, interfaceKey, readinessProfile) {
920
- return readinessProfile ?? `${systemPath}.${interfaceKey}`;
921
- }
922
911
  function isBuiltInReadinessProfile(profileId) {
923
912
  return _profileRegistry.get(profileId)?.kind === "built-in";
924
913
  }
@@ -1016,217 +1005,26 @@ var SystemsDomainSchema = z.record(z.string(), SystemEntrySchema).refine((record
1016
1005
  }).default({});
1017
1006
  var DEFAULT_ORGANIZATION_MODEL_SYSTEMS = {};
1018
1007
 
1019
- // ../core/src/organization-model/migration-helpers.ts
1020
- function catalogRecords(model) {
1021
- return Object.values(compileOrganizationOntology(model).ontology.catalogTypes);
1022
- }
1023
- function localId(id) {
1024
- return parseOntologyId(id).localId;
1025
- }
1026
- function systemScope(id, fallback) {
1027
- return parseOntologyId(id).scope || fallback || "";
1028
- }
1029
- function entriesOf(catalog) {
1030
- return Object.entries(catalog.entries ?? {}).map(([id, value]) => [
1031
- id,
1032
- value && typeof value === "object" && !Array.isArray(value) ? value : {}
1033
- ]);
1034
- }
1035
- function stringValue(value) {
1036
- return typeof value === "string" ? value : void 0;
1037
- }
1038
- function stringArray(value) {
1039
- return Array.isArray(value) ? value.filter((item) => typeof item === "string") : [];
1040
- }
1041
- function numberValue(value, fallback = 0) {
1042
- return typeof value === "number" ? value : fallback;
1043
- }
1044
- function stageFromEntry(entryId, entry) {
1045
- return {
1046
- id: entryId,
1047
- label: stringValue(entry.label) ?? entryId,
1048
- order: numberValue(entry.order),
1049
- semanticClass: stringValue(entry.semanticClass) ?? "open",
1050
- surfaceIds: stringArray(entry.surfaceIds),
1051
- resourceIds: stringArray(entry.resourceIds),
1052
- color: stringValue(entry.color)
1053
- };
1054
- }
1055
- function appliesToLocalId(catalog) {
1056
- const appliesTo = catalog.appliesTo;
1057
- if (appliesTo === void 0) return void 0;
1058
- return parseOntologyId(appliesTo).localId;
1008
+ // ../core/src/organization-model/readiness/profile-registry.ts
1009
+ var _builtInProfileValidators = /* @__PURE__ */ new Map();
1010
+ function registerBuiltInReadinessProfile(profileId, registration) {
1011
+ _builtInProfileValidators.set(profileId, registration);
1059
1012
  }
1060
- function appliesToEntityKind(catalog) {
1061
- const id = appliesToLocalId(catalog);
1062
- if (id === "company" || id === "contact" || id === "project" || id === "milestone" || id === "task") return id;
1063
- if (id === "deal") return void 0;
1064
- return void 0;
1013
+ function getBuiltInReadinessProfile(profileId) {
1014
+ return _builtInProfileValidators.get(profileId);
1065
1015
  }
1066
- function getAllPipelines(model) {
1067
- return catalogRecords(model).filter((catalog) => catalog.kind === "pipeline").map((catalog) => {
1068
- const pipeline = {
1069
- id: localId(catalog.id),
1070
- label: catalog.label ?? localId(catalog.id),
1071
- ...catalog.description ? { description: catalog.description } : {},
1072
- entityId: appliesToLocalId(catalog) ?? "",
1073
- stages: entriesOf(catalog).map(([entryId, entry]) => stageFromEntry(entryId, entry)).sort((a, b) => a.order - b.order || a.id.localeCompare(b.id))
1074
- };
1075
- return { systemPath: catalog.ownerSystemId ?? systemScope(catalog.id), pipeline };
1076
- }).sort((a, b) => a.systemPath.localeCompare(b.systemPath) || a.pipeline.id.localeCompare(b.pipeline.id));
1016
+ var _interfaceMarkerResolvers = /* @__PURE__ */ new Map();
1017
+ function interfaceMarkerKey(systemPath, interfaceKey) {
1018
+ return `${systemPath}::${interfaceKey}`;
1077
1019
  }
1078
- function getAllBuildTemplates(model) {
1079
- const catalogs = catalogRecords(model);
1080
- const stepCatalogs = new Map(
1081
- catalogs.filter((catalog) => catalog.kind === "template-step").map((catalog) => [catalog.id, catalog])
1082
- );
1083
- return catalogs.filter((catalog) => catalog.kind === "template").flatMap(
1084
- (catalog) => entriesOf(catalog).map(([templateId, templateEntry]) => {
1085
- const stepCatalogId = stringValue(templateEntry.stepCatalog);
1086
- const stepCatalog = stepCatalogId !== void 0 ? stepCatalogs.get(stepCatalogId) : void 0;
1087
- const steps = stepCatalog === void 0 ? [] : entriesOf(stepCatalog).sort(
1088
- ([leftId, left], [rightId, right]) => numberValue(left.order, Number.MAX_SAFE_INTEGER) - numberValue(right.order, Number.MAX_SAFE_INTEGER) || leftId.localeCompare(rightId)
1089
- );
1090
- return {
1091
- order: numberValue(templateEntry.order, Number.MAX_SAFE_INTEGER),
1092
- template: {
1093
- id: templateId,
1094
- label: stringValue(templateEntry.label) ?? templateId,
1095
- ...stringValue(templateEntry.description) ? { description: stringValue(templateEntry.description) } : {},
1096
- ...stringValue(templateEntry.color) ? { color: stringValue(templateEntry.color) } : {},
1097
- steps: steps.map(([stepId, step]) => ({
1098
- id: stepId,
1099
- label: stringValue(step.label) ?? stepId,
1100
- ...stringValue(step.description) ? { description: stringValue(step.description) } : {},
1101
- ...step
1102
- }))
1103
- }
1104
- };
1105
- })
1106
- ).sort((a, b) => a.order - b.order || a.template.id.localeCompare(b.template.id)).map(({ template }) => template);
1107
- }
1108
- function getAllProspectingStages(model, kind) {
1109
- return catalogRecords(model).filter((catalog) => catalog.kind === "stage" && appliesToEntityKind(catalog) === kind).flatMap(
1110
- (catalog) => entriesOf(catalog).map(([entryId, entry]) => ({
1111
- id: entryId,
1112
- label: stringValue(entry.label) ?? entryId,
1113
- order: numberValue(entry.order),
1114
- ...stringValue(entry.color) ? { color: stringValue(entry.color) } : {},
1115
- ...stringValue(entry.description) ? { description: stringValue(entry.description) } : {}
1116
- }))
1117
- ).sort((a, b) => a.order - b.order || a.id.localeCompare(b.id));
1118
- }
1119
- function getLeadGenStageCatalog(model) {
1120
- const results = {};
1121
- for (const catalog of catalogRecords(model).filter(
1122
- (record) => record.kind === "stage" && (record.ownerSystemId ?? systemScope(record.id)) === "sales.lead-gen"
1123
- )) {
1124
- const catalogEntity = appliesToEntityKind(catalog);
1125
- if (catalogEntity !== "company" && catalogEntity !== "contact") continue;
1126
- for (const [entryId, entry] of entriesOf(catalog)) {
1127
- const entity = entry.entity === "contact" ? "contact" : entry.entity === "company" ? "company" : catalogEntity;
1128
- const additionalEntities = stringArray(entry.additionalEntities).filter(
1129
- (item) => item === "company" || item === "contact"
1130
- );
1131
- const recordEntity = entry.recordEntity === "company" || entry.recordEntity === "contact" ? entry.recordEntity : void 0;
1132
- const recordStageKey = stringValue(entry.recordStageKey);
1133
- const readinessTarget = entry.readinessTarget === true ? true : void 0;
1134
- results[entryId] = {
1135
- key: entryId,
1136
- label: stringValue(entry.label) ?? entryId,
1137
- description: stringValue(entry.description) ?? "",
1138
- order: numberValue(entry.order),
1139
- entity,
1140
- ...additionalEntities.length > 0 ? { additionalEntities } : {},
1141
- ...recordEntity ? { recordEntity } : {},
1142
- ...recordStageKey ? { recordStageKey } : {},
1143
- ...readinessTarget ? { readinessTarget } : {}
1144
- };
1145
- }
1146
- }
1147
- return Object.fromEntries(
1148
- Object.entries(results).sort(([, a], [, b]) => a.order - b.order || a.key.localeCompare(b.key))
1149
- );
1020
+ function registerReadinessInterfaceMarker(systemPath, interfaceKey, resolver) {
1021
+ _interfaceMarkerResolvers.set(interfaceMarkerKey(systemPath, interfaceKey), resolver);
1150
1022
  }
1151
- function getAllProjectStatuses(model, appliesTo) {
1152
- return catalogRecords(model).filter((catalog) => catalog.kind === "status-flow" && appliesToEntityKind(catalog) === appliesTo).flatMap(
1153
- (catalog) => entriesOf(catalog).map(([entryId, entry]) => ({
1154
- id: entryId,
1155
- label: stringValue(entry.label) ?? entryId,
1156
- order: numberValue(entry.order),
1157
- ...stringValue(entry.color) ? { color: stringValue(entry.color) } : {},
1158
- ...stringValue(entry.description) ? { description: stringValue(entry.description) } : {}
1159
- }))
1160
- ).sort((a, b) => a.order - b.order || a.id.localeCompare(b.id));
1023
+ function resolveReadinessInterfaceMarker(model, systemPath, interfaceKey) {
1024
+ return _interfaceMarkerResolvers.get(interfaceMarkerKey(systemPath, interfaceKey))?.(model);
1161
1025
  }
1162
1026
 
1163
- // ../core/src/business/acquisition/ontology-validation.ts
1164
- var LEAD_GEN_API_INTERFACE = SYSTEM_INTERFACE_PROFILES[0];
1165
- var CRM_API_INTERFACE = SYSTEM_INTERFACE_PROFILES[1];
1166
- var LEAD_GEN_CRM_HANDOFF_INTERFACE = SYSTEM_INTERFACE_PROFILES[2];
1167
- LEAD_GEN_API_INTERFACE.readinessProfile;
1168
- CRM_API_INTERFACE.readinessProfile;
1169
- LEAD_GEN_CRM_HANDOFF_INTERFACE.readinessProfile;
1170
- var LEAD_GEN_LIST_OBJECT_ONTOLOGY_ID = formatOntologyId({
1171
- scope: "sales.lead-gen",
1172
- kind: "object",
1173
- localId: "list"
1174
- });
1175
- var LEAD_GEN_COMPANY_OBJECT_ONTOLOGY_ID = formatOntologyId({
1176
- scope: "sales.lead-gen",
1177
- kind: "object",
1178
- localId: "company"
1179
- });
1180
- var LEAD_GEN_CONTACT_OBJECT_ONTOLOGY_ID = formatOntologyId({
1181
- scope: "sales.lead-gen",
1182
- kind: "object",
1183
- localId: "contact"
1184
- });
1185
- var LEAD_GEN_BUILD_TEMPLATE_CATALOG_ONTOLOGY_ID = formatOntologyId({
1186
- scope: "sales.lead-gen",
1187
- kind: "catalog",
1188
- localId: "build-template"
1189
- });
1190
- var LEAD_GEN_COMPANY_STAGE_CATALOG_ONTOLOGY_ID = formatOntologyId({
1191
- scope: "sales.lead-gen",
1192
- kind: "catalog",
1193
- localId: "company-stage"
1194
- });
1195
- var LEAD_GEN_CONTACT_STAGE_CATALOG_ONTOLOGY_ID = formatOntologyId({
1196
- scope: "sales.lead-gen",
1197
- kind: "catalog",
1198
- localId: "contact-stage"
1199
- });
1200
- var CRM_PIPELINE_CATALOG_ONTOLOGY_ID = formatOntologyId({
1201
- scope: "sales.crm",
1202
- kind: "catalog",
1203
- localId: "crm.pipeline"
1204
- });
1205
- var LEAD_GEN_STAGE_CATALOG_ONTOLOGY_ID = formatOntologyId({
1206
- scope: "sales.lead-gen",
1207
- kind: "catalog",
1208
- localId: "lead-gen.stage-catalog"
1209
- });
1210
- function createLeadGenStageCatalog(model) {
1211
- return {
1212
- id: LEAD_GEN_STAGE_CATALOG_ONTOLOGY_ID,
1213
- label: "Lead Gen Processing Stages",
1214
- ownerSystemId: "sales.lead-gen",
1215
- kind: "processing-stage-catalog",
1216
- entries: Object.fromEntries(
1217
- Object.entries(getLeadGenStageCatalog(model)).map(([key, entry]) => [
1218
- key,
1219
- {
1220
- ...entry
1221
- }
1222
- ])
1223
- ),
1224
- legacyCatalogKey: "LEAD_GEN_STAGE_CATALOG"
1225
- };
1226
- }
1227
- function isPlainRecord(value) {
1228
- return Boolean(value) && typeof value === "object" && !Array.isArray(value);
1229
- }
1027
+ // ../core/src/organization-model/readiness/engine.ts
1230
1028
  function addReadinessIssue(issues, family, code, message, details = {}) {
1231
1029
  issues.push({
1232
1030
  family,
@@ -1239,16 +1037,26 @@ function formatInterfaceIdentity(systemPath, interfaceKey) {
1239
1037
  return `${systemPath}/${interfaceKey}`;
1240
1038
  }
1241
1039
  function readinessMarkerPath(context) {
1242
- return context.interfaceKey === "api" ? `systems.${context.systemPath}.apiInterface` : `systems.${context.systemPath}.derivedCrmHandoffReadiness`;
1040
+ return context.interfaceKey === "api" ? `systems.${context.systemPath}.apiInterface` : void 0;
1041
+ }
1042
+ function readinessMarkerFieldPath(context, suffix) {
1043
+ const base = readinessMarkerPath(context);
1044
+ return base === void 0 ? void 0 : `${base}${suffix}`;
1243
1045
  }
1244
1046
  function formatSupportedReadinessProfiles() {
1245
1047
  return SYSTEM_INTERFACE_PROFILES.map((p) => `"${p.readinessProfile}"`).join(", ");
1246
1048
  }
1049
+ function isPlainRecord(value) {
1050
+ return Boolean(value) && typeof value === "object" && !Array.isArray(value);
1051
+ }
1052
+ function getCatalogEntries(catalog) {
1053
+ return isPlainRecord(catalog.entries) ? catalog.entries : {};
1054
+ }
1247
1055
  function getActiveScopedResources(model, resourceIds, issues, context) {
1248
1056
  const resources = [];
1249
1057
  for (const [index, resourceId] of resourceIds.entries()) {
1250
1058
  const resource = model.resources?.[resourceId];
1251
- const path = `${readinessMarkerPath(context)}.resourceIds.${index}`;
1059
+ const path = readinessMarkerFieldPath(context, `.resourceIds.${index}`);
1252
1060
  if (resource === void 0) {
1253
1061
  addReadinessIssue(
1254
1062
  issues,
@@ -1293,7 +1101,7 @@ function requireScopedBinding(issues, boundIds, bindingKey, ontologyId, context)
1293
1101
  "SYSTEM_INTERFACE_NOT_READY",
1294
1102
  "missing-resource-binding",
1295
1103
  `System Interface "${formatInterfaceIdentity(context.systemPath, context.interfaceKey)}" has no active scoped resource with ontology.${bindingKey} binding "${ontologyId}".`,
1296
- { path: `${readinessMarkerPath(context)}.resourceIds`, ref: ontologyId }
1104
+ { path: readinessMarkerFieldPath(context, ".resourceIds"), ref: ontologyId }
1297
1105
  );
1298
1106
  }
1299
1107
  function ontologyOwnerMatches(ontologyId, expectedSystemPath, catalog) {
@@ -1355,129 +1163,40 @@ function requireCatalogReadiness(issues, index, catalogId, context) {
1355
1163
  }
1356
1164
  return catalog;
1357
1165
  }
1358
- function requireLeadGenInterfaceReadiness(issues, index, resources, context) {
1166
+ function requireContractReadiness(issues, index, resources, contract, context) {
1359
1167
  const reads = resourceBindingIds(resources, "reads");
1360
1168
  const catalogs = resourceBindingIds(resources, "usesCatalogs");
1361
- for (const objectId of [
1362
- LEAD_GEN_LIST_OBJECT_ONTOLOGY_ID,
1363
- LEAD_GEN_COMPANY_OBJECT_ONTOLOGY_ID,
1364
- LEAD_GEN_CONTACT_OBJECT_ONTOLOGY_ID
1365
- ]) {
1169
+ for (const objectId of contract.requiredObjects) {
1366
1170
  requireObjectReadiness(issues, index, objectId, context);
1367
1171
  requireScopedBinding(issues, reads, "reads", objectId, context);
1368
1172
  }
1369
- for (const catalogId of [
1370
- LEAD_GEN_BUILD_TEMPLATE_CATALOG_ONTOLOGY_ID,
1371
- LEAD_GEN_COMPANY_STAGE_CATALOG_ONTOLOGY_ID,
1372
- LEAD_GEN_CONTACT_STAGE_CATALOG_ONTOLOGY_ID
1373
- ]) {
1173
+ for (const catalogId of contract.requiredCatalogs) {
1374
1174
  requireCatalogReadiness(issues, index, catalogId, context);
1375
1175
  requireScopedBinding(issues, catalogs, "usesCatalogs", catalogId, context);
1376
1176
  }
1377
- const templateStepCatalog = findLeadGenTemplateStepCatalog(index);
1378
- if (templateStepCatalog === void 0) {
1379
- addReadinessIssue(
1380
- issues,
1381
- "SYSTEM_INTERFACE_NOT_READY",
1382
- "missing-template-step-catalog",
1383
- `System Interface "${formatInterfaceIdentity(context.systemPath, context.interfaceKey)}" is missing a lead-gen template-step catalog.`
1384
- );
1385
- } else {
1386
- requireCatalogReadiness(issues, index, templateStepCatalog.id, context);
1387
- requireScopedBinding(issues, catalogs, "usesCatalogs", templateStepCatalog.id, context);
1388
- }
1389
- const leadGenStageCatalog = requireCatalogReadiness(issues, index, LEAD_GEN_STAGE_CATALOG_ONTOLOGY_ID, context);
1390
- return leadGenStageCatalog;
1391
- }
1392
- function requireCrmInterfaceReadiness(issues, index, resources, context) {
1393
- const catalogs = resourceBindingIds(resources, "usesCatalogs");
1394
- const crmPipelineCatalog = requireCatalogReadiness(issues, index, CRM_PIPELINE_CATALOG_ONTOLOGY_ID, context);
1395
- requireScopedBinding(issues, catalogs, "usesCatalogs", CRM_PIPELINE_CATALOG_ONTOLOGY_ID, context);
1396
- return crmPipelineCatalog;
1397
- }
1398
- function findSystemInterfaceGrant(model, consumer, provider) {
1399
- return Object.values(model.topology?.relationships ?? {}).find((relationship) => {
1400
- const grant = relationship.metadata?.["systemInterfaceGrant"];
1401
- if (!isPlainRecord(grant) || !isPlainRecord(grant.consumer) || !isPlainRecord(grant.provider)) return false;
1402
- return grant.consumer.systemPath === consumer.systemPath && grant.consumer.interfaceKey === consumer.interfaceKey && grant.provider.systemPath === provider.systemPath && grant.provider.interfaceKey === provider.interfaceKey;
1403
- });
1404
- }
1405
- function requireHandoffBridgeReadiness(issues, model, context) {
1406
- const crmResult = computeInterfaceReadiness(model, CRM_API_INTERFACE);
1407
- if (!crmResult.ready) {
1408
- for (const issue of crmResult.issues) {
1409
- addReadinessIssue(
1410
- issues,
1411
- "SYSTEM_BRIDGE_NOT_READY",
1412
- issue.code,
1413
- `Provider interface ${formatInterfaceIdentity(CRM_API_INTERFACE.systemPath, CRM_API_INTERFACE.interfaceKey)} is not ready: ${issue.message}`,
1414
- { path: issue.path, ref: issue.ref }
1415
- );
1416
- }
1417
- }
1418
- const bridgeGrant = findSystemInterfaceGrant(model, context, CRM_API_INTERFACE);
1419
- if (bridgeGrant === void 0) {
1420
- addReadinessIssue(
1421
- issues,
1422
- "SYSTEM_BRIDGE_NOT_READY",
1423
- "missing-topology-grant",
1424
- `System Interface "${formatInterfaceIdentity(context.systemPath, context.interfaceKey)}" requires a scoped topology grant to "${formatInterfaceIdentity(CRM_API_INTERFACE.systemPath, CRM_API_INTERFACE.interfaceKey)}".`
1425
- );
1426
- }
1427
- return bridgeGrant;
1428
- }
1429
- function getLeadGenCrmHandoffResourceIds(model) {
1430
- return Object.values(model.resources ?? {}).filter(
1431
- (resource) => resource.systemPath === LEAD_GEN_CRM_HANDOFF_INTERFACE.systemPath && resource.ontology?.usesCatalogs?.includes(CRM_PIPELINE_CATALOG_ONTOLOGY_ID) === true
1432
- ).map((resource) => resource.id);
1433
1177
  }
1434
1178
  function getSystemInterfaceReadinessMarker(model, request) {
1435
1179
  const system = getSystem(model, request.systemPath);
1436
1180
  if (system === void 0) return void 0;
1437
- if (request.systemPath === LEAD_GEN_CRM_HANDOFF_INTERFACE.systemPath && request.interfaceKey === LEAD_GEN_CRM_HANDOFF_INTERFACE.interfaceKey) {
1438
- return {
1439
- lifecycle: "active",
1440
- readinessProfile: LEAD_GEN_CRM_HANDOFF_INTERFACE.readinessProfile,
1441
- resourceIds: getLeadGenCrmHandoffResourceIds(model)
1442
- };
1443
- }
1181
+ const registeredMarker = resolveReadinessInterfaceMarker(model, request.systemPath, request.interfaceKey);
1182
+ if (registeredMarker !== void 0) return registeredMarker;
1444
1183
  if (request.interfaceKey === "api" && system.apiInterface !== void 0) {
1445
1184
  return system.apiInterface;
1446
1185
  }
1447
1186
  return void 0;
1448
1187
  }
1449
- function mergeLeadGenDerivedCatalogs(model) {
1450
- const baseCatalogTypes = model.ontology?.catalogTypes ?? {};
1451
- const derivedCatalogTypes = {};
1452
- if (baseCatalogTypes[LEAD_GEN_STAGE_CATALOG_ONTOLOGY_ID] === void 0) {
1453
- derivedCatalogTypes[LEAD_GEN_STAGE_CATALOG_ONTOLOGY_ID] = createLeadGenStageCatalog(model);
1454
- }
1455
- if (Object.keys(derivedCatalogTypes).length === 0) return model;
1456
- return {
1457
- ...model,
1458
- ontology: {
1459
- ...model.ontology ?? {},
1460
- catalogTypes: {
1461
- ...baseCatalogTypes,
1462
- ...derivedCatalogTypes
1463
- }
1464
- }
1465
- };
1466
- }
1467
- function compileBusinessOntology(model, contractId) {
1468
- const compilation = compileOrganizationOntology(mergeLeadGenDerivedCatalogs(model));
1188
+ function compileReadinessOntology(model, readinessProfile, prepareModel) {
1189
+ const preparedModel = prepareModel !== void 0 ? prepareModel(model) : model;
1190
+ const compilation = compileOrganizationOntology(preparedModel);
1469
1191
  if (compilation.diagnostics.length > 0) {
1470
1192
  const summary = compilation.diagnostics.map((diagnostic) => diagnostic.message).join("; ");
1471
- throw new Error(`${contractId} ontology validation index failed to compile: ${summary}`);
1193
+ throw new Error(`${readinessProfile} ontology validation index failed to compile: ${summary}`);
1472
1194
  }
1473
- return {
1474
- ontology: compilation.ontology,
1475
- actionTypesByLegacyId: indexActionTypesByLegacyId(compilation.ontology.actionTypes)
1476
- };
1195
+ return { ontology: compilation.ontology };
1477
1196
  }
1478
- function tryCompileBusinessOntology(model, readinessProfile, issues) {
1197
+ function tryCompileReadinessOntology(model, readinessProfile, prepareModel, issues) {
1479
1198
  try {
1480
- return compileBusinessOntology(model, readinessProfile);
1199
+ return compileReadinessOntology(model, readinessProfile, prepareModel);
1481
1200
  } catch (error) {
1482
1201
  addReadinessIssue(
1483
1202
  issues,
@@ -1488,23 +1207,11 @@ function tryCompileBusinessOntology(model, readinessProfile, issues) {
1488
1207
  return void 0;
1489
1208
  }
1490
1209
  }
1491
- function requireContractReadiness(issues, index, resources, contract, context) {
1492
- const reads = resourceBindingIds(resources, "reads");
1493
- const catalogs = resourceBindingIds(resources, "usesCatalogs");
1494
- for (const objectId of contract.requiredObjects) {
1495
- requireObjectReadiness(issues, index, objectId, context);
1496
- requireScopedBinding(issues, reads, "reads", objectId, context);
1497
- }
1498
- for (const catalogId of contract.requiredCatalogs) {
1499
- requireCatalogReadiness(issues, index, catalogId, context);
1500
- requireScopedBinding(issues, catalogs, "usesCatalogs", catalogId, context);
1501
- }
1502
- }
1503
1210
  function computeInterfaceReadiness(model, request) {
1504
1211
  const issues = [];
1505
1212
  const system = getSystem(model, request.systemPath);
1506
1213
  const systemInterface = getSystemInterfaceReadinessMarker(model, request);
1507
- const readinessProfile = systemInterface === void 0 ? void 0 : profileForInterface(request.systemPath, request.interfaceKey, systemInterface.readinessProfile);
1214
+ const readinessProfile = systemInterface?.readinessProfile;
1508
1215
  const scopedResourceIds = systemInterface?.resourceIds ?? [];
1509
1216
  if (system === void 0) {
1510
1217
  addReadinessIssue(
@@ -1544,25 +1251,48 @@ function computeInterfaceReadiness(model, request) {
1544
1251
  "SYSTEM_INTERFACE_DISABLED",
1545
1252
  "inactive-interface",
1546
1253
  `System Interface "${formatInterfaceIdentity(request.systemPath, request.interfaceKey)}" lifecycle is "${systemInterface.lifecycle}".`,
1547
- { path: `${readinessMarkerPath(request)}.lifecycle` }
1254
+ { path: readinessMarkerFieldPath(request, ".lifecycle") }
1548
1255
  );
1256
+ return {
1257
+ ready: false,
1258
+ systemPath: request.systemPath,
1259
+ interfaceKey: request.interfaceKey,
1260
+ readinessProfile,
1261
+ scopedResourceIds,
1262
+ issues
1263
+ };
1549
1264
  }
1550
- const checkedReadinessProfile = readinessProfile ?? profileForInterface(request.systemPath, request.interfaceKey);
1551
- const isBuiltIn = isBuiltInReadinessProfile(checkedReadinessProfile);
1265
+ if (readinessProfile === void 0) {
1266
+ addReadinessIssue(
1267
+ issues,
1268
+ "SYSTEM_INTERFACE_INVALID",
1269
+ "missing-readiness-profile",
1270
+ `System Interface "${formatInterfaceIdentity(request.systemPath, request.interfaceKey)}" declares an apiInterface but no readinessProfile. Declare a built-in profile (${formatSupportedReadinessProfiles()}) or a custom id paired with a readinessContract.`,
1271
+ { path: readinessMarkerFieldPath(request, ".readinessProfile") }
1272
+ );
1273
+ return {
1274
+ ready: false,
1275
+ systemPath: request.systemPath,
1276
+ interfaceKey: request.interfaceKey,
1277
+ scopedResourceIds,
1278
+ issues
1279
+ };
1280
+ }
1281
+ const isBuiltIn = isBuiltInReadinessProfile(readinessProfile);
1552
1282
  const readinessContract = systemInterface.readinessContract;
1553
1283
  if (!isBuiltIn && readinessContract === void 0) {
1554
1284
  addReadinessIssue(
1555
1285
  issues,
1556
1286
  "SYSTEM_INTERFACE_INVALID",
1557
1287
  "missing-readiness-contract",
1558
- `System Interface "${formatInterfaceIdentity(request.systemPath, request.interfaceKey)}" uses custom readiness profile "${checkedReadinessProfile}" but declares no readinessContract. Built-in profiles: ${formatSupportedReadinessProfiles()}.`,
1559
- { path: `${readinessMarkerPath(request)}.readinessContract`, ref: checkedReadinessProfile }
1288
+ `System Interface "${formatInterfaceIdentity(request.systemPath, request.interfaceKey)}" uses custom readiness profile "${readinessProfile}" but declares no readinessContract. Built-in profiles: ${formatSupportedReadinessProfiles()}.`,
1289
+ { path: readinessMarkerFieldPath(request, ".readinessContract"), ref: readinessProfile }
1560
1290
  );
1561
1291
  return {
1562
1292
  ready: false,
1563
1293
  systemPath: request.systemPath,
1564
1294
  interfaceKey: request.interfaceKey,
1565
- readinessProfile: checkedReadinessProfile,
1295
+ readinessProfile,
1566
1296
  scopedResourceIds,
1567
1297
  issues
1568
1298
  };
@@ -1573,20 +1303,15 @@ function computeInterfaceReadiness(model, request) {
1573
1303
  "SYSTEM_INTERFACE_NOT_READY",
1574
1304
  "missing-scoped-resources",
1575
1305
  `System Interface "${formatInterfaceIdentity(request.systemPath, request.interfaceKey)}" must scope at least one active resource.`,
1576
- { path: `${readinessMarkerPath(request)}.resourceIds` }
1306
+ { path: readinessMarkerFieldPath(request, ".resourceIds") }
1577
1307
  );
1578
1308
  }
1579
1309
  const resources = getActiveScopedResources(model, scopedResourceIds, issues, request);
1580
- const index = tryCompileBusinessOntology(model, checkedReadinessProfile, issues);
1310
+ const registration = getBuiltInReadinessProfile(readinessProfile);
1311
+ const index = tryCompileReadinessOntology(model, readinessProfile, registration?.prepareModel, issues);
1581
1312
  if (index !== void 0) {
1582
- if (checkedReadinessProfile === LEAD_GEN_API_INTERFACE.readinessProfile) {
1583
- requireLeadGenInterfaceReadiness(issues, index, resources, request);
1584
- } else if (checkedReadinessProfile === CRM_API_INTERFACE.readinessProfile) {
1585
- requireCrmInterfaceReadiness(issues, index, resources, request);
1586
- } else if (checkedReadinessProfile === LEAD_GEN_CRM_HANDOFF_INTERFACE.readinessProfile) {
1587
- requireLeadGenInterfaceReadiness(issues, index, resources, request);
1588
- requireCrmInterfaceReadiness(issues, index, resources, { ...request, allowForeignOwner: true });
1589
- requireHandoffBridgeReadiness(issues, model, request);
1313
+ if (registration !== void 0) {
1314
+ registration.validate(issues, index, resources, model, request);
1590
1315
  } else if (readinessContract !== void 0) {
1591
1316
  requireContractReadiness(issues, index, resources, readinessContract, request);
1592
1317
  }
@@ -1595,29 +1320,11 @@ function computeInterfaceReadiness(model, request) {
1595
1320
  ready: issues.length === 0,
1596
1321
  systemPath: request.systemPath,
1597
1322
  interfaceKey: request.interfaceKey,
1598
- readinessProfile: checkedReadinessProfile,
1323
+ readinessProfile,
1599
1324
  scopedResourceIds,
1600
1325
  issues
1601
1326
  };
1602
1327
  }
1603
- function findLeadGenTemplateStepCatalog(index) {
1604
- return Object.values(index.ontology.catalogTypes).find(
1605
- (catalog) => catalog.ownerSystemId === "sales.lead-gen" && catalog.kind === "template-step" && catalog.appliesTo === LEAD_GEN_LIST_OBJECT_ONTOLOGY_ID
1606
- );
1607
- }
1608
- function indexActionTypesByLegacyId(actionTypes) {
1609
- const byLegacyId = {};
1610
- for (const actionType of Object.values(actionTypes)) {
1611
- const legacyActionId = actionType["legacyActionId"];
1612
- if (typeof legacyActionId === "string") {
1613
- byLegacyId[legacyActionId] = actionType;
1614
- }
1615
- }
1616
- return byLegacyId;
1617
- }
1618
- function getCatalogEntries(catalog) {
1619
- return isPlainRecord(catalog.entries) ? catalog.entries : {};
1620
- }
1621
1328
 
1622
1329
  // ../core/src/platform/registry/resource-metadata.ts
1623
1330
  var resourceTypeIconNames = {
@@ -1743,4 +1450,4 @@ function setupBrowserMocks() {
1743
1450
  setupResizeObserver();
1744
1451
  }
1745
1452
 
1746
- export { APIClientError, API_URL, ActionInvocationSchema, ActionSchema, ActionsDomainSchema, DEBOUNCE_FILTER, DEBOUNCE_SLIDER, DEFAULT_ONTOLOGY_SCOPE, DEFAULT_ORGANIZATION_MODEL_ACTIONS, DEFAULT_ORGANIZATION_MODEL_SYSTEMS, DescriptionSchema, EntitiesDomainSchema, EntitySchema, GC_TIME_LONG, GC_TIME_MEDIUM, GC_TIME_SHORT, IconNameSchema, JsonValueSchema, LEAD_GEN_API_INTERFACE, LIMIT_ACTIVITY_FEED, LabelSchema, ModelIdSchema, NodeIdStringSchema, OAUTH_FLOW_TIMEOUT, OntologyIdSchema, OntologyScopeSchema, PAGE_SIZE_DEFAULT, PathSchema, STALE_TIME_ADMIN, STALE_TIME_DEFAULT, STALE_TIME_MONITORING, SystemEntrySchema, SystemIdSchema, SystemInterfaceRefSchema, SystemLifecycleSchema, SystemPathSchema, SystemsDomainSchema, ancestorsOf, childrenOf, compileOrganizationOntology, computeInterfaceReadiness, defaultPathFor, defineActions, defineEntities, devOnlyFor, findById, findByPath, formatChartAxisDate, formatDate, formatDateTime, formatErrorMessage, formatRelativeTime, formatTimeAgo, getAllBuildTemplates, getAllPipelines, getAllProjectStatuses, getAllProspectingStages, getErrorInfo, getErrorTitle, getLeadGenStageCatalog, getResourceColor, getResourceIcon, getResourcesForSystem, getSystem, getSystemAncestors, isAPIClientError, listAllSystems, listResolvedOntologyRecords, ontologyGraphNodeId, parentOf, parseOntologyId, requiresAdminFor, resolveSystemConfig, restoreConsole, setupBrowserMocks, suppressKnownWarnings, topLevel, validateEmail };
1453
+ export { APIClientError, API_URL, ActionInvocationSchema, ActionSchema, ActionsDomainSchema, DEBOUNCE_FILTER, DEBOUNCE_SLIDER, DEFAULT_ONTOLOGY_SCOPE, DEFAULT_ORGANIZATION_MODEL_ACTIONS, DEFAULT_ORGANIZATION_MODEL_SYSTEMS, DescriptionSchema, EntitiesDomainSchema, EntitySchema, GC_TIME_LONG, GC_TIME_MEDIUM, GC_TIME_SHORT, IconNameSchema, JsonValueSchema, LIMIT_ACTIVITY_FEED, LabelSchema, ModelIdSchema, NodeIdStringSchema, OAUTH_FLOW_TIMEOUT, OntologyIdSchema, OntologyScopeSchema, PAGE_SIZE_DEFAULT, PathSchema, STALE_TIME_ADMIN, STALE_TIME_DEFAULT, STALE_TIME_MONITORING, SYSTEM_INTERFACE_PROFILES, SystemEntrySchema, SystemIdSchema, SystemInterfaceRefSchema, SystemLifecycleSchema, SystemPathSchema, SystemsDomainSchema, addReadinessIssue, ancestorsOf, childrenOf, compileOrganizationOntology, computeInterfaceReadiness, defaultPathFor, devOnlyFor, findById, findByPath, formatChartAxisDate, formatDate, formatDateTime, formatErrorMessage, formatInterfaceIdentity, formatOntologyId, formatRelativeTime, formatTimeAgo, getErrorInfo, getErrorTitle, getResourceColor, getResourceIcon, getResourcesForSystem, getSystem, getSystemAncestors, isAPIClientError, listAllSystems, listResolvedOntologyRecords, ontologyGraphNodeId, parentOf, parseOntologyId, registerBuiltInReadinessProfile, registerReadinessInterfaceMarker, requireCatalogReadiness, requireContractReadiness, requireScopedBinding, requiresAdminFor, resolveSystemConfig, resourceBindingIds, restoreConsole, setupBrowserMocks, suppressKnownWarnings, topLevel, validateEmail };