BuilderIO / builder

Drag and drop headless CMS for React, Vue, Svelte, Qwik, and more
https://builder.io
MIT License
6.78k stars 840 forks source link

fix: `query` option in gen2 sdks to correctly flatten the query object for mongodb #3250

Closed sidmohanty11 closed 2 weeks ago

sidmohanty11 commented 2 weeks ago

Description

This PR updates the query option to use flattenMongoQuery which is basically flatten but when we get an $key we just return the object as is as, so that it properly gets parsed in our API (mongo query).

Jira https://builder-io.atlassian.net/browse/ENG-5268

Loom https://www.loom.com/share/10493e4fd2a24b40937590f7f690bff2

Fixes #3007

changeset-bot[bot] commented 2 weeks ago

🦋 Changeset detected

Latest commit: 2837f0d174f06874cc00fbdcfd9dfdad76112e89

The changes in this PR will be included in the next version bump.

This PR includes changesets to release 7 packages | Name | Type | | ---------------------------- | ----- | | @builder.io/sdk-react-nextjs | Patch | | @builder.io/sdk-qwik | Patch | | @builder.io/sdk-react | Patch | | @builder.io/sdk-react-native | Patch | | @builder.io/sdk-solid | Patch | | @builder.io/sdk-svelte | Patch | | @builder.io/sdk-vue | Patch |

Not sure what this means? Click here to learn what changesets are.

Click here if you're a maintainer who wants to add another changeset to this PR

vercel[bot] commented 2 weeks ago

The latest updates on your projects. Learn more about Vercel for Git ↗︎

Name Status Preview Comments Updated (UTC)
nextjs-app-router-example ✅ Ready (Inspect) Visit Preview 💬 Add feedback May 1, 2024 4:35am
nextjs-pages-router-example ✅ Ready (Inspect) Visit Preview 💬 Add feedback May 1, 2024 4:35am
remix-gen2-example ✅ Ready (Inspect) Visit Preview 💬 Add feedback May 1, 2024 4:35am
svelte-vite-example ✅ Ready (Inspect) Visit Preview 💬 Add feedback May 1, 2024 4:35am
gitguardian[bot] commented 2 weeks ago

⚠️ GitGuardian has uncovered 5 secrets following the scan of your pull request.

Please consider investigating the findings and remediating the incidents. Failure to do so may lead to compromising the associated services or software components.

