@convex-dev/persistent-text-streaming 0.2.3 → 0.3.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 +37 -35
- package/dist/{commonjs/client → client}/index.d.ts +4 -4
- package/dist/client/index.d.ts.map +1 -0
- package/dist/{esm/client → client}/index.js +1 -0
- package/dist/client/index.js.map +1 -0
- package/dist/component/_generated/api.d.ts +36 -0
- package/dist/component/_generated/api.d.ts.map +1 -0
- package/{src → dist}/component/_generated/api.js +11 -3
- package/dist/component/_generated/api.js.map +1 -0
- package/dist/component/_generated/component.d.ts +44 -0
- package/dist/component/_generated/component.d.ts.map +1 -0
- package/dist/component/_generated/component.js +11 -0
- package/dist/component/_generated/component.js.map +1 -0
- package/dist/component/_generated/dataModel.d.ts +46 -0
- package/dist/component/_generated/dataModel.d.ts.map +1 -0
- package/dist/component/_generated/dataModel.js +11 -0
- package/dist/component/_generated/dataModel.js.map +1 -0
- package/{src → dist}/component/_generated/server.d.ts +10 -38
- package/dist/component/_generated/server.d.ts.map +1 -0
- package/dist/{commonjs/component → component}/_generated/server.js +9 -5
- package/dist/component/_generated/server.js.map +1 -0
- package/dist/component/convex.config.d.ts.map +1 -0
- package/dist/component/convex.config.js.map +1 -0
- package/dist/component/crons.d.ts.map +1 -0
- package/dist/{commonjs/component → component}/crons.js +1 -1
- package/dist/component/crons.js.map +1 -0
- package/dist/component/lib.d.ts.map +1 -0
- package/dist/{commonjs/component → component}/lib.js +2 -2
- package/dist/component/lib.js.map +1 -0
- package/dist/{commonjs/component → component}/schema.d.ts +1 -1
- package/dist/component/schema.d.ts.map +1 -0
- package/dist/component/schema.js.map +1 -0
- package/dist/{commonjs/react → react}/index.d.ts +2 -2
- package/dist/react/index.d.ts.map +1 -0
- package/dist/{commonjs/react → react}/index.js +10 -5
- package/dist/react/index.js.map +1 -0
- package/package.json +64 -54
- package/src/client/index.ts +16 -13
- package/src/component/_generated/api.ts +52 -0
- package/src/component/_generated/component.ts +63 -0
- package/src/component/_generated/server.ts +161 -0
- package/src/component/crons.ts +2 -2
- package/src/component/lib.ts +4 -4
- package/src/component/schema.ts +2 -2
- package/src/react/index.ts +17 -13
- package/src/test.ts +18 -0
- package/dist/commonjs/client/index.d.ts.map +0 -1
- package/dist/commonjs/client/index.js +0 -146
- package/dist/commonjs/client/index.js.map +0 -1
- package/dist/commonjs/component/_generated/api.d.ts +0 -12
- package/dist/commonjs/component/_generated/api.d.ts.map +0 -1
- package/dist/commonjs/component/_generated/api.js +0 -22
- package/dist/commonjs/component/_generated/api.js.map +0 -1
- package/dist/commonjs/component/_generated/server.d.ts +0 -64
- package/dist/commonjs/component/_generated/server.d.ts.map +0 -1
- package/dist/commonjs/component/_generated/server.js.map +0 -1
- package/dist/commonjs/component/convex.config.d.ts.map +0 -1
- package/dist/commonjs/component/convex.config.js.map +0 -1
- package/dist/commonjs/component/crons.d.ts.map +0 -1
- package/dist/commonjs/component/crons.js.map +0 -1
- package/dist/commonjs/component/lib.d.ts.map +0 -1
- package/dist/commonjs/component/lib.js.map +0 -1
- package/dist/commonjs/component/schema.d.ts.map +0 -1
- package/dist/commonjs/component/schema.js.map +0 -1
- package/dist/commonjs/package.json +0 -3
- package/dist/commonjs/react/index.d.ts.map +0 -1
- package/dist/commonjs/react/index.js.map +0 -1
- package/dist/esm/client/index.d.ts +0 -89
- package/dist/esm/client/index.d.ts.map +0 -1
- package/dist/esm/client/index.js.map +0 -1
- package/dist/esm/component/_generated/api.d.ts +0 -12
- package/dist/esm/component/_generated/api.d.ts.map +0 -1
- package/dist/esm/component/_generated/api.js +0 -22
- package/dist/esm/component/_generated/api.js.map +0 -1
- package/dist/esm/component/_generated/server.d.ts +0 -64
- package/dist/esm/component/_generated/server.d.ts.map +0 -1
- package/dist/esm/component/_generated/server.js +0 -74
- package/dist/esm/component/_generated/server.js.map +0 -1
- package/dist/esm/component/convex.config.d.ts +0 -3
- package/dist/esm/component/convex.config.d.ts.map +0 -1
- package/dist/esm/component/convex.config.js +0 -3
- package/dist/esm/component/convex.config.js.map +0 -1
- package/dist/esm/component/crons.d.ts +0 -3
- package/dist/esm/component/crons.d.ts.map +0 -1
- package/dist/esm/component/crons.js +0 -7
- package/dist/esm/component/crons.js.map +0 -1
- package/dist/esm/component/lib.d.ts +0 -21
- package/dist/esm/component/lib.d.ts.map +0 -1
- package/dist/esm/component/lib.js +0 -134
- package/dist/esm/component/lib.js.map +0 -1
- package/dist/esm/component/schema.d.ts +0 -23
- package/dist/esm/component/schema.d.ts.map +0 -1
- package/dist/esm/component/schema.js +0 -13
- package/dist/esm/component/schema.js.map +0 -1
- package/dist/esm/package.json +0 -3
- package/dist/esm/react/index.d.ts +0 -26
- package/dist/esm/react/index.d.ts.map +0 -1
- package/dist/esm/react/index.js +0 -136
- package/dist/esm/react/index.js.map +0 -1
- package/react/package.json +0 -5
- package/src/component/_generated/api.d.ts +0 -81
- package/src/component/_generated/server.js +0 -90
- /package/dist/{commonjs/component → component}/convex.config.d.ts +0 -0
- /package/dist/{commonjs/component → component}/convex.config.js +0 -0
- /package/dist/{commonjs/component → component}/crons.d.ts +0 -0
- /package/dist/{commonjs/component → component}/lib.d.ts +0 -0
- /package/dist/{commonjs/component → component}/schema.js +0 -0
- /package/src/component/_generated/{dataModel.d.ts → dataModel.ts} +0 -0
|
@@ -0,0 +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,EAAc,MAAM,eAAe,CAAC;AAE9C,MAAM,CAAC,MAAM,qBAAqB,GAAG,CAAC,CAAC,KAAK,CAC1C,CAAC,CAAC,OAAO,CAAC,SAAS,CAAC,EACpB,CAAC,CAAC,OAAO,CAAC,WAAW,CAAC,EACtB,CAAC,CAAC,OAAO,CAAC,MAAM,CAAC,EACjB,CAAC,CAAC,OAAO,CAAC,OAAO,CAAC,EAClB,CAAC,CAAC,OAAO,CAAC,SAAS,CAAC,CACrB,CAAC;AAGF,eAAe,YAAY,CAAC;IAC1B,OAAO,EAAE,WAAW,CAAC;QACnB,MAAM,EAAE,qBAAqB;KAC9B,CAAC,CAAC,KAAK,CAAC,UAAU,EAAE,CAAC,QAAQ,CAAC,CAAC;IAChC,MAAM,EAAE,WAAW,CAAC;QAClB,QAAQ,EAAE,CAAC,CAAC,EAAE,CAAC,SAAS,CAAC;QACzB,IAAI,EAAE,CAAC,CAAC,MAAM,EAAE;KACjB,CAAC,CAAC,KAAK,CAAC,UAAU,EAAE,CAAC,UAAU,CAAC,CAAC;CACnC,CAAC,CAAC"}
|
|
@@ -1,5 +1,5 @@
|
|
|
1
|
-
import { StreamBody, StreamId } from "../client";
|
|
2
|
-
import { FunctionReference } from "convex/server";
|
|
1
|
+
import type { StreamBody, StreamId } from "../client/index.js";
|
|
2
|
+
import type { FunctionReference } from "convex/server";
|
|
3
3
|
/**
|
|
4
4
|
* React hook for persistent text streaming.
|
|
5
5
|
*
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../src/react/index.ts"],"names":[],"mappings":"AAKA,OAAO,KAAK,EAAE,UAAU,EAAE,QAAQ,EAAE,MAAM,oBAAoB,CAAC;AAE/D,OAAO,KAAK,EAAE,iBAAiB,EAAE,MAAM,eAAe,CAAC;AAEvD;;;;;;;;;;;;;;;;GAgBG;AACH,wBAAgB,SAAS,CACvB,iBAAiB,EAAE,iBAAiB,CAClC,OAAO,EACP,QAAQ,EACR;IAAE,QAAQ,EAAE,MAAM,CAAA;CAAE,EACpB,UAAU,CACX,EACD,SAAS,EAAE,GAAG,EACd,MAAM,EAAE,OAAO,EACf,QAAQ,EAAE,QAAQ,GAAG,SAAS,EAC9B,IAAI,CAAC,EAAE;IAEL,SAAS,CAAC,EAAE,MAAM,GAAG,IAAI,CAAC;IAE1B,OAAO,CAAC,EAAE,MAAM,CAAC,MAAM,EAAE,MAAM,CAAC,CAAC;CAClC,cAkFF"}
|
|
@@ -1,9 +1,6 @@
|
|
|
1
1
|
"use client";
|
|
2
2
|
import { useQuery } from "convex/react";
|
|
3
3
|
import { useEffect, useMemo, useRef, useState } from "react";
|
|
4
|
-
if (typeof window === "undefined") {
|
|
5
|
-
throw new Error("this is frontend code, but it's running somewhere else!");
|
|
6
|
-
}
|
|
7
4
|
/**
|
|
8
5
|
* React hook for persistent text streaming.
|
|
9
6
|
*
|
|
@@ -36,7 +33,7 @@ export function useStream(getPersistentBody, streamUrl, driven, streamId, opts)
|
|
|
36
33
|
}
|
|
37
34
|
// Otherwise, we'll try to drive the stream and use the HTTP response.
|
|
38
35
|
return false;
|
|
39
|
-
}, [driven,
|
|
36
|
+
}, [driven, streamEnded]);
|
|
40
37
|
// console.log("usePersistence", usePersistence);
|
|
41
38
|
const persistentBody = useQuery(getPersistentBody, usePersistence && streamId ? { streamId } : "skip");
|
|
42
39
|
const [streamBody, setStreamBody] = useState("");
|
|
@@ -59,7 +56,15 @@ export function useStream(getPersistentBody, streamUrl, driven, streamId, opts)
|
|
|
59
56
|
streamStarted.current = true;
|
|
60
57
|
};
|
|
61
58
|
}
|
|
62
|
-
|
|
59
|
+
// eslint-disable-next-line react-hooks/exhaustive-deps
|
|
60
|
+
}, [
|
|
61
|
+
driven,
|
|
62
|
+
streamUrl,
|
|
63
|
+
streamId,
|
|
64
|
+
setStreamEnded,
|
|
65
|
+
streamStarted,
|
|
66
|
+
opts?.authToken,
|
|
67
|
+
]);
|
|
63
68
|
const body = useMemo(() => {
|
|
64
69
|
// console.log(
|
|
65
70
|
// "body info p vs. s",
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"index.js","sourceRoot":"","sources":["../../src/react/index.ts"],"names":[],"mappings":"AAAA,YAAY,CAAC;AAIb,OAAO,EAAE,QAAQ,EAAE,MAAM,cAAc,CAAC;AAExC,OAAO,EAAE,SAAS,E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,CAAC,CAAC;YACzC,OAAO,KAAK,CAAC;QACf,CAAC;IACH,CAAC;AACH,CAAC"}
|
package/package.json
CHANGED
|
@@ -7,7 +7,7 @@
|
|
|
7
7
|
"email": "support@convex.dev",
|
|
8
8
|
"url": "https://github.com/get-convex/persistent-text-streaming/issues"
|
|
9
9
|
},
|
|
10
|
-
"version": "0.
|
|
10
|
+
"version": "0.3.0",
|
|
11
11
|
"license": "Apache-2.0",
|
|
12
12
|
"keywords": [
|
|
13
13
|
"convex",
|
|
@@ -15,77 +15,87 @@
|
|
|
15
15
|
],
|
|
16
16
|
"type": "module",
|
|
17
17
|
"scripts": {
|
|
18
|
-
"
|
|
19
|
-
"
|
|
20
|
-
"
|
|
21
|
-
"dev": "
|
|
22
|
-
"
|
|
23
|
-
"
|
|
24
|
-
"
|
|
25
|
-
"
|
|
26
|
-
"
|
|
27
|
-
"
|
|
28
|
-
"test": "vitest run",
|
|
18
|
+
"dev": "run-p -r 'dev:*'",
|
|
19
|
+
"dev:backend": "convex dev --typecheck-components",
|
|
20
|
+
"dev:frontend": "cd example && vite --clearScreen false",
|
|
21
|
+
"dev:build": "chokidar 'tsconfig*.json' 'src/**/*.ts' -i '**/*.test.ts' -c 'convex codegen --component-dir ./src/component && npm run build' --initial",
|
|
22
|
+
"predev": "npm run dev:backend -- --until-success",
|
|
23
|
+
"clean": "rm -rf dist *.tsbuildinfo",
|
|
24
|
+
"build": "tsc --project ./tsconfig.build.json",
|
|
25
|
+
"typecheck": "tsc --noEmit && tsc -p example && tsc -p example/convex",
|
|
26
|
+
"lint": "eslint .",
|
|
27
|
+
"all": "run-p -r 'dev:*' 'test:watch'",
|
|
28
|
+
"test": "vitest run --typecheck",
|
|
29
|
+
"test:watch": "vitest --typecheck --clearScreen false",
|
|
29
30
|
"test:debug": "vitest --inspect-brk --no-file-parallelism",
|
|
30
|
-
"test:coverage": "vitest run --coverage --coverage.reporter=text"
|
|
31
|
+
"test:coverage": "vitest run --coverage --coverage.reporter=text",
|
|
32
|
+
"prepare": "npm run build",
|
|
33
|
+
"alpha": "npm run clean && npm ci && run-p test lint typecheck && npm version prerelease --preid alpha && npm publish --tag alpha && git push --tags",
|
|
34
|
+
"release": "npm run clean && npm ci && run-p test lint typecheck && npm version patch && npm publish && git push --tags",
|
|
35
|
+
"version": "pbcopy <<<$npm_package_version; vim CHANGELOG.md && prettier -w CHANGELOG.md && git add CHANGELOG.md"
|
|
31
36
|
},
|
|
32
37
|
"files": [
|
|
33
38
|
"dist",
|
|
34
|
-
"src"
|
|
35
|
-
"react"
|
|
39
|
+
"src"
|
|
36
40
|
],
|
|
37
41
|
"exports": {
|
|
38
42
|
"./package.json": "./package.json",
|
|
39
43
|
".": {
|
|
40
|
-
"
|
|
41
|
-
|
|
42
|
-
"types": "./dist/esm/client/index.d.ts",
|
|
43
|
-
"default": "./dist/esm/client/index.js"
|
|
44
|
-
},
|
|
45
|
-
"require": {
|
|
46
|
-
"@convex-dev/component-source": "./src/client/index.ts",
|
|
47
|
-
"types": "./dist/commonjs/client/index.d.ts",
|
|
48
|
-
"default": "./dist/commonjs/client/index.js"
|
|
49
|
-
}
|
|
44
|
+
"types": "./dist/client/index.d.ts",
|
|
45
|
+
"default": "./dist/client/index.js"
|
|
50
46
|
},
|
|
51
47
|
"./react": {
|
|
52
|
-
"
|
|
53
|
-
|
|
54
|
-
|
|
55
|
-
|
|
56
|
-
|
|
57
|
-
"
|
|
58
|
-
"@convex-dev/component-source": "./src/react/index.ts",
|
|
59
|
-
"types": "./dist/commonjs/react/index.d.ts",
|
|
60
|
-
"default": "./dist/commonjs/react/index.js"
|
|
61
|
-
}
|
|
48
|
+
"types": "./dist/react/index.d.ts",
|
|
49
|
+
"default": "./dist/react/index.js"
|
|
50
|
+
},
|
|
51
|
+
"./test": "./src/test.ts",
|
|
52
|
+
"./_generated/component.js": {
|
|
53
|
+
"types": "./dist/component/_generated/component.d.ts"
|
|
62
54
|
},
|
|
63
55
|
"./convex.config": {
|
|
64
|
-
"
|
|
65
|
-
|
|
66
|
-
|
|
67
|
-
|
|
68
|
-
|
|
56
|
+
"types": "./dist/component/convex.config.d.ts",
|
|
57
|
+
"default": "./dist/component/convex.config.js"
|
|
58
|
+
},
|
|
59
|
+
"./convex.config.js": {
|
|
60
|
+
"types": "./dist/component/convex.config.d.ts",
|
|
61
|
+
"default": "./dist/component/convex.config.js"
|
|
69
62
|
}
|
|
70
63
|
},
|
|
71
64
|
"peerDependencies": {
|
|
72
|
-
"convex": "
|
|
65
|
+
"convex": "^1.24.8",
|
|
73
66
|
"react": "~18.3.1 || ^19.0.0",
|
|
74
67
|
"react-dom": "~18.3.1 || ^19.0.0"
|
|
75
68
|
},
|
|
76
69
|
"devDependencies": {
|
|
77
|
-
"@
|
|
78
|
-
"@
|
|
79
|
-
"@
|
|
80
|
-
"
|
|
81
|
-
"
|
|
82
|
-
"
|
|
83
|
-
"
|
|
84
|
-
"
|
|
85
|
-
"
|
|
86
|
-
"
|
|
70
|
+
"@edge-runtime/vm": "5.0.0",
|
|
71
|
+
"@eslint/eslintrc": "3.3.1",
|
|
72
|
+
"@eslint/js": "9.38.0",
|
|
73
|
+
"@tailwindcss/vite": "4.1.16",
|
|
74
|
+
"@types/node": "20.19.24",
|
|
75
|
+
"@types/react": "19.2.2",
|
|
76
|
+
"@types/react-dom": "19.2.2",
|
|
77
|
+
"@vitejs/plugin-react": "5.1.0",
|
|
78
|
+
"chokidar-cli": "3.0.0",
|
|
79
|
+
"clsx": "2.1.1",
|
|
80
|
+
"convex": "1.29.0",
|
|
81
|
+
"convex-test": "0.0.38",
|
|
82
|
+
"eslint": "9.39.1",
|
|
83
|
+
"eslint-plugin-react-hooks": "7.0.1",
|
|
84
|
+
"eslint-plugin-react-refresh": "0.4.24",
|
|
85
|
+
"globals": "15.15.0",
|
|
86
|
+
"npm-run-all2": "8.0.4",
|
|
87
|
+
"openai": "6.8.0",
|
|
88
|
+
"prettier": "3.6.2",
|
|
89
|
+
"react": "19.2.0",
|
|
90
|
+
"react-dom": "19.2.0",
|
|
91
|
+
"react-markdown": "10.1.0",
|
|
92
|
+
"tailwind-merge": "3.3.1",
|
|
93
|
+
"tailwindcss": "4.1.16",
|
|
94
|
+
"typescript": "5.9.3",
|
|
95
|
+
"typescript-eslint": "8.46.2",
|
|
96
|
+
"vite": "6.4.1",
|
|
97
|
+
"vitest": "3.2.4"
|
|
87
98
|
},
|
|
88
|
-
"
|
|
89
|
-
"
|
|
90
|
-
"module": "./dist/esm/client/index.js"
|
|
99
|
+
"types": "./dist/client/index.d.ts",
|
|
100
|
+
"module": "./dist/client/index.js"
|
|
91
101
|
}
|
package/src/client/index.ts
CHANGED
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import {
|
|
1
|
+
import type {
|
|
2
2
|
Expand,
|
|
3
3
|
FunctionReference,
|
|
4
4
|
GenericActionCtx,
|
|
@@ -6,9 +6,9 @@ import {
|
|
|
6
6
|
GenericMutationCtx,
|
|
7
7
|
GenericQueryCtx,
|
|
8
8
|
} from "convex/server";
|
|
9
|
-
import {
|
|
10
|
-
import { api } from "../component/_generated/api";
|
|
11
|
-
import { StreamStatus } from "../component/schema";
|
|
9
|
+
import { v, type GenericId } from "convex/values";
|
|
10
|
+
import { api } from "../component/_generated/api.js";
|
|
11
|
+
import type { StreamStatus } from "../component/schema.js";
|
|
12
12
|
|
|
13
13
|
export type StreamId = string & { __isStreamId: true };
|
|
14
14
|
export const StreamIdValidator = v.string();
|
|
@@ -22,7 +22,7 @@ export type StreamWriter<A extends GenericActionCtx<GenericDataModel>> = (
|
|
|
22
22
|
ctx: A,
|
|
23
23
|
request: Request,
|
|
24
24
|
streamId: StreamId,
|
|
25
|
-
chunkAppender: ChunkAppender
|
|
25
|
+
chunkAppender: ChunkAppender,
|
|
26
26
|
) => Promise<void>;
|
|
27
27
|
|
|
28
28
|
// TODO -- make more flexible. # of bytes, etc?
|
|
@@ -34,7 +34,7 @@ const hasDelimeter = (text: string) => {
|
|
|
34
34
|
export class PersistentTextStreaming {
|
|
35
35
|
constructor(
|
|
36
36
|
public component: UseApi<typeof api>,
|
|
37
|
-
public options?: object
|
|
37
|
+
public options?: object,
|
|
38
38
|
) {}
|
|
39
39
|
|
|
40
40
|
/**
|
|
@@ -75,11 +75,11 @@ export class PersistentTextStreaming {
|
|
|
75
75
|
*/
|
|
76
76
|
async getStreamBody(
|
|
77
77
|
ctx: RunQueryCtx,
|
|
78
|
-
streamId: StreamId
|
|
78
|
+
streamId: StreamId,
|
|
79
79
|
): Promise<StreamBody> {
|
|
80
80
|
const { text, status } = await ctx.runQuery(
|
|
81
81
|
this.component.lib.getStreamText,
|
|
82
|
-
{ streamId }
|
|
82
|
+
{ streamId },
|
|
83
83
|
);
|
|
84
84
|
return { text, status: status as StreamStatus };
|
|
85
85
|
}
|
|
@@ -109,7 +109,7 @@ export class PersistentTextStreaming {
|
|
|
109
109
|
ctx: A,
|
|
110
110
|
request: Request,
|
|
111
111
|
streamId: StreamId,
|
|
112
|
-
streamWriter: StreamWriter<A
|
|
112
|
+
streamWriter: StreamWriter<A>,
|
|
113
113
|
) {
|
|
114
114
|
const streamState = await ctx.runQuery(this.component.lib.getStreamStatus, {
|
|
115
115
|
streamId,
|
|
@@ -122,7 +122,8 @@ export class PersistentTextStreaming {
|
|
|
122
122
|
}
|
|
123
123
|
// Create a TransformStream to handle streaming data
|
|
124
124
|
const { readable, writable } = new TransformStream();
|
|
125
|
-
let writer =
|
|
125
|
+
let writer =
|
|
126
|
+
writable.getWriter() as WritableStreamDefaultWriter<Uint8Array> | null;
|
|
126
127
|
const textEncoder = new TextEncoder();
|
|
127
128
|
let pending = "";
|
|
128
129
|
|
|
@@ -134,7 +135,9 @@ export class PersistentTextStreaming {
|
|
|
134
135
|
await writer.write(textEncoder.encode(text));
|
|
135
136
|
} catch (e) {
|
|
136
137
|
console.error("Error writing to stream", e);
|
|
137
|
-
console.error(
|
|
138
|
+
console.error(
|
|
139
|
+
"Will skip writing to stream but continue database updates",
|
|
140
|
+
);
|
|
138
141
|
writer = null;
|
|
139
142
|
}
|
|
140
143
|
}
|
|
@@ -175,7 +178,7 @@ export class PersistentTextStreaming {
|
|
|
175
178
|
ctx: RunMutationCtx,
|
|
176
179
|
streamId: StreamId,
|
|
177
180
|
text: string,
|
|
178
|
-
final: boolean
|
|
181
|
+
final: boolean,
|
|
179
182
|
) {
|
|
180
183
|
await ctx.runMutation(this.component.lib.addChunk, {
|
|
181
184
|
streamId,
|
|
@@ -188,7 +191,7 @@ export class PersistentTextStreaming {
|
|
|
188
191
|
private async setStreamStatus(
|
|
189
192
|
ctx: RunMutationCtx,
|
|
190
193
|
streamId: StreamId,
|
|
191
|
-
status: StreamStatus
|
|
194
|
+
status: StreamStatus,
|
|
192
195
|
) {
|
|
193
196
|
await ctx.runMutation(this.component.lib.setStreamStatus, {
|
|
194
197
|
streamId,
|
|
@@ -0,0 +1,52 @@
|
|
|
1
|
+
/* eslint-disable */
|
|
2
|
+
/**
|
|
3
|
+
* Generated `api` utility.
|
|
4
|
+
*
|
|
5
|
+
* THIS CODE IS AUTOMATICALLY GENERATED.
|
|
6
|
+
*
|
|
7
|
+
* To regenerate, run `npx convex dev`.
|
|
8
|
+
* @module
|
|
9
|
+
*/
|
|
10
|
+
|
|
11
|
+
import type * as crons from "../crons.js";
|
|
12
|
+
import type * as lib from "../lib.js";
|
|
13
|
+
|
|
14
|
+
import type {
|
|
15
|
+
ApiFromModules,
|
|
16
|
+
FilterApi,
|
|
17
|
+
FunctionReference,
|
|
18
|
+
} from "convex/server";
|
|
19
|
+
import { anyApi, componentsGeneric } from "convex/server";
|
|
20
|
+
|
|
21
|
+
const fullApi: ApiFromModules<{
|
|
22
|
+
crons: typeof crons;
|
|
23
|
+
lib: typeof lib;
|
|
24
|
+
}> = anyApi as any;
|
|
25
|
+
|
|
26
|
+
/**
|
|
27
|
+
* A utility for referencing Convex functions in your app's public API.
|
|
28
|
+
*
|
|
29
|
+
* Usage:
|
|
30
|
+
* ```js
|
|
31
|
+
* const myFunctionReference = api.myModule.myFunction;
|
|
32
|
+
* ```
|
|
33
|
+
*/
|
|
34
|
+
export const api: FilterApi<
|
|
35
|
+
typeof fullApi,
|
|
36
|
+
FunctionReference<any, "public">
|
|
37
|
+
> = anyApi as any;
|
|
38
|
+
|
|
39
|
+
/**
|
|
40
|
+
* A utility for referencing Convex functions in your app's internal API.
|
|
41
|
+
*
|
|
42
|
+
* Usage:
|
|
43
|
+
* ```js
|
|
44
|
+
* const myFunctionReference = internal.myModule.myFunction;
|
|
45
|
+
* ```
|
|
46
|
+
*/
|
|
47
|
+
export const internal: FilterApi<
|
|
48
|
+
typeof fullApi,
|
|
49
|
+
FunctionReference<any, "internal">
|
|
50
|
+
> = anyApi as any;
|
|
51
|
+
|
|
52
|
+
export const components = componentsGeneric() as unknown as {};
|
|
@@ -0,0 +1,63 @@
|
|
|
1
|
+
/* eslint-disable */
|
|
2
|
+
/**
|
|
3
|
+
* Generated `ComponentApi` utility.
|
|
4
|
+
*
|
|
5
|
+
* THIS CODE IS AUTOMATICALLY GENERATED.
|
|
6
|
+
*
|
|
7
|
+
* To regenerate, run `npx convex dev`.
|
|
8
|
+
* @module
|
|
9
|
+
*/
|
|
10
|
+
|
|
11
|
+
import type { FunctionReference } from "convex/server";
|
|
12
|
+
|
|
13
|
+
/**
|
|
14
|
+
* A utility for referencing a Convex component's exposed API.
|
|
15
|
+
*
|
|
16
|
+
* Useful when expecting a parameter like `components.myComponent`.
|
|
17
|
+
* Usage:
|
|
18
|
+
* ```ts
|
|
19
|
+
* async function myFunction(ctx: QueryCtx, component: ComponentApi) {
|
|
20
|
+
* return ctx.runQuery(component.someFile.someQuery, { ...args });
|
|
21
|
+
* }
|
|
22
|
+
* ```
|
|
23
|
+
*/
|
|
24
|
+
export type ComponentApi<Name extends string | undefined = string | undefined> =
|
|
25
|
+
{
|
|
26
|
+
lib: {
|
|
27
|
+
addChunk: FunctionReference<
|
|
28
|
+
"mutation",
|
|
29
|
+
"internal",
|
|
30
|
+
{ final: boolean; streamId: string; text: string },
|
|
31
|
+
any,
|
|
32
|
+
Name
|
|
33
|
+
>;
|
|
34
|
+
createStream: FunctionReference<"mutation", "internal", {}, any, Name>;
|
|
35
|
+
getStreamStatus: FunctionReference<
|
|
36
|
+
"query",
|
|
37
|
+
"internal",
|
|
38
|
+
{ streamId: string },
|
|
39
|
+
"pending" | "streaming" | "done" | "error" | "timeout",
|
|
40
|
+
Name
|
|
41
|
+
>;
|
|
42
|
+
getStreamText: FunctionReference<
|
|
43
|
+
"query",
|
|
44
|
+
"internal",
|
|
45
|
+
{ streamId: string },
|
|
46
|
+
{
|
|
47
|
+
status: "pending" | "streaming" | "done" | "error" | "timeout";
|
|
48
|
+
text: string;
|
|
49
|
+
},
|
|
50
|
+
Name
|
|
51
|
+
>;
|
|
52
|
+
setStreamStatus: FunctionReference<
|
|
53
|
+
"mutation",
|
|
54
|
+
"internal",
|
|
55
|
+
{
|
|
56
|
+
status: "pending" | "streaming" | "done" | "error" | "timeout";
|
|
57
|
+
streamId: string;
|
|
58
|
+
},
|
|
59
|
+
any,
|
|
60
|
+
Name
|
|
61
|
+
>;
|
|
62
|
+
};
|
|
63
|
+
};
|
|
@@ -0,0 +1,161 @@
|
|
|
1
|
+
/* eslint-disable */
|
|
2
|
+
/**
|
|
3
|
+
* Generated utilities for implementing server-side Convex query and mutation functions.
|
|
4
|
+
*
|
|
5
|
+
* THIS CODE IS AUTOMATICALLY GENERATED.
|
|
6
|
+
*
|
|
7
|
+
* To regenerate, run `npx convex dev`.
|
|
8
|
+
* @module
|
|
9
|
+
*/
|
|
10
|
+
|
|
11
|
+
import type {
|
|
12
|
+
ActionBuilder,
|
|
13
|
+
HttpActionBuilder,
|
|
14
|
+
MutationBuilder,
|
|
15
|
+
QueryBuilder,
|
|
16
|
+
GenericActionCtx,
|
|
17
|
+
GenericMutationCtx,
|
|
18
|
+
GenericQueryCtx,
|
|
19
|
+
GenericDatabaseReader,
|
|
20
|
+
GenericDatabaseWriter,
|
|
21
|
+
} from "convex/server";
|
|
22
|
+
import {
|
|
23
|
+
actionGeneric,
|
|
24
|
+
httpActionGeneric,
|
|
25
|
+
queryGeneric,
|
|
26
|
+
mutationGeneric,
|
|
27
|
+
internalActionGeneric,
|
|
28
|
+
internalMutationGeneric,
|
|
29
|
+
internalQueryGeneric,
|
|
30
|
+
} from "convex/server";
|
|
31
|
+
import type { DataModel } from "./dataModel.js";
|
|
32
|
+
|
|
33
|
+
/**
|
|
34
|
+
* Define a query in this Convex app's public API.
|
|
35
|
+
*
|
|
36
|
+
* This function will be allowed to read your Convex database and will be accessible from the client.
|
|
37
|
+
*
|
|
38
|
+
* @param func - The query function. It receives a {@link QueryCtx} as its first argument.
|
|
39
|
+
* @returns The wrapped query. Include this as an `export` to name it and make it accessible.
|
|
40
|
+
*/
|
|
41
|
+
export const query: QueryBuilder<DataModel, "public"> = queryGeneric;
|
|
42
|
+
|
|
43
|
+
/**
|
|
44
|
+
* Define a query that is only accessible from other Convex functions (but not from the client).
|
|
45
|
+
*
|
|
46
|
+
* This function will be allowed to read from your Convex database. It will not be accessible from the client.
|
|
47
|
+
*
|
|
48
|
+
* @param func - The query function. It receives a {@link QueryCtx} as its first argument.
|
|
49
|
+
* @returns The wrapped query. Include this as an `export` to name it and make it accessible.
|
|
50
|
+
*/
|
|
51
|
+
export const internalQuery: QueryBuilder<DataModel, "internal"> =
|
|
52
|
+
internalQueryGeneric;
|
|
53
|
+
|
|
54
|
+
/**
|
|
55
|
+
* Define a mutation in this Convex app's public API.
|
|
56
|
+
*
|
|
57
|
+
* This function will be allowed to modify your Convex database and will be accessible from the client.
|
|
58
|
+
*
|
|
59
|
+
* @param func - The mutation function. It receives a {@link MutationCtx} as its first argument.
|
|
60
|
+
* @returns The wrapped mutation. Include this as an `export` to name it and make it accessible.
|
|
61
|
+
*/
|
|
62
|
+
export const mutation: MutationBuilder<DataModel, "public"> = mutationGeneric;
|
|
63
|
+
|
|
64
|
+
/**
|
|
65
|
+
* Define a mutation that is only accessible from other Convex functions (but not from the client).
|
|
66
|
+
*
|
|
67
|
+
* This function will be allowed to modify your Convex database. It will not be accessible from the client.
|
|
68
|
+
*
|
|
69
|
+
* @param func - The mutation function. It receives a {@link MutationCtx} as its first argument.
|
|
70
|
+
* @returns The wrapped mutation. Include this as an `export` to name it and make it accessible.
|
|
71
|
+
*/
|
|
72
|
+
export const internalMutation: MutationBuilder<DataModel, "internal"> =
|
|
73
|
+
internalMutationGeneric;
|
|
74
|
+
|
|
75
|
+
/**
|
|
76
|
+
* Define an action in this Convex app's public API.
|
|
77
|
+
*
|
|
78
|
+
* An action is a function which can execute any JavaScript code, including non-deterministic
|
|
79
|
+
* code and code with side-effects, like calling third-party services.
|
|
80
|
+
* They can be run in Convex's JavaScript environment or in Node.js using the "use node" directive.
|
|
81
|
+
* They can interact with the database indirectly by calling queries and mutations using the {@link ActionCtx}.
|
|
82
|
+
*
|
|
83
|
+
* @param func - The action. It receives an {@link ActionCtx} as its first argument.
|
|
84
|
+
* @returns The wrapped action. Include this as an `export` to name it and make it accessible.
|
|
85
|
+
*/
|
|
86
|
+
export const action: ActionBuilder<DataModel, "public"> = actionGeneric;
|
|
87
|
+
|
|
88
|
+
/**
|
|
89
|
+
* Define an action that is only accessible from other Convex functions (but not from the client).
|
|
90
|
+
*
|
|
91
|
+
* @param func - The function. It receives an {@link ActionCtx} as its first argument.
|
|
92
|
+
* @returns The wrapped function. Include this as an `export` to name it and make it accessible.
|
|
93
|
+
*/
|
|
94
|
+
export const internalAction: ActionBuilder<DataModel, "internal"> =
|
|
95
|
+
internalActionGeneric;
|
|
96
|
+
|
|
97
|
+
/**
|
|
98
|
+
* Define an HTTP action.
|
|
99
|
+
*
|
|
100
|
+
* The wrapped function will be used to respond to HTTP requests received
|
|
101
|
+
* by a Convex deployment if the requests matches the path and method where
|
|
102
|
+
* this action is routed. Be sure to route your httpAction in `convex/http.js`.
|
|
103
|
+
*
|
|
104
|
+
* @param func - The function. It receives an {@link ActionCtx} as its first argument
|
|
105
|
+
* and a Fetch API `Request` object as its second.
|
|
106
|
+
* @returns The wrapped function. Import this function from `convex/http.js` and route it to hook it up.
|
|
107
|
+
*/
|
|
108
|
+
export const httpAction: HttpActionBuilder = httpActionGeneric;
|
|
109
|
+
|
|
110
|
+
type GenericCtx =
|
|
111
|
+
| GenericActionCtx<DataModel>
|
|
112
|
+
| GenericMutationCtx<DataModel>
|
|
113
|
+
| GenericQueryCtx<DataModel>;
|
|
114
|
+
|
|
115
|
+
/**
|
|
116
|
+
* A set of services for use within Convex query functions.
|
|
117
|
+
*
|
|
118
|
+
* The query context is passed as the first argument to any Convex query
|
|
119
|
+
* function run on the server.
|
|
120
|
+
*
|
|
121
|
+
* If you're using code generation, use the `QueryCtx` type in `convex/_generated/server.d.ts` instead.
|
|
122
|
+
*/
|
|
123
|
+
export type QueryCtx = GenericQueryCtx<DataModel>;
|
|
124
|
+
|
|
125
|
+
/**
|
|
126
|
+
* A set of services for use within Convex mutation functions.
|
|
127
|
+
*
|
|
128
|
+
* The mutation context is passed as the first argument to any Convex mutation
|
|
129
|
+
* function run on the server.
|
|
130
|
+
*
|
|
131
|
+
* If you're using code generation, use the `MutationCtx` type in `convex/_generated/server.d.ts` instead.
|
|
132
|
+
*/
|
|
133
|
+
export type MutationCtx = GenericMutationCtx<DataModel>;
|
|
134
|
+
|
|
135
|
+
/**
|
|
136
|
+
* A set of services for use within Convex action functions.
|
|
137
|
+
*
|
|
138
|
+
* The action context is passed as the first argument to any Convex action
|
|
139
|
+
* function run on the server.
|
|
140
|
+
*/
|
|
141
|
+
export type ActionCtx = GenericActionCtx<DataModel>;
|
|
142
|
+
|
|
143
|
+
/**
|
|
144
|
+
* An interface to read from the database within Convex query functions.
|
|
145
|
+
*
|
|
146
|
+
* The two entry points are {@link DatabaseReader.get}, which fetches a single
|
|
147
|
+
* document by its {@link Id}, or {@link DatabaseReader.query}, which starts
|
|
148
|
+
* building a query.
|
|
149
|
+
*/
|
|
150
|
+
export type DatabaseReader = GenericDatabaseReader<DataModel>;
|
|
151
|
+
|
|
152
|
+
/**
|
|
153
|
+
* An interface to read from and write to the database within Convex mutation
|
|
154
|
+
* functions.
|
|
155
|
+
*
|
|
156
|
+
* Convex guarantees that all writes within a single mutation are
|
|
157
|
+
* executed atomically, so you never have to worry about partial writes leaving
|
|
158
|
+
* your data in an inconsistent state. See [the Convex Guide](https://docs.convex.dev/understanding/convex-fundamentals/functions#atomicity-and-optimistic-concurrency-control)
|
|
159
|
+
* for the guarantees Convex provides your functions.
|
|
160
|
+
*/
|
|
161
|
+
export type DatabaseWriter = GenericDatabaseWriter<DataModel>;
|
package/src/component/crons.ts
CHANGED
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
import { cronJobs } from "convex/server";
|
|
2
|
-
import { internal } from "./_generated/api";
|
|
2
|
+
import { internal } from "./_generated/api.js";
|
|
3
3
|
|
|
4
4
|
const crons = cronJobs();
|
|
5
5
|
|
|
@@ -7,7 +7,7 @@ const crons = cronJobs();
|
|
|
7
7
|
crons.interval(
|
|
8
8
|
"cleanup expired streams",
|
|
9
9
|
{ minutes: 1 },
|
|
10
|
-
internal.lib.cleanupExpiredStreams
|
|
10
|
+
internal.lib.cleanupExpiredStreams,
|
|
11
11
|
);
|
|
12
12
|
|
|
13
13
|
export default crons;
|
package/src/component/lib.ts
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
import { v } from "convex/values";
|
|
2
|
-
import { internalMutation, mutation, query } from "./_generated/server";
|
|
3
|
-
import { streamStatusValidator } from "./schema";
|
|
2
|
+
import { internalMutation, mutation, query } from "./_generated/server.js";
|
|
3
|
+
import { streamStatusValidator } from "./schema.js";
|
|
4
4
|
|
|
5
5
|
// Create a new stream with zero chunks.
|
|
6
6
|
export const createStream = mutation({
|
|
@@ -56,7 +56,7 @@ export const setStreamStatus = mutation({
|
|
|
56
56
|
v.literal("streaming"),
|
|
57
57
|
v.literal("done"),
|
|
58
58
|
v.literal("error"),
|
|
59
|
-
v.literal("timeout")
|
|
59
|
+
v.literal("timeout"),
|
|
60
60
|
),
|
|
61
61
|
},
|
|
62
62
|
handler: async (ctx, args) => {
|
|
@@ -67,7 +67,7 @@ export const setStreamStatus = mutation({
|
|
|
67
67
|
if (stream.status !== "pending" && stream.status !== "streaming") {
|
|
68
68
|
console.log(
|
|
69
69
|
"Stream is already finalized; ignoring status change",
|
|
70
|
-
stream
|
|
70
|
+
stream,
|
|
71
71
|
);
|
|
72
72
|
return;
|
|
73
73
|
}
|
package/src/component/schema.ts
CHANGED
|
@@ -1,12 +1,12 @@
|
|
|
1
1
|
import { defineSchema, defineTable } from "convex/server";
|
|
2
|
-
import {
|
|
2
|
+
import { v, type Infer } from "convex/values";
|
|
3
3
|
|
|
4
4
|
export const streamStatusValidator = v.union(
|
|
5
5
|
v.literal("pending"),
|
|
6
6
|
v.literal("streaming"),
|
|
7
7
|
v.literal("done"),
|
|
8
8
|
v.literal("error"),
|
|
9
|
-
v.literal("timeout")
|
|
9
|
+
v.literal("timeout"),
|
|
10
10
|
);
|
|
11
11
|
export type StreamStatus = Infer<typeof streamStatusValidator>;
|
|
12
12
|
|