Skip to content

Conversation

@abnegate
Copy link
Member

@abnegate abnegate commented Sep 4, 2025

What does this PR do?

(Provide a description of what this PR does.)

Test Plan

(Write your test plan here. If you changed any code, please provide us with clear instructions on how you verified your changes work.)

Related PRs and Issues

(If this PR is related to any other PR or resolves any issue or related to any issue link all related PR and issues here.)

Have you read the Contributing Guidelines on issues?

(Write your answer here.)

Summary by CodeRabbit

  • New Features

    • Added date-range, distance and spatial query builders; added HEAD as a supported execution method.
  • Breaking Changes

    • Credit card enum member renamed to UnionPay (replaces previous name).
  • Behavior Changes

    • Document create/upsert/update no longer strip certain internal metadata keys from payloads.
  • Documentation

    • Expanded deprecation notes, clarified default execution method as POST, updated examples, and replaced credit-card doc references.
  • Chores

    • SDK version bumped to 20.0.0; README CDN snippet updated.

@coderabbitai
Copy link

coderabbitai bot commented Sep 4, 2025

Walkthrough

Version bumped to 20.0.0 (README, package.json) and client default header updated. CreditCard enum member UnionChinaPay replaced by UnionPay; ExecutionMethod enum adds HEAD. Query API expanded: QueryTypesList widened, several method signatures broadened (equal, notEqual, contains, notContains) and new predicates added (createdBetween, updatedBetween, distance*, intersects/crosses/overlaps/touches and negations). Databases methods no longer strip $sequence, $collectionId, and $databaseId from document payloads. Documentation updates to account session deprecations, avatars credit-card docs, functions JSDoc default, and example payloads in docs.

✨ Finishing Touches
  • 📝 Generate Docstrings
🧪 Generate unit tests
  • Create PR with unit tests
  • Post copyable unit tests in a comment
  • Commit unit tests in branch dev

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

Comment @coderabbitai help to get the list of available commands and usage tips.

Copy link

@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 (7)
README.md (1)

36-36: CDN bump to 20.0.0 — avoid 404s at release time

Confirm npm publish and CDN availability before merging; otherwise this snippet will break until 20.0.0 is live. Optionally use @20 to reduce churn in future docs.

src/client.ts (1)

315-321: x-sdk-version updated to 20.0.0 — keep single source of truth

LGTM. Consider centralizing the version (e.g., Rollup define or importing package.json) to avoid drift with README and package.json.

src/services/account.ts (2)

1754-1754: Clarified deprecation (since 1.6.0) — nice

Consider adding an inline link to Account.createSession in the JSDoc for faster navigation.


1910-1910: Aligned deprecation note (since 1.6.0) — consistent

Same note: link to Account.createSession for easy migration.

src/enums/execution-method.ts (1)

8-8: Added HEAD method — verify handling of empty bodies

Client.call() should safely handle HEAD (often no body/content-type). Looks OK; consider adding a small test to confirm no JSON parsing attempt on HEAD.

src/services/functions.ts (1)

80-81: Nit: list allowed values for method (incl. new HEAD).
Add “Possible values: GET, POST, PUT, PATCH, DELETE, OPTIONS, HEAD.” to the JSDoc to help discovery.

- * @param {ExecutionMethod} params.method - HTTP method of execution. Default value is POST.
+ * @param {ExecutionMethod} params.method - HTTP method of execution. Default POST. Possible values: GET, POST, PUT, PATCH, DELETE, OPTIONS, HEAD.
...
- * @param {ExecutionMethod} method - HTTP method of execution. Default value is POST.
+ * @param {ExecutionMethod} method - HTTP method of execution. Default POST. Possible values: GET, POST, PUT, PATCH, DELETE, OPTIONS, HEAD.

Also applies to: 94-95

src/query.ts (1)

