-
Notifications
You must be signed in to change notification settings - Fork 224
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
[bug]: Property 'generateSecuredApiKey' does not exist on type 'Algoliasearch' #1583
Comments
Hey, on what environment is your application running? |
Well the ts error is popping up in local development. I'm using it in a nitro server route The method itself works, both in node environment and in CF workers. So its just the types that are missing. . |
Would you mind providing a minimal reproduction if possible? From a simple node env it seems like the type is present https://github.com/algolia/api-clients-automation/blob/main/playground/javascript/node/algoliasearch.ts#L32 so I assume this is a resolution problem |
Looking at nitrojs/nitro#2242 which points to https://github.com/nitrojs/nitro/blob/7e13a51fe6cf005109fd5ab60015cb1b38380be9/src/options.ts#L542-L552, it seems like |
Could you log |
log output of client.transporter.algoliaAgent.value: See reproduction: https://stackblitz.com/edit/nuxt-starter-l3ypukxx?file=modules%2Fsearch%2Findex.ts After installing the deps, line 19 of ./modules/search/index gives the typescript error Please note that stackblitz node version is 18. I'm using v22 (as per logs above). |
Pretty weird to see this UA as hovering the import shows the browser one: ![]() |
@shortcuts I also found this happening to NextJS with App Route in import { algoliasearch } from "algoliasearch/dist/node"; https://nextjs.org/docs/app/building-your-application/routing/route-handlers#convention import { algoliasearch } from "algoliasearch/dist/node";
export async function GET() {
// const algoliasearch = require('algoliasearch');
const APP_KEY = 'RANDOM_KEY';
const client = algoliasearch(APP_KEY, 'HAIYAH_WHAT_HAPPEND');
const securedAppKey = client.generateSecuredApiKey('HAIYAH_WHAT_HAPPEND', {
restrictIndices: 'demo_ecommerce',
})
return Response.json({ appKey: APP_KEY, securedAppKey });
} I do see that https://github.com/algolia/algoliasearch-client-javascript/blob/main/packages/client-search/builds/node.ts#L59 It's available on node. But upon resolving to /dist/node, it doesn't have the type helper of it. (or is it intended?) EDIT: Strange thing is, other developer say it's available? #1548 (comment) Or is there anyway around for now so using App Route or anything fetch we can get the secured generated one time API Key? EDIT 2: For now I use work around with server side rendering using PHP/Composer package, at least it work on the PHP. Hope this resolved soon or we can have different importing ways into typescript. |
Description
type definitions are missing for generateSecuredApiKey. This issue was also metioned in #1548
Client
Search
Version
5.21.0
Relevant log output
The text was updated successfully, but these errors were encountered: