stitchkit 0.60.1 → 0.61.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.
Files changed (39) hide show
  1. package/dist/application/kernel.d.ts +23 -0
  2. package/dist/application/kernel.d.ts.map +1 -1
  3. package/dist/application/server-resource.d.ts.map +1 -1
  4. package/dist/application.d.ts +1 -1
  5. package/dist/application.d.ts.map +1 -1
  6. package/dist/application.js +11 -6
  7. package/dist/browser/socket-io.d.ts +47 -0
  8. package/dist/browser/socket-io.d.ts.map +1 -1
  9. package/dist/browser/stream.d.ts +23 -0
  10. package/dist/browser/stream.d.ts.map +1 -1
  11. package/dist/contract/index.js +1 -1
  12. package/dist/{index-t8xrqc9g.js → index-413xk7ga.js} +1 -1
  13. package/dist/{index-82e74yfx.js → index-eabpd4tb.js} +56 -7
  14. package/dist/{index-2cgbdckv.js → index-s1tywej8.js} +88 -19
  15. package/dist/index.d.ts +2 -2
  16. package/dist/index.d.ts.map +1 -1
  17. package/dist/index.js +213 -17
  18. package/dist/internal/optional-peer.d.ts +14 -0
  19. package/dist/internal/optional-peer.d.ts.map +1 -0
  20. package/dist/node.js +1 -1
  21. package/dist/realtime/contract.d.ts +7 -1
  22. package/dist/realtime/contract.d.ts.map +1 -1
  23. package/dist/realtime/index.d.ts +2 -1
  24. package/dist/realtime/index.d.ts.map +1 -1
  25. package/dist/realtime/rejected-frame.d.ts +86 -0
  26. package/dist/realtime/rejected-frame.d.ts.map +1 -0
  27. package/dist/realtime/request.d.ts +24 -0
  28. package/dist/realtime/request.d.ts.map +1 -1
  29. package/dist/realtime/socket.d.ts.map +1 -1
  30. package/dist/server/index.d.ts +1 -0
  31. package/dist/server/index.d.ts.map +1 -1
  32. package/dist/server/index.js +196 -3
  33. package/dist/server/socket-io.d.ts.map +1 -1
  34. package/dist/server/stream.d.ts.map +1 -1
  35. package/dist/server/streaming-route.d.ts +130 -0
  36. package/dist/server/streaming-route.d.ts.map +1 -0
  37. package/dist/testing.js +1 -1
  38. package/llms-full.txt +364 -23
  39. package/package.json +2 -2
package/dist/index.js CHANGED
@@ -19,7 +19,7 @@ import {
19
19
  parseTrailingWildcard,
20
20
  rateLimited,
21
21
  unauthorized
22
- } from "./index-t8xrqc9g.js";
22
+ } from "./index-413xk7ga.js";
23
23
  import {
24
24
  isRecord,
25
25
  mapObject,
@@ -808,6 +808,15 @@ function createUrlBuilders(contracts, source, contractConfig) {
808
808
  function createScopedUrlBuilders(contracts, source, scopeConfigs) {
809
809
  return buildScopedRegistry(contracts, scopeConfigs, "URL builder", (contract, config) => createUrlBuilder(contract, source, config));
810
810
  }
811
+ // src/internal/optional-peer.ts
812
+ function isModuleNotFound(error) {
813
+ if (typeof error !== "object" || error === null)
814
+ return false;
815
+ const code = "code" in error ? error.code : undefined;
816
+ const message = "message" in error && typeof error.message === "string" ? error.message : "";
817
+ return code === "ERR_MODULE_NOT_FOUND" || code === "MODULE_NOT_FOUND" || message.includes("Cannot find module") || message.includes("Cannot find package");
818
+ }
819
+
811
820
  // src/realtime/request.ts
812
821
  class RealtimeRequestTimeoutError extends Error {
813
822
  code = "REALTIME_REQUEST_TIMEOUT";
@@ -841,8 +850,19 @@ class RealtimeRequestInvalidAcknowledgementError extends Error {
841
850
  }
842
851
  }
843
852
 
844
- // src/realtime/rejection.ts
845
- import { z as z2 } from "zod";
853
+ class RealtimeRequestRejectedError extends Error {
854
+ code = "REALTIME_REQUEST_REJECTED";
855
+ event;
856
+ reason;
857
+ issues;
858
+ constructor(event, reason, detail, issues) {
859
+ super(`Realtime request "${event}" was rejected by the peer (${reason}): ${detail}`);
860
+ this.name = "RealtimeRequestRejectedError";
861
+ this.event = event;
862
+ this.reason = reason;
863
+ this.issues = issues;
864
+ }
865
+ }
846
866
 
847
867
  // src/internal/errors.ts
848
868
  import { z } from "zod";
@@ -857,7 +877,48 @@ function zodIssues(error) {
857
877
  }));
858
878
  }
859
879
 
