@creatorem/next-trpc 1.0.11 → 1.0.12

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.
@@ -11,7 +11,21 @@ const parseInput = (request, endpoint) => {
11
11
  const paramsObj = {};
12
12
  // Convert URLSearchParams to object
13
13
  for (const [key, value] of searchParams) {
14
- paramsObj[key] = value;
14
+ try {
15
+ // Try to parse as JSON first, but only for complex types (arrays/objects)
16
+ // Skip JSON parsing for simple primitives to preserve string values
17
+ const parsed = JSON.parse(value);
18
+ if (Array.isArray(parsed) || (typeof parsed === 'object' && parsed !== null)) {
19
+ paramsObj[key] = parsed;
20
+ }
21
+ else {
22
+ paramsObj[key] = value;
23
+ }
24
+ }
25
+ catch (_a) {
26
+ // If JSON parsing fails, keep as string
27
+ paramsObj[key] = value;
28
+ }
15
29
  }
16
30
  // Validate input with endpoint schema
17
31
  return endpoint.input.parse(paramsObj);
@@ -9,7 +9,18 @@ const getTrpcFetch = ({ endpointSlug, url, headers, }) => async (input) => {
9
9
  if (input) {
10
10
  const searchParams = new URLSearchParams();
11
11
  for (const [key, value] of Object.entries(input)) {
12
- searchParams.append(key, String(value));
12
+ if (Array.isArray(value)) {
13
+ // Handle arrays by JSON stringifying them
14
+ searchParams.append(key, JSON.stringify(value));
15
+ }
16
+ else if (value !== null && typeof value === 'object') {
17
+ // Handle objects by JSON stringifying them
18
+ searchParams.append(key, JSON.stringify(value));
19
+ }
20
+ else {
21
+ // Handle primitive values as strings
22
+ searchParams.append(key, String(value));
23
+ }
13
24
  }
14
25
  requestUrl += `?${searchParams.toString()}`;
15
26
  }
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@creatorem/next-trpc",
3
- "version": "1.0.11",
3
+ "version": "1.0.12",
4
4
  "repository": {
5
5
  "type": "git",
6
6
  "url": "git+https://github.com/creatorem/next-trpc"