314-323: Clarify JSDoc inclusivity and date format; add serialization tests

  • In src/query.ts lines 314–323 and 342–351, update both JSDoc blocks to read:
    /**
     * Filter resources where document was created between dates (inclusive).
     * Use ISO 8601 datetime strings.
     * …
     */
    
    (and likewise for “updatedBetween”).
  • Add a quick unit test (e.g. src/query.spec.ts) asserting:
    expect(Query.createdBetween(
      '2025-01-01T00:00:00Z','2025-01-31T23:59:59Z'
    )).toBe(/* expected backend string */);
    expect(Query.updatedBetween(
      '2025-01-01T00:00:00Z','2025-01-31T23:59:59Z'
    )).toBe(/* expected backend string */);
📜 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 f4f0f16 and 2a0246d.

📒 Files selected for processing (11)
  • README.md (1 hunks)
  • package.json (1 hunks)
  • src/client.ts (1 hunks)
  • src/enums/credit-card.ts (1 hunks)
  • src/enums/execution-method.ts (1 hunks)
  • src/models.ts (2 hunks)
  • src/query.ts (2 hunks)
  • src/services/account.ts (2 hunks)
  • src/services/avatars.ts (2 hunks)
  • src/services/databases.ts (0 hunks)
  • src/services/functions.ts (2 hunks)
💤 Files with no reviewable changes (1)
  • src/services/databases.ts
🧰 Additional context used
🧬 Code graph analysis (1)
src/query.ts (2)
src/client.ts (2)
  • Query (802-802)
  • QueryTypesList (805-805)
src/index.ts (2)
  • Query (8-8)
  • QueryTypesList (20-20)
🔇 Additional comments (6)
package.json (1)

5-5: Version set to 20.0.0 — double-check release hygiene

Ensure the Git tag/release notes match 20.0.0 and the PR title/description reflect this version bump (current title “Add time between queries” seems unrelated).

src/services/functions.ts (1)

80-81: Docs: default method is POST — looks good and consistent with API usage.

Also applies to: 94-95

src/enums/credit-card.ts (1)

14-15: No leftover references to UnionChinaPay detected. Safe to merge.

src/services/avatars.ts (1)

100-101: Docs synced with enum (unionpay).
Consistent with CreditCard enum change.

Also applies to: 114-115

src/models.ts (2)

229-237: Readonly metadata is a good hardening step.
Prevents accidental mutation of internal IDs/sequence.

Also applies to: 268-276


229-237: No writes detected to readonly metadata fields
A code-wide ripgrep search returned only the $sequence, $collectionId, and $databaseId declarations and no assignments or delete operations targeting those keys.

Copy link

@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: 1

🧹 Nitpick comments (3)
src/query.ts (3)

314-323: createdBetween: accept Date inputs and clarify inclusivity/format

Allow Date to reduce caller friction; normalize to ISO 8601; also good to document whether the range is inclusive on both ends (server behavior).

-  static createdBetween = (start: string, end: string): string =>
-    new Query("createdBetween", undefined, [start, end] as QueryTypesList).toString();
+  static createdBetween = (start: Date | string, end: Date | string): string => {
+    const s = start instanceof Date ? start.toISOString() : start;
+    const e = end instanceof Date ? end.toISOString() : end;
+    // Optionally enforce start <= end; uncomment if desired:
+    // if (new Date(s) > new Date(e)) throw new Error("createdBetween: start must be <= end");
+    return new Query("createdBetween", undefined, [s, e]).toString();
+  }

Would you confirm whether both bounds are inclusive so we can reflect that in JSDoc?


342-351: updatedBetween: mirror createdBetween improvements

Same Date overload and normalization. Keep parity with createdBetween.

-  static updatedBetween = (start: string, end: string): string =>
-    new Query("updatedBetween", undefined, [start, end] as QueryTypesList).toString();
+  static updatedBetween = (start: Date | string, end: Date | string): string => {
+    const s = start instanceof Date ? start.toISOString() : start;
+    const e = end instanceof Date ? end.toISOString() : end;
+    // Optionally enforce start <= end; uncomment if desired:
+    // if (new Date(s) > new Date(e)) throw new Error("updatedBetween: start must be <= end");
+    return new Query("updatedBetween", undefined, [s, e]).toString();
+  }

