@memberjunction/core-entities-server 6.2.2 → 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/README.md +19 -0
- package/dist/custom/AnchoredConversationReadSecurityHook.d.ts +1 -14
- package/dist/custom/AnchoredConversationReadSecurityHook.d.ts.map +1 -1
- package/dist/custom/AnchoredConversationReadSecurityHook.js +43 -5
- package/dist/custom/AnchoredConversationReadSecurityHook.js.map +1 -1
- package/dist/custom/ArtifactSecurityHookHelpers.d.ts +223 -0
- package/dist/custom/ArtifactSecurityHookHelpers.d.ts.map +1 -0
- package/dist/custom/ArtifactSecurityHookHelpers.js +1402 -0
- package/dist/custom/ArtifactSecurityHookHelpers.js.map +1 -0
- package/dist/custom/ConversationAndCommentDrivers.d.ts +82 -0
- package/dist/custom/ConversationAndCommentDrivers.d.ts.map +1 -0
- package/dist/custom/ConversationAndCommentDrivers.js +543 -0
- package/dist/custom/ConversationAndCommentDrivers.js.map +1 -0
- package/dist/custom/FieldSuggestionRecordChangeHook.d.ts +17 -0
- package/dist/custom/FieldSuggestionRecordChangeHook.d.ts.map +1 -0
- package/dist/custom/FieldSuggestionRecordChangeHook.js +142 -0
- package/dist/custom/FieldSuggestionRecordChangeHook.js.map +1 -0
- package/dist/custom/MJAIAgentUserPolicyEntityServer.server.d.ts +11 -0
- package/dist/custom/MJAIAgentUserPolicyEntityServer.server.d.ts.map +1 -1
- package/dist/custom/MJAIAgentUserPolicyEntityServer.server.js +41 -0
- package/dist/custom/MJAIAgentUserPolicyEntityServer.server.js.map +1 -1
- package/dist/custom/MJAIBridgeAgentIdentityEntityServer.server.js +2 -2
- package/dist/custom/MJAIBridgeAgentIdentityEntityServer.server.js.map +1 -1
- package/dist/custom/MJAIPromptRunEntityServer.server.d.ts +21 -0
- package/dist/custom/MJAIPromptRunEntityServer.server.d.ts.map +1 -1
- package/dist/custom/MJAIPromptRunEntityServer.server.js +76 -5
- package/dist/custom/MJAIPromptRunEntityServer.server.js.map +1 -1
- package/dist/custom/MJArtifactEntityServer.server.d.ts +38 -0
- package/dist/custom/MJArtifactEntityServer.server.d.ts.map +1 -0
- package/dist/custom/MJArtifactEntityServer.server.js +436 -0
- package/dist/custom/MJArtifactEntityServer.server.js.map +1 -0
- package/dist/custom/MJArtifactGuestShareLinkEntityServer.server.d.ts +32 -0
- package/dist/custom/MJArtifactGuestShareLinkEntityServer.server.d.ts.map +1 -0
- package/dist/custom/MJArtifactGuestShareLinkEntityServer.server.js +434 -0
- package/dist/custom/MJArtifactGuestShareLinkEntityServer.server.js.map +1 -0
- package/dist/custom/MJArtifactPermissionEntityServer.server.d.ts +18 -0
- package/dist/custom/MJArtifactPermissionEntityServer.server.d.ts.map +1 -0
- package/dist/custom/MJArtifactPermissionEntityServer.server.js +194 -0
- package/dist/custom/MJArtifactPermissionEntityServer.server.js.map +1 -0
- package/dist/custom/MJArtifactVersionAttributeEntityServer.server.d.ts +22 -0
- package/dist/custom/MJArtifactVersionAttributeEntityServer.server.d.ts.map +1 -0
- package/dist/custom/MJArtifactVersionAttributeEntityServer.server.js +312 -0
- package/dist/custom/MJArtifactVersionAttributeEntityServer.server.js.map +1 -0
- package/dist/custom/MJArtifactVersionEntityServer.server.d.ts +76 -12
- package/dist/custom/MJArtifactVersionEntityServer.server.d.ts.map +1 -1
- package/dist/custom/MJArtifactVersionEntityServer.server.js +934 -55
- package/dist/custom/MJArtifactVersionEntityServer.server.js.map +1 -1
- package/dist/custom/MJArtifactWorkingStateEntityServer.server.d.ts +42 -0
- package/dist/custom/MJArtifactWorkingStateEntityServer.server.d.ts.map +1 -0
- package/dist/custom/MJArtifactWorkingStateEntityServer.server.js +547 -0
- package/dist/custom/MJArtifactWorkingStateEntityServer.server.js.map +1 -0
- package/dist/custom/MJCollectionArtifactEntityServer.server.d.ts +36 -0
- package/dist/custom/MJCollectionArtifactEntityServer.server.d.ts.map +1 -0
- package/dist/custom/MJCollectionArtifactEntityServer.server.js +533 -0
- package/dist/custom/MJCollectionArtifactEntityServer.server.js.map +1 -0
- package/dist/custom/MJCollectionEntityServer.server.d.ts +23 -0
- package/dist/custom/MJCollectionEntityServer.server.d.ts.map +1 -0
- package/dist/custom/MJCollectionEntityServer.server.js +555 -0
- package/dist/custom/MJCollectionEntityServer.server.js.map +1 -0
- package/dist/custom/MJCollectionPermissionEntityServer.server.d.ts +18 -0
- package/dist/custom/MJCollectionPermissionEntityServer.server.d.ts.map +1 -0
- package/dist/custom/MJCollectionPermissionEntityServer.server.js +196 -0
- package/dist/custom/MJCollectionPermissionEntityServer.server.js.map +1 -0
- package/dist/custom/MJCommentEntityServer.server.d.ts +19 -0
- package/dist/custom/MJCommentEntityServer.server.d.ts.map +1 -0
- package/dist/custom/MJCommentEntityServer.server.js +137 -0
- package/dist/custom/MJCommentEntityServer.server.js.map +1 -0
- package/dist/custom/MJConversationEntityServer.server.d.ts +11 -4
- package/dist/custom/MJConversationEntityServer.server.d.ts.map +1 -1
- package/dist/custom/MJConversationEntityServer.server.js +75 -11
- package/dist/custom/MJConversationEntityServer.server.js.map +1 -1
- package/dist/custom/MJEntityEntityServer.server.d.ts +9 -0
- package/dist/custom/MJEntityEntityServer.server.d.ts.map +1 -1
- package/dist/custom/MJEntityEntityServer.server.js +31 -2
- package/dist/custom/MJEntityEntityServer.server.js.map +1 -1
- package/dist/custom/MJFieldSuggestionEntityServer.server.d.ts +29 -0
- package/dist/custom/MJFieldSuggestionEntityServer.server.d.ts.map +1 -0
- package/dist/custom/MJFieldSuggestionEntityServer.server.js +249 -0
- package/dist/custom/MJFieldSuggestionEntityServer.server.js.map +1 -0
- package/dist/custom/MJGraphEdgeEntityServer.server.d.ts +197 -0
- package/dist/custom/MJGraphEdgeEntityServer.server.d.ts.map +1 -0
- package/dist/custom/MJGraphEdgeEntityServer.server.js +459 -0
- package/dist/custom/MJGraphEdgeEntityServer.server.js.map +1 -0
- package/dist/custom/MJGraphEdgeProviderEntityServer.server.d.ts +22 -0
- package/dist/custom/MJGraphEdgeProviderEntityServer.server.d.ts.map +1 -0
- package/dist/custom/MJGraphEdgeProviderEntityServer.server.js +85 -0
- package/dist/custom/MJGraphEdgeProviderEntityServer.server.js.map +1 -0
- package/dist/custom/MJGraphEdgeTypeEntityServer.server.d.ts +21 -0
- package/dist/custom/MJGraphEdgeTypeEntityServer.server.d.ts.map +1 -0
- package/dist/custom/MJGraphEdgeTypeEntityServer.server.js +88 -0
- package/dist/custom/MJGraphEdgeTypeEntityServer.server.js.map +1 -0
- package/dist/custom/MJListEntityServer.server.d.ts +26 -10
- package/dist/custom/MJListEntityServer.server.d.ts.map +1 -1
- package/dist/custom/MJListEntityServer.server.js +118 -20
- package/dist/custom/MJListEntityServer.server.js.map +1 -1
- package/dist/custom/MJMLEvaluationProtocolEntityServer.server.d.ts +39 -0
- package/dist/custom/MJMLEvaluationProtocolEntityServer.server.d.ts.map +1 -0
- package/dist/custom/MJMLEvaluationProtocolEntityServer.server.js +124 -0
- package/dist/custom/MJMLEvaluationProtocolEntityServer.server.js.map +1 -0
- package/dist/custom/MJMLPredictionUnitEntityServer.server.d.ts +124 -0
- package/dist/custom/MJMLPredictionUnitEntityServer.server.d.ts.map +1 -0
- package/dist/custom/MJMLPredictionUnitEntityServer.server.js +214 -0
- package/dist/custom/MJMLPredictionUnitEntityServer.server.js.map +1 -0
- package/dist/custom/MJMLTrainingPipelineEntityServer.server.d.ts +101 -1
- package/dist/custom/MJMLTrainingPipelineEntityServer.server.d.ts.map +1 -1
- package/dist/custom/MJMLTrainingPipelineEntityServer.server.js +266 -12
- package/dist/custom/MJMLTrainingPipelineEntityServer.server.js.map +1 -1
- package/dist/custom/MJMLTrainingSnapshotEntityServer.server.d.ts +14 -0
- package/dist/custom/MJMLTrainingSnapshotEntityServer.server.d.ts.map +1 -0
- package/dist/custom/MJMLTrainingSnapshotEntityServer.server.js +42 -0
- package/dist/custom/MJMLTrainingSnapshotEntityServer.server.js.map +1 -0
- package/dist/custom/MJProjectEntityServer.server.d.ts +28 -2
- package/dist/custom/MJProjectEntityServer.server.d.ts.map +1 -1
- package/dist/custom/MJProjectEntityServer.server.js +115 -2
- package/dist/custom/MJProjectEntityServer.server.js.map +1 -1
- package/dist/custom/MJQueryEntityServer.server.d.ts +10 -6
- package/dist/custom/MJQueryEntityServer.server.d.ts.map +1 -1
- package/dist/custom/MJQueryEntityServer.server.js +27 -16
- package/dist/custom/MJQueryEntityServer.server.js.map +1 -1
- package/dist/custom/MJScheduledJobEntityServer.server.d.ts +27 -0
- package/dist/custom/MJScheduledJobEntityServer.server.d.ts.map +1 -0
- package/dist/custom/MJScheduledJobEntityServer.server.js +56 -0
- package/dist/custom/MJScheduledJobEntityServer.server.js.map +1 -0
- package/dist/custom/MJScopedNotificationConfigEntityServer.server.d.ts +15 -0
- package/dist/custom/MJScopedNotificationConfigEntityServer.server.d.ts.map +1 -0
- package/dist/custom/MJScopedNotificationConfigEntityServer.server.js +48 -0
- package/dist/custom/MJScopedNotificationConfigEntityServer.server.js.map +1 -0
- package/dist/custom/MJTagEntityServer.server.d.ts +11 -1
- package/dist/custom/MJTagEntityServer.server.d.ts.map +1 -1
- package/dist/custom/MJTagEntityServer.server.js +28 -3
- package/dist/custom/MJTagEntityServer.server.js.map +1 -1
- package/dist/custom/MJTaskDependencyEntityServer.server.d.ts +24 -0
- package/dist/custom/MJTaskDependencyEntityServer.server.d.ts.map +1 -0
- package/dist/custom/MJTaskDependencyEntityServer.server.js +75 -0
- package/dist/custom/MJTaskDependencyEntityServer.server.js.map +1 -0
- package/dist/custom/MJTaskEntityServer.server.d.ts +148 -0
- package/dist/custom/MJTaskEntityServer.server.d.ts.map +1 -0
- package/dist/custom/MJTaskEntityServer.server.js +413 -0
- package/dist/custom/MJTaskEntityServer.server.js.map +1 -0
- package/dist/custom/MJUserEntityServer.server.d.ts +2 -1
- package/dist/custom/MJUserEntityServer.server.d.ts.map +1 -1
- package/dist/custom/MJUserEntityServer.server.js +2 -1
- package/dist/custom/MJUserEntityServer.server.js.map +1 -1
- package/dist/custom/MJUserViewEntityServer.server.d.ts +8 -2
- package/dist/custom/MJUserViewEntityServer.server.d.ts.map +1 -1
- package/dist/custom/MJUserViewEntityServer.server.js +25 -12
- package/dist/custom/MJUserViewEntityServer.server.js.map +1 -1
- package/dist/custom/RestrictedFieldCommentClassifier.d.ts +9 -3
- package/dist/custom/RestrictedFieldCommentClassifier.d.ts.map +1 -1
- package/dist/custom/RestrictedFieldCommentClassifier.js +91 -15
- package/dist/custom/RestrictedFieldCommentClassifier.js.map +1 -1
- package/dist/custom/RestrictedFieldDecision.d.ts +121 -0
- package/dist/custom/RestrictedFieldDecision.d.ts.map +1 -0
- package/dist/custom/RestrictedFieldDecision.js +168 -0
- package/dist/custom/RestrictedFieldDecision.js.map +1 -0
- package/dist/custom/SpreadsheetWorkerEntry.d.ts +25 -0
- package/dist/custom/SpreadsheetWorkerEntry.d.ts.map +1 -0
- package/dist/custom/SpreadsheetWorkerEntry.js +37 -0
- package/dist/custom/SpreadsheetWorkerEntry.js.map +1 -0
- package/dist/custom/SpreadsheetWorkerRunner.d.ts +45 -0
- package/dist/custom/SpreadsheetWorkerRunner.d.ts.map +1 -0
- package/dist/custom/SpreadsheetWorkerRunner.js +243 -0
- package/dist/custom/SpreadsheetWorkerRunner.js.map +1 -0
- package/dist/custom/fieldPermissionDelta.d.ts +15 -1
- package/dist/custom/fieldPermissionDelta.d.ts.map +1 -1
- package/dist/custom/fieldPermissionDelta.js +28 -7
- package/dist/custom/fieldPermissionDelta.js.map +1 -1
- package/dist/custom/fieldPermissionReconciler.d.ts +4 -1
- package/dist/custom/fieldPermissionReconciler.d.ts.map +1 -1
- package/dist/custom/fieldPermissionReconciler.js +4 -2
- package/dist/custom/fieldPermissionReconciler.js.map +1 -1
- package/dist/custom/list-refresh/ListRefreshRoutine.d.ts +40 -0
- package/dist/custom/list-refresh/ListRefreshRoutine.d.ts.map +1 -0
- package/dist/custom/list-refresh/ListRefreshRoutine.js +114 -0
- package/dist/custom/list-refresh/ListRefreshRoutine.js.map +1 -0
- package/dist/custom/query-extraction/childRowWriter.d.ts +2 -2
- package/dist/custom/query-extraction/childRowWriter.d.ts.map +1 -1
- package/dist/custom/query-extraction/childRowWriter.js +7 -2
- package/dist/custom/query-extraction/childRowWriter.js.map +1 -1
- package/dist/custom/query-extraction/describeFacts.d.ts +2 -0
- package/dist/custom/query-extraction/describeFacts.d.ts.map +1 -1
- package/dist/custom/query-extraction/describeFacts.js +17 -10
- package/dist/custom/query-extraction/describeFacts.js.map +1 -1
- package/dist/custom/query-extraction/descriptionPass.d.ts.map +1 -1
- package/dist/custom/query-extraction/descriptionPass.js +4 -1
- package/dist/custom/query-extraction/descriptionPass.js.map +1 -1
- package/dist/custom/query-extraction/extractQuery.js +5 -3
- package/dist/custom/query-extraction/extractQuery.js.map +1 -1
- package/dist/custom/query-extraction/extractionTypes.d.ts +5 -0
- package/dist/custom/query-extraction/extractionTypes.d.ts.map +1 -1
- package/dist/custom/sessionConfigGuard.d.ts +7 -0
- package/dist/custom/sessionConfigGuard.d.ts.map +1 -1
- package/dist/custom/sessionConfigGuard.js +13 -1
- package/dist/custom/sessionConfigGuard.js.map +1 -1
- package/dist/index.d.ts +25 -0
- package/dist/index.d.ts.map +1 -1
- package/dist/index.js +34 -0
- package/dist/index.js.map +1 -1
- package/dist/tsconfig.tsbuildinfo +1 -0
- package/package.json +31 -30
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"MJEntityEntityServer.server.d.ts","sourceRoot":"","sources":["../../src/custom/MJEntityEntityServer.server.ts"],"names":[],"mappings":"AAAA,OAAO,
|
|
1
|
+
{"version":3,"file":"MJEntityEntityServer.server.d.ts","sourceRoot":"","sources":["../../src/custom/MJEntityEntityServer.server.ts"],"names":[],"mappings":"AAAA,OAAO,EAA0B,iBAAiB,EAAgE,MAAM,sBAAsB,CAAC;AAC/I,OAAO,EAAE,sBAAsB,EAAE,MAAM,+BAA+B,CAAC;AAKvE;;;;;;;;;;;;;GAaG;AACH,qBACa,oBAAqB,SAAQ,sBAAsB;IACtC,IAAI,CAAC,OAAO,CAAC,EAAE,iBAAiB,GAAG,OAAO,CAAC,OAAO,CAAC;IAiBzE;;;;;;OAMG;IACH,OAAO,CAAC,wBAAwB;IAOhC;;;;;;;;;;OAUG;YACW,wBAAwB;IAatC;;;OAGG;YACW,+BAA+B;CAuBhD"}
|
|
@@ -4,7 +4,7 @@ var __decorate = (this && this.__decorate) || function (decorators, target, key,
|
|
|
4
4
|
else for (var i = decorators.length - 1; i >= 0; i--) if (d = decorators[i]) r = (c < 3 ? d(r) : c > 3 ? d(target, key, r) : d(target, key)) || r;
|
|
5
5
|
return c > 3 && r && Object.defineProperty(target, key, r), r;
|
|
6
6
|
};
|
|
7
|
-
import { BaseEntity, LogDebug, RunInEntityTransaction } from '@memberjunction/core';
|
|
7
|
+
import { BaseEntity, LogDebug, RunInEntityTransaction, RunView } from '@memberjunction/core';
|
|
8
8
|
import { MJEntityEntityExtended } from '@memberjunction/core-entities';
|
|
9
9
|
import { RegisterClass, UUIDsEqual } from '@memberjunction/global';
|
|
10
10
|
import { ReconcileFieldPermissions } from './fieldPermissionReconciler.js';
|
|
@@ -57,6 +57,10 @@ let MJEntityEntityServer = class MJEntityEntityServer extends MJEntityEntityExte
|
|
|
57
57
|
* Resolves the `EntityInfo` from the provider rather than trusting a captured reference:
|
|
58
58
|
* the delta is computed from the entity's fields and entity-level permissions, and those
|
|
59
59
|
* live on metadata rather than on this record.
|
|
60
|
+
*
|
|
61
|
+
* The existing field-permission rows, though, are read from the database. Metadata can still
|
|
62
|
+
* list rows that were deleted outside this process; trusting it would skip inserting them and
|
|
63
|
+
* leave every field denied to everyone.
|
|
60
64
|
*/
|
|
61
65
|
async snapshotFieldPermissions(provider) {
|
|
62
66
|
const entityInfo = provider.Entities?.find(e => UUIDsEqual(e.ID, this.ID));
|
|
@@ -66,9 +70,34 @@ let MJEntityEntityServer = class MJEntityEntityServer extends MJEntityEntityExte
|
|
|
66
70
|
LogDebug(`[FieldSecurity] '${this.Name}' enabled before its metadata was available; deferring snapshot`);
|
|
67
71
|
return;
|
|
68
72
|
}
|
|
69
|
-
const
|
|
73
|
+
const existingRows = await this.loadExistingFieldPermissionRows(entityInfo);
|
|
74
|
+
const result = await ReconcileFieldPermissions(entityInfo, provider, this.ContextCurrentUser, existingRows);
|
|
70
75
|
LogDebug(`[FieldSecurity] '${this.Name}' enabled; snapshot wrote ${result.Inserted} row(s)`);
|
|
71
76
|
}
|
|
77
|
+
/**
|
|
78
|
+
* The entity's field-permission rows as stored now, bypassing every cache. A failed read
|
|
79
|
+
* throws, which rolls back the flag with it: enabling on a guess could deny every field.
|
|
80
|
+
*/
|
|
81
|
+
async loadExistingFieldPermissionRows(entityInfo) {
|
|
82
|
+
if (entityInfo.Fields.length === 0) {
|
|
83
|
+
return [];
|
|
84
|
+
}
|
|
85
|
+
const fieldIDs = entityInfo.Fields.map(f => `'${f.ID.replace(/'/g, "''")}'`).join(', ');
|
|
86
|
+
const result = await new RunView(this.RunViewProviderToUse).RunView({
|
|
87
|
+
EntityName: 'MJ: Entity Field Permissions',
|
|
88
|
+
ExtraFilter: `EntityFieldID IN (${fieldIDs})`,
|
|
89
|
+
Fields: ['ID', 'EntityFieldID', 'RoleID'],
|
|
90
|
+
ResultType: 'simple',
|
|
91
|
+
BypassCache: true,
|
|
92
|
+
// The entity's UserViewMaxRows would otherwise cap the read, so on an entity with
|
|
93
|
+
// more rules than that the rest would look missing and the delta would re-insert them.
|
|
94
|
+
IgnoreMaxRows: true,
|
|
95
|
+
}, this.ContextCurrentUser);
|
|
96
|
+
if (!result.Success) {
|
|
97
|
+
throw new Error(`Could not read the field permissions of '${entityInfo.Name}' before enabling field-level security: ${result.ErrorMessage}`);
|
|
98
|
+
}
|
|
99
|
+
return result.Results;
|
|
100
|
+
}
|
|
72
101
|
};
|
|
73
102
|
MJEntityEntityServer = __decorate([
|
|
74
103
|
RegisterClass(BaseEntity, 'MJ: Entities')
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"MJEntityEntityServer.server.js","sourceRoot":"","sources":["../../src/custom/MJEntityEntityServer.server.ts"],"names":[],"mappings":";;;;;;AAAA,OAAO,EAAE,UAAU,
|
|
1
|
+
{"version":3,"file":"MJEntityEntityServer.server.js","sourceRoot":"","sources":["../../src/custom/MJEntityEntityServer.server.ts"],"names":[],"mappings":";;;;;;AAAA,OAAO,EAAE,UAAU,EAAoD,QAAQ,EAAE,sBAAsB,EAAE,OAAO,EAAE,MAAM,sBAAsB,CAAC;AAC/I,OAAO,EAAE,sBAAsB,EAAE,MAAM,+BAA+B,CAAC;AACvE,OAAO,EAAE,aAAa,EAAE,UAAU,EAAE,MAAM,wBAAwB,CAAC;AACnE,OAAO,EAAE,yBAAyB,EAAE,MAAM,6BAA6B,CAAC;AAGxE;;;;;;;;;;;;;GAaG;AAEI,IAAM,oBAAoB,GAA1B,MAAM,oBAAqB,SAAQ,sBAAsB;IAC5C,KAAK,CAAC,IAAI,CAAC,OAA2B;QAClD,IAAI,CAAC,IAAI,CAAC,wBAAwB,EAAE,EAAE,CAAC;YACnC,OAAO,KAAK,CAAC,IAAI,CAAC,OAAO,CAAC,CAAC;QAC/B,CAAC;QAED,MAAM,QAAQ,GAAG,IAAI,CAAC,aAA6C,CAAC;QACpE,OAAO,sBAAsB,CAAC,IAAI,CAAC,aAAa,EAAE,KAAK,IAAI,EAAE;YACzD,6EAA6E;YAC7E,4CAA4C;YAC5C,IAAI,CAAC,CAAC,MAAM,KAAK,CAAC,IAAI,CAAC,OAAO,CAAC,CAAC,EAAE,CAAC;gBAC/B,OAAO,KAAK,CAAC;YACjB,CAAC;YACD,MAAM,IAAI,CAAC,wBAAwB,CAAC,QAAQ,CAAC,CAAC;YAC9C,OAAO,IAAI,CAAC;QAChB,CAAC,CAAC,CAAC;IACP,CAAC;IAED;;;;;;OAMG;IACK,wBAAwB;QAC5B,IAAI,CAAC,IAAI,CAAC,wBAAwB,EAAE,CAAC;YACj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AC,CAAC,OAAO,CAC/D;YACI,UAAU,EAAE,8BAA8B;YAC1C,WAAW,EAAE,qBAAqB,QAAQ,GAAG;YAC7C,MAAM,EAAE,CAAC,IAAI,EAAE,eAAe,EAAE,QAAQ,CAAC;YACzC,UAAU,EAAE,QAAQ;YACpB,WAAW,EAAE,IAAI;YACjB,kFAAkF;YAClF,uFAAuF;YACvF,aAAa,EAAE,IAAI;SACtB,EACD,IAAI,CAAC,kBAAkB,CAC1B,CAAC;QACF,IAAI,CAAC,MAAM,CAAC,OAAO,EAAE,CAAC;YAClB,MAAM,IAAI,KAAK,CAAC,4CAA4C,UAAU,CAAC,IAAI,2CAA2C,MAAM,CAAC,YAAY,EAAE,CAAC,CAAC;QACjJ,CAAC;QACD,OAAO,MAAM,CAAC,OAAO,CAAC;IAC1B,CAAC;CACJ,CAAA;AAnFY,oBAAoB;IADhC,aAAa,CAAC,UAAU,EAAE,cAAc,CAAC;GAC7B,oBAAoB,CAmFhC"}
|
|
@@ -0,0 +1,29 @@
|
|
|
1
|
+
import { EntityDeleteOptions, EntitySaveOptions, ValidationResult } from '@memberjunction/core';
|
|
2
|
+
import { MJFieldSuggestionEntity } from '@memberjunction/core-entities';
|
|
3
|
+
/**
|
|
4
|
+
* Server-side `MJ: Field Suggestions` entity subclass.
|
|
5
|
+
*
|
|
6
|
+
* Coordinates the 2-level IS-A chain (`FieldSuggestion -> Comment -> Conversation`) with
|
|
7
|
+
* {@link CommentTypeDriver} (`FieldSuggestionCommentDriver`):
|
|
8
|
+
* - Stamps `TypeID = COMMENT`, `CommentTypeID = FIELD_SUGGESTION`, and `AnchorType = 'Field'`
|
|
9
|
+
* on new records when omitted.
|
|
10
|
+
* - Routes `Outcome` transitions (`null -> 'Accepted'`, `null -> 'Rejected'`, `null -> 'Superseded'`)
|
|
11
|
+
* through the configured `CommentTypeDriver` BEFORE `super.Save(options)` so mutations to
|
|
12
|
+
* inherited `Conversation` fields (`IsResolved`, `ResolvedByUserID`, `ResolvedAt`) flush in
|
|
13
|
+
* the same atomic IS-A chain transaction, and any target-record permission/validation failure
|
|
14
|
+
* aborts cleanly before persisting `Outcome`.
|
|
15
|
+
* - Supersedes older pending suggestions on the same `(LinkedEntityID, LinkedRecordID, AnchorKey)`
|
|
16
|
+
* after a new pending suggestion commits.
|
|
17
|
+
*/
|
|
18
|
+
export declare class MJFieldSuggestionEntityServer extends MJFieldSuggestionEntity {
|
|
19
|
+
Validate(): ValidationResult;
|
|
20
|
+
ValidateAsync(): Promise<ValidationResult>;
|
|
21
|
+
Save(options?: EntitySaveOptions): Promise<boolean>;
|
|
22
|
+
Delete(options?: EntityDeleteOptions): Promise<boolean>;
|
|
23
|
+
private normalizeAnchorKeyToCanonicalFieldName;
|
|
24
|
+
private resolveCommentTypeDriverSync;
|
|
25
|
+
private resolveCommentTypeDriver;
|
|
26
|
+
private recordSaveDenied;
|
|
27
|
+
private recordDeleteDenied;
|
|
28
|
+
}
|
|
29
|
+
//# sourceMappingURL=MJFieldSuggestionEntityServer.server.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"MJFieldSuggestionEntityServer.server.d.ts","sourceRoot":"","sources":["../../src/custom/MJFieldSuggestionEntityServer.server.ts"],"names":[],"mappings":"AAAA,OAAO,EAGH,mBAAmB,EACnB,iBAAiB,EAQjB,gBAAgB,EAEnB,MAAM,sBAAsB,CAAC;AAC9B,OAAO,EAOH,uBAAuB,EAC1B,MAAM,+BAA+B,CAAC;AAwBvC;;;;;;;;;;;;;;GAcG;AACH,qBACa,6BAA8B,SAAQ,uBAAuB;IACtD,QAAQ,IAAI,gBAAgB;IAyBtB,aAAa,IAAI,OAAO,CAAC,gBAAgB,CAAC;IAS1C,IAAI,CAAC,OAAO,CAAC,EAAE,iBAAiB,GAAG,OAAO,CAAC,OAAO,CAAC;IA0InD,MAAM,CAAC,OAAO,CAAC,EAAE,mBAAmB,GAAG,OAAO,CAAC,OAAO,CAAC;IAgB7E,OAAO,CAAC,sCAAsC;IAwB9C,OAAO,CAAC,4BAA4B;YAYtB,wBAAwB;IAUtC,OAAO,CAAC,gBAAgB;IAUxB,OAAO,CAAC,kBAAkB;CAS7B"}
|
|
@@ -0,0 +1,249 @@
|
|
|
1
|
+
var __decorate = (this && this.__decorate) || function (decorators, target, key, desc) {
|
|
2
|
+
var c = arguments.length, r = c < 3 ? target : desc === null ? desc = Object.getOwnPropertyDescriptor(target, key) : desc, d;
|
|
3
|
+
if (typeof Reflect === "object" && typeof Reflect.decorate === "function") r = Reflect.decorate(decorators, target, key, desc);
|
|
4
|
+
else for (var i = decorators.length - 1; i >= 0; i--) if (d = decorators[i]) r = (c < 3 ? d(r) : c > 3 ? d(target, key, r) : d(target, key)) || r;
|
|
5
|
+
return c > 3 && r && Object.defineProperty(target, key, r), r;
|
|
6
|
+
};
|
|
7
|
+
import { BaseEntity, BaseEntityResult, LogError, Metadata, ValidationErrorInfo, ValidationErrorType, WellKnownUserSource, } from '@memberjunction/core';
|
|
8
|
+
import { BUILT_IN_COMMENT_TYPE_IDS, BUILT_IN_CONVERSATION_TYPE_IDS, COMMENT_TYPE_CODES, CONVERSATION_TYPE_CODES, ConversationEngine, MJFieldSuggestionEntity, } from '@memberjunction/core-entities';
|
|
9
|
+
import { MJGlobal, RegisterClass, UUIDsEqual } from '@memberjunction/global';
|
|
10
|
+
import { BeginSuggestionAcceptInFlight, CommentTypeDriver, EndSuggestionAcceptInFlight, FieldSuggestionCommentDriver, } from './ConversationAndCommentDrivers.js';
|
|
11
|
+
const IMMUTABLE_PROPOSAL_FIELDS = [
|
|
12
|
+
'SuggestedValue',
|
|
13
|
+
'Source',
|
|
14
|
+
'Confidence',
|
|
15
|
+
'LinkedEntityID',
|
|
16
|
+
'LinkedRecordID',
|
|
17
|
+
'AnchorType',
|
|
18
|
+
'AnchorKey',
|
|
19
|
+
];
|
|
20
|
+
/**
|
|
21
|
+
* Server-side `MJ: Field Suggestions` entity subclass.
|
|
22
|
+
*
|
|
23
|
+
* Coordinates the 2-level IS-A chain (`FieldSuggestion -> Comment -> Conversation`) with
|
|
24
|
+
* {@link CommentTypeDriver} (`FieldSuggestionCommentDriver`):
|
|
25
|
+
* - Stamps `TypeID = COMMENT`, `CommentTypeID = FIELD_SUGGESTION`, and `AnchorType = 'Field'`
|
|
26
|
+
* on new records when omitted.
|
|
27
|
+
* - Routes `Outcome` transitions (`null -> 'Accepted'`, `null -> 'Rejected'`, `null -> 'Superseded'`)
|
|
28
|
+
* through the configured `CommentTypeDriver` BEFORE `super.Save(options)` so mutations to
|
|
29
|
+
* inherited `Conversation` fields (`IsResolved`, `ResolvedByUserID`, `ResolvedAt`) flush in
|
|
30
|
+
* the same atomic IS-A chain transaction, and any target-record permission/validation failure
|
|
31
|
+
* aborts cleanly before persisting `Outcome`.
|
|
32
|
+
* - Supersedes older pending suggestions on the same `(LinkedEntityID, LinkedRecordID, AnchorKey)`
|
|
33
|
+
* after a new pending suggestion commits.
|
|
34
|
+
*/
|
|
35
|
+
let MJFieldSuggestionEntityServer = class MJFieldSuggestionEntityServer extends MJFieldSuggestionEntity {
|
|
36
|
+
Validate() {
|
|
37
|
+
const result = super.Validate();
|
|
38
|
+
const driver = this.resolveCommentTypeDriverSync();
|
|
39
|
+
if (driver?.Validate) {
|
|
40
|
+
const maybePromise = driver.Validate(this, result, this.ContextCurrentUser ?? null);
|
|
41
|
+
if (maybePromise instanceof Promise) {
|
|
42
|
+
maybePromise.catch((err) => {
|
|
43
|
+
LogError(`MJFieldSuggestionEntityServer: async driver Validate rejected during synchronous Validate(): ${err instanceof Error ? err.message : String(err)}`);
|
|
44
|
+
});
|
|
45
|
+
const msg = 'Field suggestion comment-type driver returned an asynchronous Promise during synchronous Validate(); call ValidateAsync() or Save() instead.';
|
|
46
|
+
LogError(msg);
|
|
47
|
+
result.Success = false;
|
|
48
|
+
result.Errors.push(new ValidationErrorInfo('ID', msg, this.ID, ValidationErrorType.Failure));
|
|
49
|
+
}
|
|
50
|
+
}
|
|
51
|
+
return result;
|
|
52
|
+
}
|
|
53
|
+
async ValidateAsync() {
|
|
54
|
+
const result = await super.ValidateAsync();
|
|
55
|
+
const driver = await this.resolveCommentTypeDriver();
|
|
56
|
+
if (driver?.Validate) {
|
|
57
|
+
await driver.Validate(this, result, this.ContextCurrentUser ?? null);
|
|
58
|
+
}
|
|
59
|
+
return result;
|
|
60
|
+
}
|
|
61
|
+
async Save(options) {
|
|
62
|
+
const wasNew = !this.IsSaved;
|
|
63
|
+
if (!this.TypeID || (!wasNew ? false : UUIDsEqual(this.TypeID, BUILT_IN_CONVERSATION_TYPE_IDS.CHAT))) {
|
|
64
|
+
this.TypeID =
|
|
65
|
+
ConversationEngine.Instance.ResolveConversationTypeID(CONVERSATION_TYPE_CODES.COMMENT) ??
|
|
66
|
+
BUILT_IN_CONVERSATION_TYPE_IDS.COMMENT;
|
|
67
|
+
}
|
|
68
|
+
const fieldSuggestionTypeId = ConversationEngine.Instance.ResolveCommentTypeID(COMMENT_TYPE_CODES.FIELD_SUGGESTION) ??
|
|
69
|
+
BUILT_IN_COMMENT_TYPE_IDS.FIELD_SUGGESTION;
|
|
70
|
+
if (!this.CommentTypeID || UUIDsEqual(this.CommentTypeID, BUILT_IN_COMMENT_TYPE_IDS.COMMENT)) {
|
|
71
|
+
this.CommentTypeID = fieldSuggestionTypeId;
|
|
72
|
+
}
|
|
73
|
+
if (!this.AnchorType) {
|
|
74
|
+
this.AnchorType = 'Field';
|
|
75
|
+
}
|
|
76
|
+
this.normalizeAnchorKeyToCanonicalFieldName();
|
|
77
|
+
const provider = this.ProviderToUse ?? Metadata.Provider;
|
|
78
|
+
const contextUser = this.ContextCurrentUser ?? provider?.CurrentUser ?? null;
|
|
79
|
+
const driver = await this.resolveCommentTypeDriver();
|
|
80
|
+
// Inspect Outcome transition before super.Save() so OnAccept / OnReject / OnSupersede can validate
|
|
81
|
+
// permissions, apply target-record writes, and stamp IsResolved/ResolvedByUserID/ResolvedAt
|
|
82
|
+
// onto the parent Conversation before the IS-A chain writes.
|
|
83
|
+
const outcomeField = this.GetFieldByName('Outcome');
|
|
84
|
+
const prevOutcome = (wasNew ? null : outcomeField?.OldValue ?? null);
|
|
85
|
+
const nextOutcome = this.Outcome;
|
|
86
|
+
if (!wasNew && prevOutcome !== null && prevOutcome !== nextOutcome) {
|
|
87
|
+
this.recordSaveDenied(`Field suggestion Outcome is already '${prevOutcome}' and cannot be changed to '${nextOutcome ?? 'null'}'.`);
|
|
88
|
+
return false;
|
|
89
|
+
}
|
|
90
|
+
if (!wasNew && !options?.ReplayOnly) {
|
|
91
|
+
const mutatedProposalField = IMMUTABLE_PROPOSAL_FIELDS.find((fieldName) => this.GetFieldByName(fieldName)?.Dirty === true);
|
|
92
|
+
if (mutatedProposalField) {
|
|
93
|
+
const isSystem = WellKnownUserSource.Instance.IsSystemUser(contextUser);
|
|
94
|
+
const isAuthor = Boolean(contextUser && this.UserID && UUIDsEqual(contextUser.ID, this.UserID));
|
|
95
|
+
if (prevOutcome !== null || (!isSystem && !isAuthor)) {
|
|
96
|
+
this.recordSaveDenied(prevOutcome !== null
|
|
97
|
+
? `Cannot modify '${mutatedProposalField}' after field suggestion Outcome is '${prevOutcome}'.`
|
|
98
|
+
: `Only the suggestion author or system may modify '${mutatedProposalField}' on an existing field suggestion.`);
|
|
99
|
+
return false;
|
|
100
|
+
}
|
|
101
|
+
}
|
|
102
|
+
}
|
|
103
|
+
if (prevOutcome !== nextOutcome && nextOutcome === 'Accepted' && !options?.ReplayOnly) {
|
|
104
|
+
const commentParent = this.ISAParent && this.ISAParent.EntityInfo?.Name === 'MJ: Comments'
|
|
105
|
+
? this.ISAParent
|
|
106
|
+
: null;
|
|
107
|
+
const txProvider = this.ProviderToUse;
|
|
108
|
+
const acceptScope = txProvider?.SupportsEntityTransactions === true &&
|
|
109
|
+
typeof txProvider.BeginEntityTransaction === 'function'
|
|
110
|
+
? await txProvider.BeginEntityTransaction()
|
|
111
|
+
: null;
|
|
112
|
+
BeginSuggestionAcceptInFlight(this.ID);
|
|
113
|
+
try {
|
|
114
|
+
await driver.OnAccept({
|
|
115
|
+
Provider: provider,
|
|
116
|
+
ContextUser: contextUser,
|
|
117
|
+
Comment: commentParent,
|
|
118
|
+
ExtensionEntity: this,
|
|
119
|
+
});
|
|
120
|
+
const saved = await super.Save(options);
|
|
121
|
+
if (!saved) {
|
|
122
|
+
await acceptScope?.Rollback();
|
|
123
|
+
return false;
|
|
124
|
+
}
|
|
125
|
+
await acceptScope?.Commit();
|
|
126
|
+
return true;
|
|
127
|
+
}
|
|
128
|
+
catch (err) {
|
|
129
|
+
await acceptScope?.Rollback().catch((rollbackErr) => {
|
|
130
|
+
LogError(`MJFieldSuggestionEntityServer: failed to roll back accept transaction for suggestion '${this.ID}': ${rollbackErr instanceof Error ? rollbackErr.message : String(rollbackErr)}`);
|
|
131
|
+
});
|
|
132
|
+
const message = err instanceof Error ? err.message : String(err);
|
|
133
|
+
this.recordSaveDenied(message);
|
|
134
|
+
return false;
|
|
135
|
+
}
|
|
136
|
+
finally {
|
|
137
|
+
EndSuggestionAcceptInFlight(this.ID);
|
|
138
|
+
}
|
|
139
|
+
}
|
|
140
|
+
if (prevOutcome !== nextOutcome && nextOutcome !== null && !options?.ReplayOnly) {
|
|
141
|
+
const commentParent = this.ISAParent && this.ISAParent.EntityInfo?.Name === 'MJ: Comments'
|
|
142
|
+
? this.ISAParent
|
|
143
|
+
: null;
|
|
144
|
+
try {
|
|
145
|
+
if (nextOutcome === 'Rejected') {
|
|
146
|
+
await driver.OnReject({
|
|
147
|
+
Provider: provider,
|
|
148
|
+
ContextUser: contextUser,
|
|
149
|
+
Comment: commentParent,
|
|
150
|
+
ExtensionEntity: this,
|
|
151
|
+
});
|
|
152
|
+
}
|
|
153
|
+
else if (nextOutcome === 'Superseded') {
|
|
154
|
+
await driver.OnSupersede({
|
|
155
|
+
Provider: provider,
|
|
156
|
+
ContextUser: contextUser,
|
|
157
|
+
Comment: commentParent,
|
|
158
|
+
ExtensionEntity: this,
|
|
159
|
+
});
|
|
160
|
+
}
|
|
161
|
+
}
|
|
162
|
+
catch (err) {
|
|
163
|
+
const message = err instanceof Error ? err.message : String(err);
|
|
164
|
+
this.recordSaveDenied(message);
|
|
165
|
+
return false;
|
|
166
|
+
}
|
|
167
|
+
}
|
|
168
|
+
const saved = await super.Save(options);
|
|
169
|
+
if (!saved) {
|
|
170
|
+
return false;
|
|
171
|
+
}
|
|
172
|
+
if (wasNew && this.Outcome === null && !options?.ReplayOnly && driver instanceof FieldSuggestionCommentDriver) {
|
|
173
|
+
await driver.SupersedeOlderPendingSuggestions(provider, this, contextUser);
|
|
174
|
+
}
|
|
175
|
+
return true;
|
|
176
|
+
}
|
|
177
|
+
async Delete(options) {
|
|
178
|
+
if (!options?.ReplayOnly) {
|
|
179
|
+
const provider = this.ProviderToUse ?? Metadata.Provider;
|
|
180
|
+
const contextUser = this.ContextCurrentUser ?? provider?.CurrentUser ?? null;
|
|
181
|
+
const isSystemOrOwner = WellKnownUserSource.Instance.IsSystemUser(contextUser) || contextUser?.Type === 'Owner';
|
|
182
|
+
const isAuthor = Boolean(contextUser && this.UserID && UUIDsEqual(contextUser.ID, this.UserID));
|
|
183
|
+
if (!isSystemOrOwner && this.UserID && !isAuthor) {
|
|
184
|
+
this.recordDeleteDenied('Only the author or a system administrator may delete a field suggestion.');
|
|
185
|
+
return false;
|
|
186
|
+
}
|
|
187
|
+
}
|
|
188
|
+
return super.Delete(options);
|
|
189
|
+
}
|
|
190
|
+
normalizeAnchorKeyToCanonicalFieldName() {
|
|
191
|
+
const rawKey = this.AnchorKey?.trim();
|
|
192
|
+
if (!rawKey || !this.LinkedEntityID) {
|
|
193
|
+
return;
|
|
194
|
+
}
|
|
195
|
+
const provider = this.ProviderToUse ?? Metadata.Provider;
|
|
196
|
+
const targetEntityInfo = (typeof provider?.EntityByID === 'function'
|
|
197
|
+
? provider.EntityByID(this.LinkedEntityID)
|
|
198
|
+
: undefined) ??
|
|
199
|
+
provider?.Entities?.find((e) => UUIDsEqual(e.ID, this.LinkedEntityID)) ??
|
|
200
|
+
null;
|
|
201
|
+
if (!targetEntityInfo) {
|
|
202
|
+
return;
|
|
203
|
+
}
|
|
204
|
+
const matched = targetEntityInfo.Fields.find((f) => f.Name.toLowerCase() === rawKey.toLowerCase());
|
|
205
|
+
if (matched && matched.Name !== this.AnchorKey) {
|
|
206
|
+
this.AnchorKey = matched.Name;
|
|
207
|
+
}
|
|
208
|
+
}
|
|
209
|
+
resolveCommentTypeDriverSync() {
|
|
210
|
+
const commentType = this.CommentTypeID
|
|
211
|
+
? ConversationEngine.Instance.CommentTypeByID(this.CommentTypeID)
|
|
212
|
+
: undefined;
|
|
213
|
+
const driverClassName = commentType?.DriverClass?.trim() || 'FieldSuggestionCommentDriver';
|
|
214
|
+
const instance = MJGlobal.Instance.ClassFactory.CreateInstance(CommentTypeDriver, driverClassName);
|
|
215
|
+
return instance ?? new FieldSuggestionCommentDriver();
|
|
216
|
+
}
|
|
217
|
+
async resolveCommentTypeDriver() {
|
|
218
|
+
if (this.ISAParent && typeof this.ISAParent.ResolveSubtypeDriver === 'function') {
|
|
219
|
+
const parentDriver = await this.ISAParent.ResolveSubtypeDriver();
|
|
220
|
+
if (parentDriver instanceof CommentTypeDriver) {
|
|
221
|
+
return parentDriver;
|
|
222
|
+
}
|
|
223
|
+
}
|
|
224
|
+
return this.resolveCommentTypeDriverSync();
|
|
225
|
+
}
|
|
226
|
+
recordSaveDenied(message) {
|
|
227
|
+
const entry = new BaseEntityResult();
|
|
228
|
+
entry.Success = false;
|
|
229
|
+
entry.Type = this.IsSaved ? 'update' : 'create';
|
|
230
|
+
entry.Message = message;
|
|
231
|
+
entry.StartedAt = new Date();
|
|
232
|
+
entry.EndedAt = new Date();
|
|
233
|
+
this.RegisterResultHistoryEntry(entry);
|
|
234
|
+
}
|
|
235
|
+
recordDeleteDenied(message) {
|
|
236
|
+
const entry = new BaseEntityResult();
|
|
237
|
+
entry.Success = false;
|
|
238
|
+
entry.Type = 'delete';
|
|
239
|
+
entry.Message = message;
|
|
240
|
+
entry.StartedAt = new Date();
|
|
241
|
+
entry.EndedAt = new Date();
|
|
242
|
+
this.RegisterResultHistoryEntry(entry);
|
|
243
|
+
}
|
|
244
|
+
};
|
|
245
|
+
MJFieldSuggestionEntityServer = __decorate([
|
|
246
|
+
RegisterClass(BaseEntity, 'MJ: Field Suggestions')
|
|
247
|
+
], MJFieldSuggestionEntityServer);
|
|
248
|
+
export { MJFieldSuggestionEntityServer };
|
|
249
|
+
//# sourceMappingURL=MJFieldSuggestionEntityServer.server.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"MJFieldSuggestionEntityServer.server.js","sourceRoot":"","sources":["../../src/custom/MJFieldSuggestionEntityServer.server.ts"],"names":[],"mappings":";;;;;;AAAA,OAAO,EACH,UAAU,EACV,gBAAgB,EAMhB,QAAQ,EACR,QAAQ,EACR,mBAAmB,EACnB,mBAAmB,EAEnB,mBAAmB,GACtB,MAAM,sBAAsB,CAAC;AAC9B,OAAO,EACH,yBAAyB,EACzB,8BAA8B,EAC9B,kBAAkB,EAClB,uBAAuB,EACvB,kBAAkB,EAElB,uBAAuB,GAC1B,MAAM,+BAA+B,CAAC;AACvC,OAAO,EAAE,QAAQ,EAAE,aAAa,EAAE,UAAU,EAAE,MAAM,wBAAwB,CAAC;AAC7E,OAAO,EACH,6BAA6B,EAC7B,iBAAiB,EACjB,2BAA2B,EAC3B,4BAA4B,GAC/B,MAAM,iCAAiC,CAAC;AAOzC,MAAM,yBAAyB,GAAG;IAC9B,gBAAgB;IAChB,QAAQ;IACR,YAAY;IACZ,gBAAgB;IAChB,gBAAgB;IAChB,YAAY;IACZ,WAAW;CACL,CAAC;AAEX;;;;;;;;;;;;;;GAcG;AAEI,IAAM,6BAA6B,GAAnC,MAAM,6BAA8B,SAAQ,uBAAuB;IACtD,QAAQ;QACpB,MAAM,MAAM,GAAG,KAAK,CAAC,QAAQ,EAAE,CAAC;QAChC,MAAM,MAAM,GAAG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,aAAa,CAAC,UAAU,EAAE,uBAAuB,CAAC;GACtC,6BAA6B,CA8PzC"}
|
|
@@ -0,0 +1,197 @@
|
|
|
1
|
+
import { AuthorizationInfo, EntityDeleteOptions, IMetadataProvider, UserInfo, ValidationErrorInfo, ValidationResult } from '@memberjunction/core';
|
|
2
|
+
import { MJGraphEdgeEntity, MJGraphEdgeTypeEntity } from '@memberjunction/core-entities';
|
|
3
|
+
/** Maximum character length permitted for `SourceRecordID` and `TargetRecordID`. */
|
|
4
|
+
export declare const MAX_GRAPH_EDGE_RECORD_ID_LENGTH = 400;
|
|
5
|
+
/** Named authorization required for every approval decision on `MJ: Graph Edges` (see {@link EvaluateGraphEdgeApproval}). */
|
|
6
|
+
export declare const GRAPH_APPROVE_EDGES_AUTHORIZATION = "Graph: Approve Edges";
|
|
7
|
+
/**
|
|
8
|
+
* Input snapshot of a `MJ: Graph Edges` row evaluated by {@link ValidateGraphEdgeInvariants}.
|
|
9
|
+
*/
|
|
10
|
+
export interface GraphEdgeValidationInput {
|
|
11
|
+
readonly GraphID: string | null | undefined;
|
|
12
|
+
readonly EdgeTypeID: string | null | undefined;
|
|
13
|
+
readonly SourceEntityID: string | null | undefined;
|
|
14
|
+
readonly SourceRecordID: string | null | undefined;
|
|
15
|
+
readonly TargetEntityID: string | null | undefined;
|
|
16
|
+
readonly TargetRecordID: string | null | undefined;
|
|
17
|
+
}
|
|
18
|
+
/**
|
|
19
|
+
* Normalized endpoints for an undirected edge (lower `<entityID>|<recordID>` node key first).
|
|
20
|
+
*/
|
|
21
|
+
export interface CanonicalGraphEdgeEndpoints {
|
|
22
|
+
readonly SourceEntityID: string;
|
|
23
|
+
readonly SourceRecordID: string;
|
|
24
|
+
readonly TargetEntityID: string;
|
|
25
|
+
readonly TargetRecordID: string;
|
|
26
|
+
readonly Swapped: boolean;
|
|
27
|
+
}
|
|
28
|
+
/**
|
|
29
|
+
* Canonicalize endpoints for an undirected edge (`IsDirected === false`) so the lower
|
|
30
|
+
* `<entityID>|<recordID>` key always occupies the `Source*` columns.
|
|
31
|
+
*/
|
|
32
|
+
export declare function CanonicalizeUndirectedEdgeEndpoints(sourceEntityID: string, sourceRecordID: string, targetEntityID: string, targetRecordID: string): CanonicalGraphEdgeEndpoints;
|
|
33
|
+
/**
|
|
34
|
+
* Pure invariant check for a `MJ: Graph Edges` record (Phase G1.3):
|
|
35
|
+
* 1. No self-loop (`SourceEntityID === TargetEntityID` and `SourceRecordID === TargetRecordID`).
|
|
36
|
+
* 2. `SourceRecordID` and `TargetRecordID` are non-empty and at most 400 characters.
|
|
37
|
+
* 3. `EdgeTypeID` resolves to an edge type with `AllowStored === true` (refuses provider-only types)
|
|
38
|
+
* that belongs to the edge's `GraphID` or is global (`GraphID === null`).
|
|
39
|
+
* 4. `SourceEntityID` and `TargetEntityID` satisfy `GraphEngine.ValidateEdgeEndpoint` constraints.
|
|
40
|
+
*
|
|
41
|
+
* Who may create an edge that starts `Approved` is not an invariant of the row: it is the approval
|
|
42
|
+
* gate's decision ({@link EvaluateGraphEdgeApproval}), and it applies to every `Origin`.
|
|
43
|
+
*/
|
|
44
|
+
export declare function ValidateGraphEdgeInvariants(input: GraphEdgeValidationInput, edgeType: Pick<MJGraphEdgeTypeEntity, 'ID' | 'Name' | 'GraphID' | 'IsDirected' | 'AllowStored'> | undefined, validateEndpoint?: (edgeTypeId: string, side: 'Source' | 'Target', entityId: string) => boolean): ValidationErrorInfo[];
|
|
45
|
+
/**
|
|
46
|
+
* Inputs to {@link EvaluateGraphEdgeApproval}: what is being saved, by whom, and the authorizations
|
|
47
|
+
* the caller's provider holds.
|
|
48
|
+
*/
|
|
49
|
+
export interface GraphEdgeApprovalInput {
|
|
50
|
+
/** `true` for an update of an existing row, `false` for a create. */
|
|
51
|
+
readonly IsSaved: boolean;
|
|
52
|
+
/** The `Origin` being saved. */
|
|
53
|
+
readonly Origin: MJGraphEdgeEntity['Origin'] | null | undefined;
|
|
54
|
+
/** The stored `Status` before this save (the field's `OldValue`); ignored for a create. */
|
|
55
|
+
readonly PreviousStatus: MJGraphEdgeEntity['Status'] | null | undefined;
|
|
56
|
+
/** The `Status` being saved. */
|
|
57
|
+
readonly NextStatus: MJGraphEdgeEntity['Status'] | null | undefined;
|
|
58
|
+
/**
|
|
59
|
+
* `true` when an update changes what the edge connects or means: `GraphID`, `EdgeTypeID`, or any
|
|
60
|
+
* `Source*` / `Target*` column. Re-pointing an approved edge approves a different edge.
|
|
61
|
+
*/
|
|
62
|
+
readonly IdentityChanged: boolean;
|
|
63
|
+
/**
|
|
64
|
+
* `true` when an update changes what the edge says: `Description`, `Weight`, `Origin`, `Attributes`
|
|
65
|
+
* or `Confidence`. Rewriting an approved edge's content approves content nobody reviewed.
|
|
66
|
+
*/
|
|
67
|
+
readonly ContentChanged: boolean;
|
|
68
|
+
readonly User: UserInfo | undefined;
|
|
69
|
+
readonly Authorizations: AuthorizationInfo[] | undefined;
|
|
70
|
+
/**
|
|
71
|
+
* `true` when the save runs inside the Content Pipeline's {@link GRAPH_PIPELINE_EDGE_APPROVAL_OPERATION}
|
|
72
|
+
* server operation scope for this caller ({@link IsInGraphPipelineApprovalScope}).
|
|
73
|
+
*/
|
|
74
|
+
readonly InPipelineApprovalScope: boolean;
|
|
75
|
+
}
|
|
76
|
+
/**
|
|
77
|
+
* Result of {@link EvaluateGraphEdgeApproval}.
|
|
78
|
+
*/
|
|
79
|
+
export interface GraphEdgeApprovalVerdict {
|
|
80
|
+
readonly Error: ValidationErrorInfo | null;
|
|
81
|
+
/** `true` when the save is an approval decision that passed, so the reviewer is stamped. */
|
|
82
|
+
readonly ShouldStampReview: boolean;
|
|
83
|
+
}
|
|
84
|
+
/**
|
|
85
|
+
* True when saving these values is an approval decision that `Graph: Approve Edges` must authorize:
|
|
86
|
+
* - creating an edge that does not start out `Proposed` or `Rejected`, whatever its `Origin`. A null `Status` counts:
|
|
87
|
+
* `spCreateGraphEdge` stores the column default, `Approved`;
|
|
88
|
+
* - changing `Status` to `Approved` or `Rejected`, or away from `Approved` or `Rejected` (a review decision, or undoing one);
|
|
89
|
+
* - changing what an `Approved` edge connects (`IdentityChanged`) or says (`ContentChanged`).
|
|
90
|
+
*/
|
|
91
|
+
export declare function GraphEdgeSaveNeedsApproval(input: GraphEdgeApprovalInput): boolean;
|
|
92
|
+
/**
|
|
93
|
+
* True when this save is the Content Pipeline creating an `Inferred` edge its content source's
|
|
94
|
+
* `GraphOverlay` policy approves: a create, `Origin = 'Inferred'`, `Status = 'Approved'`, inside the
|
|
95
|
+
* {@link GRAPH_PIPELINE_EDGE_APPROVAL_OPERATION} scope. Nothing else (a `Declared` edge, a status
|
|
96
|
+
* change, a re-pointed or edited edge) is covered by the pipeline's policy.
|
|
97
|
+
*/
|
|
98
|
+
export declare function IsPipelinePolicyApprovedCreate(input: GraphEdgeApprovalInput): boolean;
|
|
99
|
+
/**
|
|
100
|
+
* Pure fail-closed gate for approval decisions on `MJ: Graph Edges` (see {@link GraphEdgeSaveNeedsApproval}).
|
|
101
|
+
*
|
|
102
|
+
* The caller must hold `Graph: Approve Edges` (or an ancestor) through `EvaluateAuthorizationChecks`,
|
|
103
|
+
* MJ's role-based evaluation, whatever the edge's `Origin`. There is no bypass for any user type: an
|
|
104
|
+
* authorization that is not seeded, an empty authorization list, or a missing caller all deny,
|
|
105
|
+
* because each of them means nobody has been granted the right.
|
|
106
|
+
*
|
|
107
|
+
* The one exception is {@link IsPipelinePolicyApprovedCreate}. The Content Pipeline `Graph` stage
|
|
108
|
+
* (`EntityGraphOverlayStore.UpsertEdges`) saves as the run's user: the scheduler's user, whoever ran
|
|
109
|
+
* the Record Process on demand, or whoever uploaded the document, most of whom hold no
|
|
110
|
+
* `Graph: Approve Edges`. Its `Approved` status is not that user's decision but the content source's
|
|
111
|
+
* configured `GraphOverlay.ConceptTaxonomyMode`, so tying it to the run user would break `auto-grow`
|
|
112
|
+
* for every run but a developer's. The stage therefore saves inside a server operation scope instead,
|
|
113
|
+
* which no API caller can enter (see {@link GRAPH_PIPELINE_EDGE_APPROVAL_OPERATION}). Such an edge is
|
|
114
|
+
* not stamped as reviewed: no person reviewed it.
|
|
115
|
+
*/
|
|
116
|
+
export declare function EvaluateGraphEdgeApproval(input: GraphEdgeApprovalInput): GraphEdgeApprovalVerdict;
|
|
117
|
+
/**
|
|
118
|
+
* Why `user` may not exercise `Graph: Approve Edges`, or `null` when it may. Fail closed: a missing
|
|
119
|
+
* caller, an unseeded authorization and an empty authorization list all deny.
|
|
120
|
+
*/
|
|
121
|
+
export declare function ApproveEdgesDenialReason(user: UserInfo | undefined, authorizations: AuthorizationInfo[] | undefined): string | null;
|
|
122
|
+
/**
|
|
123
|
+
* The refusal for deleting an edge whose stored `Status` is `storedStatus`, or `null` when allowed.
|
|
124
|
+
* Removing an `Approved` edge undoes a review decision, so it needs `Graph: Approve Edges`; a
|
|
125
|
+
* `Proposed` or `Rejected` edge may be deleted by anyone the entity permissions allow.
|
|
126
|
+
*/
|
|
127
|
+
export declare function GraphEdgeDeleteRefusal(storedStatus: MJGraphEdgeEntity['Status'] | null | undefined, user: UserInfo | undefined, authorizations: AuthorizationInfo[] | undefined): string | null;
|
|
128
|
+
/** `Attributes` keys the server writes when an edge is approved or rejected; a caller never sets them. */
|
|
129
|
+
export declare const GRAPH_EDGE_REVIEW_ATTRIBUTE_KEYS: readonly string[];
|
|
130
|
+
/**
|
|
131
|
+
* The first review-stamp key ({@link GRAPH_EDGE_REVIEW_ATTRIBUTE_KEYS}) whose value differs between
|
|
132
|
+
* the stored and the new `Attributes` JSON, or `null`. A save that is not itself a stamped review
|
|
133
|
+
* decision may not add, change or remove one: the stamp would otherwise be forgeable.
|
|
134
|
+
*/
|
|
135
|
+
export declare function FindReviewStampChange(storedAttributes: string | null | undefined, nextAttributes: string | null | undefined): string | null;
|
|
136
|
+
/**
|
|
137
|
+
* True while the current async call chain is inside a {@link GRAPH_PIPELINE_EDGE_APPROVAL_OPERATION}
|
|
138
|
+
* server operation scope bound to `user` (`ServerOperationScopeManager.IsOperationActive`). Frames
|
|
139
|
+
* outside the innermost client CRUD boundary are masked, so a GraphQL, REST or transaction-group save
|
|
140
|
+
* never sees one.
|
|
141
|
+
*/
|
|
142
|
+
export declare function IsInGraphPipelineApprovalScope(user: UserInfo | undefined): boolean;
|
|
143
|
+
/**
|
|
144
|
+
* Batched `RunViews` (`ResultType: 'count_only'`) existence check for `Source` and `Target` endpoint
|
|
145
|
+
* records, run as `user` so an endpoint the caller cannot read (entity permission or row-level
|
|
146
|
+
* security) is refused exactly like one that does not exist.
|
|
147
|
+
*
|
|
148
|
+
* Fails closed: an endpoint entity missing from metadata, a failed read, or an exception is a
|
|
149
|
+
* validation error, never a silent pass.
|
|
150
|
+
*/
|
|
151
|
+
export declare function CheckGraphEdgeEndpointsExist(input: {
|
|
152
|
+
readonly SourceEntityID: string | null | undefined;
|
|
153
|
+
readonly SourceRecordID: string | null | undefined;
|
|
154
|
+
readonly TargetEntityID: string | null | undefined;
|
|
155
|
+
readonly TargetRecordID: string | null | undefined;
|
|
156
|
+
}, provider: IMetadataProvider, user: UserInfo | undefined): Promise<ValidationErrorInfo[]>;
|
|
157
|
+
/**
|
|
158
|
+
* Server-side `MJ: Graph Edges` entity enforcing Phase G1.3 write-time invariants:
|
|
159
|
+
* - No self-loops
|
|
160
|
+
* - Record ID length <= 400 chars
|
|
161
|
+
* - Refuses an `EdgeTypeID` that is unknown, provider-only (`AllowStored = false`) or scoped to another graph
|
|
162
|
+
* - Enforces `MJ: Graph Edge Type Endpoints` source/target entity constraints via `GraphEngine.Instance.ValidateEdgeEndpoint`
|
|
163
|
+
* - Canonicalizes undirected (`IsDirected = false`) edge endpoint orientation (lower `<entityID>|<recordID>` key first)
|
|
164
|
+
* - Requires `Graph: Approve Edges` for every approval decision, whatever the `Origin`, including creating
|
|
165
|
+
* an edge that starts `Approved` and editing or deleting an `Approved` edge ({@link EvaluateGraphEdgeApproval},
|
|
166
|
+
* {@link GraphEdgeDeleteRefusal}), and stamps `ReviewedByUserID` / `ReviewedAt` into `Attributes`; the
|
|
167
|
+
* Content Pipeline's policy-approved `Inferred` edges are the one exception ({@link IsPipelinePolicyApprovedCreate})
|
|
168
|
+
* - Refuses any other save that sets, changes or removes that review stamp ({@link FindReviewStampChange})
|
|
169
|
+
* - Verifies `Source` and `Target` endpoint records exist, as the caller, via batched `RunViews` (`count_only`)
|
|
170
|
+
*
|
|
171
|
+
* Every check fails closed: graph metadata that cannot be loaded is a validation error, not a pass.
|
|
172
|
+
*/
|
|
173
|
+
export declare class MJGraphEdgeEntityServer extends MJGraphEdgeEntity {
|
|
174
|
+
get DefaultSkipAsyncValidation(): boolean;
|
|
175
|
+
ValidateAsync(): Promise<ValidationResult>;
|
|
176
|
+
/**
|
|
177
|
+
* Makes sure `GraphEngine` has its edge types and endpoint constraints. `Config` is a no-op once
|
|
178
|
+
* loaded; on a server `BaseEngine` loads it as the system user, so the shared cache never takes
|
|
179
|
+
* this caller's scope. A failure is returned as an error: validating against an empty cache
|
|
180
|
+
* would skip the edge-type checks.
|
|
181
|
+
*/
|
|
182
|
+
private ensureGraphEngine;
|
|
183
|
+
private canonicalizeUndirectedEndpoints;
|
|
184
|
+
/**
|
|
185
|
+
* Refuses deleting an `Approved` edge without `Graph: Approve Edges` ({@link GraphEdgeDeleteRefusal}).
|
|
186
|
+
* The delete path loads the stored row first, so `Status` is the stored value.
|
|
187
|
+
*/
|
|
188
|
+
Delete(options?: EntityDeleteOptions): Promise<boolean>;
|
|
189
|
+
/** The stored `Attributes` before this save; `null` for a create. */
|
|
190
|
+
private storedAttributes;
|
|
191
|
+
private previousStatus;
|
|
192
|
+
private stampReview;
|
|
193
|
+
private endpointsDirty;
|
|
194
|
+
private fail;
|
|
195
|
+
private resolveEdgeType;
|
|
196
|
+
}
|
|
197
|
+
//# sourceMappingURL=MJGraphEdgeEntityServer.server.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"MJGraphEdgeEntityServer.server.d.ts","sourceRoot":"","sources":["../../src/custom/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