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

Incorrect TypeScript types for contacts.search query #458

Open
jaska120 opened this issue Jan 3, 2025 · 1 comment
Open

Incorrect TypeScript types for contacts.search query #458

jaska120 opened this issue Jan 3, 2025 · 1 comment

Comments

@jaska120
Copy link

jaska120 commented Jan 3, 2025

The following was considered valid with previous library version. Also, it works correctly with the new 6.0.0 library version, if the types are supressed, as in the example:

  const result = await intercom.contacts.search({
    query: {
      operator: MultipleFilterSearchRequest.Operator.Or,
      value: [
        {
          field: 'external_id',
          operator: SingleFilterSearchRequest.Operator.Equals,
          value: 'some_external_id',
        },
        {
          // @ts-expect-error TODO remove this once the types in the library are correct, as it works this way.
          operator: MultipleFilterSearchRequest.Operator.And,
          // @ts-expect-error TODO remove this once the types in the library are correct, as it works this way.
          value: [
            {
              field: 'role',
              operator: SingleFilterSearchRequest.Operator.Equals,
              value: 'user',
            },
            {
              field: 'email',
              operator: SingleFilterSearchRequest.Operator.Equals,
              value: `some_email`,
            },
          ],
        },
      ],
    },
  });

The types don't seem to work correctly around the MultipleFilterSearchRequest variant.

@fern-support
Copy link
Collaborator

Thanks for the issue @jaska120! It looks like this is a gap in Intercom's OpenAPI spec here. The request value is defined as either an array of single element filters or an array of multiple element filters (but they cannot be intermixed).

To be clear, the interface is currently typed as the following:

/**
 * Search using Intercoms Search APIs with more than one filter.
 */
export interface MultipleFilterSearchRequest {
    /** An operator to allow boolean inspection between multiple fields. */
    operator?: MultipleFilterSearchRequest.Operator;
    value?: MultipleFilterSearchRequest.Value;
}

export namespace MultipleFilterSearchRequest {
    /**
     * An operator to allow boolean inspection between multiple fields.
     */
    export type Operator = "AND" | "OR";
    export const Operator = {
        And: "AND",
        Or: "OR",
    } as const;
    export type Value =
        /**
         * Add mutiple filters. */
        | Intercom.MultipleFilterSearchRequest[]
        /**
         * Add a single filter field. */
        | Intercom.SingleFilterSearchRequest[];
}

For your use case to work, we will need to:

  1. Confirm with the Intercom team that your use case is actually intended by the API.
  2. Update Intercom's OpenAPI specification to include this new ability.
  3. Regenerate the SDK with the latest input.

We'll follow-up here - thanks for your patience!

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

2 participants