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

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.
@@ -36,14 +36,31 @@ async function search(cosmosDb, config, containerName, filters, limit, afterCurs
36
36
  // - Legacy cursors: Numeric cursor.id values must use OFFSET/LIMIT for backward compatibility
37
37
  const canUseContinuationToken = !isDistinctQuery;
38
38
  const hasLegacyCursor = typeof (afterCursor === null || afterCursor === void 0 ? void 0 : afterCursor.id) === 'string' && /^\d+$/.test(afterCursor.id);
39
+ logger.debug('PAGINATION DEBUG - Initial analysis:', {
40
+ isDistinctQuery,
41
+ canUseContinuationToken,
42
+ hasLegacyCursor,
43
+ afterCursor,
44
+ limit,
45
+ finalQuery,
46
+ });
39
47
  // Use Cosmos DB's continuation token pagination
40
48
  const feedOptions = {};
41
49
  if (limit) {
42
50
  feedOptions.maxItemCount = limit;
43
51
  }
52
+ // Track cumulative offset for cursor.id calculation
53
+ let cumulativeOffset = 0;
44
54
  // Extract continuation token from the cursor (backward compatibility)
45
55
  if (afterCursor === null || afterCursor === void 0 ? void 0 : afterCursor.continuationToken) {
46
56
  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
+ logger.debug('PAGINATION DEBUG - Using provided continuation token:', {
60
+ continuationToken: afterCursor.continuationToken,
61
+ cumulativeOffset,
62
+ feedOptions,
63
+ });
47
64
  }
48
65
  else if (!canUseContinuationToken || hasLegacyCursor) {
49
66
  // Legacy cursor format - fallback to OFFSET for backward compatibility
@@ -53,8 +70,19 @@ async function search(cosmosDb, config, containerName, filters, limit, afterCurs
53
70
  legacyQuery += ` LIMIT ${limit} `;
54
71
  }
55
72
  const legacyQuerySpec = { ...querySpec, query: legacyQuery };
73
+ logger.debug('PAGINATION DEBUG - Using LEGACY OFFSET/LIMIT approach:', {
74
+ reason: !canUseContinuationToken ? 'DISTINCT query detected' : 'Legacy numeric cursor detected',
75
+ offset,
76
+ legacyQuery,
77
+ legacyQuerySpec,
78
+ });
56
79
  const { resources } = await container.items.query(legacyQuerySpec).fetchAll();
57
80
  const processedResources = processResources(resources);
81
+ logger.debug('PAGINATION DEBUG - Legacy query results:', {
82
+ resourcesCount: (resources === null || resources === void 0 ? void 0 : resources.length) || 0,
83
+ processedResourcesCount: processedResources.length,
84
+ nextCursor: { id: (offset + processedResources.length).toString() },
85
+ });
58
86
  return {
59
87
  items: processedResources !== null && processedResources !== void 0 ? processedResources : [],
60
88
  count: processedResources.length,
@@ -63,17 +91,46 @@ async function search(cosmosDb, config, containerName, filters, limit, afterCurs
63
91
  },
64
92
  };
65
93
  }
94
+ logger.debug('PAGINATION DEBUG - About to execute continuation token query with feedOptions:', feedOptions);
66
95
  const queryIterator = container.items.query(querySpec, feedOptions);
67
96
  const { resources, continuationToken } = await queryIterator.fetchNext();
97
+ logger.debug('PAGINATION DEBUG - Cosmos SDK response:', {
98
+ resourcesCount: (resources === null || resources === void 0 ? void 0 : resources.length) || 0,
99
+ continuationTokenReceived: !!continuationToken,
100
+ continuationTokenValue: continuationToken,
101
+ continuationTokenType: typeof continuationToken,
102
+ continuationTokenLength: continuationToken === null || continuationToken === void 0 ? void 0 : continuationToken.length,
103
+ });
68
104
  const finalResources = processResources(resources || []);
69
105
  let cursor;
70
106
  if (continuationToken) {
71
- cursor = { 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() };
110
+ logger.debug('PAGINATION DEBUG - Setting cursor with continuation token:', {
111
+ cursor,
112
+ previousOffset: cumulativeOffset,
113
+ currentPageSize: finalResources.length,
114
+ newCumulativeId,
115
+ });
72
116
  }
73
117
  else if (finalResources.length > 0) {
74
- const currentOffset = (afterCursor === null || afterCursor === void 0 ? void 0 : afterCursor.id) && !isNaN(parseInt(afterCursor.id)) ? parseInt(afterCursor.id) : 0;
75
- cursor = { id: (currentOffset + finalResources.length).toString() }; // Use the length of the results to calculate the next id
118
+ // Last page - use cumulative offset for final cursor position
119
+ cursor = { id: (cumulativeOffset + finalResources.length).toString() };
120
+ logger.debug('PAGINATION DEBUG - No continuation token, setting fallback cursor:', {
121
+ cursor,
122
+ previousOffset: cumulativeOffset,
123
+ currentPageSize: finalResources.length,
124
+ });
125
+ }
126
+ else {
127
+ logger.debug('PAGINATION DEBUG - No continuation token and no resources, no cursor set');
76
128
  }
129
+ logger.debug('PAGINATION DEBUG - Final response:', {
130
+ itemsCount: finalResources.length,
131
+ cursor,
132
+ hasMoreResults: !!continuationToken,
133
+ });
77
134
  return {
78
135
  items: finalResources,
79
136
  count: finalResources.length,
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@boostercloud/framework-provider-azure",
3
- "version": "3.4.2",
3
+ "version": "3.4.3-debug.4",
4
4
  "description": "Handle Booster's integration with Azure",
5
5
  "keywords": [
6
6
  "framework-provider-azure"
@@ -27,14 +27,14 @@
27
27
  "@azure/functions": "^1.2.2",
28
28
  "@azure/identity": "~4.7.0",
29
29
  "@azure/event-hubs": "5.11.1",
30
- "@boostercloud/framework-common-helpers": "^3.4.2",
31
- "@boostercloud/framework-types": "^3.4.2",
30
+ "@boostercloud/framework-common-helpers": "^3.4.3",
31
+ "@boostercloud/framework-types": "^3.4.3",
32
32
  "tslib": "^2.4.0",
33
33
  "@effect-ts/core": "^0.60.4",
34
34
  "@azure/web-pubsub": "~1.1.0"
35
35
  },
36
36
  "devDependencies": {
37
- "@boostercloud/eslint-config": "^3.4.2",
37
+ "@boostercloud/eslint-config": "^3.4.3",
38
38
  "@types/chai": "4.2.18",
39
39
  "@types/chai-as-promised": "7.1.4",
40
40
  "@types/faker": "5.1.5",
@@ -61,16 +61,27 @@
61
61
  "typescript": "5.7.3",
62
62
  "eslint-plugin-unicorn": "~44.0.2"
63
63
  },
64
- "bugs": {
65
- "url": "https://github.com/boostercloud/booster/issues"
66
- },
67
64
  "scripts": {
68
65
  "format": "prettier --write --ext '.js,.ts' **/*.ts **/*/*.ts",
69
66
  "lint:check": "eslint --ext '.js,.ts' **/*.ts",
70
67
  "lint:fix": "eslint --quiet --fix --ext '.js,.ts' **/*.ts",
71
68
  "build": "tsc -b tsconfig.json",
72
69
  "clean": "rimraf ./dist tsconfig.tsbuildinfo",
70
+ "prepack": "tsc -b tsconfig.json",
73
71
  "test:provider-azure": "npm run test",
74
72
  "test": "nyc --extension .ts mocha --forbid-only \"test/**/*.test.ts\""
73
+ },
74
+ "bugs": {
75
+ "url": "https://github.com/boostercloud/booster/issues"
76
+ },
77
+ "pnpm": {
78
+ "overrides": {
79
+ "pac-resolver@<5.0.0": ">=5.0.0",
80
+ "underscore@>=1.3.2 <1.12.1": ">=1.13.6",
81
+ "node-fetch@<2.6.7": ">=2.6.7",
82
+ "ws@>=7.0.0 <7.4.6": ">=7.4.6",
83
+ "nanoid@>=3.0.0 <3.1.31": ">=3.1.31",
84
+ "node-fetch@<2.6.1": ">=2.6.1"
85
+ }
75
86
  }
76
- }
87
+ }