@memberjunction/core-entities-server 6.2.0-edge.6 → 6.2.0-edge.8
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 +155 -100
- package/dist/custom/AnchoredConversationReadSecurityHook.d.ts +22 -0
- package/dist/custom/AnchoredConversationReadSecurityHook.d.ts.map +1 -0
- package/dist/custom/AnchoredConversationReadSecurityHook.js +293 -0
- package/dist/custom/AnchoredConversationReadSecurityHook.js.map +1 -0
- package/dist/custom/MJAIAgentExampleEntityServer.server.d.ts +2 -0
- package/dist/custom/MJAIAgentExampleEntityServer.server.d.ts.map +1 -1
- package/dist/custom/MJAIAgentExampleEntityServer.server.js +8 -5
- package/dist/custom/MJAIAgentExampleEntityServer.server.js.map +1 -1
- package/dist/custom/MJAIAgentNoteEntityServer.server.d.ts +2 -0
- package/dist/custom/MJAIAgentNoteEntityServer.server.d.ts.map +1 -1
- package/dist/custom/MJAIAgentNoteEntityServer.server.js +8 -5
- package/dist/custom/MJAIAgentNoteEntityServer.server.js.map +1 -1
- package/dist/custom/MJAIAgentRelationshipEntityServer.server.d.ts +17 -0
- package/dist/custom/MJAIAgentRelationshipEntityServer.server.d.ts.map +1 -0
- package/dist/custom/MJAIAgentRelationshipEntityServer.server.js +71 -0
- package/dist/custom/MJAIAgentRelationshipEntityServer.server.js.map +1 -0
- package/dist/custom/MJAIAgentSessionEntityServer.server.d.ts +8 -22
- package/dist/custom/MJAIAgentSessionEntityServer.server.d.ts.map +1 -1
- package/dist/custom/MJAIAgentSessionEntityServer.server.js +24 -1
- package/dist/custom/MJAIAgentSessionEntityServer.server.js.map +1 -1
- package/dist/custom/MJAIAgentUserPolicyEntityServer.server.d.ts +23 -0
- package/dist/custom/MJAIAgentUserPolicyEntityServer.server.d.ts.map +1 -0
- package/dist/custom/MJAIAgentUserPolicyEntityServer.server.js +53 -0
- package/dist/custom/MJAIAgentUserPolicyEntityServer.server.js.map +1 -0
- package/dist/custom/MJAIPromptEntityServer.server.d.ts.map +1 -1
- package/dist/custom/MJAIPromptEntityServer.server.js +2 -1
- package/dist/custom/MJAIPromptEntityServer.server.js.map +1 -1
- package/dist/custom/MJBrandKitEntityServer.server.d.ts +14 -0
- package/dist/custom/MJBrandKitEntityServer.server.d.ts.map +1 -0
- package/dist/custom/MJBrandKitEntityServer.server.js +75 -0
- package/dist/custom/MJBrandKitEntityServer.server.js.map +1 -0
- package/dist/custom/MJCompanyIntegrationEntityServer.server.d.ts.map +1 -1
- package/dist/custom/MJCompanyIntegrationEntityServer.server.js +1 -0
- package/dist/custom/MJCompanyIntegrationEntityServer.server.js.map +1 -1
- package/dist/custom/MJComponentEntityServer.server.d.ts +2 -0
- package/dist/custom/MJComponentEntityServer.server.d.ts.map +1 -1
- package/dist/custom/MJComponentEntityServer.server.js +5 -1
- package/dist/custom/MJComponentEntityServer.server.js.map +1 -1
- package/dist/custom/MJConversationDetailEntityServer.server.d.ts +20 -30
- package/dist/custom/MJConversationDetailEntityServer.server.d.ts.map +1 -1
- package/dist/custom/MJConversationDetailEntityServer.server.js +89 -35
- package/dist/custom/MJConversationDetailEntityServer.server.js.map +1 -1
- package/dist/custom/MJConversationEntityServer.server.d.ts +19 -4
- package/dist/custom/MJConversationEntityServer.server.d.ts.map +1 -1
- package/dist/custom/MJConversationEntityServer.server.js +169 -11
- package/dist/custom/MJConversationEntityServer.server.js.map +1 -1
- package/dist/custom/MJEntityDocumentEntityServer.server.d.ts.map +1 -1
- package/dist/custom/MJEntityDocumentEntityServer.server.js +1 -0
- package/dist/custom/MJEntityDocumentEntityServer.server.js.map +1 -1
- package/dist/custom/MJListDetailEntityServer.server.d.ts.map +1 -1
- package/dist/custom/MJListDetailEntityServer.server.js +1 -0
- package/dist/custom/MJListDetailEntityServer.server.js.map +1 -1
- package/dist/custom/MJProjectEntityServer.server.d.ts +21 -0
- package/dist/custom/MJProjectEntityServer.server.d.ts.map +1 -0
- package/dist/custom/MJProjectEntityServer.server.js +106 -0
- package/dist/custom/MJProjectEntityServer.server.js.map +1 -0
- package/dist/custom/MJQueryEntityServer.server.d.ts +177 -47
- package/dist/custom/MJQueryEntityServer.server.d.ts.map +1 -1
- package/dist/custom/MJQueryEntityServer.server.js +479 -164
- package/dist/custom/MJQueryEntityServer.server.js.map +1 -1
- package/dist/custom/MJQuerySQLEntityServer.server.d.ts +15 -18
- package/dist/custom/MJQuerySQLEntityServer.server.d.ts.map +1 -1
- package/dist/custom/MJQuerySQLEntityServer.server.js +34 -42
- package/dist/custom/MJQuerySQLEntityServer.server.js.map +1 -1
- package/dist/custom/MJTagEntityServer.server.d.ts +2 -0
- package/dist/custom/MJTagEntityServer.server.d.ts.map +1 -1
- package/dist/custom/MJTagEntityServer.server.js +13 -7
- package/dist/custom/MJTagEntityServer.server.js.map +1 -1
- package/dist/custom/MJUserRoutineEntityServer.server.d.ts.map +1 -1
- package/dist/custom/MJUserRoutineEntityServer.server.js +8 -1
- package/dist/custom/MJUserRoutineEntityServer.server.js.map +1 -1
- package/dist/custom/RestrictedFieldCommentClassifier.d.ts +73 -0
- package/dist/custom/RestrictedFieldCommentClassifier.d.ts.map +1 -0
- package/dist/custom/RestrictedFieldCommentClassifier.js +240 -0
- package/dist/custom/RestrictedFieldCommentClassifier.js.map +1 -0
- package/dist/custom/query-extraction/childRowWriter.d.ts +77 -0
- package/dist/custom/query-extraction/childRowWriter.d.ts.map +1 -0
- package/dist/custom/query-extraction/childRowWriter.js +277 -0
- package/dist/custom/query-extraction/childRowWriter.js.map +1 -0
- package/dist/custom/query-extraction/compositionTargets.d.ts +40 -0
- package/dist/custom/query-extraction/compositionTargets.d.ts.map +1 -0
- package/dist/custom/query-extraction/compositionTargets.js +99 -0
- package/dist/custom/query-extraction/compositionTargets.js.map +1 -0
- package/dist/custom/query-extraction/declared.d.ts +79 -0
- package/dist/custom/query-extraction/declared.d.ts.map +1 -0
- package/dist/custom/query-extraction/declared.js +91 -0
- package/dist/custom/query-extraction/declared.js.map +1 -0
- package/dist/custom/query-extraction/describeFacts.d.ts +40 -0
- package/dist/custom/query-extraction/describeFacts.d.ts.map +1 -0
- package/dist/custom/query-extraction/describeFacts.js +225 -0
- package/dist/custom/query-extraction/describeFacts.js.map +1 -0
- package/dist/custom/query-extraction/descriptionPass.d.ts +23 -0
- package/dist/custom/query-extraction/descriptionPass.d.ts.map +1 -0
- package/dist/custom/query-extraction/descriptionPass.js +95 -0
- package/dist/custom/query-extraction/descriptionPass.js.map +1 -0
- package/dist/custom/query-extraction/extractQuery.d.ts +25 -0
- package/dist/custom/query-extraction/extractQuery.d.ts.map +1 -0
- package/dist/custom/query-extraction/extractQuery.js +146 -0
- package/dist/custom/query-extraction/extractQuery.js.map +1 -0
- package/dist/custom/query-extraction/extractionTypes.d.ts +133 -0
- package/dist/custom/query-extraction/extractionTypes.d.ts.map +1 -0
- package/dist/custom/query-extraction/extractionTypes.js +2 -0
- package/dist/custom/query-extraction/extractionTypes.js.map +1 -0
- package/dist/custom/query-extraction/index.d.ts +16 -0
- package/dist/custom/query-extraction/index.d.ts.map +1 -1
- package/dist/custom/query-extraction/index.js +11 -1
- package/dist/custom/query-extraction/index.js.map +1 -1
- package/dist/custom/query-extraction/pipeline.d.ts +6 -2
- package/dist/custom/query-extraction/pipeline.d.ts.map +1 -1
- package/dist/custom/query-extraction/pipeline.js +21 -14
- package/dist/custom/query-extraction/pipeline.js.map +1 -1
- package/dist/custom/query-extraction/resolve.d.ts +7 -2
- package/dist/custom/query-extraction/resolve.d.ts.map +1 -1
- package/dist/custom/query-extraction/resolve.js +17 -14
- package/dist/custom/query-extraction/resolve.js.map +1 -1
- package/dist/custom/query-extraction/sourceBinding.d.ts +57 -0
- package/dist/custom/query-extraction/sourceBinding.d.ts.map +1 -0
- package/dist/custom/query-extraction/sourceBinding.js +104 -0
- package/dist/custom/query-extraction/sourceBinding.js.map +1 -0
- package/dist/custom/query-extraction/sync.d.ts +27 -3
- package/dist/custom/query-extraction/sync.d.ts.map +1 -1
- package/dist/custom/query-extraction/sync.js +69 -44
- package/dist/custom/query-extraction/sync.js.map +1 -1
- package/dist/custom/query-extraction/templateFacts.d.ts +62 -0
- package/dist/custom/query-extraction/templateFacts.d.ts.map +1 -0
- package/dist/custom/query-extraction/templateFacts.js +229 -0
- package/dist/custom/query-extraction/templateFacts.js.map +1 -0
- package/dist/custom/query-extraction/types.d.ts +4 -0
- package/dist/custom/query-extraction/types.d.ts.map +1 -1
- package/dist/custom/query-refresh/QueryExtractionService.d.ts +54 -0
- package/dist/custom/query-refresh/QueryExtractionService.d.ts.map +1 -0
- package/dist/custom/query-refresh/QueryExtractionService.js +207 -0
- package/dist/custom/query-refresh/QueryExtractionService.js.map +1 -0
- package/dist/custom/query-refresh/QueryRefreshExtractionServerOperation.d.ts +28 -0
- package/dist/custom/query-refresh/QueryRefreshExtractionServerOperation.d.ts.map +1 -0
- package/dist/custom/query-refresh/QueryRefreshExtractionServerOperation.js +106 -0
- package/dist/custom/query-refresh/QueryRefreshExtractionServerOperation.js.map +1 -0
- package/dist/custom/query-refresh/index.d.ts +14 -0
- package/dist/custom/query-refresh/index.d.ts.map +1 -0
- package/dist/custom/query-refresh/index.js +10 -0
- package/dist/custom/query-refresh/index.js.map +1 -0
- package/dist/custom/query-refresh/queryRebind.d.ts +33 -0
- package/dist/custom/query-refresh/queryRebind.d.ts.map +1 -0
- package/dist/custom/query-refresh/queryRebind.js +85 -0
- package/dist/custom/query-refresh/queryRebind.js.map +1 -0
- package/dist/custom/query-refresh/refreshAuthorization.d.ts +29 -0
- package/dist/custom/query-refresh/refreshAuthorization.d.ts.map +1 -0
- package/dist/custom/query-refresh/refreshAuthorization.js +66 -0
- package/dist/custom/query-refresh/refreshAuthorization.js.map +1 -0
- package/dist/custom/query-refresh/refreshFormat.d.ts +16 -0
- package/dist/custom/query-refresh/refreshFormat.d.ts.map +1 -0
- package/dist/custom/query-refresh/refreshFormat.js +67 -0
- package/dist/custom/query-refresh/refreshFormat.js.map +1 -0
- package/dist/custom/query-refresh/refreshOrder.d.ts +25 -0
- package/dist/custom/query-refresh/refreshOrder.d.ts.map +1 -0
- package/dist/custom/query-refresh/refreshOrder.js +95 -0
- package/dist/custom/query-refresh/refreshOrder.js.map +1 -0
- package/dist/custom/query-refresh/refreshSelection.d.ts +15 -0
- package/dist/custom/query-refresh/refreshSelection.d.ts.map +1 -0
- package/dist/custom/query-refresh/refreshSelection.js +99 -0
- package/dist/custom/query-refresh/refreshSelection.js.map +1 -0
- package/dist/custom/query-refresh/refreshTypes.d.ts +81 -0
- package/dist/custom/query-refresh/refreshTypes.d.ts.map +1 -0
- package/dist/custom/query-refresh/refreshTypes.js +5 -0
- package/dist/custom/query-refresh/refreshTypes.js.map +1 -0
- package/dist/custom/util.d.ts +8 -0
- package/dist/custom/util.d.ts.map +1 -1
- package/dist/custom/util.js +18 -1
- package/dist/custom/util.js.map +1 -1
- package/dist/engines/QueryEngineServer.d.ts +8 -5
- package/dist/engines/QueryEngineServer.d.ts.map +1 -1
- package/dist/engines/QueryEngineServer.js +16 -23
- package/dist/engines/QueryEngineServer.js.map +1 -1
- package/dist/index.d.ts +7 -0
- package/dist/index.d.ts.map +1 -1
- package/dist/index.js +7 -0
- package/dist/index.js.map +1 -1
- package/package.json +30 -30
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"MJAIAgentSessionEntityServer.server.js","sourceRoot":"","sources":["../../src/custom/MJAIAgentSessionEntityServer.server.ts"],"names":[],"mappings":";;;;;;AAAA,OAAO,EAAE,UAAU,EAAE,mBAAmB,EAAE,mBAAmB,EAAoB,MAAM,sBAAsB,CAAC;AAC9G,OAAO,EAAE,aAAa,EAAE,MAAM,wBAAwB,CAAC;AACvD,OAAO,EAAE,sBAAsB,EAAE,MAAM,+BAA+B,CAAC;AACvE,OAAO,EAAE,iCAAiC,EAAE,iCAAiC,EAAE,MAAM,sBAAsB,CAAC;AAC5G,OAAO,EAAE,gCAAgC,EAAE,0BAA0B,EAAE,MAAM,8BAA8B,CAAC;AAE5G
|
|
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,OAAO,IAAI,CAAC;QAChB,CAAC;QACD,MAAM,QAAQ,GAAG,IAAI,CAAC,OAAO,IAAI,OAAO,WAAW,CAAC,QAAQ,KAAK,QAAQ,CAAC,CAAC,CAAC,WAAW,CAAC,QAAQ,CAAC,CAAC,CAAC,IAAI,CAAC;QACxG,MAAM,OAAO,GAAG,iCAAiC,CAAC,QAAQ,EAAE,IAAI,CAAC,OAAO,CAAC,CAAC;QAC1E,IAAI,OAAO,CAAC,MAAM,KAAK,CAAC,EAAE,CAAC;YACvB,OAAO,IAAI,CAAC;QAChB,CAAC;QACD,OAAO,IAAI,mBAAmB,CAC1B,QAAQ,EACR,gBAAgB,OAAO,CAAC,IAAI,CAAC,IAAI,CAAC,8DAA8D,EAChG,IAAI,EACJ,mBAAmB,CAAC,OAAO,CAC9B,CAAC;IACN,CAAC;CACJ,CAAA;AA5EY,4BAA4B;IADxC,aAAa,CAAC,UAAU,EAAE,uBAAuB,CAAC;GACtC,4BAA4B,CA4ExC"}
|
|
@@ -0,0 +1,23 @@
|
|
|
1
|
+
import { EntitySaveOptions, ValidationResult } from '@memberjunction/core';
|
|
2
|
+
import { MJAIAgentUserPolicyEntity } from '@memberjunction/core-entities';
|
|
3
|
+
/**
|
|
4
|
+
* Server-side `MJ: AI Agent User Policies` entity: a user's agent policy is private to that user.
|
|
5
|
+
*
|
|
6
|
+
* The UI role may create and update policies (granted in `metadata/entity-permissions`) so that
|
|
7
|
+
* a regular user's Chief of Staff can persist their preferences during onboarding and the
|
|
8
|
+
* cockpit's Governance tab can save edits. Row-level security for this entity is not yet
|
|
9
|
+
* expressible as version-controlled metadata, so this subclass is the defense-in-depth gate,
|
|
10
|
+
* mirroring `MJUserRoutineEntityServer`:
|
|
11
|
+
*
|
|
12
|
+
* 1. **Ownership** — a non-Owner-type context user may only save the policy whose `UserID` is
|
|
13
|
+
* their own, compared against the PRE-save owner so reassigning `UserID` cannot bypass it.
|
|
14
|
+
* Owner-type users (administrators, the scheduler's system user) are exempt.
|
|
15
|
+
* 2. **Owner attribution** — first save defaults `UserID` to the context user when unset, so
|
|
16
|
+
* programmatic create paths attribute the row correctly.
|
|
17
|
+
*/
|
|
18
|
+
export declare class MJAIAgentUserPolicyEntityServer extends MJAIAgentUserPolicyEntity {
|
|
19
|
+
Save(options?: EntitySaveOptions): Promise<boolean>;
|
|
20
|
+
Validate(): ValidationResult;
|
|
21
|
+
private validateOwnership;
|
|
22
|
+
}
|
|
23
|
+
//# sourceMappingURL=MJAIAgentUserPolicyEntityServer.server.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"MJAIAgentUserPolicyEntityServer.server.d.ts","sourceRoot":"","sources":["../../src/custom/MJAIAgentUserPolicyEntityServer.server.ts"],"names":[],"mappings":"AAAA,OAAO,EAAc,iBAAiB,EAA4C,gBAAgB,EAAE,MAAM,sBAAsB,CAAC;AAEjI,OAAO,EAAE,yBAAyB,EAAE,MAAM,+BAA+B,CAAC;AAE1E;;;;;;;;;;;;;;GAcG;AACH,qBACa,+BAAgC,SAAQ,yBAAyB;IACpD,IAAI,CAAC,OAAO,CAAC,EAAE,iBAAiB,GAAG,OAAO,CAAC,OAAO,CAAC;IAOzD,QAAQ,IAAI,gBAAgB;IAO5C,OAAO,CAAC,iBAAiB;CAe5B"}
|
|
@@ -0,0 +1,53 @@
|
|
|
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, ValidationErrorInfo, ValidationErrorType } from '@memberjunction/core';
|
|
8
|
+
import { RegisterClass, UUIDsEqual } from '@memberjunction/global';
|
|
9
|
+
import { MJAIAgentUserPolicyEntity } from '@memberjunction/core-entities';
|
|
10
|
+
/**
|
|
11
|
+
* Server-side `MJ: AI Agent User Policies` entity: a user's agent policy is private to that user.
|
|
12
|
+
*
|
|
13
|
+
* The UI role may create and update policies (granted in `metadata/entity-permissions`) so that
|
|
14
|
+
* a regular user's Chief of Staff can persist their preferences during onboarding and the
|
|
15
|
+
* cockpit's Governance tab can save edits. Row-level security for this entity is not yet
|
|
16
|
+
* expressible as version-controlled metadata, so this subclass is the defense-in-depth gate,
|
|
17
|
+
* mirroring `MJUserRoutineEntityServer`:
|
|
18
|
+
*
|
|
19
|
+
* 1. **Ownership** — a non-Owner-type context user may only save the policy whose `UserID` is
|
|
20
|
+
* their own, compared against the PRE-save owner so reassigning `UserID` cannot bypass it.
|
|
21
|
+
* Owner-type users (administrators, the scheduler's system user) are exempt.
|
|
22
|
+
* 2. **Owner attribution** — first save defaults `UserID` to the context user when unset, so
|
|
23
|
+
* programmatic create paths attribute the row correctly.
|
|
24
|
+
*/
|
|
25
|
+
let MJAIAgentUserPolicyEntityServer = class MJAIAgentUserPolicyEntityServer extends MJAIAgentUserPolicyEntity {
|
|
26
|
+
async Save(options) {
|
|
27
|
+
if (!this.IsSaved && !this.UserID && this.ContextCurrentUser) {
|
|
28
|
+
this.UserID = this.ContextCurrentUser.ID;
|
|
29
|
+
}
|
|
30
|
+
return super.Save(options);
|
|
31
|
+
}
|
|
32
|
+
Validate() {
|
|
33
|
+
const result = super.Validate();
|
|
34
|
+
this.validateOwnership(result);
|
|
35
|
+
result.Success = result.Success && result.Errors.length === 0;
|
|
36
|
+
return result;
|
|
37
|
+
}
|
|
38
|
+
validateOwnership(result) {
|
|
39
|
+
const user = this.ContextCurrentUser;
|
|
40
|
+
if (!user || user.Type?.trim().toLowerCase() === 'owner') {
|
|
41
|
+
return;
|
|
42
|
+
}
|
|
43
|
+
const preSaveOwnerId = this.GetFieldByName('UserID')?.OldValue ?? this.UserID;
|
|
44
|
+
if (preSaveOwnerId && !UUIDsEqual(preSaveOwnerId, user.ID)) {
|
|
45
|
+
result.Errors.push(new ValidationErrorInfo('UserID', 'An agent policy is private to its user — you can only modify your own policy.', this.UserID, ValidationErrorType.Failure));
|
|
46
|
+
}
|
|
47
|
+
}
|
|
48
|
+
};
|
|
49
|
+
MJAIAgentUserPolicyEntityServer = __decorate([
|
|
50
|
+
RegisterClass(BaseEntity, 'MJ: AI Agent User Policies')
|
|
51
|
+
], MJAIAgentUserPolicyEntityServer);
|
|
52
|
+
export { MJAIAgentUserPolicyEntityServer };
|
|
53
|
+
//# sourceMappingURL=MJAIAgentUserPolicyEntityServer.server.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"MJAIAgentUserPolicyEntityServer.server.js","sourceRoot":"","sources":["../../src/custom/MJAIAgentUserPolicyEntityServer.server.ts"],"names":[],"mappings":";;;;;;AAAA,OAAO,EAAE,UAAU,EAAqB,mBAAmB,EAAE,mBAAmB,EAAoB,MAAM,sBAAsB,CAAC;AACjI,OAAO,EAAE,aAAa,EAAE,UAAU,EAAE,MAAM,wBAAwB,CAAC;AACnE,OAAO,EAAE,yBAAyB,EAAE,MAAM,+BAA+B,CAAC;AAE1E;;;;;;;;;;;;;;GAcG;AAEI,IAAM,+BAA+B,GAArC,MAAM,+BAAgC,SAAQ,yBAAyB;IAC1D,KAAK,CAAC,IAAI,CAAC,OAA2B;QAClD,IAAI,CAAC,IAAI,CAAC,OAAO,IAAI,CAAC,IAAI,CAAC,MAAM,IAAI,IAAI,CAAC,kBAAkB,EAAE,CAAC;YAC3D,IAAI,CAAC,MAAM,GAAG,IAAI,CAAC,kBAAkB,CAAC,EAAE,CAAC;QAC7C,CAAC;QACD,OAAO,KAAK,CAAC,IAAI,CAAC,OAAO,CAAC,CAAC;IAC/B,CAAC;IAEe,QAAQ;QACpB,MAA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AAI,MAAM,GAAG,IAAI,CAEvD;IACD,WAAkB,qBAAqB,CAAC,KAAK,EAAE,MAAM,GAAG,IAAI,EAE3D;IAED,OAAO,CAAC,MAAM,CAAC,uBAAuB,CAAuB;IAC7D;;;;;;;;;;OAUG;IACH,WAAkB,sBAAsB,IAAI,MAAM,GAAG,IAAI,CAExD;IACD,WAAkB,sBAAsB,CAAC,KAAK,EAAE,MAAM,GAAG,IAAI,EAE5D;IAED;;;;;;;;;OASG;cACa,iCAAiC,IAAI,OAAO,CAAC,MAAM,CAAC;IA0BpE;;;;;;OAMG;cACa,0BAA0B,CAAC,IAAI,EAAE,MAAM,GAAG,OAAO,CAAC,MAAM,CAAC;IAoBzE;;;;;;OAMG;IACY,IAAI,CAAC,OAAO,CAAC,EAAE,iBAAiB,GAAG,OAAO,CAAC,OAAO,CAAC;IA8ClE;;;;;;OAMG;cACa,4BAA4B,CAAC,EAAE,EAAE,iBAAiB,EAAE,EAAE,CAAC,EAAE,oBAAoB,GAAG,OAAO,CAAC,OAAO,CAAC;IAqDhH;;;;;OAKG;cACa,uCAAuC,CAAC,EAAE,EAAE,iBAAiB,GAAG,OAAO,CAAC,gBAAgB,GAAG,IAAI,CAAC;IA2ChH;;;OAGG;cACa,wBAAwB,IAAI,OAAO,CAAC,MAAM,CAAC;CAoB9D"}
|
|
@@ -175,7 +175,8 @@ let MJAIPromptEntityServer = class MJAIPromptEntityServer extends MJAIPromptEnti
|
|
|
175
175
|
ExtraFilter: `TemplateID='${this.TemplateID}'`,
|
|
176
176
|
OrderBy: "__mj_CreatedAt ASC", // first one
|
|
177
177
|
ResultType: 'entity_object',
|
|
178
|
-
MaxRows: 1 // should only be one row
|
|
178
|
+
MaxRows: 1, // should only be one row
|
|
179
|
+
SkipTotalRowCount: true
|
|
179
180
|
}, this.ContextCurrentUser);
|
|
180
181
|
let tc = undefined;
|
|
181
182
|
if (result && result.Success && result.Results.length > 0) {
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file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ACvB,MAAM,CAAC,OAAO,GAAG,sGAAsG,CAAC;gBACxH,IAAI,CAAC,0BAA0B,CAAC,MAAM,CAAC,CAAC;YAC5C,CAAC;QACL,CAAC;QACD,IAAI,OAAO,EAAE,CAAC;YACV,gCAAgC;YAChC,IAAI,MAAM,KAAK,CAAC,IAAI,CAAC,OAAO,CAAC,EAAG,CAAC;gBAC7B,IAAI,CAAC,qBAAqB,GAAG,IAAI,CAAC,YAAY,CAAC,CAAC,+CAA+C;gBAC/F,OAAO,IAAI,CAAC;YAChB,CAAC;iBACI,CAAC;gBACF,OAAO,KAAK,CAAC;YACjB,CAAC;QACL,CAAC;aACI,CAAC;YACF,8GAA8G;YAC9G,OAAO,KAAK,CAAC;QACjB,CAAC;IACL,CAAC;IAED;;;;;;OAMG;IACO,KAAK,CAAC,4BAA4B,CAAC,EAAqB,EAAE,EAAyB;QACzF,IAAI,CAAC;YACD,wFAAwF;YACxF,IAAI,CAAC,IAAI,CAAC,UAAU,EAAE,CAAC;gBACnB,MAAM,IAAI,KAAK,CAAC,oEAAoE,CAAC,CAAC;YAC1F,CAAC;YACD,MAAM,EAAE,GAAG,IAAI,CAAC,oBAAoB,CAAA;YACpC,MAAM,MAAM,GAAG,MAAM,EAAE,CAAC,OAAO,CAA0B;gBACrD,UAAU,EAAE,uBAAuB;gBACnC,WAAW,EAAE,eAAe,IAAI,CAAC,UAAU,GAAG;gBAC9C,OAAO,EAAE,oBAAoB,EAAE,YAAY;gBAC3C,UAAU,EAAE,eAAe;gBAC3B,OAAO,EAAE,CAAC,
|
|
1
|
+
{"version":3,"file":"MJAIPromptEntityServer.server.js","sourceRoot":"","sources":["../../src/custom/MJAIPromptEntityServer.server.ts"],"names":[],"mappings":";;;;;;;AAAA,OAAO,EAAE,UAAU,EAAE,gBAAgB,EAA0D,UAAU,EAAwB,MAAM,sBAAsB,CAAC;AAC9J,OAAO,EAAE,aAAa,EAAE,MAAM,EAAE,MAAM,wBAAwB,CAAC;AAC/D,OAAO,EAA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AAO,IAAI,CAAC,CAAC,yDAAyD;QAC1E,CAAC;IACL,CAAC;IAED;;;OAGG;IACO,KAAK,CAAC,wBAAwB;QACpC,IAAI,wBAAsB,CAAC,qBAAqB,EAAE,CAAC;YAC/C,OAAO,wBAAsB,CAAC,qBAAqB,CAAC;QACxD,CAAC;QACD,sDAAsD;QACtD,MAAM,EAAE,GAAG,IAAI,CAAC,aAAwC,CAAC;QACzD,MAAM,MAAM,GAAG,MAAM,EAAE,CAAC,OAAO,CAA8B;YACzD,UAAU,EAAE,4BAA4B;YACxC,WAAW,EAAE,aAAa;YAC1B,OAAO,EAAE,oBAAoB,CAAC,YAAY;SAC7C,EAAE,IAAI,CAAC,kBAAkB,CAAC,CAAC;QAC5B,IAAI,MAAM,IAAI,MAAM,CAAC,OAAO,IAAI,MAAM,CAAC,OAAO,CAAC,MAAM,GAAG,CAAC,EAAE,CAAC;YACxD,qEAAqE;YACrE,wBAAsB,CAAC,qBAAqB,GAAG,MAAM,CAAC,OAAO,CAAC,CAAC,CAAC,CAAC,EAAE,CAAC;YACpE,OAAO,MAAM,CAAC,OAAO,CAAC,CAAC,CAAC,CAAC,EAAE,CAAC;QAChC,CAAC;aACI,CAAC;YACF,MAAM,IAAI,KAAK,CAAC,gEAAgE,CAAC,CAAC;QACtF,CAAC;IACL,CAAC;;AAzRQ,sBAAsB;IADlC,aAAa,CAAC,UAAU,EAAE,gBAAgB,CAAC;GAC/B,sBAAsB,CA0RlC"}
|
|
@@ -0,0 +1,14 @@
|
|
|
1
|
+
import { ValidationResult } from '@memberjunction/core';
|
|
2
|
+
import { MJBrandKitEntity } from '@memberjunction/core-entities';
|
|
3
|
+
/**
|
|
4
|
+
* Server-side `MJ: Brand Kits` entity enforcing the one-default-kit-per-scope rule (§4.1):
|
|
5
|
+
* at most one brand kit with `IsDefault = 1` may exist per `CompanyID` scope (where
|
|
6
|
+
* `CompanyID IS NULL` is the org-wide scope). No SQL index backs `IsDefault`; this
|
|
7
|
+
* `ValidateAsync` check is the only guard, failing a second default kit in the same scope
|
|
8
|
+
* with a `ValidationErrorInfo` naming the existing default kit rather than silently swapping flags.
|
|
9
|
+
*/
|
|
10
|
+
export declare class MJBrandKitEntityServer extends MJBrandKitEntity {
|
|
11
|
+
get DefaultSkipAsyncValidation(): boolean;
|
|
12
|
+
ValidateAsync(): Promise<ValidationResult>;
|
|
13
|
+
}
|
|
14
|
+
//# sourceMappingURL=MJBrandKitEntityServer.server.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"MJBrandKitEntityServer.server.d.ts","sourceRoot":"","sources":["../../src/custom/MJBrandKitEntityServer.server.ts"],"names":[],"mappings":"AAAA,OAAO,EAAwD,gBAAgB,EAAE,MAAM,sBAAsB,CAAC;AAE9G,OAAO,EAAE,gBAAgB,EAAE,MAAM,+BAA+B,CAAC;AAEjE;;;;;;GAMG;AACH,qBACa,sBAAuB,SAAQ,gBAAgB;IACxD,IAAoB,0BAA0B,IAAI,OAAO,CAExD;IAEqB,aAAa,IAAI,OAAO,CAAC,gBAAgB,CAAC;CA+EnE"}
|
|
@@ -0,0 +1,75 @@
|
|
|
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, ValidationErrorInfo, ValidationErrorType } from '@memberjunction/core';
|
|
8
|
+
import { EscapeSQLString, RegisterClass } from '@memberjunction/global';
|
|
9
|
+
import { MJBrandKitEntity } from '@memberjunction/core-entities';
|
|
10
|
+
/**
|
|
11
|
+
* Server-side `MJ: Brand Kits` entity enforcing the one-default-kit-per-scope rule (§4.1):
|
|
12
|
+
* at most one brand kit with `IsDefault = 1` may exist per `CompanyID` scope (where
|
|
13
|
+
* `CompanyID IS NULL` is the org-wide scope). No SQL index backs `IsDefault`; this
|
|
14
|
+
* `ValidateAsync` check is the only guard, failing a second default kit in the same scope
|
|
15
|
+
* with a `ValidationErrorInfo` naming the existing default kit rather than silently swapping flags.
|
|
16
|
+
*/
|
|
17
|
+
let MJBrandKitEntityServer = class MJBrandKitEntityServer extends MJBrandKitEntity {
|
|
18
|
+
get DefaultSkipAsyncValidation() {
|
|
19
|
+
return false;
|
|
20
|
+
}
|
|
21
|
+
async ValidateAsync() {
|
|
22
|
+
const result = await super.ValidateAsync();
|
|
23
|
+
if (!result.Success) {
|
|
24
|
+
return result;
|
|
25
|
+
}
|
|
26
|
+
if (!this.IsDefault) {
|
|
27
|
+
return result;
|
|
28
|
+
}
|
|
29
|
+
const isDefaultDirty = this.GetFieldByName('IsDefault')?.Dirty ?? false;
|
|
30
|
+
const companyIdDirty = this.GetFieldByName('CompanyID')?.Dirty ?? false;
|
|
31
|
+
if (this.IsSaved && !isDefaultDirty && !companyIdDirty) {
|
|
32
|
+
return result;
|
|
33
|
+
}
|
|
34
|
+
const companyFilter = this.CompanyID
|
|
35
|
+
? `CompanyID = '${EscapeSQLString(this.CompanyID)}'`
|
|
36
|
+
: 'CompanyID IS NULL';
|
|
37
|
+
const selfFilter = this.ID
|
|
38
|
+
? ` AND ID <> '${EscapeSQLString(this.ID)}'`
|
|
39
|
+
: '';
|
|
40
|
+
const extraFilter = `IsDefault = 1 AND ${companyFilter}${selfFilter}`;
|
|
41
|
+
try {
|
|
42
|
+
const rv = this.RunViewProviderToUse;
|
|
43
|
+
const runResult = await rv.RunView({
|
|
44
|
+
EntityName: 'MJ: Brand Kits',
|
|
45
|
+
ExtraFilter: extraFilter,
|
|
46
|
+
Fields: ['ID', 'Name'],
|
|
47
|
+
ResultType: 'simple',
|
|
48
|
+
MaxRows: 1,
|
|
49
|
+
}, this.ContextCurrentUser);
|
|
50
|
+
if (!runResult.Success) {
|
|
51
|
+
result.Errors.push(new ValidationErrorInfo('IsDefault', `Could not check for another default kit: ${runResult.ErrorMessage ?? 'RunView failed'}.`, this.IsDefault, ValidationErrorType.Failure));
|
|
52
|
+
result.Success = false;
|
|
53
|
+
return result;
|
|
54
|
+
}
|
|
55
|
+
const existing = runResult.Results?.[0];
|
|
56
|
+
if (existing) {
|
|
57
|
+
const scopeMessage = this.CompanyID
|
|
58
|
+
? `Brand kit '${existing.Name}' is already the default for this company. Clear its IsDefault first.`
|
|
59
|
+
: `Brand kit '${existing.Name}' is already the default for all companies. Clear its IsDefault first.`;
|
|
60
|
+
result.Errors.push(new ValidationErrorInfo('IsDefault', scopeMessage, this.IsDefault, ValidationErrorType.Failure));
|
|
61
|
+
result.Success = false;
|
|
62
|
+
}
|
|
63
|
+
}
|
|
64
|
+
catch (err) {
|
|
65
|
+
result.Errors.push(new ValidationErrorInfo('IsDefault', `Could not check for another default kit: ${err instanceof Error ? err.message : String(err)}.`, this.IsDefault, ValidationErrorType.Failure));
|
|
66
|
+
result.Success = false;
|
|
67
|
+
}
|
|
68
|
+
return result;
|
|
69
|
+
}
|
|
70
|
+
};
|
|
71
|
+
MJBrandKitEntityServer = __decorate([
|
|
72
|
+
RegisterClass(BaseEntity, 'MJ: Brand Kits')
|
|
73
|
+
], MJBrandKitEntityServer);
|
|
74
|
+
export { MJBrandKitEntityServer };
|
|
75
|
+
//# sourceMappingURL=MJBrandKitEntityServer.server.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"MJBrandKitEntityServer.server.js","sourceRoot":"","sources":["../../src/custom/MJBrandKitEntityServer.server.ts"],"names":[],"mappings":";;;;;;AAAA,OAAO,EAAE,UAAU,EAAE,mBAAmB,EAAE,mBAAmB,EAAoB,MAAM,sBAAsB,CAAC;AAC9G,OAAO,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AI,CAAC,SAAS,EACd,mBAAmB,CAAC,OAAO,CAC9B,CACJ,CAAC;YACF,MAAM,CAAC,OAAO,GAAG,KAAK,CAAC;QAC3B,CAAC;QAED,OAAO,MAAM,CAAC;IAClB,CAAC;CACJ,CAAA;AApFY,sBAAsB;IADlC,aAAa,CAAC,UAAU,EAAE,gBAAgB,CAAC;GAC/B,sBAAsB,CAoFlC"}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"MJCompanyIntegrationEntityServer.server.d.ts","sourceRoot":"","sources":["../../src/custom/MJCompanyIntegrationEntityServer.server.ts"],"names":[],"mappings":"AAUA,OAAO,EAAE,0BAA0B,EAAuB,MAAM,+BAA+B,CAAC;AAQhG;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;GA8FG;AACH,qBACa,gCAAiC,SAAQ,0BAA0B;IAC5E;;;;;;;;OAQG;IACU,wBAAwB,IAAI,OAAO,CAAC,IAAI,CAAC;
|
|
1
|
+
{"version":3,"file":"MJCompanyIntegrationEntityServer.server.d.ts","sourceRoot":"","sources":["../../src/custom/MJCompanyIntegrationEntityServer.server.ts"],"names":[],"mappings":"AAUA,OAAO,EAAE,0BAA0B,EAAuB,MAAM,+BAA+B,CAAC;AAQhG;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;GA8FG;AACH,qBACa,gCAAiC,SAAQ,0BAA0B;IAC5E;;;;;;;;OAQG;IACU,wBAAwB,IAAI,OAAO,CAAC,IAAI,CAAC;CA2EzD"}
|
|
@@ -136,6 +136,7 @@ let MJCompanyIntegrationEntityServer = class MJCompanyIntegrationEntityServer ex
|
|
|
136
136
|
ExtraFilter: `ID='${this.IntegrationID}'`,
|
|
137
137
|
ResultType: 'entity_object',
|
|
138
138
|
MaxRows: 1,
|
|
139
|
+
SkipTotalRowCount: true,
|
|
139
140
|
}, user);
|
|
140
141
|
const integration = integResult.Success ? integResult.Results[0] : undefined;
|
|
141
142
|
if (!integration) {
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"MJCompanyIntegrationEntityServer.server.js","sourceRoot":"","sources":["../../src/custom/MJCompanyIntegrationEntityServer.server.ts"],"names":[],"mappings":";;;;;;AAAA,OAAO,EAAE,aAAa,EAAE,MAAM,wBAAwB,CAAC;AACvD,OAAO,EACH,UAAU,EACV,QAAQ,EACR,SAAS,EACT,QAAQ,EACR,OAAO,GAGV,MAAM,sBAAsB,CAAC;AAC9B,OAAO,EAAE,0BAA0B,EAAuB,MAAM,+BAA+B,CAAC;AAChG,OAAO,EACH,oCAAoC,EACpC,iBAAiB,EACjB,gBAAgB,GACnB,MAAM,oCAAoC,CAAC;AAC5C,OAAO,EAAE,6BAA6B,EAAE,MAAM,4BAA4B,CAAC;AAE3E;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;GA8FG;AAEI,IAAM,gCAAgC,GAAtC,MAAM,gCAAiC,SAAQ,0BAA0B;IAC5E;;;;;;;;OAQG;IACI,KAAK,CAAC,wBAAwB;QACjC,MAAM,IAAI,GAAyB,IAAI,CAAC,kBAAkB,CAAC;QAC3D,IAAI,CAAC,IAAI,EAAE,CAAC;YACR,SAAS,CAAC,iEAAiE,IAAI,CAAC,EAAE,mCAAmC,CAAC,CAAC;YACvH,OAAO;QACX,CAAC;QACD,2EAA2E;QAC3E,qEAAqE;QACrE,2EAA2E;QAC3E,4EAA4E;QAC5E,MAAM,QAAQ,GAAkC,IAAI,CAAC,aAAyD,CAAC;QAE/G,SAAS,CAAC,mEAAmE,IAAI,CAAC,WAAW,IAAI,IAAI,CAAC,EAAE,KAAK,IAAI,CAAC,EAAE,sBAAsB,CAAC,CAAC;QAE5I,2EAA2E;QAC3E,yDAAyD;QACzD,MAAM,iBAAiB,CAAC,QAAQ,CAAC,MAAM,CAAC,KAAK,EAAE,IAAI,EAAE,QAAQ,CAAC,CAAC;QAE/D,oEAAoE;QACpE,MAAM,EAAE,GAAG,IAAI,OAAO,EAAE,CAAC;QACzB,MAAM,WAAW,GAAG,MAAM,EAAE,CAAC,OAAO,CAAsB;YACtD,UAAU,EAAE,kBAAkB;YAC9B,WAAW,EAAE,OAAO,IAAI,CAAC,aAAa,GAAG;YACzC,UAAU,EAAE,eAAe;YAC3B,OAAO,EAAE,CAAC;
|
|
1
|
+
{"version":3,"file":"MJCompanyIntegrationEntityServer.server.js","sourceRoot":"","sources":["../../src/custom/MJCompanyIntegrationEntityServer.server.ts"],"names":[],"mappings":";;;;;;AAAA,OAAO,EAAE,aAAa,EAAE,MAAM,wBAAwB,CAAC;AACvD,OAAO,EACH,UAAU,EACV,QAAQ,EACR,SAAS,EACT,QAAQ,EACR,OAAO,GAGV,MAAM,sBAAsB,CAAC;AAC9B,OAAO,EAAE,0BAA0B,EAAuB,MAAM,+BAA+B,CAAC;AAChG,OAAO,EACH,oCAAoC,EACpC,iBAAiB,EACjB,gBAAgB,GACnB,MAAM,oCAAoC,CAAC;AAC5C,OAAO,EAAE,6BAA6B,EAAE,MAAM,4BAA4B,CAAC;AAE3E;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;GA8FG;AAEI,IAAM,gCAAgC,GAAtC,MAAM,gCAAiC,SAAQ,0BAA0B;IAC5E;;;;;;;;OAQG;IACI,KAAK,CAAC,wBAAwB;QACjC,MAAM,IAAI,GAAyB,IAAI,CAAC,kBAAkB,CAAC;QAC3D,IAAI,CAAC,IAAI,EAAE,CAAC;YACR,SAAS,CAAC,iEAAiE,IAAI,CAAC,EAAE,mCAAmC,CAAC,CAAC;YACvH,OAAO;QACX,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AC;IACN,CAAC;CACJ,CAAA;AArFY,gCAAgC;IAD5C,aAAa,CAAC,UAAU,EAAE,0BAA0B,CAAC;GACzC,gCAAgC,CAqF5C"}
|
|
@@ -43,6 +43,8 @@ export declare class MJComponentEntityServer extends MJComponentEntityExtended {
|
|
|
43
43
|
* @returns
|
|
44
44
|
*/
|
|
45
45
|
protected EmbedTextLocal(textToEmbed: string): Promise<SimpleEmbeddingResult>;
|
|
46
|
+
/** A stored vector from a model other than the default local one is re-embedded on save. */
|
|
47
|
+
protected IsEmbeddingStale(embeddingModelID: string | null): Promise<boolean>;
|
|
46
48
|
/** This component as the guard reads it. Built here because `ActiveUser` is protected on `BaseEntity`. */
|
|
47
49
|
private get guardedRow();
|
|
48
50
|
}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"MJComponentEntityServer.server.d.ts","sourceRoot":"","sources":["../../src/custom/MJComponentEntityServer.server.ts"],"names":[],"mappings":"AAAA,OAAO,EAEH,mBAAmB,EACnB,iBAAiB,EACjB,qBAAqB,EAExB,MAAM,sBAAsB,CAAC;AAE9B,OAAO,EAAoC,yBAAyB,EAAE,MAAM,+BAA+B,CAAC;AAM5G;;;;;;;;;;;;;;;;;;;;;;;;;;;GA2BG;AACH,qBACa,uBAAwB,SAAQ,yBAAyB;IAC5C,IAAI,CAAC,OAAO,CAAC,EAAE,iBAAiB,GAAG,OAAO,CAAC,OAAO,CAAC;IA4BzE;;;;OAIG;YACW,kBAAkB;IAYV,MAAM,CAAC,OAAO,CAAC,EAAE,mBAAmB,GAAG,OAAO,CAAC,OAAO,CAAC;IAS7E;;;;OAIG;cACsB,cAAc,CAAC,WAAW,EAAE,MAAM,GAAG,OAAO,CAAC,qBAAqB,CAAC;IAI5F,0GAA0G;IAC1G,OAAO,KAAK,UAAU,GAcrB;CACJ"}
|
|
1
|
+
{"version":3,"file":"MJComponentEntityServer.server.d.ts","sourceRoot":"","sources":["../../src/custom/MJComponentEntityServer.server.ts"],"names":[],"mappings":"AAAA,OAAO,EAEH,mBAAmB,EACnB,iBAAiB,EACjB,qBAAqB,EAExB,MAAM,sBAAsB,CAAC;AAE9B,OAAO,EAAoC,yBAAyB,EAAE,MAAM,+BAA+B,CAAC;AAM5G;;;;;;;;;;;;;;;;;;;;;;;;;;;GA2BG;AACH,qBACa,uBAAwB,SAAQ,yBAAyB;IAC5C,IAAI,CAAC,OAAO,CAAC,EAAE,iBAAiB,GAAG,OAAO,CAAC,OAAO,CAAC;IA4BzE;;;;OAIG;YACW,kBAAkB;IAYV,MAAM,CAAC,OAAO,CAAC,EAAE,mBAAmB,GAAG,OAAO,CAAC,OAAO,CAAC;IAS7E;;;;OAIG;cACsB,cAAc,CAAC,WAAW,EAAE,MAAM,GAAG,OAAO,CAAC,qBAAqB,CAAC;IAI5F,4FAA4F;cACnE,gBAAgB,CAAC,gBAAgB,EAAE,MAAM,GAAG,IAAI,GAAG,OAAO,CAAC,OAAO,CAAC;IAI5F,0GAA0G;IAC1G,OAAO,KAAK,UAAU,GAcrB;CACJ"}
|
|
@@ -7,7 +7,7 @@ var __decorate = (this && this.__decorate) || function (decorators, target, key,
|
|
|
7
7
|
import { BaseEntity, } from "@memberjunction/core";
|
|
8
8
|
import { RegisterClass } from "@memberjunction/global";
|
|
9
9
|
import { ComputeComponentFingerprintAsync, MJComponentEntityExtended } from "@memberjunction/core-entities";
|
|
10
|
-
import { EmbedTextLocalHelper } from "./util.js";
|
|
10
|
+
import { EmbedTextLocalHelper, IsLocalEmbeddingStaleHelper } from "./util.js";
|
|
11
11
|
import { FormScopeRefusalResult } from "./FormScopeGuard.js";
|
|
12
12
|
import { ComponentGuardRefusal } from "./FormComponentGuard.js";
|
|
13
13
|
import { ApplyApprovalRulesAsync, ApprovalRefusalResult } from "./approvalStamp.js";
|
|
@@ -100,6 +100,10 @@ let MJComponentEntityServer = class MJComponentEntityServer extends MJComponentE
|
|
|
100
100
|
async EmbedTextLocal(textToEmbed) {
|
|
101
101
|
return EmbedTextLocalHelper(this, textToEmbed);
|
|
102
102
|
}
|
|
103
|
+
/** A stored vector from a model other than the default local one is re-embedded on save. */
|
|
104
|
+
async IsEmbeddingStale(embeddingModelID) {
|
|
105
|
+
return IsLocalEmbeddingStaleHelper(this, embeddingModelID);
|
|
106
|
+
}
|
|
103
107
|
/** This component as the guard reads it. Built here because `ActiveUser` is protected on `BaseEntity`. */
|
|
104
108
|
get guardedRow() {
|
|
105
109
|
return {
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"MJComponentEntityServer.server.js","sourceRoot":"","sources":["../../src/custom/MJComponentEntityServer.server.ts"],"names":[],"mappings":";;;;;;AAAA,OAAO,EACH,UAAU,GAKb,MAAM,sBAAsB,CAAC;AAC9B,OAAO,EAAE,aAAa,EAAE,MAAM,wBAAwB,CAAC;AACvD,OAAO,EAAE,gCAAgC,EAAE,yBAAyB,EAAE,MAAM,+BAA+B,CAAC;AAC5G,OAAO,EAAE,oBAAoB,EAAE,MAAM,QAAQ,CAAC;
|
|
1
|
+
{"version":3,"file":"MJComponentEntityServer.server.js","sourceRoot":"","sources":["../../src/custom/MJComponentEntityServer.server.ts"],"names":[],"mappings":";;;;;;AAAA,OAAO,EACH,UAAU,GAKb,MAAM,sBAAsB,CAAC;AAC9B,OAAO,EAAE,aAAa,EAAE,MAAM,wBAAwB,CAAC;AACvD,OAAO,EAAE,gCAAgC,EAAE,yBAAyB,EAAE,MAAM,+BAA+B,CAAC;AAC5G,OAAO,EAAE,oBAAoB,EAAE,2BAA2B,EAAE,MAAM,QAAQ,CAAC;AAC3E,OAAO,EAAE,sBAAsB,EAAE,MAAM,kBAAkB,CAAC;AAC1D,OAAO,EAAE,qBAAqB,EAA4B,MAAM,sBAAsB,CAAC;AACvF,OAAO,EAAE,uBAAuB,EAAE,qBAAqB,EAAE,MAAM,iBAAiB,CAAC;AAEjF;;;;;;;;;;;;;;;;;;;;;;;;;;;GA2BG;AAEI,IAAM,uBAAuB,GAA7B,MAAM,uBAAwB,SAAQ,y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C/B,uBAAuB,CAqFnC"}
|
|
@@ -1,48 +1,38 @@
|
|
|
1
1
|
import { EntitySaveOptions } from "@memberjunction/core";
|
|
2
2
|
import { MJConversationDetailEntityExtended } from "@memberjunction/core-entities";
|
|
3
3
|
/**
|
|
4
|
-
* Server-side subclass of MJConversationDetailEntity that
|
|
5
|
-
* when the original message content has been modified
|
|
6
|
-
* each new message.
|
|
7
|
-
*
|
|
8
|
-
*
|
|
9
|
-
*
|
|
10
|
-
*
|
|
11
|
-
*
|
|
12
|
-
*
|
|
13
|
-
*
|
|
14
|
-
*
|
|
15
|
-
* summary is explicitly lossy; agents page in exact rows via the retrieval tools).
|
|
16
|
-
*
|
|
17
|
-
* Extends {@link MJConversationDetailEntityExtended} rather than the generated entity
|
|
18
|
-
* directly. Both classes register for `BaseEntity` under the key
|
|
19
|
-
* `'MJ: Conversation Details'`, and `@RegisterClass` passes `priority = 0`, which routes
|
|
20
|
-
* to the auto-increment branch — so whichever registers LAST wins outright. On the server
|
|
21
|
-
* this package loads after `@memberjunction/core-entities`, which meant this class replaced
|
|
22
|
-
* the Extended one and its `Save`/`Delete` permission gate never ran. That gate is the check
|
|
23
|
-
* that only a conversation's owner may set `UserRating` / `UserFeedback`, and that a
|
|
24
|
-
* non-owner without a resource grant cannot write at all — and it is explicitly designed to
|
|
25
|
-
* run server-side (`ProviderType === 'Database'`), which is exactly where it was being
|
|
26
|
-
* shadowed out. Inheriting composes the two behaviors instead: this class flags the edit,
|
|
27
|
-
* then delegates to the permission gate via `super.Save`.
|
|
28
|
-
*
|
|
29
|
-
* A new row keeps the `BranchID` its writer set (null is Main). On create, a non-null `BranchID`
|
|
30
|
-
* must name a fork of the same conversation; otherwise `Save` returns `false` with a result
|
|
31
|
-
* entry and nothing is written.
|
|
4
|
+
* Server-side subclass of MJConversationDetailEntity that:
|
|
5
|
+
* 1. Automatically tracks when the original message content has been modified (`OriginalMessageChanged`).
|
|
6
|
+
* 2. Checks the fork (`BranchID`) of each new message on create.
|
|
7
|
+
* 3. Inspects comments posted on anchored conversations (`LinkedEntityID` + `LinkedRecordID`)
|
|
8
|
+
* when the target entity has `FieldLevelSecurityApplies === true`:
|
|
9
|
+
* - Runs two-stage restricted-field detection (deterministic field/label/value matching + semantic LLM classifier).
|
|
10
|
+
* - Refuses the save if the authoring user is denied Read access on a restricted field referenced by their comment.
|
|
11
|
+
* - Stamps any detected restricted field names into the parent conversation's
|
|
12
|
+
* `AnchorMetadataObject.restrictedFields` so all subsequent reads filter deterministically in 0ms.
|
|
13
|
+
* 4. Delegates to {@link MJConversationDetailEntityExtended} for write-access, authorship,
|
|
14
|
+
* server-authored reply validation, and `@mention` notification dispatch.
|
|
32
15
|
*/
|
|
33
16
|
export declare class MJConversationDetailEntityServer extends MJConversationDetailEntityExtended {
|
|
34
17
|
/**
|
|
35
18
|
* Sets the OriginalMessageChanged flag on a genuine message edit, checks a new row's fork,
|
|
36
|
-
* then calls super.Save().
|
|
19
|
+
* runs FLS restricted-field inspection for anchored conversations, then calls super.Save().
|
|
37
20
|
*/
|
|
38
21
|
Save(options?: EntitySaveOptions): Promise<boolean>;
|
|
22
|
+
/**
|
|
23
|
+
* When saving a message in an anchored conversation (`LinkedEntityID` + `LinkedRecordID`) whose
|
|
24
|
+
* target entity has `FieldLevelSecurityApplies === true`, runs {@link InspectAndStampRestrictedFieldsForComment}
|
|
25
|
+
* to block restricted-field probing by unauthorized authors and stamp `restrictedFields` onto the
|
|
26
|
+
* parent conversation's `AnchorMetadataObject`.
|
|
27
|
+
*/
|
|
28
|
+
CheckAndStampAnchoredRestrictedFields(): Promise<string | null>;
|
|
39
29
|
/**
|
|
40
30
|
* On create, a non-null BranchID must name a fork of the same conversation. Returns why the save
|
|
41
31
|
* must fail, or null when it may go on. An existing row, a Main row (null BranchID), a row with no
|
|
42
32
|
* ConversationID and a save with no context user are not checked.
|
|
43
33
|
*/
|
|
44
34
|
CheckBranchOnCreate(): Promise<string | null>;
|
|
45
|
-
/** Records a failed create in the result history, so callers see why nothing was written. */
|
|
35
|
+
/** Records a failed create/save in the result history, so callers see why nothing was written. */
|
|
46
36
|
private recordCreateFailure;
|
|
47
37
|
/**
|
|
48
38
|
* True when this save is a genuine Message EDIT on an existing record — not one of
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"MJConversationDetailEntityServer.server.d.ts","sourceRoot":"","sources":["../../src/custom/MJConversationDetailEntityServer.server.ts"],"names":[],"mappings":"AAAA,OAAO,
|
|
1
|
+
{"version":3,"file":"MJConversationDetailEntityServer.server.d.ts","sourceRoot":"","sources":["../../src/custom/MJConversationDetailEntityServer.server.ts"],"names":[],"mappings":"AAAA,OAAO,EAGH,iBAAiB,EAKpB,MAAM,sBAAsB,CAAC;AAE9B,OAAO,EAAE,kCAAkC,EAAwB,MAAM,+BAA+B,CAAC;AAGzG;;;;;;;;;;;;GAYG;AACH,qBACa,gCAAiC,SAAQ,kCAAkC;IACpF;;;OAGG;IACY,IAAI,CAAC,OAAO,CAAC,EAAE,iBAAiB,GAAG,OAAO,CAAC,OAAO,CAAC;IAoBlE;;;;;OAKG;IACU,qCAAqC,IAAI,OAAO,CAAC,MAAM,GAAG,IAAI,CAAC;IAsE5E;;;;OAIG;IACU,mBAAmB,IAAI,OAAO,CAAC,MAAM,GAAG,IAAI,CAAC;IAgC1D,kGAAkG;IAClG,OAAO,CAAC,mBAAmB;IAU3B;;;;;;;;;;;OAWG;IACI,gCAAgC,IAAI,OAAO;CAiBrD"}
|
|
@@ -4,43 +4,28 @@ 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
|
-
|
|
7
|
+
var MJConversationDetailEntityServer_1;
|
|
8
|
+
import { BaseEntity, BaseEntityResult, LogError, RunView, WellKnownUserSource } from "@memberjunction/core";
|
|
8
9
|
import { EscapeSQLString, RegisterClass, UUIDsEqual } from "@memberjunction/global";
|
|
9
10
|
import { MJConversationDetailEntityExtended } from "@memberjunction/core-entities";
|
|
11
|
+
import { InspectAndStampRestrictedFieldsForComment } from "./RestrictedFieldCommentClassifier.js";
|
|
10
12
|
/**
|
|
11
|
-
* Server-side subclass of MJConversationDetailEntity that
|
|
12
|
-
* when the original message content has been modified
|
|
13
|
-
* each new message.
|
|
14
|
-
*
|
|
15
|
-
*
|
|
16
|
-
*
|
|
17
|
-
*
|
|
18
|
-
*
|
|
19
|
-
*
|
|
20
|
-
*
|
|
21
|
-
*
|
|
22
|
-
* summary is explicitly lossy; agents page in exact rows via the retrieval tools).
|
|
23
|
-
*
|
|
24
|
-
* Extends {@link MJConversationDetailEntityExtended} rather than the generated entity
|
|
25
|
-
* directly. Both classes register for `BaseEntity` under the key
|
|
26
|
-
* `'MJ: Conversation Details'`, and `@RegisterClass` passes `priority = 0`, which routes
|
|
27
|
-
* to the auto-increment branch — so whichever registers LAST wins outright. On the server
|
|
28
|
-
* this package loads after `@memberjunction/core-entities`, which meant this class replaced
|
|
29
|
-
* the Extended one and its `Save`/`Delete` permission gate never ran. That gate is the check
|
|
30
|
-
* that only a conversation's owner may set `UserRating` / `UserFeedback`, and that a
|
|
31
|
-
* non-owner without a resource grant cannot write at all — and it is explicitly designed to
|
|
32
|
-
* run server-side (`ProviderType === 'Database'`), which is exactly where it was being
|
|
33
|
-
* shadowed out. Inheriting composes the two behaviors instead: this class flags the edit,
|
|
34
|
-
* then delegates to the permission gate via `super.Save`.
|
|
35
|
-
*
|
|
36
|
-
* A new row keeps the `BranchID` its writer set (null is Main). On create, a non-null `BranchID`
|
|
37
|
-
* must name a fork of the same conversation; otherwise `Save` returns `false` with a result
|
|
38
|
-
* entry and nothing is written.
|
|
13
|
+
* Server-side subclass of MJConversationDetailEntity that:
|
|
14
|
+
* 1. Automatically tracks when the original message content has been modified (`OriginalMessageChanged`).
|
|
15
|
+
* 2. Checks the fork (`BranchID`) of each new message on create.
|
|
16
|
+
* 3. Inspects comments posted on anchored conversations (`LinkedEntityID` + `LinkedRecordID`)
|
|
17
|
+
* when the target entity has `FieldLevelSecurityApplies === true`:
|
|
18
|
+
* - Runs two-stage restricted-field detection (deterministic field/label/value matching + semantic LLM classifier).
|
|
19
|
+
* - Refuses the save if the authoring user is denied Read access on a restricted field referenced by their comment.
|
|
20
|
+
* - Stamps any detected restricted field names into the parent conversation's
|
|
21
|
+
* `AnchorMetadataObject.restrictedFields` so all subsequent reads filter deterministically in 0ms.
|
|
22
|
+
* 4. Delegates to {@link MJConversationDetailEntityExtended} for write-access, authorship,
|
|
23
|
+
* server-authored reply validation, and `@mention` notification dispatch.
|
|
39
24
|
*/
|
|
40
|
-
let MJConversationDetailEntityServer = class MJConversationDetailEntityServer extends MJConversationDetailEntityExtended {
|
|
25
|
+
let MJConversationDetailEntityServer = MJConversationDetailEntityServer_1 = class MJConversationDetailEntityServer extends MJConversationDetailEntityExtended {
|
|
41
26
|
/**
|
|
42
27
|
* Sets the OriginalMessageChanged flag on a genuine message edit, checks a new row's fork,
|
|
43
|
-
* then calls super.Save().
|
|
28
|
+
* runs FLS restricted-field inspection for anchored conversations, then calls super.Save().
|
|
44
29
|
*/
|
|
45
30
|
async Save(options) {
|
|
46
31
|
if (this.ShouldFlagOriginalMessageChanged()) {
|
|
@@ -51,8 +36,77 @@ let MJConversationDetailEntityServer = class MJConversationDetailEntityServer ex
|
|
|
51
36
|
this.recordCreateFailure(problem);
|
|
52
37
|
return false;
|
|
53
38
|
}
|
|
39
|
+
const checkFls = this.CheckAndStampAnchoredRestrictedFields ??
|
|
40
|
+
MJConversationDetailEntityServer_1.prototype.CheckAndStampAnchoredRestrictedFields;
|
|
41
|
+
const flsRefusal = await checkFls.call(this);
|
|
42
|
+
if (flsRefusal) {
|
|
43
|
+
this.recordCreateFailure(flsRefusal, this.IsSaved ? 'update' : 'create');
|
|
44
|
+
return false;
|
|
45
|
+
}
|
|
54
46
|
return super.Save(options);
|
|
55
47
|
}
|
|
48
|
+
/**
|
|
49
|
+
* When saving a message in an anchored conversation (`LinkedEntityID` + `LinkedRecordID`) whose
|
|
50
|
+
* target entity has `FieldLevelSecurityApplies === true`, runs {@link InspectAndStampRestrictedFieldsForComment}
|
|
51
|
+
* to block restricted-field probing by unauthorized authors and stamp `restrictedFields` onto the
|
|
52
|
+
* parent conversation's `AnchorMetadataObject`.
|
|
53
|
+
*/
|
|
54
|
+
async CheckAndStampAnchoredRestrictedFields() {
|
|
55
|
+
const provider = this.ProviderToUse;
|
|
56
|
+
if (provider?.ProviderType !== 'Database') {
|
|
57
|
+
return null;
|
|
58
|
+
}
|
|
59
|
+
const user = this.ContextCurrentUser;
|
|
60
|
+
if (!user || !this.ConversationID) {
|
|
61
|
+
return null;
|
|
62
|
+
}
|
|
63
|
+
// Only inspect on new messages or when Message text is being modified
|
|
64
|
+
if (this.IsSaved && !this.GetFieldByName('Message')?.Dirty) {
|
|
65
|
+
return null;
|
|
66
|
+
}
|
|
67
|
+
try {
|
|
68
|
+
const systemUser = (await WellKnownUserSource.Instance.GetSystemUser(provider)) ?? user;
|
|
69
|
+
const conversation = await provider.GetEntityObject('MJ: Conversations', systemUser);
|
|
70
|
+
const loaded = await conversation.Load(this.ConversationID);
|
|
71
|
+
if (!loaded || !conversation.AnchorType || !conversation.LinkedEntityID || !conversation.LinkedRecordID) {
|
|
72
|
+
return null;
|
|
73
|
+
}
|
|
74
|
+
const entityInfo = (typeof provider.EntityByID === 'function'
|
|
75
|
+
? provider.EntityByID(conversation.LinkedEntityID)
|
|
76
|
+
: undefined) ??
|
|
77
|
+
provider.Entities?.find((e) => UUIDsEqual(e.ID, conversation.LinkedEntityID)) ??
|
|
78
|
+
null;
|
|
79
|
+
if (!entityInfo) {
|
|
80
|
+
return null;
|
|
81
|
+
}
|
|
82
|
+
if (!WellKnownUserSource.Instance.IsSystemUser(user)) {
|
|
83
|
+
if (entityInfo.AllowRecordComments === false) {
|
|
84
|
+
return `Record commenting is disabled for ${entityInfo.DisplayNameOrName}.`;
|
|
85
|
+
}
|
|
86
|
+
if (typeof entityInfo.CanUserComment === 'function' && !entityInfo.CanUserComment(user)) {
|
|
87
|
+
return `You do not have permission to post comments on ${entityInfo.DisplayNameOrName} records.`;
|
|
88
|
+
}
|
|
89
|
+
}
|
|
90
|
+
if (!entityInfo.FieldLevelSecurityApplies) {
|
|
91
|
+
return null;
|
|
92
|
+
}
|
|
93
|
+
const inspection = await InspectAndStampRestrictedFieldsForComment({
|
|
94
|
+
Provider: provider,
|
|
95
|
+
ContextUser: user,
|
|
96
|
+
Conversation: conversation,
|
|
97
|
+
EntityInfo: entityInfo,
|
|
98
|
+
MessageText: this.Message
|
|
99
|
+
});
|
|
100
|
+
if (!inspection.Allowed) {
|
|
101
|
+
return inspection.Reason ?? 'You do not have permission to comment on this restricted field.';
|
|
102
|
+
}
|
|
103
|
+
return null;
|
|
104
|
+
}
|
|
105
|
+
catch (error) {
|
|
106
|
+
LogError(`MJConversationDetailEntityServer.CheckAndStampAnchoredRestrictedFields failed on conversation ${this.ConversationID}: ${error instanceof Error ? error.message : String(error)}`);
|
|
107
|
+
return null;
|
|
108
|
+
}
|
|
109
|
+
}
|
|
56
110
|
/**
|
|
57
111
|
* On create, a non-null BranchID must name a fork of the same conversation. Returns why the save
|
|
58
112
|
* must fail, or null when it may go on. An existing row, a Main row (null BranchID), a row with no
|
|
@@ -90,11 +144,11 @@ let MJConversationDetailEntityServer = class MJConversationDetailEntityServer ex
|
|
|
90
144
|
return 'Unable to check the fork of this message.';
|
|
91
145
|
}
|
|
92
146
|
}
|
|
93
|
-
/** Records a failed create in the result history, so callers see why nothing was written. */
|
|
94
|
-
recordCreateFailure(message) {
|
|
147
|
+
/** Records a failed create/save in the result history, so callers see why nothing was written. */
|
|
148
|
+
recordCreateFailure(message, type = 'create') {
|
|
95
149
|
const result = new BaseEntityResult();
|
|
96
150
|
result.Success = false;
|
|
97
|
-
result.Type =
|
|
151
|
+
result.Type = type;
|
|
98
152
|
result.Message = message;
|
|
99
153
|
result.StartedAt = new Date();
|
|
100
154
|
result.EndedAt = new Date();
|
|
@@ -130,7 +184,7 @@ let MJConversationDetailEntityServer = class MJConversationDetailEntityServer ex
|
|
|
130
184
|
return true;
|
|
131
185
|
}
|
|
132
186
|
};
|
|
133
|
-
MJConversationDetailEntityServer = __decorate([
|
|
187
|
+
MJConversationDetailEntityServer = MJConversationDetailEntityServer_1 = __decorate([
|
|
134
188
|
RegisterClass(BaseEntity, "MJ: Conversation Details")
|
|
135
189
|
], MJConversationDetailEntityServer);
|
|
136
190
|
export { MJConversationDetailEntityServer };
|