418-497: Geometry predicate inputs need documented shape; tighten param types

JSDoc says “given geometry” but the parameter is any[]. Please document the expected format (e.g., GeoJSON Point/Polygon, WKT, or coordinate arrays) and, if stable, reflect it in types (e.g., Coordinates = [number, number], Polygon = number[][], or a GeoJSON union). This improves DX and reduces misuse.

Minimal improvement now: clarify via JSDoc without changing runtime.

-  static intersects = (attribute: string, values: any[]): string =>
+  /** values: GeoJSON geometry or coordinate array(s) as supported by the server. */
+  static intersects = (attribute: string, values: any[]): string =>
     new Query("intersects", attribute, values).toString();

Repeat similar comment for notIntersects, crosses, notCrosses, overlaps, notOverlaps, touches, notTouches.

Also, once the recursive QueryValue types (above) are applied, you can remove all remaining as QueryTypesList casts in this block to rely on sound typing.

📜 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 2a0246d and a5678c9.

📒 Files selected for processing (1)
  • src/query.ts (3 hunks)
🧰 Additional context used
🧬 Code graph analysis (1)
src/query.ts (2)
src/client.ts (2)
  • Query (802-802)
  • QueryTypesList (805-805)
src/index.ts (2)
  • Query (8-8)
  • QueryTypesList (20-20)
🔇 Additional comments (1)
src/query.ts (1)

314-351: Verify server support and add tests for new query operators

New operators (createdBetween, updatedBetween, distanceEqual/…/distanceLessThan, intersects/…/notTouches) are defined in src/query.ts (lines 314–497) but have no coverage in docs, examples, or tests. Confirm the backend recognizes these operators and add minimal unit tests validating the serialized JSON matches backend expectations.

Copy link

@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: 3

📜 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 a5678c9 and 2b085e6.

📒 Files selected for processing (3)
  • docs/examples/account/update-prefs.md (1 hunks)
  • docs/examples/databases/create-document.md (1 hunks)
  • docs/examples/tablesdb/create-row.md (1 hunks)
🧰 Additional context used
🪛 LanguageTool
docs/examples/tablesdb/create-row.md

[grammar] ~13-~13: There might be a mistake here.
Context: ...ID>', rowId: '<ROW_ID>', data: { "username": "walter.obrien", "em...

(QB_NEW_EN)


[grammar] ~14-~14: There might be a mistake here.
Context: ...: { "username": "walter.obrien", "email": "[email protected]", ...

(QB_NEW_EN)


[grammar] ~15-~15: There might be a mistake here.
Context: ... "email": "[email protected]", "fullName": "Walter O'Brien", "a...

(QB_NEW_EN)


[grammar] ~16-~16: There might be a mistake here.
Context: ...", "fullName": "Walter O'Brien", "age": 30, "isAdmin": false ...

(QB_NEW_EN)


[grammar] ~17-~17: There might be a mistake here.
Context: ...e": "Walter O'Brien", "age": 30, "isAdmin": false }, permissions:...

(QB_NEW_EN)


[grammar] ~18-~18: There might be a mistake here.
Context: ... "age": 30, "isAdmin": false }, permissions: ["read("any")"] // o...

(QB_NEW_EN)


[grammar] ~19-~19: There might be a mistake here.
Context: ...ge": 30, "isAdmin": false }, permissions: ["read("any")"] // optional...

(QB_NEW_EN)

docs/examples/account/update-prefs.md

[grammar] ~14-~14: There might be a mistake here.
Context: ...: "UTC", "darkTheme": true } }); console.log(result);

(QB_NEW_EN)

docs/examples/databases/create-document.md

