@nsxbet/admin-sdk 0.5.1 → 0.7.0
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/CHECKLIST.md +52 -10
- package/README.md +371 -36
- package/dist/auth/client/gateway-token.d.ts +19 -0
- package/dist/auth/client/gateway-token.js +89 -0
- package/dist/auth/client/in-memory.d.ts +5 -1
- package/dist/auth/client/in-memory.js +75 -38
- package/dist/auth/client/index.d.ts +0 -1
- package/dist/auth/client/interface.d.ts +6 -3
- package/dist/auth/client/keycloak.d.ts +0 -1
- package/dist/auth/client/keycloak.js +6 -3
- package/dist/auth/components/UserSelector.d.ts +0 -1
- package/dist/auth/components/UserSelector.js +89 -7
- package/dist/auth/components/index.d.ts +0 -1
- package/dist/auth/index.d.ts +0 -1
- package/dist/components/AuthProvider.d.ts +0 -1
- package/dist/components/Timestamp.d.ts +7 -0
- package/dist/components/Timestamp.js +50 -0
- package/dist/hooks/useAuth.d.ts +0 -1
- package/dist/hooks/useAuth.js +1 -1
- package/dist/hooks/useFetch.d.ts +0 -1
- package/dist/hooks/useI18n.d.ts +0 -1
- package/dist/hooks/usePlatformAPI.d.ts +0 -1
- package/dist/hooks/useTelemetry.d.ts +0 -1
- package/dist/hooks/useTimestamp.d.ts +8 -0
- package/dist/hooks/useTimestamp.js +122 -0
- package/dist/i18n/config.d.ts +20 -2
- package/dist/i18n/config.js +48 -0
- package/dist/i18n/index.d.ts +2 -3
- package/dist/i18n/index.js +1 -1
- package/dist/i18n/locales/en-US.json +95 -18
- package/dist/i18n/locales/es.json +95 -18
- package/dist/i18n/locales/pt-BR.json +95 -18
- package/dist/i18n/locales/ro.json +95 -18
- package/dist/index.d.ts +11 -7
- package/dist/index.js +5 -1
- package/dist/registry/AdminShellRegistry.d.ts +1 -2
- package/dist/registry/cache/cached-catalog.d.ts +11 -0
- package/dist/registry/cache/cached-catalog.js +42 -0
- package/dist/registry/cache/catalog-cache.d.ts +10 -0
- package/dist/registry/cache/catalog-cache.js +58 -0
- package/dist/registry/cache/index.d.ts +5 -0
- package/dist/registry/cache/index.js +3 -0
- package/dist/registry/cache/types.d.ts +20 -0
- package/dist/registry/cache/types.js +3 -0
- package/dist/registry/client/http.d.ts +0 -1
- package/dist/registry/client/http.js +13 -0
- package/dist/registry/client/in-memory.d.ts +0 -1
- package/dist/registry/client/in-memory.js +117 -12
- package/dist/registry/client/index.d.ts +0 -1
- package/dist/registry/client/interface.d.ts +21 -6
- package/dist/registry/index.d.ts +5 -2
- package/dist/registry/index.js +4 -0
- package/dist/registry/types/index.d.ts +2 -3
- package/dist/registry/types/manifest.d.ts +20 -24
- package/dist/registry/types/manifest.js +17 -18
- package/dist/registry/types/module.d.ts +43 -14
- package/dist/registry/useRegistryPolling.d.ts +15 -0
- package/dist/registry/useRegistryPolling.js +66 -0
- package/dist/router/DynamicModule.d.ts +6 -22
- package/dist/router/DynamicModule.js +25 -48
- package/dist/router/ModuleErrorBoundary.d.ts +39 -0
- package/dist/router/ModuleErrorBoundary.js +101 -0
- package/dist/router/index.d.ts +1 -1
- package/dist/router/url-allowlist.d.ts +22 -0
- package/dist/router/url-allowlist.js +65 -0
- package/dist/shell/AdminShell.d.ts +0 -1
- package/dist/shell/AdminShell.js +178 -43
- package/dist/shell/BackofficeShell.d.ts +0 -1
- package/dist/shell/BackofficeShell.js +59 -25
- package/dist/shell/components/CommandPalette.d.ts +0 -1
- package/dist/shell/components/CommandPalette.js +26 -50
- package/dist/shell/components/DevtoolsPanel.d.ts +11 -0
- package/dist/shell/components/DevtoolsPanel.js +145 -0
- package/dist/shell/components/HomePage.d.ts +0 -1
- package/dist/shell/components/HomePage.js +9 -4
- package/dist/shell/components/LeftNav.d.ts +0 -1
- package/dist/shell/components/LeftNav.js +91 -93
- package/dist/shell/components/MainContent.d.ts +3 -2
- package/dist/shell/components/MainContent.js +8 -23
- package/dist/shell/components/ModuleOverview.d.ts +0 -1
- package/dist/shell/components/ModuleOverview.js +4 -20
- package/dist/shell/components/ProfilePage.d.ts +0 -1
- package/dist/shell/components/ProfilePage.js +1 -1
- package/dist/shell/components/RegistryPage.d.ts +0 -1
- package/dist/shell/components/RegistryPage.js +154 -64
- package/dist/shell/components/RegistryStatusBanner.d.ts +6 -0
- package/dist/shell/components/RegistryStatusBanner.js +31 -0
- package/dist/shell/components/RegistryUnavailable.d.ts +4 -0
- package/dist/shell/components/RegistryUnavailable.js +7 -0
- package/dist/shell/components/SettingsPage.d.ts +0 -1
- package/dist/shell/components/StackedPanel.d.ts +15 -0
- package/dist/shell/components/StackedPanel.js +45 -0
- package/dist/shell/components/TopBar.d.ts +4 -2
- package/dist/shell/components/TopBar.js +9 -3
- package/dist/shell/components/UpdateBanner.d.ts +5 -0
- package/dist/shell/components/UpdateBanner.js +8 -0
- package/dist/shell/components/index.d.ts +4 -1
- package/dist/shell/components/index.js +2 -0
- package/dist/shell/components/theme-provider.d.ts +0 -1
- package/dist/shell/components/theme-provider.js +8 -5
- package/dist/shell/hooks/useCspViolations.d.ts +12 -0
- package/dist/shell/hooks/useCspViolations.js +34 -0
- package/dist/shell/index.d.ts +1 -2
- package/dist/shell/polling-config.d.ts +10 -0
- package/dist/shell/polling-config.js +26 -0
- package/dist/shell/search/fuzzy.d.ts +0 -1
- package/dist/shell/search/index.d.ts +0 -1
- package/dist/shell/telemetry.d.ts +0 -1
- package/dist/shell/types.d.ts +34 -18
- package/dist/tailwind/index.d.ts +0 -1
- package/dist/types/keycloak.d.ts +0 -1
- package/dist/types/platform.d.ts +12 -1
- package/dist/vite/AdminShellSharedDeps.d.ts +64 -0
- package/dist/vite/AdminShellSharedDeps.js +215 -0
- package/dist/vite/config.d.ts +17 -3
- package/dist/vite/config.js +34 -8
- package/dist/vite/i18n-plugin.d.ts +13 -0
- package/dist/vite/i18n-plugin.js +81 -0
- package/dist/vite/index.d.ts +3 -2
- package/dist/vite/index.js +3 -1
- package/dist/vite/plugins.d.ts +0 -1
- package/package.json +6 -2
- package/dist/auth/client/in-memory.d.ts.map +0 -1
- package/dist/auth/client/index.d.ts.map +0 -1
- package/dist/auth/client/interface.d.ts.map +0 -1
- package/dist/auth/client/keycloak.d.ts.map +0 -1
- package/dist/auth/components/UserSelector.d.ts.map +0 -1
- package/dist/auth/components/index.d.ts.map +0 -1
- package/dist/auth/index.d.ts.map +0 -1
- package/dist/components/AuthProvider.d.ts.map +0 -1
- package/dist/hooks/useAuth.d.ts.map +0 -1
- package/dist/hooks/useFetch.d.ts.map +0 -1
- package/dist/hooks/useI18n.d.ts.map +0 -1
- package/dist/hooks/usePlatformAPI.d.ts.map +0 -1
- package/dist/hooks/useTelemetry.d.ts.map +0 -1
- package/dist/i18n/config.d.ts.map +0 -1
- package/dist/i18n/index.d.ts.map +0 -1
- package/dist/index.d.ts.map +0 -1
- package/dist/registry/AdminShellRegistry.d.ts.map +0 -1
- package/dist/registry/client/http.d.ts.map +0 -1
- package/dist/registry/client/in-memory.d.ts.map +0 -1
- package/dist/registry/client/index.d.ts.map +0 -1
- package/dist/registry/client/interface.d.ts.map +0 -1
- package/dist/registry/index.d.ts.map +0 -1
- package/dist/registry/types/index.d.ts.map +0 -1
- package/dist/registry/types/manifest.d.ts.map +0 -1
- package/dist/registry/types/module.d.ts.map +0 -1
- package/dist/router/DynamicModule.d.ts.map +0 -1
- package/dist/router/index.d.ts.map +0 -1
- package/dist/shell/AdminShell.d.ts.map +0 -1
- package/dist/shell/BackofficeShell.d.ts.map +0 -1
- package/dist/shell/components/CommandPalette.d.ts.map +0 -1
- package/dist/shell/components/HomePage.d.ts.map +0 -1
- package/dist/shell/components/LeftNav.d.ts.map +0 -1
- package/dist/shell/components/MainContent.d.ts.map +0 -1
- package/dist/shell/components/ModuleOverview.d.ts.map +0 -1
- package/dist/shell/components/ProfilePage.d.ts.map +0 -1
- package/dist/shell/components/RegistryPage.d.ts.map +0 -1
- package/dist/shell/components/SettingsPage.d.ts.map +0 -1
- package/dist/shell/components/TopBar.d.ts.map +0 -1
- package/dist/shell/components/index.d.ts.map +0 -1
- package/dist/shell/components/theme-provider.d.ts.map +0 -1
- package/dist/shell/index.d.ts.map +0 -1
- package/dist/shell/search/fuzzy.d.ts.map +0 -1
- package/dist/shell/search/index.d.ts.map +0 -1
- package/dist/shell/telemetry.d.ts.map +0 -1
- package/dist/shell/types.d.ts.map +0 -1
- package/dist/tailwind/index.d.ts.map +0 -1
- package/dist/types/keycloak.d.ts.map +0 -1
- package/dist/types/platform.d.ts.map +0 -1
- package/dist/vite/config.d.ts.map +0 -1
- package/dist/vite/index.d.ts.map +0 -1
- package/dist/vite/plugins.d.ts.map +0 -1
package/CHECKLIST.md
CHANGED
|
@@ -12,7 +12,7 @@
|
|
|
12
12
|
- [ ] `vite.config.ts` — Vite build config
|
|
13
13
|
- [ ] `index.html` — HTML entry point
|
|
14
14
|
- [ ] `src/spa.tsx` — Shell entry (default export)
|
|
15
|
-
- [ ] `src/
|
|
15
|
+
- [ ] `src/main.tsx` — Dev entry (AdminShell wrapper)
|
|
16
16
|
- [ ] `src/App.tsx` — Main app component (Routes)
|
|
17
17
|
- [ ] `src/index.css` — Styles with Tailwind directives
|
|
18
18
|
- [ ] `tailwind.config.js` — Tailwind config
|
|
@@ -20,17 +20,36 @@
|
|
|
20
20
|
- [ ] `tsconfig.json` — TypeScript config
|
|
21
21
|
- [ ] `tsconfig.node.json` — Node TypeScript config
|
|
22
22
|
- [ ] `src/globals.d.ts` — Global type declarations
|
|
23
|
+
- [ ] `src/i18n/locales/en-US.json` — English (US) translations
|
|
24
|
+
- [ ] `src/i18n/locales/pt-BR.json` — Portuguese (Brazil) translations
|
|
25
|
+
- [ ] `src/i18n/locales/es.json` — Spanish translations
|
|
26
|
+
- [ ] `src/i18n/locales/ro.json` — Romanian translations
|
|
27
|
+
- [ ] `.env.staging` — Gateway environment config (staging mode)
|
|
28
|
+
|
|
29
|
+
## Environment Configuration
|
|
30
|
+
|
|
31
|
+
- [ ] `.env.staging` exists with `VITE_ADMIN_GATEWAY_URL` configured
|
|
32
|
+
- [ ] `dev` script uses `--mode staging` to load `.env.staging` by default
|
|
33
|
+
|
|
34
|
+
Expected `.env.staging`:
|
|
35
|
+
|
|
36
|
+
```bash
|
|
37
|
+
# Gateway URL for BFF token integration (InMemory auth)
|
|
38
|
+
# Fetches real signed JWTs from the admin gateway instead of mock tokens.
|
|
39
|
+
# Staging: https://admin-bff-stg.nsx.dev | Homol: https://admin-bff-homol.nsx.dev | Local: http://localhost:8080
|
|
40
|
+
VITE_ADMIN_GATEWAY_URL=https://admin-bff-stg.nsx.dev
|
|
41
|
+
```
|
|
23
42
|
|
|
24
43
|
## Module Manifest (`admin.module.json`)
|
|
25
44
|
|
|
26
45
|
- [ ] Has `id` field (format: `@admin/<name>`)
|
|
27
|
-
- [ ] Has `title` field
|
|
46
|
+
- [ ] Has `title` field (localized object with en-US, pt-BR, es, ro)
|
|
28
47
|
- [ ] Has `routeBase` field (starts with `/`)
|
|
29
|
-
- [ ] Has `description` field (
|
|
48
|
+
- [ ] Has `description` field (required, localized object with all 4 locales)
|
|
30
49
|
- [ ] Has `version` field (recommended)
|
|
31
50
|
- [ ] Has `category` field (recommended)
|
|
32
51
|
- [ ] Has `permissions` object (recommended, values are string arrays)
|
|
33
|
-
- [ ] Has `commands` array (recommended, each with `id`, `title
|
|
52
|
+
- [ ] Has `commands` array (recommended, each with `id`, `title` (localized), `route`)
|
|
34
53
|
- [ ] All command `route` values start with the module's `routeBase`
|
|
35
54
|
|
|
36
55
|
Expected structure:
|
|
@@ -38,12 +57,14 @@ Expected structure:
|
|
|
38
57
|
```json
|
|
39
58
|
{
|
|
40
59
|
"id": "@admin/my-module",
|
|
41
|
-
"title": "My Module",
|
|
60
|
+
"title": { "en-US": "My Module", "pt-BR": "Meu Módulo", "es": "Mi Módulo", "ro": "Modulul Meu" },
|
|
42
61
|
"routeBase": "/my-module",
|
|
43
|
-
"description": "My Module admin module",
|
|
62
|
+
"description": { "en-US": "My Module admin module", "pt-BR": "...", "es": "...", "ro": "..." },
|
|
44
63
|
"version": "1.0.0",
|
|
45
64
|
"category": "Tools",
|
|
46
|
-
"commands": [
|
|
65
|
+
"commands": [
|
|
66
|
+
{ "id": "home", "title": { "en-US": "Home", "pt-BR": "Início", "es": "Inicio", "ro": "Acasă" }, "route": "/my-module/home" }
|
|
67
|
+
],
|
|
47
68
|
"permissions": {
|
|
48
69
|
"view": ["admin.my-module.view"],
|
|
49
70
|
"edit": ["admin.my-module.edit"],
|
|
@@ -52,6 +73,14 @@ Expected structure:
|
|
|
52
73
|
}
|
|
53
74
|
```
|
|
54
75
|
|
|
76
|
+
## i18n
|
|
77
|
+
|
|
78
|
+
- [ ] All 4 locale files exist: `src/i18n/locales/en-US.json`, `pt-BR.json`, `es.json`, `ro.json`
|
|
79
|
+
- [ ] Manifest `title` and `description` are localized objects (not plain strings)
|
|
80
|
+
- [ ] Each command `title` is a localized object
|
|
81
|
+
- [ ] No manual i18n registration in `main.tsx` or `spa.tsx` (Vite plugin auto-injects)
|
|
82
|
+
- [ ] No `import "./i18n"` in `App.tsx`
|
|
83
|
+
|
|
55
84
|
## Dependencies (`package.json`)
|
|
56
85
|
|
|
57
86
|
- [ ] `"type": "module"` is set
|
|
@@ -162,7 +191,7 @@ import { App } from "./App";
|
|
|
162
191
|
export default App;
|
|
163
192
|
```
|
|
164
193
|
|
|
165
|
-
### `src/
|
|
194
|
+
### `src/main.tsx`
|
|
166
195
|
|
|
167
196
|
- [ ] Uses `AdminShell` from `@nsxbet/admin-sdk`
|
|
168
197
|
- [ ] Imports manifest and passes to `modules` prop
|
|
@@ -220,13 +249,25 @@ If your module was scaffolded by Lovable, the following differences apply:
|
|
|
220
249
|
- [ ] `vite.config.ts` uses `adminModule()` spread into the existing plugins array (option B above), NOT `defineModuleConfig`
|
|
221
250
|
- [ ] React plugin is `@vitejs/plugin-react-swc` (Lovable default) — this is supported
|
|
222
251
|
- [ ] `index.html` entry point references `/src/main.tsx` (Lovable default) — this serves as the standalone dev entry
|
|
223
|
-
- [ ] `src/main.tsx` wraps your App with `AdminShell` (same role as `src/
|
|
252
|
+
- [ ] `src/main.tsx` wraps your App with `AdminShell` (same role as `src/main.tsx` in non-Lovable modules)
|
|
224
253
|
- [ ] `src/spa.tsx` still required — `export default App` for shell mode
|
|
225
254
|
- [ ] `admin.module.json` still required at project root
|
|
226
255
|
- [ ] `module.manifest.json` is auto-generated at build time by `adminModule()` — do NOT manually copy `admin.module.json` to `dist/`
|
|
227
256
|
- [ ] Lovable's existing `server`, `resolve.alias`, and plugin settings are preserved — `adminModule()` only affects `vite build`
|
|
228
257
|
- [ ] Build script can be `"vite build"` (Lovable default) or `"tsc && vite build"` — both work
|
|
229
258
|
|
|
259
|
+
### Environment Configuration (automatic)
|
|
260
|
+
|
|
261
|
+
`adminModule()` automatically injects `VITE_ADMIN_GATEWAY_URL` with the staging gateway URL (`https://admin-bff-stg.nsx.dev`). No `.env.staging` file or `--mode staging` script is needed for Lovable projects.
|
|
262
|
+
|
|
263
|
+
- [ ] Do NOT create `.env.staging` — the Vite plugin handles it
|
|
264
|
+
- [ ] Do NOT add `--mode staging` to the dev script
|
|
265
|
+
|
|
266
|
+
To override the gateway URL, either:
|
|
267
|
+
- Set `VITE_ADMIN_GATEWAY_URL` in a `.env` or `.env.local` file
|
|
268
|
+
- Pass `gatewayUrl` option: `...adminModule({ gatewayUrl: "http://localhost:8080" })`
|
|
269
|
+
- Disable injection: `...adminModule({ gatewayUrl: null })`
|
|
270
|
+
|
|
230
271
|
Expected `vite.config.ts` for Lovable:
|
|
231
272
|
|
|
232
273
|
```typescript
|
|
@@ -294,8 +335,9 @@ ReactDOM.createRoot(document.getElementById("root")!).render(
|
|
|
294
335
|
|
|
295
336
|
- [ ] No `@supabase/supabase-js` or `supabase` imports in `src/**`
|
|
296
337
|
- [ ] No `firebase` imports in `src/**`
|
|
297
|
-
- [ ] No `BrowserRouter` or `MemoryRouter` in `src/**` (except `
|
|
338
|
+
- [ ] No `BrowserRouter` or `MemoryRouter` in `src/**` (except `main.tsx`)
|
|
298
339
|
- [ ] No `useNavigate` imported from `@nsxbet/admin-sdk` (use `react-router-dom`)
|
|
299
340
|
- [ ] No `@supabase/supabase-js` or `firebase` in `package.json` dependencies
|
|
300
341
|
- [ ] No raw `fetch()` or `window.fetch()` calls — use `useFetch()` from the SDK
|
|
342
|
+
- [ ] No direct date formatting (`toLocaleDateString`, `toLocaleTimeString`, `Intl.DateTimeFormat`, dayjs/moment `.format()`, date-fns `format`) — use `<Timestamp />` or `useTimestamp()` from the SDK
|
|
301
343
|
- [ ] Do NOT scaffold shadcn/ui components locally — use `@nsxbet/admin-ui` which ships them pre-configured
|