typesense / typesense-js

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

Property 'upsert' does not exist on type 'AnalyticsRule'. #205

Open naimulemon opened 3 months ago

naimulemon commented 3 months ago

Description

I want to create analytics collection for 'products' collect. On your documentation there are a upsert mathod but when I tried to implement this mathod it show me type error

Property 'upsert' does not exist on type 'AnalyticsRules | AnalyticsRule'.  

Here is my code example

  import { Injectable } from  '@nestjs/common';

import { Client } from  'typesense';

@Injectable()

export  class  TypesenseService {

private  client: Client;

constructor() {

this.client  =  new  Client({

nodes: [

{

host: process.env.TYPESENSE_HOST,

port: 443,

protocol: 'https',

},

],

apiKey: process.env.TYPESENSE_API_KEY,

});

}

async  createAnalyticsCollection() {

await  this.typeSenseClient()

.collections()

.create({

name: 'product_queries',

fields: [

{ name: 'q', type: 'string' },

{ name: 'count', type: 'int32' },

],

});

const  ruleName  =  'product_queries_aggregation';

const  ruleConfiguration  = {

type: 'popular_queries',

params: {

source: {

collections: ['products'],

},

destination: {

collection: 'product_queries',

},

limit: 1000,

},

};

await  this.client.analytics.rules().upsert(ruleName, ruleConfiguration);

}

typeSenseClient(): Client {

return  this.client;

}

}

Steps to reproduce

npm i typesense

Expected Behavior

I want to use upsert to create a analytics for collection

Actual Behavior

Metadata

Typesense Version: "typesense": "^1.8.2"

OS: Windows

jasonbosco commented 3 months ago

Could you try replicating the issue using this example: https://github.com/typesense/typesense-js/blob/f89c74819d3434f646eaee1cb0d28882d661cf98/doc/examples/server/querySuggestions.mjs#L71-L78

solomonmulatu commented 3 weeks ago

here same issue

jbp35 commented 2 weeks ago

+1