@boostercloud/framework-provider-azure 3.4.3-debug.4 → 3.4.3-debug.6

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.
@@ -46,33 +46,30 @@ async function search(cosmosDb, config, containerName, filters, limit, afterCurs
46
46
  });
47
47
  // Use Cosmos DB's continuation token pagination
48
48
  const feedOptions = {};
49
- if (limit) {
50
- feedOptions.maxItemCount = limit;
51
- }
52
- // Track cumulative offset for cursor.id calculation
53
- let cumulativeOffset = 0;
54
49
  // Extract continuation token from the cursor (backward compatibility)
55
50
  if (afterCursor === null || afterCursor === void 0 ? void 0 : afterCursor.continuationToken) {
56
51
  feedOptions.continuationToken = afterCursor.continuationToken;
57
- // Extract cumulative id from cursor for tracking position across pages
58
- cumulativeOffset = afterCursor.id && !isNaN(parseInt(afterCursor.id)) ? parseInt(afterCursor.id) : 0;
59
52
  logger.debug('PAGINATION DEBUG - Using provided continuation token:', {
60
53
  continuationToken: afterCursor.continuationToken,
61
- cumulativeOffset,
62
54
  feedOptions,
63
55
  });
64
56
  }
65
- else if (!canUseContinuationToken || hasLegacyCursor) {
57
+ // Azure Cosmos DB requires maxItemCount when using continuation tokens
58
+ // Always set maxItemCount when limit is provided or when using continuation token
59
+ if (limit || (afterCursor === null || afterCursor === void 0 ? void 0 : afterCursor.continuationToken)) {
60
+ feedOptions.maxItemCount = limit !== null && limit !== void 0 ? limit : 100;
61
+ }
62
+ if (!(afterCursor === null || afterCursor === void 0 ? void 0 : afterCursor.continuationToken) && (!canUseContinuationToken || hasLegacyCursor)) {
66
63
  // Legacy cursor format - fallback to OFFSET for backward compatibility
67
64
  const offset = (afterCursor === null || afterCursor === void 0 ? void 0 : afterCursor.id) ? parseInt(afterCursor.id) : 0;
68
- let legacyQuery = `${finalQuery} OFFSET ${offset}`;
69
- if (limit) {
70
- legacyQuery += ` LIMIT ${limit} `;
71
- }
65
+ // Azure Cosmos DB requires LIMIT when using OFFSET
66
+ const effectiveLimit = limit !== null && limit !== void 0 ? limit : 100;
67
+ const legacyQuery = `${finalQuery} OFFSET ${offset} LIMIT ${effectiveLimit} `;
72
68
  const legacyQuerySpec = { ...querySpec, query: legacyQuery };
73
69
  logger.debug('PAGINATION DEBUG - Using LEGACY OFFSET/LIMIT approach:', {
74
70
  reason: !canUseContinuationToken ? 'DISTINCT query detected' : 'Legacy numeric cursor detected',
75
71
  offset,
72
+ effectiveLimit,
76
73
  legacyQuery,
77
74
  legacyQuerySpec,
78
75
  });
@@ -102,25 +99,25 @@ async function search(cosmosDb, config, containerName, filters, limit, afterCurs
102
99
  continuationTokenLength: continuationToken === null || continuationToken === void 0 ? void 0 : continuationToken.length,
103
100
  });
104
101
  const finalResources = processResources(resources || []);
102
+ // cursor.id advances by the page size (limit) to maintain consistent page-based offsets
103
+ // that frontends rely on (e.g., limit=5 produces cursors 5, 10, 15, ...)
104
+ const previousOffset = (afterCursor === null || afterCursor === void 0 ? void 0 : afterCursor.id) ? parseInt(afterCursor.id) : 0;
105
+ const effectiveLimit = limit !== null && limit !== void 0 ? limit : 100;
105
106
  let cursor;
106
107
  if (continuationToken) {
107
- // Store both continuation token AND cumulative id for proper position tracking
108
- const newCumulativeId = cumulativeOffset + finalResources.length;
109
- cursor = { continuationToken, id: newCumulativeId.toString() };
108
+ cursor = { continuationToken, id: (previousOffset + effectiveLimit).toString() };
110
109
  logger.debug('PAGINATION DEBUG - Setting cursor with continuation token:', {
111
110
  cursor,
112
- previousOffset: cumulativeOffset,
113
- currentPageSize: finalResources.length,
114
- newCumulativeId,
111
+ previousOffset,
112
+ effectiveLimit,
115
113
  });
116
114
  }
117
115
  else if (finalResources.length > 0) {
118
- // Last page - use cumulative offset for final cursor position
119
- cursor = { id: (cumulativeOffset + finalResources.length).toString() };
116
+ cursor = { id: (previousOffset + effectiveLimit).toString() };
120
117
  logger.debug('PAGINATION DEBUG - No continuation token, setting fallback cursor:', {
121
118
  cursor,
122
- previousOffset: cumulativeOffset,
123
- currentPageSize: finalResources.length,
119
+ previousOffset,
120
+ effectiveLimit,
124
121
  });
125
122
  }
126
123
  else {
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@boostercloud/framework-provider-azure",
3
- "version": "3.4.3-debug.4",
3
+ "version": "3.4.3-debug.6",
4
4
  "description": "Handle Booster's integration with Azure",
5
5
  "keywords": [
6
6
  "framework-provider-azure"