@convex-dev/agent 0.1.8 → 0.1.9-alpha.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/README.md +3 -0
- package/dist/commonjs/component/_generated/api.d.ts +18 -0
- package/dist/commonjs/component/messages.d.ts.map +1 -1
- package/dist/commonjs/component/messages.js +1 -0
- package/dist/commonjs/component/messages.js.map +1 -1
- package/dist/commonjs/component/streams.d.ts.map +1 -1
- package/dist/commonjs/component/streams.js +0 -1
- package/dist/commonjs/component/streams.js.map +1 -1
- package/dist/commonjs/component/threads.d.ts.map +1 -1
- package/dist/commonjs/component/threads.js +2 -4
- package/dist/commonjs/component/threads.js.map +1 -1
- package/dist/commonjs.tsbuildinfo +1 -1
- package/dist/esm/component/_generated/api.d.ts +18 -0
- package/dist/esm/component/messages.d.ts.map +1 -1
- package/dist/esm/component/messages.js +1 -0
- package/dist/esm/component/messages.js.map +1 -1
- package/dist/esm/component/streams.d.ts.map +1 -1
- package/dist/esm/component/streams.js +0 -1
- package/dist/esm/component/streams.js.map +1 -1
- package/dist/esm/component/threads.d.ts.map +1 -1
- package/dist/esm/component/threads.js +2 -4
- package/dist/esm/component/threads.js.map +1 -1
- package/dist/esm.tsbuildinfo +1 -1
- package/package.json +1 -1
- package/src/component/_generated/api.d.ts +18 -0
- package/src/component/messages.ts +1 -0
- package/src/component/streams.ts +1 -3
- package/src/component/threads.test.ts +9 -3
- package/src/component/threads.ts +6 -7
- package/src/component/users.test.ts +3 -3
package/src/component/streams.ts
CHANGED
|
@@ -6,7 +6,7 @@ import {
|
|
|
6
6
|
vStreamMessage,
|
|
7
7
|
} from "../validators.js";
|
|
8
8
|
import { api, internal } from "./_generated/api.js";
|
|
9
|
-
import type {
|
|
9
|
+
import type { Id } from "./_generated/dataModel.js";
|
|
10
10
|
import {
|
|
11
11
|
internalMutation,
|
|
12
12
|
mutation,
|
|
@@ -15,8 +15,6 @@ import {
|
|
|
15
15
|
action,
|
|
16
16
|
} from "./_generated/server.js";
|
|
17
17
|
import schema from "./schema.js";
|
|
18
|
-
import type { PaginationResult } from "convex/server";
|
|
19
|
-
import { paginator } from "convex-helpers/server/pagination";
|
|
20
18
|
import { stream } from "convex-helpers/server/stream";
|
|
21
19
|
import { mergedStream } from "convex-helpers/server/stream";
|
|
22
20
|
|
|
@@ -295,9 +295,9 @@ describe("threads", () => {
|
|
|
295
295
|
|
|
296
296
|
await t.mutation(api.messages.addMessages, {
|
|
297
297
|
threadId: thread._id as Id<"threads">,
|
|
298
|
-
messages:
|
|
299
|
-
|
|
300
|
-
|
|
298
|
+
messages: Array.from({ length: 100 }, (_, i) => ({
|
|
299
|
+
message: { role: "user" as const, content: `Message ${i}` },
|
|
300
|
+
})),
|
|
301
301
|
});
|
|
302
302
|
|
|
303
303
|
// Start async deletion
|
|
@@ -320,6 +320,12 @@ describe("threads", () => {
|
|
|
320
320
|
});
|
|
321
321
|
expect(afterThread).toBeNull();
|
|
322
322
|
|
|
323
|
+
// Verify streams are deleted
|
|
324
|
+
const afterStreams = await t.query(api.streams.list, {
|
|
325
|
+
threadId: thread._id as Id<"threads">,
|
|
326
|
+
});
|
|
327
|
+
expect(afterStreams).toHaveLength(0);
|
|
328
|
+
|
|
323
329
|
// Reset to normal timers
|
|
324
330
|
vi.useRealTimers();
|
|
325
331
|
});
|
package/src/component/threads.ts
CHANGED
|
@@ -157,14 +157,13 @@ export const deleteAllForThreadIdAsync = mutation({
|
|
|
157
157
|
threadId: args.threadId,
|
|
158
158
|
cursor: result.cursor,
|
|
159
159
|
});
|
|
160
|
-
} else {
|
|
161
|
-
// Kick off the streams deletion
|
|
162
|
-
await ctx.scheduler.runAfter(
|
|
163
|
-
0,
|
|
164
|
-
api.streams.deleteAllStreamsForThreadIdSync,
|
|
165
|
-
{ threadId: args.threadId }
|
|
166
|
-
);
|
|
167
160
|
}
|
|
161
|
+
// Kick off the streams deletion
|
|
162
|
+
await ctx.scheduler.runAfter(
|
|
163
|
+
0,
|
|
164
|
+
api.streams.deleteAllStreamsForThreadIdSync,
|
|
165
|
+
{ threadId: args.threadId }
|
|
166
|
+
);
|
|
168
167
|
return result;
|
|
169
168
|
},
|
|
170
169
|
returns: deleteThreadReturns,
|
|
@@ -12,15 +12,15 @@ describe("users", () => {
|
|
|
12
12
|
const t = convexTest(schema, modules);
|
|
13
13
|
|
|
14
14
|
// Create two users with threads and one without
|
|
15
|
-
|
|
15
|
+
await t.mutation(api.threads.createThread, {
|
|
16
16
|
userId: "user1",
|
|
17
17
|
title: "Test thread 1",
|
|
18
18
|
});
|
|
19
|
-
|
|
19
|
+
await t.mutation(api.threads.createThread, {
|
|
20
20
|
userId: "user2",
|
|
21
21
|
title: "Test thread 2",
|
|
22
22
|
});
|
|
23
|
-
|
|
23
|
+
await t.mutation(api.threads.createThread, {
|
|
24
24
|
userId: "user1", // Same user, different thread
|
|
25
25
|
title: "Test thread 3",
|
|
26
26
|
});
|