@memberjunction/server 6.2.0-edge.6 → 6.2.0-edge.7

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 (407) hide show
  1. package/README.md +69 -0
  2. package/dist/.tsbuildinfo +1 -1
  3. package/dist/agentSessions/BridgeHostInstance.d.ts +8 -3
  4. package/dist/agentSessions/BridgeHostInstance.d.ts.map +1 -1
  5. package/dist/agentSessions/BridgeHostInstance.js +14 -4
  6. package/dist/agentSessions/BridgeHostInstance.js.map +1 -1
  7. package/dist/agentSessions/HandoffOfferExpiry.d.ts +10 -0
  8. package/dist/agentSessions/HandoffOfferExpiry.d.ts.map +1 -0
  9. package/dist/agentSessions/HandoffOfferExpiry.js +18 -0
  10. package/dist/agentSessions/HandoffOfferExpiry.js.map +1 -0
  11. package/dist/agentSessions/ReturningVisitorRecap.js +1 -0
  12. package/dist/agentSessions/ReturningVisitorRecap.js.map +1 -1
  13. package/dist/agentSessions/SessionJanitor.d.ts +31 -8
  14. package/dist/agentSessions/SessionJanitor.d.ts.map +1 -1
  15. package/dist/agentSessions/SessionJanitor.js +85 -41
  16. package/dist/agentSessions/SessionJanitor.js.map +1 -1
  17. package/dist/agentSessions/SessionManager.d.ts +14 -4
  18. package/dist/agentSessions/SessionManager.d.ts.map +1 -1
  19. package/dist/agentSessions/SessionManager.js +28 -4
  20. package/dist/agentSessions/SessionManager.js.map +1 -1
  21. package/dist/agentSessions/conversationBrowsers.d.ts +61 -0
  22. package/dist/agentSessions/conversationBrowsers.d.ts.map +1 -0
  23. package/dist/agentSessions/conversationBrowsers.js +118 -0
  24. package/dist/agentSessions/conversationBrowsers.js.map +1 -0
  25. package/dist/agentSessions/sessionDeadline.d.ts +43 -0
  26. package/dist/agentSessions/sessionDeadline.d.ts.map +1 -0
  27. package/dist/agentSessions/sessionDeadline.js +68 -0
  28. package/dist/agentSessions/sessionDeadline.js.map +1 -0
  29. package/dist/auth/APIKeyScopeAuth.d.ts.map +1 -1
  30. package/dist/auth/APIKeyScopeAuth.js +5 -4
  31. package/dist/auth/APIKeyScopeAuth.js.map +1 -1
  32. package/dist/auth/loginEmailResolution.d.ts +41 -0
  33. package/dist/auth/loginEmailResolution.d.ts.map +1 -0
  34. package/dist/auth/loginEmailResolution.js +47 -0
  35. package/dist/auth/loginEmailResolution.js.map +1 -0
  36. package/dist/auth/magicLink/MagicLinkKeys.d.ts +50 -2
  37. package/dist/auth/magicLink/MagicLinkKeys.d.ts.map +1 -1
  38. package/dist/auth/magicLink/MagicLinkKeys.js +129 -12
  39. package/dist/auth/magicLink/MagicLinkKeys.js.map +1 -1
  40. package/dist/auth/magicLink/MagicLinkRouter.d.ts +3 -0
  41. package/dist/auth/magicLink/MagicLinkRouter.d.ts.map +1 -1
  42. package/dist/auth/magicLink/MagicLinkRouter.js +23 -5
  43. package/dist/auth/magicLink/MagicLinkRouter.js.map +1 -1
  44. package/dist/auth/magicLink/MagicLinkService.d.ts +39 -5
  45. package/dist/auth/magicLink/MagicLinkService.d.ts.map +1 -1
  46. package/dist/auth/magicLink/MagicLinkService.js +221 -9
  47. package/dist/auth/magicLink/MagicLinkService.js.map +1 -1
  48. package/dist/auth/magicLink/index.d.ts +1 -1
  49. package/dist/auth/magicLink/index.d.ts.map +1 -1
  50. package/dist/auth/magicLink/index.js +1 -1
  51. package/dist/auth/magicLink/index.js.map +1 -1
  52. package/dist/auth/magicLink/redeemLanding.d.ts +2 -2
  53. package/dist/auth/magicLink/redeemLanding.d.ts.map +1 -1
  54. package/dist/auth/magicLink/redeemLanding.js +7 -4
  55. package/dist/auth/magicLink/redeemLanding.js.map +1 -1
  56. package/dist/auth/magicLink/types.d.ts +27 -3
  57. package/dist/auth/magicLink/types.d.ts.map +1 -1
  58. package/dist/auth/magicLink/types.js +0 -4
  59. package/dist/auth/magicLink/types.js.map +1 -1
  60. package/dist/auth/newUsers.d.ts.map +1 -1
  61. package/dist/auth/newUsers.js +1 -0
  62. package/dist/auth/newUsers.js.map +1 -1
  63. package/dist/backgroundSweepConfigUnits.d.ts +231 -0
  64. package/dist/backgroundSweepConfigUnits.d.ts.map +1 -0
  65. package/dist/backgroundSweepConfigUnits.js +180 -0
  66. package/dist/backgroundSweepConfigUnits.js.map +1 -0
  67. package/dist/config.d.ts +906 -8
  68. package/dist/config.d.ts.map +1 -1
  69. package/dist/config.js +59 -0
  70. package/dist/config.js.map +1 -1
  71. package/dist/context.d.ts +2 -0
  72. package/dist/context.d.ts.map +1 -1
  73. package/dist/context.js +35 -4
  74. package/dist/context.js.map +1 -1
  75. package/dist/coreRoutes.d.ts +3 -1
  76. package/dist/coreRoutes.d.ts.map +1 -1
  77. package/dist/coreRoutes.js +6 -4
  78. package/dist/coreRoutes.js.map +1 -1
  79. package/dist/generated/graphql-schemas/__mj.d.ts +228 -0
  80. package/dist/generated/graphql-schemas/__mj.d.ts.map +1 -1
  81. package/dist/generated/graphql-schemas/__mj.js +1163 -6
  82. package/dist/generated/graphql-schemas/__mj.js.map +1 -1
  83. package/dist/generic/OrphanedConversationDetailReconciler.d.ts +11 -0
  84. package/dist/generic/OrphanedConversationDetailReconciler.d.ts.map +1 -1
  85. package/dist/generic/OrphanedConversationDetailReconciler.js +27 -1
  86. package/dist/generic/OrphanedConversationDetailReconciler.js.map +1 -1
  87. package/dist/generic/ResolverBase.d.ts +50 -5
  88. package/dist/generic/ResolverBase.d.ts.map +1 -1
  89. package/dist/generic/ResolverBase.js +321 -132
  90. package/dist/generic/ResolverBase.js.map +1 -1
  91. package/dist/generic/RunViewResolver.d.ts +4 -0
  92. package/dist/generic/RunViewResolver.d.ts.map +1 -1
  93. package/dist/generic/RunViewResolver.js +47 -7
  94. package/dist/generic/RunViewResolver.js.map +1 -1
  95. package/dist/index.d.ts +1 -0
  96. package/dist/index.d.ts.map +1 -1
  97. package/dist/index.js +157 -35
  98. package/dist/index.js.map +1 -1
  99. package/dist/integration/ConnectionPause.d.ts +121 -0
  100. package/dist/integration/ConnectionPause.d.ts.map +1 -0
  101. package/dist/integration/ConnectionPause.js +183 -0
  102. package/dist/integration/ConnectionPause.js.map +1 -0
  103. package/dist/integration/CustomColumnPromoter.d.ts +72 -6
  104. package/dist/integration/CustomColumnPromoter.d.ts.map +1 -1
  105. package/dist/integration/CustomColumnPromoter.js +87 -46
  106. package/dist/integration/CustomColumnPromoter.js.map +1 -1
  107. package/dist/integration/EntityMapLifecycle.d.ts +78 -4
  108. package/dist/integration/EntityMapLifecycle.d.ts.map +1 -1
  109. package/dist/integration/EntityMapLifecycle.js +199 -5
  110. package/dist/integration/EntityMapLifecycle.js.map +1 -1
  111. package/dist/integration/InactiveRowWarnings.d.ts +31 -0
  112. package/dist/integration/InactiveRowWarnings.d.ts.map +1 -1
  113. package/dist/integration/InactiveRowWarnings.js +29 -0
  114. package/dist/integration/InactiveRowWarnings.js.map +1 -1
  115. package/dist/integration/ObjectNamesByID.d.ts +28 -0
  116. package/dist/integration/ObjectNamesByID.d.ts.map +1 -0
  117. package/dist/integration/ObjectNamesByID.js +87 -0
  118. package/dist/integration/ObjectNamesByID.js.map +1 -0
  119. package/dist/integration/PostRestartIntrospect.d.ts +26 -0
  120. package/dist/integration/PostRestartIntrospect.d.ts.map +1 -0
  121. package/dist/integration/PostRestartIntrospect.js +27 -0
  122. package/dist/integration/PostRestartIntrospect.js.map +1 -0
  123. package/dist/integration/RSUPostRestartProgress.d.ts +176 -0
  124. package/dist/integration/RSUPostRestartProgress.d.ts.map +1 -0
  125. package/dist/integration/RSUPostRestartProgress.js +323 -0
  126. package/dist/integration/RSUPostRestartProgress.js.map +1 -0
  127. package/dist/integration/RSUProgressBridge.d.ts +41 -2
  128. package/dist/integration/RSUProgressBridge.d.ts.map +1 -1
  129. package/dist/integration/RSUProgressBridge.js +84 -1
  130. package/dist/integration/RSUProgressBridge.js.map +1 -1
  131. package/dist/integration/RunArtifactAuthorization.d.ts +39 -0
  132. package/dist/integration/RunArtifactAuthorization.d.ts.map +1 -0
  133. package/dist/integration/RunArtifactAuthorization.js +45 -0
  134. package/dist/integration/RunArtifactAuthorization.js.map +1 -0
  135. package/dist/integration/SchemaRefreshLaunch.d.ts +9 -0
  136. package/dist/integration/SchemaRefreshLaunch.d.ts.map +1 -1
  137. package/dist/integration/SchemaRefreshLaunch.js +3 -2
  138. package/dist/integration/SchemaRefreshLaunch.js.map +1 -1
  139. package/dist/integration/ScopedFieldsForBuild.d.ts +46 -0
  140. package/dist/integration/ScopedFieldsForBuild.d.ts.map +1 -0
  141. package/dist/integration/ScopedFieldsForBuild.js +91 -0
  142. package/dist/integration/ScopedFieldsForBuild.js.map +1 -0
  143. package/dist/integration/TargetConfigGuard.d.ts +40 -0
  144. package/dist/integration/TargetConfigGuard.d.ts.map +1 -0
  145. package/dist/integration/TargetConfigGuard.js +40 -0
  146. package/dist/integration/TargetConfigGuard.js.map +1 -0
  147. package/dist/realtimeSessions/ownedRealtimeSession.d.ts.map +1 -1
  148. package/dist/realtimeSessions/ownedRealtimeSession.js +2 -3
  149. package/dist/realtimeSessions/ownedRealtimeSession.js.map +1 -1
  150. package/dist/realtimeSessions/sessionAccess.d.ts +15 -0
  151. package/dist/realtimeSessions/sessionAccess.d.ts.map +1 -1
  152. package/dist/realtimeSessions/sessionAccess.js +22 -0
  153. package/dist/realtimeSessions/sessionAccess.js.map +1 -1
  154. package/dist/realtimeWidget/WidgetSessionService.d.ts.map +1 -1
  155. package/dist/realtimeWidget/WidgetSessionService.js +2 -0
  156. package/dist/realtimeWidget/WidgetSessionService.js.map +1 -1
  157. package/dist/realtimeWidget/visitorIdentity.d.ts.map +1 -1
  158. package/dist/realtimeWidget/visitorIdentity.js +1 -0
  159. package/dist/realtimeWidget/visitorIdentity.js.map +1 -1
  160. package/dist/realtimeWidget/widgetCore.d.ts.map +1 -1
  161. package/dist/realtimeWidget/widgetCore.js +4 -7
  162. package/dist/realtimeWidget/widgetCore.js.map +1 -1
  163. package/dist/realtimeWidget/widgetGuestElevation.js +1 -0
  164. package/dist/realtimeWidget/widgetGuestElevation.js.map +1 -1
  165. package/dist/requestOrigin.d.ts +22 -0
  166. package/dist/requestOrigin.d.ts.map +1 -0
  167. package/dist/requestOrigin.js +60 -0
  168. package/dist/requestOrigin.js.map +1 -0
  169. package/dist/resolvers/AgentSessionResolver.d.ts.map +1 -1
  170. package/dist/resolvers/AgentSessionResolver.js +6 -2
  171. package/dist/resolvers/AgentSessionResolver.js.map +1 -1
  172. package/dist/resolvers/AutotagPipelineResolver.d.ts.map +1 -1
  173. package/dist/resolvers/AutotagPipelineResolver.js +2 -1
  174. package/dist/resolvers/AutotagPipelineResolver.js.map +1 -1
  175. package/dist/resolvers/ConversationRunEventsResolver.d.ts.map +1 -1
  176. package/dist/resolvers/ConversationRunEventsResolver.js +2 -0
  177. package/dist/resolvers/ConversationRunEventsResolver.js.map +1 -1
  178. package/dist/resolvers/ExecuteRemoteOperationResolver.d.ts +6 -0
  179. package/dist/resolvers/ExecuteRemoteOperationResolver.d.ts.map +1 -1
  180. package/dist/resolvers/ExecuteRemoteOperationResolver.js +30 -7
  181. package/dist/resolvers/ExecuteRemoteOperationResolver.js.map +1 -1
  182. package/dist/resolvers/GetDataResolver.d.ts.map +1 -1
  183. package/dist/resolvers/GetDataResolver.js +34 -13
  184. package/dist/resolvers/GetDataResolver.js.map +1 -1
  185. package/dist/resolvers/IntegrationDiscoveryResolver.d.ts +401 -11
  186. package/dist/resolvers/IntegrationDiscoveryResolver.d.ts.map +1 -1
  187. package/dist/resolvers/IntegrationDiscoveryResolver.js +2690 -1305
  188. package/dist/resolvers/IntegrationDiscoveryResolver.js.map +1 -1
  189. package/dist/resolvers/MCPResolver.d.ts.map +1 -1
  190. package/dist/resolvers/MCPResolver.js +13 -2
  191. package/dist/resolvers/MCPResolver.js.map +1 -1
  192. package/dist/resolvers/QuerySystemUserResolver.d.ts +36 -0
  193. package/dist/resolvers/QuerySystemUserResolver.d.ts.map +1 -1
  194. package/dist/resolvers/QuerySystemUserResolver.js +174 -87
  195. package/dist/resolvers/QuerySystemUserResolver.js.map +1 -1
  196. package/dist/resolvers/RealtimeBridgeResolver.d.ts.map +1 -1
  197. package/dist/resolvers/RealtimeBridgeResolver.js +1 -0
  198. package/dist/resolvers/RealtimeBridgeResolver.js.map +1 -1
  199. package/dist/resolvers/RealtimeClientSessionResolver.d.ts +6 -0
  200. package/dist/resolvers/RealtimeClientSessionResolver.d.ts.map +1 -1
  201. package/dist/resolvers/RealtimeClientSessionResolver.js +36 -5
  202. package/dist/resolvers/RealtimeClientSessionResolver.js.map +1 -1
  203. package/dist/resolvers/RemoteBrowserActionResolver.d.ts +62 -10
  204. package/dist/resolvers/RemoteBrowserActionResolver.d.ts.map +1 -1
  205. package/dist/resolvers/RemoteBrowserActionResolver.js +217 -34
  206. package/dist/resolvers/RemoteBrowserActionResolver.js.map +1 -1
  207. package/dist/resolvers/RunAIAgentResolver.d.ts +24 -8
  208. package/dist/resolvers/RunAIAgentResolver.d.ts.map +1 -1
  209. package/dist/resolvers/RunAIAgentResolver.js +185 -67
  210. package/dist/resolvers/RunAIAgentResolver.js.map +1 -1
  211. package/dist/resolvers/RunAIPromptResolver.d.ts +5 -3
  212. package/dist/resolvers/RunAIPromptResolver.d.ts.map +1 -1
  213. package/dist/resolvers/RunAIPromptResolver.js +19 -18
  214. package/dist/resolvers/RunAIPromptResolver.js.map +1 -1
  215. package/dist/resolvers/RunTemplateResolver.d.ts.map +1 -1
  216. package/dist/resolvers/RunTemplateResolver.js +3 -1
  217. package/dist/resolvers/RunTemplateResolver.js.map +1 -1
  218. package/dist/resolvers/meetingRecordingRegistration.d.ts.map +1 -1
  219. package/dist/resolvers/meetingRecordingRegistration.js +2 -0
  220. package/dist/resolvers/meetingRecordingRegistration.js.map +1 -1
  221. package/dist/rest/MediaAccessKeys.d.ts.map +1 -1
  222. package/dist/rest/MediaAccessKeys.js +6 -2
  223. package/dist/rest/MediaAccessKeys.js.map +1 -1
  224. package/dist/rest/OAuthCallbackHandler.d.ts.map +1 -1
  225. package/dist/rest/OAuthCallbackHandler.js +11 -5
  226. package/dist/rest/OAuthCallbackHandler.js.map +1 -1
  227. package/dist/rest/RealtimeRecordingHandler.d.ts +3 -3
  228. package/dist/rest/RealtimeRecordingHandler.d.ts.map +1 -1
  229. package/dist/rest/RealtimeRecordingHandler.js +2 -4
  230. package/dist/rest/RealtimeRecordingHandler.js.map +1 -1
  231. package/dist/rest/ViewOperationsHandler.d.ts.map +1 -1
  232. package/dist/rest/ViewOperationsHandler.js +2 -1
  233. package/dist/rest/ViewOperationsHandler.js.map +1 -1
  234. package/dist/rest/setupRESTEndpoints.d.ts +3 -1
  235. package/dist/rest/setupRESTEndpoints.d.ts.map +1 -1
  236. package/dist/rest/setupRESTEndpoints.js +11 -2
  237. package/dist/rest/setupRESTEndpoints.js.map +1 -1
  238. package/dist/services/DurableEntityActionTaskSubmitter.d.ts.map +1 -1
  239. package/dist/services/DurableEntityActionTaskSubmitter.js +6 -1
  240. package/dist/services/DurableEntityActionTaskSubmitter.js.map +1 -1
  241. package/dist/services/TaskGraphActionRunner.d.ts.map +1 -1
  242. package/dist/services/TaskGraphActionRunner.js +2 -26
  243. package/dist/services/TaskGraphActionRunner.js.map +1 -1
  244. package/dist/services/TaskGraphAgentRunner.d.ts +6 -0
  245. package/dist/services/TaskGraphAgentRunner.d.ts.map +1 -1
  246. package/dist/services/TaskGraphAgentRunner.js +38 -0
  247. package/dist/services/TaskGraphAgentRunner.js.map +1 -1
  248. package/dist/services/TaskGraphContinuationDeliverer.d.ts.map +1 -1
  249. package/dist/services/TaskGraphContinuationDeliverer.js +1 -0
  250. package/dist/services/TaskGraphContinuationDeliverer.js.map +1 -1
  251. package/dist/services/WorkQueueHostService.d.ts +2 -1
  252. package/dist/services/WorkQueueHostService.d.ts.map +1 -1
  253. package/dist/services/WorkQueueHostService.js +19 -4
  254. package/dist/services/WorkQueueHostService.js.map +1 -1
  255. package/dist/services/workQueueConfig.d.ts +2 -2
  256. package/dist/services/workQueueConfig.js +5 -5
  257. package/dist/services/workQueueConfig.js.map +1 -1
  258. package/dist/sharedCache.js +1 -1
  259. package/dist/sharedCache.js.map +1 -1
  260. package/dist/types.d.ts +17 -0
  261. package/dist/types.d.ts.map +1 -1
  262. package/dist/types.js.map +1 -1
  263. package/package.json +98 -98
  264. package/src/__tests__/APIKeyScopeAuth.test.ts +4 -8
  265. package/src/__tests__/ActiveOperations.test.ts +68 -0
  266. package/src/__tests__/AgentSessionResolver.ownership.test.ts +13 -0
  267. package/src/__tests__/AssertTargetConfigs.test.ts +75 -0
  268. package/src/__tests__/BatchApplyParity.test.ts +109 -0
  269. package/src/__tests__/BridgeHostInstance.test.ts +42 -0
  270. package/src/__tests__/CollectInactiveRowWarnings.test.ts +115 -0
  271. package/src/__tests__/ConnectionPause.test.ts +192 -0
  272. package/src/__tests__/ConnectionPauseResolver.test.ts +166 -0
  273. package/src/__tests__/ConnectionPauseSave.test.ts +143 -0
  274. package/src/__tests__/CustomColumnPromoterCompletion.test.ts +142 -0
  275. package/src/__tests__/DeleteConnectionRemovesPerConnectionCatalog.test.ts +51 -0
  276. package/src/__tests__/DetachedDiscoveryStart.test.ts +65 -0
  277. package/src/__tests__/DurableEntityActionTaskSubmitter.test.ts +73 -0
  278. package/src/__tests__/EntityMapLifecycle.rekey.test.ts +252 -0
  279. package/src/__tests__/ExecuteRemoteOperationResolver.test.ts +213 -0
  280. package/src/__tests__/HandoffOfferExpiry.test.ts +40 -0
  281. package/src/__tests__/IntegrationRunArtifactAuthorization.test.ts +126 -0
  282. package/src/__tests__/MagicLinkKeys.test.ts +102 -0
  283. package/src/__tests__/MediaAccessKeys.test.ts +57 -10
  284. package/src/__tests__/NewArrivalsDefaultDisabled.test.ts +50 -0
  285. package/src/__tests__/ObjectNamesByID.test.ts +176 -0
  286. package/src/__tests__/PostRestartMapsInCatalogScope.test.ts +146 -0
  287. package/src/__tests__/QuerySystemUserResolver.childRows.test.ts +80 -0
  288. package/src/__tests__/QuerySystemUserResolver.collision.test.ts +200 -0
  289. package/src/__tests__/QuerySystemUserResolver.permissions.test.ts +132 -0
  290. package/src/__tests__/RSUPostRestartProgress.test.ts +343 -0
  291. package/src/__tests__/RSUProgressBridge.test.ts +188 -5
  292. package/src/__tests__/RSUStartupSweepWiring.test.ts +30 -0
  293. package/src/__tests__/ReactivateRefreshMessage.test.ts +10 -3
  294. package/src/__tests__/RealtimeClientSessionResolver.test.ts +22 -0
  295. package/src/__tests__/{RefreshAdoptsNewColumns.test.ts → RefreshReportsNewColumns.test.ts} +25 -16
  296. package/src/__tests__/RemoteBrowserActionRecovery.test.ts +287 -0
  297. package/src/__tests__/RemoteBrowserActionResolver.goalRunLink.test.ts +3 -0
  298. package/src/__tests__/RemoteBrowserActionResolver.ownership.test.ts +6 -4
  299. package/src/__tests__/RemoteBrowserAudioStream.test.ts +3 -0
  300. package/src/__tests__/RemoteBrowserSnapshot.test.ts +3 -0
  301. package/src/__tests__/ResolverBase.clientOldValues.test.ts +323 -26
  302. package/src/__tests__/ResolverBase.encryptedApiZeroReencrypt.test.ts +307 -0
  303. package/src/__tests__/ResolverBase.entityMessageRelay.test.ts +53 -2
  304. package/src/__tests__/ResolverBase.includeBinaryFields.test.ts +60 -0
  305. package/src/__tests__/RunAIAgentResolver.branch.test.ts +4 -0
  306. package/src/__tests__/RunAIAgentResolver.consultPredecessor.test.ts +289 -0
  307. package/src/__tests__/RunAIAgentResolver.handoff.test.ts +649 -0
  308. package/src/__tests__/RunAIAgentResolver.historyFrom.test.ts +2 -0
  309. package/src/__tests__/RunAIAgentResolver.runDataGuard.test.ts +2 -0
  310. package/src/__tests__/RunAIAgentResolver.stoppedPredecessor.test.ts +87 -12
  311. package/src/__tests__/SchemaEvolutionCustomColumns.test.ts +119 -0
  312. package/src/__tests__/SchemaRefreshLaunch.test.ts +24 -2
  313. package/src/__tests__/ScopedFieldsForBuild.test.ts +192 -0
  314. package/src/__tests__/SessionJanitor.test.ts +195 -4
  315. package/src/__tests__/SessionManager.test.ts +69 -0
  316. package/src/__tests__/TaskGraphActionRunner.durablePayload.test.ts +2 -2
  317. package/src/__tests__/TaskGraphAgentRunner.test.ts +272 -16
  318. package/src/__tests__/ViewOperationsHandler.test.ts +2 -5
  319. package/src/__tests__/WorkQueueHostService.test.ts +25 -7
  320. package/src/__tests__/backgroundSweepConfigUnits.test.ts +153 -0
  321. package/src/__tests__/contextRequestOrigin.test.ts +105 -0
  322. package/src/__tests__/conversationBrowsers.test.ts +62 -0
  323. package/src/__tests__/magicLinkExtensionCapabilities.test.ts +413 -0
  324. package/src/__tests__/orphanedConversationDetailReconciler.start.test.ts +82 -0
  325. package/src/__tests__/ownedRealtimeSession.test.ts +14 -0
  326. package/src/__tests__/realtimeRecordingHandler.test.ts +7 -2
  327. package/src/__tests__/realtimeSessions/sessionAccess.test.ts +79 -1
  328. package/src/__tests__/requestOrigin.test.ts +104 -0
  329. package/src/__tests__/securityHardeningPr6034.test.ts +120 -0
  330. package/src/__tests__/sessionDeadline.test.ts +51 -0
  331. package/src/__tests__/sharedCache.test.ts +11 -0
  332. package/src/__tests__/unifiedAuth.test.ts +73 -1
  333. package/src/agentSessions/BridgeHostInstance.ts +20 -5
  334. package/src/agentSessions/HandoffOfferExpiry.ts +18 -0
  335. package/src/agentSessions/ReturningVisitorRecap.ts +1 -0
  336. package/src/agentSessions/SessionJanitor.ts +92 -42
  337. package/src/agentSessions/SessionManager.ts +38 -8
  338. package/src/agentSessions/conversationBrowsers.ts +143 -0
  339. package/src/agentSessions/sessionDeadline.ts +81 -0
  340. package/src/auth/APIKeyScopeAuth.ts +5 -4
  341. package/src/auth/__tests__/loginEmailResolution.test.ts +67 -0
  342. package/src/auth/loginEmailResolution.ts +67 -0
  343. package/src/auth/magicLink/MagicLinkKeys.ts +146 -14
  344. package/src/auth/magicLink/MagicLinkRouter.ts +33 -6
  345. package/src/auth/magicLink/MagicLinkService.ts +250 -10
  346. package/src/auth/magicLink/index.ts +1 -1
  347. package/src/auth/magicLink/redeemLanding.ts +7 -4
  348. package/src/auth/magicLink/types.ts +28 -3
  349. package/src/auth/newUsers.ts +1 -0
  350. package/src/backgroundSweepConfigUnits.ts +213 -0
  351. package/src/config.ts +69 -0
  352. package/src/context.ts +39 -6
  353. package/src/coreRoutes.ts +14 -7
  354. package/src/generated/graphql-schemas/__mj.ts +822 -7
  355. package/src/generic/OrphanedConversationDetailReconciler.ts +32 -1
  356. package/src/generic/ResolverBase.ts +414 -143
  357. package/src/generic/RunViewResolver.ts +96 -49
  358. package/src/index.ts +201 -35
  359. package/src/integration/ConnectionPause.ts +222 -0
  360. package/src/integration/CustomColumnPromoter.ts +123 -53
  361. package/src/integration/EntityMapLifecycle.ts +229 -6
  362. package/src/integration/InactiveRowWarnings.ts +50 -0
  363. package/src/integration/ObjectNamesByID.ts +97 -0
  364. package/src/integration/PostRestartIntrospect.ts +49 -0
  365. package/src/integration/RSUPostRestartProgress.ts +359 -0
  366. package/src/integration/RSUProgressBridge.ts +85 -2
  367. package/src/integration/RunArtifactAuthorization.ts +65 -0
  368. package/src/integration/SchemaRefreshLaunch.ts +12 -2
  369. package/src/integration/ScopedFieldsForBuild.ts +113 -0
  370. package/src/integration/TargetConfigGuard.ts +71 -0
  371. package/src/realtimeSessions/ownedRealtimeSession.ts +2 -6
  372. package/src/realtimeSessions/sessionAccess.ts +30 -0
  373. package/src/realtimeWidget/WidgetSessionService.ts +2 -0
  374. package/src/realtimeWidget/visitorIdentity.ts +1 -0
  375. package/src/realtimeWidget/widgetCore.ts +4 -8
  376. package/src/realtimeWidget/widgetGuestElevation.ts +1 -0
  377. package/src/requestOrigin.ts +64 -0
  378. package/src/resolvers/AgentSessionResolver.ts +6 -2
  379. package/src/resolvers/AutotagPipelineResolver.ts +2 -1
  380. package/src/resolvers/ConversationRunEventsResolver.ts +2 -0
  381. package/src/resolvers/ExecuteRemoteOperationResolver.ts +41 -9
  382. package/src/resolvers/GetDataResolver.ts +35 -13
  383. package/src/resolvers/IntegrationDiscoveryResolver.ts +1522 -203
  384. package/src/resolvers/MCPResolver.ts +15 -2
  385. package/src/resolvers/QuerySystemUserResolver.ts +197 -98
  386. package/src/resolvers/RealtimeBridgeResolver.ts +1 -0
  387. package/src/resolvers/RealtimeClientSessionResolver.ts +40 -7
  388. package/src/resolvers/RemoteBrowserActionResolver.ts +242 -32
  389. package/src/resolvers/RunAIAgentResolver.ts +265 -86
  390. package/src/resolvers/RunAIPromptResolver.ts +18 -18
  391. package/src/resolvers/RunTemplateResolver.ts +3 -1
  392. package/src/resolvers/__tests__/GetDataResolver.tokens.test.ts +52 -0
  393. package/src/resolvers/meetingRecordingRegistration.ts +2 -0
  394. package/src/rest/MediaAccessKeys.ts +6 -2
  395. package/src/rest/OAuthCallbackHandler.ts +13 -5
  396. package/src/rest/RealtimeRecordingHandler.ts +5 -9
  397. package/src/rest/ViewOperationsHandler.ts +2 -1
  398. package/src/rest/setupRESTEndpoints.ts +11 -2
  399. package/src/services/DurableEntityActionTaskSubmitter.ts +10 -2
  400. package/src/services/TaskGraphActionRunner.ts +2 -23
  401. package/src/services/TaskGraphAgentRunner.ts +43 -0
  402. package/src/services/TaskGraphContinuationDeliverer.ts +1 -0
  403. package/src/services/WorkQueueHostService.ts +26 -4
  404. package/src/services/workQueueConfig.ts +5 -5
  405. package/src/sharedCache.ts +1 -1
  406. package/src/types.ts +18 -0
  407. package/src/services/TaskOrchestration-Integration.md +0 -188
