@sylphx/lens-server 4.1.0 → 4.1.2

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/index.js CHANGED
@@ -1070,7 +1070,7 @@ class LensServerImpl {
1070
1070
  });
1071
1071
  }
1072
1072
  if (isSnapshot(result)) {
1073
- return new Response(JSON.stringify({ data: result.data }), {
1073
+ return new Response(JSON.stringify(result), {
1074
1074
  headers: baseHeaders
1075
1075
  });
1076
1076
  }
@@ -1135,7 +1135,7 @@ async function handleWebQuery(server, path, url) {
1135
1135
  return Response.json({ error: result.error }, { status: 400 });
1136
1136
  }
1137
1137
  if (isSnapshot2(result)) {
1138
- return Response.json({ data: result.data });
1138
+ return Response.json(result);
1139
1139
  }
1140
1140
  return Response.json(result);
1141
1141
  } catch (error) {
@@ -1151,7 +1151,7 @@ async function handleWebMutation(server, path, request) {
1151
1151
  return Response.json({ error: result.error }, { status: 400 });
1152
1152
  }
1153
1153
  if (isSnapshot2(result)) {
1154
- return Response.json({ data: result.data });
1154
+ return Response.json(result);
1155
1155
  }
1156
1156
  return Response.json(result);
1157
1157
  } catch (error) {
@@ -1195,7 +1195,7 @@ data: ${JSON.stringify({ error: `Invalid input JSON: ${errMsg}` })}
1195
1195
  const observable = result;
1196
1196
  const subscription = observable.subscribe({
1197
1197
  next: (value) => {
1198
- const data = `data: ${JSON.stringify(value.data)}
1198
+ const data = `data: ${JSON.stringify(value)}
1199
1199
 
1200
1200
  `;
1201
1201
  controller.enqueue(encoder.encode(data));
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@sylphx/lens-server",
3
- "version": "4.1.0",
3
+ "version": "4.1.2",
4
4
  "description": "Server runtime for Lens API framework",
5
5
  "type": "module",
6
6
  "main": "./dist/index.js",
@@ -30,7 +30,7 @@
30
30
  "author": "SylphxAI",
31
31
  "license": "MIT",
32
32
  "dependencies": {
33
- "@sylphx/lens-core": "^4.1.0"
33
+ "@sylphx/lens-core": "^4.1.1"
34
34
  },
35
35
  "devDependencies": {
36
36
  "typescript": "^5.9.3",
@@ -125,7 +125,7 @@ export async function handleWebQuery(
125
125
  }
126
126
 
127
127
  if (isSnapshot(result)) {
128
- return Response.json({ data: result.data });
128
+ return Response.json(result);
129
129
  }
130
130
 
131
131
  // ops message - forward as-is
@@ -165,7 +165,7 @@ export async function handleWebMutation(
165
165
  }
166
166
 
167
167
  if (isSnapshot(result)) {
168
- return Response.json({ data: result.data });
168
+ return Response.json(result);
169
169
  }
170
170
 
171
171
  // ops message - forward as-is
@@ -233,7 +233,7 @@ export function handleWebSSE(
233
233
  if (result && typeof result === "object" && "subscribe" in result) {
234
234
  const observable = result as {
235
235
  subscribe: (handlers: {
236
- next: (value: { data?: unknown }) => void;
236
+ next: (value: unknown) => void;
237
237
  error: (err: Error) => void;
238
238
  complete: () => void;
239
239
  }) => { unsubscribe: () => void };
@@ -241,7 +241,9 @@ export function handleWebSSE(
241
241
 
242
242
  const subscription = observable.subscribe({
243
243
  next: (value) => {
244
- const data = `data: ${JSON.stringify(value.data)}\n\n`;
244
+ // Send full LensResult envelope (e.g. { "$": "snapshot", "data": ... })
245
+ // Client expects the complete message, not just the inner data
246
+ const data = `data: ${JSON.stringify(value)}\n\n`;
245
247
  controller.enqueue(encoder.encode(data));
246
248
  },
247
249
  error: (err) => {
@@ -356,7 +356,7 @@ export function createHTTPHandler(
356
356
  }
357
357
 
358
358
  if (isSnapshot(result)) {
359
- return new Response(JSON.stringify({ data: result.data }), {
359
+ return new Response(JSON.stringify(result), {
360
360
  headers: {
361
361
  "Content-Type": "application/json",
362
362
  ...baseHeaders,
@@ -1306,7 +1306,7 @@ class LensServerImpl<
1306
1306
  }
1307
1307
 
1308
1308
  if (isSnapshot(result)) {
1309
- return new Response(JSON.stringify({ data: result.data }), {
1309
+ return new Response(JSON.stringify(result), {
1310
1310
  headers: baseHeaders,
1311
1311
  });
1312
1312
  }