@emeryld/rrroutes-client 2.5.4 → 2.5.6
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 +28 -12
- package/dist/index.cjs.map +1 -1
- package/dist/index.mjs +28 -12
- package/dist/index.mjs.map +1 -1
- package/dist/routesV3.client.types.d.ts +5 -5
- package/package.json +6 -5
package/dist/index.cjs
CHANGED
|
@@ -116,6 +116,10 @@ function toSearchString(query) {
|
|
|
116
116
|
params.append(k, String(v));
|
|
117
117
|
continue;
|
|
118
118
|
}
|
|
119
|
+
if (v instanceof Date) {
|
|
120
|
+
params.append(k, v.toISOString());
|
|
121
|
+
continue;
|
|
122
|
+
}
|
|
119
123
|
params.append(k, JSON.stringify(v));
|
|
120
124
|
}
|
|
121
125
|
const s = params.toString();
|
|
@@ -160,9 +164,21 @@ function toFormData(body) {
|
|
|
160
164
|
const fd = new FormData();
|
|
161
165
|
for (const [k, v] of Object.entries(body ?? {})) {
|
|
162
166
|
if (v == null) continue;
|
|
163
|
-
if (Array.isArray(v))
|
|
164
|
-
|
|
165
|
-
|
|
167
|
+
if (Array.isArray(v)) {
|
|
168
|
+
for (const item of v) {
|
|
169
|
+
if (item == null) continue;
|
|
170
|
+
fd.append(k, item);
|
|
171
|
+
}
|
|
172
|
+
continue;
|
|
173
|
+
}
|
|
174
|
+
if (typeof FileList !== "undefined" && v instanceof FileList) {
|
|
175
|
+
for (const item of Array.from(v)) {
|
|
176
|
+
if (item == null) continue;
|
|
177
|
+
fd.append(k, item);
|
|
178
|
+
}
|
|
179
|
+
continue;
|
|
180
|
+
}
|
|
181
|
+
fd.append(k, v);
|
|
166
182
|
}
|
|
167
183
|
return fd;
|
|
168
184
|
}
|
|
@@ -288,11 +304,11 @@ function buildGetLeaf(leaf, rqOpts, env) {
|
|
|
288
304
|
query
|
|
289
305
|
);
|
|
290
306
|
let payload;
|
|
291
|
-
const
|
|
307
|
+
const isMultipart = Array.isArray(leafCfg.bodyFiles) && leafCfg.bodyFiles.length > 0;
|
|
308
|
+
const acceptsBody = Boolean(leafCfg.bodySchema || isMultipart);
|
|
292
309
|
const requiresBody = options?.requireBody ?? (!acceptsBody ? false : true);
|
|
293
310
|
if (typeof options?.body !== "undefined") {
|
|
294
|
-
const normalizedBody = leafCfg.bodySchema ? (0, import_rrroutes_contract2.lowProfileParse)(leafCfg.bodySchema, options.body) :
|
|
295
|
-
const isMultipart = Array.isArray(leafCfg.bodyFiles) && leafCfg.bodyFiles.length > 0;
|
|
311
|
+
const normalizedBody = leafCfg.bodySchema ? (0, import_rrroutes_contract2.lowProfileParse)(leafCfg.bodySchema, options.body) : options.body;
|
|
296
312
|
if (isMultipart && normalizedBody && typeof normalizedBody === "object") {
|
|
297
313
|
payload = toFormData(normalizedBody);
|
|
298
314
|
} else {
|
|
@@ -551,11 +567,11 @@ function buildInfiniteGetLeaf(leaf, rqOpts, env) {
|
|
|
551
567
|
query
|
|
552
568
|
);
|
|
553
569
|
let payload;
|
|
554
|
-
const
|
|
570
|
+
const isMultipart = Array.isArray(leafCfg.bodyFiles) && leafCfg.bodyFiles.length > 0;
|
|
571
|
+
const acceptsBody = Boolean(leafCfg.bodySchema || isMultipart);
|
|
555
572
|
const requiresBody = options?.requireBody ?? (!acceptsBody ? false : true);
|
|
556
573
|
if (typeof options?.body !== "undefined") {
|
|
557
|
-
const normalizedBody = leafCfg.bodySchema ? (0, import_rrroutes_contract3.lowProfileParse)(leafCfg.bodySchema, options.body) :
|
|
558
|
-
const isMultipart = Array.isArray(leafCfg.bodyFiles) && leafCfg.bodyFiles.length > 0;
|
|
574
|
+
const normalizedBody = leafCfg.bodySchema ? (0, import_rrroutes_contract3.lowProfileParse)(leafCfg.bodySchema, options.body) : options.body;
|
|
559
575
|
if (isMultipart && normalizedBody && typeof normalizedBody === "object") {
|
|
560
576
|
payload = toFormData(normalizedBody);
|
|
561
577
|
} else {
|
|
@@ -849,11 +865,11 @@ function buildMutationLeaf(leaf, rqOpts, env) {
|
|
|
849
865
|
query
|
|
850
866
|
);
|
|
851
867
|
let payload;
|
|
852
|
-
const
|
|
868
|
+
const isMultipart = Array.isArray(leafCfg.bodyFiles) && leafCfg.bodyFiles.length > 0;
|
|
869
|
+
const acceptsBody = Boolean(leafCfg.bodySchema || isMultipart);
|
|
853
870
|
const requiresBody = options?.requireBody ?? (!acceptsBody ? false : true);
|
|
854
871
|
if (typeof options?.body !== "undefined") {
|
|
855
|
-
const normalizedBody = leafCfg.bodySchema ? (0, import_rrroutes_contract4.lowProfileParse)(leafCfg.bodySchema, options.body) :
|
|
856
|
-
const isMultipart = Array.isArray(leafCfg.bodyFiles) && leafCfg.bodyFiles.length > 0;
|
|
872
|
+
const normalizedBody = leafCfg.bodySchema ? (0, import_rrroutes_contract4.lowProfileParse)(leafCfg.bodySchema, options.body) : options.body;
|
|
857
873
|
if (isMultipart && normalizedBody && typeof normalizedBody === "object") {
|
|
858
874
|
payload = toFormData(normalizedBody);
|
|
859
875
|
} else {
|