@memberjunction/entity-documents 0.0.0 → 6.2.0-edge.0
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/LICENSE +183 -0
- package/dist/generic/EntityDocumentTemplateParser.d.ts +32 -0
- package/dist/generic/EntityDocumentTemplateParser.d.ts.map +1 -0
- package/dist/generic/EntityDocumentTemplateParser.js +141 -0
- package/dist/generic/EntityDocumentTemplateParser.js.map +1 -0
- package/dist/generic/EntityDocumentTemplateParserBase.d.ts +34 -0
- package/dist/generic/EntityDocumentTemplateParserBase.d.ts.map +1 -0
- package/dist/generic/EntityDocumentTemplateParserBase.js +132 -0
- package/dist/generic/EntityDocumentTemplateParserBase.js.map +1 -0
- package/dist/index.d.ts +4 -0
- package/dist/index.d.ts.map +1 -0
- package/dist/index.js +4 -0
- package/dist/index.js.map +1 -0
- package/dist/models/EntityDocumentCache.d.ts +31 -0
- package/dist/models/EntityDocumentCache.d.ts.map +1 -0
- package/dist/models/EntityDocumentCache.js +100 -0
- package/dist/models/EntityDocumentCache.js.map +1 -0
- package/package.json +32 -8
- package/README.md +0 -45
package/LICENSE
ADDED
|
@@ -0,0 +1,183 @@
|
|
|
1
|
+
Business Source License 1.1
|
|
2
|
+
|
|
3
|
+
License text copyright (c) 2024 MariaDB plc, All Rights Reserved.
|
|
4
|
+
"Business Source License" is a trademark of MariaDB plc.
|
|
5
|
+
|
|
6
|
+
-----------------------------------------------------------------------------
|
|
7
|
+
|
|
8
|
+
Parameters
|
|
9
|
+
|
|
10
|
+
Licensor: Blue Cypress, Inc.
|
|
11
|
+
|
|
12
|
+
Licensed Work: MemberJunction.
|
|
13
|
+
The Licensed Work is (c) 2023-2026 Blue Cypress, Inc.
|
|
14
|
+
|
|
15
|
+
Additional Use Grant: Subject to the terms of this License, Licensor grants
|
|
16
|
+
you the following additional rights to make Production
|
|
17
|
+
Use of the Licensed Work.
|
|
18
|
+
|
|
19
|
+
1. Internal Use
|
|
20
|
+
|
|
21
|
+
You may make production use of the Licensed Work for
|
|
22
|
+
your own internal business or organizational operations.
|
|
23
|
+
|
|
24
|
+
2. Nonprofit Use
|
|
25
|
+
|
|
26
|
+
If you are a Nonprofit, you may make production use of
|
|
27
|
+
the Licensed Work for the operations and activities of
|
|
28
|
+
your Organizational Family.
|
|
29
|
+
|
|
30
|
+
3. MemberJunction Certified Program Use
|
|
31
|
+
|
|
32
|
+
If you are authorized by Licensor under the
|
|
33
|
+
MemberJunction Certified Program to provide professional
|
|
34
|
+
services using the Licensed Work, you may make
|
|
35
|
+
production use of the Licensed Work in providing such
|
|
36
|
+
professional services to a client, provided that:
|
|
37
|
+
|
|
38
|
+
(a) the Licensed Work is deployed in, and the applicable
|
|
39
|
+
production use occurs within, an environment owned,
|
|
40
|
+
leased, licensed, subscribed to, or otherwise controlled
|
|
41
|
+
by that client; and
|
|
42
|
+
|
|
43
|
+
(b) the production use is for that client's own internal
|
|
44
|
+
business or organizational operations or is otherwise
|
|
45
|
+
independently permitted to that client under this
|
|
46
|
+
Additional Use Grant.
|
|
47
|
+
|
|
48
|
+
4. Definitions Applicable to the Additional Use Grant
|
|
49
|
+
|
|
50
|
+
"Affiliate" means, with respect to a specified Person,
|
|
51
|
+
any other Person that directly or indirectly Controls,
|
|
52
|
+
is Controlled by, or is under common Control with such
|
|
53
|
+
specified Person.
|
|
54
|
+
|
|
55
|
+
"Control" (including the terms "Controls," "Controlled
|
|
56
|
+
by," and "under common Control with") means the direct
|
|
57
|
+
or indirect possession of the power to direct or cause
|
|
58
|
+
the direction of the management and policies of a
|
|
59
|
+
Person, whether through ownership of voting interests,
|
|
60
|
+
by contract, or otherwise.
|
|
61
|
+
|
|
62
|
+
"Organizational Family" means, with respect to a Person,
|
|
63
|
+
(a) such Person and its Affiliates, and (b) any
|
|
64
|
+
nonprofit organization, governmental entity, chapter,
|
|
65
|
+
division, local affiliate, regional affiliate, state
|
|
66
|
+
affiliate, national affiliate, or other entity that is
|
|
67
|
+
formally affiliated with such Person through governing
|
|
68
|
+
documents, a charter, bylaws, a membership agreement, or
|
|
69
|
+
another written organizational instrument, and is
|
|
70
|
+
recognized under such documents as part of the same
|
|
71
|
+
organizational structure.
|
|
72
|
+
|
|
73
|
+
"Nonprofit" means a Person recognized by the Internal
|
|
74
|
+
Revenue Service as exempt from federal income taxation
|
|
75
|
+
under Section 501(c)(3), 501(c)(4), 501(c)(5), or
|
|
76
|
+
501(c)(6) of the Internal Revenue Code, or a foreign
|
|
77
|
+
organization recognized under substantially equivalent
|
|
78
|
+
laws.
|
|
79
|
+
|
|
80
|
+
A Person claiming eligibility as a Nonprofit shall, upon
|
|
81
|
+
Licensor's reasonable request, provide documentation
|
|
82
|
+
reasonably sufficient to demonstrate that it qualifies
|
|
83
|
+
as a Nonprofit. If such Person materially misrepresents,
|
|
84
|
+
or is unable to demonstrate, its qualification as a
|
|
85
|
+
Nonprofit, the rights granted to such Person under
|
|
86
|
+
Section 2 of this Additional Use Grant shall terminate.
|
|
87
|
+
|
|
88
|
+
"MemberJunction Certified Program" means Licensor's
|
|
89
|
+
then-current program for certifying and authorizing a
|
|
90
|
+
Person to provide professional services using the
|
|
91
|
+
Licensed Work.
|
|
92
|
+
|
|
93
|
+
"Person" means any individual, corporation, limited
|
|
94
|
+
liability company, partnership, association, nonprofit
|
|
95
|
+
organization, governmental entity, or other legal or
|
|
96
|
+
organizational entity.
|
|
97
|
+
|
|
98
|
+
Change Date: Four (4) years from the date the Licensed Work is first
|
|
99
|
+
made available.
|
|
100
|
+
|
|
101
|
+
Change License: MIT License.
|
|
102
|
+
|
|
103
|
+
For information about alternative licensing arrangements for the Licensed
|
|
104
|
+
Work, please contact Blue Cypress, Inc.
|
|
105
|
+
|
|
106
|
+
-----------------------------------------------------------------------------
|
|
107
|
+
|
|
108
|
+
Terms
|
|
109
|
+
|
|
110
|
+
The Licensor hereby grants you the right to copy, modify, create derivative
|
|
111
|
+
works, redistribute, and make non-production use of the Licensed Work. The
|
|
112
|
+
Licensor may make an Additional Use Grant, above, permitting limited
|
|
113
|
+
production use.
|
|
114
|
+
|
|
115
|
+
Effective on the Change Date, or the fourth anniversary of the first publicly
|
|
116
|
+
available distribution of a specific version of the Licensed Work under this
|
|
117
|
+
License, whichever comes first, the Licensor hereby grants you rights under
|
|
118
|
+
the terms of the Change License, and the rights granted in the paragraph
|
|
119
|
+
above terminate.
|
|
120
|
+
|
|
121
|
+
If your use of the Licensed Work does not comply with the requirements
|
|
122
|
+
currently in effect as described in this License, you must purchase a
|
|
123
|
+
commercial license from the Licensor, its affiliated entities, or authorized
|
|
124
|
+
resellers, or you must refrain from using the Licensed Work.
|
|
125
|
+
|
|
126
|
+
All copies of the original and modified Licensed Work, and derivative works
|
|
127
|
+
of the Licensed Work, are subject to this License. This License applies
|
|
128
|
+
separately for each version of the Licensed Work and the Change Date may vary
|
|
129
|
+
for each version of the Licensed Work released by Licensor.
|
|
130
|
+
|
|
131
|
+
You must conspicuously display this License on each original or modified copy
|
|
132
|
+
of the Licensed Work. If you receive the Licensed Work in original or
|
|
133
|
+
modified form from a third party, the terms and conditions set forth in this
|
|
134
|
+
License apply to your use of that work.
|
|
135
|
+
|
|
136
|
+
Any use of the Licensed Work in violation of this License will automatically
|
|
137
|
+
terminate your rights under this License for the current and all other
|
|
138
|
+
versions of the Licensed Work.
|
|
139
|
+
|
|
140
|
+
This License does not grant you any right in any trademark or logo of
|
|
141
|
+
Licensor or its affiliates (provided that you may use a trademark or logo of
|
|
142
|
+
Licensor as expressly required by this License).
|
|
143
|
+
|
|
144
|
+
TO THE EXTENT PERMITTED BY APPLICABLE LAW, THE LICENSED WORK IS PROVIDED ON
|
|
145
|
+
AN "AS IS" BASIS. LICENSOR HEREBY DISCLAIMS ALL WARRANTIES AND CONDITIONS,
|
|
146
|
+
EXPRESS OR IMPLIED, INCLUDING (WITHOUT LIMITATION) WARRANTIES OF
|
|
147
|
+
MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE, NON-INFRINGEMENT, AND
|
|
148
|
+
TITLE.
|
|
149
|
+
|
|
150
|
+
MariaDB hereby grants you permission to use this License's text to license
|
|
151
|
+
your works, and to refer to it using the trademark "Business Source License",
|
|
152
|
+
as long as you comply with the Covenants of Licensor below.
|
|
153
|
+
|
|
154
|
+
-----------------------------------------------------------------------------
|
|
155
|
+
|
|
156
|
+
Covenants of Licensor
|
|
157
|
+
|
|
158
|
+
In consideration of the right to use this License's text and the "Business
|
|
159
|
+
Source License" name and trademark, Licensor covenants to MariaDB, and to all
|
|
160
|
+
other recipients of the licensed work to be provided by Licensor:
|
|
161
|
+
|
|
162
|
+
1. To specify as the Change License the GPL Version 2.0 or any later version,
|
|
163
|
+
or a license that is compatible with GPL Version 2.0 or a later version,
|
|
164
|
+
where "compatible" means that software provided under the Change License
|
|
165
|
+
can be included in a program with software provided under GPL Version 2.0
|
|
166
|
+
or a later version. Licensor may specify additional Change Licenses without
|
|
167
|
+
limitation.
|
|
168
|
+
|
|
169
|
+
2. To either: (a) specify an additional grant of rights to use that does not
|
|
170
|
+
impose any additional restriction on the right granted in this License, as
|
|
171
|
+
the Additional Use Grant; or (b) insert the text "None".
|
|
172
|
+
|
|
173
|
+
3. To specify a Change Date.
|
|
174
|
+
|
|
175
|
+
4. Not to modify this License in any other way.
|
|
176
|
+
|
|
177
|
+
-----------------------------------------------------------------------------
|
|
178
|
+
|
|
179
|
+
Notice
|
|
180
|
+
|
|
181
|
+
The Business Source License (this document, or the "License") is not an Open
|
|
182
|
+
Source license. However, the Licensed Work will eventually be made available
|
|
183
|
+
under an Open Source License, as stated in this License.
|
|
@@ -0,0 +1,32 @@
|
|
|
1
|
+
import { UserInfo } from '@memberjunction/core';
|
|
2
|
+
import { MJEntityDocumentEntity } from '@memberjunction/core-entities';
|
|
3
|
+
import { EntityDocumentTemplateParserBase } from './EntityDocumentTemplateParserBase.js';
|
|
4
|
+
/**
|
|
5
|
+
* First-level subclass of EntityDocumentTemplateParserBase used to parse entity document templates
|
|
6
|
+
* with variables, dotted context paths (__Parent), and functions such as Relationship().
|
|
7
|
+
*/
|
|
8
|
+
export declare class EntityDocumentTemplateParser extends EntityDocumentTemplateParserBase {
|
|
9
|
+
/** Convenience factory method to get an instance via ClassFactory, allowing registered subclass overrides */
|
|
10
|
+
static CreateInstance(): EntityDocumentTemplateParser;
|
|
11
|
+
/**
|
|
12
|
+
* Resolves related records for an entity and recursively renders a child Entity Document over each.
|
|
13
|
+
*
|
|
14
|
+
* @param entityID - ID of the parent entity
|
|
15
|
+
* @param entityRecord - Data of the parent entity record
|
|
16
|
+
* @param ContextUser - Current user info
|
|
17
|
+
* @param relationshipName - Name of the related entity / relationship
|
|
18
|
+
* @param maxRows - Maximum number of related rows to load
|
|
19
|
+
* @param entityDocumentName - Name of the child Entity Document to render over each related row
|
|
20
|
+
* @returns Concatenated rendered output for all related rows, or raw JSON data if no document specified
|
|
21
|
+
*/
|
|
22
|
+
protected Relationship(entityID: string, entityRecord: Record<string, unknown>, ContextUser: UserInfo, relationshipName: string, maxRows: number, entityDocumentName: string): Promise<string>;
|
|
23
|
+
/**
|
|
24
|
+
* Resolves the template text from an Entity Document.
|
|
25
|
+
* Priority:
|
|
26
|
+
* 1. doc.TemplateText virtual property (MJEntityDocumentEntityExtended)
|
|
27
|
+
* 2. TemplateEngine cached contents for doc.TemplateID
|
|
28
|
+
* 3. RunView on MJ: Template Contents
|
|
29
|
+
*/
|
|
30
|
+
resolveDocumentTemplateText(doc: MJEntityDocumentEntity, contextUser: UserInfo): Promise<string>;
|
|
31
|
+
}
|
|
32
|
+
//# sourceMappingURL=EntityDocumentTemplateParser.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"EntityDocumentTemplateParser.d.ts","sourceRoot":"","sources":["../../src/generic/EntityDocumentTemplateParser.ts"],"names":[],"mappings":"AAAA,OAAO,EAA6D,QAAQ,EAAE,MAAM,sBAAsB,CAAC;AAE3G,OAAO,EAAE,sBAAsB,EAA2B,MAAM,+BAA+B,CAAC;AAEhG,OAAO,EAAE,gCAAgC,EAAE,MAAM,oCAAoC,CAAC;AAQtF;;;GAGG;AACH,qBAAa,4BAA6B,SAAQ,gCAAgC;IAChF,6GAA6G;WAC/F,cAAc,IAAI,4BAA4B;IAI5D;;;;;;;;;;OAUG;cACa,YAAY,CAC1B,QAAQ,EAAE,MAAM,EAChB,YAAY,EAAE,MAAM,CAAC,MAAM,EAAE,OAAO,CAAC,EACrC,WAAW,EAAE,QAAQ,EACrB,gBAAgB,EAAE,MAAM,EACxB,OAAO,EAAE,MAAM,EACf,kBAAkB,EAAE,MAAM,GACzB,OAAO,CAAC,MAAM,CAAC;IAqElB;;;;;;OAMG;IACU,2BAA2B,CAAC,GAAG,EAAE,sBAAsB,EAAE,WAAW,EAAE,QAAQ,GAAG,OAAO,CAAC,MAAM,CAAC;CAwD9G"}
|
|
@@ -0,0 +1,141 @@
|
|
|
1
|
+
import { CompositeKey, LogError, LogStatus, RunView } from '@memberjunction/core';
|
|
2
|
+
import { EscapeSQLString, MJGlobal, UUIDsEqual } from '@memberjunction/global';
|
|
3
|
+
import { TemplateEngineServer } from '@memberjunction/templates';
|
|
4
|
+
import { EntityDocumentTemplateParserBase } from './EntityDocumentTemplateParserBase.js';
|
|
5
|
+
import { EntityDocumentCache } from '../models/EntityDocumentCache.js';
|
|
6
|
+
/**
|
|
7
|
+
* First-level subclass of EntityDocumentTemplateParserBase used to parse entity document templates
|
|
8
|
+
* with variables, dotted context paths (__Parent), and functions such as Relationship().
|
|
9
|
+
*/
|
|
10
|
+
export class EntityDocumentTemplateParser extends EntityDocumentTemplateParserBase {
|
|
11
|
+
/** Convenience factory method to get an instance via ClassFactory, allowing registered subclass overrides */
|
|
12
|
+
static CreateInstance() {
|
|
13
|
+
return MJGlobal.Instance.ClassFactory.CreateInstance(EntityDocumentTemplateParser);
|
|
14
|
+
}
|
|
15
|
+
/**
|
|
16
|
+
* Resolves related records for an entity and recursively renders a child Entity Document over each.
|
|
17
|
+
*
|
|
18
|
+
* @param entityID - ID of the parent entity
|
|
19
|
+
* @param entityRecord - Data of the parent entity record
|
|
20
|
+
* @param ContextUser - Current user info
|
|
21
|
+
* @param relationshipName - Name of the related entity / relationship
|
|
22
|
+
* @param maxRows - Maximum number of related rows to load
|
|
23
|
+
* @param entityDocumentName - Name of the child Entity Document to render over each related row
|
|
24
|
+
* @returns Concatenated rendered output for all related rows, or raw JSON data if no document specified
|
|
25
|
+
*/
|
|
26
|
+
async Relationship(entityID, entityRecord, ContextUser, relationshipName, maxRows, entityDocumentName) {
|
|
27
|
+
// G6 Note: Relationship() loads related entities per parent row. Batch-optimizing
|
|
28
|
+
// related-record loading across multi-row batches is mapped in plans/feature-pipelines-build-plan.md (§3 D12, G6).
|
|
29
|
+
const md = this.ProviderToUse;
|
|
30
|
+
const entityInfo = md.Entities.find((e) => UUIDsEqual(e.ID, entityID));
|
|
31
|
+
if (!entityInfo) {
|
|
32
|
+
throw new Error(`Entity with ID ${entityID} not found.`);
|
|
33
|
+
}
|
|
34
|
+
const re = entityInfo.RelatedEntities.find((r) => r.RelatedEntity === relationshipName);
|
|
35
|
+
if (!re) {
|
|
36
|
+
throw new Error(`Relationship ${relationshipName} not found for entity ${entityInfo.Name}`);
|
|
37
|
+
}
|
|
38
|
+
const obj = await md.GetEntityObject(entityInfo.Name, ContextUser);
|
|
39
|
+
const compositeKey = new CompositeKey();
|
|
40
|
+
compositeKey.LoadFromEntityInfoAndRecord(entityInfo, entityRecord);
|
|
41
|
+
const loadResult = await obj.InnerLoad(compositeKey);
|
|
42
|
+
if (!loadResult) {
|
|
43
|
+
LogError(`Failed to load entity ${entityInfo.Name} with ID ${compositeKey.ToString()}`);
|
|
44
|
+
return '';
|
|
45
|
+
}
|
|
46
|
+
const reData = await obj.GetRelatedEntityDataExt(re, null, maxRows);
|
|
47
|
+
if (reData && reData.Data && reData.Data.length > 0) {
|
|
48
|
+
if (entityDocumentName && entityDocumentName.trim().length > 0) {
|
|
49
|
+
// Resolve child entity document from cache
|
|
50
|
+
const cache = EntityDocumentCache.Instance;
|
|
51
|
+
if (!cache.IsLoaded) {
|
|
52
|
+
await cache.Refresh(false, ContextUser);
|
|
53
|
+
}
|
|
54
|
+
const doc = cache.GetDocumentByName(entityDocumentName);
|
|
55
|
+
if (doc) {
|
|
56
|
+
// Resolve actual template text (C1 fix: never pass the template's name, pass the template's content text)
|
|
57
|
+
const templateText = await this.resolveDocumentTemplateText(doc, ContextUser);
|
|
58
|
+
const parser = EntityDocumentTemplateParser.CreateInstance();
|
|
59
|
+
parser.ProviderOverride = this.ProviderToUse;
|
|
60
|
+
const batchSize = 10;
|
|
61
|
+
const results = [];
|
|
62
|
+
for (let i = 0; i < reData.Data.length; i += batchSize) {
|
|
63
|
+
const batchPromises = reData.Data.slice(i, i + batchSize).map((data) => {
|
|
64
|
+
// D14: Child context gains __Parent pointing to the parent data context, chainable to arbitrary depth
|
|
65
|
+
const childRecord = {
|
|
66
|
+
...data,
|
|
67
|
+
__Parent: entityRecord,
|
|
68
|
+
};
|
|
69
|
+
return parser.Parse(templateText, re.RelatedEntityID, childRecord, ContextUser);
|
|
70
|
+
});
|
|
71
|
+
const batchResults = await Promise.all(batchPromises);
|
|
72
|
+
results.push(...batchResults);
|
|
73
|
+
}
|
|
74
|
+
return results.map((r) => r + '\n\n').join('');
|
|
75
|
+
}
|
|
76
|
+
else {
|
|
77
|
+
LogStatus(`Entity Document with name ${entityDocumentName} not found.`);
|
|
78
|
+
return '';
|
|
79
|
+
}
|
|
80
|
+
}
|
|
81
|
+
else {
|
|
82
|
+
return JSON.stringify({ Relationship: relationshipName, Data: reData.Data });
|
|
83
|
+
}
|
|
84
|
+
}
|
|
85
|
+
else {
|
|
86
|
+
return '{ No Data for: ' + relationshipName + ' }';
|
|
87
|
+
}
|
|
88
|
+
}
|
|
89
|
+
/**
|
|
90
|
+
* Resolves the template text from an Entity Document.
|
|
91
|
+
* Priority:
|
|
92
|
+
* 1. doc.TemplateText virtual property (MJEntityDocumentEntityExtended)
|
|
93
|
+
* 2. TemplateEngine cached contents for doc.TemplateID
|
|
94
|
+
* 3. RunView on MJ: Template Contents
|
|
95
|
+
*/
|
|
96
|
+
async resolveDocumentTemplateText(doc, contextUser) {
|
|
97
|
+
// 1. Virtual property on extended entity subclass if populated
|
|
98
|
+
const virtualDoc = doc;
|
|
99
|
+
if (virtualDoc.TemplateText && virtualDoc.TemplateText.trim().length > 0) {
|
|
100
|
+
return virtualDoc.TemplateText;
|
|
101
|
+
}
|
|
102
|
+
// 2. TemplateEngine cached template contents
|
|
103
|
+
if (doc.TemplateID) {
|
|
104
|
+
const cached = TemplateEngineServer.Instance.TemplateContents.filter((tc) => UUIDsEqual(tc.TemplateID, doc.TemplateID));
|
|
105
|
+
if (cached.length > 0) {
|
|
106
|
+
const sorted = cached.sort((a, b) => {
|
|
107
|
+
const aP = a.Priority ?? 0;
|
|
108
|
+
const bP = b.Priority ?? 0;
|
|
109
|
+
return aP - bP;
|
|
110
|
+
});
|
|
111
|
+
if (sorted[0]?.TemplateText) {
|
|
112
|
+
return sorted[0].TemplateText;
|
|
113
|
+
}
|
|
114
|
+
}
|
|
115
|
+
// Warm template cache if needed
|
|
116
|
+
await TemplateEngineServer.Instance.Config(false, contextUser);
|
|
117
|
+
const afterWarm = TemplateEngineServer.Instance.TemplateContents.filter((tc) => UUIDsEqual(tc.TemplateID, doc.TemplateID));
|
|
118
|
+
if (afterWarm.length > 0) {
|
|
119
|
+
if (afterWarm[0]?.TemplateText) {
|
|
120
|
+
return afterWarm[0].TemplateText;
|
|
121
|
+
}
|
|
122
|
+
}
|
|
123
|
+
// 3. Fallback: RunView lookup for template content
|
|
124
|
+
const rv = new RunView();
|
|
125
|
+
const rvResult = await rv.RunView({
|
|
126
|
+
EntityName: 'MJ: Template Contents',
|
|
127
|
+
ExtraFilter: `TemplateID = '${EscapeSQLString(doc.TemplateID)}'`,
|
|
128
|
+
OrderBy: 'Priority ASC',
|
|
129
|
+
MaxRows: 1,
|
|
130
|
+
ResultType: 'entity_object',
|
|
131
|
+
}, contextUser);
|
|
132
|
+
if (rvResult.Success && rvResult.Results.length > 0 && rvResult.Results[0].TemplateText) {
|
|
133
|
+
return rvResult.Results[0].TemplateText;
|
|
134
|
+
}
|
|
135
|
+
}
|
|
136
|
+
// Fallback: if doc has a Template property that is string, return it as last resort
|
|
137
|
+
const fallbackTemplate = doc.Template;
|
|
138
|
+
return fallbackTemplate ?? '';
|
|
139
|
+
}
|
|
140
|
+
}
|
|
141
|
+
//# sourceMappingURL=EntityDocumentTemplateParser.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"EntityDocumentTemplateParser.js","sourceRoot":"","sources":["../../src/generic/EntityDocumentTemplateParser.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,YAAY,EAAE,QAAQ,EAAE,SAAS,EAAE,OAAO,EAA2B,MAAM,sBAAsB,CAAC;AAC3G,OAAO,EAAE,eAAe,EAAE,QAAQ,EAAiB,UAAU,EAAE,MAAM,wBAAwB,CAAC;AAE9F,OAAO,EAAE,oBAAoB,EAAE,MAAM,2BAA2B,CAAC;AACjE,OAAO,EAAE,gCAAgC,EAAE,MAAM,oCAAoC,CAAC;AACtF,OAAO,EAAE,mBAAmB,EAAE,MAAM,+BAA+B,CAAC;AAOpE;;;GAGG;AACH,MAAM,OAAO,4BAA6B,SAAQ,gCAAgC;IAChF,6GAA6G;IACtG,MAAM,CAAC,cAAc;QAC1B,OAAO,QAAQ,CAAC,QAAQ,CAAC,YAAY,CAAC,cAAc,CAA+B,4BAA4B,CAAC,CAAC;IACnH,CAAC;IAED;;;;;;;;;;OAUG;IACO,KAAK,CAAC,YAAY,CAC1B,QAAgB,EAChB,YAAqC,EACrC,WAAqB,EACrB,gBAAwB,EACxB,OAAe,EACf,kBAA0B;QAE1B,kFAAkF;QAClF,mHAAmH;QACnH,MAAM,EAAE,GAAG,IAAI,CAAC,aAAa,CAAC;QAE9B,MAAM,UAAU,GAAG,EAAE,CAAC,QAAQ,CAAC,IAAI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AC,CAAC,YAAY,CAAC;YAC1C,CAAC;QACH,CAAC;QAED,oFAAoF;QACpF,MAAM,gBAAgB,GAAI,GAAkC,CAAC,QAAQ,CAAC;QACtE,OAAO,gBAAgB,IAAI,EAAE,CAAC;IAChC,CAAC;CACF"}
|
|
@@ -0,0 +1,34 @@
|
|
|
1
|
+
import { IMetadataProvider, UserInfo } from '@memberjunction/core';
|
|
2
|
+
/**
|
|
3
|
+
* Abstract base class for entity document template parsing.
|
|
4
|
+
* Use EntityDocumentTemplateParser or a subclass thereof.
|
|
5
|
+
*/
|
|
6
|
+
export declare abstract class EntityDocumentTemplateParserBase {
|
|
7
|
+
static ClearCache(): void;
|
|
8
|
+
static CreateCacheKey(EntityID: string, EntityRecordPrimaryKey: string, Content: string): string;
|
|
9
|
+
protected static __cache: Record<string, string>;
|
|
10
|
+
protected static get _cache(): Record<string, string>;
|
|
11
|
+
/** Optional provider override; falls back to Metadata.Provider when not set. */
|
|
12
|
+
protected _provider?: IMetadataProvider;
|
|
13
|
+
/** Allows setting or reading an explicit provider override for testing or isolated execution */
|
|
14
|
+
get ProviderOverride(): IMetadataProvider | undefined;
|
|
15
|
+
set ProviderOverride(value: IMetadataProvider | undefined);
|
|
16
|
+
/** Returns the active provider — explicit override if set, otherwise the global default. */
|
|
17
|
+
protected get ProviderToUse(): IMetadataProvider;
|
|
18
|
+
/**
|
|
19
|
+
* Parses an entity document template and replaces values within ${} placeholders with actual values from the entity record.
|
|
20
|
+
* If template uses Nunjucks {{ }} syntax, it is pre-rendered with the MJ TemplateEngine first.
|
|
21
|
+
*
|
|
22
|
+
* @param Template - the document template to parse
|
|
23
|
+
* @param EntityID - the ID of the entity
|
|
24
|
+
* @param EntityRecord - the values for the entity record (may contain __Parent context)
|
|
25
|
+
* @param ContextUser - the current user
|
|
26
|
+
* @returns the evaluated value of the template incorporating fields, nested contexts, and function call(s)
|
|
27
|
+
*/
|
|
28
|
+
Parse(Template: string, EntityID: string, EntityRecord: Record<string, unknown>, ContextUser: UserInfo): Promise<string>;
|
|
29
|
+
/**
|
|
30
|
+
* Evaluates a single placeholder argument: either a function call like Relationship(...) or a field/path reference like Name or __Parent.Title.
|
|
31
|
+
*/
|
|
32
|
+
protected evalSingleArgument(argument: string, entityID: string, entityRecord: Record<string, unknown>, ContextUser: UserInfo): Promise<string>;
|
|
33
|
+
}
|
|
34
|
+
//# sourceMappingURL=EntityDocumentTemplateParserBase.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"EntityDocumentTemplateParserBase.d.ts","sourceRoot":"","sources":["../../src/generic/EntityDocumentTemplateParserBase.ts"],"names":[],"mappings":"AAAA,OAAO,EAAgB,iBAAiB,EAAY,QAAQ,EAAE,MAAM,sBAAsB,CAAC;AAI3F;;;GAGG;AACH,8BAAsB,gCAAgC;WACtC,UAAU,IAAI,IAAI;WAIlB,cAAc,CAAC,QAAQ,EAAE,MAAM,EAAE,sBAAsB,EAAE,MAAM,EAAE,OAAO,EAAE,MAAM,GAAG,MAAM;IAIvG,SAAS,CAAC,MAAM,CAAC,OAAO,EAAE,MAAM,CAAC,MAAM,EAAE,MAAM,CAAC,CAAM;IACtD,SAAS,CAAC,MAAM,KAAK,MAAM,IAAI,MAAM,CAAC,MAAM,EAAE,MAAM,CAAC,CAEpD;IAED,gFAAgF;IAChF,SAAS,CAAC,SAAS,CAAC,EAAE,iBAAiB,CAAC;IAExC,gGAAgG;IAChG,IAAW,gBAAgB,IAAI,iBAAiB,GAAG,SAAS,CAE3D;IACD,IAAW,gBAAgB,CAAC,KAAK,EAAE,iBAAiB,GAAG,SAAS,EAE/D;IAED,4FAA4F;IAC5F,SAAS,KAAK,aAAa,IAAI,iBAAiB,CAE/C;IAED;;;;;;;;;OASG;IACU,KAAK,CAChB,QAAQ,EAAE,MAAM,EAChB,QAAQ,EAAE,MAAM,EAChB,YAAY,EAAE,MAAM,CAAC,MAAM,EAAE,OAAO,CAAC,EACrC,WAAW,EAAE,QAAQ,GACpB,OAAO,CAAC,MAAM,CAAC;IA2DlB;;OAEG;cACa,kBAAkB,CAChC,QAAQ,EAAE,MAAM,EAChB,QAAQ,EAAE,MAAM,EAChB,YAAY,EAAE,MAAM,CAAC,MAAM,EAAE,OAAO,CAAC,EACrC,WAAW,EAAE,QAAQ,GACpB,OAAO,CAAC,MAAM,CAAC;CA4CnB"}
|
|
@@ -0,0 +1,132 @@
|
|
|
1
|
+
import { CompositeKey, Metadata } from '@memberjunction/core';
|
|
2
|
+
import { UUIDsEqual } from '@memberjunction/global';
|
|
3
|
+
import { TemplateEngineServer } from '@memberjunction/templates';
|
|
4
|
+
/**
|
|
5
|
+
* Abstract base class for entity document template parsing.
|
|
6
|
+
* Use EntityDocumentTemplateParser or a subclass thereof.
|
|
7
|
+
*/
|
|
8
|
+
export class EntityDocumentTemplateParserBase {
|
|
9
|
+
static ClearCache() {
|
|
10
|
+
EntityDocumentTemplateParserBase.__cache = {};
|
|
11
|
+
}
|
|
12
|
+
static CreateCacheKey(EntityID, EntityRecordPrimaryKey, Content) {
|
|
13
|
+
return `${EntityID}___${EntityRecordPrimaryKey}___${Content}`;
|
|
14
|
+
}
|
|
15
|
+
static { this.__cache = {}; }
|
|
16
|
+
static get _cache() {
|
|
17
|
+
return EntityDocumentTemplateParserBase.__cache;
|
|
18
|
+
}
|
|
19
|
+
/** Allows setting or reading an explicit provider override for testing or isolated execution */
|
|
20
|
+
get ProviderOverride() {
|
|
21
|
+
return this._provider;
|
|
22
|
+
}
|
|
23
|
+
set ProviderOverride(value) {
|
|
24
|
+
this._provider = value;
|
|
25
|
+
}
|
|
26
|
+
/** Returns the active provider — explicit override if set, otherwise the global default. */
|
|
27
|
+
get ProviderToUse() {
|
|
28
|
+
return this._provider ?? Metadata.Provider;
|
|
29
|
+
}
|
|
30
|
+
/**
|
|
31
|
+
* Parses an entity document template and replaces values within ${} placeholders with actual values from the entity record.
|
|
32
|
+
* If template uses Nunjucks {{ }} syntax, it is pre-rendered with the MJ TemplateEngine first.
|
|
33
|
+
*
|
|
34
|
+
* @param Template - the document template to parse
|
|
35
|
+
* @param EntityID - the ID of the entity
|
|
36
|
+
* @param EntityRecord - the values for the entity record (may contain __Parent context)
|
|
37
|
+
* @param ContextUser - the current user
|
|
38
|
+
* @returns the evaluated value of the template incorporating fields, nested contexts, and function call(s)
|
|
39
|
+
*/
|
|
40
|
+
async Parse(Template, EntityID, EntityRecord, ContextUser) {
|
|
41
|
+
if (!ContextUser) {
|
|
42
|
+
throw new Error('ContextUser is required to parse the template');
|
|
43
|
+
}
|
|
44
|
+
const md = this.ProviderToUse;
|
|
45
|
+
const entityInfo = md.Entities.find((e) => UUIDsEqual(e.ID, EntityID));
|
|
46
|
+
if (!entityInfo) {
|
|
47
|
+
throw new Error(`Entity with ID ${EntityID} not found.`);
|
|
48
|
+
}
|
|
49
|
+
// Pass 1: If template uses Nunjucks {{ }} syntax, pre-render with the MJ TemplateEngine first.
|
|
50
|
+
// This handles conditionals ({% if __Parent %}), filters, and expressions.
|
|
51
|
+
let processedTemplate = Template;
|
|
52
|
+
if (Template.includes('{{') || Template.includes('{%')) {
|
|
53
|
+
await TemplateEngineServer.Instance.Config(false, ContextUser);
|
|
54
|
+
const renderResult = await TemplateEngineServer.Instance.RenderTemplateSimple(Template, EntityRecord);
|
|
55
|
+
if (renderResult.Success && renderResult.Output) {
|
|
56
|
+
processedTemplate = renderResult.Output;
|
|
57
|
+
}
|
|
58
|
+
}
|
|
59
|
+
const compositeKey = new CompositeKey();
|
|
60
|
+
compositeKey.LoadFromEntityInfoAndRecord(entityInfo, EntityRecord);
|
|
61
|
+
const regex = /\$\{([^{}]+)\}/g;
|
|
62
|
+
const matches = processedTemplate.matchAll(regex);
|
|
63
|
+
// Pass 2: Replace ${} placeholders (variables, dotted paths like __Parent.Field, and function calls)
|
|
64
|
+
const replacements = Array.from(matches).map(async (match) => {
|
|
65
|
+
const content = match[1]; // The captured group from regex
|
|
66
|
+
const cacheKey = EntityDocumentTemplateParserBase.CreateCacheKey(EntityID, compositeKey.ToString(), content);
|
|
67
|
+
if (!EntityDocumentTemplateParserBase._cache[cacheKey]) {
|
|
68
|
+
EntityDocumentTemplateParserBase._cache[cacheKey] = await this.evalSingleArgument(content, EntityID, EntityRecord, ContextUser);
|
|
69
|
+
}
|
|
70
|
+
return {
|
|
71
|
+
old: match[0],
|
|
72
|
+
new: EntityDocumentTemplateParserBase._cache[cacheKey],
|
|
73
|
+
};
|
|
74
|
+
});
|
|
75
|
+
const resolvedReplacements = await Promise.all(replacements);
|
|
76
|
+
let resolvedTemplate = processedTemplate;
|
|
77
|
+
resolvedReplacements.forEach((replacement) => {
|
|
78
|
+
// Function replacement: the resolved value is field data, so $&/$`/$$ in it must be text rather than splice directives (#3171).
|
|
79
|
+
resolvedTemplate = resolvedTemplate.replace(replacement.old, () => replacement.new);
|
|
80
|
+
});
|
|
81
|
+
return resolvedTemplate;
|
|
82
|
+
}
|
|
83
|
+
/**
|
|
84
|
+
* Evaluates a single placeholder argument: either a function call like Relationship(...) or a field/path reference like Name or __Parent.Title.
|
|
85
|
+
*/
|
|
86
|
+
async evalSingleArgument(argument, entityID, entityRecord, ContextUser) {
|
|
87
|
+
const funcMatch = argument.match(/^\s*(\w+)\(([^)]*)\)\s*$/);
|
|
88
|
+
if (funcMatch) {
|
|
89
|
+
const [, funcName, paramsString] = funcMatch;
|
|
90
|
+
const params = paramsString.split(',').map((param) => {
|
|
91
|
+
param = param.trim();
|
|
92
|
+
if ((param.startsWith('"') && param.endsWith('"')) || (param.startsWith("'") && param.endsWith("'"))) {
|
|
93
|
+
return param.slice(1, -1);
|
|
94
|
+
}
|
|
95
|
+
return param;
|
|
96
|
+
});
|
|
97
|
+
const method = this[funcName];
|
|
98
|
+
if (typeof method === 'function') {
|
|
99
|
+
const result = await method.apply(this, [
|
|
100
|
+
entityID,
|
|
101
|
+
entityRecord,
|
|
102
|
+
ContextUser,
|
|
103
|
+
...params,
|
|
104
|
+
]);
|
|
105
|
+
return result ?? '';
|
|
106
|
+
}
|
|
107
|
+
else {
|
|
108
|
+
throw new Error(`Function ${funcName} is not defined.`);
|
|
109
|
+
}
|
|
110
|
+
}
|
|
111
|
+
else {
|
|
112
|
+
// Field or property path resolution (supports dotted paths e.g. __Parent.Field, __Parent.__Parent.Field)
|
|
113
|
+
if (argument.includes('.')) {
|
|
114
|
+
let current = entityRecord;
|
|
115
|
+
const parts = argument.split('.');
|
|
116
|
+
for (const part of parts) {
|
|
117
|
+
if (current !== null && typeof current === 'object' && part in current) {
|
|
118
|
+
current = current[part];
|
|
119
|
+
}
|
|
120
|
+
else {
|
|
121
|
+
current = undefined;
|
|
122
|
+
break;
|
|
123
|
+
}
|
|
124
|
+
}
|
|
125
|
+
return current !== undefined && current !== null ? String(current) : '';
|
|
126
|
+
}
|
|
127
|
+
const val = entityRecord[argument];
|
|
128
|
+
return val !== undefined && val !== null ? String(val) : '';
|
|
129
|
+
}
|
|
130
|
+
}
|
|
131
|
+
}
|
|
132
|
+
//# sourceMappingURL=EntityDocumentTemplateParserBase.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"EntityDocumentTemplateParserBase.js","sourceRoot":"","sources":["../../src/generic/EntityDocumentTemplateParserBase.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,YAAY,EAAqB,QAAQ,EAAY,MAAM,sBAAsB,CAAC;AAC3F,OAAO,EAAE,UAAU,EAAE,MAAM,wBAAwB,CAAC;AACpD,OAAO,EAAE,oBAAoB,EAAE,MAAM,2BAA2B,CAAC;AAEjE;;;GAGG;AACH,MAAM,OAAgB,gCAAgC;IAC7C,MAAM,CAAC,UAAU;QACtB,gCAAgC,CAAC,OAAO,GAAG,EAAE,CAAC;IAChD,CAAC;IAEM,MAAM,CAAC,cAAc,CAAC,QAAgB,EAAE,sBAA8B,EAAE,OAAe;QAC5F,OAAO,GAAG,QAAQ,MAAM,sBAAsB,MAAM,OAAO,EAAE,CAAC;IAChE,CAAC;aAEgB,YAAO,GAA2B,EAAE,CA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AM,CAAC;gBACN,MAAM,IAAI,KAAK,CAAC,YAAY,QAAQ,kBAAkB,CAAC,CAAC;YAC1D,CAAC;QACH,CAAC;aAAM,CAAC;YACN,yGAAyG;YACzG,IAAI,QAAQ,CAAC,QAAQ,CAAC,GAAG,CAAC,EAAE,CAAC;gBAC3B,IAAI,OAAO,GAAY,YAAY,CAAC;gBACpC,MAAM,KAAK,GAAG,QAAQ,CAAC,KAAK,CAAC,GAAG,CAAC,CAAC;gBAClC,KAAK,MAAM,IAAI,IAAI,KAAK,EAAE,CAAC;oBACzB,IAAI,OAAO,KAAK,IAAI,IAAI,OAAO,OAAO,KAAK,QAAQ,IAAI,IAAI,IAAK,OAAmC,EAAE,CAAC;wBACpG,OAAO,GAAI,OAAmC,CAAC,IAAI,CAAC,CAAC;oBACvD,CAAC;yBAAM,CAAC;wBACN,OAAO,GAAG,SAAS,CAAC;wBACpB,MAAM;oBACR,CAAC;gBACH,CAAC;gBACD,OAAO,OAAO,KAAK,SAAS,IAAI,OAAO,KAAK,IAAI,CAAC,CAAC,CAAC,MAAM,CAAC,OAAO,CAAC,CAAC,CAAC,CAAC,EAAE,CAAC;YAC1E,CAAC;YAED,MAAM,GAAG,GAAG,YAAY,CAAC,QAAQ,CAAC,CAAC;YACnC,OAAO,GAAG,KAAK,SAAS,IAAI,GAAG,KAAK,IAAI,CAAC,CAAC,CAAC,MAAM,CAAC,GAAG,CAAC,CAAC,CAAC,CAAC,EAAE,CAAC;QAC9D,CAAC;IACH,CAAC"}
|
package/dist/index.d.ts
ADDED
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":"AAAA,cAAc,4CAA4C,CAAC;AAC3D,cAAc,wCAAwC,CAAC;AACvD,cAAc,8BAA8B,CAAC"}
|
package/dist/index.js
ADDED
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"index.js","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":"AAAA,cAAc,4CAA4C,CAAC;AAC3D,cAAc,wCAAwC,CAAC;AACvD,cAAc,8BAA8B,CAAC"}
|
|
@@ -0,0 +1,31 @@
|
|
|
1
|
+
import { UserInfo } from "@memberjunction/core";
|
|
2
|
+
import { BaseSingleton } from "@memberjunction/global";
|
|
3
|
+
import { MJEntityDocumentEntity, MJEntityDocumentTypeEntity } from "@memberjunction/core-entities";
|
|
4
|
+
/**
|
|
5
|
+
* Caching class for Entity Documents and Entity Document Types.
|
|
6
|
+
*
|
|
7
|
+
* Delegates Entity Document storage to KnowledgeHubMetadataEngine (which uses
|
|
8
|
+
* BaseEngine auto-refresh on entity events), and only independently caches
|
|
9
|
+
* Entity Document Types (which KH engine does not manage).
|
|
10
|
+
*/
|
|
11
|
+
export declare class EntityDocumentCache extends BaseSingleton<EntityDocumentCache> {
|
|
12
|
+
private _loaded;
|
|
13
|
+
private _typeCache;
|
|
14
|
+
private _contextUser;
|
|
15
|
+
constructor();
|
|
16
|
+
static get Instance(): EntityDocumentCache;
|
|
17
|
+
get IsLoaded(): boolean;
|
|
18
|
+
GetDocument(EntityDocumentID: string): MJEntityDocumentEntity | null;
|
|
19
|
+
GetFirstActiveDocumentForEntityByID(EntityID: string): MJEntityDocumentEntity | null;
|
|
20
|
+
GetFirstActiveDocumentForEntityByName(EntityName: string): MJEntityDocumentEntity | null;
|
|
21
|
+
GetDocumentByName(EntityDocumentName: string): MJEntityDocumentEntity | null;
|
|
22
|
+
GetDocumentType(EntityDocumentTypeID: string): MJEntityDocumentTypeEntity | null;
|
|
23
|
+
GetDocumentTypeByName(EntityDocumentTypeName: string): MJEntityDocumentTypeEntity | null;
|
|
24
|
+
SetCurrentUser(user: UserInfo): void;
|
|
25
|
+
/**
|
|
26
|
+
* Refreshes the cache. Entity Documents are loaded via KnowledgeHubMetadataEngine
|
|
27
|
+
* (auto-refreshing BaseEngine). Entity Document Types are loaded independently.
|
|
28
|
+
*/
|
|
29
|
+
Refresh(forceRefresh: boolean, ContextUser?: UserInfo): Promise<void>;
|
|
30
|
+
}
|
|
31
|
+
//# sourceMappingURL=EntityDocumentCache.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"EntityDocumentCache.d.ts","sourceRoot":"","sources":["../../src/models/EntityDocumentCache.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,QAAQ,EAAqC,MAAM,sBAAsB,CAAC;AACnF,OAAO,EAAc,aAAa,EAAE,MAAM,wBAAwB,CAAC;AACnE,OAAO,EAAE,sBAAsB,EAAE,0BAA0B,EAA8B,MAAM,+BAA+B,CAAC;AAE/H;;;;;;GAMG;AACH,qBAAa,mBAAoB,SAAQ,aAAa,CAAC,mBAAmB,CAAC;IACvE,OAAO,CAAC,OAAO,CAAkB;IACjC,OAAO,CAAC,UAAU,CAAqD;IACvE,OAAO,CAAC,YAAY,CAAyB;;IAM7C,WAAkB,QAAQ,IAAI,mBAAmB,CAEhD;IAED,IAAW,QAAQ,IAAI,OAAO,CAE7B;IAEM,WAAW,CAAC,gBAAgB,EAAE,MAAM,GAAG,sBAAsB,GAAG,IAAI;IAQpE,mCAAmC,CAAC,QAAQ,EAAE,MAAM,GAAG,sBAAsB,GAAG,IAAI;IAWpF,qCAAqC,CAAC,UAAU,EAAE,MAAM,GAAG,sBAAsB,GAAG,IAAI;IAWxF,iBAAiB,CAAC,kBAAkB,EAAE,MAAM,GAAG,sBAAsB,GAAG,IAAI;IAa5E,eAAe,CAAC,oBAAoB,EAAE,MAAM,GAAG,0BAA0B,GAAG,IAAI;IAUhF,qBAAqB,CAAC,sBAAsB,EAAE,MAAM,GAAG,0BAA0B,GAAG,IAAI;IAcxF,cAAc,CAAC,IAAI,EAAE,QAAQ;IAIpC;;;OAGG;IACU,OAAO,CAAC,YAAY,EAAE,OAAO,EAAE,WAAW,CAAC,EAAE,QAAQ,GAAG,OAAO,CAAC,IAAI,CAAC;CA4BrF"}
|
|
@@ -0,0 +1,100 @@
|
|
|
1
|
+
import { RunView, LogStatus } from "@memberjunction/core";
|
|
2
|
+
import { UUIDsEqual, BaseSingleton } from "@memberjunction/global";
|
|
3
|
+
import { KnowledgeHubMetadataEngine } from "@memberjunction/core-entities";
|
|
4
|
+
/**
|
|
5
|
+
* Caching class for Entity Documents and Entity Document Types.
|
|
6
|
+
*
|
|
7
|
+
* Delegates Entity Document storage to KnowledgeHubMetadataEngine (which uses
|
|
8
|
+
* BaseEngine auto-refresh on entity events), and only independently caches
|
|
9
|
+
* Entity Document Types (which KH engine does not manage).
|
|
10
|
+
*/
|
|
11
|
+
export class EntityDocumentCache extends BaseSingleton {
|
|
12
|
+
constructor() {
|
|
13
|
+
super();
|
|
14
|
+
this._loaded = false;
|
|
15
|
+
this._typeCache = {};
|
|
16
|
+
this._contextUser = null;
|
|
17
|
+
}
|
|
18
|
+
static get Instance() {
|
|
19
|
+
return super.getInstance();
|
|
20
|
+
}
|
|
21
|
+
get IsLoaded() {
|
|
22
|
+
return this._loaded;
|
|
23
|
+
}
|
|
24
|
+
GetDocument(EntityDocumentID) {
|
|
25
|
+
const document = KnowledgeHubMetadataEngine.Instance.GetEntityDocumentByID(EntityDocumentID);
|
|
26
|
+
if (!document) {
|
|
27
|
+
LogStatus(`EntityDocumentCache.GetDocument: Cache miss for EntityDocumentID: ${EntityDocumentID}`);
|
|
28
|
+
}
|
|
29
|
+
return document ?? null;
|
|
30
|
+
}
|
|
31
|
+
GetFirstActiveDocumentForEntityByID(EntityID) {
|
|
32
|
+
const documentType = this.GetDocumentTypeByName('Record Duplicate');
|
|
33
|
+
if (!documentType) {
|
|
34
|
+
return null;
|
|
35
|
+
}
|
|
36
|
+
return KnowledgeHubMetadataEngine.Instance.EntityDocuments.find((ed) => UUIDsEqual(ed.EntityID, EntityID) && ed.Status === 'Active' && UUIDsEqual(ed.TypeID, documentType.ID)) ?? null;
|
|
37
|
+
}
|
|
38
|
+
GetFirstActiveDocumentForEntityByName(EntityName) {
|
|
39
|
+
const documentType = this.GetDocumentTypeByName('Record Duplicate');
|
|
40
|
+
if (!documentType) {
|
|
41
|
+
return null;
|
|
42
|
+
}
|
|
43
|
+
return KnowledgeHubMetadataEngine.Instance.EntityDocuments.find((ed) => ed.Entity === EntityName && ed.Status === 'Active' && UUIDsEqual(ed.TypeID, documentType.ID)) ?? null;
|
|
44
|
+
}
|
|
45
|
+
GetDocumentByName(EntityDocumentName) {
|
|
46
|
+
const toLower = EntityDocumentName.trim().toLowerCase();
|
|
47
|
+
const document = KnowledgeHubMetadataEngine.Instance.EntityDocuments.find((ed) => ed.Name.trim().toLowerCase() === toLower);
|
|
48
|
+
if (!document) {
|
|
49
|
+
LogStatus(`EntityDocumentCache.GetDocumentByName: Cache miss for EntityDocumentName: ${EntityDocumentName}`);
|
|
50
|
+
}
|
|
51
|
+
return document ?? null;
|
|
52
|
+
}
|
|
53
|
+
GetDocumentType(EntityDocumentTypeID) {
|
|
54
|
+
const documentType = this._typeCache[EntityDocumentTypeID];
|
|
55
|
+
if (!documentType) {
|
|
56
|
+
LogStatus(`EntityDocumentCache.GetDocumentType: Cache miss for EntityDocumentTypeID: ${EntityDocumentTypeID}`);
|
|
57
|
+
return null;
|
|
58
|
+
}
|
|
59
|
+
return documentType;
|
|
60
|
+
}
|
|
61
|
+
GetDocumentTypeByName(EntityDocumentTypeName) {
|
|
62
|
+
const toLower = EntityDocumentTypeName.trim().toLowerCase();
|
|
63
|
+
const documentType = Object.values(this._typeCache).find((edt) => edt.Name.trim().toLowerCase() === toLower);
|
|
64
|
+
if (!documentType) {
|
|
65
|
+
LogStatus(`EntityDocumentCache.GetDocumentTypeByName: Cache miss for EntityDocumentTypeName: ${EntityDocumentTypeName}`);
|
|
66
|
+
return null;
|
|
67
|
+
}
|
|
68
|
+
return documentType;
|
|
69
|
+
}
|
|
70
|
+
SetCurrentUser(user) {
|
|
71
|
+
this._contextUser = user;
|
|
72
|
+
}
|
|
73
|
+
/**
|
|
74
|
+
* Refreshes the cache. Entity Documents are loaded via KnowledgeHubMetadataEngine
|
|
75
|
+
* (auto-refreshing BaseEngine). Entity Document Types are loaded independently.
|
|
76
|
+
*/
|
|
77
|
+
async Refresh(forceRefresh, ContextUser) {
|
|
78
|
+
if (!forceRefresh && this._loaded) {
|
|
79
|
+
return;
|
|
80
|
+
}
|
|
81
|
+
LogStatus('Refreshing Entity Document Cache');
|
|
82
|
+
this._typeCache = {};
|
|
83
|
+
const user = ContextUser || this._contextUser;
|
|
84
|
+
// Delegate Entity Documents to KnowledgeHubMetadataEngine
|
|
85
|
+
await KnowledgeHubMetadataEngine.Instance.Config(forceRefresh, user);
|
|
86
|
+
// Load Entity Document Types independently (KH engine doesn't cache these)
|
|
87
|
+
const rv = new RunView();
|
|
88
|
+
const result = await rv.RunView({
|
|
89
|
+
EntityName: "MJ: Entity Document Types",
|
|
90
|
+
ResultType: "entity_object"
|
|
91
|
+
}, user);
|
|
92
|
+
if (result && result.Success) {
|
|
93
|
+
for (const entityDocumentType of result.Results) {
|
|
94
|
+
this._typeCache[entityDocumentType.ID] = entityDocumentType;
|
|
95
|
+
}
|
|
96
|
+
}
|
|
97
|
+
this._loaded = true;
|
|
98
|
+
}
|
|
99
|
+
}
|
|
100
|
+
//# sourceMappingURL=EntityDocumentCache.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"EntityDocumentCache.js","sourceRoot":"","sources":["../../src/models/EntityDocumentCache.ts"],"names":[],"mappings":"AAAA,OAAO,EAAY,OAAO,EAAE,SAAS,EAAiB,MAAM,sBAAsB,CAAC;AACnF,OAAO,EAAE,UAAU,EAAE,aAAa,EAAE,MAAM,wBAAwB,CAAC;AACnE,OAAO,EAAsD,0BAA0B,EAAE,MAAM,+BAA+B,CAAC;AAE/H;;;;;;GAMG;AACH,MAAM,OAAO,mBAAoB,SAAQ,aAAkC;IAKvE;QACI,KAAK,EAAE,CAAC;QALJ,YAAO,GAAY,KAAK,CAAC;QACzB,eAAU,GAAkD,EAAE,CAAC;QAC/D,iBAAY,GAAoB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
|
5
|
+
"description": "MemberJunction: Entity Documents - lightweight template parsing and caching engine for converting records into rich prompt context",
|
|
6
|
+
"main": "dist/index.js",
|
|
7
|
+
"types": "dist/index.d.ts",
|
|
8
|
+
"files": [
|
|
9
|
+
"/dist"
|
|
10
|
+
],
|
|
11
|
+
"author": "MemberJunction.com",
|
|
12
|
+
"license": "BUSL-1.1",
|
|
13
|
+
"dependencies": {
|
|
14
|
+
"@memberjunction/core": "6.2.0-edge.0",
|
|
15
|
+
"@memberjunction/core-entities": "6.2.0-edge.0",
|
|
16
|
+
"@memberjunction/global": "6.2.0-edge.0",
|
|
17
|
+
"@memberjunction/templates": "6.2.0-edge.0"
|
|
18
|
+
},
|
|
19
|
+
"devDependencies": {
|
|
20
|
+
"@types/node": "24.10.11",
|
|
21
|
+
"typescript": "^5.9.3",
|
|
22
|
+
"vitest": "^4.0.18"
|
|
23
|
+
},
|
|
24
|
+
"repository": {
|
|
25
|
+
"type": "git",
|
|
26
|
+
"url": "https://github.com/MemberJunction/MJ"
|
|
27
|
+
},
|
|
28
|
+
"scripts": {
|
|
29
|
+
"build": "tsc && tsc-alias -f",
|
|
30
|
+
"watch": "tsc --watch",
|
|
31
|
+
"test": "vitest run",
|
|
32
|
+
"test:watch": "vitest"
|
|
33
|
+
}
|
|
34
|
+
}
|
package/README.md
DELETED
|
@@ -1,45 +0,0 @@
|
|
|
1
|
-
# @memberjunction/entity-documents
|
|
2
|
-
|
|
3
|
-
## ⚠️ IMPORTANT NOTICE ⚠️
|
|
4
|
-
|
|
5
|
-
**This package is created solely for the purpose of setting up OIDC (OpenID Connect) trusted publishing with npm.**
|
|
6
|
-
|
|
7
|
-
This is **NOT** a functional package and contains **NO** code or functionality beyond the OIDC setup configuration.
|
|
8
|
-
|
|
9
|
-
## Purpose
|
|
10
|
-
|
|
11
|
-
This package exists to:
|
|
12
|
-
1. Configure OIDC trusted publishing for the package name `@memberjunction/entity-documents`
|
|
13
|
-
2. Enable secure, token-less publishing from CI/CD workflows
|
|
14
|
-
3. Establish provenance for packages published under this name
|
|
15
|
-
|
|
16
|
-
## What is OIDC Trusted Publishing?
|
|
17
|
-
|
|
18
|
-
OIDC trusted publishing allows package maintainers to publish packages directly from their CI/CD workflows without needing to manage npm access tokens. Instead, it uses OpenID Connect to establish trust between the CI/CD provider (like GitHub Actions) and npm.
|
|
19
|
-
|
|
20
|
-
## Setup Instructions
|
|
21
|
-
|
|
22
|
-
To properly configure OIDC trusted publishing for this package:
|
|
23
|
-
|
|
24
|
-
1. Go to [npmjs.com](https://www.npmjs.com/) and navigate to your package settings
|
|
25
|
-
2. Configure the trusted publisher (e.g., GitHub Actions)
|
|
26
|
-
3. Specify the repository and workflow that should be allowed to publish
|
|
27
|
-
4. Use the configured workflow to publish your actual package
|
|
28
|
-
|
|
29
|
-
## DO NOT USE THIS PACKAGE
|
|
30
|
-
|
|
31
|
-
This package is a placeholder for OIDC configuration only. It:
|
|
32
|
-
- Contains no executable code
|
|
33
|
-
- Provides no functionality
|
|
34
|
-
- Should not be installed as a dependency
|
|
35
|
-
- Exists only for administrative purposes
|
|
36
|
-
|
|
37
|
-
## More Information
|
|
38
|
-
|
|
39
|
-
For more details about npm's trusted publishing feature, see:
|
|
40
|
-
- [npm Trusted Publishing Documentation](https://docs.npmjs.com/generating-provenance-statements)
|
|
41
|
-
- [GitHub Actions OIDC Documentation](https://docs.github.com/en/actions/deployment/security-hardening-your-deployments/about-security-hardening-with-openid-connect)
|
|
42
|
-
|
|
43
|
-
---
|
|
44
|
-
|
|
45
|
-
**Maintained for OIDC setup purposes only**
|