@settlemint/dalp-sdk 3.1.19-main.35909219019 → 3.1.19-main.35922421643

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/auth.js CHANGED
@@ -10,7 +10,7 @@ import {
10
10
  makeCookieStore2,
11
11
  createCookieStoreFetch2,
12
12
  SDK_USER_AGENT2
13
- } from "./chunk-695n870t.js";
13
+ } from "./chunk-kvsyvt7m.js";
14
14
 
15
15
  // src/auth/live.ts
16
16
  import { apiKeyClient } from "@better-auth/api-key/client";
package/dist/bundler.js CHANGED
@@ -1,9 +1,9 @@
1
1
  import"./chunk-j4sxrfzz.js";
2
- import"./chunk-0bf7c9q3.js";
2
+ import"./chunk-0t9a8vn8.js";
3
3
  import"./chunk-xp3fx2yt.js";
4
4
  import {
5
5
  buildDalpClient
6
- } from "./chunk-9y1cjngw.js";
6
+ } from "./chunk-d4agy53b.js";
7
7
 
8
8
  // src/bundler.ts
9
9
  import { getAddress, hexToBigInt, isHex } from "viem";
@@ -512,8 +512,17 @@ function withConditionalRequests(base) {
512
512
  }
513
513
 
514
514
  // src/proxy/flat-args.ts
