@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.
Files changed (173) hide show
  1. package/CHECKLIST.md +52 -10
  2. package/README.md +371 -36
  3. package/dist/auth/client/gateway-token.d.ts +19 -0
  4. package/dist/auth/client/gateway-token.js +89 -0
  5. package/dist/auth/client/in-memory.d.ts +5 -1
  6. package/dist/auth/client/in-memory.js +75 -38
  7. package/dist/auth/client/index.d.ts +0 -1
  8. package/dist/auth/client/interface.d.ts +6 -3
  9. package/dist/auth/client/keycloak.d.ts +0 -1
  10. package/dist/auth/client/keycloak.js +6 -3
  11. package/dist/auth/components/UserSelector.d.ts +0 -1
  12. package/dist/auth/components/UserSelector.js +89 -7
  13. package/dist/auth/components/index.d.ts +0 -1
  14. package/dist/auth/index.d.ts +0 -1
  15. package/dist/components/AuthProvider.d.ts +0 -1
  16. package/dist/components/Timestamp.d.ts +7 -0
  17. package/dist/components/Timestamp.js +50 -0
  18. package/dist/hooks/useAuth.d.ts +0 -1
  19. package/dist/hooks/useAuth.js +1 -1
  20. package/dist/hooks/useFetch.d.ts +0 -1
  21. package/dist/hooks/useI18n.d.ts +0 -1
  22. package/dist/hooks/usePlatformAPI.d.ts +0 -1
  23. package/dist/hooks/useTelemetry.d.ts +0 -1
  24. package/dist/hooks/useTimestamp.d.ts +8 -0
  25. package/dist/hooks/useTimestamp.js +122 -0
  26. package/dist/i18n/config.d.ts +20 -2
  27. package/dist/i18n/config.js +48 -0
  28. package/dist/i18n/index.d.ts +2 -3
  29. package/dist/i18n/index.js +1 -1
  30. package/dist/i18n/locales/en-US.json +95 -18
  31. package/dist/i18n/locales/es.json +95 -18
  32. package/dist/i18n/locales/pt-BR.json +95 -18
  33. package/dist/i18n/locales/ro.json +95 -18
  34. package/dist/index.d.ts +11 -7
  35. package/dist/index.js +5 -1
  36. package/dist/registry/AdminShellRegistry.d.ts +1 -2
  37. package/dist/registry/cache/cached-catalog.d.ts +11 -0
  38. package/dist/registry/cache/cached-catalog.js +42 -0
  39. package/dist/registry/cache/catalog-cache.d.ts +10 -0
  40. package/dist/registry/cache/catalog-cache.js +58 -0
  41. package/dist/registry/cache/index.d.ts +5 -0
  42. package/dist/registry/cache/index.js +3 -0
  43. package/dist/registry/cache/types.d.ts +20 -0
  44. package/dist/registry/cache/types.js +3 -0
  45. package/dist/registry/client/http.d.ts +0 -1
  46. package/dist/registry/client/http.js +13 -0
  47. package/dist/registry/client/in-memory.d.ts +0 -1
  48. package/dist/registry/client/in-memory.js +117 -12
  49. package/dist/registry/client/index.d.ts +0 -1
  50. package/dist/registry/client/interface.d.ts +21 -6
  51. package/dist/registry/index.d.ts +5 -2
  52. package/dist/registry/index.js +4 -0
  53. package/dist/registry/types/index.d.ts +2 -3
  54. package/dist/registry/types/manifest.d.ts +20 -24
  55. package/dist/registry/types/manifest.js +17 -18
  56. package/dist/registry/types/module.d.ts +43 -14
  57. package/dist/registry/useRegistryPolling.d.ts +15 -0
  58. package/dist/registry/useRegistryPolling.js +66 -0
  59. package/dist/router/DynamicModule.d.ts +6 -22
  60. package/dist/router/DynamicModule.js +25 -48
  61. package/dist/router/ModuleErrorBoundary.d.ts +39 -0
  62. package/dist/router/ModuleErrorBoundary.js +101 -0
  63. package/dist/router/index.d.ts +1 -1
  64. package/dist/router/url-allowlist.d.ts +22 -0
  65. package/dist/router/url-allowlist.js +65 -0
  66. package/dist/shell/AdminShell.d.ts +0 -1
  67. package/dist/shell/AdminShell.js +178 -43
  68. package/dist/shell/BackofficeShell.d.ts +0 -1
  69. package/dist/shell/BackofficeShell.js +59 -25
  70. package/dist/shell/components/CommandPalette.d.ts +0 -1
  71. package/dist/shell/components/CommandPalette.js +26 -50
  72. package/dist/shell/components/DevtoolsPanel.d.ts +11 -0
  73. package/dist/shell/components/DevtoolsPanel.js +145 -0
  74. package/dist/shell/components/HomePage.d.ts +0 -1
  75. package/dist/shell/components/HomePage.js +9 -4
  76. package/dist/shell/components/LeftNav.d.ts +0 -1
  77. package/dist/shell/components/LeftNav.js +91 -93
  78. package/dist/shell/components/MainContent.d.ts +3 -2
  79. package/dist/shell/components/MainContent.js +8 -23
  80. package/dist/shell/components/ModuleOverview.d.ts +0 -1
  81. package/dist/shell/components/ModuleOverview.js +4 -20
  82. package/dist/shell/components/ProfilePage.d.ts +0 -1
  83. package/dist/shell/components/ProfilePage.js +1 -1
  84. package/dist/shell/components/RegistryPage.d.ts +0 -1
  85. package/dist/shell/components/RegistryPage.js +154 -64
  86. package/dist/shell/components/RegistryStatusBanner.d.ts +6 -0
  87. package/dist/shell/components/RegistryStatusBanner.js +31 -0
  88. package/dist/shell/components/RegistryUnavailable.d.ts +4 -0
  89. package/dist/shell/components/RegistryUnavailable.js +7 -0
  90. package/dist/shell/components/SettingsPage.d.ts +0 -1
  91. package/dist/shell/components/StackedPanel.d.ts +15 -0
  92. package/dist/shell/components/StackedPanel.js +45 -0
  93. package/dist/shell/components/TopBar.d.ts +4 -2
  94. package/dist/shell/components/TopBar.js +9 -3
  95. package/dist/shell/components/UpdateBanner.d.ts +5 -0
  96. package/dist/shell/components/UpdateBanner.js +8 -0
  97. package/dist/shell/components/index.d.ts +4 -1
  98. package/dist/shell/components/index.js +2 -0
  99. package/dist/shell/components/theme-provider.d.ts +0 -1
  100. package/dist/shell/components/theme-provider.js +8 -5
  101. package/dist/shell/hooks/useCspViolations.d.ts +12 -0
  102. package/dist/shell/hooks/useCspViolations.js +34 -0
  103. package/dist/shell/index.d.ts +1 -2
  104. package/dist/shell/polling-config.d.ts +10 -0
  105. package/dist/shell/polling-config.js +26 -0
  106. package/dist/shell/search/fuzzy.d.ts +0 -1
  107. package/dist/shell/search/index.d.ts +0 -1
  108. package/dist/shell/telemetry.d.ts +0 -1
  109. package/dist/shell/types.d.ts +34 -18
  110. package/dist/tailwind/index.d.ts +0 -1
  111. package/dist/types/keycloak.d.ts +0 -1
  112. package/dist/types/platform.d.ts +12 -1
  113. package/dist/vite/AdminShellSharedDeps.d.ts +64 -0
  114. package/dist/vite/AdminShellSharedDeps.js +215 -0
  115. package/dist/vite/config.d.ts +17 -3
  116. package/dist/vite/config.js +34 -8
  117. package/dist/vite/i18n-plugin.d.ts +13 -0
  118. package/dist/vite/i18n-plugin.js +81 -0
  119. package/dist/vite/index.d.ts +3 -2
  120. package/dist/vite/index.js +3 -1
  121. package/dist/vite/plugins.d.ts +0 -1
  122. package/package.json +6 -2
  123. package/dist/auth/client/in-memory.d.ts.map +0 -1
  124. package/dist/auth/client/index.d.ts.map +0 -1
  125. package/dist/auth/client/interface.d.ts.map +0 -1
  126. package/dist/auth/client/keycloak.d.ts.map +0 -1
  127. package/dist/auth/components/UserSelector.d.ts.map +0 -1
  128. package/dist/auth/components/index.d.ts.map +0 -1
  129. package/dist/auth/index.d.ts.map +0 -1
  130. package/dist/components/AuthProvider.d.ts.map +0 -1
  131. package/dist/hooks/useAuth.d.ts.map +0 -1
  132. package/dist/hooks/useFetch.d.ts.map +0 -1
  133. package/dist/hooks/useI18n.d.ts.map +0 -1
  134. package/dist/hooks/usePlatformAPI.d.ts.map +0 -1
  135. package/dist/hooks/useTelemetry.d.ts.map +0 -1
  136. package/dist/i18n/config.d.ts.map +0 -1
  137. package/dist/i18n/index.d.ts.map +0 -1
  138. package/dist/index.d.ts.map +0 -1
  139. package/dist/registry/AdminShellRegistry.d.ts.map +0 -1
  140. package/dist/registry/client/http.d.ts.map +0 -1
  141. package/dist/registry/client/in-memory.d.ts.map +0 -1
  142. package/dist/registry/client/index.d.ts.map +0 -1
  143. package/dist/registry/client/interface.d.ts.map +0 -1
  144. package/dist/registry/index.d.ts.map +0 -1
  145. package/dist/registry/types/index.d.ts.map +0 -1
  146. package/dist/registry/types/manifest.d.ts.map +0 -1
  147. package/dist/registry/types/module.d.ts.map +0 -1
  148. package/dist/router/DynamicModule.d.ts.map +0 -1
  149. package/dist/router/index.d.ts.map +0 -1
  150. package/dist/shell/AdminShell.d.ts.map +0 -1
  151. package/dist/shell/BackofficeShell.d.ts.map +0 -1
  152. package/dist/shell/components/CommandPalette.d.ts.map +0 -1
  153. package/dist/shell/components/HomePage.d.ts.map +0 -1
  154. package/dist/shell/components/LeftNav.d.ts.map +0 -1
  155. package/dist/shell/components/MainContent.d.ts.map +0 -1
  156. package/dist/shell/components/ModuleOverview.d.ts.map +0 -1
  157. package/dist/shell/components/ProfilePage.d.ts.map +0 -1
  158. package/dist/shell/components/RegistryPage.d.ts.map +0 -1
  159. package/dist/shell/components/SettingsPage.d.ts.map +0 -1
  160. package/dist/shell/components/TopBar.d.ts.map +0 -1
  161. package/dist/shell/components/index.d.ts.map +0 -1
  162. package/dist/shell/components/theme-provider.d.ts.map +0 -1
  163. package/dist/shell/index.d.ts.map +0 -1
  164. package/dist/shell/search/fuzzy.d.ts.map +0 -1
  165. package/dist/shell/search/index.d.ts.map +0 -1
  166. package/dist/shell/telemetry.d.ts.map +0 -1
  167. package/dist/shell/types.d.ts.map +0 -1
  168. package/dist/tailwind/index.d.ts.map +0 -1
  169. package/dist/types/keycloak.d.ts.map +0 -1
  170. package/dist/types/platform.d.ts.map +0 -1
  171. package/dist/vite/config.d.ts.map +0 -1
  172. package/dist/vite/index.d.ts.map +0 -1
  173. 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/standalone.tsx` — Dev entry (AdminShell wrapper)
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 (recommended)
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`, `route`)
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": [{ "id": "home", "title": "Home", "route": "/my-module/home" }],
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/standalone.tsx`
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/standalone.tsx` in non-Lovable modules)
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 `standalone.tsx`)
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