Mordsith
Mordsith
CCConvex Community
Created by Mordsith on 9/28/2024 in #support-community
Type inference issue with newly added routes
apps
api
hnotes
apps
api
hnotes
hnotes imports @api.. exisiting apis imported from api are type correctly but new functions are not typed correctly
5 replies
CCConvex Community
Created by Mordsith on 9/28/2024 in #support-community
Type inference issue with newly added routes
More info: Turbo Monorepo convex exists in another directory named api , imported with type alias @api/
5 replies
CCConvex Community
Created by Mordsith on 9/28/2024 in #support-community
Custom query with default argument
Thank you @erquhart @jamalsoueidan
5 replies
CCConvex Community
Created by Mordsith on 9/20/2024 in #support-community
Convex Auth Typescript Error with Vercel
Temporary workaround
const convexAuthData = convexAuth({
providers: [ResendOTPProvider],
});

export const auth: any = convexAuthData.auth;
export const signIn: any = convexAuthData.signIn;
export const store: any = convexAuthData.store;
export const signOut: any = convexAuthData.signOut;
const convexAuthData = convexAuth({
providers: [ResendOTPProvider],
});

export const auth: any = convexAuthData.auth;
export const signIn: any = convexAuthData.signIn;
export const store: any = convexAuthData.store;
export const signOut: any = convexAuthData.signOut;
9 replies
CCConvex Community
Created by Mordsith on 9/20/2024 in #support-community
Convex Auth Typescript Error with Vercel
More info:
"next": "15.0.0-canary.157",
"react": "19.0.0-rc-a99d8e8d-20240916",
"next": "15.0.0-canary.157",
"react": "19.0.0-rc-a99d8e8d-20240916",
9 replies
CCConvex Community
Created by Mordsith on 9/20/2024 in #support-community
Convex Auth Typescript Error with Vercel
@sshader Error still persists on vercel after upgrading to version 0.0.69
9 replies
CCConvex Community
Created by Mordsith on 9/20/2024 in #support-community
Convex Auth Typescript Error with Vercel
"@convex-dev/auth": "^0.0.67",
"convex": "^1.16.0",
"@convex-dev/auth": "^0.0.67",
"convex": "^1.16.0",
9 replies
CCConvex Community
Created by Mordsith on 9/20/2024 in #support-community
Convex Auth Typescript Error with Vercel
{
/* This TypeScript project config describes the environment that
* Convex functions run in and is used to typecheck them.
* You can modify it, but some settings required to use Convex.
*/
"compilerOptions": {
/* These settings are not required by Convex and can be modified. */
"skipLibCheck": true,
"allowJs": true,
"strict": true,
"esModuleInterop": true,
"resolveJsonModule": true,
"isolatedModules": true,
"moduleResolution": "Bundler",
"jsx": "react-jsx",
/* These compiler options are required by Convex */
"target": "ESNext",
"lib": ["ES2021", "dom"],
"forceConsistentCasingInFileNames": true,
"allowSyntheticDefaultImports": true,
"module": "ESNext",
},
"include": ["./**/*"],
"exclude": ["./src/_generated", "node_modules"]
}
{
/* This TypeScript project config describes the environment that
* Convex functions run in and is used to typecheck them.
* You can modify it, but some settings required to use Convex.
*/
"compilerOptions": {
/* These settings are not required by Convex and can be modified. */
"skipLibCheck": true,
"allowJs": true,
"strict": true,
"esModuleInterop": true,
"resolveJsonModule": true,
"isolatedModules": true,
"moduleResolution": "Bundler",
"jsx": "react-jsx",
/* These compiler options are required by Convex */
"target": "ESNext",
"lib": ["ES2021", "dom"],
"forceConsistentCasingInFileNames": true,
"allowSyntheticDefaultImports": true,
"module": "ESNext",
},
"include": ["./**/*"],
"exclude": ["./src/_generated", "node_modules"]
}
9 replies
CCConvex Community
Created by Mordsith on 8/6/2024 in #support-community
Conex Auth fatal error
That fixed it
4 replies
CCConvex Community
Created by Mordsith on 8/6/2024 in #support-community
Conex Auth fatal error
Thank you @Michal Srb
4 replies
CCConvex Community
Created by Mordsith on 7/2/2024 in #support-community
Schedulers with priority
@jamwt This is for schedulers... The flow is like this Azure Task Complete -> Trigger Convex Webhook URL -> Schedule a task to run
7 replies
CCConvex Community
Created by Mordsith on 7/2/2024 in #support-community
Schedulers with priority
@ampp No particular reason, I never considered it since it's small volume of requests at the moment. I'll add this to my setup
7 replies
CCConvex Community
Created by Mordsith on 7/6/2024 in #support-community
ConvexTest setup error
More contexts... Project is a monorepo
5 replies
CCConvex Community
Created by Mordsith on 7/6/2024 in #support-community
ConvexTest setup error
I think this may be the source of my problem
5 replies
CCConvex Community
Created by Mordsith on 7/6/2024 in #support-community
ConvexTest setup error
The convex-test package documentation is missing important information like how to use the second parameters if your functions are in nested folders.
5 replies
CCConvex Community
Created by Mordsith on 6/19/2024 in #support-community
Database seed with 70,000 items
export const processBatch = internalAction({
args: {
diagnosis: v.array(v.object(pick(diagnosisFields, ["code", "desc"])))
},
handler: async (ctx, { diagnosis }) => {
for (const { code, desc } of diagnosis) {
// Run with sceduler
try {
await ctx.runAction(internal.init.seedDiagnosis, {
code,
desc
});
} catch (err) {
console.log("Diagnosis Seed Batch Process Error", err)
}
}
}
})

