typesense-js icon indicating copy to clipboard operation
typesense-js copied to clipboard

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

Open naimulemon opened this issue 9 months ago • 1 comments

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

naimulemon avatar May 09 '24 04:05 naimulemon

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

jasonbosco avatar May 14 '24 16:05 jasonbosco

here same issue

solomonmulatu avatar Jul 29 '24 12:07 solomonmulatu

+1

jbp35 avatar Aug 05 '24 15:08 jbp35

@jasonbosco can confirm, it's the same using the example. TypeScript only picks up retreive() for typesense.analytics.rules()

thedevdavid avatar Oct 06 '24 16:10 thedevdavid

Could you try this again with 2.0.0-7 of typesense-js and let me know if you still see the issue?

jasonbosco avatar Oct 08 '24 21:10 jasonbosco