@boostercloud/framework-provider-azure 2.18.1 → 2.18.3

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.
@@ -197,6 +197,8 @@ function buildProjections(projections = '*') {
197
197
  if (typeof projections !== 'object') {
198
198
  return projections;
199
199
  }
200
+ // Preprocess the projections
201
+ const preprocessedProjections = preprocessProjections(projections);
200
202
  // Helper function to convert dot notation to square-bracket notation
201
203
  const toSquareBracketsNotation = (path) => {
202
204
  return path
@@ -206,7 +208,7 @@ function buildProjections(projections = '*') {
206
208
  };
207
209
  // Group fields by the root property
208
210
  const groupedFields = {};
209
- Object.values(projections).forEach((field) => {
211
+ Object.values(preprocessedProjections).forEach((field) => {
210
212
  const root = field.split('.')[0];
211
213
  if (!groupedFields[root]) {
212
214
  groupedFields[root] = [];
@@ -264,6 +266,49 @@ function buildProjections(projections = '*') {
264
266
  })
265
267
  .join(', ');
266
268
  }
269
+ /**
270
+ * Preprocesses the projections to handle nested arrays and objects.
271
+ *
272
+ * @param {ProjectionFor<unknown>} projections - The projections to preprocess.
273
+ * @returns {ProjectionFor<unknown>} - The preprocessed projections.
274
+ */
275
+ function preprocessProjections(projections) {
276
+ const processed = new Set();
277
+ Object.values(projections).forEach((field) => {
278
+ const parts = field.split('.');
279
+ const arrayIndices = parts.reduce((acc, part, index) => {
280
+ if (part.endsWith('[]'))
281
+ acc.push(index);
282
+ return acc;
283
+ }, []);
284
+ if (arrayIndices.length === 0 ||
285
+ (arrayIndices[0] === 0 && arrayIndices.length === 1) ||
286
+ (arrayIndices[0] === 1 && arrayIndices.length === 1)) {
287
+ // This block is accessed when one of the following occurs:
288
+ // - No arrays in the projection
289
+ // - Top-level array not followed by another array
290
+ // - Array nested within a top-level property, no arrays follow
291
+ processed.add(field);
292
+ }
293
+ else {
294
+ // Cases with nested arrays or arrays deeper in the structure
295
+ const processToIndex = arrayIndices[0] === 0 || arrayIndices[0] === 1 ? arrayIndices[1] : arrayIndices[0];
296
+ const processedField = parts.slice(0, processToIndex + 1).join('.');
297
+ processed.add(processedField.slice(0, -2)); // Remove the '[]' from the last part
298
+ }
299
+ });
300
+ // Convert the Set back to the original type of projections
301
+ if (Array.isArray(projections)) {
302
+ return Array.from(processed);
303
+ }
304
+ else {
305
+ return Array.from(processed).reduce((acc, field) => {
306
+ ;
307
+ acc[field] = field;
308
+ return acc;
309
+ }, {});
310
+ }
311
+ }
267
312
  /**
268
313
  * Transforms the flat properties returned by Cosmos DB into a nested structure. For example, the following object:
269
314
  *
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@boostercloud/framework-provider-azure",
3
- "version": "2.18.1",
3
+ "version": "2.18.3",
4
4
  "description": "Handle Booster's integration with Azure",
5
5
  "keywords": [
6
6
  "framework-provider-azure"
@@ -27,14 +27,15 @@
27
27
  "@azure/functions": "^1.2.2",
28
28
  "@azure/identity": "~2.1.0",
29
29
  "@azure/event-hubs": "5.11.1",
30
- "@boostercloud/framework-common-helpers": "^2.18.1",
31
- "@boostercloud/framework-types": "^2.18.1",
30
+ "@boostercloud/framework-common-helpers": "^2.18.3",
31
+ "@boostercloud/framework-types": "^2.18.3",
32
32
  "tslib": "^2.4.0",
33
33
  "@effect-ts/core": "^0.60.4",
34
- "@azure/web-pubsub": "~1.1.0"
34
+ "@azure/web-pubsub": "~1.1.0",
35
+ "@cdktf/provider-azurerm": "13.3.0"
35
36
  },
36
37
  "devDependencies": {
37
- "@boostercloud/eslint-config": "^2.18.1",
38
+ "@boostercloud/eslint-config": "^2.18.3",
38
39
  "@types/chai": "4.2.18",
39
40
  "@types/chai-as-promised": "7.1.4",
40
41
  "@types/faker": "5.1.5",