@memberjunction/react-runtime 5.26.0 → 5.27.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.
@@ -1,13 +1,13 @@
1
1
 
2
- > @memberjunction/react-runtime@5.26.0 build
2
+ > @memberjunction/react-runtime@5.27.0 build
3
3
  > npm run build:node && npm run build:umd
4
4
 
5
5
 
6
- > @memberjunction/react-runtime@5.26.0 build:node
6
+ > @memberjunction/react-runtime@5.27.0 build:node
7
7
  > tsc
8
8
 
9
9
 
10
- > @memberjunction/react-runtime@5.26.0 build:umd
10
+ > @memberjunction/react-runtime@5.27.0 build:umd
11
11
  > webpack --config webpack.umd.config.cjs
12
12
 
13
13
  [BABEL] Note: The code generator has deoptimised the styling of /home/runner/work/MJ/MJ/packages/MJCoreEntities/dist/generated/entity_subclasses.js as it exceeds the max of 500KB.
@@ -26,6 +26,6 @@ cacheable modules 6.56 MiB
26
26
  ../../MJCoreEntities/dist/engines/UserViewEngine.js 19.6 KiB [built] [code generated]
27
27
  ./dist/index.js + 27 modules 426 KiB [built] [code generated]
28
28
  ../../MJCore/dist/index.js + 75 modules 1.3 MiB [built] [code generated]
29
- ../../MJGlobal/dist/index.js + 16 modules 220 KiB [built] [code generated]
29
+ ../../MJGlobal/dist/index.js + 16 modules 221 KiB [built] [code generated]
30
30
  ../../GraphQLDataProvider/dist/index.mjs 158 KiB [built] [code generated]
31
- webpack 5.105.0 compiled successfully in 76682 ms
31
+ webpack 5.105.0 compiled successfully in 85682 ms
package/CHANGELOG.md CHANGED
@@ -1,5 +1,15 @@
1
1
  # @memberjunction/react-runtime
2
2
 
3
+ ## 5.27.0
4
+
5
+ ### Patch Changes
6
+
7
+ - @memberjunction/graphql-dataprovider@5.27.0
8
+ - @memberjunction/interactive-component-types@5.27.0
9
+ - @memberjunction/core@5.27.0
10
+ - @memberjunction/core-entities@5.27.0
11
+ - @memberjunction/global@5.27.0
12
+
3
13
  ## 5.26.0
4
14
 
5
15
  ### Patch Changes
@@ -19975,6 +19975,20 @@ var BaseInfo = /*#__PURE__*/function () {
19975
19975
  this.copyInitData(initData);
19976
19976
  }
19977
19977
  }
19978
+ /**
19979
+ * Default JSON serialization for BaseInfo subclasses.
19980
+ *
19981
+ * Emits all non-underscored direct field declarations. For `_`-prefixed private backing fields
19982
+ * (the MJ pattern for collection storage — e.g. `_Fields`, `_RelatedEntities`, `_OrganicKeys`),
19983
+ * emits the value of the corresponding same-named public getter instead. Purely computed getters
19984
+ * without a backing field (display-name formatters, derived flags) are intentionally skipped —
19985
+ * they can throw when source fields are null and don't belong on the wire anyway.
19986
+ *
19987
+ * Nested BaseInfo instances and arrays of them unwrap automatically via JSON.stringify's
19988
+ * native toJSON() protocol.
19989
+ *
19990
+ * Subclasses may override to emit a filtered subset or custom shape (see EntityFieldValueInfo).
19991
+ */
19978
19992
  return _createClass(BaseInfo, [{
19979
19993
  key: "copyInitData",
19980
19994
  value:
@@ -20003,6 +20017,32 @@ var BaseInfo = /*#__PURE__*/function () {
20003
20017
  }
20004
20018
  }
20005
20019
  }
20020
+ }, {
20021
+ key: "toJSON",
20022
+ value: function toJSON() {
20023
+ var result = {};
20024
+ var self = this;
20025
+ for (var _i = 0, _Object$keys = Object.keys(this); _i < _Object$keys.length; _i++) {
20026
+ var key = _Object$keys[_i];
20027
+ if (!key.startsWith('_')) {
20028
+ result[key] = self[key];
20029
+ continue;
20030
+ }
20031
+ // Private backing field — expose via its public getter if one exists with the same name minus the underscore
20032
+ var publicKey = key.slice(1);
20033
+ if (!publicKey) continue;
20034
+ var proto = Object.getPrototypeOf(this);
20035
+ while (proto && proto !== Object.prototype) {
20036
+ var desc = Object.getOwnPropertyDescriptor(proto, publicKey);
20037
+ if (desc && typeof desc.get === 'function') {
20038
+ result[publicKey] = self[publicKey];
20039
+ break;
20040
+ }
20041
+ proto = Object.getPrototypeOf(proto);
20042
+ }
20043
+ }
20044
+ return result;
20045
+ }
20006
20046
  }]);
