@memberjunction/core-entities 6.3.0-edge.0 → 6.3.0-edge.1

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (140) hide show
  1. package/dist/.tsbuildinfo +1 -1
  2. package/dist/custom/AnchoredConversationSecurity.d.ts +10 -1
  3. package/dist/custom/AnchoredConversationSecurity.d.ts.map +1 -1
  4. package/dist/custom/AnchoredConversationSecurity.js +15 -0
  5. package/dist/custom/AnchoredConversationSecurity.js.map +1 -1
  6. package/dist/custom/ArtifactLockValidation.d.ts +28 -0
  7. package/dist/custom/ArtifactLockValidation.d.ts.map +1 -0
  8. package/dist/custom/ArtifactLockValidation.js +867 -0
  9. package/dist/custom/ArtifactLockValidation.js.map +1 -0
  10. package/dist/custom/ArtifactPermissionDelegate.d.ts +267 -0
  11. package/dist/custom/ArtifactPermissionDelegate.d.ts.map +1 -0
  12. package/dist/custom/ArtifactPermissionDelegate.js +1232 -0
  13. package/dist/custom/ArtifactPermissionDelegate.js.map +1 -0
  14. package/dist/custom/ArtifactPreviewSnapshot.d.ts +199 -0
  15. package/dist/custom/ArtifactPreviewSnapshot.d.ts.map +1 -0
  16. package/dist/custom/ArtifactPreviewSnapshot.js +772 -0
  17. package/dist/custom/ArtifactPreviewSnapshot.js.map +1 -0
  18. package/dist/custom/ArtifactSynthesisEngine.d.ts +151 -0
  19. package/dist/custom/ArtifactSynthesisEngine.d.ts.map +1 -0
  20. package/dist/custom/ArtifactSynthesisEngine.js +1124 -0
  21. package/dist/custom/ArtifactSynthesisEngine.js.map +1 -0
  22. package/dist/custom/ConversationWriteAccess.d.ts +27 -0
  23. package/dist/custom/ConversationWriteAccess.d.ts.map +1 -1
  24. package/dist/custom/ConversationWriteAccess.js +53 -0
  25. package/dist/custom/ConversationWriteAccess.js.map +1 -1
  26. package/dist/custom/DocumentLiveBlockEngine.d.ts +612 -0
  27. package/dist/custom/DocumentLiveBlockEngine.d.ts.map +1 -0
  28. package/dist/custom/DocumentLiveBlockEngine.js +2352 -0
  29. package/dist/custom/DocumentLiveBlockEngine.js.map +1 -0
  30. package/dist/custom/MJQueryEntityExtended.d.ts.map +1 -1
  31. package/dist/custom/MJQueryEntityExtended.js +27 -11
  32. package/dist/custom/MJQueryEntityExtended.js.map +1 -1
  33. package/dist/custom/PermissionProviders/ArtifactPermissionProvider.d.ts.map +1 -1
  34. package/dist/custom/PermissionProviders/ArtifactPermissionProvider.js +31 -7
  35. package/dist/custom/PermissionProviders/ArtifactPermissionProvider.js.map +1 -1
  36. package/dist/custom/PermissionProviders/CollectionPermissionProvider.d.ts +3 -4
  37. package/dist/custom/PermissionProviders/CollectionPermissionProvider.d.ts.map +1 -1
  38. package/dist/custom/PermissionProviders/CollectionPermissionProvider.js +334 -47
  39. package/dist/custom/PermissionProviders/CollectionPermissionProvider.js.map +1 -1
  40. package/dist/custom/Permissions/BaseShareEntityExtended.d.ts +19 -3
  41. package/dist/custom/Permissions/BaseShareEntityExtended.d.ts.map +1 -1
  42. package/dist/custom/Permissions/BaseShareEntityExtended.js +139 -13
  43. package/dist/custom/Permissions/BaseShareEntityExtended.js.map +1 -1
  44. package/dist/custom/Permissions/MJArtifactPermissionEntityExtended.d.ts +8 -6
  45. package/dist/custom/Permissions/MJArtifactPermissionEntityExtended.d.ts.map +1 -1
  46. package/dist/custom/Permissions/MJArtifactPermissionEntityExtended.js +93 -41
  47. package/dist/custom/Permissions/MJArtifactPermissionEntityExtended.js.map +1 -1
  48. package/dist/custom/Permissions/MJCollectionPermissionEntityExtended.d.ts +12 -5
  49. package/dist/custom/Permissions/MJCollectionPermissionEntityExtended.d.ts.map +1 -1
  50. package/dist/custom/Permissions/MJCollectionPermissionEntityExtended.js +240 -37
  51. package/dist/custom/Permissions/MJCollectionPermissionEntityExtended.js.map +1 -1
  52. package/dist/custom/SlideDeckEngine.d.ts +427 -0
  53. package/dist/custom/SlideDeckEngine.d.ts.map +1 -0
  54. package/dist/custom/SlideDeckEngine.js +1669 -0
  55. package/dist/custom/SlideDeckEngine.js.map +1 -0
  56. package/dist/custom/SlideDeckPptxEngine.d.ts +25 -0
  57. package/dist/custom/SlideDeckPptxEngine.d.ts.map +1 -0
  58. package/dist/custom/SlideDeckPptxEngine.js +1237 -0
  59. package/dist/custom/SlideDeckPptxEngine.js.map +1 -0
  60. package/dist/custom/SpreadsheetEngine.d.ts +1370 -0
  61. package/dist/custom/SpreadsheetEngine.d.ts.map +1 -0
  62. package/dist/custom/SpreadsheetEngine.js +17580 -0
  63. package/dist/custom/SpreadsheetEngine.js.map +1 -0
  64. package/dist/custom/approvals.d.ts +7 -1
  65. package/dist/custom/approvals.d.ts.map +1 -1
  66. package/dist/custom/approvals.js +8 -1
  67. package/dist/custom/approvals.js.map +1 -1
  68. package/dist/custom/operations/ArtifactComplianceAuditOperation.d.ts +7 -0
  69. package/dist/custom/operations/ArtifactComplianceAuditOperation.d.ts.map +1 -0
  70. package/dist/custom/operations/ArtifactComplianceAuditOperation.js +7 -0
  71. package/dist/custom/operations/ArtifactComplianceAuditOperation.js.map +1 -0
  72. package/dist/custom/operations/ArtifactEvaluateAiFormulaOperation.d.ts +7 -0
  73. package/dist/custom/operations/ArtifactEvaluateAiFormulaOperation.d.ts.map +1 -0
  74. package/dist/custom/operations/ArtifactEvaluateAiFormulaOperation.js +7 -0
  75. package/dist/custom/operations/ArtifactEvaluateAiFormulaOperation.js.map +1 -0
  76. package/dist/custom/operations/ArtifactGuestShareOperations.d.ts +60 -0
  77. package/dist/custom/operations/ArtifactGuestShareOperations.d.ts.map +1 -0
  78. package/dist/custom/operations/ArtifactGuestShareOperations.js +6 -0
  79. package/dist/custom/operations/ArtifactGuestShareOperations.js.map +1 -0
  80. package/dist/custom/operations/SynthesizeArtifactFromSourcesOperation.d.ts +7 -0
  81. package/dist/custom/operations/SynthesizeArtifactFromSourcesOperation.d.ts.map +1 -0
  82. package/dist/custom/operations/SynthesizeArtifactFromSourcesOperation.js +7 -0
  83. package/dist/custom/operations/SynthesizeArtifactFromSourcesOperation.js.map +1 -0
  84. package/dist/custom/typedQuery.d.ts +162 -0
  85. package/dist/custom/typedQuery.d.ts.map +1 -0
  86. package/dist/custom/typedQuery.js +296 -0
  87. package/dist/custom/typedQuery.js.map +1 -0
  88. package/dist/engines/CanonGraphEngine.d.ts +1 -1
  89. package/dist/engines/CanonGraphEngine.d.ts.map +1 -1
  90. package/dist/engines/CanonGraphEngine.js +19 -14
  91. package/dist/engines/CanonGraphEngine.js.map +1 -1
  92. package/dist/engines/EncryptionEngineBase.js +2 -2
  93. package/dist/engines/EncryptionEngineBase.js.map +1 -1
  94. package/dist/engines/QueryEngine.js +2 -2
  95. package/dist/engines/QueryEngine.js.map +1 -1
  96. package/dist/engines/SearchEngineBase.d.ts +17 -3
  97. package/dist/engines/SearchEngineBase.d.ts.map +1 -1
  98. package/dist/engines/SearchEngineBase.js +100 -28
  99. package/dist/engines/SearchEngineBase.js.map +1 -1
  100. package/dist/engines/UserInfoEngine.d.ts +8 -0
  101. package/dist/engines/UserInfoEngine.d.ts.map +1 -1
  102. package/dist/engines/UserInfoEngine.js +50 -3
  103. package/dist/engines/UserInfoEngine.js.map +1 -1
  104. package/dist/engines/conversations.d.ts +54 -2
  105. package/dist/engines/conversations.d.ts.map +1 -1
  106. package/dist/engines/conversations.js +144 -12
  107. package/dist/engines/conversations.js.map +1 -1
  108. package/dist/generated/entities/__mj.d.ts +1076 -25406
  109. package/dist/generated/entities/__mj.d.ts.map +1 -1
  110. package/dist/generated/entities/__mj.js +636 -41542
  111. package/dist/generated/entities/__mj.js.map +1 -1
  112. package/dist/generated/queries/__mj.d.ts +12 -12
  113. package/dist/generated/queries/__mj.d.ts.map +1 -1
  114. package/dist/generated/queries/__mj.js +1 -1
  115. package/dist/generated/queries/__mj.js.map +1 -1
  116. package/dist/generated/remote_operations.d.ts +225 -0
  117. package/dist/generated/remote_operations.d.ts.map +1 -1
  118. package/dist/generated/remote_operations.js +95 -0
  119. package/dist/generated/remote_operations.js.map +1 -1
  120. package/dist/generated/schemas/__mj.d.ts +25489 -0
  121. package/dist/generated/schemas/__mj.d.ts.map +1 -0
  122. package/dist/generated/schemas/__mj.js +41768 -0
  123. package/dist/generated/schemas/__mj.js.map +1 -0
  124. package/dist/generated/schemas.d.ts +2 -0
  125. package/dist/generated/schemas.d.ts.map +1 -0
  126. package/dist/generated/schemas.js +2 -0
  127. package/dist/generated/schemas.js.map +1 -0
  128. package/dist/graph/GraphEngine.d.ts +19 -0
  129. package/dist/graph/GraphEngine.d.ts.map +1 -1
  130. package/dist/graph/GraphEngine.js +90 -0
  131. package/dist/graph/GraphEngine.js.map +1 -1
  132. package/dist/index.d.ts +12 -0
  133. package/dist/index.d.ts.map +1 -1
  134. package/dist/index.js +18 -0
  135. package/dist/index.js.map +1 -1
  136. package/dist/schemas.d.ts +6 -0
  137. package/dist/schemas.d.ts.map +1 -0
  138. package/dist/schemas.js +6 -0
  139. package/dist/schemas.js.map +1 -0
  140. package/package.json +17 -6
