@adobe/spacecat-shared-data-access 2.62.2 → 2.63.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
@@ -1,3 +1,10 @@
1
+ # [@adobe/spacecat-shared-data-access-v2.63.0](https://github.com/adobe/spacecat-shared/compare/@adobe/spacecat-shared-data-access-v2.62.2...@adobe/spacecat-shared-data-access-v2.63.0) (2025-09-19)
2
+
3
+
4
+ ### Features
5
+
6
+ * System-Wide Pagination Fix for DynamoDB Data Truncation ([#964](https://github.com/adobe/spacecat-shared/issues/964)) ([8f82e5f](https://github.com/adobe/spacecat-shared/commit/8f82e5fe2d5ed9ecd8ad2ff4e139b0588b3d8c01))
7
+
1
8
  # [@adobe/spacecat-shared-data-access-v2.62.2](https://github.com/adobe/spacecat-shared/compare/@adobe/spacecat-shared-data-access-v2.62.1...@adobe/spacecat-shared-data-access-v2.62.2) (2025-09-16)
2
9
 
3
10
 
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@adobe/spacecat-shared-data-access",
3
- "version": "2.62.2",
3
+ "version": "2.63.0",
4
4
  "description": "Shared modules of the Spacecat Services - Data Access",
5
5
  "type": "module",
6
6
  "engines": {
@@ -252,15 +252,34 @@ class BaseCollection {
252
252
  let result = await query.go(queryOptions);
253
253
  let allData = result.data;
254
254
 
255
- // if the caller requests ALL pages and we're not using limit: 1,
256
- // continue to fetch until there is no cursor.
257
- if (options.fetchAllPages && options.limit !== 1) {
255
+ // Smart pagination behavior:
256
+ // - fetchAllPages: true Always paginate through all results
257
+ // - fetchAllPages: false Only fetch first page
258
+ // - undefined → Auto-paginate when no limit specified, respect limits otherwise
259
+ const shouldFetchAllPages = options.fetchAllPages === true
260
+ || (options.fetchAllPages !== false && !options.limit);
261
+
262
+ if (shouldFetchAllPages) {
263
+ let pageCount = 1;
264
+ const startTime = Date.now();
265
+
258
266
  while (result.cursor) {
267
+ pageCount += 1;
259
268
  queryOptions.cursor = result.cursor;
260
269
  // eslint-disable-next-line no-await-in-loop
261
270
  result = await query.go(queryOptions);
262
271
  allData = allData.concat(result.data);
263
272
  }
273
+
274
+ // Debug logging to track pagination behavior
275
+ if (pageCount > 1) {
276
+ this.log.debug(`Pagination completed for ${this.entityName}`, {
277
+ entityName: this.entityName,
278
+ totalPages: pageCount,
279
+ totalRecords: allData.length,
280
+ queryDuration: Date.now() - startTime,
281
+ });
282
+ }
264
283
  }
265
284
 
266
285
  if (options.limit === 1) {
@@ -34,6 +34,13 @@ export interface QueryOptions {
34
34
  limit?: number;
35
35
  order?: string;
36
36
  attributes?: string[];
37
+ /**
38
+ * Whether to automatically fetch all pages of results.
39
+ * - `true`: Always paginate through all results
40
+ * - `false`: Only fetch first page
41
+ * - `undefined`: Auto-paginate when no limit specified, respect limits otherwise
42
+ */
43
+ fetchAllPages?: boolean;
37
44
  }
38
45
 
39
46
  export interface BaseCollection<T extends BaseModel> {
@@ -130,10 +130,16 @@ export function createAccessor(config) { /* eslint-disable no-underscore-dangle
130
130
  } else {
131
131
  const { keys, options } = parseAccessorArgs(collection, requiredKeys, args);
132
132
  const allKeys = { ...foreignKeys, ...keys };
133
+ const finalOptions = all
134
+ ? {
135
+ ...options,
136
+ fetchAllPages: options?.fetchAllPages ?? !options?.limit,
137
+ }
138
+ : options;
133
139
 
134
140
  result = all
135
- ? collection.allByIndexKeys(allKeys, options)
136
- : collection.findByIndexKeys(allKeys, options);
141
+ ? collection.allByIndexKeys(allKeys, finalOptions)
142
+ : collection.findByIndexKeys(allKeys, finalOptions);
137
143
  }
138
144
 
139
145
  result = await result;