@convex-dev/agent 0.0.15-alpha.1 → 0.0.16-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 +93 -29
- package/dist/commonjs/client/index.d.ts +771 -74
- package/dist/commonjs/client/index.d.ts.map +1 -1
- package/dist/commonjs/client/index.js +82 -45
- package/dist/commonjs/client/index.js.map +1 -1
- package/dist/commonjs/client/playground.d.ts +474 -0
- package/dist/commonjs/client/playground.d.ts.map +1 -0
- package/dist/commonjs/client/playground.js +178 -0
- package/dist/commonjs/client/playground.js.map +1 -0
- package/dist/commonjs/component/apiKeys.d.ts +11 -0
- package/dist/commonjs/component/apiKeys.d.ts.map +1 -0
- package/dist/commonjs/component/apiKeys.js +69 -0
- package/dist/commonjs/component/apiKeys.js.map +1 -0
- package/dist/commonjs/component/files.d.ts +31 -0
- package/dist/commonjs/component/files.d.ts.map +1 -0
- package/dist/commonjs/component/files.js +61 -0
- package/dist/commonjs/component/files.js.map +1 -0
- package/dist/commonjs/component/messages.d.ts +40 -109
- package/dist/commonjs/component/messages.d.ts.map +1 -1
- package/dist/commonjs/component/messages.js +44 -260
- package/dist/commonjs/component/messages.js.map +1 -1
- package/dist/commonjs/component/schema.d.ts +54 -10
- package/dist/commonjs/component/schema.d.ts.map +1 -1
- package/dist/commonjs/component/schema.js +7 -2
- package/dist/commonjs/component/schema.js.map +1 -1
- package/dist/commonjs/component/threads.d.ts +95 -0
- package/dist/commonjs/component/threads.d.ts.map +1 -0
- package/dist/commonjs/component/threads.js +151 -0
- package/dist/commonjs/component/threads.js.map +1 -0
- package/dist/commonjs/component/users.d.ts +37 -0
- package/dist/commonjs/component/users.d.ts.map +1 -0
- package/dist/commonjs/component/users.js +118 -0
- package/dist/commonjs/component/users.js.map +1 -0
- package/dist/commonjs/validators.d.ts +2 -6
- package/dist/commonjs/validators.d.ts.map +1 -1
- package/dist/commonjs/validators.js +0 -1
- package/dist/commonjs/validators.js.map +1 -1
- package/dist/esm/client/index.d.ts +771 -74
- package/dist/esm/client/index.d.ts.map +1 -1
- package/dist/esm/client/index.js +82 -45
- package/dist/esm/client/index.js.map +1 -1
- package/dist/esm/client/playground.d.ts +474 -0
- package/dist/esm/client/playground.d.ts.map +1 -0
- package/dist/esm/client/playground.js +178 -0
- package/dist/esm/client/playground.js.map +1 -0
- package/dist/esm/component/apiKeys.d.ts +11 -0
- package/dist/esm/component/apiKeys.d.ts.map +1 -0
- package/dist/esm/component/apiKeys.js +69 -0
- package/dist/esm/component/apiKeys.js.map +1 -0
- package/dist/esm/component/files.d.ts +31 -0
- package/dist/esm/component/files.d.ts.map +1 -0
- package/dist/esm/component/files.js +61 -0
- package/dist/esm/component/files.js.map +1 -0
- package/dist/esm/component/messages.d.ts +40 -109
- package/dist/esm/component/messages.d.ts.map +1 -1
- package/dist/esm/component/messages.js +44 -260
- package/dist/esm/component/messages.js.map +1 -1
- package/dist/esm/component/schema.d.ts +54 -10
- package/dist/esm/component/schema.d.ts.map +1 -1
- package/dist/esm/component/schema.js +7 -2
- package/dist/esm/component/schema.js.map +1 -1
- package/dist/esm/component/threads.d.ts +95 -0
- package/dist/esm/component/threads.d.ts.map +1 -0
- package/dist/esm/component/threads.js +151 -0
- package/dist/esm/component/threads.js.map +1 -0
- package/dist/esm/component/users.d.ts +37 -0
- package/dist/esm/component/users.d.ts.map +1 -0
- package/dist/esm/component/users.js +118 -0
- package/dist/esm/component/users.js.map +1 -0
- package/dist/esm/validators.d.ts +2 -6
- package/dist/esm/validators.d.ts.map +1 -1
- package/dist/esm/validators.js +0 -1
- package/dist/esm/validators.js.map +1 -1
- package/package.json +10 -2
- package/src/client/index.ts +152 -120
- package/src/client/playground.ts +231 -0
- package/src/component/_generated/api.d.ts +319 -107
- package/src/component/apiKeys.ts +74 -0
- package/src/component/files.ts +72 -0
- package/src/component/messages.ts +54 -308
- package/src/component/schema.ts +7 -2
- package/src/component/threads.ts +184 -0
- package/src/component/users.ts +145 -0
- package/src/validators.ts +0 -1
|
@@ -1,4 +1,11 @@
|
|
|
1
1
|
export declare const schema: import("convex/server").SchemaDefinition<{
|
|
2
|
+
apiKeys: import("convex/server").TableDefinition<import("convex/values").VObject<{
|
|
3
|
+
name?: string | undefined;
|
|
4
|
+
}, {
|
|
5
|
+
name: import("convex/values").VString<string | undefined, "optional">;
|
|
6
|
+
}, "required", "name">, {
|
|
7
|
+
name: ["name", "_creationTime"];
|
|
8
|
+
}, {}, {}>;
|
|
2
9
|
embeddings_128: import("convex/server").TableDefinition<import("convex/values").VObject<{
|
|
3
10
|
userId?: string | undefined;
|
|
4
11
|
threadId?: string | undefined;
|
|
@@ -226,21 +233,21 @@ export declare const schema: import("convex/server").SchemaDefinition<{
|
|
|
226
233
|
}>;
|
|
227
234
|
threads: import("convex/server").TableDefinition<import("convex/values").VObject<{
|
|
228
235
|
userId?: string | undefined;
|
|
229
|
-
defaultSystemPrompt?: string | undefined;
|
|
230
236
|
title?: string | undefined;
|
|
231
237
|
summary?: string | undefined;
|
|
238
|
+
defaultSystemPrompt?: string | undefined;
|
|
232
239
|
parentThreadIds?: import("convex/values").GenericId<"threads">[] | undefined;
|
|
233
240
|
order?: number | undefined;
|
|
234
241
|
status: "active" | "archived";
|
|
235
242
|
}, {
|
|
236
243
|
userId: import("convex/values").VString<string | undefined, "optional">;
|
|
237
|
-
defaultSystemPrompt: import("convex/values").VString<string | undefined, "optional">;
|
|
238
244
|
title: import("convex/values").VString<string | undefined, "optional">;
|
|
239
245
|
summary: import("convex/values").VString<string | undefined, "optional">;
|
|
240
246
|
status: import("convex/values").VUnion<"active" | "archived", [import("convex/values").VLiteral<"active", "required">, import("convex/values").VLiteral<"archived", "required">], "required", never>;
|
|
247
|
+
defaultSystemPrompt: import("convex/values").VString<string | undefined, "optional">;
|
|
241
248
|
parentThreadIds: import("convex/values").VArray<import("convex/values").GenericId<"threads">[] | undefined, import("convex/values").VId<import("convex/values").GenericId<"threads">, "required">, "optional">;
|
|
242
249
|
order: import("convex/values").VFloat64<number | undefined, "optional">;
|
|
243
|
-
}, "required", "status" | "userId" | "
|
|
250
|
+
}, "required", "status" | "userId" | "title" | "summary" | "defaultSystemPrompt" | "parentThreadIds" | "order">, {
|
|
244
251
|
userId: ["userId", "_creationTime"];
|
|
245
252
|
}, {}, {}>;
|
|
246
253
|
messages: import("convex/server").TableDefinition<import("convex/values").VObject<{
|
|
@@ -2281,14 +2288,14 @@ export declare const vv: {
|
|
|
2281
2288
|
_id: import("convex/values").GenericId<"threads">;
|
|
2282
2289
|
_creationTime: number;
|
|
2283
2290
|
userId?: string | undefined;
|
|
2284
|
-
defaultSystemPrompt?: string | undefined;
|
|
2285
2291
|
title?: string | undefined;
|
|
2286
2292
|
summary?: string | undefined;
|
|
2293
|
+
defaultSystemPrompt?: string | undefined;
|
|
2287
2294
|
parentThreadIds?: import("convex/values").GenericId<"threads">[] | undefined;
|
|
2288
2295
|
order?: number | undefined;
|
|
2289
2296
|
status: "active" | "archived";
|
|
2290
2297
|
};
|
|
2291
|
-
fieldPaths: ("status" | "userId" | "
|
|
2298
|
+
fieldPaths: ("status" | "userId" | "title" | "summary" | "defaultSystemPrompt" | "parentThreadIds" | "order" | "_creationTime") | "_id";
|
|
2292
2299
|
indexes: {
|
|
2293
2300
|
userId: ["userId", "_creationTime"];
|
|
2294
2301
|
by_id: ["_id"];
|
|
@@ -2908,6 +2915,21 @@ export declare const vv: {
|
|
|
2908
2915
|
searchIndexes: {};
|
|
2909
2916
|
vectorIndexes: {};
|
|
2910
2917
|
};
|
|
2918
|
+
apiKeys: {
|
|
2919
|
+
document: {
|
|
2920
|
+
_id: import("convex/values").GenericId<"apiKeys">;
|
|
2921
|
+
_creationTime: number;
|
|
2922
|
+
name?: string | undefined;
|
|
2923
|
+
};
|
|
2924
|
+
fieldPaths: ("_creationTime" | "name") | "_id";
|
|
2925
|
+
indexes: {
|
|
2926
|
+
name: ["name", "_creationTime"];
|
|
2927
|
+
by_id: ["_id"];
|
|
2928
|
+
by_creation_time: ["_creationTime"];
|
|
2929
|
+
};
|
|
2930
|
+
searchIndexes: {};
|
|
2931
|
+
vectorIndexes: {};
|
|
2932
|
+
};
|
|
2911
2933
|
}>>(tableName: TableName) => import("convex/values").VId<import("convex/values").GenericId<TableName>, "required">;
|
|
2912
2934
|
doc: <TableName extends import("convex/server").TableNamesInDataModel<{
|
|
2913
2935
|
threads: {
|
|
@@ -2915,14 +2937,14 @@ export declare const vv: {
|
|
|
2915
2937
|
_id: import("convex/values").GenericId<"threads">;
|
|
2916
2938
|
_creationTime: number;
|
|
2917
2939
|
userId?: string | undefined;
|
|
2918
|
-
defaultSystemPrompt?: string | undefined;
|
|
2919
2940
|
title?: string | undefined;
|
|
2920
2941
|
summary?: string | undefined;
|
|
2942
|
+
defaultSystemPrompt?: string | undefined;
|
|
2921
2943
|
parentThreadIds?: import("convex/values").GenericId<"threads">[] | undefined;
|
|
2922
2944
|
order?: number | undefined;
|
|
2923
2945
|
status: "active" | "archived";
|
|
2924
2946
|
};
|
|
2925
|
-
fieldPaths: ("status" | "userId" | "
|
|
2947
|
+
fieldPaths: ("status" | "userId" | "title" | "summary" | "defaultSystemPrompt" | "parentThreadIds" | "order" | "_creationTime") | "_id";
|
|
2926
2948
|
indexes: {
|
|
2927
2949
|
userId: ["userId", "_creationTime"];
|
|
2928
2950
|
by_id: ["_id"];
|
|
@@ -3542,7 +3564,29 @@ export declare const vv: {
|
|
|
3542
3564
|
searchIndexes: {};
|
|
3543
3565
|
vectorIndexes: {};
|
|
3544
3566
|
};
|
|
3567
|
+
apiKeys: {
|
|
3568
|
+
document: {
|
|
3569
|
+
_id: import("convex/values").GenericId<"apiKeys">;
|
|
3570
|
+
_creationTime: number;
|
|
3571
|
+
name?: string | undefined;
|
|
3572
|
+
};
|
|
3573
|
+
fieldPaths: ("_creationTime" | "name") | "_id";
|
|
3574
|
+
indexes: {
|
|
3575
|
+
name: ["name", "_creationTime"];
|
|
3576
|
+
by_id: ["_id"];
|
|
3577
|
+
by_creation_time: ["_creationTime"];
|
|
3578
|
+
};
|
|
3579
|
+
searchIndexes: {};
|
|
3580
|
+
vectorIndexes: {};
|
|
3581
|
+
};
|
|
3545
3582
|
}>>(tableName: TableName) => import("convex-helpers/validators").AddFieldsToValidator<{
|
|
3583
|
+
apiKeys: import("convex/server").TableDefinition<import("convex/values").VObject<{
|
|
3584
|
+
name?: string | undefined;
|
|
3585
|
+
}, {
|
|
3586
|
+
name: import("convex/values").VString<string | undefined, "optional">;
|
|
3587
|
+
}, "required", "name">, {
|
|
3588
|
+
name: ["name", "_creationTime"];
|
|
3589
|
+
}, {}, {}>;
|
|
3546
3590
|
embeddings_128: import("convex/server").TableDefinition<import("convex/values").VObject<{
|
|
3547
3591
|
userId?: string | undefined;
|
|
3548
3592
|
threadId?: string | undefined;
|
|
@@ -3770,21 +3814,21 @@ export declare const vv: {
|
|
|
3770
3814
|
}>;
|
|
3771
3815
|
threads: import("convex/server").TableDefinition<import("convex/values").VObject<{
|
|
3772
3816
|
userId?: string | undefined;
|
|
3773
|
-
defaultSystemPrompt?: string | undefined;
|
|
3774
3817
|
title?: string | undefined;
|
|
3775
3818
|
summary?: string | undefined;
|
|
3819
|
+
defaultSystemPrompt?: string | undefined;
|
|
3776
3820
|
parentThreadIds?: import("convex/values").GenericId<"threads">[] | undefined;
|
|
3777
3821
|
order?: number | undefined;
|
|
3778
3822
|
status: "active" | "archived";
|
|
3779
3823
|
}, {
|
|
3780
3824
|
userId: import("convex/values").VString<string | undefined, "optional">;
|
|
3781
|
-
defaultSystemPrompt: import("convex/values").VString<string | undefined, "optional">;
|
|
3782
3825
|
title: import("convex/values").VString<string | undefined, "optional">;
|
|
3783
3826
|
summary: import("convex/values").VString<string | undefined, "optional">;
|
|
3784
3827
|
status: import("convex/values").VUnion<"active" | "archived", [import("convex/values").VLiteral<"active", "required">, import("convex/values").VLiteral<"archived", "required">], "required", never>;
|
|
3828
|
+
defaultSystemPrompt: import("convex/values").VString<string | undefined, "optional">;
|
|
3785
3829
|
parentThreadIds: import("convex/values").VArray<import("convex/values").GenericId<"threads">[] | undefined, import("convex/values").VId<import("convex/values").GenericId<"threads">, "required">, "optional">;
|
|
3786
3830
|
order: import("convex/values").VFloat64<number | undefined, "optional">;
|
|
3787
|
-
}, "required", "status" | "userId" | "
|
|
3831
|
+
}, "required", "status" | "userId" | "title" | "summary" | "defaultSystemPrompt" | "parentThreadIds" | "order">, {
|
|
3788
3832
|
userId: ["userId", "_creationTime"];
|
|
3789
3833
|
}, {}, {}>;
|
|
3790
3834
|
messages: import("convex/server").TableDefinition<import("convex/values").VObject<{
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"schema.d.ts","sourceRoot":"","sources":["../../../src/component/schema.ts"],"names":[],"mappings":"AAeA,eAAO,MAAM,MAAM
|
|
1
|
+
{"version":3,"file":"schema.d.ts","sourceRoot":"","sources":["../../../src/component/schema.ts"],"names":[],"mappings":"AAeA,eAAO,MAAM,MAAM;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;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;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;gMAI+vK,eAAgB,qEAAqE,CAAC,mJAAkJ,aAAc,+MAA+M,eAAe;;mFAA0W,GAAG,gDAAwB,WAAW,2BAA0B,WAAY;;;CAJxnM,CAAC;AACjC,OAAO,EAAE,EAAE,IAAI,CAAC,EAAE,CAAC;AAEnB,eAAe,MAAM,CAAC"}
|
|
@@ -6,12 +6,11 @@ import vectorTables, { vVectorId } from "./vector/tables.js";
|
|
|
6
6
|
export const schema = defineSchema({
|
|
7
7
|
threads: defineTable({
|
|
8
8
|
userId: v.optional(v.string()), // Unset for anonymous
|
|
9
|
-
// TODO: is this bubbling up in continue?
|
|
10
|
-
defaultSystemPrompt: v.optional(v.string()),
|
|
11
9
|
title: v.optional(v.string()),
|
|
12
10
|
summary: v.optional(v.string()),
|
|
13
11
|
status: vThreadStatus,
|
|
14
12
|
// DEPRECATED
|
|
13
|
+
defaultSystemPrompt: v.optional(v.string()),
|
|
15
14
|
parentThreadIds: v.optional(v.array(v.id("threads"))),
|
|
16
15
|
order: /*DEPRECATED*/ v.optional(v.number()),
|
|
17
16
|
}).index("userId", ["userId"]),
|
|
@@ -112,6 +111,12 @@ export const schema = defineSchema({
|
|
|
112
111
|
.index("hash", ["hash"])
|
|
113
112
|
.index("refcount", ["refcount"]),
|
|
114
113
|
...vectorTables,
|
|
114
|
+
// To authenticate playground usage
|
|
115
|
+
// Delete a key to invalidate it
|
|
116
|
+
// Provide a name to easily identify it / invalidate by name
|
|
117
|
+
apiKeys: defineTable({
|
|
118
|
+
name: v.optional(v.string()),
|
|
119
|
+
}).index("name", ["name"]),
|
|
115
120
|
});
|
|
116
121
|
export const vv = typedV(schema);
|
|
117
122
|
export { vv as v };
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"schema.js","sourceRoot":"","sources":["../../../src/component/schema.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,YAAY,EAAE,WAAW,EAAE,MAAM,eAAe,CAAC;AAC1D,OAAO,EAAE,CAAC,EAAE,MAAM,eAAe,CAAC;AAClC,OAAO,EACL,aAAa,EACb,QAAQ,EACR,cAAc,EACd,KAAK,EACL,MAAM,EACN,OAAO,EACP,2BAA2B,EAC3B,aAAa,GACd,MAAM,kBAAkB,CAAC;AAC1B,OAAO,EAAE,MAAM,EAAE,MAAM,2BAA2B,CAAC;AACnD,OAAO,YAAY,EAAE,EAAE,SAAS,EAAE,MAAM,oBAAoB,CAAC;AAE7D,MAAM,CAAC,MAAM,MAAM,GAAG,YAAY,CAAC;IACjC,OAAO,EAAE,WAAW,CAAC;QACnB,MAAM,EAAE,CAAC,CAAC,QAAQ,CAAC,CAAC,CAAC,MAAM,EAAE,CAAC,EAAE,sBAAsB;QACtD,
|
|
1
|
+
{"version":3,"file":"schema.js","sourceRoot":"","sources":["../../../src/component/schema.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,YAAY,EAAE,WAAW,EAAE,MAAM,eAAe,CAAC;AAC1D,OAAO,EAAE,CAAC,EAAE,MAAM,eAAe,CAAC;AAClC,OAAO,EACL,aAAa,EACb,QAAQ,EACR,cAAc,EACd,KAAK,EACL,MAAM,EACN,OAAO,EACP,2BAA2B,EAC3B,aAAa,GACd,MAAM,kBAAkB,CAAC;AAC1B,OAAO,EAAE,MAAM,EAAE,MAAM,2BAA2B,CAAC;AACnD,OAAO,YAAY,EAAE,EAAE,SAAS,EAAE,MAAM,oBAAoB,CAAC;AAE7D,MAAM,CAAC,MAAM,MAAM,GAAG,YAAY,CAAC;IACjC,OAAO,EAAE,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AK,CAAC,UAAU,EAAE,CAAC,UAAU,CAAC,CAAC;SAC/B,KAAK,CAAC,QAAQ,EAAE,CAAC,QAAQ,CAAC,CAAC;SAC3B,KAAK,CAAC,aAAa,EAAE,CAAC,aAAa,CAAC,CAAC;IAExC,KAAK,EAAE,WAAW,CAAC;QACjB,SAAS,EAAE,CAAC,CAAC,MAAM,EAAE;QACrB,IAAI,EAAE,CAAC,CAAC,MAAM,EAAE;QAChB,QAAQ,EAAE,CAAC,CAAC,MAAM,EAAE;KACrB,CAAC;SACC,KAAK,CAAC,MAAM,EAAE,CAAC,MAAM,CAAC,CAAC;SACvB,KAAK,CAAC,UAAU,EAAE,CAAC,UAAU,CAAC,CAAC;IAClC,GAAG,YAAY;IACf,mCAAmC;IACnC,gCAAgC;IAChC,4DAA4D;IAC5D,OAAO,EAAE,WAAW,CAAC;QACnB,IAAI,EAAE,CAAC,CAAC,QAAQ,CAAC,CAAC,CAAC,MAAM,EAAE,CAAC;KAC7B,CAAC,CAAC,KAAK,CAAC,MAAM,EAAE,CAAC,MAAM,CAAC,CAAC;CAC3B,CAAC,CAAC;AAEH,MAAM,CAAC,MAAM,EAAE,GAAG,MAAM,CAAC,MAAM,CAAC,CAAC;AACjC,OAAO,EAAE,EAAE,IAAI,CAAC,EAAE,CAAC;AAEnB,eAAe,MAAM,CAAC"}
|
|
@@ -0,0 +1,95 @@
|
|
|
1
|
+
export declare const getThread: import("convex/server").RegisteredQuery<"public", {
|
|
2
|
+
threadId: import("convex/values").GenericId<"threads">;
|
|
3
|
+
}, Promise<{
|
|
4
|
+
userId?: string | undefined;
|
|
5
|
+
title?: string | undefined;
|
|
6
|
+
summary?: string | undefined;
|
|
7
|
+
status: "active" | "archived";
|
|
8
|
+
_creationTime: number;
|
|
9
|
+
_id: string;
|
|
10
|
+
} | null>>;
|
|
11
|
+
export declare const listThreadsByUserId: import("convex/server").RegisteredQuery<"public", {
|
|
12
|
+
order?: "asc" | "desc" | undefined;
|
|
13
|
+
paginationOpts?: {
|
|
14
|
+
id?: number | undefined;
|
|
15
|
+
endCursor?: string | null | undefined;
|
|
16
|
+
maximumRowsRead?: number | undefined;
|
|
17
|
+
maximumBytesRead?: number | undefined;
|
|
18
|
+
numItems: number;
|
|
19
|
+
cursor: string | null;
|
|
20
|
+
} | undefined;
|
|
21
|
+
userId: string;
|
|
22
|
+
}, Promise<{
|
|
23
|
+
page: {
|
|
24
|
+
userId?: string | undefined;
|
|
25
|
+
title?: string | undefined;
|
|
26
|
+
summary?: string | undefined;
|
|
27
|
+
status: "active" | "archived";
|
|
28
|
+
_creationTime: number;
|
|
29
|
+
_id: string;
|
|
30
|
+
}[];
|
|
31
|
+
isDone: boolean;
|
|
32
|
+
continueCursor: import("convex/server").Cursor;
|
|
33
|
+
splitCursor?: import("convex/server").Cursor | null;
|
|
34
|
+
pageStatus?: "SplitRecommended" | "SplitRequired" | null;
|
|
35
|
+
}>>;
|
|
36
|
+
export declare const createThread: import("convex/server").RegisteredMutation<"public", {
|
|
37
|
+
userId?: string | undefined;
|
|
38
|
+
title?: string | undefined;
|
|
39
|
+
summary?: string | undefined;
|
|
40
|
+
defaultSystemPrompt?: string | undefined;
|
|
41
|
+
parentThreadIds?: import("convex/values").GenericId<"threads">[] | undefined;
|
|
42
|
+
}, Promise<{
|
|
43
|
+
userId?: string | undefined;
|
|
44
|
+
title?: string | undefined;
|
|
45
|
+
summary?: string | undefined;
|
|
46
|
+
status: "active" | "archived";
|
|
47
|
+
_creationTime: number;
|
|
48
|
+
_id: string;
|
|
49
|
+
}>>;
|
|
50
|
+
export declare const updateThread: import("convex/server").RegisteredMutation<"public", {
|
|
51
|
+
threadId: import("convex/values").GenericId<"threads">;
|
|
52
|
+
patch: {
|
|
53
|
+
status?: "active" | "archived" | undefined;
|
|
54
|
+
title?: string | undefined;
|
|
55
|
+
summary?: string | undefined;
|
|
56
|
+
};
|
|
57
|
+
}, Promise<{
|
|
58
|
+
userId?: string | undefined;
|
|
59
|
+
title?: string | undefined;
|
|
60
|
+
summary?: string | undefined;
|
|
61
|
+
status: "active" | "archived";
|
|
62
|
+
_creationTime: number;
|
|
63
|
+
_id: string;
|
|
64
|
+
}>>;
|
|
65
|
+
/**
|
|
66
|
+
* Use this to delete a thread and everything it contains.
|
|
67
|
+
* It will try to delete all pages synchronously.
|
|
68
|
+
* If it times out or fails, you'll have to run it again.
|
|
69
|
+
*/
|
|
70
|
+
export declare const deleteAllForThreadIdSync: import("convex/server").RegisteredAction<"public", {
|
|
71
|
+
limit?: number | undefined;
|
|
72
|
+
cursor?: string | undefined;
|
|
73
|
+
threadId: import("convex/values").GenericId<"threads">;
|
|
74
|
+
}, Promise<void>>;
|
|
75
|
+
export declare const _deletePageForThreadId: import("convex/server").RegisteredMutation<"internal", {
|
|
76
|
+
limit?: number | undefined;
|
|
77
|
+
cursor?: string | undefined;
|
|
78
|
+
threadId: import("convex/values").GenericId<"threads">;
|
|
79
|
+
}, Promise<{
|
|
80
|
+
isDone: boolean;
|
|
81
|
+
cursor: string;
|
|
82
|
+
}>>;
|
|
83
|
+
/**
|
|
84
|
+
* Use this to delete a thread and everything it contains.
|
|
85
|
+
* It will continue deleting pages asynchronously.
|
|
86
|
+
*/
|
|
87
|
+
export declare const deleteAllForThreadIdAsync: import("convex/server").RegisteredMutation<"public", {
|
|
88
|
+
limit?: number | undefined;
|
|
89
|
+
cursor?: string | undefined;
|
|
90
|
+
threadId: import("convex/values").GenericId<"threads">;
|
|
91
|
+
}, Promise<{
|
|
92
|
+
isDone: boolean;
|
|
93
|
+
cursor: string;
|
|
94
|
+
}>>;
|
|
95
|
+
//# sourceMappingURL=threads.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"threads.d.ts","sourceRoot":"","sources":["../../../src/component/threads.ts"],"names":[],"mappings":"AA8BA,eAAO,MAAM,SAAS;;;;;;;;;UAMpB,CAAC;AAEH,eAAO,MAAM,mBAAmB;;;;;;;;;;;;;;;;;;;;;;;;GAkB9B,CAAC;AAIH,eAAO,MAAM,YAAY;;;;;;;;;;;;;GAUvB,CAAC;AAEH,eAAO,MAAM,YAAY;;;;;;;;;;;;;;GAcvB,CAAC;AA4BH;;;;GAIG;AACH,eAAO,MAAM,wBAAwB;;;;iBAgBnC,CAAC;AAEH,eAAO,MAAM,sBAAsB;;;;;;;GAIjC,CAAC;AAEH;;;GAGG;AACH,eAAO,MAAM,yBAAyB;;;;;;;GAapC,CAAC"}
|
|
@@ -0,0 +1,151 @@
|
|
|
1
|
+
import { assert, omit, pick } from "convex-helpers";
|
|
2
|
+
import { paginator } from "convex-helpers/server/pagination";
|
|
3
|
+
import { partial } from "convex-helpers/validators";
|
|
4
|
+
import { paginationResultValidator } from "../validators.js";
|
|
5
|
+
import { api, internal } from "./_generated/api.js";
|
|
6
|
+
import { action, internalMutation, mutation, query, } from "./_generated/server.js";
|
|
7
|
+
import { schema, v } from "./schema.js";
|
|
8
|
+
import { paginationOptsValidator } from "convex/server";
|
|
9
|
+
import { deleteMessage } from "./messages.js";
|
|
10
|
+
import { vThreadDoc } from "../client/index.js";
|
|
11
|
+
function publicThreadOrNull(thread) {
|
|
12
|
+
if (thread === null) {
|
|
13
|
+
return null;
|
|
14
|
+
}
|
|
15
|
+
return publicThread(thread);
|
|
16
|
+
}
|
|
17
|
+
function publicThread(thread) {
|
|
18
|
+
return omit(thread, ["defaultSystemPrompt", "parentThreadIds", "order"]);
|
|
19
|
+
}
|
|
20
|
+
export const getThread = query({
|
|
21
|
+
args: { threadId: v.id("threads") },
|
|
22
|
+
handler: async (ctx, args) => {
|
|
23
|
+
return publicThreadOrNull(await ctx.db.get(args.threadId));
|
|
24
|
+
},
|
|
25
|
+
returns: v.union(vThreadDoc, v.null()),
|
|
26
|
+
});
|
|
27
|
+
export const listThreadsByUserId = query({
|
|
28
|
+
args: {
|
|
29
|
+
userId: v.string(),
|
|
30
|
+
order: v.optional(v.union(v.literal("asc"), v.literal("desc"))),
|
|
31
|
+
paginationOpts: v.optional(paginationOptsValidator),
|
|
32
|
+
},
|
|
33
|
+
handler: async (ctx, args) => {
|
|
34
|
+
const threads = await paginator(ctx.db, schema)
|
|
35
|
+
.query("threads")
|
|
36
|
+
.withIndex("userId", (q) => q.eq("userId", args.userId))
|
|
37
|
+
.order(args.order ?? "desc")
|
|
38
|
+
.paginate(args.paginationOpts ?? { cursor: null, numItems: 100 });
|
|
39
|
+
return {
|
|
40
|
+
...threads,
|
|
41
|
+
page: threads.page.map(publicThread),
|
|
42
|
+
};
|
|
43
|
+
},
|
|
44
|
+
returns: paginationResultValidator(vThreadDoc),
|
|
45
|
+
});
|
|
46
|
+
const vThread = schema.tables.threads.validator;
|
|
47
|
+
export const createThread = mutation({
|
|
48
|
+
args: omit(vThread.fields, ["order", "status"]),
|
|
49
|
+
handler: async (ctx, args) => {
|
|
50
|
+
const threadId = await ctx.db.insert("threads", {
|
|
51
|
+
...args,
|
|
52
|
+
status: "active",
|
|
53
|
+
});
|
|
54
|
+
return publicThread((await ctx.db.get(threadId)));
|
|
55
|
+
},
|
|
56
|
+
returns: vThreadDoc,
|
|
57
|
+
});
|
|
58
|
+
export const updateThread = mutation({
|
|
59
|
+
args: {
|
|
60
|
+
threadId: v.id("threads"),
|
|
61
|
+
patch: v.object(partial(pick(vThread.fields, ["title", "summary", "status"]))),
|
|
62
|
+
},
|
|
63
|
+
handler: async (ctx, args) => {
|
|
64
|
+
const thread = await ctx.db.get(args.threadId);
|
|
65
|
+
assert(thread, `Thread ${args.threadId} not found`);
|
|
66
|
+
await ctx.db.patch(args.threadId, args.patch);
|
|
67
|
+
return publicThread((await ctx.db.get(args.threadId)));
|
|
68
|
+
},
|
|
69
|
+
returns: vThreadDoc,
|
|
70
|
+
});
|
|
71
|
+
// When we expose this, we need to also hide all the messages and steps
|
|
72
|
+
// export const archiveThread = mutation({
|
|
73
|
+
// args: { threadId: v.id("threads") },
|
|
74
|
+
// handler: async (ctx, args) => {
|
|
75
|
+
// const thread = await ctx.db.get(args.threadId);
|
|
76
|
+
// assert(thread, `Thread ${args.threadId} not found`);
|
|
77
|
+
// await ctx.db.patch(args.threadId, { status: "archived" });
|
|
78
|
+
// return publicThread((await ctx.db.get(args.threadId))!);
|
|
79
|
+
// },
|
|
80
|
+
// returns: vThreadDoc,
|
|
81
|
+
// });
|
|
82
|
+
// TODO: delete thread
|
|
83
|
+
const deleteThreadArgs = {
|
|
84
|
+
threadId: v.id("threads"),
|
|
85
|
+
cursor: v.optional(v.string()),
|
|
86
|
+
limit: v.optional(v.number()),
|
|
87
|
+
};
|
|
88
|
+
const deleteThreadReturns = {
|
|
89
|
+
cursor: v.string(),
|
|
90
|
+
isDone: v.boolean(),
|
|
91
|
+
};
|
|
92
|
+
/**
|
|
93
|
+
* Use this to delete a thread and everything it contains.
|
|
94
|
+
* It will try to delete all pages synchronously.
|
|
95
|
+
* If it times out or fails, you'll have to run it again.
|
|
96
|
+
*/
|
|
97
|
+
export const deleteAllForThreadIdSync = action({
|
|
98
|
+
args: deleteThreadArgs,
|
|
99
|
+
handler: async (ctx, args) => {
|
|
100
|
+
let cursor = args.cursor;
|
|
101
|
+
while (true) {
|
|
102
|
+
const result = await ctx.runMutation(internal.threads._deletePageForThreadId, { threadId: args.threadId, cursor, limit: args.limit });
|
|
103
|
+
if (result.isDone) {
|
|
104
|
+
break;
|
|
105
|
+
}
|
|
106
|
+
cursor = result.cursor;
|
|
107
|
+
}
|
|
108
|
+
},
|
|
109
|
+
returns: v.null(),
|
|
110
|
+
});
|
|
111
|
+
export const _deletePageForThreadId = internalMutation({
|
|
112
|
+
args: deleteThreadArgs,
|
|
113
|
+
handler: deletePageForThreadIdHandler,
|
|
114
|
+
returns: deleteThreadReturns,
|
|
115
|
+
});
|
|
116
|
+
/**
|
|
117
|
+
* Use this to delete a thread and everything it contains.
|
|
118
|
+
* It will continue deleting pages asynchronously.
|
|
119
|
+
*/
|
|
120
|
+
export const deleteAllForThreadIdAsync = mutation({
|
|
121
|
+
args: deleteThreadArgs,
|
|
122
|
+
handler: async (ctx, args) => {
|
|
123
|
+
const result = await deletePageForThreadIdHandler(ctx, args);
|
|
124
|
+
if (!result.isDone) {
|
|
125
|
+
await ctx.scheduler.runAfter(0, api.threads.deleteAllForThreadIdAsync, {
|
|
126
|
+
threadId: args.threadId,
|
|
127
|
+
cursor: result.cursor,
|
|
128
|
+
});
|
|
129
|
+
}
|
|
130
|
+
return result;
|
|
131
|
+
},
|
|
132
|
+
returns: deleteThreadReturns,
|
|
133
|
+
});
|
|
134
|
+
async function deletePageForThreadIdHandler(ctx, args) {
|
|
135
|
+
const messages = await paginator(ctx.db, schema)
|
|
136
|
+
.query("messages")
|
|
137
|
+
.withIndex("threadId_status_tool_order_stepOrder", (q) => q.eq("threadId", args.threadId))
|
|
138
|
+
.paginate({
|
|
139
|
+
numItems: args.limit ?? 100,
|
|
140
|
+
cursor: args.cursor ?? null,
|
|
141
|
+
});
|
|
142
|
+
await Promise.all(messages.page.map((m) => deleteMessage(ctx, m)));
|
|
143
|
+
if (messages.isDone) {
|
|
144
|
+
await ctx.db.delete(args.threadId);
|
|
145
|
+
}
|
|
146
|
+
return {
|
|
147
|
+
cursor: messages.continueCursor,
|
|
148
|
+
isDone: messages.isDone,
|
|
149
|
+
};
|
|
150
|
+
}
|
|
151
|
+
//# sourceMappingURL=threads.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"threads.js","sourceRoot":"","sources":["../../../src/component/threads.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,MAAM,EAAE,IAAI,EAAE,IAAI,EAAE,MAAM,gBAAgB,CAAC;AACpD,OAAO,EAAE,SAAS,EAAE,MAAM,kCAAkC,CAAC;AAC7D,OAAO,EAAE,OAAO,EAAE,MAAM,2BAA2B,CAAC;AAEpD,OAAO,EAAE,yBAAyB,EAAE,MAAM,kBAAkB,CAAC;AAC7D,OAAO,EAAE,GAAG,EAAE,QAAQ,EAAE,MAAM,qBAAqB,CAAC;AAEpD,OAAO,EACL,MAAM,EACN,gBAAgB,EA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C,QAAQ,CAAC,CAAC,EAAE,GAAG,CAAC,OAAO,CAAC,yBAAyB,EAAE;gBACrE,QAAQ,EAAE,IAAI,CAAC,QAAQ;gBACvB,MAAM,EAAE,MAAM,CAAC,MAAM;aACtB,CAAC,CAAC;QACL,CAAC;QACD,OAAO,MAAM,CAAC;IAChB,CAAC;IACD,OAAO,EAAE,mBAAmB;CAC7B,CAAC,CAAC;AAEH,KAAK,UAAU,4BAA4B,CACzC,GAAgB,EAChB,IAAsB;IAEtB,MAAM,QAAQ,GAAG,MAAM,SAAS,CAAC,GAAG,CAAC,EAAE,EAAE,MAAM,CAAC;SAC7C,KAAK,CAAC,UAAU,CAAC;SACjB,SAAS,CAAC,sCAAsC,EAAE,CAAC,CAAC,EAAE,EAAE,CACvD,CAAC,CAAC,EAAE,CAAC,UAAU,EAAE,IAAI,CAAC,QAAQ,CAAC,CAChC;SACA,QAAQ,CAAC;QACR,QAAQ,EAAE,IAAI,CAAC,KAAK,IAAI,GAAG;QAC3B,MAAM,EAAE,IAAI,CAAC,MAAM,IAAI,IAAI;KAC5B,CAAC,CAAC;IACL,MAAM,OAAO,CAAC,GAAG,CAAC,QAAQ,CAAC,IAAI,CAAC,GAAG,CAAC,CAAC,CAAC,EAAE,EAAE,CAAC,aAAa,CAAC,GAAG,EAAE,CAAC,CAAC,CAAC,CAAC,CAAC;IACnE,IAAI,QAAQ,CAAC,MAAM,EAAE,CAAC;QACpB,MAAM,GAAG,CAAC,EAAE,CAAC,MAAM,CAAC,IAAI,CAAC,QAAQ,CAAC,CAAC;IACrC,CAAC;IACD,OAAO;QACL,MAAM,EAAE,QAAQ,CAAC,cAAc;QAC/B,MAAM,EAAE,QAAQ,CAAC,MAAM;KACxB,CAAC;AACJ,CAAC"}
|
|
@@ -0,0 +1,37 @@
|
|
|
1
|
+
export declare const listUsersWithThreads: import("convex/server").RegisteredQuery<"public", {
|
|
2
|
+
paginationOpts: {
|
|
3
|
+
id?: number | undefined;
|
|
4
|
+
endCursor?: string | null | undefined;
|
|
5
|
+
maximumRowsRead?: number | undefined;
|
|
6
|
+
maximumBytesRead?: number | undefined;
|
|
7
|
+
numItems: number;
|
|
8
|
+
cursor: string | null;
|
|
9
|
+
};
|
|
10
|
+
}, Promise<{
|
|
11
|
+
page: string[];
|
|
12
|
+
isDone: boolean;
|
|
13
|
+
continueCursor: import("convex/server").Cursor;
|
|
14
|
+
splitCursor?: import("convex/server").Cursor | null;
|
|
15
|
+
pageStatus?: "SplitRecommended" | "SplitRequired" | null;
|
|
16
|
+
}>>;
|
|
17
|
+
export declare const deleteAllForUserId: import("convex/server").RegisteredAction<"public", {
|
|
18
|
+
userId: string;
|
|
19
|
+
}, Promise<void>>;
|
|
20
|
+
export declare const deleteAllForUserIdAsync: import("convex/server").RegisteredMutation<"public", {
|
|
21
|
+
userId: string;
|
|
22
|
+
}, Promise<boolean>>;
|
|
23
|
+
export declare const _deleteAllForUserIdAsync: import("convex/server").RegisteredMutation<"internal", {
|
|
24
|
+
userId: string;
|
|
25
|
+
messagesCursor: string | null;
|
|
26
|
+
threadsCursor: string | null;
|
|
27
|
+
}, Promise<boolean>>;
|
|
28
|
+
export declare const _deletePageForUserId: import("convex/server").RegisteredMutation<"internal", {
|
|
29
|
+
userId: string;
|
|
30
|
+
messagesCursor: string | null;
|
|
31
|
+
threadsCursor: string | null;
|
|
32
|
+
}, Promise<{
|
|
33
|
+
isDone: boolean;
|
|
34
|
+
messagesCursor: string;
|
|
35
|
+
threadsCursor: string | null;
|
|
36
|
+
}>>;
|
|
37
|
+
//# sourceMappingURL=users.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"users.d.ts","sourceRoot":"","sources":["../../../src/component/users.ts"],"names":[],"mappings":"AAkBA,eAAO,MAAM,oBAAoB;;;;;;;;;;;;;;;GAiB/B,CAAC;AAEH,eAAO,MAAM,kBAAkB;;iBAsB7B,CAAC;AAEH,eAAO,MAAM,uBAAuB;;oBAalC,CAAC;AAeH,eAAO,MAAM,wBAAwB;;;;oBAInC,CAAC;AAiBH,eAAO,MAAM,oBAAoB;;;;;;;;GAI/B,CAAC"}
|
|
@@ -0,0 +1,118 @@
|
|
|
1
|
+
import { paginator } from "convex-helpers/server/pagination";
|
|
2
|
+
import { nullable } from "convex-helpers/validators";
|
|
3
|
+
import { internal } from "./_generated/api.js";
|
|
4
|
+
import { action, internalMutation, mutation, query, } from "./_generated/server.js";
|
|
5
|
+
import { schema, v } from "./schema.js";
|
|
6
|
+
import { deleteMessage } from "./messages.js";
|
|
7
|
+
import { paginationOptsValidator } from "convex/server";
|
|
8
|
+
import { stream } from "convex-helpers/server/stream";
|
|
9
|
+
import { paginationResultValidator } from "../validators.js";
|
|
10
|
+
// Note: it only searches for users with threads
|
|
11
|
+
export const listUsersWithThreads = query({
|
|
12
|
+
args: {
|
|
13
|
+
paginationOpts: paginationOptsValidator,
|
|
14
|
+
},
|
|
15
|
+
handler: async (ctx, args) => {
|
|
16
|
+
const results = await stream(ctx.db, schema)
|
|
17
|
+
.query("threads")
|
|
18
|
+
.withIndex("userId", (q) => q)
|
|
19
|
+
.filterWith(async (q) => !!q.userId)
|
|
20
|
+
.distinct(["userId"])
|
|
21
|
+
.paginate(args.paginationOpts);
|
|
22
|
+
return {
|
|
23
|
+
...results,
|
|
24
|
+
page: results.page.map((t) => t.userId).filter((t) => !!t),
|
|
25
|
+
};
|
|
26
|
+
},
|
|
27
|
+
returns: paginationResultValidator(v.string()),
|
|
28
|
+
});
|
|
29
|
+
export const deleteAllForUserId = action({
|
|
30
|
+
args: { userId: v.string() },
|
|
31
|
+
handler: async (ctx, args) => {
|
|
32
|
+
let messagesCursor = null;
|
|
33
|
+
let threadsCursor = null;
|
|
34
|
+
let isDone = false;
|
|
35
|
+
while (!isDone) {
|
|
36
|
+
const result = await ctx.runMutation(internal.users._deletePageForUserId, {
|
|
37
|
+
userId: args.userId,
|
|
38
|
+
messagesCursor,
|
|
39
|
+
threadsCursor,
|
|
40
|
+
});
|
|
41
|
+
messagesCursor = result.messagesCursor;
|
|
42
|
+
threadsCursor = result.threadsCursor;
|
|
43
|
+
isDone = result.isDone;
|
|
44
|
+
}
|
|
45
|
+
},
|
|
46
|
+
returns: v.null(),
|
|
47
|
+
});
|
|
48
|
+
export const deleteAllForUserIdAsync = mutation({
|
|
49
|
+
args: {
|
|
50
|
+
userId: v.string(),
|
|
51
|
+
},
|
|
52
|
+
handler: async (ctx, args) => {
|
|
53
|
+
const isDone = await deleteAllForUserIdAsyncHandler(ctx, {
|
|
54
|
+
userId: args.userId,
|
|
55
|
+
messagesCursor: null,
|
|
56
|
+
threadsCursor: null,
|
|
57
|
+
});
|
|
58
|
+
return isDone;
|
|
59
|
+
},
|
|
60
|
+
returns: v.boolean(),
|
|
61
|
+
});
|
|
62
|
+
const deleteAllArgs = {
|
|
63
|
+
userId: v.string(),
|
|
64
|
+
messagesCursor: nullable(v.string()),
|
|
65
|
+
threadsCursor: nullable(v.string()),
|
|
66
|
+
};
|
|
67
|
+
const deleteAllReturns = {
|
|
68
|
+
messagesCursor: v.string(),
|
|
69
|
+
threadsCursor: nullable(v.string()),
|
|
70
|
+
isDone: v.boolean(),
|
|
71
|
+
};
|
|
72
|
+
export const _deleteAllForUserIdAsync = internalMutation({
|
|
73
|
+
args: deleteAllArgs,
|
|
74
|
+
handler: deleteAllForUserIdAsyncHandler,
|
|
75
|
+
returns: v.boolean(),
|
|
76
|
+
});
|
|
77
|
+
async function deleteAllForUserIdAsyncHandler(ctx, args) {
|
|
78
|
+
const result = await deletePageForUserId(ctx, args);
|
|
79
|
+
if (!result.isDone) {
|
|
80
|
+
await ctx.scheduler.runAfter(0, internal.users._deleteAllForUserIdAsync, {
|
|
81
|
+
userId: args.userId,
|
|
82
|
+
messagesCursor: result.messagesCursor,
|
|
83
|
+
threadsCursor: result.threadsCursor,
|
|
84
|
+
});
|
|
85
|
+
}
|
|
86
|
+
return result.isDone;
|
|
87
|
+
}
|
|
88
|
+
export const _deletePageForUserId = internalMutation({
|
|
89
|
+
args: deleteAllArgs,
|
|
90
|
+
handler: deletePageForUserId,
|
|
91
|
+
returns: deleteAllReturns,
|
|
92
|
+
});
|
|
93
|
+
async function deletePageForUserId(ctx, args) {
|
|
94
|
+
const threads = await paginator(ctx.db, schema)
|
|
95
|
+
.query("threads")
|
|
96
|
+
.withIndex("userId", (q) => q.eq("userId", args.userId))
|
|
97
|
+
.order("desc")
|
|
98
|
+
.paginate({
|
|
99
|
+
numItems: 100,
|
|
100
|
+
cursor: args.threadsCursor ?? null,
|
|
101
|
+
});
|
|
102
|
+
await Promise.all(threads.page.map((c) => ctx.db.delete(c._id)));
|
|
103
|
+
const messages = await paginator(ctx.db, schema)
|
|
104
|
+
.query("messages")
|
|
105
|
+
.withIndex("userId_status_tool_order_stepOrder", (q) => q.eq("userId", args.userId))
|
|
106
|
+
.order("desc")
|
|
107
|
+
.paginate({
|
|
108
|
+
numItems: 100,
|
|
109
|
+
cursor: args.messagesCursor ?? null,
|
|
110
|
+
});
|
|
111
|
+
await Promise.all(messages.page.map((m) => deleteMessage(ctx, m)));
|
|
112
|
+
return {
|
|
113
|
+
messagesCursor: messages.continueCursor,
|
|
114
|
+
threadsCursor: threads.continueCursor,
|
|
115
|
+
isDone: messages.isDone,
|
|
116
|
+
};
|
|
117
|
+
}
|
|
118
|
+
//# sourceMappingURL=users.js.map
|