typesense / typesense-js

JavaScript / TypeScript client for Typesense
https://typesense.org/docs/api
Apache License 2.0
414 stars 75 forks source link

Extend CollectionFieldSchema type according to 0.23.1 #145

Closed CyraxRobot closed 1 year ago

CyraxRobot commented 1 year ago

Description

In current version of typesense-js (1.4.4) there are no two optional fields in definition of CollectionFieldSchema

Here is an example of interface in Collection.d.ts image

{ "infix": boolean, "locale": string, }

But in documentation (0.23.1) there are examples of usage of these fields: image

Steps to reproduce

npm i typesense@1.4.4

client.collections().create({
name: "some_collection",
fields: [
  {name: "title", type: "string", locale: "ru", "infix": false}
]
})

Expected Behavior

there should be no error when use of missing fields in .create() method

Actual Behavior

It cannot be compiled because corresponding fields are missing in 1.4.4

I suggest to extend current interface with

export interface CollectionFieldSchema {
    name: string;
    type: FieldType;
    optional?: boolean;
    facet?: boolean;
    index?: boolean;
    sort?: boolean;
    // missing fields in current version (1.4.4)
    infix?: boolean,
    locale?: string,
    // and add expression below to allow to use missing fields in case if there are new added fields on server side, that currently are not supported in typesense.js
    [t: string]: unknown
}

Metadata

Typesense Version: 0.23.1 OS: Ubuntu 22.04