@airoom/nextmin-react 1.4.6 → 2.0.2
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/README.md +29 -3
- package/dist/auth/SignInForm.js +4 -2
- package/dist/components/AdminApp.js +15 -38
- package/dist/components/ArchitectureDemo.d.ts +1 -0
- package/dist/components/ArchitectureDemo.js +45 -0
- package/dist/components/PhoneInput.d.ts +3 -0
- package/dist/components/PhoneInput.js +23 -19
- package/dist/components/RefSelect.d.ts +16 -0
- package/dist/components/RefSelect.js +225 -0
- package/dist/components/SchemaForm.js +125 -50
- package/dist/components/Sidebar.js +6 -13
- package/dist/components/TableFilters.js +2 -0
- package/dist/components/editor/TiptapEditor.js +4 -2
- package/dist/components/editor/Toolbar.js +21 -2
- package/dist/components/editor/components/DistrictGridModal.js +2 -3
- package/dist/components/editor/components/SchemaInsertionModal.js +2 -2
- package/dist/components/viewer/DynamicViewer.js +70 -9
- package/dist/hooks/useRealtime.d.ts +8 -0
- package/dist/hooks/useRealtime.js +30 -0
- package/dist/index.d.ts +6 -0
- package/dist/index.js +6 -0
- package/dist/lib/AuthClient.d.ts +15 -0
- package/dist/lib/AuthClient.js +63 -0
- package/dist/lib/QueryBuilder.d.ts +29 -0
- package/dist/lib/QueryBuilder.js +74 -0
- package/dist/lib/RealtimeClient.d.ts +16 -0
- package/dist/lib/RealtimeClient.js +56 -0
- package/dist/lib/api.d.ts +15 -3
- package/dist/lib/api.js +71 -58
- package/dist/lib/auth.js +7 -2
- package/dist/lib/types.d.ts +16 -0
- package/dist/nextmin.css +1 -1
- package/dist/providers/NextMinProvider.d.ts +8 -1
- package/dist/providers/NextMinProvider.js +40 -8
- package/dist/router/NextMinRouter.d.ts +1 -1
- package/dist/router/NextMinRouter.js +1 -1
- package/dist/state/schemasSlice.js +4 -27
- package/dist/views/DashboardPage.js +56 -42
- package/dist/views/ListPage.js +34 -4
- package/dist/views/SettingsEdit.js +25 -2
- package/dist/views/list/DataTableHero.js +103 -46
- package/dist/views/list/ListHeader.d.ts +3 -1
- package/dist/views/list/ListHeader.js +2 -2
- package/dist/views/list/jsonSummary.d.ts +3 -3
- package/dist/views/list/jsonSummary.js +47 -20
- package/dist/views/list/useListData.js +5 -1
- package/package.json +9 -4
- package/dist/components/RefMultiSelect.d.ts +0 -22
- package/dist/components/RefMultiSelect.js +0 -113
- package/dist/components/RefSingleSelect.d.ts +0 -17
- package/dist/components/RefSingleSelect.js +0 -110
- package/dist/lib/schemaService.d.ts +0 -2
- package/dist/lib/schemaService.js +0 -39
- package/dist/state/schemaLive.d.ts +0 -2
- package/dist/state/schemaLive.js +0 -19
- /package/dist/{editor.css → components/editor/editor.css} +0 -0
package/dist/lib/auth.js
CHANGED
|
@@ -16,6 +16,9 @@ function normalizeRole(value) {
|
|
|
16
16
|
if (typeof value === 'object' && typeof value.name === 'string') {
|
|
17
17
|
return String(value.name).toLowerCase();
|
|
18
18
|
}
|
|
19
|
+
if (typeof value === 'number') {
|
|
20
|
+
return String(value);
|
|
21
|
+
}
|
|
19
22
|
}
|
|
20
23
|
catch { }
|
|
21
24
|
return null;
|
|
@@ -30,8 +33,10 @@ export async function login({ email, password }) {
|
|
|
30
33
|
throw new Error(res?.message || 'Login failed');
|
|
31
34
|
}
|
|
32
35
|
// Enforce admin-only access here (superadmin/admin)
|
|
33
|
-
const
|
|
34
|
-
|
|
36
|
+
const roleName = String(user?.roleName || '').toLowerCase();
|
|
37
|
+
const normalized = normalizeRole(user?.role);
|
|
38
|
+
const isAdmin = roleName === 'admin' || roleName === 'superadmin' || normalized === 'admin' || normalized === 'superadmin';
|
|
39
|
+
if (!isAdmin) {
|
|
35
40
|
throw new Error('You are not authorized to access the admin panel');
|
|
36
41
|
}
|
|
37
42
|
return { token, user };
|
package/dist/lib/types.d.ts
CHANGED
|
@@ -7,9 +7,23 @@ export type AttributeBase = {
|
|
|
7
7
|
longtext?: boolean;
|
|
8
8
|
show?: string;
|
|
9
9
|
populateSlugFrom?: string;
|
|
10
|
+
minLength?: number;
|
|
11
|
+
maxLength?: number;
|
|
12
|
+
pattern?: string;
|
|
13
|
+
mask?: string;
|
|
14
|
+
inherited?: boolean;
|
|
10
15
|
};
|
|
11
16
|
export type ArrayAttribute = AttributeBase[];
|
|
12
17
|
export type Attribute = AttributeBase | ArrayAttribute;
|
|
18
|
+
export type CustomAction = {
|
|
19
|
+
label: string;
|
|
20
|
+
href: string;
|
|
21
|
+
icon?: string;
|
|
22
|
+
variant?: 'light' | 'flat' | 'solid' | 'bordered';
|
|
23
|
+
color?: 'default' | 'primary' | 'secondary' | 'success' | 'warning' | 'danger';
|
|
24
|
+
relatedModel?: string;
|
|
25
|
+
relatedField?: string;
|
|
26
|
+
};
|
|
13
27
|
export type SchemaDef = {
|
|
14
28
|
modelName: string;
|
|
15
29
|
attributes: Record<string, Attribute>;
|
|
@@ -19,6 +33,8 @@ export type SchemaDef = {
|
|
|
19
33
|
update?: boolean;
|
|
20
34
|
delete?: boolean;
|
|
21
35
|
};
|
|
36
|
+
extends?: string;
|
|
37
|
+
actions?: CustomAction[];
|
|
22
38
|
};
|
|
23
39
|
export type SchemasResponse = {
|
|
24
40
|
success: true;
|