🔎 Detected hardcoded secrets in your pull request
| GitGuardian id | GitGuardian status | Secret | Commit | Filename | | | -------------- | ------------------ | ------------------------------ | ---------------- | --------------- | -------------------- | | [314150](https://dashboard.gitguardian.com/workspace/81635/incidents/314150) | Triggered | Generic High Entropy Secret | 7bb96a2c5432df41fe0a659bbf1036709917bc19 | packages/sdks/src/functions/get-content/__snapshots__/generate-content-url.test.ts.snap | [View secret](https://github.com/BuilderIO/builder/commit/7bb96a2c5432df41fe0a659bbf1036709917bc19#diff-128cb4b209412d5af26648083199aa3a5cbe2094c4852b20152f2b9abb4d6cbbR9) | | [314150](https://dashboard.gitguardian.com/workspace/81635/incidents/314150) | Triggered | Generic High Entropy Secret | 7bb96a2c5432df41fe0a659bbf1036709917bc19 | packages/sdks/src/functions/get-content/__snapshots__/generate-content-url.test.ts.snap | [View secret](https://github.com/BuilderIO/builder/commit/7bb96a2c5432df41fe0a659bbf1036709917bc19#diff-128cb4b209412d5af26648083199aa3a5cbe2094c4852b20152f2b9abb4d6cbbR11) | | [314150](https://dashboard.gitguardian.com/workspace/81635/incidents/314150) | Triggered | Generic High Entropy Secret | 7bb96a2c5432df41fe0a659bbf1036709917bc19 | packages/sdks/src/functions/get-content/__snapshots__/generate-content-url.test.ts.snap | [View secret](https://github.com/BuilderIO/builder/commit/7bb96a2c5432df41fe0a659bbf1036709917bc19#diff-128cb4b209412d5af26648083199aa3a5cbe2094c4852b20152f2b9abb4d6cbbR13) | | [314150](https://dashboard.gitguardian.com/workspace/81635/incidents/314150) | Triggered | Generic High Entropy Secret | 7bb96a2c5432df41fe0a659bbf1036709917bc19 | packages/sdks/src/functions/get-content/__snapshots__/generate-content-url.test.ts.snap | [View secret](https://github.com/BuilderIO/builder/commit/7bb96a2c5432df41fe0a659bbf1036709917bc19#diff-128cb4b209412d5af26648083199aa3a5cbe2094c4852b20152f2b9abb4d6cbbL11) | | [314150](https://dashboard.gitguardian.com/workspace/81635/incidents/314150) | Triggered | Generic High Entropy Secret | 7bb96a2c5432df41fe0a659bbf1036709917bc19 | packages/sdks/src/functions/get-content/__snapshots__/generate-content-url.test.ts.snap | [View secret](https://github.com/BuilderIO/builder/commit/7bb96a2c5432df41fe0a659bbf1036709917bc19#diff-128cb4b209412d5af26648083199aa3a5cbe2094c4852b20152f2b9abb4d6cbbL13) |
🛠 Guidelines to remediate hardcoded secrets
1. Understand the implications of revoking this secret by investigating where it is used in your code. 2. Replace and store your secrets safely. [Learn here](https://blog.gitguardian.com/secrets-api-management?utm_source=product&utm_medium=GitHub_checks&utm_campaign=check_run_comment) the best practices. 3. Revoke and [rotate these secrets](https://docs.gitguardian.com/secrets-detection/secrets-detection-engine/detectors/generics/generic_high_entropy_secret#revoke-the-secret?utm_source=product&utm_medium=GitHub_checks&utm_campaign=check_run_comment). 4. If possible, [rewrite git history](https://blog.gitguardian.com/rewriting-git-history-cheatsheet?utm_source=product&utm_medium=GitHub_checks&utm_campaign=check_run_comment). Rewriting git history is not a trivial act. You might completely break other contributing developers' workflow and you risk accidentally deleting legitimate data. To avoid such incidents in the future consider - following these [best practices](https://blog.gitguardian.com/secrets-api-management/?utm_source=product&utm_medium=GitHub_checks&utm_campaign=check_run_comment) for managing and storing secrets including API keys and other credentials - install [secret detection on pre-commit](https://docs.gitguardian.com/ggshield-docs/integrations/git-hooks/pre-commit?utm_source=product&utm_medium=GitHub_checks&utm_campaign=check_run_comment) to catch secret before it leaves your machine and ease remediation.

🦉 GitGuardian detects secrets in your source code to help developers and security teams secure the modern development process. You are seeing this because you or someone else with access to this repository has authorized GitGuardian to scan your pull request.

nx-cloud[bot] commented 2 weeks ago

☁️ Nx Cloud Report

CI is running/has finished running commands for commit 2837f0d174f06874cc00fbdcfd9dfdad76112e89. As they complete they will appear below. Click to see the status, the terminal output, and the build insights.

📂 See all runs for this CI Pipeline Execution


✅ Successfully ran 13 targets - [`nx test @e2e/tests`](https://cloud.nx.app/runs/NjRbkYjIL8?utm_source=pull-request&utm_medium=comment) - [`nx run-many -t build -p @e2e/svelte @e2e/sveltekit`](https://cloud.nx.app/runs/vhg6SoJV9x?utm_source=pull-request&utm_medium=comment) - [`nx run-many -t build -p @e2e/react-native`](https://cloud.nx.app/runs/zStkpaI9Xg?utm_source=pull-request&utm_medium=comment) - [`nx run-many -t build -p @e2e/next-app-dir`](https://cloud.nx.app/runs/bh7CwNUGwH?utm_source=pull-request&utm_medium=comment) - [`nx run-many -t build -p @e2e/react @e2e/next-pages-dir @e2e/next-app-dir-client`](https://cloud.nx.app/runs/5YvvtReiwS?utm_source=pull-request&utm_medium=comment) - [`nx run-many -t build -p @e2e/qwik-city`](https://cloud.nx.app/runs/MusUVNpNYw?utm_source=pull-request&utm_medium=comment) - [`nx run-many -t build -p @e2e/vue @e2e/nuxt`](https://cloud.nx.app/runs/EiwSDt4ekT?utm_source=pull-request&utm_medium=comment) - [`nx run-many -t build -p @e2e/solid @e2e/solid-start`](https://cloud.nx.app/runs/uHqk6AUGKB?utm_source=pull-request&utm_medium=comment) - [`nx run-many -t build -p @e2e/angular`](https://cloud.nx.app/runs/sf6rr5L7Uw?utm_source=pull-request&utm_medium=comment) - [`nx test @builder.io/sdks`](https://cloud.nx.app/runs/sdZrCwVnfN?utm_source=pull-request&utm_medium=comment) - [`nx typecheck @builder.io/sdks`](https://cloud.nx.app/runs/gaygljQ5CM?utm_source=pull-request&utm_medium=comment) - [`nx run-many -t build -p @e2e/gen1-react @e2e/gen1-next @e2e/gen1-remix`](https://cloud.nx.app/runs/lxEYjXKL31?utm_source=pull-request&utm_medium=comment) - [`nx build @builder.io/sdk`](https://cloud.nx.app/runs/RbCj6Vy7qj?utm_source=pull-request&utm_medium=comment)

Sent with 💌 from NxCloud.

Conceptiks commented 1 day ago

@samijaber I don't know if this is the right place for it, but after updating to the latest version of the SDK, my query (including $or will no longer work:


$or: [
                {
                    $and: [{ startDate: { $lte: Date.now() } }, { endDate: { $gte: Date.now() } }],
                },
                {
                    $and: [{ startDate: { $exists: false } }, { endDate: { $exists: false } }],
                },
            ],