appwrite / sdk-for-node

[READ-ONLY] Official Appwrite Node.js SDK 🟒

Home Page:https://appwrite.io

Geek Repo:Geek Repo

Github PK Tool:Github PK Tool

πŸ› Bug Report: Query.contains, Query.or, and Query.and are missing from typescript types

alexrabin opened this issue Β· comments

πŸ‘Ÿ Reproduction steps

When I try to access the contains value on the Query class like so: Query.contains('property', 123), I get the following typescript error: Property 'contains' does not exist on type 'typeof Query'.ts(2339)

When I go into the index.d.ts file for node-app write the contains function is not present:

  export class Query {
    static equal(attribute: string, value: QueryTypes): string;

    static notEqual(attribute: string, value: QueryTypes): string;

    static lessThan(attribute: string, value: QueryTypes): string;

    static lessThanEqual(attribute: string, value: QueryTypes): string;

    static greaterThan(attribute: string, value: QueryTypes): string;

    static greaterThanEqual(attribute: string, value: QueryTypes): string;

    static isNull(attribute: string): string;

    static isNotNull(attribute: string): string;

    static between<T extends string | number>(attribute: string, start: T, end: T): string;

    static startsWith(attribute: string, value: string): string;

    static endsWith(attribute: string, value: string): string;

    static select(attributes: string[]): string;

    static search(attribute: string, value: string): string;

    static orderDesc(attribute: string): string;
    
    static orderAsc(attribute: string): string;
    
    static cursorAfter(documentId: string): string;
    
    static cursorBefore(documentId: string): string;
    
    static limit(value: number): string;
    
    static offset(value: number): string;

    private static addQuery(attribute: string, method: string, value: QueryTypes): string;

    private static parseValues(value: QueryTypes): string;
  }

However, when I go to node-app write/lib/query.js the contains function is present:

class Query {
  constructor(method, attribute, values) {
    this.method = method
    this.attribute = attribute

    if (values !== undefined) {
      if (Array.isArray(values)) {
        this.values = values
      } else {
        this.values = [values]
      }
    }
  }

...

 static contains = (attribute, value) =>
    new Query("contains", attribute, value).toString()

  static or = (queries) =>
    new Query("or", undefined, queries.map((query) => JSON.parse(query))).toString()

  static and = (queries) =>
    new Query("and", undefined, queries.map((query) => JSON.parse(query))).toString();
}

πŸ‘ Expected behavior

The contains, or and and functions on the Query class should be present in the index.d.ts file

πŸ‘Ž Actual Behavior

The contains, orandand` functions on the Query class is not present in the index.d.ts file

🎲 Appwrite version

Version 0.10.x

πŸ’» Operating system

MacOS

🧱 Your Environment

No response

πŸ‘€ Have you spent some time to check if this issue has been raised before?

  • I checked and didn't find similar issue

🏒 Have you read the Code of Conduct?

As a quickfix you should try

declare class Query {
    static contains(attribute: string, value: QueryTypes): string
    static or(queries: Query[]): string;
    static and(queries: Query[]): string;
}