@@ -1,8 +1,9 @@
1
- import { BaseEngine, EntityEventRowIsFree, ResolveEntityEventKey, ResolveEntityEventRow, RunQuery, RunView, TransformSimpleObjectToEntityObject } from "@memberjunction/core";
1
+ import { BaseEngine, EntityEventRowIsFree, EntityPermissionType, ResolveEntityEventKey, ResolveEntityEventRow, RunQuery, RunView, TransformSimpleObjectToEntityObject } from "@memberjunction/core";
2
2
  import { EscapeSQLString, IndexByUUID, NormalizeUUID, ToEpochMs, UUIDMap, UUIDSet, UUIDsEqual } from "@memberjunction/global";
3
3
  import { BehaviorSubject } from "rxjs";
4
4
  import { ArtifactMetadataEngine } from "./artifacts.js";
5
5
  import { ResourcePermissionEngine } from "../custom/ResourcePermissions/ResourcePermissionEngine.js";
6
+ import { CONVERSATION_DELETE_REFUSED_REASON, ConversationDeleteAllowed } from "../custom/ConversationWriteAccess.js";
6
7
  import { FilterAnchoredConversationsForUser, IsConversationHiddenByFieldSecurity, ParseConversationAnchorMetadata } from "../custom/AnchoredConversationSecurity.js";