515
+ function asFlatObject(value) {
516
+ return value === null || value === undefined || typeof value !== "object" ? {} : { ...value };
517
+ }
518
+ function assertPathParams(route, path) {
519
+ const missing = route.params.filter((name) => path[name] === undefined);
520
+ if (missing.length > 0) {
521
+ throw new TypeError(`Missing path parameter${missing.length === 1 ? "" : "s"} ${missing.map((name) => `\`${name}\``).join(", ")} for ${route.method} ${route.path}`);
522
+ }
523
+ }
515
524
  function splitFlatArgs(route, input) {
516
- const source = input === null || input === undefined || typeof input !== "object" ? {} : input;
525
+ const source = asFlatObject(input);
517
526
  const path = {};
518
527
  const query = {};
519
528
  const rest = {};
@@ -528,10 +537,7 @@ function splitFlatArgs(route, input) {
528
537
  rest[key] = value;
529
538
  }
530
539
  }
531
- const missing = route.params.filter((name) => path[name] === undefined);
532
- if (missing.length > 0) {
533
- throw new TypeError(`Missing path parameter${missing.length === 1 ? "" : "s"} ${missing.map((name) => `\`${name}\``).join(", ")} for ${route.method} ${route.path}`);
534
- }
540
+ assertPathParams(route, path);
535
541
  if (!route.hasPayload) {
536
542
  return { path, query: rest, body: undefined };
537
543
  }
@@ -546,6 +552,25 @@ function splitFlatArgs(route, input) {
546
552
  }
547
553
  return { path, query, body: rest };
548
554
  }
555
+ function splitRequestParts(route, parts) {
556
+ const source = asFlatObject(parts);
557
+ const path = asFlatObject(source["params"]);
558
+ const query = asFlatObject(source["query"]);
559
+ assertPathParams(route, path);
560
+ if (!route.hasPayload) {
561
+ return { path, query, body: undefined };
562
+ }
563
+ const body = asFlatObject(source["body"]);
564
+ for (const name of route.bodyParams) {
565
+ if (body[name] === undefined && path[name] !== undefined) {
566
+ body[name] = path[name];
567
+ }
568
+ }
569
+ return { path, query, body };
570
+ }
571
+ function splitRequestInput(route, input) {
572
+ return "parts" in input ? splitRequestParts(route, input.parts) : splitFlatArgs(route, input.flat);
573
+ }
549
574
  function buildPath(route, path) {
550
575
  return route.path.replaceAll(/:([A-Za-z0-9_]+)/gu, (_match, name) => {
551
576
  const value = path[name];
@@ -647,7 +672,7 @@ function callHeaders(transport, options) {
647
672
  return headers;
648
673
  }
649
674
  function prepareRequest(transport, route, input, options) {
650
- const split = splitFlatArgs(route, input);
675
+ const split = splitRequestInput(route, input);
651
676
  const query = serializeDalpQuery(split.query);
652
677
  const url = `${transport.baseUrl}/api/v2${buildPath(route, split.path)}${query === "" ? "" : `?${query}`}`;
653
678
  const headers = callHeaders(transport, options);
@@ -732,6 +757,448 @@ async function readResponse(response) {
732
757
  return payload;
733
758
  }
734
759
 
760
+ // src/proxy/response-decode.ts
761
+ var MALFORMED_SUCCESS_ERROR_CODE2 = "sdk.response.MALFORMED_SUCCESS";
762
+ function kindOf(value) {
763
+ if (value === null) {
764
+ return "null";
765
+ }
766
+ if (Array.isArray(value)) {
767
+ return "array";
768
+ }
769
+ if (typeof value === "number") {
770
+ return Number.isInteger(value) ? "integer" : "number";
771
+ }
772
+ return typeof value;
773
+ }
774
+ function isObject(value) {
775
+ return value !== null && typeof value === "object" && !Array.isArray(value);
776
+ }
777
+ function matchesType(type, value) {
778
+ switch (type) {
779
+ case "string": {
780
+ return typeof value === "string";
781
+ }
782
+ case "number": {
783
+ return typeof value === "number";
784
+ }
785
+ case "integer": {
786
+ return Number.isInteger(value);
787
+ }
788
+ case "boolean": {
789
+ return typeof value === "boolean";
790
+ }
791
+ case "null": {
792
+ return value === null;
793
+ }
794
+ case "array": {
795
+ return Array.isArray(value);
796
+ }
797
+ case "object": {
798
+ return isObject(value);
799
+ }
800
+ default: {
801
+ return false;
802
+ }
803
+ }
804
+ }
805
+ function jsonEqual(left, right) {
806
+ if (left === right) {
807
+ return true;
808
+ }
809
+ if (typeof left !== "object" || typeof right !== "object" || left === null || right === null) {
810
+ return false;
811
+ }
812
+ if (Array.isArray(left) !== Array.isArray(right)) {
813
+ return false;
814
+ }
815
+ const leftKeys = Object.keys(left);
816
+ if (leftKeys.length !== Object.keys(right).length) {
817
+ return false;
818
+ }
819
+ return leftKeys.every((key) => Object.hasOwn(right, key) && jsonEqual(Reflect.get(left, key), Reflect.get(right, key)));
820
+ }
821
+ function depthOf(path) {
822
+ let depth = 0;
823
+ for (const character of path) {
824
+ if (character === "." || character === "[") {
825
+ depth += 1;
826
+ }
827
+ }
828
+ return depth;
829
+ }
830
+ function compilePattern(pattern) {
831
+ try {
832
+ return new RegExp(pattern, "u");
833
+ } catch {
834
+ return new RegExp(pattern);
835
+ }
836
+ }
837
+
838
+ class ResponseSchemaChecker {
839
+ compiled = new Map;
840
+ patterns = new Map;
841
+ definitions;
842
+ constructor(definitions) {
843
+ this.definitions = definitions;
844
+ }
845
+ validate(node, value) {
846
+ return this.compile(node)(value);
847
+ }
848
+ explain(node, value, path = "$") {
849
+ if (this.validate(node, value)) {
850
+ return;
851
+ }
852
+ if (node.$ref !== undefined) {
853
+ return this.explain(this.definition(node.$ref), value, path);
854
+ }
855
+ const typeMismatch = this.explainType(node, value, path);
856
+ if (typeMismatch !== undefined) {
857
+ return typeMismatch;
858
+ }
859
+ return this.explainValue(node, value, path) ?? this.explainObject(node, value, path) ?? this.explainArray(node, value, path) ?? this.explainComposition(node, value, path) ?? {
860
+ path,
861
+ expected: "a value matching the schema",
862
+ received: kindOf(value)
863
+ };
864
+ }
865
+ definition(name) {
866
+ const node = this.definitions[name];
867
+ if (node === undefined) {
868
+ throw new TypeError(`DALP SDK response schema references the missing definition ${name}`);
869
+ }
870
+ return node;
871
+ }
872
+ pattern(source) {
873
+ let compiled = this.patterns.get(source);
874
+ if (compiled === undefined) {
875
+ compiled = compilePattern(source);
876
+ this.patterns.set(source, compiled);
877
+ }
878
+ return compiled;
879
+ }
880
+ compile(node) {
881
+ const cached = this.compiled.get(node);
882
+ if (cached !== undefined) {
883
+ return cached;
884
+ }
885
+ const built = this.build(node);
886
+ this.compiled.set(node, built);
887
+ return built;
888
+ }
889
+ build(node) {
890
+ const checks = [];
891
+ if (node.$ref !== undefined) {
892
+ const name = node.$ref;
893
+ let target;
894
+ checks.push((value) => (target ??= this.compile(this.definition(name)))(value));
895
+ }
896
+ if (node.type !== undefined) {
897
+ const types = typeof node.type === "string" ? [node.type] : node.type;
898
+ checks.push(types.length === 1 ? (value) => matchesType(types[0], value) : (value) => types.some((type) => matchesType(type, value)));
899
+ }
900
+ this.buildValueChecks(node, checks);
901
+ this.buildObjectChecks(node, checks);
902
+ this.buildArrayChecks(node, checks);
903
+ this.buildCompositionChecks(node, checks);
904
+ if (checks.length === 0) {
905
+ return () => true;
906
+ }
907
+ if (checks.length === 1) {
908
+ return checks[0];
909
+ }
910
+ return (value) => {
911
+ for (const check of checks) {
912
+ if (!check(value)) {
913
+ return false;
914
+ }
915
+ }
916
+ return true;
917
+ };
918
+ }
919
+ buildValueChecks(node, checks) {
920
+ if (node.enum !== undefined) {
921
+ const members = node.enum;
922
+ const primitives = new Set(members.filter((member) => member === null || typeof member !== "object"));
923
+ checks.push((value) => primitives.has(value) || members.some((member) => typeof member === "object" && jsonEqual(member, value)));
924
+ }
925
+ if ("const" in node) {
926
+ const expected = node.const;
927
+ checks.push((value) => jsonEqual(expected, value));
928
+ }
929
+ const { pattern, minLength, maxLength, minimum, maximum, exclusiveMinimum, exclusiveMaximum, multipleOf } = node;
930
+ if (pattern !== undefined) {
931
+ const regex = this.pattern(pattern);
932
+ checks.push((value) => typeof value !== "string" || regex.test(value));
933
+ }
934
+ if (minLength !== undefined) {
935
+ checks.push((value) => typeof value !== "string" || value.length >= minLength);
936
+ }
937
+ if (maxLength !== undefined) {
938
+ checks.push((value) => typeof value !== "string" || value.length <= maxLength);
939
+ }
940
+ if (minimum !== undefined) {
941
+ checks.push((value) => typeof value !== "number" || value >= minimum);
942
+ }
943
+ if (maximum !== undefined) {
944
+ checks.push((value) => typeof value !== "number" || value <= maximum);
945
+ }
946
+ if (exclusiveMinimum !== undefined) {
947
+ checks.push((value) => typeof value !== "number" || value > exclusiveMinimum);
948
+ }
949
+ if (exclusiveMaximum !== undefined) {
950
+ checks.push((value) => typeof value !== "number" || value < exclusiveMaximum);
951
+ }
952
+ if (multipleOf !== undefined) {
953
+ checks.push((value) => typeof value !== "number" || Number.isInteger(value / multipleOf));
954
+ }
955
+ }
956
+ buildObjectChecks(node, checks) {
957
+ const { properties, required, additionalProperties, propertyNames } = node;
958
+ if (required !== undefined && required.length > 0) {
959
+ checks.push((value) => !isObject(value) || required.every((key) => Object.hasOwn(value, key)));
960
+ }
961
+ if (properties !== undefined) {
962
+ const entries = Object.entries(properties).map(([key, child]) => [key, this.compile(child)]);
963
+ checks.push((value) => {
964
+ if (!isObject(value)) {
965
+ return true;
966
+ }
967
+ for (const [key, check] of entries) {
968
+ if (Object.hasOwn(value, key) && !check(Reflect.get(value, key))) {
969
+ return false;
970
+ }
971
+ }
972
+ return true;
973
+ });
974
+ }
975
+ if (typeof additionalProperties === "object") {
976
+ const declared = new Set(Object.keys(properties ?? {}));
977
+ const check = this.compile(additionalProperties);
978
+ checks.push((value) => {
979
+ if (!isObject(value)) {
980
+ return true;
981
+ }
982
+ for (const key in value) {
983
+ if (Object.hasOwn(value, key) && !declared.has(key) && !check(Reflect.get(value, key))) {
984
+ return false;
985
+ }
986
+ }
987
+ return true;
988
+ });
989
+ }
990
+ if (propertyNames !== undefined) {
991
+ const check = this.compile(propertyNames);
992
+ checks.push((value) => !isObject(value) || Object.keys(value).every(check));
993
+ }
994
+ }
995
+ buildArrayChecks(node, checks) {
996
+ const { items, prefixItems, minItems, maxItems } = node;
997
+ const prefix = (prefixItems ?? []).map((child) => this.compile(child));
998
+ if (prefix.length > 0) {
999
+ checks.push((value) => !Array.isArray(value) || prefix.every((check, index) => index >= value.length || check(value[index])));
1000
+ }
1001
+ if (items !== undefined) {
1002
+ const check = this.compile(items);
1003
+ const from = prefix.length;
1004
+ checks.push((value) => {
1005
+ if (!Array.isArray(value)) {
1006
+ return true;
1007
+ }
1008
+ for (let index = from;index < value.length; index += 1) {
1009
+ if (!check(value[index])) {
1010
+ return false;
1011
+ }
1012
+ }
1013
+ return true;
1014
+ });
1015
+ }
1016
+ if (minItems !== undefined) {
1017
+ checks.push((value) => !Array.isArray(value) || value.length >= minItems);
1018
+ }
1019
+ if (maxItems !== undefined) {
1020
+ checks.push((value) => !Array.isArray(value) || value.length <= maxItems);
1021
+ }
1022
+ }
1023
+ buildCompositionChecks(node, checks) {
1024
+ if (node.allOf !== undefined) {
1025
+ const all = node.allOf.map((child) => this.compile(child));
1026
+ checks.push((value) => all.every((check) => check(value)));
1027
+ }
1028
+ if (node.anyOf !== undefined) {
1029
+ const any = node.anyOf.map((child) => this.compile(child));
1030
+ checks.push((value) => any.some((check) => check(value)));
1031
+ }
1032
+ if (node.oneOf !== undefined) {
1033
+ const one = node.oneOf.map((child) => this.compile(child));
1034
+ checks.push((value) => one.filter((check) => check(value)).length === 1);
1035
+ }
1036
+ }
1037
+ explainType(node, value, path) {
1038
+ if (node.type === undefined) {
1039
+ return;
1040
+ }
1041
+ const types = typeof node.type === "string" ? [node.type] : node.type;
1042
+ return types.some((type) => matchesType(type, value)) ? undefined : { path, expected: types.join(" | "), received: kindOf(value) };
1043
+ }
1044
+ explainValue(node, value, path) {
1045
+ const checks = [];
1046
+ this.buildValueChecks(node, checks);
1047
+ if (checks.every((check) => check(value))) {
1048
+ return;
1049
+ }
1050
+ let expected = "a value within the schema's bounds";
1051
+ if (node.enum !== undefined) {
1052
+ expected = `one of ${String(node.enum.length)} allowed values`;
1053
+ } else if ("const" in node) {
1054
+ expected = "the schema's constant value";
1055
+ } else if (node.pattern !== undefined && typeof value === "string" && !this.pattern(node.pattern).test(value)) {
1056
+ expected = "a string matching the schema pattern";
1057
+ }
1058
+ return { path, expected, received: kindOf(value) };
1059
+ }
1060
+ explainObject(node, value, path) {
1061
+ if (!isObject(value)) {
1062
+ return;
1063
+ }
1064
+ for (const key of node.required ?? []) {
1065
+ if (!Object.hasOwn(value, key)) {
1066
+ return { path: `${path}.${key}`, expected: "a required property", received: "missing" };
1067
+ }
1068
+ }
1069
+ const properties = node.properties ?? {};
1070
+ for (const [key, child] of Object.entries(properties)) {
1071
+ if (Object.hasOwn(value, key)) {
1072
+ const mismatch = this.explain(child, Reflect.get(value, key), `${path}.${key}`);
1073
+ if (mismatch !== undefined) {
1074
+ return mismatch;
1075
+ }
1076
+ }
1077
+ }
1078
+ const extra = node.additionalProperties;
1079
+ for (const key of Object.keys(value)) {
1080
+ if (node.propertyNames !== undefined && !this.validate(node.propertyNames, key)) {
1081
+ return { path: `${path}.{key}`, expected: "a property name matching the schema", received: "string" };
1082
+ }
1083
+ if (typeof extra === "object" && !Object.hasOwn(properties, key)) {
1084
+ const mismatch = this.explain(extra, Reflect.get(value, key), `${path}.{key}`);
1085
+ if (mismatch !== undefined) {
1086
+ return mismatch;
1087
+ }
1088
+ }
1089
+ }
1090
+ return;
1091
+ }
1092
+ explainArray(node, value, path) {
1093
+ if (!Array.isArray(value)) {
1094
+ return;
1095
+ }
1096
+ const { minItems, maxItems, prefixItems = [], items } = node;
1097
+ if (minItems !== undefined && value.length < minItems || maxItems !== undefined && value.length > maxItems) {
1098
+ return { path, expected: "an array length within the schema's bounds", received: "array" };
1099
+ }
1100
+ for (const [index, element] of value.entries()) {
1101
+ const child = index < prefixItems.length ? prefixItems[index] : items;
1102
+ const mismatch = child === undefined ? undefined : this.explain(child, element, `${path}[${String(index)}]`);
1103
+ if (mismatch !== undefined) {
1104
+ return mismatch;
1105
+ }
1106
+ }
1107
+ return;
1108
+ }
1109
+ explainComposition(node, value, path) {
1110
+ for (const child of node.allOf ?? []) {
1111
+ const mismatch = this.explain(child, value, path);
1112
+ if (mismatch !== undefined) {
1113
+ return mismatch;
1114
+ }
1115
+ }
1116
+ const variants = node.anyOf ?? node.oneOf;
1117
+ if (variants === undefined || variants.some((child) => this.validate(child, value))) {
1118
+ return;
1119
+ }
1120
+ const tagged = variants.filter((child) => this.tagsMatch(child, value));
1121
+ const candidates = tagged.length === 1 ? tagged : variants;
1122
+ let deepest;
1123
+ for (const child of candidates) {
1124
+ const mismatch = this.explain(child, value, path);
1125
+ if (mismatch !== undefined && (deepest === undefined || depthOf(mismatch.path) > depthOf(deepest.path))) {
1126
+ deepest = mismatch;
1127
+ }
1128
+ }
1129
+ return deepest !== undefined && (tagged.length === 1 || deepest.path !== path) ? deepest : { path, expected: `one of ${String(variants.length)} variants`, received: kindOf(value) };
1130
+ }
1131
+ tagsMatch(node, value) {
1132
+ const resolved = node.$ref === undefined ? node : this.definition(node.$ref);
1133
+ if (!isObject(value) || resolved.properties === undefined) {
1134
+ return false;
1135
+ }
1136
+ let tags = 0;
1137
+ for (const [key, child] of Object.entries(resolved.properties)) {
1138
+ const property = child.$ref === undefined ? child : this.definition(child.$ref);
1139
+ const tag = property.enum?.length === 1 ? property.enum[0] : property.const;
1140
+ if (tag === undefined) {
1141
+ continue;
1142
+ }
1143
+ if (!jsonEqual(tag, Reflect.get(value, key))) {
1144
+ return false;
1145
+ }
1146
+ tags += 1;
1147
+ }
1148
+ return tags > 0;
1149
+ }
1150
+ }
1151
+ function malformedSuccess(routeId, status, mismatch) {
1152
+ return makeDalpApiError2(new DalpSdkError2({
1153
+ code: MALFORMED_SUCCESS_ERROR_CODE2,
1154
+ category: "dependency",
1155
+ status,
1156
+ retryable: false,
1157
+ message: `DALP API responded ${String(status)} to ${routeId} with a body that does not match the route's schema at ${mismatch.path}`,
1158
+ why: `The success body failed the ${routeId} response schema: ${mismatch.path} should be ${mismatch.expected}, but it is ${mismatch.received}.`,
1159
+ fix: "Check that the SDK version matches the platform version. If they match, report the route id and field path: the platform served a body its own contract does not allow.",
1160
+ details: { routeId, status, path: mismatch.path, expected: mismatch.expected, received: mismatch.received }
1161
+ }));
1162
+ }
1163
+
1164
+ class ResponseDecoder {
1165
+ checker;
1166
+ table;
1167
+ constructor(table) {
1168
+ this.table = table;
1169
+ this.checker = new ResponseSchemaChecker(table.definitions);
1170
+ }
1171
+ decode(routeId, status, payload) {
1172
+ const statuses = this.table.routes[routeId];
1173
+ const schema = statuses?.[String(status)];
1174
+ if (schema === undefined || schema === null) {
1175
+ throw malformedSuccess(routeId, status, {
1176
+ path: "$",
1177
+ expected: statuses === undefined ? "a route the SDK knows" : `a status the route declares (${Object.keys(statuses).join(", ")})`,
1178
+ received: statuses === undefined ? "an unknown route" : `status ${String(status)}`
1179
+ });
1180
+ }
1181
+ if (this.checker.validate(schema, payload)) {
1182
+ return payload;
1183
+ }
1184
+ throw malformedSuccess(routeId, status, this.checker.explain(schema, payload) ?? { path: "$", expected: "the route's schema", received: kindOf(payload) });
1185
+ }
1186
+ }
1187
+ var shared;
1188
+ async function importResponseDecoder() {
1189
+ const { data } = await import("./chunk-74chbmzc.js");
1190
+ return new ResponseDecoder(data);
1191
+ }
1192
+ async function loadResponseDecoder() {
1193
+ shared ??= importResponseDecoder();
1194
+ try {
1195
+ return await shared;
1196
+ } catch (error) {
1197
+ shared = undefined;
1198
+ throw error;
1199
+ }
1200
+ }
1201
+
735
1202
  // src/proxy/sse.ts
