@langchain/langgraph-ui 0.0.20-dev.2 → 0.0.21
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/dist/api.d.mts +26 -4
- package/dist/api.mjs +23 -14
- package/package.json +1 -1
package/dist/api.d.mts
CHANGED
|
@@ -1,6 +1,28 @@
|
|
|
1
|
-
|
|
1
|
+
import { z } from "zod";
|
|
2
|
+
declare const ConfigSchema: z.ZodObject<{
|
|
3
|
+
shared: z.ZodOptional<z.ZodArray<z.ZodString, "many">>;
|
|
4
|
+
}, "strip", z.ZodTypeAny, {
|
|
5
|
+
shared?: string[];
|
|
6
|
+
}, {
|
|
7
|
+
shared?: string[];
|
|
8
|
+
}>;
|
|
9
|
+
declare const DefsSchema: z.ZodRecord<z.ZodString, z.ZodString>;
|
|
10
|
+
interface BuildEnvType {
|
|
11
|
+
cwd?: string;
|
|
12
|
+
defs?: z.infer<typeof DefsSchema>;
|
|
13
|
+
config?: z.infer<typeof ConfigSchema>;
|
|
14
|
+
}
|
|
15
|
+
interface BuildOptionsType extends BuildEnvType {
|
|
2
16
|
output: string;
|
|
3
|
-
}
|
|
4
|
-
export declare function
|
|
17
|
+
}
|
|
18
|
+
export declare function build(options: BuildOptionsType): Promise<void>;
|
|
19
|
+
type WatchOptionsType = ({
|
|
5
20
|
output: string;
|
|
6
|
-
}
|
|
21
|
+
} | {
|
|
22
|
+
onOutput: (graphId: string, result: {
|
|
23
|
+
basename: string;
|
|
24
|
+
contents: Uint8Array;
|
|
25
|
+
}[]) => void;
|
|
26
|
+
}) & BuildEnvType;
|
|
27
|
+
export declare function watch(options: WatchOptionsType): Promise<void>;
|
|
28
|
+
export {};
|
package/dist/api.mjs
CHANGED
|
@@ -2,21 +2,21 @@ import { z } from "zod";
|
|
|
2
2
|
import * as fs from "node:fs/promises";
|
|
3
3
|
import * as path from "node:path";
|
|
4
4
|
import * as bundler from "./bundler.mjs";
|
|
5
|
-
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
.parse(JSON.parse(process.env.LANGGRAPH_UI_CONFIG || "{}"));
|
|
5
|
+
const ConfigSchema = z.object({ shared: z.array(z.string()).optional() });
|
|
6
|
+
const DefsSchema = z.record(z.string(), z.string());
|
|
7
|
+
function getBuildEnv(options) {
|
|
8
|
+
const cwd = options.cwd ?? process.cwd();
|
|
9
|
+
const defs = options.defs ??
|
|
10
|
+
DefsSchema.parse(JSON.parse(process.env.LANGGRAPH_UI || "{}"));
|
|
11
|
+
const config = options.config ??
|
|
12
|
+
ConfigSchema.parse(JSON.parse(process.env.LANGGRAPH_UI_CONFIG || "{}"));
|
|
13
|
+
return { cwd, defs, config };
|
|
14
|
+
}
|
|
15
|
+
export async function build(options) {
|
|
16
|
+
const { cwd, defs, config } = getBuildEnv(options);
|
|
13
17
|
const fullPath = path.resolve(cwd, options.output);
|
|
14
18
|
const publicPath = path.resolve(fullPath, "public");
|
|
15
19
|
const schemasPath = path.resolve(fullPath, "schemas.json");
|
|
16
|
-
return { cwd, defs, config, publicPath, schemasPath };
|
|
17
|
-
}
|
|
18
|
-
export async function build(options) {
|
|
19
|
-
const { cwd, defs, config, publicPath, schemasPath } = getBuildContext(options);
|
|
20
20
|
const schemas = {};
|
|
21
21
|
await Promise.all(Object.entries(defs).map(async ([graphId, userPath]) => {
|
|
22
22
|
const folder = path.resolve(publicPath, graphId);
|
|
@@ -34,9 +34,18 @@ export async function build(options) {
|
|
|
34
34
|
});
|
|
35
35
|
}
|
|
36
36
|
export async function watch(options) {
|
|
37
|
-
const { cwd,
|
|
38
|
-
|
|
37
|
+
const { cwd, config, defs } = getBuildEnv(options);
|
|
38
|
+
if ("onOutput" in options) {
|
|
39
|
+
await Promise.all(Object.entries(defs).map(async ([graphId, userPath]) => {
|
|
40
|
+
await bundler.watch(graphId, { cwd, config, userPath }, (files) => options.onOutput(graphId, files));
|
|
41
|
+
}));
|
|
42
|
+
return;
|
|
43
|
+
}
|
|
44
|
+
const fullPath = path.resolve(cwd, options.output);
|
|
45
|
+
const publicPath = path.resolve(fullPath, "public");
|
|
46
|
+
const schemasPath = path.resolve(fullPath, "schemas.json");
|
|
39
47
|
let promiseSeq = Promise.resolve();
|
|
48
|
+
const schemas = {};
|
|
40
49
|
await Promise.all(Object.entries(defs).map(async ([graphId, userPath]) => {
|
|
41
50
|
const folder = path.resolve(publicPath, graphId);
|
|
42
51
|
await fs.mkdir(folder, { recursive: true });
|