880
+ // src/realtime/rejected-frame.ts
881
+ var REALTIME_REJECTION_KEY = "@stitchkit/realtime-rejected";
882
+ var MAX_REJECTION_ISSUES = 20;
883
+ function realtimeRejectionEnvelope(report) {
884
+ return { [REALTIME_REJECTION_KEY]: report };
885
+ }
886
+ function asRealtimeRejection(value) {
887
+ if (typeof value !== "object" || value === null)
888
+ return null;
889
+ const report = Reflect.get(value, REALTIME_REJECTION_KEY);
890
+ if (typeof report !== "object" || report === null)
891
+ return null;
892
+ const event = Reflect.get(report, "event");
893
+ const reason = Reflect.get(report, "reason");
894
+ const message = Reflect.get(report, "message");
895
+ if (typeof event !== "string" || typeof reason !== "string" || typeof message !== "string") {
896
+ return null;
897
+ }
898
+ if (reason.length === 0)
899
+ return null;
900
+ const issues = parseIssues(Reflect.get(report, "issues"));
901
+ return { event, reason, message, ...issues !== undefined && { issues } };
902
+ }
903
+ function parseIssues(value) {
904
+ if (!Array.isArray(value))
905
+ return;
906
+ const issues = [];
907
+ for (const entry of value.slice(0, MAX_REJECTION_ISSUES)) {
908
+ if (typeof entry !== "object" || entry === null)
909
+ continue;
910
+ const path = Reflect.get(entry, "path");
911
+ const code = Reflect.get(entry, "code");
912
+ const message = Reflect.get(entry, "message");
913
+ if (typeof path === "string" && typeof code === "string" && typeof message === "string") {
914
+ issues.push({ path, code, message });
915
+ }
916
+ }
917
+ return issues.length > 0 ? issues : undefined;
918
+ }
919
+
860
920
  // src/realtime/rejection.ts
921
+ import { z as z2 } from "zod";
861
922
  function realtimeContractViolation(options) {
862
923
  const issues = options.cause instanceof z2.ZodError ? zodIssues(options.cause) : undefined;
863
924
  const reason = options.reason.replaceAll("-", " ");
@@ -883,15 +944,11 @@ function method(target, name) {
883
944
  return (...args) => Reflect.apply(value, target, args);
884
945
  }
885
946
  function splitWireArguments(definition, args) {
886
- if (!definition.ack)
887
- return { values: args };
888
- const acknowledgement = args.at(-1);
889
- if (typeof acknowledgement !== "function")
890
- return { values: args };
891
- return {
892
- values: args.slice(0, -1),
893
- acknowledgement: (...callbackArgs) => Reflect.apply(acknowledgement, undefined, callbackArgs)
894
- };
947
+ const trailing = args.at(-1);
948
+ const replyTo = typeof trailing === "function" ? (...callbackArgs) => Reflect.apply(trailing, undefined, callbackArgs) : undefined;
949
+ if (!definition.ack || !replyTo)
950
+ return { values: args, ...replyTo && { replyTo } };
951
+ return { values: args.slice(0, -1), acknowledgement: replyTo, replyTo };
895
952
  }
896
953
  function eventDefinition(registry, event, direction) {
897
954
  const definition = registry[event];
@@ -919,6 +976,19 @@ function reportRejected(rejected, hook, logger) {
919
976
  console.error("[stitchkit] realtime rejection hook failed", error);
920
977
  });
921
978
  }
