@ortha/admin-identity 0.0.0 → 0.0.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.
Files changed (3) hide show
  1. package/README.md +127 -0
  2. package/package.json +53 -3
  3. package/index.js +0 -0
package/README.md ADDED
@@ -0,0 +1,127 @@
1
+ # @ortha/admin-identity
2
+
3
+ Authentication UI plugin for the Ortha admin application — provides login, signup, and invite code verification pages. All auth routes are public (guest-only) and redirect authenticated users to the home page.
4
+
5
+ ## Installation
6
+
7
+ Internal monorepo dependency — import directly:
8
+
9
+ ```ts
10
+ import { identityPlugin } from '@ortha/admin-identity';
11
+ import type { CurrentUser, Role, Permission } from '@ortha/admin-identity';
12
+ ```
13
+
14
+ ## Usage
15
+
16
+ ### Registering the plugin
17
+
18
+ ```ts
19
+ import { bootstrap } from '@ortha/admin-platform-bootstrap';
20
+ import { identityPlugin } from '@ortha/admin-identity';
21
+
22
+ bootstrap(document.getElementById('root')!, [
23
+ identityPlugin()
24
+ // ...other plugins
25
+ ]);
26
+ ```
27
+
28
+ ### Using API hooks
29
+
30
+ ```ts
31
+ import { useLogin, useCurrentUser, useRoles } from '@ortha/admin-identity';
32
+
33
+ const LoginComponent = () => {
34
+ const login = useLogin();
35
+
36
+ const handleSubmit = (data: { email: string; password: string }) => {
37
+ login.mutate(data);
38
+ };
39
+ };
40
+
41
+ const ProfileComponent = () => {
42
+ const { data: user } = useCurrentUser();
43
+ const { data: roles } = useRoles();
44
+ };
45
+ ```
46
+
47
+ ## Routes
48
+
49
+ | Path | Page | Auth Required |
50
+ | -------------- | -------------------------- | ------------- |
51
+ | `/auth` | Auth layout wrapper | No |
52
+ | `/auth/login` | Login form | No |
53
+ | `/auth/signup` | Signup form (invite-gated) | No |
54
+ | `/auth/invite` | Invite code verification | No |
55
+
56
+ ## API Reference
57
+
58
+ ### Plugin
59
+
60
+ | Export | Kind | Description |
61
+ | ------------------ | ------- | ------------------------------------ |
62
+ | `identityPlugin()` | factory | Admin plugin — registers auth routes |
63
+
64
+ ### Hooks
65
+
66
+ | Export | Kind | Description |
67
+ | ----------------- | ---- | --------------------------------------------- |
68
+ | `useLogin` | hook | Login mutation (`POST /api/identity/login`) |
69
+ | `useSignup` | hook | Signup mutation (`POST /api/identity/signup`) |
70
+ | `useInviteVerify` | hook | Invite verify mutation |
71
+ | `useInviteCreate` | hook | Invite create mutation |
72
+ | `useRefresh` | hook | Token refresh mutation |
73
+ | `useCurrentUser` | hook | Current user query (`GET /api/identity/me`) |
74
+ | `useRoles` | hook | Roles query (`GET /api/identity/roles`) |
75
+ | `currentUserKey` | fn | Query key factory for current user cache |
76
+ | `rolesKey` | fn | Query key factory for roles cache |
77
+
78
+ ### Types
79
+
80
+ | Export | Kind | Description |
81
+ | ----------------- | ---- | ------------------------------------ |
82
+ | `CurrentUser` | type | Current user entity |
83
+ | `CurrentUserRole` | type | Current user's role with permissions |
84
+ | `Permission` | type | Permission (action + resource) |
85
+ | `Role` | type | Role entity |
86
+
87
+ ## Internal Structure
88
+
89
+ ```
90
+ src/lib/
91
+ ├── identityPlugin/index.ts # Plugin factory with route registration
92
+ ├── types/index.ts # Shared entity types (CurrentUser, Role, etc.)
93
+ ├── api/
94
+ │ ├── useLogin/index.ts # LoginBody + login() + useLogin mutation
95
+ │ ├── useSignup/index.ts # SignupBody + signup() + useSignup mutation
96
+ │ ├── useInviteVerify/index.ts # InviteVerifyBody + useInviteVerify mutation
97
+ │ ├── useInviteCreate/index.ts # InviteCreateBody + useInviteCreate mutation
98
+ │ ├── useRefresh/index.ts # refresh() + useRefresh mutation
99
+ │ ├── useCurrentUser/index.ts # currentUserKey + useCurrentUser query
100
+ │ └── useRoles/index.ts # rolesKey + useRoles query
101
+ └── pages/
102
+ ├── LoginPage/index.tsx
103
+ ├── SignUpPage/index.tsx
104
+ └── InviteCodePage/index.tsx
105
+ ```
106
+
107
+ ## Key Patterns
108
+
109
+ - Auth pages use `react-hook-form` with `ajvResolver` from `@ortha/admin-utils`.
110
+ - API hooks use TanStack React Query and `httpClient` from `@ortha/admin-platform-core`.
111
+ - Request/response types specific to one hook are co-located inside that hook's file.
112
+ - Shared entity types live in `types/index.ts`.
113
+ - Error handling uses `handleMutationError` from `@ortha/admin-utils`.
114
+ - This plugin has no dependencies on other feature plugins — it is foundational.
115
+
116
+ ## Dependencies
117
+
118
+ - `@ortha/admin-platform-core` — `httpClient`, auth store
119
+ - `@ortha/admin-platform-plugin-registry` — plugin types
120
+ - `@ortha/admin-utils` — `ajvResolver`, `handleMutationError`
121
+ - `@ortha/design-system` — theme and UI components
122
+
123
+ ## Building
124
+
125
+ ```bash
126
+ nx build admin-identity
127
+ ```
package/package.json CHANGED
@@ -1,5 +1,55 @@
1
1
  {
2
2
  "name": "@ortha/admin-identity",
3
- "version": "0.0.0",
4
- "description": "Reserved package placeholder"
5
- }
3
+ "version": "0.0.3",
4
+ "license": "MIT",
5
+ "type": "module",
6
+ "main": "./dist/index.js",
7
+ "module": "./dist/index.js",
8
+ "types": "./dist/index.d.ts",
9
+ "exports": {
10
+ "./package.json": "./package.json",
11
+ ".": {
12
+ "@org/source": "./src/index.ts",
13
+ "types": "./dist/index.d.ts",
14
+ "import": "./dist/index.js",
15
+ "default": "./dist/index.js"
16
+ },
17
+ "./*": {
18
+ "@org/source": "./src/lib/*/index.ts",
19
+ "types": "./dist/lib/*/index.d.ts",
20
+ "import": "./dist/lib/*/index.js",
21
+ "default": "./dist/lib/*/index.js"
22
+ }
23
+ },
24
+ "files": [
25
+ "dist",
26
+ "!**/*.tsbuildinfo"
27
+ ],
28
+ "repository": {
29
+ "type": "git",
30
+ "url": "https://github.com/ortha-source/ortha.git",
31
+ "directory": "packages/identity/admin"
32
+ },
33
+ "publishConfig": {
34
+ "access": "public"
35
+ },
36
+ "dependencies": {
37
+ "@ortha/admin-platform-core": "0.0.1",
38
+ "@ortha/admin-platform-plugin-registry": "0.0.1",
39
+ "@ortha/design-system": "0.0.1",
40
+ "@ortha/admin-utils": "0.0.1"
41
+ },
42
+ "peerDependencies": {
43
+ "react": ">=18.0.0",
44
+ "react-dom": ">=18.0.0",
45
+ "react-router-dom": ">=6.0.0",
46
+ "react-hook-form": ">=7.0.0",
47
+ "react-intl": ">=6.0.0",
48
+ "@tanstack/react-query": ">=5.0.0",
49
+ "@mui/material": ">=7.0.0",
50
+ "@emotion/react": ">=11.0.0",
51
+ "@emotion/styled": ">=11.0.0",
52
+ "axios": ">=1.0.0"
53
+ },
54
+ "scripts": {}
55
+ }
package/index.js DELETED
File without changes