export const seedDiagnosis = internalAction({
args: pick(diagnosisFields, ["code", "desc"]),
handler: async (ctx, { code, desc }) => {
try {
const diagnosisFromCode = await ctx.runQuery(
internal.routes.diagnosis.internal_queries.getDiagnosisByCode,
{
code,
},
);
// Prevent adding duplicate
if (!diagnosisFromCode) {
await ctx.runMutation(
internal.routes.diagnosis.internal_mutations.addDiagnosis,
{
code,
desc,
searchable: `${code} ${desc}`
},
);
} else if (!diagnosisFromCode.searchable) {
await ctx.runMutation(
internal.routes.diagnosis.internal_mutations.updateDiagnosis,
{
diagnosisId: diagnosisFromCode._id,
searchable: `${code} ${desc}`
},
);
}
console.log("Diagnosis Data Uploaded");
} catch (err) {
console.error("Error saving diagnosis", err);
}
},
});
export const processBatch = internalAction({
args: {
diagnosis: v.array(v.object(pick(diagnosisFields, ["code", "desc"])))
},
handler: async (ctx, { diagnosis }) => {
for (const { code, desc } of diagnosis) {
// Run with sceduler
try {
await ctx.runAction(internal.init.seedDiagnosis, {
code,
desc
});
} catch (err) {
console.log("Diagnosis Seed Batch Process Error", err)
}
}
}
})

export const seedDiagnosis = internalAction({
args: pick(diagnosisFields, ["code", "desc"]),
handler: async (ctx, { code, desc }) => {
try {
const diagnosisFromCode = await ctx.runQuery(
internal.routes.diagnosis.internal_queries.getDiagnosisByCode,
{
code,
},
);
// Prevent adding duplicate
if (!diagnosisFromCode) {
await ctx.runMutation(
internal.routes.diagnosis.internal_mutations.addDiagnosis,
{
code,
desc,
searchable: `${code} ${desc}`
},
);
} else if (!diagnosisFromCode.searchable) {
await ctx.runMutation(
internal.routes.diagnosis.internal_mutations.updateDiagnosis,
{
diagnosisId: diagnosisFromCode._id,
searchable: `${code} ${desc}`
},
);
}
console.log("Diagnosis Data Uploaded");
} catch (err) {
console.error("Error saving diagnosis", err);
}
},
});
31 replies
CCConvex Community
Created by Mordsith on 6/19/2024 in #support-community
Database seed with 70,000 items
export const seed = internalAction({
args: {},
handler: async (ctx) => {
console.log("Start Diagnosis seed...");
// Diagnosis Data is about 7-8MB, run this seed once to speed up deployment
// and to prevent seeding large amount of data all the time.
try {
const diagnosisUploaded = await ctx.runQuery(internal.routes.diagnosis.internal_queries.getDiagnosisCount)
// Check if there are are no diagnosis code present
if (diagnosisUploaded < TOTAL_DIAGNOSIS) {
// Fetch all diagnosis code and data. Total: 70,000+
const request = await fetch(DIAGNOSIS_CODES_URL);
const diagnosis: Pick<Doc<"diagnosis">, "code" | "desc">[] =
await request.json();
// Split and process as a batch (max 7), with 10,000 in a batch
for (let i = 0; i < diagnosis.length; i += CHUNK_SIZE) {
// This chunk contain max of 10,000 items
const chunk = diagnosis.slice(i, i + CHUNK_SIZE);
await ctx.scheduler.runAfter(0, internal.init.processBatch, {
diagnosis: chunk
})
}
console.log("Diagnosis Data Upload in progress");
}
} catch (err) {
console.error("Error seeding diagnosis", err);
}
console.log("Seed run complete")
},
});
export const seed = internalAction({
args: {},
handler: async (ctx) => {
console.log("Start Diagnosis seed...");
// Diagnosis Data is about 7-8MB, run this seed once to speed up deployment
// and to prevent seeding large amount of data all the time.
try {
const diagnosisUploaded = await ctx.runQuery(internal.routes.diagnosis.internal_queries.getDiagnosisCount)
// Check if there are are no diagnosis code present
if (diagnosisUploaded < TOTAL_DIAGNOSIS) {
// Fetch all diagnosis code and data. Total: 70,000+
const request = await fetch(DIAGNOSIS_CODES_URL);
const diagnosis: Pick<Doc<"diagnosis">, "code" | "desc">[] =
await request.json();
// Split and process as a batch (max 7), with 10,000 in a batch
for (let i = 0; i < diagnosis.length; i += CHUNK_SIZE) {
// This chunk contain max of 10,000 items
const chunk = diagnosis.slice(i, i + CHUNK_SIZE);
await ctx.scheduler.runAfter(0, internal.init.processBatch, {
diagnosis: chunk
})
}
console.log("Diagnosis Data Upload in progress");
}
} catch (err) {
console.error("Error seeding diagnosis", err);
}
console.log("Seed run complete")
},
});
31 replies
CCConvex Community
Created by Mordsith on 6/19/2024 in #support-community
Database seed with 70,000 items
"use node";

