Skip to content

Conversation

thephez
Copy link
Collaborator

@thephez thephez commented Sep 2, 2025

Issue being fixed or feature implemented

Fixes a bug where where clauses in getDocuments queries were being ignored. The issue was caused by a field name mismatch and incorrect field type handling in the API definitions.

What was done?

Fixed API field mapping, enabled JSON parsing, and added test coverage

How Has This Been Tested?

Ran tests locally

Breaking Changes

N/A

Checklist:

  • I have performed a self-review of my own code
  • I have commented my code, particularly in hard-to-understand areas
  • I have added or updated relevant unit/integration/functional/e2e tests
  • I have added "!" to the title and described breaking changes in the corresponding section if my code contains any
  • I have made corresponding changes to the documentation if needed

For repository code-owners and collaborators only

  • I have assigned this pull request to a milestone

Summary by CodeRabbit

  • New Features

    • getDocuments now accepts structured JSON for filtering (where) and sorting (orderBy) instead of plain text.
  • Tests

    • Added test data covering JSON where filters and JSON orderBy sorting (including sample filters and ascending sort).
  • Documentation

    • Updated docs and generated examples to reflect JSON-formatted where and orderBy; code example display improved for long lines.

thephez and others added 2 commits September 2, 2025 12:53
- Change field name from "whereClause" to "where" to match query execution expectations
- Change field type from "text" to "json" for proper JSON parsing of where and orderBy clauses
- Fixes issue where where clauses were being ignored in document queries

