TypeScript support?

Hello @brett19 / @mark-at-rccl ,

Are there any updates to documentation on how to use Full-Text Search with version 3.2.0-alpha.2 ?

Thanks,
Aakshaye

Hey @aakshaye ,

Can you elaborate on what you mean by that?

P.S. 3.2.0-beta.1 was released recently
you can find its api reference here:

and the release notes for it here:

Cheers, Brett

Hi @brett19 ,

Appreciate the quick response. Thanks for the update about the release and API reference.

I’m using Couchbase Server 6.0.0 and node package 3.2.0-beta.1 with Typescript

On using the new API reference as shown here: Start Using the Node.js SDK | Couchbase Docs
I get a timeout error when trying to connect using the following

const cluster = await couchbase.connect(connectionString, {
        username: login_user,
        password: login_password,
    });

I am not able to pass timeout as an option to the connect function.

Please advise.

Thanks,
Aakshaye

Hey @aakshaye ,

Have you tried enabling debug logging (DEBUG=* node index) as mentioned earlier in this thread to see why it is failing to connect in time?

Cheers, Brett

Hi @brett19 ,

Thanks for your response. I was able to fix that issue on my end.

I am trying to use Full Text Search as shown here : Search | Couchbase Docs

I get this error with Typescript: Property ‘SearchQuery’ does not exist on type ‘typeof import(“couchbase”)’
when using the following code:
import couchbase from "couchbase";

const result = await searchQuery( indexName, couchbase.SearchQuery.match(searchTerm), { limit: 5, });

Please advise.

Thanks,
Aakshaye

Hey @aakshaye,

I’ve seen that before. Try using import * as couchbase from 'couchbase' instead. I’m going to look into figuring out why that’s needed before the next release. I’d expect that they both would work.

Cheers, Brett

Hi @brett19 ,

Using import * as couchbase from 'couchbase' also gives me the same error.

Hope you can fix that soon.

Thanks,
Aakshaye

Hello everyone, hello @brett19 ,

I allow myself to answer this thread rather than opening a new one because I think it’s the same topic. I ran into some issues with my typescript project and the last version of couchbase node sdk :
For example, when I check the implementation of the method getAllBucket() : It takes two parameters, one optional and one mandatory called “bucketName”. That mean for retreiving all buckets, we need to pass a bucket name ?
buckets
I tried to use this method without any arguments and annoted it with @ts-ignore for making typescript compile and it works, I get all buckets from my Cluster, so I am a bit confused, can I have an explanation about this ?
In advance, many thanks
Thibaut

Hi @brett19 ,
I am using couchbase 3.2.0-beta.1 in my node application. Couchbase module works fine when i do not run the application in debug mode. But when i debug the node application, i always get timeout error. Please note that there is hardly any wait time between breakpoints execution.
Following is the Error log:
\node_modules\couchbase\deps\lcb\src\bootstrap.cc:199) Failed to bootstrap client=000002A29D5C8B30. Error=LCB_ERR_TIMEOUT (201) (Last=LCB_ERR_TIMEOUT (201)), Message=Failed to bootstrap in time +0ms
couchnode failed to connect to bucket: TimeoutError: timeout
couchnode at Object.translateCppError (C:\node ang update 2021\test-api\node_modules\couchbase\dist\bindingutilities.js:148:20)
couchnode at Object. (C:\node ang update 2021\test-api\node_modules\couchbase\dist\connection.js:91:45)
couchnode at Object.callbackTrampoline (internal/async_hooks.js:131:14) {
couchnode cause: LibcouchbaseError: libcouchbase error 201
couchnode at Object.translateCppError (C:\node ang update 2021\test-api\node_modules\couchbase\dist\bindingutilities.js:142:21)
couchnode at Object. (C:\node ang update 2021\test-api\node_modules\couchbase\dist\connection.js:91:45)
couchnode at Object.callbackTrampoline (internal/async_hooks.js:131:14) {
couchnode code: 201

Hi @brett19 ,
Please guide on this.

Hello @brett19 ,

I see the new version was released few days ago. However, Full Text Search still doesn’t seem to work.

Please advise.

Thanks,
Aakshaye

Any solutions to this debacle? i cant use esModuleInterop (which anyway is a HACK) since i deploy to amazon lambda (and thus require that the module will be transpiled in my output source code (js).
any help would be appreciated. i have not came across this problem with any other lib.

For everyone wanting proper TypeScript support, I’m happy to inform you that I have published Cbjs. It’s a drop-in replacement of the official client.

Cbjs adds genuine TypeScript support like path validation, path autocompletion, discriminated unions and more.

All the tests of the official library have been rewritten in TypeScript and ported to a modern test framework, Vitest.
Hundreds of tests have been added to test the new TypeScript support.

GitHub : GitHub - cbjs-dev/cbjs: TypeScript client for Couchbase, built on top of the official library.
Website : https://cbjs.dev