736
1203
  var RESERVED_STREAM_FAILURE_EVENT2 = "effect/httpapi/stream/failure";
737
1204
  var STREAM_FAILED_ERROR_CODE2 = "sdk.stream.FAILED";
@@ -742,7 +1209,7 @@ function parseFrame(raw) {
742
1209
  return raw.data;
743
1210
  }
744
1211
  }
745
- function dispatchFrame(raw) {
1212
+ function dispatchFrame(raw, decodeFrame) {
746
1213
  if (raw.event === RESERVED_STREAM_FAILURE_EVENT2) {
747
1214
  throw makeDalpApiError2(new DalpSdkError2({
748
1215
  code: STREAM_FAILED_ERROR_CODE2,
@@ -754,7 +1221,8 @@ function dispatchFrame(raw) {
754
1221
  details: { cause: raw.data }
755
1222
  }));
756
1223
  }
757
- return parseFrame(raw);
1224
+ const frame = parseFrame(raw);
1225
+ return decodeFrame === undefined ? frame : decodeFrame(frame);
758
1226
  }
759
1227
  function readBlock(block) {
760
1228
  let event = "message";
@@ -776,7 +1244,7 @@ function readBlock(block) {
776
1244
  return data.length === 0 ? undefined : { event, data: data.join(`
777
1245
  `) };
778
1246
  }
779
- async function* decodeEventStream2(body) {
1247
+ async function* decodeEventStream2(body, decodeFrame) {
780
1248
  const reader = body.getReader();
781
1249
  const decoder = new TextDecoder;
782
1250
  let buffer = "";
@@ -797,7 +1265,7 @@ async function* decodeEventStream2(body) {
797
1265
  const raw = readBlock(buffer.slice(0, boundary));
798
1266
  buffer = buffer.slice(boundary + 2);
799
1267
  if (raw !== undefined) {
800
- yield dispatchFrame(raw);
1268
+ yield dispatchFrame(raw, decodeFrame);
801
1269
  }
802
1270
  boundary = buffer.indexOf(`
803
1271
 
@@ -806,13 +1274,13 @@ async function* decodeEventStream2(body) {
806
1274
  }
807
1275
  const trailing = readBlock(buffer);
808
1276
  if (trailing !== undefined) {
809
- yield dispatchFrame(trailing);
1277
+ yield dispatchFrame(trailing, decodeFrame);
810
1278
  }
811
1279
  } finally {
812
1280
  await reader.cancel().catch(() => {});
813
1281
  }
814
1282
  }
815
- async function* openEventStream(transport, route, input, options, signal, closed) {
1283
+ async function* openEventStream(transport, route, routeId, input, options, signal, closed) {
816
1284
  const prepared = prepareRequest(transport, route, input, options);
817
1285
  prepared.headers.set("Accept", "text/event-stream");
818
1286
  const response = await transport.fetch(prepared.url, {
@@ -829,15 +1297,17 @@ async function* openEventStream(transport, route, input, options, signal, closed
829
1297
  if (response.body === null) {
830
1298
  return;
831
1299
  }
1300
+ const decoder = await loadResponseDecoder();
1301
+ const { status } = response;
832
1302
  try {
833
- yield* decodeEventStream2(response.body);
1303
+ yield* decodeEventStream2(response.body, (frame) => decoder.decode(routeId, status, frame));
834
1304
  } catch (error) {
835
1305
  if (!closed.byConsumer) {
836
1306
  throw error;
837
1307
  }
838
1308
  }
839
1309
  }
840
- function streamRequest(transport, route, input, options) {
1310
+ function streamRequest(transport, route, routeId, input, options) {
841
1311
  const closing = new AbortController;
842
1312
  const callerSignal = options?.signal;
843
1313
  if (callerSignal !== undefined) {
@@ -848,7 +1318,7 @@ function streamRequest(transport, route, input, options) {
848
1318
  }
849
1319
  }
850
1320
  const closed = { byConsumer: false };
851
- const frames = openEventStream(transport, route, input, options, closing.signal, closed);
1321
+ const frames = openEventStream(transport, route, routeId, input, options, closing.signal, closed);
852
1322
  const close = () => {
853
1323
  closed.byConsumer = true;
854
1324
  closing.abort();
@@ -874,7 +1344,7 @@ function streamRequest(transport, route, input, options) {
874
1344
  }
875
1345
 
876
1346
  // src/proxy/fetch-executor.ts
877
- async function sendRequest(transport, route, input, options) {
1347
+ async function sendRequest(transport, route, routeId, input, options) {
878
1348
  const prepared = prepareRequest(transport, route, input, options);
879
1349
  const response = await transport.fetch(prepared.url, {
880
1350
  method: prepared.method,
@@ -883,10 +1353,12 @@ async function sendRequest(transport, route, input, options) {
883
1353
  ...prepared.body === undefined ? {} : { body: prepared.body },
884
1354
  ...options?.signal === undefined ? {} : { signal: options.signal }
885
1355
  });
886
- return readResponse(response);
1356
+ const payload = await readResponse(response);
1357
+ const decoder = await loadResponseDecoder();
1358
+ return decoder.decode(routeId, response.status, payload);
887
1359
  }
888
1360
  function createFetchExecutor(transport) {
889
- return (route, _id, input, options) => route.serializer === "sse" ? streamRequest(transport, route, input, options) : sendRequest(transport, route, input, options);
1361
+ return (route, id, input, options) => route.serializer === "sse" ? streamRequest(transport, route, id, { flat: input }, options) : sendRequest(transport, route, id, { flat: input }, options);
890
1362
  }
891
1363
 
892
1364
  // src/proxy/tanstack.ts
@@ -915,16 +1387,16 @@ function createTanstackFactories(transport) {
915
1387
  return {
916
1388
  queryOptions: (route, id, input, options) => ({
917
1389
  queryKey: queryKeyFor2(id, input),
918
- queryFn: (context) => sendRequest(transport, route, input, {
1390
+ queryFn: (context) => sendRequest(transport, route, id, { flat: input }, {
919
1391
  ...options,
920
1392
  ...context.signal === undefined ? {} : { signal: context.signal }
921
1393
  })
922
1394
  }),
923
1395
  mutationOptions: (route, id, options) => ({
924
1396
  mutationKey: ["dalp", id],
925
- mutationFn: (input) => sendRequest(transport, route, input, { settlementTimeoutMs: UI_SETTLEMENT_TIMEOUT_MS2, ...options })
1397
+ mutationFn: (input) => sendRequest(transport, route, id, { flat: input }, { settlementTimeoutMs: UI_SETTLEMENT_TIMEOUT_MS2, ...options })
926
1398
  })
927
1399
  };
928
1400
  }
929
1401
 
930
- export { DalpApiError2, isDalpApiError2, findDalpSdkError2, makeDalpApiError2, createDalpContextHeaders2, createTransport, RESERVED_STREAM_FAILURE_EVENT2, STREAM_FAILED_ERROR_CODE2, decodeEventStream2, streamRequest, sendRequest, createFetchExecutor, canonicalize2, queryKeyFor2, UI_SETTLEMENT_TIMEOUT_MS2, createTanstackFactories };
1402
+ export { DalpApiError2, isDalpApiError2, findDalpSdkError2, makeDalpApiError2, createDalpContextHeaders2, createTransport, MALFORMED_SUCCESS_ERROR_CODE2, RESERVED_STREAM_FAILURE_EVENT2, STREAM_FAILED_ERROR_CODE2, decodeEventStream2, streamRequest, sendRequest, createFetchExecutor, canonicalize2, queryKeyFor2, UI_SETTLEMENT_TIMEOUT_MS2, createTanstackFactories };