🤖 Generated with [Claude Code](https://claude.ai/code)

Co-Authored-By: Claude <noreply@anthropic.com>
- Add where clause to filter for dash parent domain and labels starting with "test"
- Add orderBy clause to sort results by normalizedLabel in ascending order
- Enables testing of document query filtering functionality

🤖 Generated with [Claude Code](https://claude.ai/code)

Co-Authored-By: Claude <noreply@anthropic.com>
@thephez thephez added this to the v2.1 milestone Sep 2, 2025
Copy link
Contributor

coderabbitai bot commented Sep 2, 2025

Walkthrough

Document query input schema updated: whereClause (text) renamed to where (json); orderBy type changed from text to json. Test fixture and generated docs/examples adjusted to use where and orderBy. Docs manifest timestamp updated and example CSS tweaked.

Changes

Cohort / File(s) Summary of Changes
API schema
packages/wasm-sdk/api-definitions.json
In document.queries.getDocuments.inputs: renamed whereClausewhere and changed its type from textjson; changed orderBy type from textjson.
Test fixtures
packages/wasm-sdk/test/ui-automation/fixtures/test-data.js
Added where and orderBy fields to the testnet getDocuments test data (values as JSON strings); preserved limit: 10.
Docs & generation
packages/wasm-sdk/AI_REFERENCE.md, packages/wasm-sdk/docs.html, packages/wasm-sdk/docs_manifest.json, packages/wasm-sdk/generate_docs.py
Documentation and generated artifacts updated to reflect where (json) and orderBy (json); generate_docs.py maps example input key from whereClausewhere and .example-code CSS updated (white-space: pre-wrap; overflow-x: auto). docs_manifest.json generated_at timestamp updated.

Sequence Diagram(s)

sequenceDiagram
  autonumber
  actor Tester
  participant Fixture as Test Fixture
  participant DocsGen as generate_docs.py
  participant WasmSDK as WASM SDK/API
  participant Platform as Platform API

  Tester->>Fixture: run getDocuments test
  Fixture->>WasmSDK: getDocuments({ where: JSON, orderBy: JSON, limit })
  Note over WasmSDK: Inputs now expected as JSON\n(`where`, `orderBy`)
  WasmSDK->>Platform: send query with filters & sort
  Platform-->>WasmSDK: documents response
  WasmSDK-->>Fixture: return results
  Fixture-->>Tester: assertions
Loading

Estimated code review effort

🎯 3 (Moderate) | ⏱️ ~20 minutes

Possibly related PRs

Suggested reviewers

  • QuantumExplorer
  • pauldelucia

Poem

I twitch my whiskers at JSON's song,
WhereClause renamed and order streaks long.
I hop through docs, examples align,
Filters and sorts in tidy design.
A rabbit cheers for schema fine 🥕✨

✨ Finishing Touches
  • 📝 Generate Docstrings
🧪 Generate unit tests
  • Create PR with unit tests
  • Post copyable unit tests in a comment
  • Commit unit tests in branch wasm-sdk-fix-getdocuments

Thanks for using CodeRabbit! It's free for OSS, and your support helps us grow. If you like it, consider giving us a shout-out.

❤️ Share
🪧 Tips

Chat

There are 3 ways to chat with CodeRabbit:

  • Review comments: Directly reply to a review comment made by CodeRabbit. Example:
    • I pushed a fix in commit <commit_id>, please review it.
    • Open a follow-up GitHub issue for this discussion.
  • Files and specific lines of code (under the "Files changed" tab): Tag @coderabbitai in a new review comment at the desired location with your query.
  • PR comments: Tag @coderabbitai in a new PR comment to ask questions about the PR branch. For the best results, please provide a very specific query, as very limited context is provided in this mode. Examples:
    • @coderabbitai gather interesting stats about this repository and render them as a table. Additionally, render a pie chart showing the language distribution in the codebase.
    • @coderabbitai read the files in the src/scheduler package and generate a class diagram using mermaid and a README in the markdown format.

Support

Need help? Create a ticket on our support page for assistance with any issues or questions.

CodeRabbit Commands (Invoked using PR/Issue comments)

Type @coderabbitai help to get the list of available commands.

Other keywords and placeholders

  • Add @coderabbitai ignore or @coderabbit ignore anywhere in the PR description to prevent this PR from being reviewed.
  • Add @coderabbitai summary to generate the high-level summary at a specific location in the PR description.
  • Add @coderabbitai anywhere in the PR title to generate the title automatically.

CodeRabbit Configuration File (.coderabbit.yaml)

  • You can programmatically configure CodeRabbit by adding a .coderabbit.yaml file to the root of your repository.
  • Please see the configuration documentation for more information.
  • If your editor has YAML language server enabled, you can add the path at the top of this file to enable auto-completion and validation: # yaml-language-server: $schema=https://coderabbit.ai/integrations/schema.v2.json

Status, Documentation and Community

  • Visit our Status Page to check the current availability of CodeRabbit.
  • Visit our Documentation for detailed information on how to use CodeRabbit.
  • Join our Discord Community to get help, request features, and share feedback.
  • Follow us on X/Twitter for updates and announcements.

Copy link
Contributor

@coderabbitai coderabbitai bot left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Actionable comments posted: 0

Caution

Some comments are outside the diff and can’t be posted inline due to platform limitations.

⚠️ Outside diff range comments (1)
packages/wasm-sdk/api-definitions.json (1)

1-420: Replace all remaining whereClause references with where
All stale whereClause occurrences must be updated to match the renamed where input:

  • UI tests:
    • packages/wasm-sdk/test/ui-automation/utils/parameter-injector.js (selector key)
    • packages/wasm-sdk/test/document-queries.test.mjs (test parameters)
  • UI code:
    • packages/wasm-sdk/index.html (dynamic whereClause building and runExample preview)
  • Code generators & docs:
    • packages/wasm-sdk/generate_docs.py (whereClause parameters)
    • packages/wasm-sdk/CLAUDE.md and AI_REFERENCE.md (example snippets and parameter lists)
    • packages/wasm-sdk/docs_manifest.json and packages/wasm-sdk/docs.html (API examples)
🧹 Nitpick comments (2)
packages/wasm-sdk/api-definitions.json (2)

402-407: Rename + JSON type looks right; add on-type validation and brief operator help.

Helps users enter valid JSON and clarifies supported operators.

Apply:

-              "name": "where",
-              "type": "json",
+              "name": "where",
+              "type": "json",
+              "validateOnType": true,
               "label": "Where Clause (JSON)",
               "required": false,
-              "placeholder": "[[\"normalizedParentDomainName\", \"==\", \"dash\"], [\"normalizedLabel\", \"==\", \"therea1s11mshaddy5\"]]"
+              "placeholder": "[[\"normalizedParentDomainName\", \"==\", \"dash\"], [\"normalizedLabel\", \"startsWith\", \"test\"]]",
+              "help": "Array of clauses: [[field, op, value], ...]. Ops include ==, !=, <, <=, >, >=, in, startsWith."

409-414: Switching orderBy to JSON is correct; enable on-type validation and clarify format.

Small UX polish to reduce input errors.

Apply:

               "name": "orderBy",
-              "type": "json",
+              "type": "json",
+              "validateOnType": true,
               "label": "Order By (JSON)",
               "required": false,
-              "placeholder": "[[\"$createdAt\", \"desc\"]]"
+              "placeholder": "[[\"$createdAt\", \"desc\"]]",
+              "help": "Array of [field, direction] pairs. Direction: \"asc\" or \"desc\"."
📜 Review details

Configuration used: CodeRabbit UI

Review profile: CHILL

Plan: Pro

💡 Knowledge Base configuration:

  • MCP integration is disabled by default for public repositories
  • Jira integration is disabled by default for public repositories
  • Linear integration is disabled by default for public repositories

You can enable these sources in your CodeRabbit configuration.

📥 Commits

Reviewing files that changed from the base of the PR and between 23125f8 and 8f1604b.

📒 Files selected for processing (2)
  • packages/wasm-sdk/api-definitions.json (1 hunks)
  • packages/wasm-sdk/test/ui-automation/fixtures/test-data.js (1 hunks)
🧰 Additional context used
🧠 Learnings (4)
📓 Common learnings
Learnt from: CR
PR: dashpay/platform#0
File: packages/wasm-sdk/CLAUDE.md:0-0
Timestamp: 2025-07-23T08:31:42.268Z
Learning: Applies to packages/wasm-sdk/src/**/*.rs : The WASM SDK now fully supports where and orderBy clauses for document queries; use the specified JSON array formats and supported operators.
Learnt from: CR
PR: dashpay/platform#0
File: packages/wasm-sdk/CLAUDE.md:0-0
Timestamp: 2025-07-23T08:31:42.268Z
Learning: Applies to packages/wasm-sdk/**/index.html : The WASM SDK now fully supports where and orderBy clauses for document queries; use the specified JSON array formats and supported operators.
📚 Learning: 2025-07-23T08:31:42.268Z
Learnt from: CR
PR: dashpay/platform#0
File: packages/wasm-sdk/CLAUDE.md:0-0
Timestamp: 2025-07-23T08:31:42.268Z
Learning: Applies to packages/wasm-sdk/**/index.html : The WASM SDK now fully supports where and orderBy clauses for document queries; use the specified JSON array formats and supported operators.

Applied to files:

  • packages/wasm-sdk/api-definitions.json
  • packages/wasm-sdk/test/ui-automation/fixtures/test-data.js
📚 Learning: 2025-07-23T08:31:42.268Z
Learnt from: CR
PR: dashpay/platform#0
File: packages/wasm-sdk/CLAUDE.md:0-0
Timestamp: 2025-07-23T08:31:42.268Z
Learning: Applies to packages/wasm-sdk/src/**/*.rs : The WASM SDK now fully supports where and orderBy clauses for document queries; use the specified JSON array formats and supported operators.

Applied to files:

  • packages/wasm-sdk/api-definitions.json
  • packages/wasm-sdk/test/ui-automation/fixtures/test-data.js
📚 Learning: 2025-08-14T15:03:56.681Z
Learnt from: thephez
PR: dashpay/platform#2726
File: packages/wasm-sdk/check_documentation.py:69-76
Timestamp: 2025-08-14T15:03:56.681Z
Learning: In packages/wasm-sdk/api-definitions.json, the structure is nested by categories: { "queries": { "categoryName": { "label": "...", "queries": { "actualQueryName": {...} } } } }. The check_documentation.py script correctly iterates over categories and then accesses the nested 'queries'/'transitions' objects within each category to collect the actual query/transition names.

Applied to files:

  • packages/wasm-sdk/api-definitions.json
⏰ Context from checks skipped due to timeout of 90000ms. You can increase the timeout in your CodeRabbit configuration to a maximum of 15 minutes (900000ms). (3)
  • GitHub Check: build-wasm-sdk
  • GitHub Check: Build Docker images (Dashmate helper, dashmate-helper, dashmate-helper) / Build Dashmate helper image
  • GitHub Check: Build JS packages / Build JS
🔇 Additional comments (1)
packages/wasm-sdk/test/ui-automation/fixtures/test-data.js (1)

229-231: Remove optional array refactor; keep JSON strings for where/orderBy. The UI harness treats array values via its generic array‐handling branch (not the JSON branch) and will misfill rather than inject a valid JSON clause—so continue using JSON.stringify for these fields.

Likely an incorrect or invalid review comment.

@thephez thephez marked this pull request as draft September 2, 2025 17:38
thephez and others added 2 commits September 2, 2025 13:42
…changes

- Change whereClause to where in generate_docs.py parameter mapping
- Regenerate docs with correct field names and types (text→json)
- Update AI_REFERENCE.md and docs.html to reflect API definition changes
- Fix documentation examples to use correct field name

🤖 Generated with [Claude Code](https://claude.ai/code)

Co-Authored-By: Claude <noreply@anthropic.com>
- Add white-space: pre-wrap to preserve formatting in code examples
- Add overflow-x: auto to handle long code lines with horizontal scrolling
- Ensures code examples remain readable and properly formatted

🤖 Generated with [Claude Code](https://claude.ai/code)

Co-Authored-By: Claude <noreply@anthropic.com>
@thephez thephez marked this pull request as ready for review September 2, 2025 17:45
Copy link
Contributor

@coderabbitai coderabbitai bot left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Actionable comments posted: 0

🧹 Nitpick comments (2)
packages/wasm-sdk/generate_docs.py (2)

121-129: Update stale comment and clarify local var names for dpnsSearch

The comment still mentions whereClause. Also consider renaming local vars to avoid confusion with the new API field names.

Apply this diff:

-        # get_documents expects: sdk, contractId, documentType, whereClause, orderBy, limit
+        # get_documents expects: sdk, contractId, documentType, where (json), orderBy (json), limit
-        where_clause = 'JSON.stringify([["normalizedLabel", "startsWith", "ali"], ["normalizedParentDomainName", "==", "dash"]])'
-        order_by = 'JSON.stringify([["normalizedLabel", "asc"]])'
-        limit = "10"
-        params = [dpns_contract_id, document_type, where_clause, order_by, limit]
+        where_json = 'JSON.stringify([["normalizedLabel", "startsWith", "ali"], ["normalizedParentDomainName", "==", "dash"]])'
+        order_by_json = 'JSON.stringify([["normalizedLabel", "asc"]])'
+        limit = "10"
+        params = [dpns_contract_id, document_type, where_json, order_by_json, limit]

665-666: Example code UX: prevent overflow on long unbroken tokens (optional)

If you want very long hex/ids to wrap instead of forcing horizontal scroll, add overflow-wrap.

 .example-code {
@@
-    white-space: pre-wrap;
-    overflow-x: auto;
+    white-space: pre-wrap;
+    overflow-x: auto;
+    overflow-wrap: anywhere; /* optional */
 }
📜 Review details

Configuration used: CodeRabbit UI

Review profile: CHILL

Plan: Pro

💡 Knowledge Base configuration:

  • MCP integration is disabled by default for public repositories
  • Jira integration is disabled by default for public repositories
  • Linear integration is disabled by default for public repositories

You can enable these sources in your CodeRabbit configuration.

📥 Commits

Reviewing files that changed from the base of the PR and between 8f1604b and 32253a0.

📒 Files selected for processing (4)
  • packages/wasm-sdk/AI_REFERENCE.md (1 hunks)
  • packages/wasm-sdk/docs.html (1 hunks)
  • packages/wasm-sdk/docs_manifest.json (1 hunks)
  • packages/wasm-sdk/generate_docs.py (2 hunks)
✅ Files skipped from review due to trivial changes (3)
  • packages/wasm-sdk/docs_manifest.json
  • packages/wasm-sdk/AI_REFERENCE.md
  • packages/wasm-sdk/docs.html
🧰 Additional context used
📓 Path-based instructions (2)
packages/wasm-sdk/generate_docs.py

📄 CodeRabbit inference engine (CLAUDE.md)

Keep documentation for the WASM SDK in sync by running 'python3 generate_docs.py' in 'packages/wasm-sdk'

Files:

  • packages/wasm-sdk/generate_docs.py
packages/wasm-sdk/**/generate_docs.py

📄 CodeRabbit inference engine (packages/wasm-sdk/CLAUDE.md)

When adding new queries or state transitions, run python3 generate_docs.py to regenerate documentation.

Files:

  • packages/wasm-sdk/generate_docs.py
🧠 Learnings (7)
📓 Common learnings
Learnt from: CR
PR: dashpay/platform#0
File: packages/wasm-sdk/CLAUDE.md:0-0
Timestamp: 2025-07-23T08:31:42.268Z
Learning: Applies to packages/wasm-sdk/src/**/*.rs : The WASM SDK now fully supports where and orderBy clauses for document queries; use the specified JSON array formats and supported operators.
Learnt from: CR
PR: dashpay/platform#0
File: packages/wasm-sdk/CLAUDE.md:0-0
Timestamp: 2025-07-23T08:31:42.268Z
Learning: Applies to packages/wasm-sdk/**/index.html : The WASM SDK now fully supports where and orderBy clauses for document queries; use the specified JSON array formats and supported operators.
📚 Learning: 2025-07-23T08:31:42.268Z
Learnt from: CR
PR: dashpay/platform#0
File: packages/wasm-sdk/CLAUDE.md:0-0
Timestamp: 2025-07-23T08:31:42.268Z
Learning: Applies to packages/wasm-sdk/**/generate_docs.py : When adding new queries or state transitions, run python3 generate_docs.py to regenerate documentation.

Applied to files:

  • packages/wasm-sdk/generate_docs.py
📚 Learning: 2025-07-23T08:31:42.268Z
Learnt from: CR
PR: dashpay/platform#0
File: packages/wasm-sdk/CLAUDE.md:0-0
Timestamp: 2025-07-23T08:31:42.268Z
Learning: Applies to packages/wasm-sdk/**/index.html : The WASM SDK now fully supports where and orderBy clauses for document queries; use the specified JSON array formats and supported operators.

Applied to files:

  • packages/wasm-sdk/generate_docs.py
📚 Learning: 2025-07-23T08:31:42.268Z
Learnt from: CR
PR: dashpay/platform#0
File: packages/wasm-sdk/CLAUDE.md:0-0
Timestamp: 2025-07-23T08:31:42.268Z
Learning: Applies to packages/wasm-sdk/src/**/*.rs : The WASM SDK now fully supports where and orderBy clauses for document queries; use the specified JSON array formats and supported operators.

Applied to files:

  • packages/wasm-sdk/generate_docs.py
📚 Learning: 2025-07-23T08:31:42.268Z
Learnt from: CR
PR: dashpay/platform#0
File: packages/wasm-sdk/CLAUDE.md:0-0
Timestamp: 2025-07-23T08:31:42.268Z
Learning: Applies to packages/wasm-sdk/**/index.html : When adding new queries or state transitions, update the definitions in index.html.

Applied to files:

  • packages/wasm-sdk/generate_docs.py
📚 Learning: 2025-07-23T08:31:05.082Z
Learnt from: CR
PR: dashpay/platform#0
File: CLAUDE.md:0-0
Timestamp: 2025-07-23T08:31:05.082Z
Learning: Applies to packages/wasm-sdk/generate_docs.py : Keep documentation for the WASM SDK in sync by running 'python3 generate_docs.py' in 'packages/wasm-sdk'

Applied to files:

  • packages/wasm-sdk/generate_docs.py
📚 Learning: 2025-07-28T20:00:08.502Z
Learnt from: QuantumExplorer
PR: dashpay/platform#2711
File: packages/wasm-sdk/AI_REFERENCE.md:771-783
Timestamp: 2025-07-28T20:00:08.502Z
Learning: In packages/wasm-sdk/AI_REFERENCE.md, the documentation correctly shows the actual SDK method signatures (including identityCreate and identityTopUp with their full parameter lists), which may differ from the UI inputs shown in fixed_definitions.json. The UI may collect fewer parameters from users while handling additional requirements internally.

Applied to files:

  • packages/wasm-sdk/generate_docs.py
⏰ Context from checks skipped due to timeout of 90000ms. You can increase the timeout in your CodeRabbit configuration to a maximum of 15 minutes (900000ms). (3)
  • GitHub Check: Build JS packages / Build JS
  • GitHub Check: Rust crates security audit
  • GitHub Check: build-wasm-sdk
🔇 Additional comments (2)
packages/wasm-sdk/generate_docs.py (2)

86-88: Good fix: map where/orderBy to JSON strings

Using JSON.stringify for both aligns with the updated API (json types). LGTM.


86-88: Remove stale whereClause references
All leftover whereClause usages must be updated to use where (type json) and orderBy per api-definitions.json. This affects:

  • packages/wasm-sdk/generate_docs.py (L123; example block at L1766–1779)
  • packages/wasm-sdk/test/document-queries.test.mjs (L107, L161)
  • packages/wasm-sdk/test/ui-automation/utils/parameter-injector.js (L87)
  • Documentation (CLAUDE.md at L89, AI_REFERENCE.md at L1244, index.html around L1276)
⛔ Skipped due to learnings
Learnt from: CR
PR: dashpay/platform#0
File: packages/wasm-sdk/CLAUDE.md:0-0
Timestamp: 2025-07-23T08:31:42.268Z
Learning: Applies to packages/wasm-sdk/**/index.html : The WASM SDK now fully supports where and orderBy clauses for document queries; use the specified JSON array formats and supported operators.
Learnt from: CR
PR: dashpay/platform#0
File: packages/wasm-sdk/CLAUDE.md:0-0
Timestamp: 2025-07-23T08:31:42.268Z
Learning: Applies to packages/wasm-sdk/src/**/*.rs : The WASM SDK now fully supports where and orderBy clauses for document queries; use the specified JSON array formats and supported operators.
Learnt from: CR
PR: dashpay/platform#0
File: packages/wasm-sdk/CLAUDE.md:0-0
Timestamp: 2025-07-23T08:31:42.268Z
Learning: Applies to packages/wasm-sdk/**/index.html : When adding new queries or state transitions, update the definitions in index.html.

@thephez thephez requested a review from pauldelucia September 2, 2025 19:27
@QuantumExplorer QuantumExplorer merged commit 4d48e75 into v2.1-dev Sep 3, 2025
41 of 47 checks passed
@QuantumExplorer QuantumExplorer deleted the wasm-sdk-fix-getdocuments branch September 3, 2025 16:06
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants