vasuzex 2.1.2 → 2.1.4
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/.ai-memory/LOGGER_STRICT_POLICY.md +201 -0
- package/.ai-memory/neastore-feature-mapping.md +1114 -0
- package/bin/create-vasuzex.js +5 -2
- package/examples/runtime-config-examples.js +309 -0
- package/framework/Config/DatabaseConfigService.js +348 -0
- package/framework/Config/DatabaseConfigServiceProvider.js +69 -0
- package/framework/Console/Commands/generate-app.js +97 -4
- package/framework/Console/Commands/generate-media-server.js +2 -1
- package/framework/Console/Commands/utils/mediaServerTemplates.js +3 -2
- package/framework/Console/Commands/utils/webStructure.js +30 -21
- package/framework/Console/config/generator.config.js +3 -3
- package/framework/Console/plopfile.js +0 -8
- package/framework/Console/templates/api/app.js.hbs +5 -4
- package/framework/Console/templates/api/server.js.hbs +8 -2
- package/framework/Database/DatabaseServiceProvider.js +1 -1
- package/framework/Database/Model.js +9 -0
- package/framework/Exceptions/index.js +2 -1
- package/framework/Foundation/BaseApp.js +19 -0
- package/framework/Foundation/BaseService.js +95 -0
- package/framework/Foundation/Container.js +18 -3
- package/framework/Foundation/Providers/index.js +0 -1
- package/framework/Foundation/ServiceProvider.js +42 -0
- package/framework/Http/asyncHandler.js +26 -0
- package/framework/Http/index.js +1 -0
- package/framework/Services/Log/LogManager.js +26 -5
- package/framework/Services/Log/LogServiceProvider.js +48 -0
- package/framework/Services/Log/index.js +1 -0
- package/framework/Services/Mail/MailServiceProvider.js +36 -0
- package/framework/Services/Mail/index.js +1 -0
- package/framework/Services/Media/MediaServiceProvider.js +2 -2
- package/framework/Services/Payment/PaymentServiceProvider.js +35 -0
- package/framework/Services/Payment/index.js +1 -0
- package/framework/Services/Security/SecurityService.js +253 -0
- package/framework/Services/Security/SecurityServiceProvider.js +33 -0
- package/framework/Services/Security/index.js +9 -0
- package/framework/Services/Storage/StorageManager.js +7 -1
- package/framework/Services/Storage/StorageServiceProvider.js +36 -0
- package/framework/Services/Storage/index.js +1 -0
- package/framework/Services/Upload/UploadManager.js +179 -0
- package/framework/Services/index.js +1 -0
- package/framework/Support/Facades/Security.js +14 -0
- package/framework/Support/Facades/index.js +1 -0
- package/framework/Support/Helpers/index.js +1 -0
- package/framework/Support/Helpers/utilities.js +348 -0
- package/framework/index.js +2 -0
- package/frontend/client/Config/ConfigLoader.js +52 -10
- package/frontend/client/Http/ApiHelpers.js +99 -0
- package/frontend/client/Http/index.js +1 -0
- package/frontend/client/index.js +1 -1
- package/frontend/client/package.json +14 -66
- package/frontend/client/package.json.backup +41 -0
- package/frontend/react-ui/components/Avatars/GradientAvatar.jsx +255 -0
- package/frontend/react-ui/components/Avatars/index.js +66 -0
- package/frontend/react-ui/components/BreadCrumb/BreadCrumb.jsx +69 -0
- package/frontend/react-ui/components/BreadCrumb/index.js +2 -0
- package/frontend/react-ui/components/DataTable/ActionDefaults.jsx +171 -0
- package/frontend/react-ui/components/DataTable/DataTable.jsx +202 -328
- package/frontend/react-ui/components/DataTable/Filters.jsx +69 -56
- package/frontend/react-ui/components/DataTable/Pagination.jsx +59 -140
- package/frontend/react-ui/components/DataTable/TableActions.jsx +11 -20
- package/frontend/react-ui/components/DataTable/TableBody.jsx +168 -168
- package/frontend/react-ui/components/DataTable/TableHeader.jsx +93 -96
- package/frontend/react-ui/components/DataTable/TableState.jsx +33 -0
- package/frontend/react-ui/components/DataTable/index.js +10 -8
- package/frontend/react-ui/components/ImageLightbox/ImageLightbox.jsx +118 -0
- package/frontend/react-ui/components/ImageLightbox/index.js +1 -0
- package/frontend/react-ui/components/OrderTimeline/OrderTimeline.jsx +269 -0
- package/frontend/react-ui/components/OrderTimeline/index.js +1 -0
- package/frontend/react-ui/components/ReadMore/ReadMore.jsx +34 -0
- package/frontend/react-ui/components/ReadMore/index.js +1 -0
- package/frontend/react-ui/components/Switch/Switch.jsx +34 -0
- package/frontend/react-ui/components/Switch/index.js +1 -0
- package/frontend/react-ui/hooks/useAppConfig.js +58 -4
- package/frontend/react-ui/hooks/useLocalStorage.js +1 -1
- package/frontend/react-ui/hooks/useValidationErrors.js +1 -1
- package/frontend/react-ui/index.js +10 -0
- package/frontend/react-ui/package.json +17 -108
- package/frontend/react-ui/providers/ApiClientProvider.jsx +1 -1
- package/frontend/react-ui/providers/AppConfigProvider.jsx +212 -20
- package/frontend/react-ui/utils/formatters.js +193 -0
- package/frontend/react-ui/utils/index.js +30 -0
- package/frontend/react-ui/utils/logger.js +62 -0
- package/frontend/react-ui/utils/storage.js +90 -0
- package/frontend/react-ui/utils/swal.js +134 -0
- package/frontend/react-ui/utils/validation.js +207 -0
- package/package.json +6 -2
- package/framework/Foundation/Providers/LogServiceProvider.js +0 -33
|
@@ -0,0 +1,171 @@
|
|
|
1
|
+
import { FiEye, FiEdit, FiTrash2 } from "react-icons/fi";
|
|
2
|
+
|
|
3
|
+
/**
|
|
4
|
+
* ActionDefaults - Production Ready
|
|
5
|
+
*
|
|
6
|
+
* Default configurations for common DataTable actions
|
|
7
|
+
* Provides sensible defaults for edit, view, delete, and switch actions
|
|
8
|
+
*
|
|
9
|
+
* @module components/DataTable/ActionDefaults
|
|
10
|
+
*/
|
|
11
|
+
|
|
12
|
+
export const ACTION_DEFAULTS = {
|
|
13
|
+
edit: {
|
|
14
|
+
type: "link",
|
|
15
|
+
label: "Edit",
|
|
16
|
+
icon: FiEdit,
|
|
17
|
+
title: "Edit",
|
|
18
|
+
extraClass:
|
|
19
|
+
"rounded-lg p-2 text-brand-600 hover:bg-brand-50 dark:text-brand-400 dark:hover:bg-gray-700",
|
|
20
|
+
},
|
|
21
|
+
view: {
|
|
22
|
+
type: "button",
|
|
23
|
+
label: "View Details",
|
|
24
|
+
icon: FiEye,
|
|
25
|
+
title: "View Details",
|
|
26
|
+
extraClass:
|
|
27
|
+
"rounded-lg p-2 text-blue-600 hover:bg-blue-50 dark:text-blue-400 dark:hover:bg-gray-700",
|
|
28
|
+
},
|
|
29
|
+
delete: {
|
|
30
|
+
type: "button",
|
|
31
|
+
label: "Delete",
|
|
32
|
+
icon: FiTrash2,
|
|
33
|
+
title: "Delete",
|
|
34
|
+
extraClass:
|
|
35
|
+
"rounded-lg p-2 text-red-600 hover:bg-red-50 dark:text-red-400 dark:hover:bg-gray-700",
|
|
36
|
+
},
|
|
37
|
+
switch: {
|
|
38
|
+
type: "button",
|
|
39
|
+
name: "switch",
|
|
40
|
+
label: "",
|
|
41
|
+
title: "Toggle Status",
|
|
42
|
+
},
|
|
43
|
+
};
|
|
44
|
+
|
|
45
|
+
/**
|
|
46
|
+
* Apply default configuration to an action based on its name
|
|
47
|
+
*/
|
|
48
|
+
export function applyActionDefaults(
|
|
49
|
+
action,
|
|
50
|
+
resourceName,
|
|
51
|
+
resourceIdField = "id",
|
|
52
|
+
) {
|
|
53
|
+
const actionName = action.name;
|
|
54
|
+
const defaults = ACTION_DEFAULTS[actionName];
|
|
55
|
+
|
|
56
|
+
// For switch action, return as-is (handled separately in TableBody)
|
|
57
|
+
if (actionName === "switch") {
|
|
58
|
+
return {
|
|
59
|
+
...defaults,
|
|
60
|
+
...action,
|
|
61
|
+
};
|
|
62
|
+
}
|
|
63
|
+
|
|
64
|
+
// Merge defaults with user-provided config
|
|
65
|
+
const mergedAction = {
|
|
66
|
+
...defaults,
|
|
67
|
+
...action,
|
|
68
|
+
};
|
|
69
|
+
|
|
70
|
+
// Auto-generate getHref for edit action if resourceName is provided
|
|
71
|
+
if (actionName === "edit" && !mergedAction.getHref && resourceName) {
|
|
72
|
+
mergedAction.getHref = (row) => `/${resourceName}/${row[resourceIdField]}/edit`;
|
|
73
|
+
}
|
|
74
|
+
|
|
75
|
+
// Auto-generate apiUrl for view action if resourceName is provided
|
|
76
|
+
if (actionName === "view" && !mergedAction.apiUrl && !mergedAction.onClick && resourceName) {
|
|
77
|
+
mergedAction.apiUrl = `/${resourceName}/:id`;
|
|
78
|
+
// Generate modalEvent name if not provided
|
|
79
|
+
if (!mergedAction.modalEvent) {
|
|
80
|
+
const capitalizedResource = resourceName.charAt(0).toUpperCase() + resourceName.slice(0, -1);
|
|
81
|
+
mergedAction.modalEvent = `show${capitalizedResource}DetailsModal`;
|
|
82
|
+
}
|
|
83
|
+
}
|
|
84
|
+
|
|
85
|
+
return mergedAction;
|
|
86
|
+
}
|
|
87
|
+
|
|
88
|
+
/**
|
|
89
|
+
* Create a default view action onClick handler
|
|
90
|
+
*/
|
|
91
|
+
export function createViewClickHandler(
|
|
92
|
+
api,
|
|
93
|
+
apiUrl,
|
|
94
|
+
modalEvent,
|
|
95
|
+
resourceIdField = "id",
|
|
96
|
+
) {
|
|
97
|
+
if (!api) {
|
|
98
|
+
throw new Error('createViewClickHandler requires "api" parameter');
|
|
99
|
+
}
|
|
100
|
+
|
|
101
|
+
return async (row) => {
|
|
102
|
+
try {
|
|
103
|
+
const url = apiUrl.replace(":id", row[resourceIdField]);
|
|
104
|
+
const { data } = await api.get(url);
|
|
105
|
+
window.dispatchEvent(new CustomEvent(modalEvent, { detail: data }));
|
|
106
|
+
} catch (error) {
|
|
107
|
+
const toast = (await import("react-toastify")).toast;
|
|
108
|
+
toast.error(error.message || "Failed to load details");
|
|
109
|
+
}
|
|
110
|
+
};
|
|
111
|
+
}
|
|
112
|
+
|
|
113
|
+
/**
|
|
114
|
+
* Create a default delete action onClick handler with confirmation
|
|
115
|
+
*/
|
|
116
|
+
export function createDeleteClickHandler(
|
|
117
|
+
api,
|
|
118
|
+
deleteUrl,
|
|
119
|
+
confirmMessage,
|
|
120
|
+
resourceIdField = "id",
|
|
121
|
+
options = {}
|
|
122
|
+
) {
|
|
123
|
+
if (!api) {
|
|
124
|
+
throw new Error('createDeleteClickHandler requires "api" parameter');
|
|
125
|
+
}
|
|
126
|
+
|
|
127
|
+
return async (row) => {
|
|
128
|
+
try {
|
|
129
|
+
// Try to use SweetAlert2 if available
|
|
130
|
+
const Swal = window.Swal;
|
|
131
|
+
|
|
132
|
+
if (Swal) {
|
|
133
|
+
const result = await Swal.fire({
|
|
134
|
+
title: options?.confirmTitle || "Are you sure?",
|
|
135
|
+
text: typeof confirmMessage === "function" ? confirmMessage(row) : confirmMessage,
|
|
136
|
+
icon: "warning",
|
|
137
|
+
showCancelButton: true,
|
|
138
|
+
confirmButtonColor: "#d33",
|
|
139
|
+
cancelButtonColor: "#3085d6",
|
|
140
|
+
confirmButtonText: options?.confirmButtonText || "Yes, delete it!",
|
|
141
|
+
});
|
|
142
|
+
|
|
143
|
+
if (!result.isConfirmed) return;
|
|
144
|
+
} else {
|
|
145
|
+
const message = typeof confirmMessage === "function" ? confirmMessage(row) : confirmMessage;
|
|
146
|
+
if (!window.confirm(message)) return;
|
|
147
|
+
}
|
|
148
|
+
|
|
149
|
+
// Perform delete operation
|
|
150
|
+
const url = deleteUrl.replace(":id", row[resourceIdField]);
|
|
151
|
+
await api.delete(url);
|
|
152
|
+
|
|
153
|
+
// Show success message
|
|
154
|
+
const toast = (await import("react-toastify")).toast;
|
|
155
|
+
const successMsg = options?.successMessage
|
|
156
|
+
? typeof options.successMessage === "function"
|
|
157
|
+
? options.successMessage(row)
|
|
158
|
+
: options.successMessage
|
|
159
|
+
: "Deleted successfully";
|
|
160
|
+
toast.success(successMsg);
|
|
161
|
+
|
|
162
|
+
// Trigger refresh
|
|
163
|
+
if (options?.onRefresh) {
|
|
164
|
+
options.onRefresh();
|
|
165
|
+
}
|
|
166
|
+
} catch (error) {
|
|
167
|
+
const toast = (await import("react-toastify")).toast;
|
|
168
|
+
toast.error(error.message || "Failed to delete");
|
|
169
|
+
}
|
|
170
|
+
};
|
|
171
|
+
}
|