979
+ function answerWithRejection(acknowledgement, report, logger) {
980
+ if (!acknowledgement)
981
+ return;
982
+ try {
983
+ acknowledgement(realtimeRejectionEnvelope(report));
984
+ } catch (error) {
985
+ const message = "[stitchkit] could not answer a rejected realtime frame";
986
+ if (logger)
987
+ logger.warn(message, { error });
988
+ else
989
+ console.warn(message, error);
990
+ }
991
+ }
922
992
  function parseRealtimeRequestArguments(registry, event, direction, args) {
923
993
  const definition = eventDefinition(registry, event, direction);
924
994
  const parsed = definition.args.safeParse(args);
@@ -944,6 +1014,17 @@ function parseRealtimeRequestArguments(registry, event, direction, args) {
944
1014
  return parsed.data;
945
1015
  }
946
1016
  function parseRealtimeRequestAcknowledgement(schema, event, direction, value, hook, logger) {
1017
+ const refusal = asRealtimeRejection(value);
1018
+ if (refusal) {
1019
+ reportRejected(realtimeContractViolation({
1020
+ event,
1021
+ direction,
1022
+ phase: "arguments",
1023
+ reason: "rejected-by-peer",
1024
+ fault: "local"
1025
+ }), hook, logger);
1026
+ throw new RealtimeRequestRejectedError(event, refusal.reason, refusal.message, refusal.issues);
1027
+ }
947
1028
  const parsed = schema.safeParse(value);
948
1029
  if (parsed.success)
949
1030
  return parsed.data;
@@ -973,17 +1054,24 @@ function createValidatedRealtimeSocket({
973
1054
  on: (event, handler) => {
974
1055
  const definition = eventDefinition(inbound, event, inboundDirection);
975
1056
  const wrapped = (...wireArgs) => {
976
- const { values, acknowledgement } = splitWireArguments(definition, wireArgs);
1057
+ const { values, acknowledgement, replyTo } = splitWireArguments(definition, wireArgs);
977
1058
  const parsed = definition.args.safeParse(values);
978
1059
  if (!parsed.success) {
979
- reportRejected(realtimeContractViolation({
1060
+ const rejected = realtimeContractViolation({
980
1061
  event,
981
1062
  direction: inboundDirection,
982
1063
  phase: "arguments",
983
1064
  reason: "invalid-arguments",
984
1065
  fault: "peer",
985
1066
  cause: parsed.error
986
- }), onRejected, logger);
1067
+ });
1068
+ reportRejected(rejected, onRejected, logger);
1069
+ answerWithRejection(replyTo, {
1070
+ event,
1071
+ reason: "invalid-arguments",
1072
+ message: rejected.error.message,
1073
+ issues: zodIssues(parsed.error).slice(0, MAX_REJECTION_ISSUES)
1074
+ }, logger);
987
1075
  return;
988
1076
  }
989
1077
  if (definition.ack && !acknowledgement) {
@@ -1053,6 +1141,17 @@ function createValidatedRealtimeSocket({
1053
1141
  const wireArgs = [...parsed.data];
1054
1142
  if (definition.ack && acknowledgement) {
1055
1143
  wireArgs.push((value) => {
1144
+ const refusal = asRealtimeRejection(value);
1145
+ if (refusal) {
1146
+ reportRejected(realtimeContractViolation({
1147
+ event,
1148
+ direction: outboundDirection,
1149
+ phase: "arguments",
1150
+ reason: "rejected-by-peer",
1151
+ fault: "local"
1152
+ }), onRejected, logger);
1153
+ return;
1154
+ }
1056
1155
  const ack = definition.ack?.safeParse(value);
1057
1156
  if (!ack?.success) {
1058
1157
  if (ack) {
@@ -1108,11 +1207,39 @@ function loadIo() {
1108
1207
  if (!ioLoader) {
1109
1208
  ioLoader = import(SOCKET_IO_CLIENT).then((mod) => mod.io, (cause) => {
1110
1209
  ioLoader = null;
1111
- throw new Error('stitchkit: createSocketIOClient needs the "socket.io-client" peer — install it (e.g. `bun add socket.io-client`).', { cause });
1210
+ throw new Error("stitchkit: createSocketIOClient needs the \"socket.io-client\" peer — install it (e.g. `bun add socket.io-client`). Shipping one self-contained artifact instead? Pass `peers: { client: () => import('socket.io-client') }` so your bundler puts it inside.", { cause });
1112
1211
  });
1113
1212
  }
1114
1213
  return ioLoader;
1115
1214
  }
1215
+ function isIoModule(module) {
1216
+ if (typeof module !== "object" || module === null)
1217
+ return false;
1218
+ return typeof Reflect.get(module, "io") === "function";
1219
+ }
1220
+ function createIoResolver(injected) {
1221
+ if (!injected)
1222
+ return loadIo;
1223
+ let pending = null;
1224
+ return () => {
1225
+ if (!pending) {
1226
+ pending = injected().then((module) => {
1227
+ const io = isIoModule(module) ? module.io : null;
1228
+ if (!io) {
1229
+ pending = null;
1230
+ throw new Error("stitchkit: the loader passed in `peers.client` did not return the \"socket.io-client\" module — it must resolve to the module itself, as `() => import('socket.io-client')`.");
1231
+ }
1232
+ return io;
1233
+ }, (cause) => {
1234
+ pending = null;
1235
+ if (!isModuleNotFound(cause))
1236
+ throw cause;
1237
+ throw new Error('stitchkit: createSocketIOClient could not load "socket.io-client" through the loader passed in `peers` — the artifact does not contain it. Check that the loader is a literal `import(\'socket.io-client\')` your bundler can follow, and that "socket.io-client" is a dependency of the package being bundled.', { cause });
1238
+ });
1239
+ }
1240
+ return pending;
1241
+ };
1242
+ }
1116
1243
  function toIoAuth(auth) {
1117
1244
  if (typeof auth !== "function")
1118
1245
  return auth;
@@ -1196,7 +1323,9 @@ function createRealtimeClient(contract, { onRejected, logger, ...config }) {
1196
1323
  }
1197
1324
  function createSocketIOClient(config) {
1198
1325
  let socket = null;
1326
+ const resolveIo = createIoResolver(config.peers?.client);
1199
1327
  let desiredConnected = false;
1328
+ let loadingPeer = false;
1200
1329
  let reconnectTimer = null;
1201
1330
  const pendingRequestDisconnects = new Set;
1202
1331
  const serverDisconnectDelay = config.reconnectOnServerDisconnect ?? 1000;
@@ -1267,6 +1396,16 @@ function createSocketIOClient(config) {
1267
1396
  attach(socket);
1268
1397
  socket.connect();
1269
1398
  }
1399
+ function reportPeerFailure(error) {
1400
+ desiredConnected = false;
1401
+ if (!config.onConnectError)
1402
+ throw error;
1403
+ config.onConnectError({
1404
+ message: error instanceof Error ? error.message : String(error),
1405
+ data: error,
1406
+ terminal: true
1407
+ });
1408
+ }
1270
1409
  return {
1271
1410
  get connected() {
1272
1411
  return socket?.connected ?? false;
@@ -1279,7 +1418,16 @@ function createSocketIOClient(config) {
1279
1418
  socket.connect();
1280
1419
  return;
1281
1420
  }
1282
- loadIo().then(openSocket);
1421
+ if (loadingPeer)
1422
+ return;
1423
+ loadingPeer = true;
1424
+ resolveIo().then((io) => {
1425
+ loadingPeer = false;
1426
+ openSocket(io);
1427
+ }, (error) => {
1428
+ loadingPeer = false;
1429
+ reportPeerFailure(error);
1430
+ });
1283
1431
  },
1284
1432
  disconnect() {
1285
1433
  desiredConnected = false;
@@ -1386,6 +1534,50 @@ async function* parseSSE(response, options) {
1386
1534
  reader.releaseLock();
1387
1535
  }
1388
1536
  }
1537
+
1538
+ // src/browser/stream.ts
1539
+ async function* parseNDJSON(response, options) {
1540
+ const reader = response.body?.getReader();
1541
+ if (!reader)
1542
+ return;
1543
+ const decoder = new TextDecoder;
1544
+ let buffer = "";
1545
+ try {
1546
+ for (;; ) {
1547
+ const { done, value } = await reader.read();
1548
+ if (done)
1549
+ break;
1550
+ buffer += decoder.decode(value, { stream: true });
1551
+ const lines = buffer.split(`
1552
+ `);
1553
+ buffer = lines.pop() ?? "";
1554
+ for (const rawLine of lines) {
1555
+ const line = (rawLine.endsWith("\r") ? rawLine.slice(0, -1) : rawLine).trim();
1556
+ if (line === "")
1557
+ continue;
1558
+ try {
1559
+ yield JSON.parse(line);
1560
+ } catch (err) {
1561
+ options?.onParseError?.(line, err instanceof Error ? err : new Error(String(err)));
1562
+ }
1563
+ }
1564
+ }
1565
+ buffer += decoder.decode();
1566
+ const tail = buffer.trim();
1567
+ if (tail !== "") {
1568
+ try {
1569
+ yield JSON.parse(tail);
1570
+ } catch (err) {
1571
+ options?.onParseError?.(tail, err instanceof Error ? err : new Error(String(err)));
1572
+ }
1573
+ }
1574
+ } finally {
1575
+ await reader.cancel().catch(() => {
1576
+ return;
1577
+ });
1578
+ reader.releaseLock();
1579
+ }
1580
+ }
1389
1581
  // src/realtime/contract.ts
1390
1582
  function defineRealtimeContract(contract) {
1391
1583
  return contract;
@@ -1396,11 +1588,14 @@ export {
1396
1588
  AppError,
1397
1589
  ManagedFilePathSchema,
1398
1590
  ManagedFileRefSchema,
1591
+ REALTIME_REJECTION_KEY,
1399
1592
  RealtimeRequestDisconnectedError,
1400
1593
  RealtimeRequestInvalidAcknowledgementError,
1594
+ RealtimeRequestRejectedError,
1401
1595
  RealtimeRequestTimeoutError,
1402
1596
  STITCH_ERROR_STATUS,
1403
1597
  appError,
1598
+ asRealtimeRejection,
1404
1599
  badRequest,
1405
1600
  bindRealtimeClient,
1406
1601
  childSpan,
@@ -1428,6 +1623,7 @@ export {
1428
1623
  isStitchErrorCode,
1429
1624
  notFound,
1430
1625
  paginatedSchema,
1626
+ parseNDJSON,
1431
1627
  parseSSE,
1432
1628
  parseTraceparent,
1433
1629
  rateLimited,
@@ -0,0 +1,14 @@
1
+ /**
2
+ * Telling "the package is not there" apart from "the loader itself threw".
3
+ *
4
+ * Both halves of the Socket.IO adapter resolve their optional peers through a
5
+ * variable specifier and both accept an injected loader, so both face the same
6
+ * question when a load fails — and both must answer it the same way. A loader
7
+ * that throws for its own reasons is not a packaging problem, and reporting it
8
+ * as one sends the reader after the wrong thing.
9
+ *
10
+ * Pure and dependency-free, so the browser half can share it without dragging
11
+ * anything from the server into a browser graph.
12
+ */
13
+ export declare function isModuleNotFound(error: unknown): boolean;
14
+ //# sourceMappingURL=optional-peer.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"optional-peer.d.ts","sourceRoot":"","sources":["../../src/internal/optional-peer.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;GAWG;AACH,wBAAgB,gBAAgB,CAAC,KAAK,EAAE,OAAO,GAAG,OAAO,CAUxD"}
package/dist/node.js CHANGED
@@ -3,7 +3,7 @@ import {
3
3
  bindRealtimeServer,
4
4
  createHandler,
5
5
  createSocketIOServer
6
- } from "./index-2cgbdckv.js";
6
+ } from "./index-s1tywej8.js";
7
7
  import {
8
8
  createImplement,
9
9
  createImplementRegistry,
@@ -40,7 +40,13 @@ export interface RealtimeRejectedEvent {
40
40
  event: string;
41
41
  direction: RealtimeRejectDirection;
42
42
  phase: 'arguments' | 'acknowledgement';
43
- reason: 'unknown-event' | 'invalid-arguments' | 'invalid-acknowledgement-value' | 'missing-acknowledgement';
43
+ reason: 'unknown-event' | 'invalid-arguments' | 'invalid-acknowledgement-value' | 'missing-acknowledgement'
44
+ /**
45
+ * The PEER refused our frame against its own copy of the contract, and
46
+ * said so. Reported on the sender, where a silent drop used to leave
47
+ * nothing but an expiring deadline.
48
+ */
49
+ | 'rejected-by-peer';
44
50
  fault: 'peer' | 'local';
45
51
  error: AppError<'REALTIME_CONTRACT_VIOLATION'>;
46
52
  }
@@ -1 +1 @@
1
- {"version":3,"file":"contract.d.ts","sourceRoot":"","sources":["../../src/realtime/contract.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,CAAC,EAAE,MAAM,KAAK,CAAC;AAC7B,OAAO,KAAK,EAAE,QAAQ,EAAE,MAAM,oBAAoB,CAAC;AAEnD,MAAM,WAAW,uBAAuB,CACtC,KAAK,SAAS,CAAC,CAAC,OAAO,CAAC,OAAO,EAAE,CAAC,GAAG,CAAC,CAAC,OAAO,CAAC,OAAO,EAAE,CAAC,EACzD,IAAI,SAAS,CAAC,CAAC,OAAO,GAAG,SAAS,GAAG,CAAC,CAAC,OAAO,GAAG,SAAS;IAE1D,IAAI,EAAE,KAAK,CAAC;IACZ,GAAG,CAAC,EAAE,IAAI,CAAC;CACZ;AAED,MAAM,MAAM,qBAAqB,GAAG,MAAM,CAAC,MAAM,EAAE,uBAAuB,CAAC,CAAC;AAE5E,MAAM,WAAW,gBAAgB,CAC/B,eAAe,SAAS,qBAAqB,EAC7C,eAAe,SAAS,qBAAqB;IAE7C,cAAc,EAAE,eAAe,CAAC;IACh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SAAS,GAAG,oBAAoB,CAAC,SAAS,CAAC,MAAM,CAAC,CAAC;CACrE,CAAC;AAEF,MAAM,MAAM,uBAAuB,GAC/B,gBAAgB,GAChB,iBAAiB,GACjB,gBAAgB,GAChB,iBAAiB,CAAC;AAEtB,MAAM,WAAW,qBAAqB;IACpC,KAAK,EAAE,MAAM,CAAC;IACd,SAAS,EAAE,uBAAuB,CAAC;IACnC,KAAK,EAAE,WAAW,GAAG,iBAAiB,CAAC;IACvC,MAAM,EACF,eAAe,GACf,mBAAmB,GACnB,+BAA+B,GAC/B,yBAAyB;IAC3B;;;;OAIG;OACD,kBAAkB,CAAC;IACvB,KAAK,EAAE,MAAM,GAAG,OAAO,CAAC;IACxB,KAAK,EAAE,QAAQ,CAAC,6BAA6B,CAAC,CAAC;CAChD;AAED,MAAM,MAAM,yBAAyB,GAAG,CACtC,QAAQ,EAAE,qBAAqB,KAC5B,IAAI,GAAG,OAAO,CAAC,IAAI,CAAC,CAAC"}
@@ -1,4 +1,5 @@
1
1
  export { defineRealtimeContract, type InferRealtimeEventMap, type RealtimeAcknowledgedEvent, type RealtimeAcknowledgement, type RealtimeContract, type RealtimeEmitArguments, type RealtimeEventArguments, type RealtimeEventDefinition, type RealtimeEventHandler, type RealtimeEventRegistry, type RealtimeRejectDirection, type RealtimeRejectedEvent, type RealtimeRejectedEventHook, type RealtimeRequestArguments, } from './contract';
2
- export { RealtimeRequestDisconnectedError, RealtimeRequestInvalidAcknowledgementError, type RealtimeRequestOptions, RealtimeRequestTimeoutError, } from './request';
2
+ export { asRealtimeRejection, REALTIME_REJECTION_KEY, type RealtimeRejectionEnvelope, type RealtimeRejectionIssue, type RealtimeRejectionReport, } from './rejected-frame';
3
+ export { RealtimeRequestDisconnectedError, RealtimeRequestInvalidAcknowledgementError, type RealtimeRequestOptions, RealtimeRequestRejectedError, RealtimeRequestTimeoutError, } from './request';
3
4
  export type { ValidatedRealtimeSocket } from './socket';
4
5
  //# sourceMappingURL=index.d.ts.map
@@ -1 +1 @@
1
- {"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../src/realtime/index.ts"],"names":[],"mappings":"AAAA,OAAO,EACL,sBAAsB,EACtB,KAAK,qBAAqB,EAC1B,KAAK,yBAAyB,EAC9B,KAAK,uBAAuB,EAC5B,KAAK,gBAAgB,EACrB,KAAK,qBAAqB,EAC1B,KAAK,sBAAsB,EAC3B,KAAK,uBAAuB,EAC5B,KAAK,oBAAoB,EACzB,KAAK,qBAAqB,EAC1B,KAAK,uBAAuB,EAC5B,KAAK,qBAAqB,EAC1B,KAAK,yBAAyB,EAC9B,KAAK,wBAAwB,GAC9B,MAAM,YAAY,CAAC;AACpB,OAAO,EACL,gCAAgC,EAChC,0CAA0C,EAC1C,KAAK,sBAAsB,EAC3B,2BAA2B,GAC5B,MAAM,WAAW,CAAC;AACnB,YAAY,EAAE,uBAAuB,EAAE,MAAM,UAAU,CAAC"}
1
+ {"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../src/realtime/index.ts"],"names":[],"mappings":"AAAA,OAAO,EACL,sBAAsB,EACtB,KAAK,qBAAqB,EAC1B,KAAK,yBAAyB,EAC9B,KAAK,uBAAuB,EAC5B,KAAK,gBAAgB,EACrB,KAAK,qBAAqB,EAC1B,KAAK,sBAAsB,EAC3B,KAAK,uBAAuB,EAC5B,KAAK,oBAAoB,EACzB,KAAK,qBAAqB,EAC1B,KAAK,uBAAuB,EAC5B,KAAK,qBAAqB,EAC1B,KAAK,yBAAyB,EAC9B,KAAK,wBAAwB,GAC9B,MAAM,YAAY,CAAC;AACpB,OAAO,EACL,mBAAmB,EACnB,sBAAsB,EACtB,KAAK,yBAAyB,EAC9B,KAAK,sBAAsB,EAC3B,KAAK,uBAAuB,GAC7B,MAAM,kBAAkB,CAAC;AAC1B,OAAO,EACL,gCAAgC,EAChC,0CAA0C,EAC1C,KAAK,sBAAsB,EAC3B,4BAA4B,EAC5B,2BAA2B,GAC5B,MAAM,WAAW,CAAC;AACnB,YAAY,EAAE,uBAAuB,EAAE,MAAM,UAAU,CAAC"}
@@ -0,0 +1,86 @@
1
+ /**
2
+ * A rejection the SENDER can see.
3
+ *
4
+ * A frame that fails the receiver's schema used to be dropped where it landed:
5
+ * the receiving side reported `onRejected` and the sending side learned
6
+ * nothing at all — it waited out its deadline and reported a timeout. For a
7
+ * distributed pair that is the worst diagnostic shape there is. The machines
8
+ * are healthy, the sockets are up, and every request times out in both
9
+ * directions at once, which reads as a network fault rather than as two peers
10
+ * disagreeing about a contract.
11
+ *
12
+ * It also quietly removed the point of putting a protocol generation in the
13
+ * envelope: the check ran, and its answer could not reach the only party able
14
+ * to act on it. There is no deployment order in which two generations coexist
15
+ * if neither can tell the other why it is being refused.
16
+ *
17
+ * So when a refused frame carries an acknowledgement callback — the one
18
+ * back-channel that already exists — the refusal is sent through it. A
19
+ * fire-and-forget event still has nowhere to answer; that boundary is real and
20
+ * is documented rather than papered over.
21
+ */
22
+ /**
23
+ * The reserved key. Namespaced because it travels on the application's own
24
+ * acknowledgement channel: this envelope is delivered INSTEAD of a value the
25
+ * application's `ack` schema would accept, and the sender recognises it before
26
+ * parsing. An application whose acknowledgement is an object carrying this
27
+ * exact key would be ambiguous — hence a key nobody writes by accident.
28
+ */
29
+ export declare const REALTIME_REJECTION_KEY = "@stitchkit/realtime-rejected";
30
+ /**
31
+ * One field the peer refused, already flattened.
32
+ *
33
+ * `path` is dotted and tuple-aware: the first payload's `v` field is `'0.v'`,
34
+ * because event arguments are a tuple. This is what replaces reading a
35
+ * `ZodError`'s internals on the receiving end — three conditions about somebody
36
+ * else's object shape, for a fact that is binary.
37
+ */
38
+ export interface RealtimeRejectionIssue {
39
+ path: string;
40
+ code: string;
41
+ message: string;
42
+ }
43
+ /**
44
+ * At most this many issues travel; a refusal is a signal, not a report.
45
+ *
46
+ * Applied on BOTH sides. On the reading side it bounds what a peer can make
47
+ * this process hold; on the writing side it bounds what a peer can make this
48
+ * process send — and that one matters more, because the number of issues is
49
+ * chosen by whoever sent the bad frame.
50
+ */
51
+ export declare const MAX_REJECTION_ISSUES = 20;
52
+ /**
53
+ * What the sender is told: which event, why, and the issues if there were any.
54
+ *
55
+ * `reason` is a union of one today, and deliberately a union: `invalid-arguments`
56
+ * is the only refusal that CAN be answered. An event the receiver's contract
57
+ * does not contain has no listener at all, so there is nothing on that side to
58
+ * answer with; a frame missing its acknowledgement callback has no channel by
59
+ * definition. Both stay reported locally, and both are honest gaps rather than
60
+ * reasons this envelope is never sent.
61
+ */
62
+ export interface RealtimeRejectionReport {
63
+ event: string;
64
+ /**
65
+ * Why the peer refused it. `invalid-arguments` is what this version sends and
66
+ * the shape a protocol-generation mismatch takes.
67
+ *
68
+ * Typed as a string rather than as a closed union **on the wire**, because a
69
+ * closed union is a mechanism that cannot version itself forward: a peer on a
70
+ * later release refusing for a reason this one has never heard of would fail
71
+ * recognition, fall through to the application's acknowledgement schema, and
72
+ * surface as "the peer answered with something invalid" — the precise
73
+ * mischaracterisation this envelope exists to prevent. An unknown reason is
74
+ * still a refusal, and is reported as one.
75
+ */
76
+ reason: string;
77
+ message: string;
78
+ issues?: RealtimeRejectionIssue[];
79
+ }
80
+ export interface RealtimeRejectionEnvelope {
81
+ [REALTIME_REJECTION_KEY]: RealtimeRejectionReport;
82
+ }
83
+ export declare function realtimeRejectionEnvelope(report: RealtimeRejectionReport): RealtimeRejectionEnvelope;
84
+ /** Whether an acknowledgement value is a peer's refusal rather than a value. */
85
+ export declare function asRealtimeRejection(value: unknown): RealtimeRejectionReport | null;
86
+ //# sourceMappingURL=rejected-frame.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"rejected-frame.d.ts","sourceRoot":"","sources":["../../src/realtime/rejected-frame.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;;;;;;;GAoBG;AAEH;;;;;;GAMG;AACH,eAAO,MAAM,sBAAsB,iCAAiC,CAAC;AAErE;;;;;;;GAOG;AACH,MAAM,WAAW,sBAAsB;IACrC,IAAI,EAAE,MAAM,CAAC;IACb,IAAI,EAAE,MAAM,CAAC;IACb,OAAO,EAAE,MAAM,CAAC;CACjB;AAED;;;;;;;GAOG;AACH,eAAO,MAAM,oBAAoB,KAAK,CAAC;AAEvC;;;;;;;;;GASG;AACH,MAAM,WAAW,uBAAuB;IACtC,KAAK,EAAE,MAAM,CAAC;IACd;;;;;;;;;;;OAWG;IACH,MAAM,EAAE,MAAM,CAAC;IACf,OAAO,EAAE,MAAM,CAAC;IAChB,MAAM,CAAC,EAAE,sBAAsB,EAAE,CAAC;CACnC;AAED,MAAM,WAAW,yBAAyB;IACxC,CAAC,sBAAsB,CAAC,EAAE,uBAAuB,CAAC;CACnD;AAED,wBAAgB,yBAAyB,CACvC,MAAM,EAAE,uBAAuB,GAC9B,yBAAyB,CAE3B;AAED,gFAAgF;AAChF,wBAAgB,mBAAmB,CAAC,KAAK,EAAE,OAAO,GAAG,uBAAuB,GAAG,IAAI,CAgBlF"}
@@ -1,3 +1,4 @@
1
+ import type { RealtimeRejectionIssue } from './rejected-frame';
1
2
  export interface RealtimeRequestOptions {
2
3
  /** Maximum acknowledgement wait in milliseconds. Must be finite and > 0. */
3
4
  timeoutMs: number;
@@ -18,4 +19,27 @@ export declare class RealtimeRequestInvalidAcknowledgementError extends Error {
18
19
  readonly event: string;
19
20
  constructor(event: string, cause: unknown);
20
21
  }
22
+ /**
23
+ * The peer refused the frame against its own copy of the contract, and said so.
24
+ *
25
+ * Distinct from `RealtimeRequestTimeoutError` on purpose, and that distinction
26
+ * is the whole point: a refusal used to BE a timeout, so a version skew looked
27
+ * exactly like a network fault — symmetrically, on every plane at once. It is
28
+ * also distinct from `RealtimeRequestInvalidAcknowledgementError`, which means
29
+ * the peer answered with something its own contract does not allow; this one
30
+ * means the peer never got as far as answering.
31
+ */
32
+ export declare class RealtimeRequestRejectedError extends Error {
33
+ readonly code = "REALTIME_REQUEST_REJECTED";
34
+ readonly event: string;
35
+ /**
36
+ * Why the peer refused it. `invalid-arguments` is the version-skew shape and
37
+ * what a peer on this release sends; a later release may name others, so
38
+ * compare rather than exhaustively switch.
39
+ */
40
+ readonly reason: string;
41
+ /** The fields the peer refused, when it named any — validated on arrival. */
42
+ readonly issues: RealtimeRejectionIssue[] | undefined;
43
+ constructor(event: string, reason: string, detail: string, issues?: RealtimeRejectionIssue[]);
44
+ }
21
45
  //# sourceMappingURL=request.d.ts.map
@@ -1 +1 @@
1
- {"version":3,"file":"request.d.ts","sourceRoot":"","sources":["../../src/realtime/request.ts"],"names":[],"mappings":"AAAA,MAAM,WAAW,sBAAsB;IACrC,4EAA4E;IAC5E,SAAS,EAAE,MAAM,CAAC;CACnB;AAED,qBAAa,2BAA4B,SAAQ,KAAK;IACpD,QAAQ,CAAC,IAAI,8BAA8B;IAC3C,QAAQ,CAAC,KAAK,EAAE,MAAM,CAAC;IACvB,QAAQ,CAAC,SAAS,EAAE,MAAM,CAAC;IAE3B,YAAY,KAAK,EAAE,MAAM,EAAE,SAAS,EAAE,MAAM,EAK3C;CACF;AAED,qBAAa,gCAAiC,SAAQ,KAAK;IACzD,QAAQ,CAAC,IAAI,mCAAmC;IAChD,QAAQ,CAAC,KAAK,EAAE,MAAM,CAAC;IAEvB,YAAY,KAAK,EAAE,MAAM,EAIxB;CACF;AAED,qBAAa,0CAA2C,SAAQ,KAAK;IACnE,QAAQ,CAAC,IAAI,8CAA8C;IAC3D,QAAQ,CAAC,KAAK,EAAE,MAAM,CAAC;IAEvB,YAAY,KAAK,EAAE,MAAM,EAAE,KAAK,EAAE,OAAO,EAIxC;CACF"}
1
+ {"version":3,"file":"request.d.ts","sourceRoot":"","sources":["../../src/realtime/request.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,sBAAsB,EAAE,MAAM,kBAAkB,CAAC;AAE/D,MAAM,WAAW,sBAAsB;IACrC,4EAA4E;IAC5E,SAAS,EAAE,MAAM,CAAC;CACnB;AAED,qBAAa,2BAA4B,SAAQ,KAAK;IACpD,QAAQ,CAAC,IAAI,8BAA8B;IAC3C,QAA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le, type ShutdownOptions, ShutdownOptionsSchema,
25
25
  export type { SocketIOHandshakeConfig, SocketIOPeerLoaders, SocketIORequestPolicy, SocketIOServerConfig, SocketIOServerHandle, SocketIOServerLifecycle, } from './socket-io';
26
26
  export { createSocketIOServer, socketIoLane } from './socket-io';
27
27
  export { type ParseSSEOptions, parseSSE, streamSSE } from './stream';
28
+ export { DEFAULT_STREAM_HEARTBEAT_MS, ndjsonRoute, type StreamingFormat, type StreamingRouteOptions, type StreamingSourceContext, sseRoute, streamingRoute, } from './streaming-route';
28
29
  export type { AuthorizationContext, EffectiveScope, EndpointHandlerContext, Handlers, LifecycleHooks, LoggingConfig, LogOutcome, MethodDef, MultipartFileMetadata, MultipartReceiver, MultipartReceiverResult, OperationIdentity, RouteGroup, ScopeContexts, ScopedHandlers, ServiceDef, StitchLogger, StreamingMultipartImplementation, } from './types';
29
30
  export { type ComposedLane, composeWebSocketHandlers, type WebSocketComposeConfig, type WebSocketLane, webSocketLane, } from './websocket';
30
31
  //# sourceMappingURL=index.d.ts.map
@@ -1 +1 @@
1
- {"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../src/server/index.ts"],"names":[],"mappings":"AAAA,OAAO,EACL,QAAQ,EACR,QAAQ,EACR,UAAU,EACV,QAAQ,EACR,SAAS,EACT,iBAAiB,EACjB,QAAQ,EACR,WAAW,EACX,mBAAmB,EACnB,KAAK,eAAe,EACpB,YAAY,GACb,MAAM,aAAa,CAAC;AAIrB,OAAO,EACL,SAAS,EACT,cAAc,EACd,cAAc,EACd,KAAK,eAAe,EACpB,SAAS,GACV,MAAM,oBAAoB,CAAC;AAG5B,OAAO,EAAE,WAAW,EAAE,MAAM,wBAAwB,CAAC;AACrD,OAAO,EACL,KAAK,mBAAmB,IAAI,gBAAgB,EAC5C,KAAK,eAAe,IAAI,YAAY,EACpC,KAAK,gBAAgB,IAAI,aAAa,EACtC,KAAK,WAAW,IAAI,QAAQ,EAC5B,KAAK,kBAAkB,IAAI,eAAe,EAC1C,K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K,mBAAmB,EACxB,KAAK,eAAe,EACpB,qBAAqB,EACrB,KAAK,cAAc,EACnB,oBAAoB,EACpB,KAAK,aAAa,EAClB,mBAAmB,EACnB,KAAK,cAAc,EACnB,oBAAoB,GACrB,MAAM,YAAY,CAAC;AACpB,YAAY,EACV,uBAAuB,EACvB,mBAAmB,EACnB,qBAAqB,EACrB,oBAAoB,EACpB,oBAAoB,EACpB,uBAAuB,GACxB,MAAM,aAAa,CAAC;AACrB,OAAO,EAAE,oBAAoB,EAAE,YAAY,EAAE,MAAM,aAAa,CAAC;AACjE,OAAO,EAAE,KAAK,eAAe,EAAE,QAAQ,EAAE,SAAS,EAAE,MAAM,UAAU,CAAC;AACrE,YAAY,EACV,oBAAoB,EACpB,cAAc,EACd,sBAAsB,EACtB,QAAQ,EACR,cAAc,EACd,aAAa,EACb,UAAU,EACV,SAAS,EACT,qBAAqB,EACrB,iBAAiB,EACjB,uBAAuB,EACvB,iBAAiB,EACjB,UAAU,EACV,aAAa,EACb,cAAc,EACd,UAAU,EACV,YAAY,EACZ,gCAAgC,GACjC,MAAM,SAAS,CAAC;AACjB,OAAO,EACL,KAAK,YAAY,EACjB,wBAAwB,EACxB,KAAK,sBAAsB,EAC3B,KAAK,aAAa,EAClB,aAAa,GACd,MAAM,aAAa,CAAC"}
1
+ {"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../src/server/index.ts"],"names":[],"mappings":"AAAA,OAAO,EACL,QAAQ,EACR,QAAQ,EACR,UAAU,EACV,QAAQ,EACR,SAAS,EACT,iBAAiB,EACjB,QAAQ,EACR,WAAW,EACX,mBAAmB,EACnB,KAAK,eAAe,EACpB,YAAY,GACb,MAAM,aAAa,CAAC;AAIrB,OAAO,EACL,SAAS,EACT,cAAc,EACd,cAAc,EACd,KAAK,eAAe,EACpB,SAAS,GACV,MAAM,oBAAoB,CAAC;AAG5B,OAAO,EAAE,WAAW,EAAE,MAAM,wBAAwB,CAAC;AACrD,OAAO,EACL,KAAK,mBAAmB,I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