Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We鈥檒l occasionally send you account related emails.

Already on GitHub? Sign in to your account

馃悰 Bug Report: Query.contains, Query.or, and Query.and are missing from typescript types #84

Closed
2 tasks done
alexrabin opened this issue Apr 29, 2024 · 2 comments
Closed
2 tasks done
Labels
bug Something isn't working

Comments

@alexrabin
Copy link

alexrabin commented Apr 29, 2024

馃憻 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?

@alexrabin alexrabin added the bug Something isn't working label Apr 29, 2024
@alexrabin alexrabin changed the title 馃悰 Bug Report: Query.contains is missing from typescript types 馃悰 Bug Report: Query.contains, Query.or, and Query.and are missing from typescript types Apr 30, 2024
@tripolskypetr
Copy link

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;
}

@stnguyen90
Copy link
Contributor

This should be fixed in https://www.npmjs.com/package/node-appwrite/v/12.1.0-rc.4

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Something isn't working
Projects
None yet
Development

No branches or pull requests

3 participants