lua-cli 2.5.1 → 2.5.3
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/CHANGELOG.md +29 -0
- package/CLI_REFERENCE.md +90 -0
- package/INSTANCE_TYPES.md +1158 -0
- package/README.md +6 -0
- package/dist/api/agent.api.service.d.ts +52 -0
- package/dist/api/agent.api.service.js +63 -0
- package/dist/api/logs.api.service.d.ts +35 -0
- package/dist/api/logs.api.service.js +43 -0
- package/dist/api/products.api.service.js +2 -0
- package/dist/cli/command-definitions.js +17 -1
- package/dist/commands/admin.d.ts +23 -0
- package/dist/commands/admin.js +62 -0
- package/dist/commands/channels.d.ts +17 -0
- package/dist/commands/channels.js +676 -0
- package/dist/commands/docs.d.ts +19 -0
- package/dist/commands/docs.js +30 -0
- package/dist/commands/index.d.ts +4 -0
- package/dist/commands/index.js +4 -0
- package/dist/commands/logs.d.ts +17 -0
- package/dist/commands/logs.js +271 -0
- package/dist/common/basket.instance.d.ts +4 -1
- package/dist/common/basket.instance.js +76 -1
- package/dist/common/data.entry.instance.d.ts +4 -1
- package/dist/common/data.entry.instance.js +57 -1
- package/dist/common/http.client.js +11 -1
- package/dist/common/order.instance.d.ts +4 -1
- package/dist/common/order.instance.js +76 -1
- package/dist/common/product.instance.d.ts +4 -1
- package/dist/common/product.instance.js +57 -1
- package/dist/common/product.pagination.instance.d.ts +58 -0
- package/dist/common/product.pagination.instance.js +78 -0
- package/dist/common/product.search.instance.d.ts +58 -0
- package/dist/common/product.search.instance.js +78 -0
- package/dist/common/user.instance.d.ts +4 -12
- package/dist/common/user.instance.js +5 -24
- package/dist/index.js +3 -0
- package/dist/interfaces/agent.d.ts +218 -0
- package/dist/interfaces/logs.d.ts +40 -0
- package/dist/interfaces/logs.js +5 -0
- package/package.json +2 -1
- package/template/package.json +1 -1
|
@@ -1,12 +1,14 @@
|
|
|
1
1
|
/**
|
|
2
2
|
* Order instance class providing a fluent API for managing orders
|
|
3
3
|
* Provides methods for updating order status and order data
|
|
4
|
+
* Supports direct property access (e.g., order.shippingAddress) for accessing data and common properties
|
|
4
5
|
*/
|
|
5
6
|
export default class OrderInstance {
|
|
6
7
|
/**
|
|
7
|
-
* Creates a new OrderInstance
|
|
8
|
+
* Creates a new OrderInstance with proxy support for direct property access
|
|
8
9
|
* @param api - The OrderApi instance for making API calls
|
|
9
10
|
* @param order - The order response data from the API
|
|
11
|
+
* @returns Proxied instance that allows direct access to data and common properties
|
|
10
12
|
*/
|
|
11
13
|
constructor(api, order) {
|
|
12
14
|
this.data = order.data;
|
|
@@ -22,6 +24,79 @@ export default class OrderInstance {
|
|
|
22
24
|
enumerable: false,
|
|
23
25
|
configurable: true
|
|
24
26
|
});
|
|
27
|
+
// Return a proxy that allows direct property access
|
|
28
|
+
return new Proxy(this, {
|
|
29
|
+
get(target, prop, receiver) {
|
|
30
|
+
// If the property exists on the instance itself, return it
|
|
31
|
+
if (prop in target) {
|
|
32
|
+
return Reflect.get(target, prop, receiver);
|
|
33
|
+
}
|
|
34
|
+
// Check data object
|
|
35
|
+
if (typeof prop === 'string' && prop in target.data) {
|
|
36
|
+
return target.data[prop];
|
|
37
|
+
}
|
|
38
|
+
// Check common object
|
|
39
|
+
if (typeof prop === 'string' && prop in target.common) {
|
|
40
|
+
return target.common[prop];
|
|
41
|
+
}
|
|
42
|
+
return undefined;
|
|
43
|
+
},
|
|
44
|
+
set(target, prop, value, receiver) {
|
|
45
|
+
// Reserved properties that should be set on the instance itself
|
|
46
|
+
const reservedProps = ['data', 'common', 'id', 'userId', 'agentId', 'orderId', 'orderAPI', 'updateStatus', 'update', 'toJSON'];
|
|
47
|
+
if (typeof prop === 'string' && reservedProps.includes(prop)) {
|
|
48
|
+
return Reflect.set(target, prop, value, receiver);
|
|
49
|
+
}
|
|
50
|
+
// Check if property exists in data or common, otherwise default to data
|
|
51
|
+
if (typeof prop === 'string') {
|
|
52
|
+
if (prop in target.common) {
|
|
53
|
+
target.common[prop] = value;
|
|
54
|
+
}
|
|
55
|
+
else {
|
|
56
|
+
target.data[prop] = value;
|
|
57
|
+
}
|
|
58
|
+
return true;
|
|
59
|
+
}
|
|
60
|
+
return false;
|
|
61
|
+
},
|
|
62
|
+
has(target, prop) {
|
|
63
|
+
// Check if property exists on instance, in data, or in common
|
|
64
|
+
return prop in target || (typeof prop === 'string' && (prop in target.data || prop in target.common));
|
|
65
|
+
},
|
|
66
|
+
ownKeys(target) {
|
|
67
|
+
// Return instance keys, data keys, and common keys
|
|
68
|
+
const instanceKeys = Reflect.ownKeys(target);
|
|
69
|
+
const dataKeys = Object.keys(target.data);
|
|
70
|
+
const commonKeys = Object.keys(target.common);
|
|
71
|
+
return [...new Set([...instanceKeys, ...dataKeys, ...commonKeys])];
|
|
72
|
+
},
|
|
73
|
+
getOwnPropertyDescriptor(target, prop) {
|
|
74
|
+
// First check if it's an instance property
|
|
75
|
+
const instanceDesc = Reflect.getOwnPropertyDescriptor(target, prop);
|
|
76
|
+
if (instanceDesc) {
|
|
77
|
+
return instanceDesc;
|
|
78
|
+
}
|
|
79
|
+
// Then check data properties
|
|
80
|
+
if (typeof prop === 'string' && prop in target.data) {
|
|
81
|
+
return {
|
|
82
|
+
configurable: true,
|
|
83
|
+
enumerable: true,
|
|
84
|
+
writable: true,
|
|
85
|
+
value: target.data[prop]
|
|
86
|
+
};
|
|
87
|
+
}
|
|
88
|
+
// Then check common properties
|
|
89
|
+
if (typeof prop === 'string' && prop in target.common) {
|
|
90
|
+
return {
|
|
91
|
+
configurable: true,
|
|
92
|
+
enumerable: true,
|
|
93
|
+
writable: true,
|
|
94
|
+
value: target.common[prop]
|
|
95
|
+
};
|
|
96
|
+
}
|
|
97
|
+
return undefined;
|
|
98
|
+
}
|
|
99
|
+
});
|
|
25
100
|
}
|
|
26
101
|
/**
|
|
27
102
|
* Custom toJSON method to control what gets serialized when logging
|
|
@@ -2,14 +2,17 @@ import { Product } from "../interfaces/product.js";
|
|
|
2
2
|
/**
|
|
3
3
|
* Product instance class providing a fluent API for managing individual products
|
|
4
4
|
* Provides methods for updating and deleting products
|
|
5
|
+
* Supports direct property access (e.g., product.name) instead of product.data.name
|
|
5
6
|
*/
|
|
6
7
|
export default class ProductInstance {
|
|
7
8
|
data: Product;
|
|
8
9
|
private productAPI;
|
|
10
|
+
[key: string]: any;
|
|
9
11
|
/**
|
|
10
|
-
* Creates a new ProductInstance
|
|
12
|
+
* Creates a new ProductInstance with proxy support for direct property access
|
|
11
13
|
* @param api - The ProductAPI instance for making API calls
|
|
12
14
|
* @param product - The product data from the API
|
|
15
|
+
* @returns Proxied instance that allows direct access to product properties
|
|
13
16
|
*/
|
|
14
17
|
constructor(api: any, product: Product);
|
|
15
18
|
/**
|
|
@@ -1,12 +1,14 @@
|
|
|
1
1
|
/**
|
|
2
2
|
* Product instance class providing a fluent API for managing individual products
|
|
3
3
|
* Provides methods for updating and deleting products
|
|
4
|
+
* Supports direct property access (e.g., product.name) instead of product.data.name
|
|
4
5
|
*/
|
|
5
6
|
export default class ProductInstance {
|
|
6
7
|
/**
|
|
7
|
-
* Creates a new ProductInstance
|
|
8
|
+
* Creates a new ProductInstance with proxy support for direct property access
|
|
8
9
|
* @param api - The ProductAPI instance for making API calls
|
|
9
10
|
* @param product - The product data from the API
|
|
11
|
+
* @returns Proxied instance that allows direct access to product properties
|
|
10
12
|
*/
|
|
11
13
|
constructor(api, product) {
|
|
12
14
|
this.data = product;
|
|
@@ -17,6 +19,60 @@ export default class ProductInstance {
|
|
|
17
19
|
enumerable: false,
|
|
18
20
|
configurable: true
|
|
19
21
|
});
|
|
22
|
+
// Return a proxy that allows direct property access
|
|
23
|
+
return new Proxy(this, {
|
|
24
|
+
get(target, prop, receiver) {
|
|
25
|
+
// If the property exists on the instance itself, return it
|
|
26
|
+
if (prop in target) {
|
|
27
|
+
return Reflect.get(target, prop, receiver);
|
|
28
|
+
}
|
|
29
|
+
// Otherwise, try to get it from the data object
|
|
30
|
+
if (typeof prop === 'string' && prop in target.data) {
|
|
31
|
+
return target.data[prop];
|
|
32
|
+
}
|
|
33
|
+
return undefined;
|
|
34
|
+
},
|
|
35
|
+
set(target, prop, value, receiver) {
|
|
36
|
+
// Reserved properties that should be set on the instance itself
|
|
37
|
+
const reservedProps = ['data', 'productAPI', 'update', 'delete', 'toJSON'];
|
|
38
|
+
if (typeof prop === 'string' && reservedProps.includes(prop)) {
|
|
39
|
+
return Reflect.set(target, prop, value, receiver);
|
|
40
|
+
}
|
|
41
|
+
// All other properties get set on the data object
|
|
42
|
+
if (typeof prop === 'string') {
|
|
43
|
+
target.data[prop] = value;
|
|
44
|
+
return true;
|
|
45
|
+
}
|
|
46
|
+
return false;
|
|
47
|
+
},
|
|
48
|
+
has(target, prop) {
|
|
49
|
+
// Check if property exists on instance or in data
|
|
50
|
+
return prop in target || (typeof prop === 'string' && prop in target.data);
|
|
51
|
+
},
|
|
52
|
+
ownKeys(target) {
|
|
53
|
+
// Return both instance keys and data keys
|
|
54
|
+
const instanceKeys = Reflect.ownKeys(target);
|
|
55
|
+
const dataKeys = Object.keys(target.data);
|
|
56
|
+
return [...new Set([...instanceKeys, ...dataKeys])];
|
|
57
|
+
},
|
|
58
|
+
getOwnPropertyDescriptor(target, prop) {
|
|
59
|
+
// First check if it's an instance property
|
|
60
|
+
const instanceDesc = Reflect.getOwnPropertyDescriptor(target, prop);
|
|
61
|
+
if (instanceDesc) {
|
|
62
|
+
return instanceDesc;
|
|
63
|
+
}
|
|
64
|
+
// Then check if it's a data property
|
|
65
|
+
if (typeof prop === 'string' && prop in target.data) {
|
|
66
|
+
return {
|
|
67
|
+
configurable: true,
|
|
68
|
+
enumerable: true,
|
|
69
|
+
writable: true,
|
|
70
|
+
value: target.data[prop]
|
|
71
|
+
};
|
|
72
|
+
}
|
|
73
|
+
return undefined;
|
|
74
|
+
}
|
|
75
|
+
});
|
|
20
76
|
}
|
|
21
77
|
/**
|
|
22
78
|
* Custom toJSON method to control what gets serialized when logging
|
|
@@ -3,6 +3,7 @@ import ProductInstance from "./product.instance.js";
|
|
|
3
3
|
/**
|
|
4
4
|
* Product pagination instance class providing a fluent API for paginated product results
|
|
5
5
|
* Provides methods for navigating through pages of products
|
|
6
|
+
* Supports array methods like map, filter, forEach for direct iteration
|
|
6
7
|
*/
|
|
7
8
|
export default class ProductPaginationInstance {
|
|
8
9
|
products: ProductInstance[];
|
|
@@ -23,6 +24,63 @@ export default class ProductPaginationInstance {
|
|
|
23
24
|
* @param results - The paginated product results from the API
|
|
24
25
|
*/
|
|
25
26
|
constructor(api: any, results: ProductsResponse);
|
|
27
|
+
/**
|
|
28
|
+
* Returns the number of products in the current page
|
|
29
|
+
*/
|
|
30
|
+
get length(): number;
|
|
31
|
+
/**
|
|
32
|
+
* Maps over the products array
|
|
33
|
+
* @param callback - Function to execute for each product
|
|
34
|
+
* @returns Array of mapped results
|
|
35
|
+
*/
|
|
36
|
+
map<T>(callback: (product: ProductInstance, index: number, array: ProductInstance[]) => T): T[];
|
|
37
|
+
/**
|
|
38
|
+
* Filters the products array
|
|
39
|
+
* @param callback - Function to test each product
|
|
40
|
+
* @returns Array of products that pass the test
|
|
41
|
+
*/
|
|
42
|
+
filter(callback: (product: ProductInstance, index: number, array: ProductInstance[]) => boolean): ProductInstance[];
|
|
43
|
+
/**
|
|
44
|
+
* Executes a function for each product
|
|
45
|
+
* @param callback - Function to execute for each product
|
|
46
|
+
*/
|
|
47
|
+
forEach(callback: (product: ProductInstance, index: number, array: ProductInstance[]) => void): void;
|
|
48
|
+
/**
|
|
49
|
+
* Finds the first product that satisfies the test
|
|
50
|
+
* @param callback - Function to test each product
|
|
51
|
+
* @returns The first product that passes the test, or undefined
|
|
52
|
+
*/
|
|
53
|
+
find(callback: (product: ProductInstance, index: number, array: ProductInstance[]) => boolean): ProductInstance | undefined;
|
|
54
|
+
/**
|
|
55
|
+
* Finds the index of the first product that satisfies the test
|
|
56
|
+
* @param callback - Function to test each product
|
|
57
|
+
* @returns The index of the first product that passes the test, or -1
|
|
58
|
+
*/
|
|
59
|
+
findIndex(callback: (product: ProductInstance, index: number, array: ProductInstance[]) => boolean): number;
|
|
60
|
+
/**
|
|
61
|
+
* Checks if some products satisfy the test
|
|
62
|
+
* @param callback - Function to test each product
|
|
63
|
+
* @returns true if at least one product passes the test
|
|
64
|
+
*/
|
|
65
|
+
some(callback: (product: ProductInstance, index: number, array: ProductInstance[]) => boolean): boolean;
|
|
66
|
+
/**
|
|
67
|
+
* Checks if all products satisfy the test
|
|
68
|
+
* @param callback - Function to test each product
|
|
69
|
+
* @returns true if all products pass the test
|
|
70
|
+
*/
|
|
71
|
+
every(callback: (product: ProductInstance, index: number, array: ProductInstance[]) => boolean): boolean;
|
|
72
|
+
/**
|
|
73
|
+
* Reduces the products array to a single value
|
|
74
|
+
* @param callback - Function to execute on each product
|
|
75
|
+
* @param initialValue - Initial value for the accumulator
|
|
76
|
+
* @returns The final accumulated value
|
|
77
|
+
*/
|
|
78
|
+
reduce<T>(callback: (accumulator: T, product: ProductInstance, index: number, array: ProductInstance[]) => T, initialValue: T): T;
|
|
79
|
+
/**
|
|
80
|
+
* Makes the instance iterable
|
|
81
|
+
* @returns Iterator for the products array
|
|
82
|
+
*/
|
|
83
|
+
[Symbol.iterator](): Iterator<ProductInstance>;
|
|
26
84
|
/**
|
|
27
85
|
* Custom toJSON method to control what gets serialized when logging
|
|
28
86
|
* @returns Serialized products and pagination data
|
|
@@ -2,6 +2,7 @@ import ProductInstance from "./product.instance.js";
|
|
|
2
2
|
/**
|
|
3
3
|
* Product pagination instance class providing a fluent API for paginated product results
|
|
4
4
|
* Provides methods for navigating through pages of products
|
|
5
|
+
* Supports array methods like map, filter, forEach for direct iteration
|
|
5
6
|
*/
|
|
6
7
|
export default class ProductPaginationInstance {
|
|
7
8
|
/**
|
|
@@ -29,6 +30,83 @@ export default class ProductPaginationInstance {
|
|
|
29
30
|
configurable: true
|
|
30
31
|
});
|
|
31
32
|
}
|
|
33
|
+
/**
|
|
34
|
+
* Returns the number of products in the current page
|
|
35
|
+
*/
|
|
36
|
+
get length() {
|
|
37
|
+
return this.products.length;
|
|
38
|
+
}
|
|
39
|
+
/**
|
|
40
|
+
* Maps over the products array
|
|
41
|
+
* @param callback - Function to execute for each product
|
|
42
|
+
* @returns Array of mapped results
|
|
43
|
+
*/
|
|
44
|
+
map(callback) {
|
|
45
|
+
return this.products.map(callback);
|
|
46
|
+
}
|
|
47
|
+
/**
|
|
48
|
+
* Filters the products array
|
|
49
|
+
* @param callback - Function to test each product
|
|
50
|
+
* @returns Array of products that pass the test
|
|
51
|
+
*/
|
|
52
|
+
filter(callback) {
|
|
53
|
+
return this.products.filter(callback);
|
|
54
|
+
}
|
|
55
|
+
/**
|
|
56
|
+
* Executes a function for each product
|
|
57
|
+
* @param callback - Function to execute for each product
|
|
58
|
+
*/
|
|
59
|
+
forEach(callback) {
|
|
60
|
+
this.products.forEach(callback);
|
|
61
|
+
}
|
|
62
|
+
/**
|
|
63
|
+
* Finds the first product that satisfies the test
|
|
64
|
+
* @param callback - Function to test each product
|
|
65
|
+
* @returns The first product that passes the test, or undefined
|
|
66
|
+
*/
|
|
67
|
+
find(callback) {
|
|
68
|
+
return this.products.find(callback);
|
|
69
|
+
}
|
|
70
|
+
/**
|
|
71
|
+
* Finds the index of the first product that satisfies the test
|
|
72
|
+
* @param callback - Function to test each product
|
|
73
|
+
* @returns The index of the first product that passes the test, or -1
|
|
74
|
+
*/
|
|
75
|
+
findIndex(callback) {
|
|
76
|
+
return this.products.findIndex(callback);
|
|
77
|
+
}
|
|
78
|
+
/**
|
|
79
|
+
* Checks if some products satisfy the test
|
|
80
|
+
* @param callback - Function to test each product
|
|
81
|
+
* @returns true if at least one product passes the test
|
|
82
|
+
*/
|
|
83
|
+
some(callback) {
|
|
84
|
+
return this.products.some(callback);
|
|
85
|
+
}
|
|
86
|
+
/**
|
|
87
|
+
* Checks if all products satisfy the test
|
|
88
|
+
* @param callback - Function to test each product
|
|
89
|
+
* @returns true if all products pass the test
|
|
90
|
+
*/
|
|
91
|
+
every(callback) {
|
|
92
|
+
return this.products.every(callback);
|
|
93
|
+
}
|
|
94
|
+
/**
|
|
95
|
+
* Reduces the products array to a single value
|
|
96
|
+
* @param callback - Function to execute on each product
|
|
97
|
+
* @param initialValue - Initial value for the accumulator
|
|
98
|
+
* @returns The final accumulated value
|
|
99
|
+
*/
|
|
100
|
+
reduce(callback, initialValue) {
|
|
101
|
+
return this.products.reduce(callback, initialValue);
|
|
102
|
+
}
|
|
103
|
+
/**
|
|
104
|
+
* Makes the instance iterable
|
|
105
|
+
* @returns Iterator for the products array
|
|
106
|
+
*/
|
|
107
|
+
[Symbol.iterator]() {
|
|
108
|
+
return this.products[Symbol.iterator]();
|
|
109
|
+
}
|
|
32
110
|
/**
|
|
33
111
|
* Custom toJSON method to control what gets serialized when logging
|
|
34
112
|
* @returns Serialized products and pagination data
|
|
@@ -4,6 +4,7 @@ import ProductInstance from "./product.instance.js";
|
|
|
4
4
|
/**
|
|
5
5
|
* Product search instance class providing a fluent API for product search results
|
|
6
6
|
* Contains an array of ProductInstance objects matching the search query
|
|
7
|
+
* Supports array methods like map, filter, forEach for direct iteration
|
|
7
8
|
*/
|
|
8
9
|
export default class ProductSearchInstance {
|
|
9
10
|
products: ProductInstance[];
|
|
@@ -14,6 +15,63 @@ export default class ProductSearchInstance {
|
|
|
14
15
|
* @param results - The product search results from the API
|
|
15
16
|
*/
|
|
16
17
|
constructor(api: ProductAPI, results: SearchProductsResponse);
|
|
18
|
+
/**
|
|
19
|
+
* Returns the number of products in the search results
|
|
20
|
+
*/
|
|
21
|
+
get length(): number;
|
|
22
|
+
/**
|
|
23
|
+
* Maps over the products array
|
|
24
|
+
* @param callback - Function to execute for each product
|
|
25
|
+
* @returns Array of mapped results
|
|
26
|
+
*/
|
|
27
|
+
map<T>(callback: (product: ProductInstance, index: number, array: ProductInstance[]) => T): T[];
|
|
28
|
+
/**
|
|
29
|
+
* Filters the products array
|
|
30
|
+
* @param callback - Function to test each product
|
|
31
|
+
* @returns Array of products that pass the test
|
|
32
|
+
*/
|
|
33
|
+
filter(callback: (product: ProductInstance, index: number, array: ProductInstance[]) => boolean): ProductInstance[];
|
|
34
|
+
/**
|
|
35
|
+
* Executes a function for each product
|
|
36
|
+
* @param callback - Function to execute for each product
|
|
37
|
+
*/
|
|
38
|
+
forEach(callback: (product: ProductInstance, index: number, array: ProductInstance[]) => void): void;
|
|
39
|
+
/**
|
|
40
|
+
* Finds the first product that satisfies the test
|
|
41
|
+
* @param callback - Function to test each product
|
|
42
|
+
* @returns The first product that passes the test, or undefined
|
|
43
|
+
*/
|
|
44
|
+
find(callback: (product: ProductInstance, index: number, array: ProductInstance[]) => boolean): ProductInstance | undefined;
|
|
45
|
+
/**
|
|
46
|
+
* Finds the index of the first product that satisfies the test
|
|
47
|
+
* @param callback - Function to test each product
|
|
48
|
+
* @returns The index of the first product that passes the test, or -1
|
|
49
|
+
*/
|
|
50
|
+
findIndex(callback: (product: ProductInstance, index: number, array: ProductInstance[]) => boolean): number;
|
|
51
|
+
/**
|
|
52
|
+
* Checks if some products satisfy the test
|
|
53
|
+
* @param callback - Function to test each product
|
|
54
|
+
* @returns true if at least one product passes the test
|
|
55
|
+
*/
|
|
56
|
+
some(callback: (product: ProductInstance, index: number, array: ProductInstance[]) => boolean): boolean;
|
|
57
|
+
/**
|
|
58
|
+
* Checks if all products satisfy the test
|
|
59
|
+
* @param callback - Function to test each product
|
|
60
|
+
* @returns true if all products pass the test
|
|
61
|
+
*/
|
|
62
|
+
every(callback: (product: ProductInstance, index: number, array: ProductInstance[]) => boolean): boolean;
|
|
63
|
+
/**
|
|
64
|
+
* Reduces the products array to a single value
|
|
65
|
+
* @param callback - Function to execute on each product
|
|
66
|
+
* @param initialValue - Initial value for the accumulator
|
|
67
|
+
* @returns The final accumulated value
|
|
68
|
+
*/
|
|
69
|
+
reduce<T>(callback: (accumulator: T, product: ProductInstance, index: number, array: ProductInstance[]) => T, initialValue: T): T;
|
|
70
|
+
/**
|
|
71
|
+
* Makes the instance iterable
|
|
72
|
+
* @returns Iterator for the products array
|
|
73
|
+
*/
|
|
74
|
+
[Symbol.iterator](): Iterator<ProductInstance>;
|
|
17
75
|
/**
|
|
18
76
|
* Custom toJSON method to control what gets serialized when logging
|
|
19
77
|
* @returns Serialized search results with product data
|
|
@@ -2,6 +2,7 @@ import ProductInstance from "./product.instance.js";
|
|
|
2
2
|
/**
|
|
3
3
|
* Product search instance class providing a fluent API for product search results
|
|
4
4
|
* Contains an array of ProductInstance objects matching the search query
|
|
5
|
+
* Supports array methods like map, filter, forEach for direct iteration
|
|
5
6
|
*/
|
|
6
7
|
export default class ProductSearchInstance {
|
|
7
8
|
/**
|
|
@@ -19,6 +20,83 @@ export default class ProductSearchInstance {
|
|
|
19
20
|
configurable: true
|
|
20
21
|
});
|
|
21
22
|
}
|
|
23
|
+
/**
|
|
24
|
+
* Returns the number of products in the search results
|
|
25
|
+
*/
|
|
26
|
+
get length() {
|
|
27
|
+
return this.products.length;
|
|
28
|
+
}
|
|
29
|
+
/**
|
|
30
|
+
* Maps over the products array
|
|
31
|
+
* @param callback - Function to execute for each product
|
|
32
|
+
* @returns Array of mapped results
|
|
33
|
+
*/
|
|
34
|
+
map(callback) {
|
|
35
|
+
return this.products.map(callback);
|
|
36
|
+
}
|
|
37
|
+
/**
|
|
38
|
+
* Filters the products array
|
|
39
|
+
* @param callback - Function to test each product
|
|
40
|
+
* @returns Array of products that pass the test
|
|
41
|
+
*/
|
|
42
|
+
filter(callback) {
|
|
43
|
+
return this.products.filter(callback);
|
|
44
|
+
}
|
|
45
|
+
/**
|
|
46
|
+
* Executes a function for each product
|
|
47
|
+
* @param callback - Function to execute for each product
|
|
48
|
+
*/
|
|
49
|
+
forEach(callback) {
|
|
50
|
+
this.products.forEach(callback);
|
|
51
|
+
}
|
|
52
|
+
/**
|
|
53
|
+
* Finds the first product that satisfies the test
|
|
54
|
+
* @param callback - Function to test each product
|
|
55
|
+
* @returns The first product that passes the test, or undefined
|
|
56
|
+
*/
|
|
57
|
+
find(callback) {
|
|
58
|
+
return this.products.find(callback);
|
|
59
|
+
}
|
|
60
|
+
/**
|
|
61
|
+
* Finds the index of the first product that satisfies the test
|
|
62
|
+
* @param callback - Function to test each product
|
|
63
|
+
* @returns The index of the first product that passes the test, or -1
|
|
64
|
+
*/
|
|
65
|
+
findIndex(callback) {
|
|
66
|
+
return this.products.findIndex(callback);
|
|
67
|
+
}
|
|
68
|
+
/**
|
|
69
|
+
* Checks if some products satisfy the test
|
|
70
|
+
* @param callback - Function to test each product
|
|
71
|
+
* @returns true if at least one product passes the test
|
|
72
|
+
*/
|
|
73
|
+
some(callback) {
|
|
74
|
+
return this.products.some(callback);
|
|
75
|
+
}
|
|
76
|
+
/**
|
|
77
|
+
* Checks if all products satisfy the test
|
|
78
|
+
* @param callback - Function to test each product
|
|
79
|
+
* @returns true if all products pass the test
|
|
80
|
+
*/
|
|
81
|
+
every(callback) {
|
|
82
|
+
return this.products.every(callback);
|
|
83
|
+
}
|
|
84
|
+
/**
|
|
85
|
+
* Reduces the products array to a single value
|
|
86
|
+
* @param callback - Function to execute on each product
|
|
87
|
+
* @param initialValue - Initial value for the accumulator
|
|
88
|
+
* @returns The final accumulated value
|
|
89
|
+
*/
|
|
90
|
+
reduce(callback, initialValue) {
|
|
91
|
+
return this.products.reduce(callback, initialValue);
|
|
92
|
+
}
|
|
93
|
+
/**
|
|
94
|
+
* Makes the instance iterable
|
|
95
|
+
* @returns Iterator for the products array
|
|
96
|
+
*/
|
|
97
|
+
[Symbol.iterator]() {
|
|
98
|
+
return this.products[Symbol.iterator]();
|
|
99
|
+
}
|
|
22
100
|
/**
|
|
23
101
|
* Custom toJSON method to control what gets serialized when logging
|
|
24
102
|
* @returns Serialized search results with product data
|
|
@@ -1,8 +1,7 @@
|
|
|
1
|
-
import { UserData } from "../interfaces/admin.js";
|
|
2
1
|
import { UserDataAPI } from "../types/index.js";
|
|
3
2
|
/**
|
|
4
3
|
* User data instance class providing a fluent API for managing user data
|
|
5
|
-
*
|
|
4
|
+
* Provides methods for updating and clearing data
|
|
6
5
|
* Supports direct property access (e.g., user.name) instead of user.data.name
|
|
7
6
|
*/
|
|
8
7
|
export default class UserDataInstance {
|
|
@@ -12,17 +11,10 @@ export default class UserDataInstance {
|
|
|
12
11
|
/**
|
|
13
12
|
* Creates a new UserDataInstance with proxy support for direct property access
|
|
14
13
|
* @param api - The UserDataAPI instance for making API calls
|
|
15
|
-
* @param data - The user data from the API
|
|
14
|
+
* @param data - The user data from the API
|
|
16
15
|
* @returns Proxied instance that allows direct access to data properties
|
|
17
16
|
*/
|
|
18
|
-
constructor(api: UserDataAPI, data:
|
|
19
|
-
/**
|
|
20
|
-
* Removes sensitive fields from the data before storing
|
|
21
|
-
* @param data - The raw user data to sanitize
|
|
22
|
-
* @returns Sanitized data with sensitive fields removed
|
|
23
|
-
* @private
|
|
24
|
-
*/
|
|
25
|
-
private sanitizeData;
|
|
17
|
+
constructor(api: UserDataAPI, data: any);
|
|
26
18
|
/**
|
|
27
19
|
* Custom toJSON method to control what gets serialized when logging
|
|
28
20
|
* @returns Serialized user data
|
|
@@ -31,7 +23,7 @@ export default class UserDataInstance {
|
|
|
31
23
|
/**
|
|
32
24
|
* Updates the user's data
|
|
33
25
|
* @param data - The data fields to update or add to user data
|
|
34
|
-
* @returns Promise resolving to the updated
|
|
26
|
+
* @returns Promise resolving to the updated user data
|
|
35
27
|
* @throws Error if the update fails
|
|
36
28
|
*/
|
|
37
29
|
update(data: Record<string, any>): Promise<any>;
|
|
@@ -1,17 +1,17 @@
|
|
|
1
1
|
/**
|
|
2
2
|
* User data instance class providing a fluent API for managing user data
|
|
3
|
-
*
|
|
3
|
+
* Provides methods for updating and clearing data
|
|
4
4
|
* Supports direct property access (e.g., user.name) instead of user.data.name
|
|
5
5
|
*/
|
|
6
6
|
export default class UserDataInstance {
|
|
7
7
|
/**
|
|
8
8
|
* Creates a new UserDataInstance with proxy support for direct property access
|
|
9
9
|
* @param api - The UserDataAPI instance for making API calls
|
|
10
|
-
* @param data - The user data from the API
|
|
10
|
+
* @param data - The user data from the API
|
|
11
11
|
* @returns Proxied instance that allows direct access to data properties
|
|
12
12
|
*/
|
|
13
13
|
constructor(api, data) {
|
|
14
|
-
this.data =
|
|
14
|
+
this.data = data;
|
|
15
15
|
// Make userAPI non-enumerable so it doesn't show up in console.log
|
|
16
16
|
Object.defineProperty(this, 'userAPI', {
|
|
17
17
|
value: api,
|
|
@@ -74,25 +74,6 @@ export default class UserDataInstance {
|
|
|
74
74
|
}
|
|
75
75
|
});
|
|
76
76
|
}
|
|
77
|
-
/**
|
|
78
|
-
* Removes sensitive fields from the data before storing
|
|
79
|
-
* @param data - The raw user data to sanitize
|
|
80
|
-
* @returns Sanitized data with sensitive fields removed
|
|
81
|
-
* @private
|
|
82
|
-
*/
|
|
83
|
-
sanitizeData(data) {
|
|
84
|
-
if (!data || typeof data !== 'object') {
|
|
85
|
-
return data;
|
|
86
|
-
}
|
|
87
|
-
// Create a copy of the data to avoid mutating the original
|
|
88
|
-
const sanitized = { ...data };
|
|
89
|
-
// Remove sensitive fields
|
|
90
|
-
const sensitiveFields = ['agentId', 'userId'];
|
|
91
|
-
sensitiveFields.forEach(field => {
|
|
92
|
-
delete sanitized[field];
|
|
93
|
-
});
|
|
94
|
-
return sanitized;
|
|
95
|
-
}
|
|
96
77
|
/**
|
|
97
78
|
* Custom toJSON method to control what gets serialized when logging
|
|
98
79
|
* @returns Serialized user data
|
|
@@ -110,13 +91,13 @@ export default class UserDataInstance {
|
|
|
110
91
|
/**
|
|
111
92
|
* Updates the user's data
|
|
112
93
|
* @param data - The data fields to update or add to user data
|
|
113
|
-
* @returns Promise resolving to the updated
|
|
94
|
+
* @returns Promise resolving to the updated user data
|
|
114
95
|
* @throws Error if the update fails
|
|
115
96
|
*/
|
|
116
97
|
async update(data) {
|
|
117
98
|
try {
|
|
118
99
|
const response = await this.userAPI.update(data);
|
|
119
|
-
this.data =
|
|
100
|
+
this.data = response.data;
|
|
120
101
|
return this.data;
|
|
121
102
|
}
|
|
122
103
|
catch (error) {
|
package/dist/index.js
CHANGED
|
@@ -30,6 +30,7 @@ Categories:
|
|
|
30
30
|
☁️ Deployment Push and deploy to production
|
|
31
31
|
💬 Testing Chat and test your agent
|
|
32
32
|
⚙️ Configuration Manage environment and persona
|
|
33
|
+
📖 Utilities Quick access to admin and docs
|
|
33
34
|
|
|
34
35
|
Examples:
|
|
35
36
|
$ lua auth configure 🔑 Set up your API key
|
|
@@ -41,6 +42,8 @@ Examples:
|
|
|
41
42
|
$ lua chat 💬 Start interactive chat
|
|
42
43
|
$ lua env ⚙️ Manage environment variables
|
|
43
44
|
$ lua persona 🤖 Manage agent persona
|
|
45
|
+
$ lua admin 🔧 Open admin dashboard
|
|
46
|
+
$ lua docs 📖 Open documentation
|
|
44
47
|
|
|
45
48
|
🌙 Documentation: https://docs.heylua.ai
|
|
46
49
|
🌙 Support: https://heylua.ai/support
|