musora-content-services 2.83.0 → 2.84.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/CHANGELOG.md CHANGED
@@ -2,6 +2,13 @@
2
2
 
3
3
  All notable changes to this project will be documented in this file. See [standard-version](https://github.com/conventional-changelog/standard-version) for commit guidelines.
4
4
 
5
+ ## [2.84.0](https://github.com/railroadmedia/musora-content-services/compare/v2.83.0...v2.84.0) (2025-11-21)
6
+
7
+
8
+ ### Features
9
+
10
+ * add option to work with object data when datafield is provided in content aggregator ([#579](https://github.com/railroadmedia/musora-content-services/issues/579)) ([300f10a](https://github.com/railroadmedia/musora-content-services/commit/300f10a9e17b8a916af746e88b091cab6772cc28))
11
+
5
12
  ## [2.83.0](https://github.com/railroadmedia/musora-content-services/compare/v2.82.0...v2.83.0) (2025-11-21)
6
13
 
7
14
 
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "musora-content-services",
3
- "version": "2.83.0",
3
+ "version": "2.84.0",
4
4
  "description": "A package for Musoras content services ",
5
5
  "main": "src/index.js",
6
6
  "type": "module",
@@ -168,10 +168,20 @@ function extractItemsFromData(data, dataField, isParentArray, includeParent) {
168
168
  if (dataField) {
169
169
  if (isParentArray) {
170
170
  for (const parent of data) {
171
- items = [...items, ...parent[dataField]]
171
+ const fieldValue = parent[dataField]
172
+ if (Array.isArray(fieldValue)) {
173
+ items = [...items, ...fieldValue]
174
+ } else if (fieldValue && typeof fieldValue === 'object') {
175
+ items = [...items, fieldValue]
176
+ }
172
177
  }
173
178
  } else {
174
- items = data[dataField]
179
+ const fieldValue = data[dataField]
180
+ if (Array.isArray(fieldValue)) {
181
+ items = fieldValue
182
+ } else if (fieldValue && typeof fieldValue === 'object') {
183
+ items = [fieldValue]
184
+ }
175
185
  }
176
186
  if (includeParent) {
177
187
  if (isParentArray) {
@@ -194,14 +204,20 @@ async function processItems(data, addContext, dataField, isParentArray, includeP
194
204
  if (dataField) {
195
205
  if (isParentArray) {
196
206
  for (let parent of data) {
197
- parent[dataField] = Array.isArray(parent[dataField])
198
- ? await Promise.all(parent[dataField].map(addContext))
199
- : await addContext(parent[dataField])
207
+ const fieldValue = parent[dataField]
208
+ if (Array.isArray(fieldValue)) {
209
+ parent[dataField] = await Promise.all(fieldValue.map(addContext))
210
+ } else if (fieldValue && typeof fieldValue === 'object') {
211
+ parent[dataField] = await addContext(fieldValue)
212
+ }
200
213
  }
201
214
  } else {
202
- data[dataField] = Array.isArray(data[dataField])
203
- ? await Promise.all(data[dataField].map(addContext))
204
- : await addContext(data[dataField])
215
+ const fieldValue = data[dataField]
216
+ if (Array.isArray(fieldValue)) {
217
+ data[dataField] = await Promise.all(fieldValue.map(addContext))
218
+ } else if (fieldValue && typeof fieldValue === 'object') {
219
+ data[dataField] = await addContext(fieldValue)
220
+ }
205
221
  }
206
222
  if (includeParent) {
207
223
  data = isParentArray ? await Promise.all(data.map(addContext)) : await addContext(data)