@arrirpc/client 0.54.0 → 0.57.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.
package/dist/index.cjs CHANGED
@@ -1,5 +1,6 @@
1
1
  'use strict';
2
2
 
3
+ const schema = require('@arrirpc/schema');
3
4
  const ofetch = require('ofetch');
4
5
  const eventSourcePlus = require('event-source-plus');
5
6
  const NodeWebsocket = require('ws');
@@ -79,7 +80,7 @@ async function getHeaders(input) {
79
80
  }
80
81
  return result;
81
82
  }
82
- return input;
83
+ return input ?? {};
83
84
  }
84
85
 
85
86
  async function arriRequest(opts) {
@@ -90,11 +91,7 @@ async function arriRequest(opts) {
90
91
  case "get":
91
92
  case "head":
92
93
  if (opts.params && typeof opts.params === "object") {
93
- const urlParts = [];
94
- Object.keys(opts.params).forEach((key) => {
95
- urlParts.push(`${key}=${opts.params[key]}`);
96
- });
97
- url = `${opts.url}?${urlParts.join("&")}`;
94
+ url = `${opts.url}?${opts.serializer(opts.params)}`;
98
95
  }
99
96
  break;
100
97
  default:
@@ -115,7 +112,7 @@ async function arriRequest(opts) {
115
112
  body,
116
113
  headers
117
114
  });
118
- return opts.parser(result);
115
+ return opts.responseFromJson(result);
119
116
  } catch (err) {
120
117
  const error = err;
121
118
  if (isArriError(error.data)) {
@@ -165,6 +162,34 @@ async function arriSafeRequest(opts) {
165
162
  };
166
163
  }
167
164
  }
165
+ const STR_ESCAPE = (
166
+ // eslint-disable-next-line no-control-regex
167
+ /[\u0000-\u001f\u0022\u005c\ud800-\udfff]|[\ud800-\udbff](?![\udc00-\udfff])|(?:[^\ud800-\udbff]|^)[\udc00-\udfff]/
168
+ );
169
+ function serializeString(input) {
170
+ if (input.length < 42) {
171
+ return schema.serializeSmallString(input);
172
+ }
173
+ if (input.length < 5e3 && !STR_ESCAPE.test(input)) {
174
+ return `"${input}"`;
175
+ }
176
+ return JSON.stringify(input);
177
+ }
178
+ const INT8_MIN = -128;
179
+ const INT8_MAX = 127;
180
+ const UINT8_MAX = 255;
181
+ const INT16_MIN = -32768;
182
+ const INT16_MAX = 32767;
183
+ const UINT16_MAX = 65535;
184
+ const INT32_MIN = -2147483648;
185
+ const INT32_MAX = 2147483647;
186
+ const UINT32_MAX = 4294967295;
187
+ const INT64_MIN = BigInt("9223372036854775808");
188
+ const INT64_MAX = BigInt("9223372036854775807");
189
+ const UINT64_MAX = BigInt("18446744073709551615");
190
+ function isObject(input) {
191
+ return typeof input === "object" && input !== null;
192
+ }
168
193
 