@@ -0,0 +1,222 @@
1
+ /**
2
+ * ConnectionPause — what "pause this connection" has to mean, beyond a flag.
3
+ *
4
+ * `IntegrationDeactivateConnection` used to set `IsActive = false` and stop. The engine reads
5
+ * that flag before a sync, so syncs did stop — but nothing else did:
6
+ *
7
+ * - The SCHEDULED jobs kept firing. A sync schedule woke on cron, was refused, and wrote a
8
+ * failed run. Every cron tick, for as long as the connection stayed paused, so a paused
9
+ * connector's history filled with failures it did not cause.
10
+ * - The DISCOVERY schedule kept firing and was NOT refused, because nothing gated discovery
11
+ * on IsActive. A paused connection went on rescanning the vendor on a timer — spending the
12
+ * customer's rate budget, and rewriting the very catalog the pause was meant to freeze.
13
+ * - An IN-FLIGHT sync ran to completion. "Paused" arrived only after the thing the operator
14
+ * was watching had finished.
15
+ *
16
+ * So pause has to touch three things, and resume has to put back exactly what pause took —
17
+ * which is the part that needs state rather than a rule.
18
+ *
19
+ * WHY THE PRIOR STATE IS RECORDED RATHER THAN INFERRED. "Resume = set every schedule Active" is
20
+ * wrong: a connection can legitimately be paused while one of its two schedules was ALREADY off
21
+ * because the operator turned it off weeks ago. Inferring would silently re-enable it, and the
22
+ * first symptom is a sync nobody asked for. So pause records which jobs it actually moved, and
23
+ * resume restores only those.
24
+ *
25
+ * WHY PAUSE IS IDEMPOTENT AT THE RECORD, NOT AT THE WRITE. Deactivating an already-deactivated
26
+ * connection finds every job already Paused, so the set it "moved" is empty. Writing that empty
27
+ * set over the real record is the bug that loses the state — resume would then restore nothing
28
+ * and both schedules would stay off forever, with no error anywhere. {@link DecidePauseWrite}
29
+ * is the guard: the FIRST pause's record stands until a resume consumes it, and a later pause only
30
+ * ever adds to it.
31
+ *
32
+ * Everything here is a pure function over plain values. The resolver owns the reads and writes.
33
+ */
34
+
35
+ import { UUIDSet } from '@memberjunction/global';
36
+
37
+ /** The two schedule kinds a connection can own. Mirrors ScheduledJob's DriverClass split. */
38
+ export type PausedScheduleKind = 'sync' | 'discovery';
39
+
40
+ /** One schedule that PAUSE moved from Active to Paused, and that RESUME should move back. */
41
+ export interface PausedScheduleRecord {
42
+ /** ScheduledJob.ID */
43
+ ID: string;
44
+ /** Recorded for the operator-facing message only; restoration keys on ID. */
45
+ Kind: PausedScheduleKind;
46
+ }
47
+
48
+ /** Minimal shape this module needs from a ScheduledJob row. */
49
+ export interface ScheduleJobState {
50
+ ID: string;
51
+ Status: string | null;
52
+ Kind: PausedScheduleKind;
53
+ }
54
+
55
+ /** Key under CompanyIntegration.Configuration where the record lives. */
56
+ export const PAUSED_SCHEDULES_KEY = 'pausedSchedules';
57
+
58
+ /**
59
+ * Which schedules a pause should move, and the record to remember them by.
60
+ *
61
+ * Only jobs that are currently `Active` are moved. A job already `Paused`, or in any other
62
+ * status, is left exactly as found and is deliberately absent from the record — that absence
63
+ * is what stops resume from turning it on.
64
+ */
65
+ export function DecideSchedulesToPause(jobs: ReadonlyArray<ScheduleJobState>): PausedScheduleRecord[] {
66
+ return jobs
67
+ .filter(j => j.Status === 'Active')
68
+ .map(j => ({ ID: j.ID, Kind: j.Kind }));
69
+ }
70
+
71
+ /**
72
+ * Whether this pause's record should be written, given whatever record is already stored.
73
+ *
74
+ * Returns the record to persist, or `null` to leave the stored one untouched. A second pause of
75
+ * an already-paused connection moves nothing, and must not overwrite the first pause's record
76
+ * with its own empty one — see the class comment.
77
+ *
78
+ * A pause that DOES move jobs while a record is stored adds them to it: the stored entries stay
79
+ * exactly as they were, and the new ones are appended by job ID. That happens when a job was
80
+ * created or switched back on while the connection was paused, or when a resume could not clear
81
+ * its record. A job paused here but left out of the record is one resume can never put back.
82
+ */
83
+ export function DecidePauseWrite(
84
+ stored: ReadonlyArray<PausedScheduleRecord>,
85
+ newlyPaused: ReadonlyArray<PausedScheduleRecord>
86
+ ): PausedScheduleRecord[] | null {
87
+ const known = new UUIDSet(stored.map(r => r.ID));
88
+ const added = newlyPaused.filter(r => !known.Has(r.ID));
89
+ if (added.length === 0) return null; // nothing new moved — any stored record stands as it is
90
+ return [...stored, ...added];
91
+ }
92
+
93
+ /**
94
+ * Which schedules a resume should re-activate.
95
+ *
96
+ * A recorded job is restored only when it STILL EXISTS and is STILL `Paused`. Both guards matter:
97
+ * a job deleted while the connection was paused must not be resurrected, and a job someone has
98
+ * already moved back to Active must not be written again for no reason. Jobs absent from the
99
+ * record are never touched, however they look now.
100
+ */
101
+ export function DecideSchedulesToResume(
102
+ stored: ReadonlyArray<PausedScheduleRecord>,
103
+ jobs: ReadonlyArray<ScheduleJobState>
104
+ ): string[] {
105
+ const live = new Map(jobs.map(j => [j.ID, j]));
106
+ return stored
107
+ .filter(r => live.get(r.ID)?.Status === 'Paused')
108
+ .map(r => r.ID);
109
+ }
110
+
111
+ /** Reads the stored record out of a CompanyIntegration.Configuration JSON blob. */
112
+ export function ReadPausedSchedules(configuration: string | null | undefined): PausedScheduleRecord[] {
113
+ if (!configuration) return [];
114
+ let parsed: unknown;
115
+ try {
116
+ parsed = JSON.parse(configuration);
117
+ } catch {
118
+ // A Configuration we cannot parse is not an error to raise here: pause/resume is not the
119
+ // operation that owns that blob. Report "no record" and let the rest of the flow proceed.
120
+ return [];
121
+ }
122
+ if (typeof parsed !== 'object' || parsed === null) return [];
123
+ const raw = (parsed as Record<string, unknown>)[PAUSED_SCHEDULES_KEY];
124
+ if (!Array.isArray(raw)) return [];
125
+ const out: PausedScheduleRecord[] = [];
126
+ for (const item of raw) {
127
+ if (typeof item !== 'object' || item === null) continue;
128
+ const rec = item as Record<string, unknown>;
129
+ const id = rec.ID;
130
+ const kind = rec.Kind;
131
+ if (typeof id !== 'string' || id.length === 0) continue;
132
+ out.push({ ID: id, Kind: kind === 'discovery' ? 'discovery' : 'sync' });
133
+ }
134
+ return out;
135
+ }
136
+
137
+ /**
138
+ * Returns the Configuration JSON with the record set (or cleared, when `record` is empty).
139
+ *
140
+ * Preserves every other key. An unparseable Configuration is REPLACED rather than merged — the
141
+ * alternative is refusing to pause because of unrelated corruption, and losing one broken blob
142
+ * is the better failure.
143
+ */
144
+ export function WritePausedSchedules(
145
+ configuration: string | null | undefined,
146
+ record: ReadonlyArray<PausedScheduleRecord>
147
+ ): string {
148
+ let base: Record<string, unknown> = {};
149
+ if (configuration) {
150
+ try {
151
+ const parsed = JSON.parse(configuration);
152
+ if (typeof parsed === 'object' && parsed !== null && !Array.isArray(parsed)) {
153
+ base = parsed as Record<string, unknown>;
154
+ }
155
+ } catch {
156
+ base = {};
157
+ }
158
+ }
159
+ if (record.length === 0) {
160
+ delete base[PAUSED_SCHEDULES_KEY];
161
+ } else {
162
+ base[PAUSED_SCHEDULES_KEY] = record.map(r => ({ ID: r.ID, Kind: r.Kind }));
163
+ }
164
+ return JSON.stringify(base);
165
+ }
166
+
167
+ /**
168
+ * How far a cancel request actually reaches — reported to the caller so the UI can say something
169
+ * TRUE rather than something reassuring.
170
+ *
171
+ * `durable` the request is recorded where the owning process will observe it, whichever
172
+ * process that is. "Stopping after the current batch" is honest.
173
+ * `this-process` a sync is running HERE and was signalled in-process. Honest, but only because
174
+ * this happens to be the owner.
175
+ * `unknown` a run is live and we could neither record the request durably nor find it in
176
+ * this process. It will finish. What pause still guarantees is that no NEW sync
177
+ * starts — say that, and do not claim the running one is stopping.
178
+ * `none` nothing was running. There is nothing to say.
179
+ */
180
+ export type CancelScope = 'durable' | 'this-process' | 'unknown' | 'none';
181
+
182
+ /**
183
+ * Classifies the cancel from observable facts, not from which API was called.
184
+ *
185
+ * Deliberately derived rather than hardcoded per lineage: the durable path needs a run-row column
186
+ * that only exists on newer tenants, so the SAME code has to tell the truth on a tenant where
187
+ * that column is absent and the in-process registry is the only signal there is.
188
+ */
189
+ export function DescribeCancelScope(facts: {
190
+ liveRunPresent: boolean;
191
+ durableRequestRecorded: boolean;
192
+ runningInThisProcess: boolean;
193
+ }): CancelScope {
194
+ if (!facts.liveRunPresent) return 'none';
195
+ if (facts.durableRequestRecorded) return 'durable';
196
+ if (facts.runningInThisProcess) return 'this-process';
197
+ return 'unknown';
198
+ }
199
+
200
+ /** Operator-facing sentence for a cancel scope. Never claims a stop it cannot deliver. */
201
+ export function DescribeCancelOutcome(scope: CancelScope): string {
202
+ switch (scope) {
203
+ case 'durable':
204
+ case 'this-process':
205
+ return 'A sync was running — it will stop after the current batch.';
206
+ case 'unknown':
207
+ return 'A sync is running in another process and will finish; no new sync will start.';
208
+ case 'none':
209
+ return '';
210
+ }
211
+ }
212
+
213
+ /** Operator-facing sentence for what pause did to the schedules. */
214
+ export function DescribePauseOutcome(paused: ReadonlyArray<PausedScheduleRecord>, alreadyPaused: boolean): string {
215
+ if (alreadyPaused) return 'Schedules were already paused.';
216
+ if (paused.length === 0) return 'No active schedules to pause.';
217
+ const kinds = paused.map(p => p.Kind);
218
+ const parts: string[] = [];
219
+ if (kinds.includes('sync')) parts.push('data sync');
220
+ if (kinds.includes('discovery')) parts.push('schema refresh');
221
+ return `Paused the ${parts.join(' and ')} schedule${parts.length > 1 ? 's' : ''}.`;
222
+ }
@@ -47,7 +47,11 @@ import {
47
47
  type PromotionCandidate,
48
48
  type CustomKeyStat,
49
49
  type InferredColumnType,
50
+ BuildCatalogWriter,
51
+ WithCatalogScope,
50
52
  } from '@memberjunction/integration-engine';
