General fixes. Still far from good or working
This commit is contained in:
@@ -1 +1 @@
|
||||
[["1","2","3","4","5","6","7","8","9","10","11","12","13","14","15"],{"key":"16","value":"17"},{"key":"18","value":"19"},{"key":"20","value":"21"},{"key":"22","value":"23"},{"key":"24","value":"25"},{"key":"26","value":"27"},{"key":"28","value":"29"},{"key":"30","value":"31"},{"key":"32","value":"33"},{"key":"34","value":"35"},{"key":"36","value":"37"},{"key":"38","value":"39"},{"key":"40","value":"41"},{"key":"42","value":"43"},{"key":"44","value":"45"},"/home/gib/Documents/Code/monorepo/convex-monorepo/packages/backend/.gitignore",{"size":16,"mtime":1753933693000,"hash":"46"},"/home/gib/Documents/Code/monorepo/convex-monorepo/packages/backend/convex/_generated/server.d.ts",{"size":5540,"mtime":1761665487097,"hash":"47","data":"48"},"/home/gib/Documents/Code/monorepo/convex-monorepo/packages/backend/convex/auth.config.js",{"size":128,"mtime":1753933693000,"hash":"49","data":"50"},"/home/gib/Documents/Code/monorepo/convex-monorepo/packages/backend/package.json",{"size":1135,"mtime":1761665487290,"hash":"51","data":"52"},"/home/gib/Documents/Code/monorepo/convex-monorepo/packages/backend/convex/openai.ts",{"size":2036,"mtime":1761665487195,"hash":"53","data":"54"},"/home/gib/Documents/Code/monorepo/convex-monorepo/packages/backend/convex/README.md",{"size":2525,"mtime":1761665487249,"hash":"55","data":"56"},"/home/gib/Documents/Code/monorepo/convex-monorepo/packages/backend/convex/_generated/api.js",{"size":414,"mtime":1753933693000,"hash":"57","data":"58"},"/home/gib/Documents/Code/monorepo/convex-monorepo/packages/backend/convex/tsconfig.json",{"size":732,"mtime":1753933693000,"hash":"59","data":"60"},"/home/gib/Documents/Code/monorepo/convex-monorepo/packages/backend/convex/_generated/server.js",{"size":3453,"mtime":1761665487114,"hash":"61","data":"62"},"/home/gib/Documents/Code/monorepo/convex-monorepo/packages/backend/convex/notes.ts",{"size":1632,"mtime":1761665487164,"hash":"63","data":"64"},"/home/gib/Documents/Code/monorepo/convex-monorepo/packages/backend/env.ts",{"size":219,"mtime":1761665487285,"hash":"65","data":"66"},"/home/gib/Documents/Code/monorepo/convex-monorepo/packages/backend/convex/_generated/dataModel.d.ts",{"size":1726,"mtime":1761665487061,"hash":"67","data":"68"},"/home/gib/Documents/Code/monorepo/convex-monorepo/packages/backend/convex/schema.ts",{"size":267,"mtime":1753933693000,"hash":"69","data":"70"},"/home/gib/Documents/Code/monorepo/convex-monorepo/packages/backend/convex/utils.ts",{"size":635,"mtime":1753933693000,"hash":"71","data":"72"},"/home/gib/Documents/Code/monorepo/convex-monorepo/packages/backend/convex/_generated/api.d.ts",{"size":845,"mtime":1761665486984,"hash":"73","data":"74"},"175b1a771387d8b7e26145c3d04e0475","da19b68e90524b894bbf1985bcec4d72",{"hashOfOptions":"75"},"a87d36cd21882ed8968ea6138f23acd9",{"hashOfOptions":"76"},"80903421dc266560a15314b96f727e40",{"hashOfOptions":"77"},"2cf34d0dd087d9749396d5f686419f4f",{"hashOfOptions":"78"},"7beaec3443b6db9c1a6b8c1668c98992",{"hashOfOptions":"79"},"c5dea56b7ddd47516cbd4038de020e53",{"hashOfOptions":"80"},"cfa98923457caed911ec68b626ef4234",{"hashOfOptions":"81"},"4a51b371d17b0a9dcc8d3a3d16790eec",{"hashOfOptions":"82"},"99403ed881c0f3caf6c13ad183e06049",{"hashOfOptions":"83"},"d78af64438f2e86a438ce045e0910a1d",{"hashOfOptions":"84"},"1a6eccbe2f9771c5b418adc40d8532c4",{"hashOfOptions":"85"},"9b1b5b82ff06ae9856df10ae91c15946",{"hashOfOptions":"86"},"0a1b4f144561ba1da064a40a2e089f10",{"hashOfOptions":"87"},"26351eae8dc2fa74ce0e3e6f6f0d4a49",{"hashOfOptions":"88"},"2545271053","1384390439","3159514942","514606721","3861339677","511151554","2611213275","1927515469","2174687556","3247610094","3411100989","2670794290","530123092","4075214594"]
|
||||
[["1","2","3","4","5","6","7","8","9","10","11","12","13","14","15"],{"key":"16","value":"17"},{"key":"18","value":"19"},{"key":"20","value":"21"},{"key":"22","value":"23"},{"key":"24","value":"25"},{"key":"26","value":"27"},{"key":"28","value":"29"},{"key":"30","value":"31"},{"key":"32","value":"33"},{"key":"34","value":"35"},{"key":"36","value":"37"},{"key":"38","value":"39"},{"key":"40","value":"41"},{"key":"42","value":"43"},{"key":"44","value":"45"},"/home/gib/Documents/Code/convex-monorepo/packages/backend/.cache/.prettiercache",{"size":3699,"mtime":1766222924000,"hash":"46"},"/home/gib/Documents/Code/convex-monorepo/packages/backend/convex/_generated/dataModel.d.ts",{"size":1726,"mtime":1768155639236,"hash":"47","data":"48"},"/home/gib/Documents/Code/convex-monorepo/packages/backend/.gitignore",{"size":16,"mtime":1766222924000,"hash":"49"},"/home/gib/Documents/Code/convex-monorepo/packages/backend/convex/utils.ts",{"size":635,"mtime":1768155639993,"hash":"50","data":"51"},"/home/gib/Documents/Code/convex-monorepo/packages/backend/convex/tsconfig.json",{"size":732,"mtime":1766222924000,"hash":"52","data":"53"},"/home/gib/Documents/Code/convex-monorepo/packages/backend/package.json",{"size":1120,"mtime":1766223702000,"hash":"54","data":"55"},"/home/gib/Documents/Code/convex-monorepo/packages/backend/convex/_generated/server.js",{"size":3453,"mtime":1768155639358,"hash":"56","data":"57"},"/home/gib/Documents/Code/convex-monorepo/packages/backend/convex/auth.config.js",{"size":128,"mtime":1768155639410,"hash":"58","data":"59"},"/home/gib/Documents/Code/convex-monorepo/packages/backend/convex/notes.ts",{"size":1632,"mtime":1768155639618,"hash":"60","data":"61"},"/home/gib/Documents/Code/convex-monorepo/packages/backend/convex/_generated/server.d.ts",{"size":5540,"mtime":1768155639312,"hash":"62","data":"63"},"/home/gib/Documents/Code/convex-monorepo/packages/backend/convex/_generated/api.d.ts",{"size":845,"mtime":1768155639122,"hash":"64","data":"65"},"/home/gib/Documents/Code/convex-monorepo/packages/backend/convex/_generated/api.js",{"size":414,"mtime":1768155639185,"hash":"66","data":"67"},"/home/gib/Documents/Code/convex-monorepo/packages/backend/convex/README.md",{"size":2525,"mtime":1768155639908,"hash":"68","data":"69"},"/home/gib/Documents/Code/convex-monorepo/packages/backend/convex/openai.ts",{"size":2036,"mtime":1768155639718,"hash":"70","data":"71"},"/home/gib/Documents/Code/convex-monorepo/packages/backend/convex/schema.ts",{"size":267,"mtime":1768155639933,"hash":"72","data":"73"},"bf09c6d61dd6a010bca24cb05271176d","ce3275ccdd28673d7e9280b33792057c",{"hashOfOptions":"74"},"175b1a771387d8b7e26145c3d04e0475","6a3198db454396c63e99ee08065726bd",{"hashOfOptions":"75"},"cfa98923457caed911ec68b626ef4234",{"hashOfOptions":"76"},"355d413e63d71e7e2107534f0d82fa31",{"hashOfOptions":"77"},"a8efc7f01f2b2dcb19115187a6f5f935",{"hashOfOptions":"78"},"449225bb5e883c1319e2ade335cdf0ad",{"hashOfOptions":"79"},"4b3c533672165e2af8d66b7149f85e1b",{"hashOfOptions":"80"},"896efcfb7466854312acff830348fec5",{"hashOfOptions":"81"},"8effb22a4ee737ecaeb923db430289f9",{"hashOfOptions":"82"},"0f5f819cfc410629d8ba1209956a037c",{"hashOfOptions":"83"},"f5aa8269478f140adb4ccf0470dd1244",{"hashOfOptions":"84"},"e06978cd8943c0adfa4d2a855c8f3627",{"hashOfOptions":"85"},"0d3d6e28d2429a34e666323218320d74",{"hashOfOptions":"86"},"1690245769","3139400620","2702670119","1723032970","1018051749","1593187711","1215337372","3786452325","2623319630","3362284046","3941219177","30277581","3515117182"]
|
||||
@@ -7,9 +7,9 @@ A query function that takes two arguments looks like:
|
||||
|
||||
```ts
|
||||
// functions.js
|
||||
import { v } from "convex/values";
|
||||
import { v } from 'convex/values';
|
||||
|
||||
import { query } from "./_generated/server";
|
||||
import { query } from './_generated/server';
|
||||
|
||||
export const myQueryFunction = query({
|
||||
// Validators for arguments.
|
||||
@@ -22,7 +22,7 @@ export const myQueryFunction = query({
|
||||
handler: async (ctx, args) => {
|
||||
// Read the database as many times as you need here.
|
||||
// See https://docs.convex.dev/database/reading-data.
|
||||
const documents = await ctx.db.query("tablename").collect();
|
||||
const documents = await ctx.db.query('tablename').collect();
|
||||
|
||||
// Arguments passed from the client are properties of the args object.
|
||||
console.log(args.first, args.second);
|
||||
@@ -39,7 +39,7 @@ Using this query function in a React component looks like:
|
||||
```ts
|
||||
const data = useQuery(api.functions.myQueryFunction, {
|
||||
first: 10,
|
||||
second: "hello",
|
||||
second: 'hello',
|
||||
});
|
||||
```
|
||||
|
||||
@@ -47,9 +47,9 @@ A mutation function looks like:
|
||||
|
||||
```ts
|
||||
// functions.js
|
||||
import { v } from "convex/values";
|
||||
import { v } from 'convex/values';
|
||||
|
||||
import { mutation } from "./_generated/server";
|
||||
import { mutation } from './_generated/server';
|
||||
|
||||
export const myMutationFunction = mutation({
|
||||
// Validators for arguments.
|
||||
@@ -64,7 +64,7 @@ export const myMutationFunction = mutation({
|
||||
// Mutations can also read from the database like queries.
|
||||
// See https://docs.convex.dev/database/writing-data.
|
||||
const message = { body: args.first, author: args.second };
|
||||
const id = await ctx.db.insert("messages", message);
|
||||
const id = await ctx.db.insert('messages', message);
|
||||
|
||||
// Optionally, return a value from your mutation.
|
||||
return await ctx.db.get(id);
|
||||
@@ -78,10 +78,10 @@ Using this mutation function in a React component looks like:
|
||||
const mutation = useMutation(api.functions.myMutationFunction);
|
||||
function handleButtonPress() {
|
||||
// fire and forget, the most common way to use mutations
|
||||
mutation({ first: "Hello!", second: "me" });
|
||||
mutation({ first: 'Hello!', second: 'me' });
|
||||
// OR
|
||||
// use the result once the mutation has completed
|
||||
mutation({ first: "Hello!", second: "me" }).then((result) =>
|
||||
mutation({ first: 'Hello!', second: 'me' }).then((result) =>
|
||||
console.log(result),
|
||||
);
|
||||
}
|
||||
|
||||
12
packages/backend/convex/_generated/api.d.ts
vendored
12
packages/backend/convex/_generated/api.d.ts
vendored
@@ -12,11 +12,11 @@ import type {
|
||||
ApiFromModules,
|
||||
FilterApi,
|
||||
FunctionReference,
|
||||
} from "convex/server";
|
||||
} from 'convex/server';
|
||||
|
||||
import type * as notes from "../notes.js";
|
||||
import type * as openai from "../openai.js";
|
||||
import type * as utils from "../utils.js";
|
||||
import type * as notes from '../notes.js';
|
||||
import type * as openai from '../openai.js';
|
||||
import type * as utils from '../utils.js';
|
||||
|
||||
/**
|
||||
* A utility for referencing Convex functions in your app's API.
|
||||
@@ -33,9 +33,9 @@ declare const fullApi: ApiFromModules<{
|
||||
}>;
|
||||
export declare const api: FilterApi<
|
||||
typeof fullApi,
|
||||
FunctionReference<any, "public">
|
||||
FunctionReference<any, 'public'>
|
||||
>;
|
||||
export declare const internal: FilterApi<
|
||||
typeof fullApi,
|
||||
FunctionReference<any, "internal">
|
||||
FunctionReference<any, 'internal'>
|
||||
>;
|
||||
|
||||
@@ -8,7 +8,7 @@
|
||||
* @module
|
||||
*/
|
||||
|
||||
import { anyApi } from "convex/server";
|
||||
import { anyApi } from 'convex/server';
|
||||
|
||||
/**
|
||||
* A utility for referencing Convex functions in your app's API.
|
||||
|
||||
@@ -13,10 +13,10 @@ import type {
|
||||
DocumentByName,
|
||||
SystemTableNames,
|
||||
TableNamesInDataModel,
|
||||
} from "convex/server";
|
||||
import type { GenericId } from "convex/values";
|
||||
} from 'convex/server';
|
||||
import type { GenericId } from 'convex/values';
|
||||
|
||||
import schema from "../schema.js";
|
||||
import schema from '../schema.js';
|
||||
|
||||
/**
|
||||
* The names of all of your Convex tables.
|
||||
|
||||
16
packages/backend/convex/_generated/server.d.ts
vendored
16
packages/backend/convex/_generated/server.d.ts
vendored
@@ -18,9 +18,9 @@ import {
|
||||
HttpActionBuilder,
|
||||
MutationBuilder,
|
||||
QueryBuilder,
|
||||
} from "convex/server";
|
||||
} from 'convex/server';
|
||||
|
||||
import type { DataModel } from "./dataModel.js";
|
||||
import type { DataModel } from './dataModel.js';
|
||||
|
||||
/**
|
||||
* Define a query in this Convex app's public API.
|
||||
@@ -30,7 +30,7 @@ import type { DataModel } from "./dataModel.js";
|
||||
* @param func - The query function. It receives a {@link QueryCtx} as its first argument.
|
||||
* @returns The wrapped query. Include this as an `export` to name it and make it accessible.
|
||||
*/
|
||||
export declare const query: QueryBuilder<DataModel, "public">;
|
||||
export declare const query: QueryBuilder<DataModel, 'public'>;
|
||||
|
||||
/**
|
||||
* Define a query that is only accessible from other Convex functions (but not from the client).
|
||||
@@ -40,7 +40,7 @@ export declare const query: QueryBuilder<DataModel, "public">;
|
||||
* @param func - The query function. It receives a {@link QueryCtx} as its first argument.
|
||||
* @returns The wrapped query. Include this as an `export` to name it and make it accessible.
|
||||
*/
|
||||
export declare const internalQuery: QueryBuilder<DataModel, "internal">;
|
||||
export declare const internalQuery: QueryBuilder<DataModel, 'internal'>;
|
||||
|
||||
/**
|
||||
* Define a mutation in this Convex app's public API.
|
||||
@@ -50,7 +50,7 @@ export declare const internalQuery: QueryBuilder<DataModel, "internal">;
|
||||
* @param func - The mutation function. It receives a {@link MutationCtx} as its first argument.
|
||||
* @returns The wrapped mutation. Include this as an `export` to name it and make it accessible.
|
||||
*/
|
||||
export declare const mutation: MutationBuilder<DataModel, "public">;
|
||||
export declare const mutation: MutationBuilder<DataModel, 'public'>;
|
||||
|
||||
/**
|
||||
* Define a mutation that is only accessible from other Convex functions (but not from the client).
|
||||
@@ -60,7 +60,7 @@ export declare const mutation: MutationBuilder<DataModel, "public">;
|
||||
* @param func - The mutation function. It receives a {@link MutationCtx} as its first argument.
|
||||
* @returns The wrapped mutation. Include this as an `export` to name it and make it accessible.
|
||||
*/
|
||||
export declare const internalMutation: MutationBuilder<DataModel, "internal">;
|
||||
export declare const internalMutation: MutationBuilder<DataModel, 'internal'>;
|
||||
|
||||
/**
|
||||
* Define an action in this Convex app's public API.
|
||||
@@ -73,7 +73,7 @@ export declare const internalMutation: MutationBuilder<DataModel, "internal">;
|
||||
* @param func - The action. It receives an {@link ActionCtx} as its first argument.
|
||||
* @returns The wrapped action. Include this as an `export` to name it and make it accessible.
|
||||
*/
|
||||
export declare const action: ActionBuilder<DataModel, "public">;
|
||||
export declare const action: ActionBuilder<DataModel, 'public'>;
|
||||
|
||||
/**
|
||||
* Define an action that is only accessible from other Convex functions (but not from the client).
|
||||
@@ -81,7 +81,7 @@ export declare const action: ActionBuilder<DataModel, "public">;
|
||||
* @param func - The function. It receives an {@link ActionCtx} as its first argument.
|
||||
* @returns The wrapped function. Include this as an `export` to name it and make it accessible.
|
||||
*/
|
||||
export declare const internalAction: ActionBuilder<DataModel, "internal">;
|
||||
export declare const internalAction: ActionBuilder<DataModel, 'internal'>;
|
||||
|
||||
/**
|
||||
* Define an HTTP action.
|
||||
|
||||
@@ -16,7 +16,7 @@ import {
|
||||
internalQueryGeneric,
|
||||
mutationGeneric,
|
||||
queryGeneric,
|
||||
} from "convex/server";
|
||||
} from 'convex/server';
|
||||
|
||||
/**
|
||||
* Define a query in this Convex app's public API.
|
||||
|
||||
@@ -2,7 +2,7 @@ export default {
|
||||
providers: [
|
||||
{
|
||||
domain: process.env.CLERK_ISSUER_URL,
|
||||
applicationID: "convex",
|
||||
applicationID: 'convex',
|
||||
},
|
||||
],
|
||||
};
|
||||
|
||||
@@ -1,8 +1,8 @@
|
||||
import { Auth } from "convex/server";
|
||||
import { v } from "convex/values";
|
||||
import { Auth } from 'convex/server';
|
||||
import { v } from 'convex/values';
|
||||
|
||||
import { internal } from "../convex/_generated/api";
|
||||
import { mutation, query } from "./_generated/server";
|
||||
import { internal } from '../convex/_generated/api';
|
||||
import { mutation, query } from './_generated/server';
|
||||
|
||||
export const getUserId = async (ctx: { auth: Auth }) => {
|
||||
return (await ctx.auth.getUserIdentity())?.subject;
|
||||
@@ -16,8 +16,8 @@ export const getNotes = query({
|
||||
if (!userId) return null;
|
||||
|
||||
const notes = await ctx.db
|
||||
.query("notes")
|
||||
.filter((q) => q.eq(q.field("userId"), userId))
|
||||
.query('notes')
|
||||
.filter((q) => q.eq(q.field('userId'), userId))
|
||||
.collect();
|
||||
|
||||
return notes;
|
||||
@@ -27,7 +27,7 @@ export const getNotes = query({
|
||||
// Get note for a specific note
|
||||
export const getNote = query({
|
||||
args: {
|
||||
id: v.optional(v.id("notes")),
|
||||
id: v.optional(v.id('notes')),
|
||||
},
|
||||
handler: async (ctx, args) => {
|
||||
const { id } = args;
|
||||
@@ -46,8 +46,8 @@ export const createNote = mutation({
|
||||
},
|
||||
handler: async (ctx, { title, content, isSummary }) => {
|
||||
const userId = await getUserId(ctx);
|
||||
if (!userId) throw new Error("User not found");
|
||||
const noteId = await ctx.db.insert("notes", { userId, title, content });
|
||||
if (!userId) throw new Error('User not found');
|
||||
const noteId = await ctx.db.insert('notes', { userId, title, content });
|
||||
|
||||
if (isSummary) {
|
||||
await ctx.scheduler.runAfter(0, internal.openai.summary, {
|
||||
@@ -63,7 +63,7 @@ export const createNote = mutation({
|
||||
|
||||
export const deleteNote = mutation({
|
||||
args: {
|
||||
noteId: v.id("notes"),
|
||||
noteId: v.id('notes'),
|
||||
},
|
||||
handler: async (ctx, args) => {
|
||||
await ctx.db.delete(args.noteId);
|
||||
|
||||
@@ -1,9 +1,9 @@
|
||||
import { v } from "convex/values";
|
||||
import OpenAI from "openai";
|
||||
import { v } from 'convex/values';
|
||||
import OpenAI from 'openai';
|
||||
|
||||
import { internal } from "./_generated/api";
|
||||
import { internalAction, internalMutation, query } from "./_generated/server";
|
||||
import { missingEnvVariableUrl } from "./utils";
|
||||
import { internal } from './_generated/api';
|
||||
import { internalAction, internalMutation, query } from './_generated/server';
|
||||
import { missingEnvVariableUrl } from './utils';
|
||||
|
||||
export const openaiKeySet = query({
|
||||
args: {},
|
||||
@@ -14,7 +14,7 @@ export const openaiKeySet = query({
|
||||
|
||||
export const summary = internalAction({
|
||||
args: {
|
||||
id: v.id("notes"),
|
||||
id: v.id('notes'),
|
||||
title: v.string(),
|
||||
content: v.string(),
|
||||
},
|
||||
@@ -24,8 +24,8 @@ export const summary = internalAction({
|
||||
const apiKey = process.env.OPENAI_API_KEY;
|
||||
if (!apiKey) {
|
||||
const error = missingEnvVariableUrl(
|
||||
"OPENAI_API_KEY",
|
||||
"https://platform.openai.com/account/api-keys",
|
||||
'OPENAI_API_KEY',
|
||||
'https://platform.openai.com/account/api-keys',
|
||||
);
|
||||
console.error(error);
|
||||
await ctx.runMutation(internal.openai.saveSummary, {
|
||||
@@ -38,14 +38,14 @@ export const summary = internalAction({
|
||||
const output = await openai.chat.completions.create({
|
||||
messages: [
|
||||
{
|
||||
role: "system",
|
||||
role: 'system',
|
||||
content:
|
||||
"You are a helpful assistant designed to output JSON in this format: {summary: string}",
|
||||
'You are a helpful assistant designed to output JSON in this format: {summary: string}',
|
||||
},
|
||||
{ role: "user", content: prompt },
|
||||
{ role: 'user', content: prompt },
|
||||
],
|
||||
model: "gpt-4-1106-preview",
|
||||
response_format: { type: "json_object" },
|
||||
model: 'gpt-4-1106-preview',
|
||||
response_format: { type: 'json_object' },
|
||||
});
|
||||
|
||||
// Pull the message content out of the response
|
||||
@@ -65,7 +65,7 @@ export const summary = internalAction({
|
||||
|
||||
export const saveSummary = internalMutation({
|
||||
args: {
|
||||
id: v.id("notes"),
|
||||
id: v.id('notes'),
|
||||
summary: v.string(),
|
||||
},
|
||||
handler: async (ctx, { id, summary }) => {
|
||||
|
||||
@@ -1,5 +1,5 @@
|
||||
import { defineSchema, defineTable } from "convex/server";
|
||||
import { v } from "convex/values";
|
||||
import { defineSchema, defineTable } from 'convex/server';
|
||||
import { v } from 'convex/values';
|
||||
|
||||
export default defineSchema({
|
||||
notes: defineTable({
|
||||
|
||||
@@ -11,6 +11,6 @@ export function missingEnvVariableUrl(envVarName: string, whereToGet: string) {
|
||||
export function deploymentName() {
|
||||
const url = process.env.CONVEX_CLOUD_URL;
|
||||
if (!url) return undefined;
|
||||
const regex = new RegExp("https://(.+).convex.cloud");
|
||||
const regex = new RegExp('https://(.+).convex.cloud');
|
||||
return regex.exec(url)?.[1];
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user