169
194
  function arriSseRequest(opts, options) {
170
195
  let url = opts.url;
@@ -173,11 +198,7 @@ function arriSseRequest(opts, options) {
173
198
  case "get":
174
199
  case "head":
175
200
  if (opts.params && typeof opts.params === "object" && opts.params !== null) {
176
- const urlParts = [];
177
- Object.keys(opts.params).forEach((key) => {
178
- urlParts.push(`${key}=${opts.params[key]}`);
179
- });
180
- url = `${opts.url}?${urlParts.join("&")}`;
201
+ url = `${opts.url}?${opts.serializer(opts.params)}`;
181
202
  }
182
203
  break;
183
204
  default:
@@ -202,7 +223,7 @@ function arriSseRequest(opts, options) {
202
223
  const controller = eventSource.listen({
203
224
  onMessage(message) {
204
225
  if (message.event === "message" || message.event === void 0 || message.event === "") {
205
- options.onMessage?.(opts.parser(message.data));
226
+ options.onMessage?.(opts.responseFromString(message.data));
206
227
  return;
207
228
  }
208
229
  if (message.event === "done") {
@@ -319,7 +340,8 @@ async function arriWsRequest(opts, retryCount = 0) {
319
340
  try {
320
341
  const controller = new WsController({
321
342
  url,
322
- parser: opts.parser,
343
+ responseFromJson: opts.responseFromJson,
344
+ responseFromString: opts.responseFromString,
323
345
  serializer: opts.serializer ?? ((_) => ""),
324
346
  onOpen: opts.onOpen,
325
347
  onClose: opts.onClose,
@@ -349,7 +371,7 @@ class WsController {
349
371
  __publicField(this, "onClose");
350
372
  this.url = opts.url;
351
373
  this._serializer = opts.serializer;
352
- this._parser = opts.parser;
374
+ this._parser = opts.responseFromString;
353
375
  this.onOpen = opts.onOpen;
354
376
  this.onClose = opts.onClose;
355
377
  this.onErrorMessage = opts.onErrorMessage;
@@ -445,14 +467,29 @@ function parsedWsResponse(input) {
445
467
  }
446
468
 
447
469
  exports.ArriErrorInstance = ArriErrorInstance;
470
+ exports.INT16_MAX = INT16_MAX;
471
+ exports.INT16_MIN = INT16_MIN;
472
+ exports.INT32_MAX = INT32_MAX;
473
+ exports.INT32_MIN = INT32_MIN;
474
+ exports.INT64_MAX = INT64_MAX;
475
+ exports.INT64_MIN = INT64_MIN;
476
+ exports.INT8_MAX = INT8_MAX;
477
+ exports.INT8_MIN = INT8_MIN;
478
+ exports.UINT16_MAX = UINT16_MAX;
479
+ exports.UINT32_MAX = UINT32_MAX;
480
+ exports.UINT64_MAX = UINT64_MAX;
481
+ exports.UINT8_MAX = UINT8_MAX;
482
+ exports.WsController = WsController;
448
483
  exports.arriRequest = arriRequest;
449
484
  exports.arriSafeRequest = arriSafeRequest;
450
485
  exports.arriSseRequest = arriSseRequest;
451
486
  exports.arriWsRequest = arriWsRequest;
452
487
  exports.isArriError = isArriError;
488
+ exports.isObject = isObject;
453
489
  exports.parseSseEvent = parseSseEvent;
454
490
  exports.parseSseEvents = parseSseEvents;
455
491
  exports.parsedWsResponse = parsedWsResponse;
492
+ exports.serializeString = serializeString;
456
493
  Object.keys(eventSourcePlus).forEach(function (k) {
457
494
  if (k !== 'default' && !Object.prototype.hasOwnProperty.call(exports, k)) exports[k] = eventSourcePlus[k];
458
495
  });
package/dist/index.d.cts CHANGED
@@ -32,11 +32,12 @@ declare class ArriErrorInstance extends Error implements ArriError {
32
32
  interface ArriRequestOpts<TType, TParams extends Record<any, any> | undefined = undefined> {
33
33
  url: string;
34
34
  method: HttpMethod;
35
- headers?: EventSourcePlusOptions["headers"];
35
+ headers: EventSourcePlusOptions["headers"];
36
36
  params?: TParams;
37
- parser: (input: unknown) => TType;
37
+ responseFromJson: (input: Record<string, unknown>) => TType;
38
+ responseFromString: (input: string) => TType;
38
39
  serializer: (input: TParams) => TParams extends undefined ? undefined : string;
39
- clientVersion?: string;
40
+ clientVersion: string;
40
41
  }
41
42
  declare function arriRequest<TType, TParams extends Record<any, any> | undefined = undefined>(opts: ArriRequestOpts<TType, TParams>): Promise<TType>;
42
43
  declare function arriSafeRequest<TType, TParams extends Record<any, any> | undefined = undefined>(opts: ArriRequestOpts<TType, TParams>): Promise<SafeResponse<TType>>;
@@ -47,6 +48,34 @@ type SafeResponse<T> = {
47
48
  success: false;
48
49
  error: ArriErrorInstance;
49
50
  };
51
+ interface ArriModelValidator<T> {
52
+ new: () => T;
53
+ validate: (input: unknown) => input is T;
54
+ fromJson: (input: Record<string, unknown>) => T;
55
+ fromJsonString: (input: string) => T;
56
+ toJsonString: (input: T) => string;
57
+ toUrlQueryString: (input: T) => string;
58
+ }
59
+ interface ArriEnumValidator<T> {
60
+ new: () => T;
61
+ values: readonly T[];
62
+ validate: (input: unknown) => input is T;
63
+ fromSerialValue: (input: string) => T;
64
+ }
65
+ declare function serializeString(input: string): string;
66
+ declare const INT8_MIN = -128;
67
+ declare const INT8_MAX = 127;
68
+ declare const UINT8_MAX = 255;
69
+ declare const INT16_MIN = -32768;
70
+ declare const INT16_MAX = 32767;
71
+ declare const UINT16_MAX = 65535;
72
+ declare const INT32_MIN = -2147483648;
73
+ declare const INT32_MAX = 2147483647;
74
+ declare const UINT32_MAX = 4294967295;
75
+ declare const INT64_MIN: bigint;
76
+ declare const INT64_MAX: bigint;
77
+ declare const UINT64_MAX: bigint;
78
+ declare function isObject(input: unknown): input is Record<string, unknown>;
50
79
 
51
80
  interface SseEvent<TData = string> {
52
81
  id?: string;
@@ -74,7 +103,8 @@ declare function parseSseEvents<TData = string>(input: string, dataParser: (inpu
74
103
  interface WsControllerOptions<TParams, TResponse> {
75
104
  url: string;
76
105
  serializer: (input: TParams) => string;
77
- parser: (input: unknown) => TResponse;
106
+ responseFromJson: (input: Record<string, unknown>) => TResponse;
107
+ responseFromString: (input: string) => TResponse;
78
108
  onMessage?: WsMessageHook<TResponse>;
79
109
  onErrorMessage?: WsErrorHook;
80
110
  onConnectionError?: WsErrorHook;
@@ -92,7 +122,8 @@ interface ArriWsRequestOptions<TParams = any, TResponse = any> {
92
122
  url: string;
93
123
  headers?: EventSourcePlusOptions["headers"];
94
124
  params?: TParams;
95
- parser: (input: unknown) => TResponse;
125
+ responseFromJson: (input: Record<string, unknown>) => TResponse;
126
+ responseFromString: (input: string) => TResponse;
96
127
  serializer: (input: TParams) => string;
97
128
  onMessage?: WsMessageHook<TResponse>;
98
129
  onError?: WsErrorHook;
@@ -126,4 +157,4 @@ declare function parsedWsResponse(input: string): {
126
157
  data: string;
127
158
  };
128
159
 
129
- export { type ArriError, ArriErrorInstance, type ArriRequestOpts, type SafeResponse, type SseEvent, type SseOptions, type WsOptions, arriRequest, arriSafeRequest, arriSseRequest, arriWsRequest, isArriError, parseSseEvent, parseSseEvents, parsedWsResponse };
160
+ export { type ArriEnumValidator, type ArriError, ArriErrorInstance, type ArriModelValidator, type ArriRequestOpts, INT16_MAX, INT16_MIN, INT32_MAX, INT32_MIN, INT64_MAX, INT64_MIN, INT8_MAX, INT8_MIN, type SafeResponse, type SseEvent, type SseOptions, UINT16_MAX, UINT32_MAX, UINT64_MAX, UINT8_MAX, WsController, type WsOptions, arriRequest, arriSafeRequest, arriSseRequest, arriWsRequest, isArriError, isObject, parseSseEvent, parseSseEvents, parsedWsResponse, serializeString };
package/dist/index.d.mts CHANGED
@@ -32,11 +32,12 @@ declare class ArriErrorInstance extends Error implements ArriError {
32
32
  interface ArriRequestOpts<TType, TParams extends Record<any, any> | undefined = undefined> {
33
33
  url: string;
34
34
  method: HttpMethod;
35
- headers?: EventSourcePlusOptions["headers"];
35
+ headers: EventSourcePlusOptions["headers"];
36
36
  params?: TParams;
37
- parser: (input: unknown) => TType;
37
+ responseFromJson: (input: Record<string, unknown>) => TType;
38
+ responseFromString: (input: string) => TType;
38
39
  serializer: (input: TParams) => TParams extends undefined ? undefined : string;
39
- clientVersion?: string;
40
+ clientVersion: string;
40
41
  }
41
42
  declare function arriRequest<TType, TParams extends Record<any, any> | undefined = undefined>(opts: ArriRequestOpts<TType, TParams>): Promise<TType>;
42
43
  declare function arriSafeRequest<TType, TParams extends Record<any, any> | undefined = undefined>(opts: ArriRequestOpts<TType, TParams>): Promise<SafeResponse<TType>>;
@@ -47,6 +48,34 @@ type SafeResponse<T> = {
47
48
  success: false;
48
49
  error: ArriErrorInstance;
49
50
  };
51
+ interface ArriModelValidator<T> {
52
+ new: () => T;
53
+ validate: (input: unknown) => input is T;
54
+ fromJson: (input: Record<string, unknown>) => T;
55
+ fromJsonString: (input: string) => T;
56
+ toJsonString: (input: T) => string;
57
+ toUrlQueryString: (input: T) => string;
58
+ }
59
+ interface ArriEnumValidator<T> {
60
+ new: () => T;
61
+ values: readonly T[];
62
+ validate: (input: unknown) => input is T;
63
+ fromSerialValue: (input: string) => T;
64
+ }
65
+ declare function serializeString(input: string): string;
66
+ declare const INT8_MIN = -128;
67
+ declare const INT8_MAX = 127;
68
+ declare const UINT8_MAX = 255;
69
+ declare const INT16_MIN = -32768;
70
+ declare const INT16_MAX = 32767;
71
+ declare const UINT16_MAX = 65535;
72
+ declare const INT32_MIN = -2147483648;
73
+ declare const INT32_MAX = 2147483647;
74
+ declare const UINT32_MAX = 4294967295;
75
+ declare const INT64_MIN: bigint;
76
+ declare const INT64_MAX: bigint;
77
+ declare const UINT64_MAX: bigint;
78
+ declare function isObject(input: unknown): input is Record<string, unknown>;
50
79
 
51
80
  interface SseEvent<TData = string> {
52
81
  id?: string;
@@ -74,7 +103,8 @@ declare function parseSseEvents<TData = string>(input: string, dataParser: (inpu
74
103
  interface WsControllerOptions<TParams, TResponse> {
75
104
  url: string;
76
105
  serializer: (input: TParams) => string;
77
- parser: (input: unknown) => TResponse;
106
+ responseFromJson: (input: Record<string, unknown>) => TResponse;
107
+ responseFromString: (input: string) => TResponse;
78
108
  onMessage?: WsMessageHook<TResponse>;
79
109
  onErrorMessage?: WsErrorHook;
80
110
  onConnectionError?: WsErrorHook;
@@ -92,7 +122,8 @@ interface ArriWsRequestOptions<TParams = any, TResponse = any> {
92
122
  url: string;
93
123
  headers?: EventSourcePlusOptions["headers"];
94
124
  params?: TParams;
95
- parser: (input: unknown) => TResponse;
125
+ responseFromJson: (input: Record<string, unknown>) => TResponse;
126
+ responseFromString: (input: string) => TResponse;
96
127
  serializer: (input: TParams) => string;
97
128
  onMessage?: WsMessageHook<TResponse>;
98
129
  onError?: WsErrorHook;
@@ -126,4 +157,4 @@ declare function parsedWsResponse(input: string): {
126
157
  data: string;
127
158
  };
128
159
 
129
- export { type ArriError, ArriErrorInstance, type ArriRequestOpts, type SafeResponse, type SseEvent, type SseOptions, type WsOptions, arriRequest, arriSafeRequest, arriSseRequest, arriWsRequest, isArriError, parseSseEvent, parseSseEvents, parsedWsResponse };
160
+ export { type ArriEnumValidator, type ArriError, ArriErrorInstance, type ArriModelValidator, type ArriRequestOpts, INT16_MAX, INT16_MIN, INT32_MAX, INT32_MIN, INT64_MAX, INT64_MIN, INT8_MAX, INT8_MIN, type SafeResponse, type SseEvent, type SseOptions, UINT16_MAX, UINT32_MAX, UINT64_MAX, UINT8_MAX, WsController, type WsOptions, arriRequest, arriSafeRequest, arriSseRequest, arriWsRequest, isArriError, isObject, parseSseEvent, parseSseEvents, parsedWsResponse, serializeString };
package/dist/index.d.ts CHANGED
@@ -32,11 +32,12 @@ declare class ArriErrorInstance extends Error implements ArriError {
32
32
  interface ArriRequestOpts<TType, TParams extends Record<any, any> | undefined = undefined> {
33
33
  url: string;
34
34
  method: HttpMethod;
35
- headers?: EventSourcePlusOptions["headers"];
35
+ headers: EventSourcePlusOptions["headers"];
36
36
  params?: TParams;
37
- parser: (input: unknown) => TType;
37
+ responseFromJson: (input: Record<string, unknown>) => TType;
38
+ responseFromString: (input: string) => TType;
38
39
  serializer: (input: TParams) => TParams extends undefined ? undefined : string;
39
- clientVersion?: string;
40
+ clientVersion: string;
40
41
  }
41
42
  declare function arriRequest<TType, TParams extends Record<any, any> | undefined = undefined>(opts: ArriRequestOpts<TType, TParams>): Promise<TType>;
42
43
  declare function arriSafeRequest<TType, TParams extends Record<any, any> | undefined = undefined>(opts: ArriRequestOpts<TType, TParams>): Promise<SafeResponse<TType>>;
@@ -47,6 +48,34 @@ type SafeResponse<T> = {
47
48
  success: false;
48
49
  error: ArriErrorInstance;
49
50
  };
51
+ interface ArriModelValidator<T> {
52
+ new: () => T;
53
+ validate: (input: unknown) => input is T;
54
+ fromJson: (input: Record<string, unknown>) => T;
55
+ fromJsonString: (input: string) => T;
56
+ toJsonString: (input: T) => string;
57
+ toUrlQueryString: (input: T) => string;
58
+ }
59
+ interface ArriEnumValidator<T> {
60
+ new: () => T;
61
+ values: readonly T[];
62
+ validate: (input: unknown) => input is T;
63
+ fromSerialValue: (input: string) => T;
64
+ }
65
+ declare function serializeString(input: string): string;
66
+ declare const INT8_MIN = -128;
67
+ declare const INT8_MAX = 127;
68
+ declare const UINT8_MAX = 255;
69
+ declare const INT16_MIN = -32768;
70
+ declare const INT16_MAX = 32767;
71
+ declare const UINT16_MAX = 65535;
72
+ declare const INT32_MIN = -2147483648;
73
+ declare const INT32_MAX = 2147483647;
74
+ declare const UINT32_MAX = 4294967295;
75
+ declare const INT64_MIN: bigint;
76
+ declare const INT64_MAX: bigint;
77
+ declare const UINT64_MAX: bigint;
78
+ declare function isObject(input: unknown): input is Record<string, unknown>;
50
79
 
51
80
  interface SseEvent<TData = string> {
52
81
  id?: string;
@@ -74,7 +103,8 @@ declare function parseSseEvents<TData = string>(input: string, dataParser: (inpu
74
103
  interface WsControllerOptions<TParams, TResponse> {
75
104
  url: string;
76
105
  serializer: (input: TParams) => string;
77
- parser: (input: unknown) => TResponse;
106
+ responseFromJson: (input: Record<string, unknown>) => TResponse;
107
+ responseFromString: (input: string) => TResponse;
78
108
  onMessage?: WsMessageHook<TResponse>;
79
109
  onErrorMessage?: WsErrorHook;
80
110
  onConnectionError?: WsErrorHook;
@@ -92,7 +122,8 @@ interface ArriWsRequestOptions<TParams = any, TResponse = any> {
92
122
  url: string;
93
123
  headers?: EventSourcePlusOptions["headers"];
94
124
  params?: TParams;
95
- parser: (input: unknown) => TResponse;
125
+ responseFromJson: (input: Record<string, unknown>) => TResponse;
126
+ responseFromString: (input: string) => TResponse;
96
127
  serializer: (input: TParams) => string;
97
128
  onMessage?: WsMessageHook<TResponse>;
98
129
  onError?: WsErrorHook;
@@ -126,4 +157,4 @@ declare function parsedWsResponse(input: string): {
126
157
  data: string;
127
158
  };
128
159
 
129
- export { type ArriError, ArriErrorInstance, type ArriRequestOpts, type SafeResponse, type SseEvent, type SseOptions, type WsOptions, arriRequest, arriSafeRequest, arriSseRequest, arriWsRequest, isArriError, parseSseEvent, parseSseEvents, parsedWsResponse };
160
+ export { type ArriEnumValidator, type ArriError, ArriErrorInstance, type ArriModelValidator, type ArriRequestOpts, INT16_MAX, INT16_MIN, INT32_MAX, INT32_MIN, INT64_MAX, INT64_MIN, INT8_MAX, INT8_MIN, type SafeResponse, type SseEvent, type SseOptions, UINT16_MAX, UINT32_MAX, UINT64_MAX, UINT8_MAX, WsController, type WsOptions, arriRequest, arriSafeRequest, arriSseRequest, arriWsRequest, isArriError, isObject, parseSseEvent, parseSseEvents, parsedWsResponse, serializeString };
package/dist/index.mjs CHANGED
@@ -1,3 +1,4 @@
1
+ import { serializeSmallString } from '@arrirpc/schema';
1
2
  import { ofetch, FetchError } from 'ofetch';
2
3
  import { EventSourcePlus } from 'event-source-plus';
3
4
  export * from 'event-source-plus';
@@ -74,7 +75,7 @@ async function getHeaders(input) {
74
75
  }
75
76
  return result;
76
77
  }
77
- return input;
78
+ return input ?? {};
78
79
  }
79
80
 
80
81
  async function arriRequest(opts) {
@@ -85,11 +86,7 @@ async function arriRequest(opts) {
85
86
  case "get":
86
87
  case "head":
87
88
  if (opts.params && typeof opts.params === "object") {
88
- const urlParts = [];
89
- Object.keys(opts.params).forEach((key) => {
90
- urlParts.push(`${key}=${opts.params[key]}`);
91
- });
92
- url = `${opts.url}?${urlParts.join("&")}`;
89
+ url = `${opts.url}?${opts.serializer(opts.params)}`;
93
90
  }
94
91
  break;
95
92
  default:
@@ -110,7 +107,7 @@ async function arriRequest(opts) {
110
107
  body,
111
108
  headers
112
109
  });
113
- return opts.parser(result);
110
+ return opts.responseFromJson(result);
114
111
  } catch (err) {
115
112
  const error = err;
116
113
  if (isArriError(error.data)) {
@@ -160,6 +157,34 @@ async function arriSafeRequest(opts) {
160
157
  };
161
158
  }
162
159
  }
160
+ const STR_ESCAPE = (
161
+ // eslint-disable-next-line no-control-regex
162
+ /[\u0000-\u001f\u0022\u005c\ud800-\udfff]|[\ud800-\udbff](?![\udc00-\udfff])|(?:[^\ud800-\udbff]|^)[\udc00-\udfff]/
163
+ );
164
+ function serializeString(input) {
165
+ if (input.length < 42) {
166
+ return serializeSmallString(input);
167
+ }
168
+ if (input.length < 5e3 && !STR_ESCAPE.test(input)) {
169
+ return `"${input}"`;
170
+ }
171
+ return JSON.stringify(input);
172
+ }
173
+ const INT8_MIN = -128;
174
+ const INT8_MAX = 127;
175
+ const UINT8_MAX = 255;
176
+ const INT16_MIN = -32768;
177
+ const INT16_MAX = 32767;
178
+ const UINT16_MAX = 65535;
179
+ const INT32_MIN = -2147483648;
180
+ const INT32_MAX = 2147483647;
181
+ const UINT32_MAX = 4294967295;
182
+ const INT64_MIN = BigInt("9223372036854775808");
183
+ const INT64_MAX = BigInt("9223372036854775807");
184
+ const UINT64_MAX = BigInt("18446744073709551615");
185
+ function isObject(input) {
186
+ return typeof input === "object" && input !== null;
187
+ }
163
188
 
164
189
  function arriSseRequest(opts, options) {
165
190
  let url = opts.url;
@@ -168,11 +193,7 @@ function arriSseRequest(opts, options) {
168
193
  case "get":
169
194
  case "head":
170
195
  if (opts.params && typeof opts.params === "object" && opts.params !== null) {
171
- const urlParts = [];
172
- Object.keys(opts.params).forEach((key) => {
173
- urlParts.push(`${key}=${opts.params[key]}`);
174
- });
175
- url = `${opts.url}?${urlParts.join("&")}`;
196
+ url = `${opts.url}?${opts.serializer(opts.params)}`;
176
197
  }
177
198
  break;
178
199
  default:
@@ -197,7 +218,7 @@ function arriSseRequest(opts, options) {
197
218
  const controller = eventSource.listen({
198
219
  onMessage(message) {
199
220
  if (message.event === "message" || message.event === void 0 || message.event === "") {
200
- options.onMessage?.(opts.parser(message.data));
221
+ options.onMessage?.(opts.responseFromString(message.data));
201
222
  return;
202
223
  }
203
224
  if (message.event === "done") {
@@ -314,7 +335,8 @@ async function arriWsRequest(opts, retryCount = 0) {
314
335
  try {
315
336
  const controller = new WsController({
316
337
  url,
317
- parser: opts.parser,
338
+ responseFromJson: opts.responseFromJson,
339
+ responseFromString: opts.responseFromString,
318
340
  serializer: opts.serializer ?? ((_) => ""),
319
341
  onOpen: opts.onOpen,
320
342
  onClose: opts.onClose,
@@ -344,7 +366,7 @@ class WsController {
344
366
  __publicField(this, "onClose");
345
367
  this.url = opts.url;
346
368
  this._serializer = opts.serializer;
347
- this._parser = opts.parser;
369
+ this._parser = opts.responseFromString;
348
370
  this.onOpen = opts.onOpen;
349
371
  this.onClose = opts.onClose;
350
372
  this.onErrorMessage = opts.onErrorMessage;
@@ -439,4 +461,4 @@ function parsedWsResponse(input) {
439
461
  };
440
462
  }
441
463
 
442
- export { ArriErrorInstance, arriRequest, arriSafeRequest, arriSseRequest, arriWsRequest, isArriError, parseSseEvent, parseSseEvents, parsedWsResponse };
464
+ export { ArriErrorInstance, INT16_MAX, INT16_MIN, INT32_MAX, INT32_MIN, INT64_MAX, INT64_MIN, INT8_MAX, INT8_MIN, UINT16_MAX, UINT32_MAX, UINT64_MAX, UINT8_MAX, WsController, arriRequest, arriSafeRequest, arriSseRequest, arriWsRequest, isArriError, isObject, parseSseEvent, parseSseEvents, parsedWsResponse, serializeString };
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@arrirpc/client",
3
- "version": "0.54.0",
3
+ "version": "0.57.0",
4
4
  "type": "module",
5
5
  "main": "./dist/index.cjs",
6
6
  "module": "./dist/index.mjs",
@@ -22,12 +22,12 @@
22
22
  "directory": "languages/ts/ts-client"
23
23
  },
24
24
  "dependencies": {
25
- "event-source-plus": "^0.1.1",
25
+ "event-source-plus": "^0.1.2",
26
26
  "ofetch": "^1.3.4",
27
- "ws": "^8.17.1",
28
- "@arrirpc/schema": "0.54.0"
27
+ "ws": "^8.18.0",
28
+ "@arrirpc/schema": "0.57.0"
29
29
  },
30
30
  "devDependencies": {
31
- "@types/ws": "^8.5.10"
31
+ "@types/ws": "^8.5.11"
32
32
  }
33
33
  }