// Seed convex data
// https://stack.convex.dev/seeding-data-for-preview-deployments#2-importing-from-the-cli
//
// International Diagnostics Code:
// https://gist.githubusercontent.com/cryocaustik/b86de96e66489ada97c25fc25f755de0
import { internalAction } from "@/convex/_generated/server";
import { internal } from "./_generated/api";
import type { Doc } from "./_generated/dataModel";
import { diagnosisFields } from "./routes/diagnosis/schema";
import { pick } from "convex-helpers";
import { v } from "convex/values";

const DIAGNOSIS_CODES_URL =
"https://gist.githubusercontent.com/cryocaustik/b86de96e66489ada97c25fc25f755de0/raw/b31a549638a609004e9a45f8933c3f37bdf4c27d/icd10_codes.json";

const TOTAL_DIAGNOSIS = 71000
const CHUNK_SIZE = 1000
"use node";

// Seed convex data
// https://stack.convex.dev/seeding-data-for-preview-deployments#2-importing-from-the-cli
//
// International Diagnostics Code:
// https://gist.githubusercontent.com/cryocaustik/b86de96e66489ada97c25fc25f755de0
import { internalAction } from "@/convex/_generated/server";
import { internal } from "./_generated/api";
import type { Doc } from "./_generated/dataModel";
import { diagnosisFields } from "./routes/diagnosis/schema";
import { pick } from "convex-helpers";
import { v } from "convex/values";

const DIAGNOSIS_CODES_URL =
"https://gist.githubusercontent.com/cryocaustik/b86de96e66489ada97c25fc25f755de0/raw/b31a549638a609004e9a45f8933c3f37bdf4c27d/icd10_codes.json";

const TOTAL_DIAGNOSIS = 71000
const CHUNK_SIZE = 1000
31 replies
CCConvex Community
Created by Mordsith on 6/19/2024 in #support-community
Database seed with 70,000 items
@lee getDiagnosisByCode uses an index by_code The batch solution worked for me and it was way faster. Thank you very much. I batched with 1000, this creates 70 scheduled functions. Each of the function run a loop of 1000 items that adds the mutation. All 70k items are in. Are there any violations with using schedulers like this?
31 replies
CCConvex Community
Created by Mordsith on 6/19/2024 in #support-community
Database seed with 70,000 items
import { internalMutation } from "@/convex/_generated/server";
import { diagnosisFields } from "./schema";

export const addDiagnosis = internalMutation({
args: diagnosisFields,
handler: async (ctx, params) => {
const diagnosis = await ctx.db.insert("diagnosis", params);
return diagnosis;
},
});
import { internalMutation } from "@/convex/_generated/server";
import { diagnosisFields } from "./schema";

export const addDiagnosis = internalMutation({
args: diagnosisFields,
handler: async (ctx, params) => {
const diagnosis = await ctx.db.insert("diagnosis", params);
return diagnosis;
},
});
31 replies