@memberjunction/core-entities 2.123.1 → 2.124.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.
|
@@ -10,8 +10,7 @@ export declare class ComponentEntityExtended extends ComponentEntity {
|
|
|
10
10
|
* @returns
|
|
11
11
|
*/
|
|
12
12
|
Save(options?: EntitySaveOptions): Promise<boolean>;
|
|
13
|
-
|
|
14
|
-
private _syncingFromSpec;
|
|
13
|
+
protected _spec: ComponentSpec | undefined;
|
|
15
14
|
/**
|
|
16
15
|
* Read-only representation of the value in the @see Specification property.
|
|
17
16
|
* **DO NOT** modify this object it is for reference and ease of access only. Writing must be done to the
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"ComponentEntityExtended.d.ts","sourceRoot":"","sources":["../../src/custom/ComponentEntityExtended.ts"],"names":[],"mappings":"AAAA,OAAO,EAAc,YAAY,EAAE,iBAAiB,EAAE,oBAAoB,EAAE,MAAM,sBAAsB,CAAC;AACzG,OAAO,EAAE,eAAe,EAAE,MAAM,gCAAgC,CAAC;AAEjE,OAAO,EAAE,aAAa,EAAE,MAAM,6CAA6C,CAAC;AAE5E,qBACa,uBAAwB,SAAQ,eAAe;IACxD;;;;;;OAMG;IACmB,IAAI,CAAC,OAAO,CAAC,EAAE,iBAAiB,GAAG,OAAO,CAAC,OAAO,CAAC;
|
|
1
|
+
{"version":3,"file":"ComponentEntityExtended.d.ts","sourceRoot":"","sources":["../../src/custom/ComponentEntityExtended.ts"],"names":[],"mappings":"AAAA,OAAO,EAAc,YAAY,EAAE,iBAAiB,EAAE,oBAAoB,EAAE,MAAM,sBAAsB,CAAC;AACzG,OAAO,EAAE,eAAe,EAAE,MAAM,gCAAgC,CAAC;AAEjE,OAAO,EAAE,aAAa,EAAE,MAAM,6CAA6C,CAAC;AAE5E,qBACa,uBAAwB,SAAQ,eAAe;IACxD;;;;;;OAMG;IACmB,IAAI,CAAC,OAAO,CAAC,EAAE,iBAAiB,GAAG,OAAO,CAAC,OAAO,CAAC;IAsCzE,SAAS,CAAC,KAAK,EAAE,aAAa,GAAG,SAAS,CAAC;IAE3C;;;;;OAKG;IACH,IAAW,IAAI,IAAI,aAAa,CAE/B;IAGQ,GAAG,CAAC,SAAS,EAAE,MAAM,EAAE,KAAK,EAAE,GAAG,GAAG,IAAI;IAajD,SAAS,CAAC,OAAO,CAAC,OAAO,EAAE,MAAM,GAAG,aAAa;IA2BlC,SAAS,CAAC,YAAY,EAAE,YAAY,EAAE,yBAAyB,CAAC,EAAE,MAAM,EAAE,GAAG,OAAO,CAAC,OAAO,CAAC;IASnG,SAAS,CAAC,SAAS,CAAC,EAAE,oBAAoB,GAAG,OAAO;IAQ9C,YAAY,CAAC,IAAI,EAAE,GAAG,EAAE,iBAAiB,CAAC,EAAE,OAAO,GAAG,OAAO,CAAC,OAAO,CAAC;CAQxF"}
|
|
@@ -11,10 +11,6 @@ const core_1 = require("@memberjunction/core");
|
|
|
11
11
|
const entity_subclasses_1 = require("../generated/entity_subclasses");
|
|
12
12
|
const global_1 = require("@memberjunction/global");
|
|
13
13
|
let ComponentEntityExtended = class ComponentEntityExtended extends entity_subclasses_1.ComponentEntity {
|
|
14
|
-
constructor() {
|
|
15
|
-
super(...arguments);
|
|
16
|
-
this._syncingFromSpec = false; // Flag to allow internal sets from SetSpec()
|
|
17
|
-
}
|
|
18
14
|
/**
|
|
19
15
|
* Whenever a Component record is saved, if it is a new record or if the Specification field
|
|
20
16
|
* has changed, we will recalculate the values of the hasCustomProps, hasCustomEvents, RequiresData, DependencyCount fields,
|
|
@@ -23,25 +19,35 @@ let ComponentEntityExtended = class ComponentEntityExtended extends entity_subcl
|
|
|
23
19
|
* @returns
|
|
24
20
|
*/
|
|
25
21
|
async Save(options) {
|
|
26
|
-
|
|
27
|
-
if (!this.
|
|
28
|
-
|
|
29
|
-
|
|
30
|
-
|
|
31
|
-
|
|
32
|
-
|
|
33
|
-
|
|
34
|
-
|
|
35
|
-
|
|
36
|
-
|
|
37
|
-
this.
|
|
38
|
-
// Note: Description, FunctionalRequirements, and TechnicalDesign are now synced
|
|
39
|
-
// immediately in SetSpec() to ensure they're always current with the Specification
|
|
22
|
+
// Always ensure spec is parsed before save
|
|
23
|
+
if (!this._spec) {
|
|
24
|
+
this.SetSpec(this.Specification);
|
|
25
|
+
}
|
|
26
|
+
try {
|
|
27
|
+
const spec = this._spec;
|
|
28
|
+
if (spec) {
|
|
29
|
+
// ALWAYS sync Description, FunctionalRequirements, and TechnicalDesign from spec before save
|
|
30
|
+
// This ensures Specification is the single source of truth - any manual changes to these
|
|
31
|
+
// fields will be overwritten with values from the Specification
|
|
32
|
+
if (spec.description) {
|
|
33
|
+
this.Description = spec.description;
|
|
40
34
|
}
|
|
35
|
+
if (spec.functionalRequirements) {
|
|
36
|
+
this.FunctionalRequirements = spec.functionalRequirements;
|
|
37
|
+
}
|
|
38
|
+
if (spec.technicalDesign) {
|
|
39
|
+
this.TechnicalDesign = spec.technicalDesign;
|
|
40
|
+
}
|
|
41
|
+
// Calculate other derived fields from spec
|
|
42
|
+
this.HasCustomProps = spec.properties?.length > 0;
|
|
43
|
+
this.HasRequiredCustomProps = spec.properties?.some(p => p.required) || false;
|
|
44
|
+
this.HasCustomEvents = spec.events?.length > 0;
|
|
45
|
+
this.RequiresData = spec.dataRequirements?.mode?.length > 0;
|
|
46
|
+
this.DependencyCount = spec.dependencies?.length || 0;
|
|
41
47
|
}
|
|
42
|
-
|
|
43
|
-
|
|
44
|
-
|
|
48
|
+
}
|
|
49
|
+
catch (ex) {
|
|
50
|
+
console.error('Error saving ComponentEntityExtended:', ex);
|
|
45
51
|
}
|
|
46
52
|
return await super.Save(options);
|
|
47
53
|
}
|
|
@@ -57,26 +63,12 @@ let ComponentEntityExtended = class ComponentEntityExtended extends entity_subcl
|
|
|
57
63
|
// Below we override various methods that could result in setting of the value of the Specification field which in turn allows us to keep the spec property in sync
|
|
58
64
|
Set(FieldName, Value) {
|
|
59
65
|
const fieldNameLower = FieldName?.trim().toLowerCase();
|
|
60
|
-
// Prevent direct setting of fields that are derived from the Specification
|
|
61
|
-
// These fields are automatically synced from the spec and should not be set directly
|
|
62
|
-
// Exception: Allow internal sets when syncing from the spec itself
|
|
63
|
-
if (!this._syncingFromSpec &&
|
|
64
|
-
(fieldNameLower === 'description' ||
|
|
65
|
-
fieldNameLower === 'functionalrequirements' ||
|
|
66
|
-
fieldNameLower === 'technicaldesign')) {
|
|
67
|
-
// Log a warning to help developers understand the correct pattern
|
|
68
|
-
console.warn(`⚠️ ComponentEntity: Attempted to set '${FieldName}' directly. ` +
|
|
69
|
-
`This field is automatically derived from the Specification. ` +
|
|
70
|
-
`Please update the spec file instead to ensure consistency.`);
|
|
71
|
-
// Skip setting these fields - they will be synced from Specification
|
|
72
|
-
return;
|
|
73
|
-
}
|
|
74
66
|
const oldValue = this.Get(FieldName);
|
|
75
67
|
super.Set(FieldName, Value);
|
|
76
|
-
|
|
77
|
-
|
|
78
|
-
|
|
79
|
-
|
|
68
|
+
// When Specification field is set, sync the derived fields from the spec
|
|
69
|
+
// This ensures Description/FunctionalRequirements/TechnicalDesign stay in sync with the spec
|
|
70
|
+
if (fieldNameLower === 'specification' && oldValue !== Value) {
|
|
71
|
+
this.SetSpec(Value);
|
|
80
72
|
}
|
|
81
73
|
}
|
|
82
74
|
SetSpec(newSpec) {
|
|
@@ -95,28 +87,21 @@ let ComponentEntityExtended = class ComponentEntityExtended extends entity_subcl
|
|
|
95
87
|
// These redundant columns exist for backwards compatibility and database queries,
|
|
96
88
|
// but should always reflect what's in the spec.
|
|
97
89
|
if (this._spec) {
|
|
98
|
-
|
|
99
|
-
|
|
100
|
-
|
|
101
|
-
|
|
102
|
-
|
|
103
|
-
}
|
|
104
|
-
if (this._spec.functionalRequirements) {
|
|
105
|
-
this.FunctionalRequirements = this._spec.functionalRequirements;
|
|
106
|
-
}
|
|
107
|
-
if (this._spec.technicalDesign) {
|
|
108
|
-
this.TechnicalDesign = this._spec.technicalDesign;
|
|
109
|
-
}
|
|
90
|
+
if (this._spec.description) {
|
|
91
|
+
this.Description = this._spec.description;
|
|
92
|
+
}
|
|
93
|
+
if (this._spec.functionalRequirements) {
|
|
94
|
+
this.FunctionalRequirements = this._spec.functionalRequirements;
|
|
110
95
|
}
|
|
111
|
-
|
|
112
|
-
|
|
113
|
-
this._syncingFromSpec = false;
|
|
96
|
+
if (this._spec.technicalDesign) {
|
|
97
|
+
this.TechnicalDesign = this._spec.technicalDesign;
|
|
114
98
|
}
|
|
115
99
|
}
|
|
116
100
|
}
|
|
117
101
|
async InnerLoad(CompositeKey, EntityRelationshipsToLoad) {
|
|
118
102
|
const result = await super.InnerLoad(CompositeKey, EntityRelationshipsToLoad);
|
|
119
103
|
if (result) {
|
|
104
|
+
// After loading from database, re-sync derived fields from Specification to ensure consistency
|
|
120
105
|
this.SetSpec(this.Specification);
|
|
121
106
|
}
|
|
122
107
|
return result;
|
|
@@ -131,6 +116,7 @@ let ComponentEntityExtended = class ComponentEntityExtended extends entity_subcl
|
|
|
131
116
|
async LoadFromData(data, _replaceOldValues) {
|
|
132
117
|
const result = await super.LoadFromData(data, _replaceOldValues);
|
|
133
118
|
if (result) {
|
|
119
|
+
// After loading, re-sync derived fields from Specification to ensure consistency
|
|
134
120
|
this.SetSpec(this.Specification);
|
|
135
121
|
}
|
|
136
122
|
return result;
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"ComponentEntityExtended.js","sourceRoot":"","sources":["../../src/custom/ComponentEntityExtended.ts"],"names":[],"mappings":";;;;;;;;;AAAA,+CAAyG;AACzG,sEAAiE;AACjE,mDAAsE;AAI/D,IAAM,uBAAuB,GAA7B,MAAM,uBAAwB,SAAQ,mCAAe;
|
|
1
|
+
{"version":3,"file":"ComponentEntityExtended.js","sourceRoot":"","sources":["../../src/custom/ComponentEntityExtended.ts"],"names":[],"mappings":";;;;;;;;;AAAA,+CAAyG;AACzG,sEAAiE;AACjE,mDAAsE;AAI/D,IAAM,uBAAu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AU,EAAE,gBAAgB,CAAC;GAC/B,uBAAuB,CA4HnC"}
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@memberjunction/core-entities",
|
|
3
|
-
"version": "2.
|
|
3
|
+
"version": "2.124.0",
|
|
4
4
|
"description": "Entity subclasses for the metadata layer of MemberJunction defined in the MJ_CORE schema (usually '__mj'), distributed as part of each release of MemberJunction",
|
|
5
5
|
"main": "dist/index.js",
|
|
6
6
|
"types": "dist/index.d.ts",
|
|
@@ -19,10 +19,10 @@
|
|
|
19
19
|
"typescript": "^5.4.5"
|
|
20
20
|
},
|
|
21
21
|
"dependencies": {
|
|
22
|
-
"@memberjunction/ai": "2.
|
|
23
|
-
"@memberjunction/core": "2.
|
|
24
|
-
"@memberjunction/global": "2.
|
|
25
|
-
"@memberjunction/interactive-component-types": "2.
|
|
22
|
+
"@memberjunction/ai": "2.124.0",
|
|
23
|
+
"@memberjunction/core": "2.124.0",
|
|
24
|
+
"@memberjunction/global": "2.124.0",
|
|
25
|
+
"@memberjunction/interactive-component-types": "2.124.0",
|
|
26
26
|
"zod": "^3.23.8"
|
|
27
27
|
},
|
|
28
28
|
"repository": {
|