20007
20047
  }();
20008
20048
  ;// ../../MJCore/dist/generic/platformVariants.js
@@ -22629,7 +22669,7 @@ var EntityOrganicKeyInfo = /*#__PURE__*/function (_BaseInfo3) {
22629
22669
  if (initData) {
22630
22670
  _this3.copyInitData(initData);
22631
22671
  _this3._RelatedEntities = [];
22632
- var re = initData.EntityOrganicKeyRelatedEntities || initData._RelatedEntities;
22672
+ var re = initData.EntityOrganicKeyRelatedEntities || initData._RelatedEntities || initData.RelatedEntities;
22633
22673
  if (re && Array.isArray(re)) {
22634
22674
  // sort by sequence
22635
22675
  var sorted = entityInfo_toConsumableArray(re);
@@ -22883,8 +22923,20 @@ var EntityFieldValueInfo = /*#__PURE__*/function (_BaseInfo6) {
22883
22923
  _this6.copyInitData(initData);
22884
22924
  return _this6;
22885
22925
  }
22926
+ /**
22927
+ * Returns a plain object suitable for JSON serialization.
22928
+ * Called automatically by JSON.stringify().
22929
+ */
22886
22930
  entityInfo_inherits(EntityFieldValueInfo, _BaseInfo6);
22887
- return entityInfo_createClass(EntityFieldValueInfo);
22931
+ return entityInfo_createClass(EntityFieldValueInfo, [{
22932
+ key: "toJSON",
22933
+ value: function toJSON() {
22934
+ return {
22935
+ Value: this.Value,
22936
+ Code: this.Code
22937
+ };
22938
+ }
22939
+ }]);
22888
22940
  }(BaseInfo);
22889
22941
  var GeneratedFormSectionType = {
22890
22942
  Top: 'Top',
@@ -23945,9 +23997,9 @@ var EntityInfo = /*#__PURE__*/function (_BaseInfo0) {
23945
23997
  if (initData) {
23946
23998
  _this0.copyInitData(initData);
23947
23999
  // do some special handling to create class instances instead of just data objects
23948
- // copy the Entity Fields
24000
+ // copy the Entity Fields (accept EntityFields, _Fields, or Fields as input names)
23949
24001
  _this0._Fields = [];
23950
- var ef = initData.EntityFields || initData._Fields;
24002
+ var ef = initData.EntityFields || initData._Fields || initData.Fields;
23951
24003
  if (ef) {
23952
24004
  for (var j = 0; j < ef.length; j++) {
23953
24005
  _this0._Fields.push(new EntityFieldInfo(ef[j]));
@@ -23971,9 +24023,9 @@ var EntityInfo = /*#__PURE__*/function (_BaseInfo0) {
23971
24023
  }
23972
24024
  // auto-populate FieldCategories from the FieldCategoryInfo setting
23973
24025
  _this0._FieldCategories = _this0.parseFieldCategoriesFromSettings();
23974
- // copy the Related Entities
24026
+ // copy the Related Entities (accept EntityRelationships, _RelatedEntities, or RelatedEntities as input names)
23975
24027
  _this0._RelatedEntities = [];
23976
- var er = initData.EntityRelationships || initData._RelatedEntities;
24028
+ var er = initData.EntityRelationships || initData._RelatedEntities || initData.RelatedEntities;
23977
24029
  if (er) {
23978
24030
  // check to see if ANY of the records in the er array have a non-null or non-zero sequence value. The reason is
23979
24031
  // if we have any sequence values populated we want to sort by that sequence, and we want to consider null to be a high number
@@ -24009,7 +24061,7 @@ var EntityInfo = /*#__PURE__*/function (_BaseInfo0) {
24009
24061
  }
24010
24062
  // copy the Organic Keys (sorted by sequence inside EntityOrganicKeyInfo constructor)
24011
24063
  _this0._OrganicKeys = [];
24012
- var ok = initData.EntityOrganicKeys || initData._OrganicKeys;
24064
+ var ok = initData.EntityOrganicKeys || initData._OrganicKeys || initData.OrganicKeys;
24013
24065
  if (ok && Array.isArray(ok)) {
24014
24066
  var _iterator3 = entityInfo_createForOfIteratorHelper(ok),
24015
24067
  _step3;
@@ -94007,12 +94059,19 @@ function util_GetGlobalObjectStore() {
94007
94059
  }
94008
94060
  /**
94009
94061
  * This utility function will copy all scalar and array properties from an object to a new object and return the new object.
94010
- * This function will NOT copy functions or non-plain objects (unless resolveCircularReferences is true).
94062
+ * This function will NOT copy non-plain object instances (unless they implement `toJSON()` or `resolveCircularReferences` is true).
94063
+ *
94064
+ * The function respects the standard JavaScript `toJSON()` protocol: if a value exposes a `toJSON()` method
94065
+ * (as `Date`, `BaseInfo` subclasses, and user-defined classes can), the method is invoked and its return value
94066
+ * is processed in place of the original. This mirrors how `JSON.stringify()` handles serialization.
94067
+ *
94068
+ * Arrays are recursively processed — each item is copied/toJSON'd individually — so nested objects with
94069
+ * `toJSON()` are unwrapped to their serializable form.
94011
94070
  *
94012
94071
  * @param input - The object to copy
94013
94072
  * @param resolveCircularReferences - If true, handles circular references and complex objects for safe JSON serialization.
94014
94073
  * When enabled, circular references are replaced with '[Circular Reference]',
94015
- * complex objects (Sockets, Streams, etc.) are replaced with their type names,
94074
+ * complex objects without `toJSON()` are replaced with their type names,
94016
94075
  * Error objects are specially handled to extract name/message/stack,
94017
94076
  * and Dates are converted to ISO strings. Default: false
94018
94077
  * @param maxDepth - Maximum recursion depth when resolveCircularReferences is true (default: 10)
@@ -94053,11 +94112,8 @@ function CopyScalarsAndArrays(input) {
94053
94112
  return _copy(item, depth + 1);
94054
94113
  });
94055
94114
  }
94056
- // Handle Date objects
94057
- if (_.isDate(value)) {
94058
- return value.toISOString();
94059
- }
94060
94115
  // Handle Error objects specially to get their properties
94116
+ // (checked before toJSON so we always get name/message/stack, even if Error subclasses define toJSON)
94061
94117
  if (value instanceof Error) {
94062
94118
  return _objectSpread({
94063
94119
  name: value.name,
@@ -94065,6 +94121,10 @@ function CopyScalarsAndArrays(input) {
94065
94121
  stack: value.stack
94066
94122
  }, _copy(_.omit(value, ['name', 'message', 'stack']), depth + 1));
94067
94123
  }
94124
+ // Respect the toJSON() protocol (covers Date, BaseInfo subclasses, and any class that implements it)
94125
+ if (typeof value.toJSON === 'function') {
94126
+ return _copy(value.toJSON(), depth + 1);
94127
+ }
94068
94128
  // Handle plain objects (POJOs)
94069
94129
  if (_.isPlainObject(value)) {
94070
94130
  var result = {};
@@ -94075,7 +94135,7 @@ function CopyScalarsAndArrays(input) {
94075
94135
  }
94076
94136
  return result;
94077
94137
  }
94078
- // For complex objects (Socket, Stream, Buffer, etc.), just use the type name
94138
+ // For complex objects without toJSON (Socket, Stream, Buffer, etc.), just use the type name
94079
94139
  var typeName = ((_value$constructor = value.constructor) === null || _value$constructor === void 0 ? void 0 : _value$constructor.name) || 'Object';
94080
94140
  if (typeName !== 'Object') {
94081
94141
  return "[".concat(typeName, "]");
@@ -94084,21 +94144,41 @@ function CopyScalarsAndArrays(input) {
94084
94144
  };
94085
94145
  return _copy(input, 0);
94086
94146
  } else {
94087
- // Original implementation for backward compatibility
94147
+ // Simple mode: preserves existing behavior (primitives/functions pass through, class instances
94148
+ // without toJSON get their keys dropped) while honoring the toJSON() protocol and recursing
94149
+ // into array items so nested objects with toJSON are unwrapped.
94088
94150
  var result = {};
94089
94151
  Object.keys(input).forEach(function (key) {
94090
94152
  var value = input[key];
94091
- // Check for null or scalar types directly
94153
+ // Primitives, null, functions pass through
94092
94154
  if (value === null || util_typeof(value) !== 'object') {
94093
94155
  result[key] = value;
94094
- } else if (Array.isArray(value)) {
94095
- // Handle arrays by creating a new array with the same elements
94096
- result[key] = _toConsumableArray(value);
94097
- } else if (util_typeof(value) === 'object' && value.constructor === Object) {
94098
- // Recursively copy plain objects
94156
+ return;
94157
+ }
94158
+ // toJSON protocol — use the method's output
94159
+ var valueToJSON = value.toJSON;
94160
+ if (typeof valueToJSON === 'function') {
94161
+ result[key] = valueToJSON.call(value);
94162
+ return;
94163
+ }
94164
+ // Arrays — process each item; items with toJSON are unwrapped, class instances without it are replaced with null to preserve array length
94165
+ if (Array.isArray(value)) {
94166
+ result[key] = value.map(function (item) {
94167
+ if (item === null || util_typeof(item) !== 'object') return item;
94168
+ var itemToJSON = item.toJSON;
94169
+ if (typeof itemToJSON === 'function') return itemToJSON.call(item);
94170
+ if (item.constructor === Object) return CopyScalarsAndArrays(item);
94171
+ // Non-plain, non-toJSON class instances inside an array — can't drop without changing
94172
+ // array length, so fall back to null (sanitized placeholder)
94173
+ return null;
94174
+ });
94175
+ return;
94176
+ }
94177
+ // Plain objects — recurse (key omitted for class instances without toJSON)
94178
+ if (value.constructor === Object) {
94099
94179
  result[key] = CopyScalarsAndArrays(value);
94100
94180
  }
94101
- // Functions and non-plain objects are intentionally ignored
94181
+ // else: non-plain class instance without toJSON → key is dropped entirely (matches legacy)
94102
94182
  });
94103
94183
  return result;
94104
94184
  }
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@memberjunction/react-runtime",
3
- "version": "5.26.0",
3
+ "version": "5.27.0",
4
4
  "description": "Platform-agnostic React component runtime for MemberJunction. Provides core compilation, registry, and execution capabilities for React components in any JavaScript environment.",
5
5
  "type": "module",
6
6
  "main": "dist/index.js",
@@ -29,11 +29,11 @@
29
29
  },
30
30
  "homepage": "https://github.com/MemberJunction/MJ#readme",
31
31
  "dependencies": {
32
- "@memberjunction/core": "5.26.0",
33
- "@memberjunction/global": "5.26.0",
34
- "@memberjunction/interactive-component-types": "5.26.0",
35
- "@memberjunction/core-entities": "5.26.0",
36
- "@memberjunction/graphql-dataprovider": "5.26.0",
32
+ "@memberjunction/core": "5.27.0",
33
+ "@memberjunction/global": "5.27.0",
34
+ "@memberjunction/interactive-component-types": "5.27.0",
35
+ "@memberjunction/core-entities": "5.27.0",
36
+ "@memberjunction/graphql-dataprovider": "5.27.0",
37
37
  "@babel/standalone": "^7.29.1",
38
38
  "rxjs": "^7.8.2"
39
39
  },