get-convex / convex-js Goto Github PK
View Code? Open in Web Editor NEWTypeScript/JavaScript client library for Convex
Home Page: https://docs.convex.dev
License: Apache License 2.0
TypeScript/JavaScript client library for Convex
Home Page: https://docs.convex.dev
License: Apache License 2.0
There is a minor UI bug that I encountered.
Here is the preview:
https://github.com/get-convex/convex-js/assets/51208270/77dc6e27-d955-4596-a1da-483064827cbf
Ik it's a minor issue, but do let me know, I would love to contribute.
I'm developing a project within a team wherein our React client consumes the Convex API. As of the moment, the onboarding process and development environment setup is quite cumbersome due to unintended(?) actions caused by npx convex dev
.
We have a client/convex.json
file that specifies the following information that is crucial to the functionality of the client side:
{
"functions": "./src/_convex"
}
Running npx convex dev
and going through the setup wizard deletes this file and then results in a [CONVEX Q(files:getFilesByDocumentId)] Could not find public function for 'files:getFilesByDocumentId'. Did you forget to run `npx convex dev` or `npx convex deploy`?
error.
If it's possible, npx convex dev
shouldn't delete these configuration files on directories without .env.local
's Convex files. Or perhaps, the wizard can ask questions if there is an existing configuration files or if there are files to ignore during the initialization process.
Also, an npx convex dev --verbose
flag would be nice to see explicit updates on any file changes.
When creating the app for the Web Dev Cody's hackathon, I found that returning anything from the ctx.runQuery
or ctx.runMutation
when using the Convex Actions ends with "circularly references" error.
reproduction repo: https://github.com/Willaiem/convex-ts-bug
Reproduction steps:
npm init vite@latest
and choose React + TS.npx convex dev
actions.ts
import { action, internalQuery } from "./_generated/server";
import { internal } from "./_generated/api";
export const getTasks = internalQuery({
args: {},
handler: async (ctx) => {
const tasks = await ctx.db.query('tasks').collect()
return tasks
}
})
export const invokeAction = action({
args: {},
handler: async (ctx) => {
const tasks = await ctx.runQuery(internal.actions.getTasks)
const texts = tasks.map(task => task.text)
// do something else...
return texts
}
})
The error from the Convex CLI:
PS E:\programowaniefiles\convex-ts-bug> npx convex dev
✖ TypeScript typecheck via `tsc` failed.
To ignore failing typecheck, use `--typecheck=disable`.
convex/_generated/api.d.ts:27:15 - error TS2502: 'fullApi' is referenced directly or indirectly in its own type annotation.
27 declare const fullApi: ApiFromModules<{
~~~~~~~
convex/_generated/api.d.ts:27:24 - error TS2615: Type of property 'actions' circularly references itself in mapped type '{ [Key in keyof { actions: FunctionReferencesInModule<typeof import("E:/programowaniefiles/convex-ts-bug/convex/actions")>; }]: ExpandModulesAndDirs<{ actions: FunctionReferencesInModule<typeof import("E:/programowaniefiles/convex-ts-bug/convex/actions")>; }[Key]>; }'.
27 declare const fullApi: ApiFromModules<{
~~~~~~~~~~~~~~~~
28 actions: typeof actions;
~~~~~~~~~~~~~~~~~~~~~~~~~~
29 }>;
~~
convex/_generated/api.d.ts:34:22 - error TS2502: 'internal' is referenced directly or indirectly in its own type annotation.
34 export declare const internal: FilterApi<
~~~~~~~~
convex/_generated/api.d.ts:35:10 - error TS2615: Type of property 'actions' circularly references itself in mapped type '{ actions: { getTasks: FunctionReference<"query", "internal", {}, { _id: Id<"tasks">; _creationTime: number; text: string; isCompleted: boolean; }[]>; invokeAction: FunctionReference<...> | ... 1 more ... | FunctionReference<...>; }; }'.
35 typeof fullApi,
~~~~~~~
convex/actions.ts:15:14 - error TS7022: 'invokeAction' implicitly has type 'any' because it does not have a type annotation and is referenced directly or indirectly in its own initializer.
15 export const invokeAction = action({
~~~~~~~~~~~~
convex/actions.ts:18:15 - error TS7022: 'tasks' implicitly has type 'any' because it does not have a type annotation and is referenced directly or indirectly in its own initializer.
18 const tasks = await ctx.runQuery(internal.actions.getTasks)
~~~~~
convex/actions.ts:20:15 - error TS7022: 'texts' implicitly has type 'any' because it does not have a type annotation and is referenced directly or indirectly in its own initializer.
20 const texts = tasks.map(task => task.text)
~~~~~
convex/actions.ts:20:33 - error TS7006: Parameter 'task' implicitly has an 'any' type.
20 const texts = tasks.map(task => task.text)
~~~~
Found 8 errors in 2 files.
Errors Files
4 convex/_generated/api.d.ts:27
4 convex/actions.ts:15
Hello, is there any way to prevent an empty string when we call a mutation?
In my case, I have a users table, and in the "create" mutation I accept "name" args, currently empty string is accepted.
Is there any built in method? Or do I need to reject it in handler?
Thanks in advance
Hey guys,
Currently the auth_helpers
don't work in Nextjs app router server-side rendered components because they use the useConvexAuth
hook, and they haven't declared they are to be run on the client. Could you please add the 'use client'
directive at the top of the auth_helpers
?
I'm trying to send an email (a verification code), which should only happen in the server in convex
I've have used "use node" flag at the top of the file. and imported the package, in the convex env I added the envs as needed
Below is function
`export const sendMail = async ({ name, to, subject, body }: {
to: string,
name: string,
subject: string,
body: string,
}) => {
const { SMTP_EMAIL, SMTP_PASSWORD } = process.env;
const transport = createTransport({
service: "gmail",
auth: {
user: SMTP_EMAIL,
pass: SMTP_PASSWORD
}
});
try {
const testResult = await transport.verify()
console.log("TEST: ", testResult);
} catch (error) {
console.log("Mail Error: ", error)
}
try {
const sendResult = await transport.sendMail({
from: SMTP_EMAIL,
to,
subject,
html: body,
});
console.log(sendResult);
} catch (error) {
console.log(error);
return
}
}`
but npx convex dev
fails with errors:
node_modules/.pnpm/[email protected]/node_modules/nodemailer/lib/dkim/message-parser.js:3:26:
3 │ const Transform = require('stream').Transform;
╵ ~~~~~~~~
The package "stream" wasn't found on the file system but is built
into node. Are you trying to bundle for node? You can use
"platform: 'node'" to do that, which will remove this error.
X [ERROR] Could not resolve "crypto"
node_modules/.pnpm/[email protected]/node_modules/nodemailer/lib/dkim/sign.js:5:23:
5 │ const crypto = require('crypto');
╵ ~~~~~~~~
The package "crypto" wasn't found on the file system but is built
into node. Are you trying to bundle for node? You can use
"platform: 'node'" to do that, which will remove this error.
removing the function body even with the import inplace, convex compile just fine, what am I missing or doing wrong?
NOTE: Other packages works just fine like svix
and bcrypt-ts
A declarative, efficient, and flexible JavaScript library for building user interfaces.
🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
An Open Source Machine Learning Framework for Everyone
The Web framework for perfectionists with deadlines.
A PHP framework for web artisans
Bring data to life with SVG, Canvas and HTML. 📊📈🎉
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
Some thing interesting about web. New door for the world.
A server is a program made to process requests and deliver data to clients.
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
Some thing interesting about visualization, use data art
Some thing interesting about game, make everyone happy.
We are working to build community through open source technology. NB: members must have two-factor auth.
Open source projects and samples from Microsoft.
Google ❤️ Open Source for everyone.
Alibaba Open Source for everyone
Data-Driven Documents codes.
China tencent open source team.