53
+ import { UUIDsEqual } from '@memberjunction/global';
54
+ import { IntegrationEngineBase } from '@memberjunction/integration-engine-base';
51
55
 
52
56
  /**
53
57
  * A custom-key candidate persisted to CompanyIntegration.Configuration.customKeyCandidates
@@ -179,6 +183,27 @@ async function readAutoPromoteFlag(companyIntegrationID: string, user: UserInfo,
179
183
  } catch { return false; }
180
184
  }
181
185
 
186
+ interface EntityPlan {
187
+ entityName: string;
188
+ entityInfo: EntityInfo;
189
+ entityMap: { ID: string; ExternalObjectName: string };
190
+ work: WorkItem[];
191
+ /** Index of this entity's input in the RSU batch; -1 when it needs no DDL. */
192
+ batchIndex: number;
193
+ }
194
+
195
+ /** What {@link IntegrationCustomColumnPromoter.PlanPromotion} worked out, before anything runs. */
196
+ export interface PromotionPlan {
197
+ IntegrationID: string;
198
+ Plans: EntityPlan[];
199
+ /**
200
+ * The ADD COLUMN migrations, ready to run. The FIRST entry carries the durable post-restart
201
+ * PendingWork for the whole plan — RSU registers PendingWork from every input in a batch, so
202
+ * these can be appended to someone else's batch without losing it.
203
+ */
204
+ BatchInputs: RSUPipelineInput[];
205
+ }
206
+
182
207
  const NOT_PROMOTED: SchemaPromotionResult = { Promoted: false, ColumnsAdded: [], SchemaUpdatePending: false };
