typesense-js
typesense-js copied to clipboard
Property 'upsert' does not exist on type 'AnalyticsRule'.
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
Could you try replicating the issue using this example: https://github.com/typesense/typesense-js/blob/f89c74819d3434f646eaee1cb0d28882d661cf98/doc/examples/server/querySuggestions.mjs#L71-L78
here same issue
+1
@jasonbosco can confirm, it's the same using the example. TypeScript only picks up retreive()
for typesense.analytics.rules()
Could you try this again with 2.0.0-7 of typesense-js and let me know if you still see the issue?