[grammar] ~13-~13: There might be a mistake here.
Context: ...documentId: '<DOCUMENT_ID>', data: { "username": "walter.obrien", "em...

(QB_NEW_EN)


[grammar] ~14-~14: There might be a mistake here.
Context: ...: { "username": "walter.obrien", "email": "[email protected]", ...

(QB_NEW_EN)


[grammar] ~15-~15: There might be a mistake here.
Context: ... "email": "[email protected]", "fullName": "Walter O'Brien", "a...

(QB_NEW_EN)


[grammar] ~16-~16: There might be a mistake here.
Context: ...", "fullName": "Walter O'Brien", "age": 30, "isAdmin": false ...

(QB_NEW_EN)


[grammar] ~17-~17: There might be a mistake here.
Context: ...e": "Walter O'Brien", "age": 30, "isAdmin": false }, permissions:...

(QB_NEW_EN)


[grammar] ~18-~18: There might be a mistake here.
Context: ... "age": 30, "isAdmin": false }, permissions: ["read("any")"] // o...

(QB_NEW_EN)


[grammar] ~19-~19: There might be a mistake here.
Context: ...ge": 30, "isAdmin": false }, permissions: ["read("any")"] // optional...

(QB_NEW_EN)

🪛 markdownlint-cli2 (0.17.2)
docs/examples/tablesdb/create-row.md

15-15: Bare URL used

(MD034, no-bare-urls)

docs/examples/databases/create-document.md

15-15: Bare URL used

(MD034, no-bare-urls)

🔇 Additional comments (2)
docs/examples/tablesdb/create-row.md (1)

13-19: Data object example looks good

Clear, realistic fields help users understand expected payloads.

docs/examples/databases/create-document.md (1)

13-19: Populated data payload example is helpful

Good improvement over an empty object; keeps the example practical.

Copy link

@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: 5

♻️ Duplicate comments (2)
src/query.ts (2)

2-2: Don’t export any[]; model recursive query values instead.

Widening QueryTypesList with any[] erodes type-safety across the public API. Prefer a recursive value model so heterogeneous tuples are typed without any. This also lets you drop unsafe casts elsewhere. (Similar to prior feedback.)

- type QueryTypesSingle = string | number | boolean;
-export type QueryTypesList = string[] | number[] | boolean[] | Query[] | any[];
-export type QueryTypes = QueryTypesSingle | QueryTypesList;
+type QueryScalar = string | number | boolean;
+export type QueryValue = QueryScalar | Query | QueryValue[]; // recursive
+export type QueryTypesList = QueryValue[];
+export type QueryTypes = QueryValue;

379-381: Bug: extra array nesting in distance* produces wrong JSON shape.

You’re sending values: [[coords, distance, meters]] instead of [coords, distance, meters]. Also drop the cast and prefer a typed number[]. (Type-safety note aligns with earlier feedback.)

- static distanceEqual = (attribute: string, values: any[], distance: number, meters: boolean = true): string =>
-   new Query("distanceEqual", attribute, [[values, distance, meters]] as QueryTypesList).toString();
+ static distanceEqual = (attribute: string, coordinates: number[], distance: number, meters: boolean = true): string =>
+   new Query("distanceEqual", attribute, [coordinates, distance, meters]).toString();

- static distanceNotEqual = (attribute: string, values: any[], distance: number, meters: boolean = true): string =>
-   new Query("distanceNotEqual", attribute, [[values, distance, meters]] as QueryTypesList).toString();
+ static distanceNotEqual = (attribute: string, coordinates: number[], distance: number, meters: boolean = true): string =>
+   new Query("distanceNotEqual", attribute, [coordinates, distance, meters]).toString();

- static distanceGreaterThan = (attribute: string, values: any[], distance: number, meters: boolean = true): string =>
-   new Query("distanceGreaterThan", attribute, [[values, distance, meters]] as QueryTypesList).toString();
+ static distanceGreaterThan = (attribute: string, coordinates: number[], distance: number, meters: boolean = true): string =>
+   new Query("distanceGreaterThan", attribute, [coordinates, distance, meters]).toString();

- static distanceLessThan = (attribute: string, values: any[], distance: number, meters: boolean = true): string =>
-   new Query("distanceLessThan", attribute, [[values, distance, meters]] as QueryTypesList).toString();
+ static distanceLessThan = (attribute: string, coordinates: number[], distance: number, meters: boolean = true): string =>
+   new Query("distanceLessThan", attribute, [coordinates, distance, meters]).toString();

Optional: replace meters: boolean with a unit literal or options bag for extensibility (e.g., unit: "m" | "km").

Also applies to: 391-393, 403-405, 415-417

🧹 Nitpick comments (3)
src/query.ts (3)

314-323: createdBetween builds the correct shape, but types/cast can be improved.

  • Accept Date too and normalize to ISO.
  • Drop the unnecessary cast.
- static createdBetween = (start: string, end: string): string =>
-   new Query("createdBetween", undefined, [start, end] as QueryTypesList).toString();
+ static createdBetween = (start: string | Date, end: string | Date): string => {
+   const s = start instanceof Date ? start.toISOString() : start;
+   const e = end instanceof Date ? end.toISOString() : end;
+   return new Query("createdBetween", undefined, [s, e]).toString();
+ }

342-351: Mirror the same improvements in updatedBetween.

- static updatedBetween = (start: string, end: string): string =>
-   new Query("updatedBetween", undefined, [start, end] as QueryTypesList).toString();
+ static updatedBetween = (start: string | Date, end: string | Date): string => {
+   const s = start instanceof Date ? start.toISOString() : start;
+   const e = end instanceof Date ? end.toISOString() : end;
+   return new Query("updatedBetween", undefined, [s, e]).toString();
+ }

314-323: Add tests to lock JSON shapes for new predicates.

Recommend golden tests asserting JSON.parse(Query.*(...)) matches the expected { method, attribute, values } for boundary cases (dates, coords, polygons). I can scaffold these.

Also applies to: 342-351, 379-381, 391-393, 403-405, 415-417, 425-427, 435-437, 445-447, 455-457, 465-467, 475-477, 485-487, 495-497

📜 Review details

Configuration used: CodeRabbit UI

Review profile: CHILL

Plan: Pro

📥 Commits

Reviewing files that changed from the base of the PR and between 2b085e6 and f6b6421.

📒 Files selected for processing (1)
  • src/query.ts (6 hunks)

Comment on lines +55 to 59
* @param {QueryTypes | any[]} value
* @returns {string}
*/
static equal = (attribute: string, value: QueryTypes): string =>
static equal = (attribute: string, value: QueryTypes | any[]): string =>
new Query("equal", attribute, value).toString();
Copy link

Choose a reason for hiding this comment

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

🛠️ Refactor suggestion

equal shouldn’t accept any[]; QueryTypes already covers arrays.

This widens the surface and hides mistakes. Keep the stricter type.

- static equal = (attribute: string, value: QueryTypes | any[]): string =>
+ static equal = (attribute: string, value: QueryTypes): string =>
📝 Committable suggestion

‼️ IMPORTANT
Carefully review the code before committing. Ensure that it accurately replaces the highlighted code, contains no missing lines, and has no issues with indentation. Thoroughly test & benchmark the code to ensure it meets the requirements.

Suggested change
* @param {QueryTypes | any[]} value
* @returns {string}
*/
static equal = (attribute: string, value: QueryTypes): string =>
static equal = (attribute: string, value: QueryTypes | any[]): string =>
new Query("equal", attribute, value).toString();
* @param {QueryTypes | any[]} value
* @returns {string}
*/
static equal = (attribute: string, value: QueryTypes): string =>
new Query("equal", attribute, value).toString();
🤖 Prompt for AI Agents
In src/query.ts around lines 55 to 59, the static equal method’s signature
widens the type by using QueryTypes | any[]; remove the union and use only
QueryTypes for the value parameter to keep the stricter type; update the method
signature to accept value: QueryTypes and ensure any related usages/overloads
conform to QueryTypes (adjust tests/call sites if they were passing plain
any[]).

Comment on lines +65 to 69
* @param {QueryTypes | any[]} value
* @returns {string}
*/
static notEqual = (attribute: string, value: QueryTypes): string =>
static notEqual = (attribute: string, value: QueryTypes | any[]): string =>
new Query("notEqual", attribute, value).toString();
Copy link

Choose a reason for hiding this comment

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

🛠️ Refactor suggestion

Same here for notEqual: avoid any[].

- static notEqual = (attribute: string, value: QueryTypes | any[]): string =>
+ static notEqual = (attribute: string, value: QueryTypes): string =>
📝 Committable suggestion

‼️ IMPORTANT
Carefully review the code before committing. Ensure that it accurately replaces the highlighted code, contains no missing lines, and has no issues with indentation. Thoroughly test & benchmark the code to ensure it meets the requirements.

Suggested change
* @param {QueryTypes | any[]} value
* @returns {string}
*/
static notEqual = (attribute: string, value: QueryTypes): string =>
static notEqual = (attribute: string, value: QueryTypes | any[]): string =>
new Query("notEqual", attribute, value).toString();
* @param {QueryTypes | any[]} value
* @returns {string}
*/
static notEqual = (attribute: string, value: QueryTypes): string =>
new Query("notEqual", attribute, value).toString();
🤖 Prompt for AI Agents
In src/query.ts around lines 65 to 69, the static notEqual method currently uses
the unsafe any[] type for the value parameter; change its type to a safer
alternative (e.g., QueryTypes[] or unknown[]) so the signature reads QueryTypes
| QueryTypes[] (or QueryTypes | unknown[]) and update any related
references/overloads to match; re-run typecheck and adjust call sites if needed
to ensure no implicit any usage remains.

Comment on lines +241 to 243
static contains = (attribute: string, value: string | any[]): string =>
new Query("contains", attribute, value).toString();

Copy link

Choose a reason for hiding this comment

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

💡 Verification agent

🧩 Analysis chain

contains should remain string-focused unless the server supports non-strings.

Switching to any[] is likely incorrect for a text containment operator. Please confirm server semantics; otherwise keep string | string[].

- static contains = (attribute: string, value: string | any[]): string =>
+ static contains = (attribute: string, value: string | string[]): string =>

🏁 Script executed:

#!/bin/bash
file=$(find . -type f -name "query.ts" | head -n1)
echo "Inspecting $file"
grep -R "class Query" -n "$file"
grep -R "static contains" -n "$file"
sed -n '230,260p' "$file"

Length of output: 1100


Change contains value type to string | string[]
Align the method signature with its JSDoc and expected server semantics.

- static contains = (attribute: string, value: string | any[]): string =>
+ static contains = (attribute: string, value: string | string[]): string =>
📝 Committable suggestion

‼️ IMPORTANT
Carefully review the code before committing. Ensure that it accurately replaces the highlighted code, contains no missing lines, and has no issues with indentation. Thoroughly test & benchmark the code to ensure it meets the requirements.

Suggested change
static contains = (attribute: string, value: string | any[]): string =>
new Query("contains", attribute, value).toString();
static contains = (attribute: string, value: string | string[]): string =>
new Query("contains", attribute, value).toString();
🤖 Prompt for AI Agents
In src/query.ts around lines 241 to 243, the static contains method currently
types its value parameter as string | any[] which conflicts with the JSDoc and
server semantics; change the type to string | string[] (and update the JSDoc if
present) so only strings or arrays of strings are accepted, run type-checks and
update any call sites that pass non-string arrays to conform to string[].

Comment on lines +248 to 252
* @param {string | any[]} value
* @returns {string}
*/
static notContains = (attribute: string, value: string | string[]): string =>
static notContains = (attribute: string, value: string | any[]): string =>
new Query("notContains", attribute, value).toString();
Copy link

Choose a reason for hiding this comment

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

💡 Verification agent

❓ Verification inconclusive

notContains: same concern as contains.

- static notContains = (attribute: string, value: string | any[]): string =>
+ static notContains = (attribute: string, value: string | string[]): string =>

narrow value to string | string[] in src/query.ts
Replace both the JSDoc and the TS signature:

- * @param {string | any[]} value
+ * @param {string | string[]} value

- static notContains = (attribute: string, value: string | any[]): string =>
+ static notContains = (attribute: string, value: string | string[]): string =>
📝 Committable suggestion

‼️ IMPORTANT
Carefully review the code before committing. Ensure that it accurately replaces the highlighted code, contains no missing lines, and has no issues with indentation. Thoroughly test & benchmark the code to ensure it meets the requirements.

Suggested change
* @param {string | any[]} value
* @returns {string}
*/
static notContains = (attribute: string, value: string | string[]): string =>
static notContains = (attribute: string, value: string | any[]): string =>
new Query("notContains", attribute, value).toString();
* @param {string | string[]} value
* @returns {string}
*/
static notContains = (attribute: string, value: string | string[]): string =>
new Query("notContains", attribute, value).toString();
🤖 Prompt for AI Agents
In src/query.ts around lines 248 to 252, the parameter type for value is too
broad (string | any[]) in both the JSDoc and the TypeScript signature; narrow it
to string | string[] by updating the JSDoc @param type and changing the static
notContains signature to accept value: string | string[] so callers get correct
typing and IDE hints.

Comment on lines +425 to +427
static intersects = (attribute: string, values: any[]): string =>
new Query("intersects", attribute, [values]).toString();

Copy link

Choose a reason for hiding this comment

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

⚠️ Potential issue

Bug: unnecessary wrapping causes nested arrays in geometry predicates.

Passing [values] turns an input array/object into an extra-nested array. Send the geometry directly; also rename param for clarity.

- static intersects = (attribute: string, values: any[]): string =>
-   new Query("intersects", attribute, [values]).toString();
+ static intersects = (attribute: string, geometry: any[]): string =>
+   new Query("intersects", attribute, geometry).toString();

- static notIntersects = (attribute: string, values: any[]): string =>
-   new Query("notIntersects", attribute, [values]).toString();
+ static notIntersects = (attribute: string, geometry: any[]): string =>
+   new Query("notIntersects", attribute, geometry).toString();

- static crosses = (attribute: string, values: any[]): string =>
-   new Query("crosses", attribute, [values]).toString();
+ static crosses = (attribute: string, geometry: any[]): string =>
+   new Query("crosses", attribute, geometry).toString();

- static notCrosses = (attribute: string, values: any[]): string =>
-   new Query("notCrosses", attribute, [values]).toString();
+ static notCrosses = (attribute: string, geometry: any[]): string =>
+   new Query("notCrosses", attribute, geometry).toString();

- static overlaps = (attribute: string, values: any[]): string =>
-   new Query("overlaps", attribute, [values]).toString();
+ static overlaps = (attribute: string, geometry: any[]): string =>
+   new Query("overlaps", attribute, geometry).toString();

- static notOverlaps = (attribute: string, values: any[]): string =>
-   new Query("notOverlaps", attribute, [values]).toString();
+ static notOverlaps = (attribute: string, geometry: any[]): string =>
+   new Query("notOverlaps", attribute, geometry).toString();

- static touches = (attribute: string, values: any[]): string =>
-   new Query("touches", attribute, [values]).toString();
+ static touches = (attribute: string, geometry: any[]): string =>
+   new Query("touches", attribute, geometry).toString();

- static notTouches = (attribute: string, values: any[]): string =>
-   new Query("notTouches", attribute, [values]).toString();
+ static notTouches = (attribute: string, geometry: any[]): string =>
+   new Query("notTouches", attribute, geometry).toString();

Optional: define a minimal GeoJSON type union and use it instead of any[].

Also applies to: 435-437, 445-447, 455-457, 465-467, 475-477, 485-487, 495-497

🤖 Prompt for AI Agents
In src/query.ts around lines 425-427 (and similarly at 435-437, 445-447,
455-457, 465-467, 475-477, 485-487, 495-497) the geometry helper functions wrap
the incoming array/object with an extra array ([values]) causing nested arrays
in geometry predicates; rename the parameter from values to geometry (or geo)
and pass it directly (no extra [ ] wrapper) to the Query constructor, and
optionally replace the any[] parameter type with a minimal GeoJSON union type
(e.g., Point|Polygon|Feature|etc.) to reflect geometry inputs.

@abnegate abnegate merged commit 8a5d716 into main Sep 8, 2025
1 check passed
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