183
208
 
184
209
  /**
@@ -199,30 +224,38 @@ export class IntegrationCustomColumnPromoter {
199
224
  return this.provider as unknown as DatabaseProviderBase;
200
225
  }
201
226
 
202
- /** Entry point: promote custom columns for every entity touched by the sync. */
203
- public async PromoteForSync(
227
+ /**
228
+ * PHASE 1 only: work out what WOULD be promoted, and the ADD COLUMN migrations that would do
229
+ * it, without running a pipeline.
230
+ *
231
+ * Split out so a caller that is ALREADY running an RSU batch can fold these migrations into
232
+ * it. A schema refresh that offers the accumulated overflow columns and then promotes them in
233
+ * its own second batch would restart the workspace twice in a row for one user action, and a
234
+ * restart storm is its own incident class here. One batch, one migration, one restart.
235
+ *
236
+ * Side effects are deliberate and belong to planning, not to promotion: stale already-promoted
237
+ * keys are purged from the staging JSON here, BEFORE any column is created and before the RSU
238
+ * pass that would restart this process. That runs even when nothing new is promoted, which is
239
+ * the only way residue on rows a sync never rewrites gets cleaned rather than endlessly
240
+ * re-detected as a phantom "new column".
241
+ *
242
+ * Returns null when there is nothing to do.
243
+ */
244
+ public async PlanPromotion(
204
245
  companyIntegrationID: string,
205
- syncedEntityNames: string[],
246
+ entityNames: string[],
206
247
  customKeyStats?: Record<string, CustomKeyStat[]>,
207
- ): Promise<SchemaPromotionResult> {
248
+ ): Promise<PromotionPlan | null> {
208
249
  const integrationID = await this.resolveIntegrationID(companyIntegrationID);
209
- if (!integrationID) return NOT_PROMOTED;
250
+ if (!integrationID) return null;
210
251
 
211
252
  // ── PHASE 1: PLAN — build every entity's work list + its RSU input; run NO pipeline. ──
212
253
  // The old shape ran the FULL RSU pipeline per entity — a sync touching N entities with
213
254
  // candidates paid N CodeGen + compile passes where the batch API exists precisely to pay
214
255
  // one. Plan everything first, then promote once.
215
- interface EntityPlan {
216
- entityName: string;
217
- entityInfo: EntityInfo;
218
- entityMap: { ID: string; ExternalObjectName: string };
219
- work: WorkItem[];
220
- /** Index of this entity's input in the RSU batch; -1 when it needs no DDL. */
221
- batchIndex: number;
222
- }
223
256
  const plans: EntityPlan[] = [];
224
257
  const batchInputs: RSUPipelineInput[] = [];
225
- for (const entityName of syncedEntityNames) {
258
+ for (const entityName of entityNames) {
226
259
  try {
227
260
  const planned = await this.planWorkForEntity(companyIntegrationID, entityName, customKeyStats?.[entityName]);
228
261
  if (!planned) continue; // no overflow column / no captured customs / no entity map
@@ -256,7 +289,7 @@ export class IntegrationCustomColumnPromoter {
256
289
  LogError(`[CustomColumnPromoter] Planning failed for entity '${entityName}': ${this.msg(err)}`);
257
290
  }
258
291
  }
259
- if (plans.length === 0) return NOT_PROMOTED;
292
+ if (plans.length === 0) return null;
260
293
 
261
294
  // Register the follow-up DURABLY before the restart, the way the apply-objects path does
262
295
  // (IntegrationDiscoveryResolver: `rsuInput.PendingWork = [pendingPayload]`). The restart is
@@ -290,6 +323,19 @@ export class IntegrationCustomColumnPromoter {
290
323
  }];
291
324
  batchInputs[0].ContextUser = this.user;
292
325
  }
326
+ return { IntegrationID: integrationID, Plans: plans, BatchInputs: batchInputs };
327
+ }
328
+
329
+ /** Entry point: promote custom columns for every entity touched by the sync. */
330
+ public async PromoteForSync(
331
+ companyIntegrationID: string,
332
+ syncedEntityNames: string[],
333
+ customKeyStats?: Record<string, CustomKeyStat[]>,
334
+ ): Promise<SchemaPromotionResult> {
335
+ const promotionPlan = await this.PlanPromotion(companyIntegrationID, syncedEntityNames, customKeyStats);
336
+ if (!promotionPlan) return NOT_PROMOTED;
337
+ const plans = promotionPlan.Plans;
338
+ const batchInputs = promotionPlan.BatchInputs;
293
339
 
294
340
  // ── PHASE 2: ONE batched RSU pass for ALL entities' ADD COLUMN migrations. ──
295
341
  // RunPipelineBatch runs every migration under one lock, then ONE CodeGen + compile +
@@ -355,7 +401,7 @@ export class IntegrationCustomColumnPromoter {
355
401
  EntityName: plan.entityName,
356
402
  EntityMapID: plan.entityMap.ID,
357
403
  ExternalObjectName: plan.entityMap.ExternalObjectName,
358
- IntegrationID: integrationID,
404
+ IntegrationID: promotionPlan.IntegrationID,
359
405
  Columns: plan.work.map(w => ({
360
406
  SourceKey: w.sourceKey,
361
407
  ColumnName: w.columnName,
@@ -390,12 +436,19 @@ export class IntegrationCustomColumnPromoter {
390
436
  * Idempotent, because a pending row is marked Completed only after success and so stays
391
437
  * re-processable after a crash: field maps are filtered against those already active, and the
392
438
  * spread only fills a destination that is still empty.
439
+ *
440
+ * One entity's failure does not stop the others, but it is not swallowed either: after every
441
+ * entry has run, any failure is THROWN, so the caller fails the pending row instead of marking
442
+ * it Completed over columns that exist in the database and are never mapped.
443
+ *
444
+ * @throws PROMOTION_INCOMPLETE naming each entity that failed.
393
445
  */
394
446
  public async CompletePromotion(
395
447
  promoted: NonNullable<RSUPendingWork['PromotedColumns']>,
396
448
  knownEntities?: ReadonlyMap<string, EntityInfo>,
397
449
  ): Promise<Array<{ EntityName: string; ColumnName: string }>> {
398
450
  const columnsAdded: Array<{ EntityName: string; ColumnName: string }> = [];
451
+ const failures: string[] = [];
399
452
  for (const entry of promoted) {
400
453
  try {
401
454
  // Provider first — post-restart it holds the REGENERATED class, which is the whole
@@ -404,6 +457,7 @@ export class IntegrationCustomColumnPromoter {
404
457
  const entityInfo = this.provider.EntityByName(entry.EntityName) ?? knownEntities?.get(entry.EntityName);
405
458
  if (!entityInfo) {
406
459
  LogError(`[CustomColumnPromoter] Post-restart: entity '${entry.EntityName}' not found; skipping.`);
460
+ failures.push(`${entry.EntityName}: entity not found`);
407
461
  continue;
408
462
  }
409
463
  // Destination names are CARRIED, never recomputed: uniqueColumnName may have
@@ -429,17 +483,23 @@ export class IntegrationCustomColumnPromoter {
429
483
  needsFieldMap: !existingMaps.has(c.SourceKey.toLowerCase()),
430
484
  }));
431
485
 
432
- await this.createIntegrationObjectFields(entry.IntegrationID, entry.ExternalObjectName, named);
486
+ await this.createIntegrationObjectFields(entry.IntegrationID, entry.EntityMapID, entry.ExternalObjectName, named);
433
487
  await this.createFieldMaps(entry.EntityMapID, named.filter(n => n.needsFieldMap));
434
488
  await this.spreadAndRebaseline(entry.EntityName, entry.EntityMapID, entityInfo, named);
435
489
 
436
490
  LogStatus(`[CustomColumnPromoter] Post-restart: completed ${named.length} promoted column(s) on ${entry.EntityName}: ${named.map(n => n.columnName).join(', ')}`);
437
491
  columnsAdded.push(...named.map(n => ({ EntityName: entry.EntityName, ColumnName: n.columnName })));
438
492
  } catch (err) {
439
- // One entity must not abort the others; the pending row stays open for retry.
493
+ // One entity must not abort the others; the failure is thrown once they have all run.
440
494
  LogError(`[CustomColumnPromoter] Post-restart completion failed for '${entry.EntityName}': ${this.msg(err)}`);
495
+ failures.push(`${entry.EntityName}: ${this.msg(err)}`);
441
496
  }
442
497
  }
498
+ if (failures.length > 0) {
499
+ throw new Error(
500
+ `PROMOTION_INCOMPLETE: ${failures.length} of ${promoted.length} entity(ies) failed to complete — ${failures.join('; ')}`
501
+ );
502
+ }
443
503
  return columnsAdded;
444
504
  }
445
505
 
@@ -786,13 +846,45 @@ export class IntegrationCustomColumnPromoter {
786
846
 
787
847
  /** Creates an IOF row per promoted field (IsCustom, MetadataSource='Discovered'). */
788
848
  private async createIntegrationObjectFields(
849
+ integrationID: string,
850
+ entityMapID: string,
851
+ externalObjectName: string,
852
+ named: WorkItem[],
853
+ ): Promise<void> {
854
+ // Resolve the CONNECTION from the entity map rather than hopping connection → integration
855
+ // and writing the shared rows. That hop is what let one tenant's promoted column appear in
856
+ // the catalog every other tenant on the same connector reads.
857
+ const entityMap = IntegrationEngineBase.Instance.EntityMaps.find(m => UUIDsEqual(m.ID, entityMapID));
858
+ const companyIntegration = entityMap
859
+ ? IntegrationEngineBase.Instance.GetCompanyIntegrationByID(entityMap.CompanyIntegrationID)
860
+ : undefined;
861
+ if (!companyIntegration) {
862
+ LogError(`[CustomColumnPromoter] Could not resolve the connection behind entity map ${entityMapID}; catalog rows skipped for '${externalObjectName}'.`);
863
+ return;
864
+ }
865
+ // In the connection's own scope, entered here per entry: the post-restart consumer calls
866
+ // in with no scope, and unscoped a connection with per-connection rows reads as having none,
867
+ // so BuildCatalogWriter throws PER_CONNECTION_CATALOG_MISSING. Per entry, so a batch that
868
+ // spans connections resolves each one to its own catalog.
869
+ await WithCatalogScope(
870
+ companyIntegration.ID,
871
+ () => this.writeIntegrationObjectFields(companyIntegration, integrationID, externalObjectName, named),
872
+ this.user,
873
+ );
874
+ }
875
+
876
+ /** The catalog writes of {@link createIntegrationObjectFields}, run inside the connection's scope. */
877
+ private async writeIntegrationObjectFields(
878
+ companyIntegration: MJCompanyIntegrationEntity,
789
879
  integrationID: string,
790
880
  externalObjectName: string,
791
881
  named: WorkItem[],
792
882
  ): Promise<void> {
793
- const objectID = await this.resolveIntegrationObjectID(integrationID, externalObjectName);
883
+ const writer = BuildCatalogWriter(this.provider, companyIntegration, this.user);
884
+ const objectID = (await writer.ObjectsInScope())
885
+ .find(o => o.Name.toLowerCase() === externalObjectName.toLowerCase())?.ID ?? null;
794
886
  if (!objectID) {
795
- LogError(`[CustomColumnPromoter] No IntegrationObject '${externalObjectName}' for integration ${integrationID}; IOF rows skipped.`);
887
+ LogError(`[CustomColumnPromoter] No catalog object '${externalObjectName}' for integration ${integrationID}; catalog field rows skipped.`);
796
888
  return;
797
889
  }
798
890
  // Lookup-or-reactivate-or-create — NEVER blind-create over an existing field. A field the source
@@ -800,13 +892,16 @@ export class IntegrationCustomColumnPromoter {
800
892
  // key reappears in the payload and reaches promotion, the IOF already exists: reactivate it (so the
801
893
  // active-filtered ApplyAll re-materializes the still-present column) instead of creating a duplicate.
802
894
  // This is the "removed-then-re-added" case + the recovery case (column existed, field map missing).
803
- const existingIOFs = await this.existingIOFsByName(objectID);
895
+ const existingIOFs = new Map<string, { ID: string; Status: string }>();
896
+ for (const f of await writer.FieldsForObject(objectID)) {
897
+ existingIOFs.set((f.Name ?? '').toLowerCase(), { ID: f.ID, Status: f.Status ?? 'Active' });
898
+ }
804
899
  for (const n of named) {
805
900
  const existing = existingIOFs.get(n.sourceKey.toLowerCase());
806
901
  if (existing) {
807
902
  if (existing.Status !== 'Active') {
808
- const reIof = await this.provider.GetEntityObject<MJIntegrationObjectFieldEntity>('MJ: Integration Object Fields', this.user);
809
- if (await reIof.Load(existing.ID)) {
903
+ const reIof = await writer.LoadField(existing.ID);
904
+ if (reIof) {
810
905
  reIof.Status = 'Active';
811
906
  const ok = await reIof.Save();
812
907
  if (!ok) LogError(`[CustomColumnPromoter] Failed to reactivate IOF '${n.sourceKey}': ${reIof.LatestResult?.CompleteMessage ?? 'unknown'}`);
@@ -814,8 +909,10 @@ export class IntegrationCustomColumnPromoter {
814
909
  }
815
910
  continue;
816
911
  }
817
- const iof = await this.provider.GetEntityObject<MJIntegrationObjectFieldEntity>('MJ: Integration Object Fields', this.user);
818
- iof.NewRecord();
912
+ const iof = await writer.NewFieldRow();
913
+ // An overflow-promoted column was seen in live data, never described by an endpoint and
914
+ // never declared — so its provenance is 'Sampled', and it has no declared row behind it.
915
+ writer.StampNewField(iof, null, 'Sampled');
819
916
  iof.IntegrationObjectID = objectID;
820
917
  iof.Name = n.sourceKey;
821
918
  iof.DisplayName = n.sourceKey;
@@ -1107,40 +1204,13 @@ export class IntegrationCustomColumnPromoter {
1107
1204
  ExtraFilter: `CompanyIntegrationID='${companyIntegrationID}' AND Entity='${this.escape(entityName)}'`,
1108
1205
  ResultType: 'simple',
1109
1206
  MaxRows: 1,
1207
+ SkipTotalRowCount: true,
1110
1208
  }, this.user);
1111
1209
  const row = res.Success ? res.Results?.[0] : undefined;
1112
1210
  return row ? { ID: row.ID, ExternalObjectName: row.ExternalObjectName } : null;
1113
1211
  }
1114
1212
 
1115
- /** Existing IOF field names (lowercased) for an object — for idempotent IOF creation. */
1116
- private async existingIOFsByName(objectID: string): Promise<ReadonlyMap<string, { ID: string; Status: string }>> {
1117
- const rv = new RunView();
1118
- const res = await rv.RunView<MJIntegrationObjectFieldEntity>({
1119
- EntityName: 'MJ: Integration Object Fields',
1120
- ExtraFilter: `IntegrationObjectID='${objectID}'`,
1121
- Fields: ['ID', 'Name', 'Status'],
1122
- ResultType: 'simple',
1123
- }, this.user);
1124
- const map = new Map<string, { ID: string; Status: string }>();
1125
- if (res.Success) for (const r of res.Results ?? []) {
1126
- map.set((r.Name ?? '').toLowerCase(), { ID: String(r.ID), Status: r.Status ?? 'Active' });
1127
- }
1128
- return map;
1129
- }
1130
1213
 
1131
- /** Resolves the IntegrationObject ID for an external object name under an integration. */
1132
- private async resolveIntegrationObjectID(integrationID: string, externalObjectName: string): Promise<string | null> {
1133
- const rv = new RunView();
1134
- const res = await rv.RunView<MJIntegrationObjectEntity>({
1135
- EntityName: 'MJ: Integration Objects',
1136
- ExtraFilter: `IntegrationID='${integrationID}' AND Name='${this.escape(externalObjectName)}'`,
1137
- Fields: ['ID', 'Name', 'IntegrationID'],
1138
- ResultType: 'simple',
1139
- MaxRows: 1,
1140
- }, this.user);
1141
- const row = res.Success ? res.Results?.[0] : undefined;
1142
- return row ? row.ID : null;
1143
- }
1144
1214
 
1145
1215
  private escape(value: string): string {
1146
1216
  return value.replace(/'/g, "''");