@cosmicdrift/kumiko-dispatcher-live 0.337.1 → 0.339.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.
@@ -155,10 +155,7 @@ export function createLiveDispatcher(options = {}) {
155
155
  }
156
156
  const body = parsed;
157
157
  if (body?.error) {
158
- throw mapServerError({
159
- ...body.error,
160
- httpStatus: body.error.httpStatus ?? response.status,
161
- });
158
+ throw mapServerErrorWithStatus(body.error, response.status);
162
159
  }
163
160
  throw buildNetworkError(`unexpected non-SSE stream response (${response.status})`);
164
161
  }
@@ -208,7 +205,7 @@ function normalizeWriteResult(call) {
208
205
  const body = call.body;
209
206
  if (body.isSuccess)
210
207
  return body;
211
- return { isSuccess: false, error: mapServerError(body.error) };
208
+ return { isSuccess: false, error: mapServerErrorWithStatus(body.error, call.status) };
212
209
  }
213
210
  function normalizeBatchResponse(call) {
214
211
  if (!call.ok) {
@@ -219,7 +216,7 @@ function normalizeBatchResponse(call) {
219
216
  return body;
220
217
  return {
221
218
  isSuccess: false,
222
- error: mapServerError(body.error),
219
+ error: mapServerErrorWithStatus(body.error, call.status),
223
220
  failedIndex: body.failedIndex,
224
221
  results: body.results,
225
222
  };
@@ -228,23 +225,22 @@ function normalizeBatchResponse(call) {
228
225
  // (no isSuccess flag) and `{ error: { code, i18nKey, message, ... } }`
229
226
  // on failure. Source of truth: packages/framework/src/api/routes.ts:85
230
227
  // (the query route handler that emits `c.json({ data: result })`).
231
- // The HTTP status carries the failure-status; the error body itself
232
- // doesn't repeat it (serializeError drops httpStatus to keep the wire
233
- // payload lean). We have to reinject httpStatus from the Response.status
234
- // here.
235
228
  function normalizeQueryResponse(call) {
236
229
  if (!call.ok)
237
230
  return { isSuccess: false, error: call.networkFailure };
238
231
  const body = call.body;
239
232
  if (body && "error" in body && body.error) {
240
- const errorWithStatus = {
241
- ...body.error,
242
- httpStatus: body.error.httpStatus ?? call.status,
243
- };
244
- return { isSuccess: false, error: mapServerError(errorWithStatus) };
233
+ return { isSuccess: false, error: mapServerErrorWithStatus(body.error, call.status) };
245
234
  }
246
235
  return { isSuccess: true, data: body?.data };
247
236
  }
237
+ // The HTTP status carries the failure-status; the error body itself
238
+ // doesn't repeat it (serializeError drops httpStatus to keep the wire
239
+ // payload lean). Every envelope has to reinject it from Response.status,
240
+ // otherwise status-based checks like isSessionEndedError never match.
241
+ function mapServerErrorWithStatus(error, responseStatus) {
242
+ return mapServerError({ ...error, httpStatus: error.httpStatus ?? responseStatus });
243
+ }
248
244
  function isAbortError(e) {
249
245
  return (!!e &&
250
246
  typeof e === "object" &&
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@cosmicdrift/kumiko-dispatcher-live",
3
- "version": "0.337.1",
3
+ "version": "0.339.0",
4
4
  "description": "HTTP-only Dispatcher for Kumiko UIs. Always-online; failures surface immediately. Default client for web admin/cockpit apps.",
5
5
  "license": "BUSL-1.1",
6
6
  "author": "Marc Frost <marc@cosmicdriftgamestudio.com>",
@@ -24,7 +24,7 @@
24
24
  }
25
25
  },
26
26
  "dependencies": {
27
- "@cosmicdrift/kumiko-headless": "0.337.1"
27
+ "@cosmicdrift/kumiko-headless": "0.339.0"
28
28
  },
29
29
  "publishConfig": {
30
30
  "registry": "https://registry.npmjs.org",
@@ -0,0 +1,8 @@
1
+ [
2
+ {
3
+ "version": "0.338.0",
4
+ "type": "fix",
5
+ "title": "Write and batch errors carry httpStatus from the response",
6
+ "detail": "dispatcher-live: write and batch failures now take `httpStatus` from the HTTP response when the server's error body omits it, like queries already did. `isSessionEndedError` now also triggers on a failed write after the session ended."
7
+ }
8
+ ]