@colveor/admin 0.0.0-stage → 0.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/LICENSE.md +106 -0
- package/README.md +365 -2
- package/TAILWINDADMIN-LICENSE +21 -0
- package/dist/account/data.d.ts +1 -0
- package/dist/account/data.js +44 -0
- package/dist/account/profile.d.ts +6 -0
- package/dist/account/profile.js +118 -0
- package/dist/account/sessions.d.ts +1 -0
- package/dist/account/sessions.js +26 -0
- package/dist/account/shared.d.ts +26 -0
- package/dist/account/shared.js +44 -0
- package/dist/account/two-factor.d.ts +5 -0
- package/dist/account/two-factor.js +60 -0
- package/dist/actions.d.ts +39 -0
- package/dist/actions.js +81 -0
- package/dist/api/audit.gen.d.ts +80 -0
- package/dist/api/audit.gen.js +43 -0
- package/dist/api/auth.gen.d.ts +537 -0
- package/dist/api/auth.gen.js +313 -0
- package/dist/api/errors.gen.d.ts +16 -0
- package/dist/api/errors.gen.js +2 -0
- package/dist/api/gormx.gen.d.ts +60 -0
- package/dist/api/gormx.gen.js +16 -0
- package/dist/api/health.gen.d.ts +103 -0
- package/dist/api/health.gen.js +23 -0
- package/dist/api/index.gen.d.ts +21 -0
- package/dist/api/index.gen.js +22 -0
- package/dist/api/invitations.gen.d.ts +128 -0
- package/dist/api/invitations.gen.js +57 -0
- package/dist/api/ledger.gen.d.ts +269 -0
- package/dist/api/ledger.gen.js +113 -0
- package/dist/api/msgtemplate.gen.d.ts +31 -0
- package/dist/api/msgtemplate.gen.js +2 -0
- package/dist/api/notifications.gen.d.ts +66 -0
- package/dist/api/notifications.gen.js +28 -0
- package/dist/api/outbox.gen.d.ts +8 -0
- package/dist/api/outbox.gen.js +2 -0
- package/dist/api/queue.gen.d.ts +112 -0
- package/dist/api/queue.gen.js +15 -0
- package/dist/api/rbac.gen.d.ts +406 -0
- package/dist/api/rbac.gen.js +191 -0
- package/dist/api/reauth.gen.d.ts +289 -0
- package/dist/api/reauth.gen.js +122 -0
- package/dist/api/recorded_payments.gen.d.ts +171 -0
- package/dist/api/recorded_payments.gen.js +79 -0
- package/dist/api/sessions.gen.d.ts +64 -0
- package/dist/api/sessions.gen.js +48 -0
- package/dist/api/settings.gen.d.ts +147 -0
- package/dist/api/settings.gen.js +69 -0
- package/dist/api/storage.gen.d.ts +327 -0
- package/dist/api/storage.gen.js +208 -0
- package/dist/api/support_access.gen.d.ts +155 -0
- package/dist/api/support_access.gen.js +131 -0
- package/dist/api/users.gen.d.ts +407 -0
- package/dist/api/users.gen.js +159 -0
- package/dist/api/verification.gen.d.ts +427 -0
- package/dist/api/verification.gen.js +280 -0
- package/dist/api/webhooks.gen.d.ts +110 -0
- package/dist/api/webhooks.gen.js +45 -0
- package/dist/auth-layout.d.ts +9 -0
- package/dist/auth-layout.js +5 -0
- package/dist/banner.d.ts +1 -0
- package/dist/banner.js +49 -0
- package/dist/client.d.ts +41 -0
- package/dist/client.js +72 -0
- package/dist/config.d.ts +27 -0
- package/dist/config.js +82 -0
- package/dist/dates.d.ts +4 -0
- package/dist/dates.js +16 -0
- package/dist/header.d.ts +12 -0
- package/dist/header.js +105 -0
- package/dist/icons.d.ts +2 -0
- package/dist/icons.js +15 -0
- package/dist/index.d.ts +28 -0
- package/dist/index.js +42 -0
- package/dist/kit/avatar.d.ts +5 -0
- package/dist/kit/avatar.js +16 -0
- package/dist/kit/badge.d.ts +10 -0
- package/dist/kit/badge.js +31 -0
- package/dist/kit/card.d.ts +12 -0
- package/dist/kit/card.js +7 -0
- package/dist/kit/code-area.d.ts +15 -0
- package/dist/kit/code-area.js +69 -0
- package/dist/kit/dropdown.d.ts +26 -0
- package/dist/kit/dropdown.js +67 -0
- package/dist/kit/filter-tabs.d.ts +9 -0
- package/dist/kit/filter-tabs.js +7 -0
- package/dist/kit/modal.d.ts +8 -0
- package/dist/kit/modal.js +15 -0
- package/dist/kit/page-header.d.ts +13 -0
- package/dist/kit/page-header.js +13 -0
- package/dist/kit/search.d.ts +4 -0
- package/dist/kit/search.js +16 -0
- package/dist/kit/tooltip.d.ts +17 -0
- package/dist/kit/tooltip.js +52 -0
- package/dist/message-editor.d.ts +9 -0
- package/dist/message-editor.js +80 -0
- package/dist/money.d.ts +10 -0
- package/dist/money.js +17 -0
- package/dist/next.d.ts +6 -0
- package/dist/next.js +19 -0
- package/dist/pages/account.d.ts +1 -0
- package/dist/pages/account.js +47 -0
- package/dist/pages/audit.d.ts +1 -0
- package/dist/pages/audit.js +88 -0
- package/dist/pages/forgot-password.d.ts +1 -0
- package/dist/pages/forgot-password.js +73 -0
- package/dist/pages/ledger.d.ts +1 -0
- package/dist/pages/ledger.js +132 -0
- package/dist/pages/roles.d.ts +1 -0
- package/dist/pages/roles.js +102 -0
- package/dist/pages/settings.d.ts +1 -0
- package/dist/pages/settings.js +86 -0
- package/dist/pages/sign-in.d.ts +5 -0
- package/dist/pages/sign-in.js +117 -0
- package/dist/pages/status.d.ts +1 -0
- package/dist/pages/status.js +122 -0
- package/dist/pages/support.d.ts +1 -0
- package/dist/pages/support.js +90 -0
- package/dist/pages/teams.d.ts +1 -0
- package/dist/pages/teams.js +94 -0
- package/dist/pages/users.d.ts +1 -0
- package/dist/pages/users.js +158 -0
- package/dist/pages/webhooks.d.ts +1 -0
- package/dist/pages/webhooks.js +88 -0
- package/dist/permissions.d.ts +5 -0
- package/dist/permissions.js +31 -0
- package/dist/proof.d.ts +10 -0
- package/dist/proof.js +78 -0
- package/dist/proxy.d.ts +10 -0
- package/dist/proxy.js +166 -0
- package/dist/retry.d.ts +8 -0
- package/dist/retry.js +30 -0
- package/dist/router.d.ts +13 -0
- package/dist/router.js +14 -0
- package/dist/setting-fields.d.ts +12 -0
- package/dist/setting-fields.js +102 -0
- package/dist/setting-list.d.ts +22 -0
- package/dist/setting-list.js +78 -0
- package/dist/shell.d.ts +40 -0
- package/dist/shell.js +97 -0
- package/dist/support.d.ts +37 -0
- package/dist/support.js +76 -0
- package/dist/table.d.ts +40 -0
- package/dist/table.js +73 -0
- package/dist/ui.d.ts +39 -0
- package/dist/ui.js +56 -0
- package/dist/user-actions.d.ts +30 -0
- package/dist/user-actions.js +129 -0
- package/dist/user-roles.d.ts +4 -0
- package/dist/user-roles.js +51 -0
- package/dist/user-row-menu.d.ts +14 -0
- package/dist/user-row-menu.js +45 -0
- package/dist/version.d.ts +1 -0
- package/dist/version.js +3 -0
- package/package.json +63 -4
package/LICENSE.md
ADDED
|
@@ -0,0 +1,106 @@
|
|
|
1
|
+
# Colveor Go — Proprietary Software License
|
|
2
|
+
|
|
3
|
+
**Copyright © 2026. All rights reserved.**
|
|
4
|
+
|
|
5
|
+
- **Software:** Colveor Go
|
|
6
|
+
- **License Type:** Proprietary
|
|
7
|
+
- **Usage:** Restricted — All rights reserved
|
|
8
|
+
|
|
9
|
+
---
|
|
10
|
+
|
|
11
|
+
## 1. Ownership and Intellectual Property
|
|
12
|
+
|
|
13
|
+
Colveor Go, including its source code, object code, architecture, algorithms, documentation, and associated materials, is proprietary software.
|
|
14
|
+
|
|
15
|
+
All rights, title, and interest in the software remain with the respective copyright owner, except for rights expressly granted in a separate written agreement.
|
|
16
|
+
|
|
17
|
+
No ownership, copyright, or intellectual property rights are transferred to any user, licensee, client, organization, or third party by accessing or using the software.
|
|
18
|
+
|
|
19
|
+
## 2. Limited Permission to Use
|
|
20
|
+
|
|
21
|
+
The copyright owner may grant specific individuals, organizations, or projects permission to access and use Colveor Go for authorized purposes.
|
|
22
|
+
|
|
23
|
+
Unless otherwise agreed in a separate written license, such permission is:
|
|
24
|
+
|
|
25
|
+
- **Limited** to the authorized purpose.
|
|
26
|
+
- **Non-exclusive**, meaning the copyright owner may authorize others.
|
|
27
|
+
- **Non-transferable**, meaning the recipient cannot transfer the permission to another party.
|
|
28
|
+
- **Revocable**, subject to applicable law and contractual obligations.
|
|
29
|
+
|
|
30
|
+
Access to the repository does not automatically grant permission to use the software for unrelated projects or purposes outside the authorized scope.
|
|
31
|
+
|
|
32
|
+
## 3. Restrictions
|
|
33
|
+
|
|
34
|
+
Unless expressly authorized in writing by the copyright owner, no recipient may:
|
|
35
|
+
|
|
36
|
+
- Redistribute, publish, sublicense, sell, rent, lease, or commercially exploit the software or substantial portions of it.
|
|
37
|
+
- Copy or incorporate the software into another product for distribution outside the authorized scope.
|
|
38
|
+
- Modify, adapt, reverse engineer, decompile, or disassemble the software, except to the extent such restrictions are prohibited by applicable law or expressly permitted in writing.
|
|
39
|
+
- Remove or alter copyright notices, ownership notices, or license terms.
|
|
40
|
+
- Claim authorship or ownership of the original software or its proprietary components.
|
|
41
|
+
- Share repository access, credentials, source code, or copies with unauthorized persons.
|
|
42
|
+
- Use protected confidential information or materials to create or distribute an unauthorized competing implementation.
|
|
43
|
+
|
|
44
|
+
## 4. Client Projects and Third-Party Access
|
|
45
|
+
|
|
46
|
+
Permission to access or use Colveor Go for one project does not automatically authorize its use in other projects.
|
|
47
|
+
|
|
48
|
+
Any client, contractor, organization, or third party must obtain the appropriate authorization before accessing or using the software.
|
|
49
|
+
|
|
50
|
+
A separate written agreement may specify:
|
|
51
|
+
|
|
52
|
+
- Permitted projects and users.
|
|
53
|
+
- Authorized deployment environments.
|
|
54
|
+
- Modification and distribution rights.
|
|
55
|
+
- Commercial usage terms.
|
|
56
|
+
- Ownership of customizations and derivative works.
|
|
57
|
+
|
|
58
|
+
The copyright owner retains ownership of Colveor Go unless a separate written agreement expressly states otherwise.
|
|
59
|
+
|
|
60
|
+
## 5. Contributions and Modifications
|
|
61
|
+
|
|
62
|
+
No contribution, modification, enhancement, or derivative work automatically transfers ownership of the original Colveor Go software.
|
|
63
|
+
|
|
64
|
+
Ownership of contributions and derivative works will be determined by applicable law and any relevant written agreements between the parties.
|
|
65
|
+
|
|
66
|
+
Recipients may not assume that permission to modify the software grants permission to distribute their modifications.
|
|
67
|
+
|
|
68
|
+
## 6. Confidentiality
|
|
69
|
+
|
|
70
|
+
Where the software or related materials are disclosed as confidential information under an applicable agreement or law, recipients must protect that information and must not disclose or use it beyond the authorized purpose.
|
|
71
|
+
|
|
72
|
+
This section does not independently make information confidential where it is not otherwise protected by applicable law or agreement.
|
|
73
|
+
|
|
74
|
+
## 7. Termination
|
|
75
|
+
|
|
76
|
+
Permission to use the software may be terminated in accordance with the applicable license agreement and law, including where a recipient materially breaches its terms.
|
|
77
|
+
|
|
78
|
+
Upon termination, the recipient must stop using the software and, where legally required or contractually agreed, return or securely delete unauthorized copies, subject to applicable legal retention obligations.
|
|
79
|
+
|
|
80
|
+
Termination does not extinguish rights or obligations that accrued before termination or provisions that are intended to survive termination.
|
|
81
|
+
|
|
82
|
+
## 8. Disclaimer of Warranty
|
|
83
|
+
|
|
84
|
+
To the maximum extent permitted by applicable law, the software is provided **"AS IS"** and **"AS AVAILABLE,"** without warranties of any kind, whether express or implied, including warranties of merchantability, fitness for a particular purpose, and non-infringement.
|
|
85
|
+
|
|
86
|
+
## 9. Limitation of Liability
|
|
87
|
+
|
|
88
|
+
To the maximum extent permitted by applicable law, the copyright owner shall not be liable for indirect, incidental, special, consequential, or punitive damages arising from the use of or inability to use the software.
|
|
89
|
+
|
|
90
|
+
Nothing in this license excludes or limits liability that cannot lawfully be excluded or limited.
|
|
91
|
+
|
|
92
|
+
## 10. Reservation of Rights
|
|
93
|
+
|
|
94
|
+
All rights not expressly granted in writing are reserved by the copyright owner.
|
|
95
|
+
|
|
96
|
+
Nothing in this license grants a patent license, trademark license, or other intellectual property license except as expressly stated.
|
|
97
|
+
|
|
98
|
+
## 11. Governing Law
|
|
99
|
+
|
|
100
|
+
The governing law and dispute-resolution arrangements shall be those specified in a separately executed written agreement. In the absence of such an agreement, applicable law will determine the governing law and competent forum.
|
|
101
|
+
|
|
102
|
+
---
|
|
103
|
+
|
|
104
|
+
## All Rights Reserved
|
|
105
|
+
|
|
106
|
+
Unauthorized use, copying, modification, or distribution may violate applicable intellectual property laws and contractual obligations.
|
package/README.md
CHANGED
|
@@ -1,3 +1,366 @@
|
|
|
1
|
-
#
|
|
1
|
+
# @colveor/admin
|
|
2
2
|
|
|
3
|
-
|
|
3
|
+
The admin panel for APIs built on **colveor-go**: its pages, its API
|
|
4
|
+
client and the building blocks to make your own pages look and work the
|
|
5
|
+
same.
|
|
6
|
+
|
|
7
|
+
Start a panel with
|
|
8
|
+
[`@colveor/create-admin`](https://www.npmjs.com/package/@colveor/create-admin),
|
|
9
|
+
which sets all of this up:
|
|
10
|
+
|
|
11
|
+
```sh
|
|
12
|
+
npm create @colveor/admin@latest my-admin
|
|
13
|
+
```
|
|
14
|
+
|
|
15
|
+
This README is the reference for what the package gives you once you have
|
|
16
|
+
a panel.
|
|
17
|
+
|
|
18
|
+
- [Pages](#pages)
|
|
19
|
+
- [How it fits together](#how-it-fits-together)
|
|
20
|
+
- [Building your own pages](#building-your-own-pages)
|
|
21
|
+
- [Talking to the API](#talking-to-the-api)
|
|
22
|
+
- [Building blocks](#building-blocks)
|
|
23
|
+
- [Versions](#versions)
|
|
24
|
+
- [Using it without the template](#using-it-without-the-template)
|
|
25
|
+
|
|
26
|
+
## Pages
|
|
27
|
+
|
|
28
|
+
Each page is shown only to admins holding its permission, and hidden when
|
|
29
|
+
its API module is off.
|
|
30
|
+
|
|
31
|
+
| Page | Import | Permission |
|
|
32
|
+
| ---------------------------------------------------------- | -------------------------------------- | -------------------------------------------------------------------------- |
|
|
33
|
+
| Sign in (password or emailed code, then two-step) | `@colveor/admin/pages/sign-in` | none |
|
|
34
|
+
| Forgot password | `@colveor/admin/pages/forgot-password` | none |
|
|
35
|
+
| My account (profile, password, two-step, devices, my data) | `@colveor/admin/pages/account` | signed in |
|
|
36
|
+
| Users | `@colveor/admin/pages/users` | `users.read` |
|
|
37
|
+
| Roles | `@colveor/admin/pages/roles` | `rbac.read` |
|
|
38
|
+
| Teams | `@colveor/admin/pages/teams` | `teams.suspend` |
|
|
39
|
+
| Support access | `@colveor/admin/pages/support` | `support.request` or `support.read` |
|
|
40
|
+
| Settings | `@colveor/admin/pages/settings` | `settings.read` |
|
|
41
|
+
| Audit log | `@colveor/admin/pages/audit` | `audit.read` |
|
|
42
|
+
| Webhook events | `@colveor/admin/pages/webhooks` | `webhooks.read` |
|
|
43
|
+
| System status | `@colveor/admin/pages/status` | `health.read` |
|
|
44
|
+
| Ledger | `@colveor/admin/pages/ledger` | `ledger.approve`, `ledger.manage` or `ledger.adjust` (each shows its part) |
|
|
45
|
+
|
|
46
|
+
A panel mounts a page with one line, so updating the package updates the
|
|
47
|
+
page:
|
|
48
|
+
|
|
49
|
+
```ts
|
|
50
|
+
// app/(admin)/(colveor)/users/page.tsx
|
|
51
|
+
export { default } from "@colveor/admin/pages/users";
|
|
52
|
+
```
|
|
53
|
+
|
|
54
|
+
Changes ask for what the API asks: a reason for the audit log on every
|
|
55
|
+
admin change, and "confirm it's you" before sensitive ones (a secret
|
|
56
|
+
setting, resetting someone's two-step verification).
|
|
57
|
+
|
|
58
|
+
## How it fits together
|
|
59
|
+
|
|
60
|
+
```
|
|
61
|
+
browser ──► the panel's Next server ──► the colveor-go API
|
|
62
|
+
/api/colveor/<path> <path>
|
|
63
|
+
(the proxy: tokens in httpOnly cookies)
|
|
64
|
+
```
|
|
65
|
+
|
|
66
|
+
| Export | What it is |
|
|
67
|
+
| ------------------------ | ------------------------------------------------------------------------------------------------------------------------------------- |
|
|
68
|
+
| `@colveor/admin` | The building blocks, the API client and the API's types. |
|
|
69
|
+
| `@colveor/admin/next` | `<NextAdmin>`: the shell with Next's router. The only file that imports Next. |
|
|
70
|
+
| `@colveor/admin/proxy` | The proxy route handler (plain web `Request` and `Response`). |
|
|
71
|
+
| `@colveor/admin/banner` | `printBanner()`: the COLVEOR ADMIN banner at server start, with the API it talks to (the template's `instrumentation.ts`). Node only. |
|
|
72
|
+
| `@colveor/admin/pages/*` | The pages above. |
|
|
73
|
+
|
|
74
|
+
The pages and building blocks are plain React 19. Only
|
|
75
|
+
`@colveor/admin/next` depends on Next (16 or later), so another React setup
|
|
76
|
+
needs only a router adapter (`<ColveorAdmin router={...}>`).
|
|
77
|
+
|
|
78
|
+
**The shell** wraps every page (the template's `app/providers.tsx`):
|
|
79
|
+
|
|
80
|
+
```tsx
|
|
81
|
+
"use client";
|
|
82
|
+
import { NextAdmin } from "@colveor/admin/next";
|
|
83
|
+
import config from "../admin.config";
|
|
84
|
+
|
|
85
|
+
export default function Providers({ children }) {
|
|
86
|
+
return <NextAdmin config={config}>{children}</NextAdmin>;
|
|
87
|
+
}
|
|
88
|
+
```
|
|
89
|
+
|
|
90
|
+
It loads the signed-in admin's roles and permissions before showing a
|
|
91
|
+
page, sends a signed-out admin to the sign-in page (with `?next=` back),
|
|
92
|
+
and loads the permissions again on each page, so a role change shows at
|
|
93
|
+
once.
|
|
94
|
+
|
|
95
|
+
**`admin.config.ts`**:
|
|
96
|
+
|
|
97
|
+
```ts
|
|
98
|
+
import { defineConfig } from "@colveor/admin";
|
|
99
|
+
|
|
100
|
+
export default defineConfig({
|
|
101
|
+
name: "Acme Admin", // the menu and the browser tab
|
|
102
|
+
logo: "/logo.svg", // optional, above the menu
|
|
103
|
+
signInPath: "/login", // optional, the default
|
|
104
|
+
nav: [ // your items, after the framework's
|
|
105
|
+
{
|
|
106
|
+
label: "Invoices",
|
|
107
|
+
href: "/invoices",
|
|
108
|
+
permission: "invoices.read", // or a list: any one of them
|
|
109
|
+
group: "Sales", // the menu heading it goes under
|
|
110
|
+
icon: <InvoiceIcon />, // optional
|
|
111
|
+
},
|
|
112
|
+
],
|
|
113
|
+
});
|
|
114
|
+
```
|
|
115
|
+
|
|
116
|
+
## Building your own pages
|
|
117
|
+
|
|
118
|
+
A page in `app/(admin)/(project)/` is a normal Next page. Build it from
|
|
119
|
+
the package's pieces and it matches ours: the same header, cards, tables,
|
|
120
|
+
dialogs, dates and permission checks.
|
|
121
|
+
|
|
122
|
+
```tsx
|
|
123
|
+
"use client";
|
|
124
|
+
|
|
125
|
+
import {
|
|
126
|
+
Badge,
|
|
127
|
+
DataTable,
|
|
128
|
+
PageHeader,
|
|
129
|
+
RequirePermission,
|
|
130
|
+
RowMenu,
|
|
131
|
+
api,
|
|
132
|
+
formatDate,
|
|
133
|
+
useAction,
|
|
134
|
+
} from "@colveor/admin";
|
|
135
|
+
import { useState } from "react";
|
|
136
|
+
|
|
137
|
+
type Invoice = { id: string; number: string; status: string; created_at: string };
|
|
138
|
+
|
|
139
|
+
export default function InvoicesPage() {
|
|
140
|
+
const { run, dialogs } = useAction();
|
|
141
|
+
const [reload, setReload] = useState(0);
|
|
142
|
+
|
|
143
|
+
const cancel = (i: Invoice) =>
|
|
144
|
+
run((o) => api.post(`/v1/invoices/${i.id}/cancel`, undefined, o)).then(() =>
|
|
145
|
+
setReload((n) => n + 1),
|
|
146
|
+
);
|
|
147
|
+
|
|
148
|
+
return (
|
|
149
|
+
<RequirePermission keys={["invoices.read"]}>
|
|
150
|
+
<PageHeader title="Invoices" crumbs={[{ label: "Sales" }]} />
|
|
151
|
+
<DataTable<Invoice>
|
|
152
|
+
title="Invoices"
|
|
153
|
+
path="/v1/invoices"
|
|
154
|
+
reload={reload}
|
|
155
|
+
download="invoices"
|
|
156
|
+
columns={[
|
|
157
|
+
{ header: "Number", cell: (i) => i.number },
|
|
158
|
+
{ header: "Status", cell: (i) => <Badge tone="green">{i.status}</Badge> },
|
|
159
|
+
{ header: "Date", sortKey: "created_at", cell: (i) => formatDate(i.created_at) },
|
|
160
|
+
{
|
|
161
|
+
header: "",
|
|
162
|
+
cell: (i) => (
|
|
163
|
+
<RowMenu items={[{ label: "Cancel", danger: true, onSelect: () => cancel(i) }]} />
|
|
164
|
+
),
|
|
165
|
+
},
|
|
166
|
+
]}
|
|
167
|
+
/>
|
|
168
|
+
{dialogs}
|
|
169
|
+
</RequirePermission>
|
|
170
|
+
);
|
|
171
|
+
}
|
|
172
|
+
```
|
|
173
|
+
|
|
174
|
+
Then add it to `nav` in `admin.config.ts`.
|
|
175
|
+
|
|
176
|
+
A file that uses React hooks must start with `"use client"`.
|
|
177
|
+
|
|
178
|
+
## Talking to the API
|
|
179
|
+
|
|
180
|
+
The browser never calls the API directly: the page calls
|
|
181
|
+
`/api/colveor/<API path>` on the panel's own server, and the proxy forwards
|
|
182
|
+
it to `COLVEOR_API_URL`.
|
|
183
|
+
|
|
184
|
+
```ts
|
|
185
|
+
// app/api/colveor/[...path]/route.ts
|
|
186
|
+
export {
|
|
187
|
+
handler as DELETE,
|
|
188
|
+
handler as GET,
|
|
189
|
+
handler as PATCH,
|
|
190
|
+
handler as POST,
|
|
191
|
+
handler as PUT,
|
|
192
|
+
} from "@colveor/admin/proxy";
|
|
193
|
+
```
|
|
194
|
+
|
|
195
|
+
- **Tokens never reach the page.** The proxy moves them from the API's
|
|
196
|
+
responses into `httpOnly`, `SameSite=Lax` cookies (`Secure` over HTTPS).
|
|
197
|
+
Nothing is kept in `localStorage`, and the API needs no CORS setup.
|
|
198
|
+
- **Refreshing is automatic.** An expired access token is refreshed and
|
|
199
|
+
the call retried; calls that arrive together share one refresh. A refresh
|
|
200
|
+
that fails signs the admin out.
|
|
201
|
+
- **Run one panel server** (or route a session to the same one): the shared
|
|
202
|
+
refresh is kept in the server's memory, and a refresh token works only
|
|
203
|
+
once.
|
|
204
|
+
- **Trust the panel server on the API:** add its address to the API's
|
|
205
|
+
`SERVER_TRUSTED_PROXIES`, so rate limits, sessions and the audit log see
|
|
206
|
+
each admin's own IP.
|
|
207
|
+
- `createProxy({ apiUrl, prefix })` makes a handler with other settings
|
|
208
|
+
(default: `COLVEOR_API_URL` and `/api/colveor`).
|
|
209
|
+
|
|
210
|
+
### The client
|
|
211
|
+
|
|
212
|
+
```ts
|
|
213
|
+
import { ApiError, api, gormx, rbac } from "@colveor/admin";
|
|
214
|
+
|
|
215
|
+
const roles = await api.get<rbac.RoleResponse[]>("/v1/rbac/roles");
|
|
216
|
+
const page = await api.get<gormx.Page<rbac.RoleMemberResponse>>(`/v1/rbac/roles/${id}/users`, {
|
|
217
|
+
limit: 50,
|
|
218
|
+
});
|
|
219
|
+
|
|
220
|
+
try {
|
|
221
|
+
await api.patch(`/v1/settings/${key}`, { value }, { reason: "Raise the limit for the launch" });
|
|
222
|
+
} catch (err) {
|
|
223
|
+
if (err instanceof ApiError && err.code === "settings.invalid_value") {
|
|
224
|
+
// err.status, err.code, err.message, err.data
|
|
225
|
+
}
|
|
226
|
+
}
|
|
227
|
+
```
|
|
228
|
+
|
|
229
|
+
`api.get(path, query)`, `api.post` / `put` / `patch(path, body, options)`
|
|
230
|
+
and `api.delete(path, options)`. `options`: `reason` (`X-Reason`),
|
|
231
|
+
`reauthToken` (`X-Reauth-Token`) and `idempotencyKey` (`Idempotency-Key`).
|
|
232
|
+
`signOut()` signs the admin out.
|
|
233
|
+
|
|
234
|
+
### The API's types
|
|
235
|
+
|
|
236
|
+
Generated from colveor-go's Go contracts, one namespace per module: the
|
|
237
|
+
request and response shapes, error codes and permission keys.
|
|
238
|
+
|
|
239
|
+
```ts
|
|
240
|
+
import { rbac, settings, users } from "@colveor/admin";
|
|
241
|
+
|
|
242
|
+
const user: users.UserResponse = await api.get(`/v1/users/${id}`);
|
|
243
|
+
if (useCan(rbac.PermissionManage)) {
|
|
244
|
+
/* ... */
|
|
245
|
+
}
|
|
246
|
+
if (err.code === users.ErrCodeNotFound) {
|
|
247
|
+
/* ... */
|
|
248
|
+
}
|
|
249
|
+
```
|
|
250
|
+
|
|
251
|
+
A field the API may leave out is optional (`next_page?: string`): check it
|
|
252
|
+
with `== null`. Lists use the standard page, `gormx.Page<T>`: `items`,
|
|
253
|
+
`next_page`, `previous_page`, `total`.
|
|
254
|
+
|
|
255
|
+
### Changes that need a reason or "confirm it's you"
|
|
256
|
+
|
|
257
|
+
```tsx
|
|
258
|
+
const { run, dialogs } = useAction();
|
|
259
|
+
|
|
260
|
+
const suspend = () => run((o) => api.post(`/v1/users/${id}/suspend`, undefined, o));
|
|
261
|
+
|
|
262
|
+
return <>{button}{dialogs}</>;
|
|
263
|
+
```
|
|
264
|
+
|
|
265
|
+
`run` sends the change. When the API asks for a reason, it shows a reason
|
|
266
|
+
dialog; when it asks the admin to confirm it's them, it shows the
|
|
267
|
+
re-authentication dialog (password, authenticator code, emailed code, PIN
|
|
268
|
+
or recovery code). Then it sends again, with a new idempotency key each
|
|
269
|
+
time. If the admin closes a dialog, `run` rejects with `Cancelled`:
|
|
270
|
+
|
|
271
|
+
```ts
|
|
272
|
+
try {
|
|
273
|
+
await run(send);
|
|
274
|
+
} catch (err) {
|
|
275
|
+
if (!(err instanceof Cancelled)) setError(err.message);
|
|
276
|
+
}
|
|
277
|
+
```
|
|
278
|
+
|
|
279
|
+
## Building blocks
|
|
280
|
+
|
|
281
|
+
**Page layout**
|
|
282
|
+
|
|
283
|
+
| Block | Use |
|
|
284
|
+
| --------------------------------------- | -------------------------------------------------------------------------- |
|
|
285
|
+
| `<PageHeader title crumbs actions>` | The top of every page: its title and breadcrumb (Home • Sales • Invoices). |
|
|
286
|
+
| `<Card title about info actions flush>` | A box with a title, a "?" (`info`) and icon buttons on the right. |
|
|
287
|
+
| `<Modal title onClose footer size>` | A dialog; Escape closes it. `size="xl"` for an editor with a preview. |
|
|
288
|
+
| `<FilterTabs tabs value onChange>` | Segmented tabs that pick what a list shows. |
|
|
289
|
+
|
|
290
|
+
**Lists**
|
|
291
|
+
|
|
292
|
+
| Block | Use |
|
|
293
|
+
| --------------------------------------------- | ----------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------- |
|
|
294
|
+
| `<DataTable path columns query limit reload>` | One list endpoint, a page at a time, with the total. Also `title` (in a card), `actions`, `toolbar`, `download` (CSV of the page shown), `onRowClick`, `transform` (join another endpoint's data, one call per page) and a column's `sortKey` (the API sorts the whole list). |
|
|
295
|
+
| `<RowMenu items>` | A row's "…" menu; its clicks don't open the row. |
|
|
296
|
+
| `<SearchToggle placeholder onSearch>` | A search icon that opens into a box, for a card's header. |
|
|
297
|
+
|
|
298
|
+
**Small pieces**
|
|
299
|
+
|
|
300
|
+
| Block | Use |
|
|
301
|
+
| ------------------------------------------- | ----------------------------------------------------------------------------------------------------------------------------------------------------------------- |
|
|
302
|
+
| `<Badge tone>` | A coloured pill: `brand`, `green`, `amber`, `red`, `purple`, `sky`, `gray`. `roleTone(slug)` gives a role the same colour everywhere; `humanize(slug)` its label. |
|
|
303
|
+
| `<Avatar name url className>` | A photo, or initials. |
|
|
304
|
+
| `<Tooltip tip label>`, `<InfoTip>` | A tip shown on click; `InfoTip` is the "?" in a circle. |
|
|
305
|
+
| `<CodeArea value onChange lang singleLine>` | A text box that colours HTML and Go template actions (`{{.Code}}`). |
|
|
306
|
+
| `<CodeInput value onChange onComplete>` | A one-time code, one box per digit. |
|
|
307
|
+
| `<Dropdown>`, `iconButton` | The header's menus and round icon buttons. |
|
|
308
|
+
| `formatDate(v)`, `formatDateTime(v)` | Every date as "1 Dec, 2026" (and "1 Dec, 2026, 14:05"). |
|
|
309
|
+
|
|
310
|
+
**Permissions and the shell**
|
|
311
|
+
|
|
312
|
+
| Block | Use |
|
|
313
|
+
| -------------------------------------------- | ---------------------------------------------------------------- |
|
|
314
|
+
| `<RequirePermission keys fallback>` | Shows its children only to admins holding every key. |
|
|
315
|
+
| `useCan(...keys)` | The same, as a boolean. |
|
|
316
|
+
| `useAdmin()` | The config, the router, the admin's roles and permissions. |
|
|
317
|
+
| `useNav()` | The menu this admin may open: the framework's items, then yours. |
|
|
318
|
+
| `NavSearch`, `NotificationsMenu`, `UserMenu` | The header's search, notifications and account menu. |
|
|
319
|
+
|
|
320
|
+
**Users** (for your own user screens)
|
|
321
|
+
|
|
322
|
+
| Block | Use |
|
|
323
|
+
| ----------------------------------------------------------------- | ------------------------------------------------------------------------------------------------------------------- |
|
|
324
|
+
| `useUserActions(user, onChange)` | The admin's actions on a user (suspend, sign out everywhere, reset two-step, unlock PINs), each for its permission. |
|
|
325
|
+
| `<UserActions>`, `<UserRoles>`, `<UserSessions>`, `<UserRowMenu>` | The user page's parts. |
|
|
326
|
+
| `<TeamSupportGrants team>` | A team's support access grants, for your own team screens. |
|
|
327
|
+
|
|
328
|
+
### Styling
|
|
329
|
+
|
|
330
|
+
The package's components use Tailwind classes and the theme's `brand-*`
|
|
331
|
+
colours, so the panel's Tailwind must scan the package. The template's
|
|
332
|
+
`app/globals.css` does it:
|
|
333
|
+
|
|
334
|
+
```css
|
|
335
|
+
@import "tailwindcss";
|
|
336
|
+
@source "../node_modules/@colveor/admin/dist";
|
|
337
|
+
```
|
|
338
|
+
|
|
339
|
+
The animations (`animate-fade-in`, `animate-pop-in`, `animate-slide-down`,
|
|
340
|
+
`animate-slide-in`) are defined there too, and turn off for admins who ask
|
|
341
|
+
for reduced motion.
|
|
342
|
+
|
|
343
|
+
## Versions
|
|
344
|
+
|
|
345
|
+
`@colveor/admin` has the major and minor version of the colveor-go release
|
|
346
|
+
it is built for: 0.5.x works with a colveor-go 0.5.x API. The System status
|
|
347
|
+
page warns when the API's version doesn't match (`version` is exported).
|
|
348
|
+
Changes that break your own pages are listed under **Breaking** in
|
|
349
|
+
colveor-go's changelog, with what to do.
|
|
350
|
+
|
|
351
|
+
## Using it without the template
|
|
352
|
+
|
|
353
|
+
The template is the supported setup. Without it, a Next 16 app needs:
|
|
354
|
+
|
|
355
|
+
1. `@colveor/admin`, `next`, `react` and `react-dom` 19.
|
|
356
|
+
2. Tailwind 4 scanning `node_modules/@colveor/admin/dist`, with a theme
|
|
357
|
+
that defines the `brand-*` colours (copy the template's `globals.css`).
|
|
358
|
+
3. The proxy route at `app/api/colveor/[...path]/route.ts`, and
|
|
359
|
+
`COLVEOR_API_URL` on the server.
|
|
360
|
+
4. `<NextAdmin config={config}>` around the app, in a client component.
|
|
361
|
+
5. A page per framework page you want, each a one-line re-export.
|
|
362
|
+
|
|
363
|
+
## License
|
|
364
|
+
|
|
365
|
+
Proprietary: see `LICENSE.md`. Parts of the look come from TailwindAdmin
|
|
366
|
+
(MIT, `TAILWINDADMIN-LICENSE`).
|
|
@@ -0,0 +1,21 @@
|
|
|
1
|
+
MIT License
|
|
2
|
+
|
|
3
|
+
Copyright (c) 2026 Tailwindadmin
|
|
4
|
+
|
|
5
|
+
Permission is hereby granted, free of charge, to any person obtaining a copy
|
|
6
|
+
of this software and associated documentation files (the "Software"), to deal
|
|
7
|
+
in the Software without restriction, including without limitation the rights
|
|
8
|
+
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
|
|
9
|
+
copies of the Software, and to permit persons to whom the Software is
|
|
10
|
+
furnished to do so, subject to the following conditions:
|
|
11
|
+
|
|
12
|
+
The above copyright notice and this permission notice shall be included in all
|
|
13
|
+
copies or substantial portions of the Software.
|
|
14
|
+
|
|
15
|
+
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
|
|
16
|
+
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
|
|
17
|
+
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
|
|
18
|
+
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
|
|
19
|
+
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
|
|
20
|
+
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
|
|
21
|
+
SOFTWARE.
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export declare function DataTab(): import("react").JSX.Element;
|
|
@@ -0,0 +1,44 @@
|
|
|
1
|
+
"use client";
|
|
2
|
+
import { jsx as _jsx, jsxs as _jsxs } from "react/jsx-runtime";
|
|
3
|
+
// Your data (docs/account-lifecycle.md): download it, or delete the account
|
|
4
|
+
// after the grace period (cancel until then). Both ask to confirm it's you.
|
|
5
|
+
import { useEffect, useState } from "react";
|
|
6
|
+
import { useAction } from "../actions";
|
|
7
|
+
import { ApiError, api, call } from "../client";
|
|
8
|
+
import { formatDate } from "../dates";
|
|
9
|
+
import { Messages, Section, secondary, useStep } from "./shared";
|
|
10
|
+
export function DataTab() {
|
|
11
|
+
const [deletion, setDeletion] = useState(null);
|
|
12
|
+
const { run, dialogs } = useAction();
|
|
13
|
+
const { step, error, notice, busy } = useStep();
|
|
14
|
+
const load = () => api
|
|
15
|
+
.get("/v1/me/deletion")
|
|
16
|
+
.then(setDeletion)
|
|
17
|
+
.catch((err) => {
|
|
18
|
+
if (err instanceof ApiError && err.status === 404) {
|
|
19
|
+
setDeletion(null);
|
|
20
|
+
}
|
|
21
|
+
});
|
|
22
|
+
useEffect(() => {
|
|
23
|
+
load();
|
|
24
|
+
}, []);
|
|
25
|
+
const download = () => step(async () => {
|
|
26
|
+
const data = await run((o) => call("/v1/me/export", { ...o, method: "GET" }));
|
|
27
|
+
const url = URL.createObjectURL(new Blob([JSON.stringify(data, null, 2)], { type: "application/json" }));
|
|
28
|
+
const a = document.createElement("a");
|
|
29
|
+
a.href = url;
|
|
30
|
+
a.download = "my-account.json";
|
|
31
|
+
a.click();
|
|
32
|
+
URL.revokeObjectURL(url);
|
|
33
|
+
}, "Your data is downloaded.");
|
|
34
|
+
const request = () => window.confirm("Delete your account? You can cancel until the date shown next.") &&
|
|
35
|
+
step(async () => {
|
|
36
|
+
await run((o) => api.post("/v1/me/deletion", undefined, o));
|
|
37
|
+
await load();
|
|
38
|
+
});
|
|
39
|
+
const cancel = () => step(async () => {
|
|
40
|
+
await api.delete("/v1/me/deletion");
|
|
41
|
+
setDeletion(null);
|
|
42
|
+
}, "Your account won't be deleted.");
|
|
43
|
+
return (_jsxs("div", { className: "space-y-6", children: [_jsx(Messages, { error: error, notice: notice }), _jsx(Section, { title: "Download your data", about: "Everything kept about your account, as a JSON file.", children: _jsx("button", { type: "button", disabled: busy, className: secondary, onClick: download, children: "Download" }) }), _jsx(Section, { title: "Delete your account", about: "Your other devices are signed out at once.", children: deletion === null ? (_jsx("button", { type: "button", disabled: busy, onClick: request, className: "rounded-lg border border-red-300 px-4 py-2.5 text-sm text-red-600 transition hover:bg-red-50 disabled:opacity-40", children: "Delete my account" })) : (_jsxs("div", { className: "flex flex-wrap items-center justify-between gap-3", children: [_jsxs("p", { className: "text-sm text-gray-700 dark:text-gray-300", children: ["Your account will be deleted on ", formatDate(deletion.due_at), ".", deletion.blocked && ` It waits: ${Object.values(deletion.blocked).join(" ")}`] }), _jsx("button", { type: "button", disabled: busy, className: secondary, onClick: cancel, children: "Keep my account" })] })) }), dialogs] }));
|
|
44
|
+
}
|