shopoflex-types 1.0.60 → 1.0.61

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 (2) hide show
  1. package/dist/filters.js +24 -4
  2. package/package.json +1 -1
package/dist/filters.js CHANGED
@@ -21,21 +21,41 @@ const buildQuery = (filters) => {
21
21
  if (Array.isArray(value)) {
22
22
  if (value.length === 2 && (key.includes('Range') || key.includes('range'))) {
23
23
  // Range values like [min, max] or [startDate, endDate]
24
- const rangeString = value.map(v => v instanceof Date ? v.toISOString().split('T')[0] : v).join(',');
25
- parts.push(`${key}=${rangeString}`);
24
+ const rangeString = value.map(v => {
25
+ if (v instanceof Date)
26
+ return v.toISOString().split('T')[0];
27
+ if (typeof v === 'object' && v !== null) {
28
+ // Handle objects in ranges (e.g., {_id: "123"} -> "123")
29
+ return v._id || v.id || JSON.stringify(v);
30
+ }
31
+ return String(v);
32
+ }).join(',');
33
+ parts.push(`${key}=${encodeURIComponent(rangeString)}`);
26
34
  }
27
35
  else {
28
36
  // Regular arrays like tags, categories
29
- parts.push(`${key}=${value.join(',')}`);
37
+ const arrayString = value.map(v => {
38
+ if (typeof v === 'object' && v !== null) {
39
+ // Handle objects in arrays (e.g., [{_id: "123"}] -> "123")
40
+ return v._id || v.id || v.value || JSON.stringify(v);
41
+ }
42
+ return String(v);
43
+ }).join(',');
44
+ parts.push(`${key}=${encodeURIComponent(arrayString)}`);
30
45
  }
31
46
  }
32
47
  // Handle dates
33
48
  else if (value instanceof Date) {
34
49
  parts.push(`${key}=${value.toISOString().split('T')[0]}`);
35
50
  }
51
+ // Handle objects (convert to JSON or extract ID)
52
+ else if (typeof value === 'object' && value !== null) {
53
+ const objectValue = value._id || value.id || value.value || JSON.stringify(value);
54
+ parts.push(`${key}=${encodeURIComponent(objectValue)}`);
55
+ }
36
56
  // Handle primitives
37
57
  else {
38
- parts.push(`${key}=${encodeURIComponent(value)}`);
58
+ parts.push(`${key}=${encodeURIComponent(String(value))}`);
39
59
  }
40
60
  });
41
61
  return parts.join('&');
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "shopoflex-types",
3
- "version": "1.0.60",
3
+ "version": "1.0.61",
4
4
  "description": "Shared TypeScript types for Shopoflex applications",
5
5
  "main": "dist/index.js",
6
6
  "types": "dist/index.d.ts",