7
8
  /**
8
9
  * `MJ: Resource Types.ID` for Conversations. Conversations that the current
@@ -737,6 +738,15 @@ export class ConversationEngine extends BaseEngine {
737
738
  }
738
739
  return this.GetSharedByInfo(conversation.ID)?.Level === 'Owner';
739
740
  }
741
+ /**
742
+ * True when the user may delete the conversation for everyone: they own it, hold an
743
+ * Owner-level grant on it, or are in the Developer or Integration role. An Edit grant
744
+ * is not enough. Mirrors the server's delete gate in `MJConversationEntityServer`, so
745
+ * the UI never offers a delete the server would refuse.
746
+ */
747
+ CanDeleteConversation(conversation, user) {
748
+ return ConversationDeleteAllowed(conversation.UserID, user, this.GetSharedByInfo(conversation.ID)?.Level ?? null);
749
+ }
740
750
  /**
741
751
  * True when the user may move the conversation to another folder or change whether it inherits its
742
752
  * folder's access: only its owner. Both decide who else sees it, so an Edit or Owner grant is not
@@ -1103,6 +1113,34 @@ export class ConversationEngine extends BaseEngine {
1103
1113
  }
1104
1114
  return [...byProjectId.values()];
1105
1115
  }
1116
+ /**
1117
+ * True when one of the user's roles grants this kind of write on folders (`MJ: Projects`) with no row-level
1118
+ * filter. A user whose folder writes are all filtered (the UI role: own folders only) writes only folders they
1119
+ * own: they cannot make a folder Public (no owner) or rename, move or delete a Public folder or someone else's.
1120
+ * Answers false when the folder entity's metadata is not loaded.
1121
+ *
1122
+ * @param provider the metadata provider the caller works against; defaults to the engine's.
1123
+ */
1124
+ CanWriteAnyProject(user, type, provider) {
1125
+ if (!user) {
1126
+ return false;
1127
+ }
1128
+ const entity = (provider ?? this.ProviderToUse)?.EntityByName('MJ: Projects');
1129
+ return !!entity && entity.UserExemptFromRowLevelSecurity(user, type);
1130
+ }
1131
+ /**
1132
+ * True when the user may rename or delete this folder from the sidebar: they own it, or their folder writes
1133
+ * are not row-filtered (see {@link CanWriteAnyProject}).
1134
+ */
1135
+ CanManageProject(project, user, provider) {
1136
+ if (!project || !user) {
1137
+ return false;
1138
+ }
1139
+ if (project.OwnerUserID && UUIDsEqual(project.OwnerUserID, user.ID)) {
1140
+ return true;
1141
+ }
1142
+ return this.CanWriteAnyProject(user, EntityPermissionType.Update, provider);
1143
+ }
1106
1144
  /**
1107
1145
  * Returns the three-tier visibility mode (`'Private' | 'Shared' | 'Public'`) for a folder:
1108
1146
  * - `'Public'`: `OwnerUserID == null` (environment-wide)
@@ -1435,6 +1473,8 @@ export class ConversationEngine extends BaseEngine {
1435
1473
  * 2. Reparents direct child folders to this folder's parent (one level up).
1436
1474
  * 3. Deletes the now-unreferenced folder.
1437
1475
  * Conversations and subfolders are preserved — only the folder itself is removed.
1476
+ * Steps 1 and 2 cover the rows the caller can change; the server's folder delete
1477
+ * (`MJProjectEntityServer.Delete`) moves the rest in the delete's transaction.
1438
1478
  *
1439
1479
  * Note: this does NOT reassign Tasks that reference the project; if a Task still
1440
1480
  * references it, the final delete will fail and this throws with the DB message.
@@ -1458,9 +1498,10 @@ export class ConversationEngine extends BaseEngine {
1458
1498
  }
1459
1499
  const newParentId = project.ParentID ?? null;
1460
1500
  // 1. Unassign conversations directly in this folder that the caller can edit.
1461
- // View-only conversations owned by other users in a shared folder cannot be edited
1462
- // by this caller; if any still exist in the DB, the delete below will surface
1463
- // FK_Conversation_Project via ExplainProjectDeleteFailure.
1501
+ // Conversations owned by other users in a shared folder cannot be edited by this
1502
+ // caller; the server's folder delete takes them out of the folder in the delete's
1503
+ // transaction (on a server without that, the delete below surfaces
1504
+ // FK_Conversation_Project via ExplainProjectDeleteFailure).
1464
1505
  const directConversations = this._conversations$.value.filter(c => c.ProjectID && UUIDsEqual(c.ProjectID, id));
1465
1506
  for (const conv of directConversations) {
1466
1507
  if (!contextUser?.ID || !conv.UserID || this.CanEditConversation(conv, contextUser.ID)) {
@@ -1477,21 +1518,27 @@ export class ConversationEngine extends BaseEngine {
1477
1518
  // RESTRICT foreign key with no ON DELETE clause, so the delete below would then fail
1478
1519
  // with a raw constraint message, about a row the user is not allowed to know exists.
1479
1520
  //
1480
- // The read carries NO ownership clause, deliberately. Deleting a folder needs
1481
- // CanDelete on the entity, which the UI role does not hold; the roles that do also
1482
- // hold unfiltered read, which makes them exempt from the row-level filter — so this
1483
- // read returns the complete child set for every principal that can actually reach
1484
- // here. Should a deployment grant delete to a filtered role anyway, the server still
1485
- // narrows the read, and step 3's guard turns the resulting FK failure into something
1486
- // legible rather than "Failed to save project".
1521
+ // The read carries no ownership clause; the server narrows it to what the caller
1522
+ // may read. A subfolder another user owns may refuse the move (only its owner moves
1523
+ // it, and a row-filtered caller writes only their own folders): that one is left in
1524
+ // place, and the server's folder delete moves it, as the system user and in the
1525
+ // delete's transaction, once the caller's Delete permission and row filter pass. On a
1526
+ // server without that, the delete below fails on the foreign key and step 3's guard
1527
+ // explains it.
1487
1528
  const childFolders = await this.readChildFolders(id, contextUser);
1488
1529
  if (childFolders.length > 0) {
1489
1530
  this._selfMutating = true;
1490
1531
  try {
1491
1532
  for (const child of childFolders) {
1533
+ const previousParentId = child.ParentID;
1492
1534
  child.ParentID = newParentId;
1493
1535
  const saved = await child.Save();
1494
1536
  if (!saved) {
1537
+ const ownedByOther = !!child.OwnerUserID && !!contextUser?.ID && !UUIDsEqual(child.OwnerUserID, contextUser.ID);
1538
+ if (ownedByOther) {
1539
+ child.ParentID = previousParentId; // left for the server's folder delete
1540
+ continue;
1541
+ }
1495
1542
  throw new Error(child.LatestResult?.CompleteMessage || 'Failed to reparent subfolder');
1496
1543
  }
1497
1544
  }
@@ -2126,7 +2173,7 @@ export class ConversationEngine extends BaseEngine {
2126
2173
  * @param id - The conversation ID to delete
2127
2174
  * @param contextUser - The current user context
2128
2175
  * @returns true if successful
2129
- * @throws Error if conversation not found or delete fails
2176
+ * @throws Error if conversation not found, the user may not delete it ({@link CanDeleteConversation}), or delete fails
2130
2177
  */
