@langchain/langgraph-ui 0.0.20-dev.1 → 0.0.20

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 CHANGED
@@ -1,6 +1,28 @@
1
- export declare function build(options: {
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
- }): Promise<void>;
4
- export declare function watch(options: {
17
+ }
18
+ export declare function build(options: BuildOptionsType): Promise<void>;
19
+ type WatchOptionsType = ({
5
20
  output: string;
6
- }): Promise<void>;
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,17 +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
+ 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
+ }
5
15
  export async function build(options) {
6
- const cwd = process.cwd();
7
- const defs = z
8
- .record(z.string(), z.string())
9
- .parse(JSON.parse(process.env.LANGGRAPH_UI || "{}"));
10
- const config = z
11
- .object({ shared: z.array(z.string()).optional() })
12
- .parse(JSON.parse(process.env.LANGGRAPH_UI_CONFIG || "{}"));
16
+ const { cwd, defs, config } = getBuildEnv(options);
13
17
  const fullPath = path.resolve(cwd, options.output);
14
- const publicPath = path.resolve(fullPath, "ui");
15
- const schemasPath = path.resolve(fullPath, "client.ui.schemas.json");
18
+ const publicPath = path.resolve(fullPath, "public");
19
+ const schemasPath = path.resolve(fullPath, "schemas.json");
16
20
  const schemas = {};
17
21
  await Promise.all(Object.entries(defs).map(async ([graphId, userPath]) => {
18
22
  const folder = path.resolve(publicPath, graphId);
@@ -30,18 +34,18 @@ export async function build(options) {
30
34
  });
31
35
  }
32
36
  export async function watch(options) {
33
- const cwd = process.cwd();
34
- const defs = z
35
- .record(z.string(), z.string())
36
- .parse(JSON.parse(process.env.LANGGRAPH_UI || "{}"));
37
- const config = z
38
- .object({ shared: z.array(z.string()).optional() })
39
- .parse(JSON.parse(process.env.LANGGRAPH_UI_CONFIG || "{}"));
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
+ }
40
44
  const fullPath = path.resolve(cwd, options.output);
41
45
  const publicPath = path.resolve(fullPath, "public");
42
46
  const schemasPath = path.resolve(fullPath, "schemas.json");
43
- const schemas = {};
44
47
  let promiseSeq = Promise.resolve();
48
+ const schemas = {};
45
49
  await Promise.all(Object.entries(defs).map(async ([graphId, userPath]) => {
46
50
  const folder = path.resolve(publicPath, graphId);
47
51
  await fs.mkdir(folder, { recursive: true });
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@langchain/langgraph-ui",
3
- "version": "0.0.20-dev.1",
3
+ "version": "0.0.20",
4
4
  "type": "module",
5
5
  "engines": {
6
6
  "node": "^18.19.0 || >=20.16.0"