shopoflex-types 1.0.61 → 1.0.63

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/common.d.ts CHANGED
@@ -418,6 +418,8 @@ export interface Vendor {
418
418
  currency: string;
419
419
  language: string;
420
420
  country: string;
421
+ status?: "pending" | "active" | "inactive" | "suspended" | "blocked" | "expired" | "deleted";
422
+ isLive?: boolean;
421
423
  template: {
422
424
  id: TemplateId;
423
425
  name: {
package/dist/filters.js CHANGED
@@ -12,20 +12,17 @@ exports.buildDiscountQuery = exports.buildCustomerQuery = exports.buildOrderQuer
12
12
  * @param filters - Any filter object
13
13
  * @returns Query parameters string (without ?)
14
14
  */
15
- const buildQuery = (filters) => {
15
+ const buildQuery = (params) => {
16
16
  const parts = [];
17
- Object.entries(filters).forEach(([key, value]) => {
17
+ const addKeyValue = (key, value) => {
18
18
  if (value === undefined || value === null || value === '')
19
19
  return;
20
- // Handle arrays (convert to comma-separated string)
21
20
  if (Array.isArray(value)) {
22
- if (value.length === 2 && (key.includes('Range') || key.includes('range'))) {
23
- // Range values like [min, max] or [startDate, endDate]
21
+ if (value.length === 2 && (key.toLowerCase().includes('range'))) {
24
22
  const rangeString = value.map(v => {
25
23
  if (v instanceof Date)
26
24
  return v.toISOString().split('T')[0];
27
25
  if (typeof v === 'object' && v !== null) {
28
- // Handle objects in ranges (e.g., {_id: "123"} -> "123")
29
26
  return v._id || v.id || JSON.stringify(v);
30
27
  }
31
28
  return String(v);
@@ -33,10 +30,8 @@ const buildQuery = (filters) => {
33
30
  parts.push(`${key}=${encodeURIComponent(rangeString)}`);
34
31
  }
35
32
  else {
36
- // Regular arrays like tags, categories
37
33
  const arrayString = value.map(v => {
38
34
  if (typeof v === 'object' && v !== null) {
39
- // Handle objects in arrays (e.g., [{_id: "123"}] -> "123")
40
35
  return v._id || v.id || v.value || JSON.stringify(v);
41
36
  }
42
37
  return String(v);
@@ -44,19 +39,26 @@ const buildQuery = (filters) => {
44
39
  parts.push(`${key}=${encodeURIComponent(arrayString)}`);
45
40
  }
46
41
  }
47
- // Handle dates
48
42
  else if (value instanceof Date) {
49
43
  parts.push(`${key}=${value.toISOString().split('T')[0]}`);
50
44
  }
51
- // Handle objects (convert to JSON or extract ID)
52
- else if (typeof value === 'object' && value !== null) {
45
+ else if (typeof value === 'object') {
53
46
  const objectValue = value._id || value.id || value.value || JSON.stringify(value);
54
47
  parts.push(`${key}=${encodeURIComponent(objectValue)}`);
55
48
  }
56
- // Handle primitives
57
49
  else {
58
50
  parts.push(`${key}=${encodeURIComponent(String(value))}`);
59
51
  }
52
+ };
53
+ Object.entries(params).forEach(([key, value]) => {
54
+ if (key === 'filters' && typeof value === 'object' && value !== null) {
55
+ Object.entries(value).forEach(([filterKey, filterValue]) => {
56
+ addKeyValue(filterKey, filterValue);
57
+ });
58
+ }
59
+ else {
60
+ addKeyValue(key, value);
61
+ }
60
62
  });
61
63
  return parts.join('&');
62
64
  };
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "shopoflex-types",
3
- "version": "1.0.61",
3
+ "version": "1.0.63",
4
4
  "description": "Shared TypeScript types for Shopoflex applications",
5
5
  "main": "dist/index.js",
6
6
  "types": "dist/index.d.ts",