2131
2178
  async DeleteConversation(id, contextUser) {
2132
2179
  // Try to use the cached entity object first to avoid a DB round-trip
@@ -2140,6 +2187,10 @@ export class ConversationEngine extends BaseEngine {
2140
2187
  throw new Error('Conversation not found');
2141
2188
  }
2142
2189
  }
2190
+ // Refuse before the optimistic removal below, so a refused conversation never leaves the list.
2191
+ if (!this.CanDeleteConversation(conversation, contextUser)) {
2192
+ throw new Error(CONVERSATION_DELETE_REFUSED_REASON);
2193
+ }
2143
2194
  // Remove from the list and cache BEFORE calling Delete(), because
2144
2195
  // BaseEntity.Delete() calls NewRecord() which wipes the entity's fields.
2145
2196
  // Since the cached entity is the same object reference in the list,
@@ -2262,6 +2313,8 @@ export class ConversationEngine extends BaseEngine {
2262
2313
  }
2263
2314
  /**
2264
2315
  * Deletes multiple conversations in a batch operation with per-item error tracking.
2316
+ * Conversations the user may not delete ({@link CanDeleteConversation}) are reported
2317
+ * as failed, by name, without a delete.
2265
2318
  *
2266
2319
  * @param ids - Array of conversation IDs to delete
2267
2320
  * @param contextUser - The current user context
@@ -2310,6 +2363,10 @@ export class ConversationEngine extends BaseEngine {
2310
2363
  try {
2311
2364
  for (const entity of entitiesToDelete) {
2312
2365
  const name = entity.Name || 'Unknown';
2366
+ if (!this.CanDeleteConversation(entity, contextUser)) {
2367
+ failed.push({ ID: entity.ID, Name: name, Error: CONVERSATION_DELETE_REFUSED_REASON });
2368
+ continue;
2369
+ }
2313
2370
  try {
2314
2371
  // Use DeleteConversation which handles Load + Delete properly
2315
2372
  // and removes from list/cache on success
@@ -3346,10 +3403,85 @@ export class ConversationEngine extends BaseEngine {
3346
3403
  static FilterToScope(scope, rows) {
3347
3404
  return ConversationEngine.FilterRowsToBranchPath(rows, scope.BranchID, scope.Branches);
3348
3405
  }
3406
+ /**
3407
+ * Client-safe query descriptor loading `MJ: Conversation Details.ID` values visible in `scope`,
3408
+ * optionally narrowed to `candidateDetailIds`. Runs directly against `MJ: Conversation Details`
3409
+ * so server `PostRunView` security hooks apply and `ClientClauseScreen` never rejects a base-view subquery.
3410
+ */
3411
+ static BuildScopedDetailIdsQuery(scope, candidateDetailIds) {
3412
+ let filter = ConversationEngine.ScopeFilter(scope);
3413
+ if (candidateDetailIds && candidateDetailIds.length > 0) {
3414
+ const uniqueEscaped = [...new Set(candidateDetailIds.map((id) => id.trim()).filter(Boolean))]
3415
+ .map((id) => `'${EscapeSQLString(id)}'`);
3416
+ if (uniqueEscaped.length > 0) {
3417
+ filter = `(${filter}) AND [ID] IN (${uniqueEscaped.join(',')})`;
3418
+ }
3419
+ }
3420
+ return {
3421
+ EntityName: 'MJ: Conversation Details',
3422
+ ExtraFilter: filter,
3423
+ Fields: ['ID'],
3424
+ ResultType: 'simple',
3425
+ IgnoreMaxRows: true
3426
+ };
3427
+ }
3428
+ /**
3429
+ * Loads lowercased `MJ: Conversation Details.ID` values visible in `scope` via `RunView`, returning
3430
+ * `null` if the read fails so callers can fail closed. Avoids emitting `[__mj].[vwConversationDetails]`
3431
+ * subqueries from GraphQL client filters.
3432
+ */
3433
+ static async LoadScopedDetailIds(scope, provider, contextUser, candidateDetailIds) {
3434
+ if (candidateDetailIds) {
3435
+ const unique = candidateDetailIds.map((id) => id.trim()).filter(Boolean);
3436
+ if (unique.length === 0) {
3437
+ return new Set();
3438
+ }
3439
+ }
3440
+ const rv = RunView.FromMetadataProvider(provider);
3441
+ const res = await rv.RunView(ConversationEngine.BuildScopedDetailIdsQuery(scope, candidateDetailIds), contextUser);
3442
+ if (!res?.Success || !Array.isArray(res.Results)) {
3443
+ return null;
3444
+ }
3445
+ const ids = new Set();
3446
+ for (const row of res.Results) {
3447
+ const id = typeof row.ID === 'string' ? row.ID.trim().toLowerCase() : '';
3448
+ if (id) {
3449
+ ids.add(id);
3450
+ }
3451
+ }
3452
+ return ids;
3453
+ }
3454
+ /**
3455
+ * Filters artifact versions to those visible in `scope` (`{@link ArtifactVersionScopeFilter}` semantics):
3456
+ * keeps versions linked in any direction to a detail in `scopedDetailIds`, plus versions that have
3457
+ * no `MJ: Conversation Detail Artifacts` link at all.
3458
+ */
3459
+ static FilterArtifactVersionsByScope(versions, links, scopedDetailIds) {
3460
+ const allLinkedVersionIds = new Set();
3461
+ const scopedLinkedVersionIds = new Set();
3462
+ for (const link of links) {
3463
+ const versionId = typeof link.ArtifactVersionID === 'string' ? link.ArtifactVersionID.trim().toLowerCase() : '';
3464
+ if (!versionId)
3465
+ continue;
3466
+ allLinkedVersionIds.add(versionId);
3467
+ const detailId = typeof link.ConversationDetailID === 'string' ? link.ConversationDetailID.trim().toLowerCase() : '';
3468
+ if (detailId && scopedDetailIds.has(detailId)) {
3469
+ scopedLinkedVersionIds.add(versionId);
3470
+ }
3471
+ }
3472
+ return versions.filter((v) => {
3473
+ const id = typeof v.ID === 'string' ? v.ID.trim().toLowerCase() : '';
3474
+ return id ? (!allLinkedVersionIds.has(id) || scopedLinkedVersionIds.has(id)) : false;
3475
+ });
3476
+ }
3349
3477
  /**
3350
3478
  * Filter over MJ: Artifact Versions for the versions of one artifact visible in scope: versions
3351
3479
  * linked (in any direction) from a message on the path, and versions with no conversation link
3352
3480
  * at all.
3481
+ *
3482
+ * Note: server/internal callers only — GraphQL clients must use {@link BuildScopedDetailIdsQuery} +
3483
+ * {@link FilterArtifactVersionsByScope} because `ClientClauseScreen` blocks `[__mj].[vwConversationDetails]`
3484
+ * subqueries in client-supplied `ExtraFilter`s.
3353
3485
  */
3354
3486
  static ArtifactVersionScopeFilter(scope, artifactId) {
3355
3487
  const path = ConversationEngine.ScopeFilter(scope);