@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.
- package/dist/.tsbuildinfo +1 -1
- package/dist/custom/AnchoredConversationSecurity.d.ts +10 -1
- package/dist/custom/AnchoredConversationSecurity.d.ts.map +1 -1
- package/dist/custom/AnchoredConversationSecurity.js +15 -0
- package/dist/custom/AnchoredConversationSecurity.js.map +1 -1
- package/dist/custom/ArtifactLockValidation.d.ts +28 -0
- package/dist/custom/ArtifactLockValidation.d.ts.map +1 -0
- package/dist/custom/ArtifactLockValidation.js +867 -0
- package/dist/custom/ArtifactLockValidation.js.map +1 -0
- package/dist/custom/ArtifactPermissionDelegate.d.ts +267 -0
- package/dist/custom/ArtifactPermissionDelegate.d.ts.map +1 -0
- package/dist/custom/ArtifactPermissionDelegate.js +1232 -0
- package/dist/custom/ArtifactPermissionDelegate.js.map +1 -0
- package/dist/custom/ArtifactPreviewSnapshot.d.ts +199 -0
- package/dist/custom/ArtifactPreviewSnapshot.d.ts.map +1 -0
- package/dist/custom/ArtifactPreviewSnapshot.js +772 -0
- package/dist/custom/ArtifactPreviewSnapshot.js.map +1 -0
- package/dist/custom/ArtifactSynthesisEngine.d.ts +151 -0
- package/dist/custom/ArtifactSynthesisEngine.d.ts.map +1 -0
- package/dist/custom/ArtifactSynthesisEngine.js +1124 -0
- package/dist/custom/ArtifactSynthesisEngine.js.map +1 -0
- package/dist/custom/ConversationWriteAccess.d.ts +27 -0
- package/dist/custom/ConversationWriteAccess.d.ts.map +1 -1
- package/dist/custom/ConversationWriteAccess.js +53 -0
- package/dist/custom/ConversationWriteAccess.js.map +1 -1
- package/dist/custom/DocumentLiveBlockEngine.d.ts +612 -0
- package/dist/custom/DocumentLiveBlockEngine.d.ts.map +1 -0
- package/dist/custom/DocumentLiveBlockEngine.js +2352 -0
- package/dist/custom/DocumentLiveBlockEngine.js.map +1 -0
- package/dist/custom/MJQueryEntityExtended.d.ts.map +1 -1
- package/dist/custom/MJQueryEntityExtended.js +27 -11
- package/dist/custom/MJQueryEntityExtended.js.map +1 -1
- package/dist/custom/PermissionProviders/ArtifactPermissionProvider.d.ts.map +1 -1
- package/dist/custom/PermissionProviders/ArtifactPermissionProvider.js +31 -7
- package/dist/custom/PermissionProviders/ArtifactPermissionProvider.js.map +1 -1
- package/dist/custom/PermissionProviders/CollectionPermissionProvider.d.ts +3 -4
- package/dist/custom/PermissionProviders/CollectionPermissionProvider.d.ts.map +1 -1
- package/dist/custom/PermissionProviders/CollectionPermissionProvider.js +334 -47
- package/dist/custom/PermissionProviders/CollectionPermissionProvider.js.map +1 -1
- package/dist/custom/Permissions/BaseShareEntityExtended.d.ts +19 -3
- package/dist/custom/Permissions/BaseShareEntityExtended.d.ts.map +1 -1
- package/dist/custom/Permissions/BaseShareEntityExtended.js +139 -13
- package/dist/custom/Permissions/BaseShareEntityExtended.js.map +1 -1
- package/dist/custom/Permissions/MJArtifactPermissionEntityExtended.d.ts +8 -6
- package/dist/custom/Permissions/MJArtifactPermissionEntityExtended.d.ts.map +1 -1
- package/dist/custom/Permissions/MJArtifactPermissionEntityExtended.js +93 -41
- package/dist/custom/Permissions/MJArtifactPermissionEntityExtended.js.map +1 -1
- package/dist/custom/Permissions/MJCollectionPermissionEntityExtended.d.ts +12 -5
- package/dist/custom/Permissions/MJCollectionPermissionEntityExtended.d.ts.map +1 -1
- package/dist/custom/Permissions/MJCollectionPermissionEntityExtended.js +240 -37
- package/dist/custom/Permissions/MJCollectionPermissionEntityExtended.js.map +1 -1
- package/dist/custom/SlideDeckEngine.d.ts +427 -0
- package/dist/custom/SlideDeckEngine.d.ts.map +1 -0
- package/dist/custom/SlideDeckEngine.js +1669 -0
- package/dist/custom/SlideDeckEngine.js.map +1 -0
- package/dist/custom/SlideDeckPptxEngine.d.ts +25 -0
- package/dist/custom/SlideDeckPptxEngine.d.ts.map +1 -0
- package/dist/custom/SlideDeckPptxEngine.js +1237 -0
- package/dist/custom/SlideDeckPptxEngine.js.map +1 -0
- package/dist/custom/SpreadsheetEngine.d.ts +1370 -0
- package/dist/custom/SpreadsheetEngine.d.ts.map +1 -0
- package/dist/custom/SpreadsheetEngine.js +17580 -0
- package/dist/custom/SpreadsheetEngine.js.map +1 -0
- package/dist/custom/approvals.d.ts +7 -1
- package/dist/custom/approvals.d.ts.map +1 -1
- package/dist/custom/approvals.js +8 -1
- package/dist/custom/approvals.js.map +1 -1
- package/dist/custom/operations/ArtifactComplianceAuditOperation.d.ts +7 -0
- package/dist/custom/operations/ArtifactComplianceAuditOperation.d.ts.map +1 -0
- package/dist/custom/operations/ArtifactComplianceAuditOperation.js +7 -0
- package/dist/custom/operations/ArtifactComplianceAuditOperation.js.map +1 -0
- package/dist/custom/operations/ArtifactEvaluateAiFormulaOperation.d.ts +7 -0
- package/dist/custom/operations/ArtifactEvaluateAiFormulaOperation.d.ts.map +1 -0
- package/dist/custom/operations/ArtifactEvaluateAiFormulaOperation.js +7 -0
- package/dist/custom/operations/ArtifactEvaluateAiFormulaOperation.js.map +1 -0
- package/dist/custom/operations/ArtifactGuestShareOperations.d.ts +60 -0
- package/dist/custom/operations/ArtifactGuestShareOperations.d.ts.map +1 -0
- package/dist/custom/operations/ArtifactGuestShareOperations.js +6 -0
- package/dist/custom/operations/ArtifactGuestShareOperations.js.map +1 -0
- package/dist/custom/operations/SynthesizeArtifactFromSourcesOperation.d.ts +7 -0
- package/dist/custom/operations/SynthesizeArtifactFromSourcesOperation.d.ts.map +1 -0
- package/dist/custom/operations/SynthesizeArtifactFromSourcesOperation.js +7 -0
- package/dist/custom/operations/SynthesizeArtifactFromSourcesOperation.js.map +1 -0
- package/dist/custom/typedQuery.d.ts +162 -0
- package/dist/custom/typedQuery.d.ts.map +1 -0
- package/dist/custom/typedQuery.js +296 -0
- package/dist/custom/typedQuery.js.map +1 -0
- package/dist/engines/CanonGraphEngine.d.ts +1 -1
- package/dist/engines/CanonGraphEngine.d.ts.map +1 -1
- package/dist/engines/CanonGraphEngine.js +19 -14
- package/dist/engines/CanonGraphEngine.js.map +1 -1
- package/dist/engines/EncryptionEngineBase.js +2 -2
- package/dist/engines/EncryptionEngineBase.js.map +1 -1
- package/dist/engines/QueryEngine.js +2 -2
- package/dist/engines/QueryEngine.js.map +1 -1
- package/dist/engines/SearchEngineBase.d.ts +17 -3
- package/dist/engines/SearchEngineBase.d.ts.map +1 -1
- package/dist/engines/SearchEngineBase.js +100 -28
- package/dist/engines/SearchEngineBase.js.map +1 -1
- package/dist/engines/UserInfoEngine.d.ts +8 -0
- package/dist/engines/UserInfoEngine.d.ts.map +1 -1
- package/dist/engines/UserInfoEngine.js +50 -3
- package/dist/engines/UserInfoEngine.js.map +1 -1
- package/dist/engines/conversations.d.ts +54 -2
- package/dist/engines/conversations.d.ts.map +1 -1
- package/dist/engines/conversations.js +144 -12
- package/dist/engines/conversations.js.map +1 -1
- package/dist/generated/entities/__mj.d.ts +1076 -25406
- package/dist/generated/entities/__mj.d.ts.map +1 -1
- package/dist/generated/entities/__mj.js +636 -41542
- package/dist/generated/entities/__mj.js.map +1 -1
- package/dist/generated/queries/__mj.d.ts +12 -12
- package/dist/generated/queries/__mj.d.ts.map +1 -1
- package/dist/generated/queries/__mj.js +1 -1
- package/dist/generated/queries/__mj.js.map +1 -1
- package/dist/generated/remote_operations.d.ts +225 -0
- package/dist/generated/remote_operations.d.ts.map +1 -1
- package/dist/generated/remote_operations.js +95 -0
- package/dist/generated/remote_operations.js.map +1 -1
- package/dist/generated/schemas/__mj.d.ts +25489 -0
- package/dist/generated/schemas/__mj.d.ts.map +1 -0
- package/dist/generated/schemas/__mj.js +41768 -0
- package/dist/generated/schemas/__mj.js.map +1 -0
- package/dist/generated/schemas.d.ts +2 -0
- package/dist/generated/schemas.d.ts.map +1 -0
- package/dist/generated/schemas.js +2 -0
- package/dist/generated/schemas.js.map +1 -0
- package/dist/graph/GraphEngine.d.ts +19 -0
- package/dist/graph/GraphEngine.d.ts.map +1 -1
- package/dist/graph/GraphEngine.js +90 -0
- package/dist/graph/GraphEngine.js.map +1 -1
- package/dist/index.d.ts +12 -0
- package/dist/index.d.ts.map +1 -1
- package/dist/index.js +18 -0
- package/dist/index.js.map +1 -1
- package/dist/schemas.d.ts +6 -0
- package/dist/schemas.d.ts.map +1 -0
- package/dist/schemas.js +6 -0
- package/dist/schemas.js.map +1 -0
- 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
|
-
//
|
|
1462
|
-
//
|
|
1463
|
-
//
|
|
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
|
|
1481
|
-
//
|
|
1482
|
-
//
|
|
1483
|
-
//
|
|
1484
|
-
//
|
|
1485
|
-
//
|
|
1486
|
-
//
|
|
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);
|