lua-cli 2.5.6 → 2.5.7
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/basket.instance.js +38 -19
- package/dist/common/data.entry.instance.js +20 -9
- package/dist/common/order.instance.js +34 -15
- package/dist/common/product.instance.js +20 -9
- package/dist/common/product.pagination.instance.js +6 -2
- package/dist/common/product.search.instance.js +4 -1
- package/dist/common/user.instance.js +20 -9
- package/package.json +1 -1
|
@@ -12,15 +12,16 @@ export default class BasketInstance {
|
|
|
12
12
|
* @returns Proxied instance that allows direct access to data and common properties
|
|
13
13
|
*/
|
|
14
14
|
constructor(api, basket) {
|
|
15
|
-
|
|
16
|
-
this.
|
|
15
|
+
// Ensure data and common are always objects, never null or undefined
|
|
16
|
+
this.data = basket.data && typeof basket.data === 'object' ? basket.data : {};
|
|
17
|
+
this.common = basket.common && typeof basket.common === 'object' ? basket.common : {};
|
|
17
18
|
this.id = basket.id;
|
|
18
19
|
this.userId = basket.userId;
|
|
19
20
|
this.agentId = basket.agentId;
|
|
20
|
-
this.metadata = basket.data
|
|
21
|
-
this.totalAmount = basket.common
|
|
22
|
-
this.itemCount = basket.common
|
|
23
|
-
this.status = basket.common.
|
|
21
|
+
this.metadata = basket.data?.metadata || {};
|
|
22
|
+
this.totalAmount = basket.common?.totalAmount || 0;
|
|
23
|
+
this.itemCount = basket.common?.itemCount || 0;
|
|
24
|
+
this.status = basket.common?.status || BasketStatus.ACTIVE;
|
|
24
25
|
// Make basketAPI non-enumerable so it doesn't show up in console.log
|
|
25
26
|
Object.defineProperty(this, 'basketAPI', {
|
|
26
27
|
value: api,
|
|
@@ -35,12 +36,12 @@ export default class BasketInstance {
|
|
|
35
36
|
if (prop in target) {
|
|
36
37
|
return Reflect.get(target, prop, receiver);
|
|
37
38
|
}
|
|
38
|
-
// Check data object
|
|
39
|
-
if (typeof prop === 'string' && prop in target.data) {
|
|
39
|
+
// Check data object (with null check)
|
|
40
|
+
if (typeof prop === 'string' && target.data && typeof target.data === 'object' && prop in target.data) {
|
|
40
41
|
return target.data[prop];
|
|
41
42
|
}
|
|
42
|
-
// Check common object
|
|
43
|
-
if (typeof prop === 'string' && prop in target.common) {
|
|
43
|
+
// Check common object (with null check)
|
|
44
|
+
if (typeof prop === 'string' && target.common && typeof target.common === 'object' && prop in target.common) {
|
|
44
45
|
return target.common[prop];
|
|
45
46
|
}
|
|
46
47
|
return undefined;
|
|
@@ -53,6 +54,13 @@ export default class BasketInstance {
|
|
|
53
54
|
}
|
|
54
55
|
// Check if property exists in data or common, otherwise default to data
|
|
55
56
|
if (typeof prop === 'string') {
|
|
57
|
+
// Initialize objects if they don't exist
|
|
58
|
+
if (!target.data || typeof target.data !== 'object') {
|
|
59
|
+
target.data = {};
|
|
60
|
+
}
|
|
61
|
+
if (!target.common || typeof target.common !== 'object') {
|
|
62
|
+
target.common = {};
|
|
63
|
+
}
|
|
56
64
|
if (prop in target.common) {
|
|
57
65
|
target.common[prop] = value;
|
|
58
66
|
}
|
|
@@ -64,14 +72,25 @@ export default class BasketInstance {
|
|
|
64
72
|
return false;
|
|
65
73
|
},
|
|
66
74
|
has(target, prop) {
|
|
67
|
-
// Check if property exists on instance, in data, or in common
|
|
68
|
-
|
|
75
|
+
// Check if property exists on instance, in data, or in common (with null checks)
|
|
76
|
+
if (prop in target) {
|
|
77
|
+
return true;
|
|
78
|
+
}
|
|
79
|
+
if (typeof prop === 'string') {
|
|
80
|
+
if (target.data && typeof target.data === 'object' && prop in target.data) {
|
|
81
|
+
return true;
|
|
82
|
+
}
|
|
83
|
+
if (target.common && typeof target.common === 'object' && prop in target.common) {
|
|
84
|
+
return true;
|
|
85
|
+
}
|
|
86
|
+
}
|
|
87
|
+
return false;
|
|
69
88
|
},
|
|
70
89
|
ownKeys(target) {
|
|
71
|
-
// Return instance keys, data keys, and common keys
|
|
90
|
+
// Return instance keys, data keys, and common keys (with null checks)
|
|
72
91
|
const instanceKeys = Reflect.ownKeys(target);
|
|
73
|
-
const dataKeys = Object.keys(target.data);
|
|
74
|
-
const commonKeys = Object.keys(target.common);
|
|
92
|
+
const dataKeys = target.data && typeof target.data === 'object' ? Object.keys(target.data) : [];
|
|
93
|
+
const commonKeys = target.common && typeof target.common === 'object' ? Object.keys(target.common) : [];
|
|
75
94
|
return [...new Set([...instanceKeys, ...dataKeys, ...commonKeys])];
|
|
76
95
|
},
|
|
77
96
|
getOwnPropertyDescriptor(target, prop) {
|
|
@@ -80,8 +99,8 @@ export default class BasketInstance {
|
|
|
80
99
|
if (instanceDesc) {
|
|
81
100
|
return instanceDesc;
|
|
82
101
|
}
|
|
83
|
-
// Then check data properties
|
|
84
|
-
if (typeof prop === 'string' && prop in target.data) {
|
|
102
|
+
// Then check data properties (with null check)
|
|
103
|
+
if (typeof prop === 'string' && target.data && typeof target.data === 'object' && prop in target.data) {
|
|
85
104
|
return {
|
|
86
105
|
configurable: true,
|
|
87
106
|
enumerable: true,
|
|
@@ -89,8 +108,8 @@ export default class BasketInstance {
|
|
|
89
108
|
value: target.data[prop]
|
|
90
109
|
};
|
|
91
110
|
}
|
|
92
|
-
// Then check common properties
|
|
93
|
-
if (typeof prop === 'string' && prop in target.common) {
|
|
111
|
+
// Then check common properties (with null check)
|
|
112
|
+
if (typeof prop === 'string' && target.common && typeof target.common === 'object' && prop in target.common) {
|
|
94
113
|
return {
|
|
95
114
|
configurable: true,
|
|
96
115
|
enumerable: true,
|
|
@@ -12,7 +12,8 @@ export default class DataEntryInstance {
|
|
|
12
12
|
* @returns Proxied instance that allows direct access to data properties
|
|
13
13
|
*/
|
|
14
14
|
constructor(api, entry, collectionName) {
|
|
15
|
-
|
|
15
|
+
// Ensure data is always an object, never null or undefined
|
|
16
|
+
this.data = entry.data && typeof entry.data === 'object' ? entry.data : {};
|
|
16
17
|
this.id = entry.id;
|
|
17
18
|
this.collectionName = collectionName;
|
|
18
19
|
this.score = entry.score;
|
|
@@ -30,8 +31,8 @@ export default class DataEntryInstance {
|
|
|
30
31
|
if (prop in target) {
|
|
31
32
|
return Reflect.get(target, prop, receiver);
|
|
32
33
|
}
|
|
33
|
-
// Otherwise, try to get it from the data object
|
|
34
|
-
if (typeof prop === 'string' && prop in target.data) {
|
|
34
|
+
// Otherwise, try to get it from the data object (with null check)
|
|
35
|
+
if (typeof prop === 'string' && target.data && typeof target.data === 'object' && prop in target.data) {
|
|
35
36
|
return target.data[prop];
|
|
36
37
|
}
|
|
37
38
|
return undefined;
|
|
@@ -44,19 +45,29 @@ export default class DataEntryInstance {
|
|
|
44
45
|
}
|
|
45
46
|
// All other properties get set on the data object
|
|
46
47
|
if (typeof prop === 'string') {
|
|
48
|
+
// Initialize data object if it doesn't exist
|
|
49
|
+
if (!target.data || typeof target.data !== 'object') {
|
|
50
|
+
target.data = {};
|
|
51
|
+
}
|
|
47
52
|
target.data[prop] = value;
|
|
48
53
|
return true;
|
|
49
54
|
}
|
|
50
55
|
return false;
|
|
51
56
|
},
|
|
52
57
|
has(target, prop) {
|
|
53
|
-
// Check if property exists on instance or in data
|
|
54
|
-
|
|
58
|
+
// Check if property exists on instance or in data (with null check)
|
|
59
|
+
if (prop in target) {
|
|
60
|
+
return true;
|
|
61
|
+
}
|
|
62
|
+
if (typeof prop === 'string' && target.data && typeof target.data === 'object') {
|
|
63
|
+
return prop in target.data;
|
|
64
|
+
}
|
|
65
|
+
return false;
|
|
55
66
|
},
|
|
56
67
|
ownKeys(target) {
|
|
57
|
-
// Return both instance keys and data keys
|
|
68
|
+
// Return both instance keys and data keys (with null check)
|
|
58
69
|
const instanceKeys = Reflect.ownKeys(target);
|
|
59
|
-
const dataKeys = Object.keys(target.data);
|
|
70
|
+
const dataKeys = target.data && typeof target.data === 'object' ? Object.keys(target.data) : [];
|
|
60
71
|
return [...new Set([...instanceKeys, ...dataKeys])];
|
|
61
72
|
},
|
|
62
73
|
getOwnPropertyDescriptor(target, prop) {
|
|
@@ -65,8 +76,8 @@ export default class DataEntryInstance {
|
|
|
65
76
|
if (instanceDesc) {
|
|
66
77
|
return instanceDesc;
|
|
67
78
|
}
|
|
68
|
-
// Then check if it's a data property
|
|
69
|
-
if (typeof prop === 'string' && prop in target.data) {
|
|
79
|
+
// Then check if it's a data property (with null check)
|
|
80
|
+
if (typeof prop === 'string' && target.data && typeof target.data === 'object' && prop in target.data) {
|
|
70
81
|
return {
|
|
71
82
|
configurable: true,
|
|
72
83
|
enumerable: true,
|
|
@@ -11,8 +11,9 @@ export default class OrderInstance {
|
|
|
11
11
|
* @returns Proxied instance that allows direct access to data and common properties
|
|
12
12
|
*/
|
|
13
13
|
constructor(api, order) {
|
|
14
|
-
|
|
15
|
-
this.
|
|
14
|
+
// Ensure data and common are always objects, never null or undefined
|
|
15
|
+
this.data = order.data && typeof order.data === 'object' ? order.data : {};
|
|
16
|
+
this.common = order.common && typeof order.common === 'object' ? order.common : {};
|
|
16
17
|
this.id = order.id;
|
|
17
18
|
this.userId = order.userId;
|
|
18
19
|
this.agentId = order.agentId;
|
|
@@ -31,12 +32,12 @@ export default class OrderInstance {
|
|
|
31
32
|
if (prop in target) {
|
|
32
33
|
return Reflect.get(target, prop, receiver);
|
|
33
34
|
}
|
|
34
|
-
// Check data object
|
|
35
|
-
if (typeof prop === 'string' && prop in target.data) {
|
|
35
|
+
// Check data object (with null check)
|
|
36
|
+
if (typeof prop === 'string' && target.data && typeof target.data === 'object' && prop in target.data) {
|
|
36
37
|
return target.data[prop];
|
|
37
38
|
}
|
|
38
|
-
// Check common object
|
|
39
|
-
if (typeof prop === 'string' && prop in target.common) {
|
|
39
|
+
// Check common object (with null check)
|
|
40
|
+
if (typeof prop === 'string' && target.common && typeof target.common === 'object' && prop in target.common) {
|
|
40
41
|
return target.common[prop];
|
|
41
42
|
}
|
|
42
43
|
return undefined;
|
|
@@ -49,6 +50,13 @@ export default class OrderInstance {
|
|
|
49
50
|
}
|
|
50
51
|
// Check if property exists in data or common, otherwise default to data
|
|
51
52
|
if (typeof prop === 'string') {
|
|
53
|
+
// Initialize objects if they don't exist
|
|
54
|
+
if (!target.data || typeof target.data !== 'object') {
|
|
55
|
+
target.data = {};
|
|
56
|
+
}
|
|
57
|
+
if (!target.common || typeof target.common !== 'object') {
|
|
58
|
+
target.common = {};
|
|
59
|
+
}
|
|
52
60
|
if (prop in target.common) {
|
|
53
61
|
target.common[prop] = value;
|
|
54
62
|
}
|
|
@@ -60,14 +68,25 @@ export default class OrderInstance {
|
|
|
60
68
|
return false;
|
|
61
69
|
},
|
|
62
70
|
has(target, prop) {
|
|
63
|
-
// Check if property exists on instance, in data, or in common
|
|
64
|
-
|
|
71
|
+
// Check if property exists on instance, in data, or in common (with null checks)
|
|
72
|
+
if (prop in target) {
|
|
73
|
+
return true;
|
|
74
|
+
}
|
|
75
|
+
if (typeof prop === 'string') {
|
|
76
|
+
if (target.data && typeof target.data === 'object' && prop in target.data) {
|
|
77
|
+
return true;
|
|
78
|
+
}
|
|
79
|
+
if (target.common && typeof target.common === 'object' && prop in target.common) {
|
|
80
|
+
return true;
|
|
81
|
+
}
|
|
82
|
+
}
|
|
83
|
+
return false;
|
|
65
84
|
},
|
|
66
85
|
ownKeys(target) {
|
|
67
|
-
// Return instance keys, data keys, and common keys
|
|
86
|
+
// Return instance keys, data keys, and common keys (with null checks)
|
|
68
87
|
const instanceKeys = Reflect.ownKeys(target);
|
|
69
|
-
const dataKeys = Object.keys(target.data);
|
|
70
|
-
const commonKeys = Object.keys(target.common);
|
|
88
|
+
const dataKeys = target.data && typeof target.data === 'object' ? Object.keys(target.data) : [];
|
|
89
|
+
const commonKeys = target.common && typeof target.common === 'object' ? Object.keys(target.common) : [];
|
|
71
90
|
return [...new Set([...instanceKeys, ...dataKeys, ...commonKeys])];
|
|
72
91
|
},
|
|
73
92
|
getOwnPropertyDescriptor(target, prop) {
|
|
@@ -76,8 +95,8 @@ export default class OrderInstance {
|
|
|
76
95
|
if (instanceDesc) {
|
|
77
96
|
return instanceDesc;
|
|
78
97
|
}
|
|
79
|
-
// Then check data properties
|
|
80
|
-
if (typeof prop === 'string' && prop in target.data) {
|
|
98
|
+
// Then check data properties (with null check)
|
|
99
|
+
if (typeof prop === 'string' && target.data && typeof target.data === 'object' && prop in target.data) {
|
|
81
100
|
return {
|
|
82
101
|
configurable: true,
|
|
83
102
|
enumerable: true,
|
|
@@ -85,8 +104,8 @@ export default class OrderInstance {
|
|
|
85
104
|
value: target.data[prop]
|
|
86
105
|
};
|
|
87
106
|
}
|
|
88
|
-
// Then check common properties
|
|
89
|
-
if (typeof prop === 'string' && prop in target.common) {
|
|
107
|
+
// Then check common properties (with null check)
|
|
108
|
+
if (typeof prop === 'string' && target.common && typeof target.common === 'object' && prop in target.common) {
|
|
90
109
|
return {
|
|
91
110
|
configurable: true,
|
|
92
111
|
enumerable: true,
|
|
@@ -11,7 +11,8 @@ export default class ProductInstance {
|
|
|
11
11
|
* @returns Proxied instance that allows direct access to product properties
|
|
12
12
|
*/
|
|
13
13
|
constructor(api, product) {
|
|
14
|
-
|
|
14
|
+
// Ensure data is always an object, never null or undefined
|
|
15
|
+
this.data = product && typeof product === 'object' ? product : {};
|
|
15
16
|
// Make productAPI non-enumerable so it doesn't show up in console.log
|
|
16
17
|
Object.defineProperty(this, 'productAPI', {
|
|
17
18
|
value: api,
|
|
@@ -26,8 +27,8 @@ export default class ProductInstance {
|
|
|
26
27
|
if (prop in target) {
|
|
27
28
|
return Reflect.get(target, prop, receiver);
|
|
28
29
|
}
|
|
29
|
-
// Otherwise, try to get it from the data object
|
|
30
|
-
if (typeof prop === 'string' && prop in target.data) {
|
|
30
|
+
// Otherwise, try to get it from the data object (with null check)
|
|
31
|
+
if (typeof prop === 'string' && target.data && typeof target.data === 'object' && prop in target.data) {
|
|
31
32
|
return target.data[prop];
|
|
32
33
|
}
|
|
33
34
|
return undefined;
|
|
@@ -40,19 +41,29 @@ export default class ProductInstance {
|
|
|
40
41
|
}
|
|
41
42
|
// All other properties get set on the data object
|
|
42
43
|
if (typeof prop === 'string') {
|
|
44
|
+
// Initialize data object if it doesn't exist
|
|
45
|
+
if (!target.data || typeof target.data !== 'object') {
|
|
46
|
+
target.data = {};
|
|
47
|
+
}
|
|
43
48
|
target.data[prop] = value;
|
|
44
49
|
return true;
|
|
45
50
|
}
|
|
46
51
|
return false;
|
|
47
52
|
},
|
|
48
53
|
has(target, prop) {
|
|
49
|
-
// Check if property exists on instance or in data
|
|
50
|
-
|
|
54
|
+
// Check if property exists on instance or in data (with null check)
|
|
55
|
+
if (prop in target) {
|
|
56
|
+
return true;
|
|
57
|
+
}
|
|
58
|
+
if (typeof prop === 'string' && target.data && typeof target.data === 'object') {
|
|
59
|
+
return prop in target.data;
|
|
60
|
+
}
|
|
61
|
+
return false;
|
|
51
62
|
},
|
|
52
63
|
ownKeys(target) {
|
|
53
|
-
// Return both instance keys and data keys
|
|
64
|
+
// Return both instance keys and data keys (with null check)
|
|
54
65
|
const instanceKeys = Reflect.ownKeys(target);
|
|
55
|
-
const dataKeys = Object.keys(target.data);
|
|
66
|
+
const dataKeys = target.data && typeof target.data === 'object' ? Object.keys(target.data) : [];
|
|
56
67
|
return [...new Set([...instanceKeys, ...dataKeys])];
|
|
57
68
|
},
|
|
58
69
|
getOwnPropertyDescriptor(target, prop) {
|
|
@@ -61,8 +72,8 @@ export default class ProductInstance {
|
|
|
61
72
|
if (instanceDesc) {
|
|
62
73
|
return instanceDesc;
|
|
63
74
|
}
|
|
64
|
-
// Then check if it's a data property
|
|
65
|
-
if (typeof prop === 'string' && prop in target.data) {
|
|
75
|
+
// Then check if it's a data property (with null check)
|
|
76
|
+
if (typeof prop === 'string' && target.data && typeof target.data === 'object' && prop in target.data) {
|
|
66
77
|
return {
|
|
67
78
|
configurable: true,
|
|
68
79
|
enumerable: true,
|
|
@@ -11,8 +11,12 @@ export default class ProductPaginationInstance {
|
|
|
11
11
|
* @param results - The paginated product results from the API
|
|
12
12
|
*/
|
|
13
13
|
constructor(api, results) {
|
|
14
|
-
|
|
15
|
-
|
|
14
|
+
// Ensure products array is always initialized, with null checks
|
|
15
|
+
const productsData = results?.data;
|
|
16
|
+
this.products = (Array.isArray(productsData) ? productsData : [])
|
|
17
|
+
.map(product => new ProductInstance(api, product));
|
|
18
|
+
// Ensure pagination is always initialized with safe defaults
|
|
19
|
+
this.pagination = results?.pagination || {
|
|
16
20
|
currentPage: 1,
|
|
17
21
|
totalPages: 1,
|
|
18
22
|
totalCount: 0,
|
|
@@ -11,7 +11,10 @@ export default class ProductSearchInstance {
|
|
|
11
11
|
* @param results - The product search results from the API
|
|
12
12
|
*/
|
|
13
13
|
constructor(api, results) {
|
|
14
|
-
|
|
14
|
+
// Ensure products array is always initialized, with null checks
|
|
15
|
+
const productsData = results?.data;
|
|
16
|
+
this.products = (Array.isArray(productsData) ? productsData : [])
|
|
17
|
+
.map(product => new ProductInstance(api, product));
|
|
15
18
|
// Make productAPI non-enumerable so it doesn't show up in console.log
|
|
16
19
|
Object.defineProperty(this, 'productAPI', {
|
|
17
20
|
value: api,
|
|
@@ -11,7 +11,8 @@ export default class UserDataInstance {
|
|
|
11
11
|
* @returns Proxied instance that allows direct access to data properties
|
|
12
12
|
*/
|
|
13
13
|
constructor(api, data) {
|
|
14
|
-
|
|
14
|
+
// Ensure data is always an object, never null or undefined
|
|
15
|
+
this.data = data && typeof data === 'object' ? data : {};
|
|
15
16
|
// Make userAPI non-enumerable so it doesn't show up in console.log
|
|
16
17
|
Object.defineProperty(this, 'userAPI', {
|
|
17
18
|
value: api,
|
|
@@ -26,8 +27,8 @@ export default class UserDataInstance {
|
|
|
26
27
|
if (prop in target) {
|
|
27
28
|
return Reflect.get(target, prop, receiver);
|
|
28
29
|
}
|
|
29
|
-
// Otherwise, try to get it from the data object
|
|
30
|
-
if (typeof prop === 'string' && prop in target.data) {
|
|
30
|
+
// Otherwise, try to get it from the data object (with null check)
|
|
31
|
+
if (typeof prop === 'string' && target.data && typeof target.data === 'object' && prop in target.data) {
|
|
31
32
|
return target.data[prop];
|
|
32
33
|
}
|
|
33
34
|
return undefined;
|
|
@@ -40,19 +41,29 @@ export default class UserDataInstance {
|
|
|
40
41
|
}
|
|
41
42
|
// All other properties get set on the data object
|
|
42
43
|
if (typeof prop === 'string') {
|
|
44
|
+
// Initialize data object if it doesn't exist
|
|
45
|
+
if (!target.data || typeof target.data !== 'object') {
|
|
46
|
+
target.data = {};
|
|
47
|
+
}
|
|
43
48
|
target.data[prop] = value;
|
|
44
49
|
return true;
|
|
45
50
|
}
|
|
46
51
|
return false;
|
|
47
52
|
},
|
|
48
53
|
has(target, prop) {
|
|
49
|
-
// Check if property exists on instance or in data
|
|
50
|
-
|
|
54
|
+
// Check if property exists on instance or in data (with null check)
|
|
55
|
+
if (prop in target) {
|
|
56
|
+
return true;
|
|
57
|
+
}
|
|
58
|
+
if (typeof prop === 'string' && target.data && typeof target.data === 'object') {
|
|
59
|
+
return prop in target.data;
|
|
60
|
+
}
|
|
61
|
+
return false;
|
|
51
62
|
},
|
|
52
63
|
ownKeys(target) {
|
|
53
|
-
// Return both instance keys and data keys
|
|
64
|
+
// Return both instance keys and data keys (with null check)
|
|
54
65
|
const instanceKeys = Reflect.ownKeys(target);
|
|
55
|
-
const dataKeys = Object.keys(target.data);
|
|
66
|
+
const dataKeys = target.data && typeof target.data === 'object' ? Object.keys(target.data) : [];
|
|
56
67
|
return [...new Set([...instanceKeys, ...dataKeys])];
|
|
57
68
|
},
|
|
58
69
|
getOwnPropertyDescriptor(target, prop) {
|
|
@@ -61,8 +72,8 @@ export default class UserDataInstance {
|
|
|
61
72
|
if (instanceDesc) {
|
|
62
73
|
return instanceDesc;
|
|
63
74
|
}
|
|
64
|
-
// Then check if it's a data property
|
|
65
|
-
if (typeof prop === 'string' && prop in target.data) {
|
|
75
|
+
// Then check if it's a data property (with null check)
|
|
76
|
+
if (typeof prop === 'string' && target.data && typeof target.data === 'object' && prop in target.data) {
|
|
66
77
|
return {
|
|
67
78
|
configurable: true,
|
|
68
79
|
enumerable: true,
|
package/package.json
CHANGED