nucleus-core-ts 0.8.7 → 0.8.9
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/client.js +1 -1
- package/dist/fe/components/AbstractAnimatedBackground/index.js +437 -0
- package/dist/fe/components/AuthorizationPage/components/AuthorizationPage.js +841 -0
- package/dist/fe/components/AuthorizationPage/components/ClaimList.js +100 -0
- package/dist/fe/components/AuthorizationPage/components/RoleClaimEditor.js +232 -0
- package/dist/fe/components/AuthorizationPage/components/RoleList.js +115 -0
- package/dist/fe/components/AuthorizationPage/index.js +6 -0
- package/dist/fe/components/AuthorizationPage/store/index.js +117 -0
- package/dist/fe/components/AuthorizationPage/theme/index.js +137 -0
- package/dist/fe/components/AuthorizationPage/types/index.js +1 -0
- package/dist/fe/components/Button/components/Button.js +158 -0
- package/dist/fe/components/Button/components/ButtonSpinner.js +52 -0
- package/dist/fe/components/Button/index.js +3 -0
- package/dist/fe/components/Button/theme/index.js +186 -0
- package/dist/fe/components/Button/types/index.js +1 -0
- package/dist/fe/components/Button/utils/cn.js +5 -0
- package/dist/fe/components/Captcha/components/Captcha.js +311 -0
- package/dist/fe/components/Captcha/index.js +2 -0
- package/dist/fe/components/Captcha/theme.js +52 -0
- package/dist/fe/components/Captcha/types.js +1 -0
- package/dist/fe/components/ChangePasswordPage/components/ChangePasswordForm.js +242 -0
- package/dist/fe/components/ChangePasswordPage/components/ChangePasswordHeader.js +39 -0
- package/dist/fe/components/ChangePasswordPage/components/ChangePasswordPage.js +60 -0
- package/dist/fe/components/ChangePasswordPage/index.js +5 -0
- package/dist/fe/components/ChangePasswordPage/store/index.js +44 -0
- package/dist/fe/components/ChangePasswordPage/theme/index.js +87 -0
- package/dist/fe/components/ChangePasswordPage/types/index.js +1 -0
- package/dist/fe/components/Checkbox/components/Checkbox.js +115 -0
- package/dist/fe/components/Checkbox/components/CheckboxIcon.js +119 -0
- package/dist/fe/components/Checkbox/components/SwitchTrack.js +178 -0
- package/dist/fe/components/Checkbox/index.js +4 -0
- package/dist/fe/components/Checkbox/theme/index.js +221 -0
- package/dist/fe/components/Checkbox/types/index.js +1 -0
- package/dist/fe/components/Checkbox/utils/cn.js +5 -0
- package/dist/fe/components/DataTable/DataTable.js +225 -0
- package/dist/fe/components/DataTable/components/ActionCell.js +26 -0
- package/dist/fe/components/DataTable/components/DataCell.js +76 -0
- package/dist/fe/components/DataTable/components/EditableCell.js +221 -0
- package/dist/fe/components/DataTable/components/EmptyState.js +29 -0
- package/dist/fe/components/DataTable/components/HeaderCell.js +64 -0
- package/dist/fe/components/DataTable/components/InfiniteScrollTrigger.js +66 -0
- package/dist/fe/components/DataTable/components/LoadingSpinner.js +19 -0
- package/dist/fe/components/DataTable/components/ResizeHandle.js +41 -0
- package/dist/fe/components/DataTable/components/SelectionCell.js +105 -0
- package/dist/fe/components/DataTable/components/SkeletonRow.js +56 -0
- package/dist/fe/components/DataTable/components/SkeletonTable.js +83 -0
- package/dist/fe/components/DataTable/components/SortIcon.js +39 -0
- package/dist/fe/components/DataTable/components/TableHeader.js +49 -0
- package/dist/fe/components/DataTable/components/TableRow.js +118 -0
- package/dist/fe/components/DataTable/components/index.js +14 -0
- package/dist/fe/components/DataTable/hooks/index.js +2 -0
- package/dist/fe/components/DataTable/hooks/useAutoFitColumn.js +23 -0
- package/dist/fe/components/DataTable/hooks/useResizeColumn.js +122 -0
- package/dist/fe/components/DataTable/index.js +3 -0
- package/dist/fe/components/DataTable/store/index.js +97 -0
- package/dist/fe/components/DataTable/theme/index.js +144 -0
- package/dist/fe/components/DataTable/types/index.js +1 -0
- package/dist/fe/components/DataTable/utils/cn.js +5 -0
- package/dist/fe/components/DatePicker/components/CalendarGrid.js +95 -0
- package/dist/fe/components/DatePicker/components/CalendarHeader.js +152 -0
- package/dist/fe/components/DatePicker/components/DatePicker.js +381 -0
- package/dist/fe/components/DatePicker/components/MonthYearSelector.js +93 -0
- package/dist/fe/components/DatePicker/index.js +7 -0
- package/dist/fe/components/DatePicker/locales/index.js +1113 -0
- package/dist/fe/components/DatePicker/theme/index.js +315 -0
- package/dist/fe/components/DatePicker/types/index.js +1 -0
- package/dist/fe/components/DatePicker/utils/cn.js +5 -0
- package/dist/fe/components/DatePicker/utils/date.js +132 -0
- package/dist/fe/components/DevicesPage/components/DeviceCard.js +251 -0
- package/dist/fe/components/DevicesPage/components/DevicesHeader.js +42 -0
- package/dist/fe/components/DevicesPage/components/DevicesPage.js +450 -0
- package/dist/fe/components/DevicesPage/index.js +5 -0
- package/dist/fe/components/DevicesPage/store/index.js +55 -0
- package/dist/fe/components/DevicesPage/theme/index.js +131 -0
- package/dist/fe/components/DevicesPage/types/index.js +1 -0
- package/dist/fe/components/ForgotPasswordPage/components/ForgotPasswordForm.js +214 -0
- package/dist/fe/components/ForgotPasswordPage/components/ForgotPasswordHeader.js +42 -0
- package/dist/fe/components/ForgotPasswordPage/components/ForgotPasswordPage.js +59 -0
- package/dist/fe/components/ForgotPasswordPage/index.js +5 -0
- package/dist/fe/components/ForgotPasswordPage/store/index.js +28 -0
- package/dist/fe/components/ForgotPasswordPage/theme/index.js +87 -0
- package/dist/fe/components/ForgotPasswordPage/types/index.js +1 -0
- package/dist/fe/components/FormBuilder/components/FormBuilder.js +156 -0
- package/dist/fe/components/FormBuilder/components/FormField.js +218 -0
- package/dist/fe/components/FormBuilder/hooks/useFormBuilder.js +152 -0
- package/dist/fe/components/FormBuilder/index.js +4 -0
- package/dist/fe/components/FormBuilder/theme/index.js +134 -0
- package/dist/fe/components/FormBuilder/types/index.js +1 -0
- package/dist/fe/components/FormBuilder/utils/cn.js +5 -0
- package/dist/fe/components/FormBuilder/utils/fieldMapping.js +216 -0
- package/dist/fe/components/FormBuilder/utils/validation.js +78 -0
- package/dist/fe/components/LoginPage/components/LoginForm.js +214 -0
- package/dist/fe/components/LoginPage/components/LoginHeader.js +24 -0
- package/dist/fe/components/LoginPage/components/LoginPage.js +138 -0
- package/dist/fe/components/LoginPage/index.js +5 -0
- package/dist/fe/components/LoginPage/store/index.js +59 -0
- package/dist/fe/components/LoginPage/theme/index.js +98 -0
- package/dist/fe/components/LoginPage/types/index.js +1 -0
- package/dist/fe/components/MagicLinkVerifyPage/components/MagicLinkVerifyPage.js +200 -0
- package/dist/fe/components/MagicLinkVerifyPage/index.js +3 -0
- package/dist/fe/components/MagicLinkVerifyPage/store.js +20 -0
- package/dist/fe/components/MagicLinkVerifyPage/theme.js +36 -0
- package/dist/fe/components/MagicLinkVerifyPage/types.js +1 -0
- package/dist/fe/components/NucleusEntityShowcase.js +1409 -0
- package/dist/fe/components/NucleusTextInput/components/FloatingLabel.js +56 -0
- package/dist/fe/components/NucleusTextInput/components/InputIcons.js +258 -0
- package/dist/fe/components/NucleusTextInput/components/NucleusTextInput.js +321 -0
- package/dist/fe/components/NucleusTextInput/components/PasswordStrengthIndicator.js +104 -0
- package/dist/fe/components/NucleusTextInput/components/TypewriterText.js +56 -0
- package/dist/fe/components/NucleusTextInput/index.js +7 -0
- package/dist/fe/components/NucleusTextInput/theme/index.js +121 -0
- package/dist/fe/components/NucleusTextInput/types/index.js +1 -0
- package/dist/fe/components/NucleusTextInput/utils/cn.js +5 -0
- package/dist/fe/components/NucleusTextInput/utils/format.js +62 -0
- package/dist/fe/components/NucleusTextInput/utils/validation.js +191 -0
- package/dist/fe/components/ProfilePage/components/AddressCard.js +196 -0
- package/dist/fe/components/ProfilePage/components/PhoneCard.js +206 -0
- package/dist/fe/components/ProfilePage/components/ProfileHeader.js +150 -0
- package/dist/fe/components/ProfilePage/components/ProfilePage.js +1336 -0
- package/dist/fe/components/ProfilePage/index.js +6 -0
- package/dist/fe/components/ProfilePage/store/index.js +115 -0
- package/dist/fe/components/ProfilePage/theme/index.js +168 -0
- package/dist/fe/components/ProfilePage/types/index.js +1 -0
- package/dist/fe/components/RangePicker/components/RangePicker.js +338 -0
- package/dist/fe/components/RangePicker/components/RangeThumb.js +68 -0
- package/dist/fe/components/RangePicker/components/RangeTooltip.js +45 -0
- package/dist/fe/components/RangePicker/components/RangeTrack.js +32 -0
- package/dist/fe/components/RangePicker/index.js +5 -0
- package/dist/fe/components/RangePicker/theme/index.js +88 -0
- package/dist/fe/components/RangePicker/types/index.js +1 -0
- package/dist/fe/components/RangePicker/utils/cn.js +3 -0
- package/dist/fe/components/RegisterPage/components/PasswordStrengthIndicator.js +107 -0
- package/dist/fe/components/RegisterPage/components/RegisterForm.js +322 -0
- package/dist/fe/components/RegisterPage/components/RegisterHeader.js +23 -0
- package/dist/fe/components/RegisterPage/components/RegisterPage.js +85 -0
- package/dist/fe/components/RegisterPage/index.js +6 -0
- package/dist/fe/components/RegisterPage/store/index.js +106 -0
- package/dist/fe/components/RegisterPage/theme/index.js +128 -0
- package/dist/fe/components/RegisterPage/types/index.js +1 -0
- package/dist/fe/components/ResetPasswordPage/components/ResetPasswordForm.js +347 -0
- package/dist/fe/components/ResetPasswordPage/components/ResetPasswordHeader.js +42 -0
- package/dist/fe/components/ResetPasswordPage/components/ResetPasswordPage.js +61 -0
- package/dist/fe/components/ResetPasswordPage/index.js +5 -0
- package/dist/fe/components/ResetPasswordPage/store/index.js +36 -0
- package/dist/fe/components/ResetPasswordPage/theme/index.js +99 -0
- package/dist/fe/components/ResetPasswordPage/types/index.js +1 -0
- package/dist/fe/components/SearchBox/components/SearchBox.js +271 -0
- package/dist/fe/components/SearchBox/components/SearchBoxDropdown.js +87 -0
- package/dist/fe/components/SearchBox/index.js +5 -0
- package/dist/fe/components/SearchBox/theme/index.js +184 -0
- package/dist/fe/components/SearchBox/types/index.js +1 -0
- package/dist/fe/components/SearchBox/utils/cn.js +5 -0
- package/dist/fe/components/SearchBox/utils/debounce.js +22 -0
- package/dist/fe/components/SearchBox/utils/sanitize.js +48 -0
- package/dist/fe/components/SelectBox/components/SelectBox.js +364 -0
- package/dist/fe/components/SelectBox/components/SelectDropdown.js +92 -0
- package/dist/fe/components/SelectBox/components/SelectOptionItem.js +43 -0
- package/dist/fe/components/SelectBox/components/SelectTrigger.js +22 -0
- package/dist/fe/components/SelectBox/index.js +5 -0
- package/dist/fe/components/SelectBox/theme/index.js +98 -0
- package/dist/fe/components/SelectBox/types/index.js +1 -0
- package/dist/fe/components/SelectBox/utils/cn.js +3 -0
- package/dist/fe/components/SetPasswordPage/components/PasswordStrengthIndicator.js +107 -0
- package/dist/fe/components/SetPasswordPage/components/SetPasswordForm.js +142 -0
- package/dist/fe/components/SetPasswordPage/components/SetPasswordHeader.js +23 -0
- package/dist/fe/components/SetPasswordPage/components/SetPasswordPage.js +263 -0
- package/dist/fe/components/SetPasswordPage/index.js +7 -0
- package/dist/fe/components/SetPasswordPage/store/index.js +79 -0
- package/dist/fe/components/SetPasswordPage/theme/index.js +98 -0
- package/dist/fe/components/SetPasswordPage/types/index.js +12 -0
- package/dist/fe/components/UsersPage/components/InviteUserModal.js +262 -0
- package/dist/fe/components/UsersPage/components/Pagination.js +147 -0
- package/dist/fe/components/UsersPage/components/RoleAssignmentModal.js +186 -0
- package/dist/fe/components/UsersPage/components/StatsCards.js +124 -0
- package/dist/fe/components/UsersPage/components/UserDetailDrawer.js +444 -0
- package/dist/fe/components/UsersPage/components/UserFilters.js +142 -0
- package/dist/fe/components/UsersPage/components/UserListItem.js +125 -0
- package/dist/fe/components/UsersPage/components/UserListSkeleton.js +40 -0
- package/dist/fe/components/UsersPage/components/UsersPage.js +556 -0
- package/dist/fe/components/UsersPage/index.js +10 -0
- package/dist/fe/components/UsersPage/store/index.js +151 -0
- package/dist/fe/components/UsersPage/theme/index.js +231 -0
- package/dist/fe/components/UsersPage/types/index.js +1 -0
- package/dist/fe/components/VerifyEmailPage/components/VerifyEmailPage.js +290 -0
- package/dist/fe/components/VerifyEmailPage/index.js +3 -0
- package/dist/fe/components/VerifyEmailPage/store/index.js +45 -0
- package/dist/fe/components/VerifyEmailPage/theme/index.js +52 -0
- package/dist/fe/components/VerifyEmailPage/types/index.js +1 -0
- package/dist/fe/hooks/useNucleusEntity.js +247 -0
- package/dist/fe/index.js +28 -157
- package/dist/fe/types/index.js +1 -0
- package/dist/fe/utils/cn.js +5 -0
- package/dist/fe/utils/columnUtils.js +189 -0
- package/dist/fe/utils/endpointKeys.js +44 -0
- package/dist/index.js +1 -1
- package/dist/nucleus.config.d.ts +2 -0
- package/dist/src/Client/ApiCaller/client.js +1 -0
- package/dist/src/Client/ApiCaller/examples/usage.example.js +1 -0
- package/dist/src/Client/ApiCaller/generator.js +1 -0
- package/dist/src/Client/ApiCaller/index.js +1 -0
- package/dist/src/Client/ApiCaller/server.js +1 -0
- package/dist/src/Client/ApiCaller/system-tables.js +1 -0
- package/dist/src/Client/ApiCaller/types.js +1 -0
- package/dist/src/Client/Proxy/httpProxy.js +1 -0
- package/dist/src/Client/Proxy/index.js +1 -1
- package/dist/src/Client/Proxy/server.js +1 -0
- package/dist/src/Client/Proxy/types.js +1 -0
- package/dist/src/Client/Proxy/utils.js +1 -0
- package/dist/src/Client/Proxy/wsProxy.js +1 -0
- package/dist/src/Client/ServerFetch/index.js +1 -0
- package/dist/src/Client/ServerFetch/types.js +1 -0
- package/dist/src/Client/index.js +1 -0
- package/package.json +1 -1
- package/scripts/build.ts +41 -16
|
@@ -0,0 +1,189 @@
|
|
|
1
|
+
export function formatLabel(name) {
|
|
2
|
+
return name.replace(/_/g, " ").replace(/([a-z])([A-Z])/g, "$1 $2").replace(/\b\w/g, (char)=>char.toUpperCase());
|
|
3
|
+
}
|
|
4
|
+
export function shouldExcludeColumn(column) {
|
|
5
|
+
if (column.primaryKey && column.type === "serial") return true;
|
|
6
|
+
if (column.primaryKey && column.type === "bigserial") return true;
|
|
7
|
+
if (column.primaryKey && column.type === "smallserial") return true;
|
|
8
|
+
if (column.generatedAlwaysAs) return true;
|
|
9
|
+
if (column.generatedAlwaysAsIdentity) return true;
|
|
10
|
+
const autoFields = [
|
|
11
|
+
"created_at",
|
|
12
|
+
"updated_at",
|
|
13
|
+
"deleted_at"
|
|
14
|
+
];
|
|
15
|
+
if (autoFields.includes(column.name)) return true;
|
|
16
|
+
return false;
|
|
17
|
+
}
|
|
18
|
+
export function shouldExcludeFromForm(column, mode) {
|
|
19
|
+
if (shouldExcludeColumn(column)) return true;
|
|
20
|
+
if (column.primaryKey) return true;
|
|
21
|
+
if (column.name === "id") return true;
|
|
22
|
+
if (mode === "add") {
|
|
23
|
+
if (column.defaultRaw?.includes("gen_random_uuid")) return true;
|
|
24
|
+
if (column.generatedByDefaultAsIdentity) return true;
|
|
25
|
+
}
|
|
26
|
+
return false;
|
|
27
|
+
}
|
|
28
|
+
export function isReferenceColumn(column) {
|
|
29
|
+
return !!column.references;
|
|
30
|
+
}
|
|
31
|
+
export function isJsonColumn(column) {
|
|
32
|
+
return column.type === "json" || column.type === "jsonb";
|
|
33
|
+
}
|
|
34
|
+
export function isArrayColumn(column) {
|
|
35
|
+
return !!column.array;
|
|
36
|
+
}
|
|
37
|
+
export function getColumnType(column) {
|
|
38
|
+
if (column.enumValues || column.enum) {
|
|
39
|
+
return "select";
|
|
40
|
+
}
|
|
41
|
+
switch(column.type){
|
|
42
|
+
case "integer":
|
|
43
|
+
case "smallint":
|
|
44
|
+
case "bigint":
|
|
45
|
+
case "serial":
|
|
46
|
+
case "smallserial":
|
|
47
|
+
case "bigserial":
|
|
48
|
+
case "real":
|
|
49
|
+
case "doublePrecision":
|
|
50
|
+
case "numeric":
|
|
51
|
+
case "decimal":
|
|
52
|
+
case "money":
|
|
53
|
+
return "number";
|
|
54
|
+
case "boolean":
|
|
55
|
+
return "boolean";
|
|
56
|
+
case "date":
|
|
57
|
+
case "time":
|
|
58
|
+
case "timestamp":
|
|
59
|
+
case "timestamptz":
|
|
60
|
+
return "date";
|
|
61
|
+
case "json":
|
|
62
|
+
case "jsonb":
|
|
63
|
+
return "json";
|
|
64
|
+
case "bytea":
|
|
65
|
+
case "vector":
|
|
66
|
+
case "geometry":
|
|
67
|
+
case "geography":
|
|
68
|
+
return "hidden";
|
|
69
|
+
default:
|
|
70
|
+
return "text";
|
|
71
|
+
}
|
|
72
|
+
}
|
|
73
|
+
export function getDefaultValue(column) {
|
|
74
|
+
if (column.default !== undefined) {
|
|
75
|
+
return column.default;
|
|
76
|
+
}
|
|
77
|
+
const colType = getColumnType(column);
|
|
78
|
+
switch(colType){
|
|
79
|
+
case "number":
|
|
80
|
+
return column.nullable ? null : 0;
|
|
81
|
+
case "boolean":
|
|
82
|
+
return false;
|
|
83
|
+
case "date":
|
|
84
|
+
return null;
|
|
85
|
+
case "select":
|
|
86
|
+
return column.nullable ? null : "";
|
|
87
|
+
case "json":
|
|
88
|
+
return column.nullable ? null : {};
|
|
89
|
+
default:
|
|
90
|
+
return "";
|
|
91
|
+
}
|
|
92
|
+
}
|
|
93
|
+
// Column type constants for type-safe filtering
|
|
94
|
+
const TEXT_COLUMN_TYPES = [
|
|
95
|
+
"text",
|
|
96
|
+
"varchar",
|
|
97
|
+
"char"
|
|
98
|
+
];
|
|
99
|
+
const NUMERIC_COLUMN_TYPES = [
|
|
100
|
+
"integer",
|
|
101
|
+
"smallint",
|
|
102
|
+
"bigint",
|
|
103
|
+
"serial",
|
|
104
|
+
"smallserial",
|
|
105
|
+
"bigserial",
|
|
106
|
+
"real",
|
|
107
|
+
"doublePrecision",
|
|
108
|
+
"numeric",
|
|
109
|
+
"decimal",
|
|
110
|
+
"money"
|
|
111
|
+
];
|
|
112
|
+
const DATE_COLUMN_TYPES = [
|
|
113
|
+
"date",
|
|
114
|
+
"time",
|
|
115
|
+
"timestamp",
|
|
116
|
+
"timestamptz"
|
|
117
|
+
];
|
|
118
|
+
/**
|
|
119
|
+
* Check if column is searchable (text-based)
|
|
120
|
+
*/ export function isSearchableColumn(column) {
|
|
121
|
+
return TEXT_COLUMN_TYPES.includes(column.type);
|
|
122
|
+
}
|
|
123
|
+
/**
|
|
124
|
+
* Check if column has enum values (for SelectBox filter)
|
|
125
|
+
* Handles both enumValues array and enum.values from customType columns
|
|
126
|
+
*/ export function isEnumColumn(column) {
|
|
127
|
+
if ((column.enumValues?.length ?? 0) > 0) return true;
|
|
128
|
+
if ((column.enum?.values?.length ?? 0) > 0) return true;
|
|
129
|
+
if (column.type === "customType" && column.enum) return true;
|
|
130
|
+
return false;
|
|
131
|
+
}
|
|
132
|
+
/**
|
|
133
|
+
* Check if column is boolean (for SelectBox filter with Yes/No)
|
|
134
|
+
*/ export function isBooleanColumn(column) {
|
|
135
|
+
return column.type === "boolean";
|
|
136
|
+
}
|
|
137
|
+
/**
|
|
138
|
+
* Check if column is numeric (for RangePicker filter)
|
|
139
|
+
*/ export function isNumericColumn(column) {
|
|
140
|
+
return NUMERIC_COLUMN_TYPES.includes(column.type);
|
|
141
|
+
}
|
|
142
|
+
/**
|
|
143
|
+
* Check if column is date/time (for DatePicker filter)
|
|
144
|
+
*/ export function isDateColumn(column) {
|
|
145
|
+
return DATE_COLUMN_TYPES.includes(column.type);
|
|
146
|
+
}
|
|
147
|
+
/**
|
|
148
|
+
* Check if column is a decimal type (for formatting)
|
|
149
|
+
*/ export function isDecimalColumn(column) {
|
|
150
|
+
return [
|
|
151
|
+
"numeric",
|
|
152
|
+
"decimal",
|
|
153
|
+
"real",
|
|
154
|
+
"doublePrecision",
|
|
155
|
+
"money"
|
|
156
|
+
].includes(column.type);
|
|
157
|
+
}
|
|
158
|
+
/**
|
|
159
|
+
* Get enum values from column
|
|
160
|
+
*/ export function getEnumValues(column) {
|
|
161
|
+
if (column.enumValues?.length) {
|
|
162
|
+
return column.enumValues;
|
|
163
|
+
}
|
|
164
|
+
if (column.enum?.values?.length) {
|
|
165
|
+
return column.enum.values;
|
|
166
|
+
}
|
|
167
|
+
return [];
|
|
168
|
+
}
|
|
169
|
+
/**
|
|
170
|
+
* Filter columns that can be searched (text-type columns)
|
|
171
|
+
*/ export function getSearchableColumns(columns) {
|
|
172
|
+
return columns.filter(isSearchableColumn);
|
|
173
|
+
}
|
|
174
|
+
/**
|
|
175
|
+
* Filter columns that can be filtered with enum/boolean SelectBox
|
|
176
|
+
*/ export function getEnumFilterColumns(columns) {
|
|
177
|
+
return columns.filter((col)=>isEnumColumn(col) || isBooleanColumn(col));
|
|
178
|
+
}
|
|
179
|
+
/**
|
|
180
|
+
* Filter columns that can be filtered with RangePicker (numeric)
|
|
181
|
+
*/ export function getNumericFilterColumns(columns) {
|
|
182
|
+
return columns.filter((col)=>isNumericColumn(col) && !col.primaryKey);
|
|
183
|
+
}
|
|
184
|
+
/**
|
|
185
|
+
* Filter columns that can be filtered with DatePicker
|
|
186
|
+
* Includes base date columns (created_at, updated_at)
|
|
187
|
+
*/ export function getDateFilterColumns(columns) {
|
|
188
|
+
return columns.filter((col)=>isDateColumn(col));
|
|
189
|
+
}
|
|
@@ -0,0 +1,44 @@
|
|
|
1
|
+
export function toUpperSnakeCase(str) {
|
|
2
|
+
return str.replace(/([a-z])([A-Z])/g, "$1_$2").replace(/[\s-]+/g, "_").toUpperCase();
|
|
3
|
+
}
|
|
4
|
+
export function singularize(str) {
|
|
5
|
+
if (str.endsWith("ies")) return `${str.slice(0, -3)}y`;
|
|
6
|
+
if (str.endsWith("ses")) return `${str.slice(0, -2)}`;
|
|
7
|
+
if (str.endsWith("s")) return str.slice(0, -1);
|
|
8
|
+
return str;
|
|
9
|
+
}
|
|
10
|
+
export function generateEntityEndpointKey(tableName, method) {
|
|
11
|
+
const upperName = toUpperSnakeCase(tableName);
|
|
12
|
+
const singularName = toUpperSnakeCase(singularize(tableName));
|
|
13
|
+
switch(method){
|
|
14
|
+
case "GET":
|
|
15
|
+
return `GET_${upperName}`;
|
|
16
|
+
case "POST":
|
|
17
|
+
return `ADD_${singularName}`;
|
|
18
|
+
case "PUT":
|
|
19
|
+
return `UPDATE_${singularName}`;
|
|
20
|
+
case "PATCH":
|
|
21
|
+
return `PATCH_${singularName}`;
|
|
22
|
+
case "DELETE":
|
|
23
|
+
return `DELETE_${singularName}`;
|
|
24
|
+
}
|
|
25
|
+
}
|
|
26
|
+
export function generateBulkEndpointKey(tableName, method) {
|
|
27
|
+
const upperName = toUpperSnakeCase(tableName);
|
|
28
|
+
switch(method){
|
|
29
|
+
case "POST":
|
|
30
|
+
return `BULK_ADD_${upperName}`;
|
|
31
|
+
case "PUT":
|
|
32
|
+
return `BULK_UPDATE_${upperName}`;
|
|
33
|
+
case "DELETE":
|
|
34
|
+
return `BULK_DELETE_${upperName}`;
|
|
35
|
+
}
|
|
36
|
+
}
|
|
37
|
+
export function generateGetByIdEndpointKey(tableName) {
|
|
38
|
+
const singularName = toUpperSnakeCase(singularize(tableName));
|
|
39
|
+
return `GET_${singularName}_BY_ID`;
|
|
40
|
+
}
|
|
41
|
+
export function generateDistinctEndpointKey(tableName) {
|
|
42
|
+
const upperName = toUpperSnakeCase(tableName);
|
|
43
|
+
return `GET_${upperName}_DISTINCT`;
|
|
44
|
+
}
|