Closed ptaberg closed 4 months ago
Just ran into this today as well
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
This works using 5.0 (not tried in latest release):
import * as hubspot from '@hubspot/api-client'
operator: hubspot.contactsModels.Filter.OperatorEnum.EQ
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
)
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.
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?
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.
Hi everyone. I've published it in the latest version(11.0.0-beta.0).
I've published it in the latest stable version(11.0.0).
Example of code:
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";