@memberjunction/core-entities 2.104.0 → 2.106.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/dist/artifact-extraction/artifact-extract-rules.d.ts +163 -0
- package/dist/artifact-extraction/artifact-extract-rules.d.ts.map +1 -0
- package/dist/artifact-extraction/artifact-extract-rules.js +13 -0
- package/dist/artifact-extraction/artifact-extract-rules.js.map +1 -0
- package/dist/artifact-extraction/artifact-extractor.d.ts +157 -0
- package/dist/artifact-extraction/artifact-extractor.d.ts.map +1 -0
- package/dist/artifact-extraction/artifact-extractor.js +265 -0
- package/dist/artifact-extraction/artifact-extractor.js.map +1 -0
- package/dist/custom/TemplateEntityExtended.d.ts +59 -0
- package/dist/custom/TemplateEntityExtended.d.ts.map +1 -0
- package/dist/custom/TemplateEntityExtended.js +126 -0
- package/dist/custom/TemplateEntityExtended.js.map +1 -0
- package/dist/engines/artifacts.d.ts +19 -0
- package/dist/engines/artifacts.d.ts.map +1 -0
- package/dist/engines/artifacts.js +37 -0
- package/dist/engines/artifacts.js.map +1 -0
- package/dist/generated/entity_subclasses.d.ts +1742 -921
- package/dist/generated/entity_subclasses.d.ts.map +1 -1
- package/dist/generated/entity_subclasses.js +2330 -1124
- package/dist/generated/entity_subclasses.js.map +1 -1
- package/dist/index.d.ts +4 -0
- package/dist/index.d.ts.map +1 -1
- package/dist/index.js +4 -0
- package/dist/index.js.map +1 -1
- package/package.json +2 -2
- package/readme.md +87 -160
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"TemplateEntityExtended.d.ts","sourceRoot":"","sources":["../../src/custom/TemplateEntityExtended.ts"],"names":[],"mappings":"AAAA,OAAO,EAAc,gBAAgB,EAAE,MAAM,sBAAsB,CAAC;AACpE,OAAO,EAAE,qBAAqB,EAAE,cAAc,EAAE,mBAAmB,EAAE,MAAM,gCAAgC,CAAC;AAG5G,qBACa,sBAAuB,SAAQ,cAAc;IACtD,OAAO,CAAC,QAAQ,CAA+B;IAC/C,IAAW,OAAO,IAAI,qBAAqB,EAAE,CAE5C;IACD,IAAW,OAAO,CAAC,KAAK,EAAE,qBAAqB,EAAE,EAEhD;IAED,OAAO,CAAC,OAAO,CAA6B;IAC5C,IAAW,MAAM,IAAI,mBAAmB,EAAE,CAEzC;IACD,IAAW,MAAM,CAAC,KAAK,EAAE,mBAAmB,EAAE,EAE7C;IAED;;;;OAIG;IACI,gBAAgB,CAAC,IAAI,EAAE,MAAM,GAAG,qBAAqB,EAAE;IAI9D;;;;OAIG;IACI,yBAAyB,CAAC,IAAI,CAAC,EAAE,MAAM,GAAG,qBAAqB;IAUtE;;;;;;;;;;;;;;;OAeG;IACI,uBAAuB,CAAC,SAAS,CAAC,EAAE,MAAM,GAAG,mBAAmB,EAAE;IAazE;;;;;;;;;;;;;;;;;OAiBG;IACI,qBAAqB,CAAC,IAAI,EAAE,GAAG,EAAE,SAAS,CAAC,EAAE,MAAM,GAAG,gBAAgB;CA0BhF"}
|
|
@@ -0,0 +1,126 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
var __decorate = (this && this.__decorate) || function (decorators, target, key, desc) {
|
|
3
|
+
var c = arguments.length, r = c < 3 ? target : desc === null ? desc = Object.getOwnPropertyDescriptor(target, key) : desc, d;
|
|
4
|
+
if (typeof Reflect === "object" && typeof Reflect.decorate === "function") r = Reflect.decorate(decorators, target, key, desc);
|
|
5
|
+
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;
|
|
6
|
+
return c > 3 && r && Object.defineProperty(target, key, r), r;
|
|
7
|
+
};
|
|
8
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
9
|
+
exports.TemplateEntityExtended = void 0;
|
|
10
|
+
const core_1 = require("@memberjunction/core");
|
|
11
|
+
const entity_subclasses_1 = require("../generated/entity_subclasses");
|
|
12
|
+
const global_1 = require("@memberjunction/global");
|
|
13
|
+
let TemplateEntityExtended = class TemplateEntityExtended extends entity_subclasses_1.TemplateEntity {
|
|
14
|
+
constructor() {
|
|
15
|
+
super(...arguments);
|
|
16
|
+
this._Content = [];
|
|
17
|
+
this._Params = [];
|
|
18
|
+
}
|
|
19
|
+
get Content() {
|
|
20
|
+
return this._Content;
|
|
21
|
+
}
|
|
22
|
+
set Content(value) {
|
|
23
|
+
this._Content = value;
|
|
24
|
+
}
|
|
25
|
+
get Params() {
|
|
26
|
+
return this._Params;
|
|
27
|
+
}
|
|
28
|
+
set Params(value) {
|
|
29
|
+
this._Params = value;
|
|
30
|
+
}
|
|
31
|
+
/**
|
|
32
|
+
* Returns all content for a given type for the template
|
|
33
|
+
* @param type
|
|
34
|
+
* @returns
|
|
35
|
+
*/
|
|
36
|
+
GetContentByType(type) {
|
|
37
|
+
return this.Content.filter(c => c.Type.trim().toLowerCase() === type.trim().toLowerCase());
|
|
38
|
+
}
|
|
39
|
+
/**
|
|
40
|
+
* Returns the highest priority content for the template
|
|
41
|
+
* @param type If provided, returns the highest priority content of the specified type
|
|
42
|
+
* @returns
|
|
43
|
+
*/
|
|
44
|
+
GetHighestPriorityContent(type) {
|
|
45
|
+
if (type) {
|
|
46
|
+
return this.Content.filter(c => c.Type.trim().toLowerCase() === type.trim().toLowerCase())
|
|
47
|
+
.sort((a, b) => a.Priority - b.Priority)[0];
|
|
48
|
+
}
|
|
49
|
+
else {
|
|
50
|
+
return this.Content.sort((a, b) => a.Priority - b.Priority)[0];
|
|
51
|
+
}
|
|
52
|
+
}
|
|
53
|
+
/**
|
|
54
|
+
* Returns all parameters that apply to a specific template content.
|
|
55
|
+
* This includes both global parameters (where TemplateContentID is NULL)
|
|
56
|
+
* and content-specific parameters for the given contentId.
|
|
57
|
+
*
|
|
58
|
+
* @param contentId - The ID of the template content. If not provided, returns only global parameters.
|
|
59
|
+
* @returns Array of TemplateParamEntity objects that apply to the specified content
|
|
60
|
+
*
|
|
61
|
+
* @example
|
|
62
|
+
* // Get all parameters for a specific content
|
|
63
|
+
* const params = template.GetParametersForContent('content-uuid');
|
|
64
|
+
*
|
|
65
|
+
* @example
|
|
66
|
+
* // Get only global parameters (that apply to all contents)
|
|
67
|
+
* const globalParams = template.GetParametersForContent();
|
|
68
|
+
*/
|
|
69
|
+
GetParametersForContent(contentId) {
|
|
70
|
+
if (!contentId) {
|
|
71
|
+
// Return only global parameters (TemplateContentID is null)
|
|
72
|
+
return this.Params.filter(p => !p.TemplateContentID);
|
|
73
|
+
}
|
|
74
|
+
// Return both global parameters and content-specific parameters
|
|
75
|
+
return this.Params.filter(p => !p.TemplateContentID || // Global param (applies to all contents)
|
|
76
|
+
p.TemplateContentID === contentId // Content-specific param
|
|
77
|
+
);
|
|
78
|
+
}
|
|
79
|
+
/**
|
|
80
|
+
* This method is different from the Validate() method which validates the state of the Template itself.
|
|
81
|
+
* This method validates the data object provided meets the requirements for the template's parameter definitions.
|
|
82
|
+
*
|
|
83
|
+
* @param data - the data object to validate against the template's parameter definitions
|
|
84
|
+
* @param contentId - Optional: The ID of the template content to validate against.
|
|
85
|
+
* If provided, validates against parameters specific to that content.
|
|
86
|
+
* If not provided, validates against all parameters.
|
|
87
|
+
* @returns ValidationResult with success status and any validation errors
|
|
88
|
+
*
|
|
89
|
+
* @example
|
|
90
|
+
* // Validate against all parameters
|
|
91
|
+
* const result = template.ValidateTemplateInput(inputData);
|
|
92
|
+
*
|
|
93
|
+
* @example
|
|
94
|
+
* // Validate against parameters for a specific content
|
|
95
|
+
* const result = template.ValidateTemplateInput(inputData, 'content-uuid');
|
|
96
|
+
*/
|
|
97
|
+
ValidateTemplateInput(data, contentId) {
|
|
98
|
+
const result = new core_1.ValidationResult();
|
|
99
|
+
// Get the relevant parameters based on contentId
|
|
100
|
+
const paramsToValidate = contentId ?
|
|
101
|
+
this.GetParametersForContent(contentId) :
|
|
102
|
+
this.Params;
|
|
103
|
+
paramsToValidate.forEach((p) => {
|
|
104
|
+
if (p.IsRequired) {
|
|
105
|
+
if (!data ||
|
|
106
|
+
data[p.Name] === undefined ||
|
|
107
|
+
data[p.Name] === null ||
|
|
108
|
+
(typeof data[p.Name] === 'string' && data[p.Name].toString().trim() === ''))
|
|
109
|
+
result.Errors.push({
|
|
110
|
+
Source: p.Name,
|
|
111
|
+
Message: `Parameter ${p.Name} is required.`,
|
|
112
|
+
Value: data[p.Name],
|
|
113
|
+
Type: 'Failure'
|
|
114
|
+
});
|
|
115
|
+
}
|
|
116
|
+
});
|
|
117
|
+
// now set result's top level success flag based on the existence of ANY failure record within the errors collection
|
|
118
|
+
result.Success = result.Errors.some(e => e.Type === 'Failure') ? false : true;
|
|
119
|
+
return result;
|
|
120
|
+
}
|
|
121
|
+
};
|
|
122
|
+
exports.TemplateEntityExtended = TemplateEntityExtended;
|
|
123
|
+
exports.TemplateEntityExtended = TemplateEntityExtended = __decorate([
|
|
124
|
+
(0, global_1.RegisterClass)(core_1.BaseEntity, 'Templates')
|
|
125
|
+
], TemplateEntityExtended);
|
|
126
|
+
//# sourceMappingURL=TemplateEntityExtended.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"TemplateEntityExtended.js","sourceRoot":"","sources":["../../src/custom/TemplateEntityExtended.ts"],"names":[],"mappings":";;;;;;;;;AAAA,+CAAoE;AACpE,sEAA4G;AAC5G,mDAAuD;AAGhD,IAAM,sBAAsB,GAA5B,MAAM,sBAAuB,SAAQ,kCAAc;IAAnD;;QACK,aAAQ,GAA4B,EAAE,CAAC;QAQvC,YAAO,GAA0B,EAAE,CAAC;IAyGhD,CAAC;IAhHG,IAAW,OAAO;QACd,OAAO,IAAI,CAAC,QAAQ,CAAC;IACzB,CAAC;IACD,IAAW,OAAO,CAAC,KAA8B;QAC7C,IAAI,CAAC,QAAQ,GAAG,KAAK,CAAC;IAC1B,CAAC;IAGD,IAAW,MAAM;QACb,OAAO,IAAI,CAAC,OAAO,CAAC;IACxB,CAAC;IACD,IAAW,MAAM,CAAC,KAA4B;QAC1C,IAAI,CAA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CAAC;CACJ,CAAA;AAlHY,wDAAsB;iCAAtB,sBAAsB;IADlC,IAAA,sBAAa,EAAC,iBAAU,EAAE,WAAW,CAAC;GAC1B,sBAAsB,CAkHlC"}
|
|
@@ -0,0 +1,19 @@
|
|
|
1
|
+
import { BaseEngine, IMetadataProvider, UserInfo } from "@memberjunction/core";
|
|
2
|
+
import { ArtifactTypeEntity } from "../generated/entity_subclasses";
|
|
3
|
+
/**
|
|
4
|
+
* Caching of metadata for components and related data
|
|
5
|
+
*/
|
|
6
|
+
export declare class ArtifactMetadataEngine extends BaseEngine<ArtifactMetadataEngine> {
|
|
7
|
+
/**
|
|
8
|
+
* Returns the global instance of the class. This is a singleton class, so there is only one instance of it in the application. Do not directly create new instances of it, always use this method to get the instance.
|
|
9
|
+
*/
|
|
10
|
+
static get Instance(): ArtifactMetadataEngine;
|
|
11
|
+
private _artifactTypes;
|
|
12
|
+
Config(forceRefresh?: boolean, contextUser?: UserInfo, provider?: IMetadataProvider): Promise<void>;
|
|
13
|
+
get ArtifactTypes(): ArtifactTypeEntity[];
|
|
14
|
+
/**
|
|
15
|
+
* Finds an artifact type on a case-insensitive match of name
|
|
16
|
+
*/
|
|
17
|
+
FindArtifactType(name: string): ArtifactTypeEntity | undefined;
|
|
18
|
+
}
|
|
19
|
+
//# sourceMappingURL=artifacts.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"artifacts.d.ts","sourceRoot":"","sources":["../../src/engines/artifacts.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,UAAU,EAA4B,iBAAiB,EAAE,QAAQ,EAAE,MAAM,sBAAsB,CAAC;AACzG,OAAO,EACH,kBAAkB,EACrB,MAAM,gCAAgC,CAAC;AAExC;;GAEG;AACH,qBAAa,sBAAuB,SAAQ,UAAU,CAAC,sBAAsB,CAAC;IAC1E;;OAEG;IACH,WAAkB,QAAQ,IAAI,sBAAsB,CAEnD;IAED,OAAO,CAAC,cAAc,CAAuB;IAEhC,MAAM,CAAC,YAAY,CAAC,EAAE,OAAO,EAAE,WAAW,CAAC,EAAE,QAAQ,EAAE,QAAQ,CAAC,EAAE,iBAAiB;IAWhG,IAAW,aAAa,IAAI,kBAAkB,EAAE,CAE/C;IAED;;OAEG;IACI,gBAAgB,CAAC,IAAI,EAAE,MAAM,GAAG,kBAAkB,GAAG,SAAS;CAIxE"}
|
|
@@ -0,0 +1,37 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.ArtifactMetadataEngine = void 0;
|
|
4
|
+
const core_1 = require("@memberjunction/core");
|
|
5
|
+
/**
|
|
6
|
+
* Caching of metadata for components and related data
|
|
7
|
+
*/
|
|
8
|
+
class ArtifactMetadataEngine extends core_1.BaseEngine {
|
|
9
|
+
/**
|
|
10
|
+
* Returns the global instance of the class. This is a singleton class, so there is only one instance of it in the application. Do not directly create new instances of it, always use this method to get the instance.
|
|
11
|
+
*/
|
|
12
|
+
static get Instance() {
|
|
13
|
+
return super.getInstance();
|
|
14
|
+
}
|
|
15
|
+
async Config(forceRefresh, contextUser, provider) {
|
|
16
|
+
const c = [
|
|
17
|
+
{
|
|
18
|
+
Type: 'entity',
|
|
19
|
+
EntityName: 'MJ: Artifact Types',
|
|
20
|
+
PropertyName: "_artifactTypes"
|
|
21
|
+
}
|
|
22
|
+
];
|
|
23
|
+
await this.Load(c, provider, forceRefresh, contextUser);
|
|
24
|
+
}
|
|
25
|
+
get ArtifactTypes() {
|
|
26
|
+
return this._artifactTypes;
|
|
27
|
+
}
|
|
28
|
+
/**
|
|
29
|
+
* Finds an artifact type on a case-insensitive match of name
|
|
30
|
+
*/
|
|
31
|
+
FindArtifactType(name) {
|
|
32
|
+
const match = this._artifactTypes.find(c => c.Name.trim().toLowerCase() === name.trim().toLowerCase());
|
|
33
|
+
return match;
|
|
34
|
+
}
|
|
35
|
+
}
|
|
36
|
+
exports.ArtifactMetadataEngine = ArtifactMetadataEngine;
|
|
37
|
+
//# sourceMappingURL=artifacts.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"artifacts.js","sourceRoot":"","sources":["../../src/engines/artifacts.ts"],"names":[],"mappings":";;;AAAA,+CAAyG;AAKzG;;GAEG;AACH,MAAa,sBAAuB,SAAQ,iBAAkC;IAC1E;;OAEG;IACI,MAAM,KAAK,QAAQ;QACvB,OAAO,KAAK,CAAC,WAAW,EAA0B,CAAC;IACtD,CAAC;IAIM,KAAK,CAAC,MAAM,CAAC,YAAsB,EAAE,WAAsB,EAAE,QAA4B;QAC5F,MAAM,CAAC,GAAwC;YAC3C;gBACI,IAAI,EAAE,QAAQ;gBACd,UAAU,EAAE,oBAAoB;gBAChC,YAAY,EAAE,gBAAgB;aACjC;SACJ,CAAA;QACD,MAAM,IAAI,CAAC,IAAI,CAAC,CAAC,EAAE,QAAQ,EAAE,YAAY,EAAE,WAAW,CAAC,CAAC;IAC5D,CAAC;IAED,IAAW,aAAa;QACpB,OAAO,IAAI,CAAC,cAAc,CAAC;IAC/B,CAAC;IAED;;OAEG;IACI,gBAAgB,CAAC,IAAY;QAChC,MAAM,KAAK,GAAI,IAAI,CAAC,cAAc,CAAC,IAAI,CAAC,CAAC,CAAC,EAAE,CAAC,CAAC,CAAC,IAAI,CAAC,IAAI,EAAE,CAAC,WAAW,EAAE,KAAK,IAAI,CAAC,IAAI,EAAE,CAAC,WAAW,EAAE,CAAC,CAAC;QACxG,OAAO,KAAK,CAAC;IACjB,CAAC;CACJ;AAhCD,wDAgCC"}
|