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’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

FilterOperatorEnum is required, but looks like it's not exported #172

Closed
ptaberg opened this issue Mar 15, 2022 · 10 comments
Closed

FilterOperatorEnum is required, but looks like it's not exported #172

ptaberg opened this issue Mar 15, 2022 · 10 comments

Comments

@ptaberg
Copy link

ptaberg commented Mar 15, 2022

Screenshot 2022-03-15 at 12 02 07

Example of code:

const filter = { propertyName: 'enriched', operator: "EQ", value: 'true' }
const filterGroup = { filters: [filter] }

const detailFromHubspot = await hubspotClient.crm.companies.searchApi.doSearch({
      filterGroups: [filterGroup]
});

I could do such thing:

import { FilterOperatorEnum } from '@hubspot/api-client/lib/codegen/crm/companies/models/Filter';

But then I see
'FilterOperatorEnum' only refers to a type, but is being used as a value here.ts(2693)

That's because of
export declare type FilterOperatorEnum = "EQ" | "NEQ" | "LT" | "LTE" | "GT" | "GTE" | "BETWEEN" | "IN" | "NOT_IN" | "HAS_PROPERTY" | "NOT_HAS_PROPERTY" | "CONTAINS_TOKEN" | "NOT_CONTAINS_TOKEN";

@PhakornKiong
Copy link

Just ran into this today as well

@mlahp7
Copy link

mlahp7 commented Apr 11, 2022

We ran into this problem as well, but in the contacts section of the CRM class.
As suggested above, asserting the EQ (or any supported operator string) as FilterOperatorEnum is a quick workaround.

Edit:
We're on the latest version, 6.0.1-beta5

quick-assert-fix-hubspot

@ghost
Copy link

ghost commented May 8, 2022

This works using 5.0 (not tried in latest release):

import * as hubspot from '@hubspot/api-client'

operator: hubspot.contactsModels.Filter.OperatorEnum.EQ

@deiga
Copy link

deiga commented Jun 17, 2022

It seems that the Filter type was changed between 5.0 and 6.0

Current version:

/**
 * Companies
 * No description provided (generated by Openapi Generator https://github.com/openapitools/openapi-generator)
 *
 * OpenAPI spec version: v3
 * 
 *
 * NOTE: This class is auto generated by OpenAPI Generator (https://openapi-generator.tech/).
 * https://openapi-generator.tech/
 * Do not edit the class manually.
 */

import { HttpFile } from '../http/http';

export class Filter {
    'value'?: string;
    'values'?: Array<string>;
    'propertyName': string;
    /**
    * null
    */
    'operator': FilterOperatorEnum;

    static readonly discriminator: string | undefined = undefined;

    static readonly attributeTypeMap: Array<{name: string, baseName: string, type: string, format: string}> = [
        {
            "name": "value",
            "baseName": "value",
            "type": "string",
            "format": ""
        },
        {
            "name": "values",
            "baseName": "values",
            "type": "Array<string>",
            "format": ""
        },
        {
            "name": "propertyName",
            "baseName": "propertyName",
            "type": "string",
            "format": ""
        },
        {
            "name": "operator",
            "baseName": "operator",
            "type": "FilterOperatorEnum",
            "format": ""
        }    ];

    static getAttributeTypeMap() {
        return Filter.attributeTypeMap;
    }

    public constructor() {
    }
}


export type FilterOperatorEnum = "EQ" | "NEQ" | "LT" | "LTE" | "GT" | "GTE" | "BETWEEN" | "IN" | "NOT_IN" | "HAS_PROPERTY" | "NOT_HAS_PROPERTY" | "CONTAINS_TOKEN" | "NOT_CONTAINS_TOKEN" ;

and previously we had:

/**
 * Companies
 * No description provided (generated by Openapi Generator https://github.com/openapitools/openapi-generator)
 *
 * The version of the OpenAPI document: v3
 * 
 *
 * NOTE: This class is auto generated by OpenAPI Generator (https://openapi-generator.tech/).
 * https://openapi-generator.tech/
 * Do not edit the class manually.
 */

import { RequestFile } from './models';

export class Filter {
    'value'?: string;
    'propertyName': string;
    /**
    * null
    */
    'operator': Filter.OperatorEnum;

    static discriminator: string | undefined = undefined;

    static attributeTypeMap: Array<{name: string, baseName: string, type: string}> = [
        {
            "name": "value",
            "baseName": "value",
            "type": "string"
        },
        {
            "name": "propertyName",
            "baseName": "propertyName",
            "type": "string"
        },
        {
            "name": "operator",
            "baseName": "operator",
            "type": "Filter.OperatorEnum"
        }    ];

    static getAttributeTypeMap() {
        return Filter.attributeTypeMap;
    }
}

export namespace Filter {
    export enum OperatorEnum {
        Eq = <any> 'EQ',
        Neq = <any> 'NEQ',
        Lt = <any> 'LT',
        Lte = <any> 'LTE',
        Gt = <any> 'GT',
        Gte = <any> 'GTE',
        Between = <any> 'BETWEEN',
        In = <any> 'IN',
        NotIn = <any> 'NOT_IN',
        HasProperty = <any> 'HAS_PROPERTY',
        NotHasProperty = <any> 'NOT_HAS_PROPERTY',
        ContainsToken = <any> 'CONTAINS_TOKEN',
        NotContainsToken = <any> 'NOT_CONTAINS_TOKEN'
    }
}

Was the change intentional? It was a lot easier to use operators, when one could reference them (like Filter.OperatorEnum.HasProperty)

@ksvirkou-hubspot
Copy link
Collaborator

Was the change intentional? It was a lot easier to use operators, when one could reference them (like Filter.OperatorEnum.HasProperty)

Hi @deiga .
We changed code generator that is why this code was changed.

@deiga
Copy link

deiga commented Jan 25, 2023

Was the change intentional? It was a lot easier to use operators, when one could reference them (like Filter.OperatorEnum.HasProperty)

Hi @deiga . We changed code generator that is why this code was changed.

Thanks for sharing context! Are there plans to allow access to Filters easily?

@ksvirkou-hubspot
Copy link
Collaborator

ksvirkou-hubspot commented Feb 1, 2023

OpenAPITools/openapi-generator#14579
OpenAPITools/openapi-generator#14663

@ksvirkou-hubspot
Copy link
Collaborator

ksvirkou-hubspot commented Mar 21, 2023

Hi everyone.
I've created PR to OpenAPIGenerator and It has been merged already.
When OpenAPIGenerator publish new major version and I have possibility to regenerate the SDK, I'll do it.

@ksvirkou-hubspot
Copy link
Collaborator

Hi everyone.
I've published it in the latest version(11.0.0-beta.0).

@ksvirkou-hubspot
Copy link
Collaborator

I've published it in the latest stable version(11.0.0).

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

No branches or pull requests

5 participants