@nsxbet/admin-sdk 0.1.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/README.md +680 -0
- package/dist/auth/client/in-memory.d.ts +27 -0
- package/dist/auth/client/in-memory.d.ts.map +1 -0
- package/dist/auth/client/in-memory.js +242 -0
- package/dist/auth/client/index.d.ts +7 -0
- package/dist/auth/client/index.d.ts.map +1 -0
- package/dist/auth/client/index.js +7 -0
- package/dist/auth/client/interface.d.ts +115 -0
- package/dist/auth/client/interface.d.ts.map +1 -0
- package/dist/auth/client/interface.js +7 -0
- package/dist/auth/client/keycloak.d.ts +19 -0
- package/dist/auth/client/keycloak.d.ts.map +1 -0
- package/dist/auth/client/keycloak.js +126 -0
- package/dist/auth/components/UserSelector.d.ts +19 -0
- package/dist/auth/components/UserSelector.d.ts.map +1 -0
- package/dist/auth/components/UserSelector.js +100 -0
- package/dist/auth/components/index.d.ts +5 -0
- package/dist/auth/components/index.d.ts.map +1 -0
- package/dist/auth/components/index.js +4 -0
- package/dist/auth/index.d.ts +7 -0
- package/dist/auth/index.d.ts.map +1 -0
- package/dist/auth/index.js +7 -0
- package/dist/components/AuthProvider.d.ts +48 -0
- package/dist/components/AuthProvider.d.ts.map +1 -0
- package/dist/components/AuthProvider.js +117 -0
- package/dist/hooks/useAuth.d.ts +21 -0
- package/dist/hooks/useAuth.d.ts.map +1 -0
- package/dist/hooks/useAuth.js +34 -0
- package/dist/hooks/useFetch.d.ts +8 -0
- package/dist/hooks/useFetch.d.ts.map +1 -0
- package/dist/hooks/useFetch.js +31 -0
- package/dist/hooks/useI18n.d.ts +46 -0
- package/dist/hooks/useI18n.d.ts.map +1 -0
- package/dist/hooks/useI18n.js +95 -0
- package/dist/hooks/usePlatformAPI.d.ts +12 -0
- package/dist/hooks/usePlatformAPI.d.ts.map +1 -0
- package/dist/hooks/usePlatformAPI.js +10 -0
- package/dist/hooks/useTelemetry.d.ts +17 -0
- package/dist/hooks/useTelemetry.d.ts.map +1 -0
- package/dist/hooks/useTelemetry.js +36 -0
- package/dist/i18n/config.d.ts +26 -0
- package/dist/i18n/config.d.ts.map +1 -0
- package/dist/i18n/config.js +92 -0
- package/dist/i18n/index.d.ts +6 -0
- package/dist/i18n/index.d.ts.map +1 -0
- package/dist/i18n/index.js +4 -0
- package/dist/i18n/locales/en-US.json +144 -0
- package/dist/i18n/locales/es.json +144 -0
- package/dist/i18n/locales/pt-BR.json +144 -0
- package/dist/i18n/locales/ro.json +144 -0
- package/dist/index.d.ts +27 -0
- package/dist/index.d.ts.map +1 -0
- package/dist/index.js +30 -0
- package/dist/registry/AdminShellRegistry.d.ts +140 -0
- package/dist/registry/AdminShellRegistry.d.ts.map +1 -0
- package/dist/registry/AdminShellRegistry.js +237 -0
- package/dist/registry/client/http.d.ts +21 -0
- package/dist/registry/client/http.d.ts.map +1 -0
- package/dist/registry/client/http.js +107 -0
- package/dist/registry/client/in-memory.d.ts +36 -0
- package/dist/registry/client/in-memory.d.ts.map +1 -0
- package/dist/registry/client/in-memory.js +242 -0
- package/dist/registry/client/index.d.ts +7 -0
- package/dist/registry/client/index.d.ts.map +1 -0
- package/dist/registry/client/index.js +5 -0
- package/dist/registry/client/interface.d.ts +96 -0
- package/dist/registry/client/interface.d.ts.map +1 -0
- package/dist/registry/client/interface.js +7 -0
- package/dist/registry/index.d.ts +12 -0
- package/dist/registry/index.d.ts.map +1 -0
- package/dist/registry/index.js +8 -0
- package/dist/registry/types/index.d.ts +9 -0
- package/dist/registry/types/index.d.ts.map +1 -0
- package/dist/registry/types/index.js +6 -0
- package/dist/registry/types/manifest.d.ts +98 -0
- package/dist/registry/types/manifest.d.ts.map +1 -0
- package/dist/registry/types/manifest.js +81 -0
- package/dist/registry/types/module.d.ts +115 -0
- package/dist/registry/types/module.d.ts.map +1 -0
- package/dist/registry/types/module.js +6 -0
- package/dist/router/DynamicModule.d.ts +50 -0
- package/dist/router/DynamicModule.d.ts.map +1 -0
- package/dist/router/DynamicModule.js +141 -0
- package/dist/router/index.d.ts +2 -0
- package/dist/router/index.d.ts.map +1 -0
- package/dist/router/index.js +1 -0
- package/dist/shell/AdminShell.d.ts +38 -0
- package/dist/shell/AdminShell.d.ts.map +1 -0
- package/dist/shell/AdminShell.js +299 -0
- package/dist/shell/BackofficeShell.d.ts +38 -0
- package/dist/shell/BackofficeShell.d.ts.map +1 -0
- package/dist/shell/BackofficeShell.js +299 -0
- package/dist/shell/components/CommandPalette.d.ts +8 -0
- package/dist/shell/components/CommandPalette.d.ts.map +1 -0
- package/dist/shell/components/CommandPalette.js +197 -0
- package/dist/shell/components/HomePage.d.ts +2 -0
- package/dist/shell/components/HomePage.d.ts.map +1 -0
- package/dist/shell/components/HomePage.js +32 -0
- package/dist/shell/components/LeftNav.d.ts +7 -0
- package/dist/shell/components/LeftNav.d.ts.map +1 -0
- package/dist/shell/components/LeftNav.js +247 -0
- package/dist/shell/components/MainContent.d.ts +9 -0
- package/dist/shell/components/MainContent.d.ts.map +1 -0
- package/dist/shell/components/MainContent.js +88 -0
- package/dist/shell/components/ModuleOverview.d.ts +7 -0
- package/dist/shell/components/ModuleOverview.d.ts.map +1 -0
- package/dist/shell/components/ModuleOverview.js +40 -0
- package/dist/shell/components/ProfilePage.d.ts +2 -0
- package/dist/shell/components/ProfilePage.d.ts.map +1 -0
- package/dist/shell/components/ProfilePage.js +30 -0
- package/dist/shell/components/RegistryPage.d.ts +8 -0
- package/dist/shell/components/RegistryPage.d.ts.map +1 -0
- package/dist/shell/components/RegistryPage.js +129 -0
- package/dist/shell/components/SettingsPage.d.ts +2 -0
- package/dist/shell/components/SettingsPage.d.ts.map +1 -0
- package/dist/shell/components/SettingsPage.js +60 -0
- package/dist/shell/components/TopBar.d.ts +8 -0
- package/dist/shell/components/TopBar.d.ts.map +1 -0
- package/dist/shell/components/TopBar.js +61 -0
- package/dist/shell/components/index.d.ts +10 -0
- package/dist/shell/components/index.d.ts.map +1 -0
- package/dist/shell/components/index.js +7 -0
- package/dist/shell/components/theme-provider.d.ts +15 -0
- package/dist/shell/components/theme-provider.d.ts.map +1 -0
- package/dist/shell/components/theme-provider.js +39 -0
- package/dist/shell/index.d.ts +9 -0
- package/dist/shell/index.d.ts.map +1 -0
- package/dist/shell/index.js +8 -0
- package/dist/shell/search/fuzzy.d.ts +18 -0
- package/dist/shell/search/fuzzy.d.ts.map +1 -0
- package/dist/shell/search/fuzzy.js +121 -0
- package/dist/shell/search/index.d.ts +3 -0
- package/dist/shell/search/index.d.ts.map +1 -0
- package/dist/shell/search/index.js +1 -0
- package/dist/shell/telemetry.d.ts +7 -0
- package/dist/shell/telemetry.d.ts.map +1 -0
- package/dist/shell/telemetry.js +25 -0
- package/dist/shell/types.d.ts +110 -0
- package/dist/shell/types.d.ts.map +1 -0
- package/dist/shell/types.js +4 -0
- package/dist/tailwind/index.d.ts +20 -0
- package/dist/tailwind/index.d.ts.map +1 -0
- package/dist/tailwind/index.js +42 -0
- package/dist/types/keycloak.d.ts +26 -0
- package/dist/types/keycloak.d.ts.map +1 -0
- package/dist/types/keycloak.js +1 -0
- package/dist/types/platform.d.ts +83 -0
- package/dist/types/platform.d.ts.map +1 -0
- package/dist/types/platform.js +5 -0
- package/dist/vite/config.d.ts +71 -0
- package/dist/vite/config.d.ts.map +1 -0
- package/dist/vite/config.js +87 -0
- package/dist/vite/index.d.ts +18 -0
- package/dist/vite/index.d.ts.map +1 -0
- package/dist/vite/index.js +17 -0
- package/dist/vite/plugins.d.ts +44 -0
- package/dist/vite/plugins.d.ts.map +1 -0
- package/dist/vite/plugins.js +74 -0
- package/package.json +86 -0
|
@@ -0,0 +1,121 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Fuzzy search implementation for command palette
|
|
3
|
+
* Supports weighted scoring across multiple fields
|
|
4
|
+
*/
|
|
5
|
+
/**
|
|
6
|
+
* Scoring weights (highest to lowest priority)
|
|
7
|
+
*/
|
|
8
|
+
const WEIGHTS = {
|
|
9
|
+
TITLE_PREFIX: 1.0,
|
|
10
|
+
TITLE_SUBSTRING: 0.7,
|
|
11
|
+
KEYWORDS: 0.6,
|
|
12
|
+
CATEGORY: 0.5,
|
|
13
|
+
DESCRIPTION: 0.3,
|
|
14
|
+
};
|
|
15
|
+
/**
|
|
16
|
+
* Normalize string for comparison (lowercase, remove spaces)
|
|
17
|
+
*/
|
|
18
|
+
function normalize(str) {
|
|
19
|
+
return str.toLowerCase().replace(/\s+/g, "");
|
|
20
|
+
}
|
|
21
|
+
/**
|
|
22
|
+
* Calculate match score for a single field
|
|
23
|
+
*/
|
|
24
|
+
function calculateFieldScore(field, query, weight) {
|
|
25
|
+
const fieldLower = field.toLowerCase();
|
|
26
|
+
const queryLower = query.toLowerCase();
|
|
27
|
+
// Exact prefix match (highest priority)
|
|
28
|
+
if (fieldLower.startsWith(queryLower)) {
|
|
29
|
+
return weight;
|
|
30
|
+
}
|
|
31
|
+
// Exact substring match
|
|
32
|
+
if (fieldLower.includes(queryLower)) {
|
|
33
|
+
return weight * 0.7;
|
|
34
|
+
}
|
|
35
|
+
// Normalized match (ignoring spaces) - "newuser" matches "New User"
|
|
36
|
+
const fieldNorm = normalize(field);
|
|
37
|
+
const queryNorm = normalize(query);
|
|
38
|
+
if (fieldNorm.startsWith(queryNorm)) {
|
|
39
|
+
return weight * 0.9; // Slightly lower than exact prefix
|
|
40
|
+
}
|
|
41
|
+
if (fieldNorm.includes(queryNorm)) {
|
|
42
|
+
return weight * 0.6; // Slightly lower than exact substring
|
|
43
|
+
}
|
|
44
|
+
return 0;
|
|
45
|
+
}
|
|
46
|
+
/**
|
|
47
|
+
* Calculate total match score for an item and track matched fields
|
|
48
|
+
*/
|
|
49
|
+
function calculateScore(item, query) {
|
|
50
|
+
let score = 0;
|
|
51
|
+
const matchedFields = [];
|
|
52
|
+
// Title matching (prefix or substring)
|
|
53
|
+
const titleScore = calculateFieldScore(item.title, query, WEIGHTS.TITLE_PREFIX);
|
|
54
|
+
if (titleScore === WEIGHTS.TITLE_PREFIX) {
|
|
55
|
+
// Prefix match
|
|
56
|
+
score += titleScore;
|
|
57
|
+
matchedFields.push("title");
|
|
58
|
+
}
|
|
59
|
+
else if (titleScore > 0) {
|
|
60
|
+
// Substring match gets TITLE_SUBSTRING weight
|
|
61
|
+
score += WEIGHTS.TITLE_SUBSTRING;
|
|
62
|
+
matchedFields.push("title");
|
|
63
|
+
}
|
|
64
|
+
// Keywords matching
|
|
65
|
+
if (item.keywords) {
|
|
66
|
+
for (const keyword of item.keywords) {
|
|
67
|
+
const keywordScore = calculateFieldScore(keyword, query, WEIGHTS.KEYWORDS);
|
|
68
|
+
if (keywordScore > 0) {
|
|
69
|
+
score += keywordScore;
|
|
70
|
+
matchedFields.push("keywords");
|
|
71
|
+
break; // Only count first matching keyword
|
|
72
|
+
}
|
|
73
|
+
}
|
|
74
|
+
}
|
|
75
|
+
// Category matching
|
|
76
|
+
if (item.category) {
|
|
77
|
+
const categoryScore = calculateFieldScore(item.category, query, WEIGHTS.CATEGORY);
|
|
78
|
+
if (categoryScore > 0) {
|
|
79
|
+
score += categoryScore;
|
|
80
|
+
matchedFields.push("category");
|
|
81
|
+
}
|
|
82
|
+
}
|
|
83
|
+
// Description matching
|
|
84
|
+
if (item.description) {
|
|
85
|
+
const descriptionScore = calculateFieldScore(item.description, query, WEIGHTS.DESCRIPTION);
|
|
86
|
+
if (descriptionScore > 0) {
|
|
87
|
+
score += descriptionScore;
|
|
88
|
+
matchedFields.push("description");
|
|
89
|
+
}
|
|
90
|
+
}
|
|
91
|
+
return { score, matchedFields };
|
|
92
|
+
}
|
|
93
|
+
/**
|
|
94
|
+
* Perform fuzzy search across searchable items
|
|
95
|
+
*
|
|
96
|
+
* @param items - Array of items to search
|
|
97
|
+
* @param query - Search query string
|
|
98
|
+
* @param options - Search options (maxResults)
|
|
99
|
+
* @returns Sorted array of search results with scores
|
|
100
|
+
*/
|
|
101
|
+
export function fuzzySearch(items, query, options = {}) {
|
|
102
|
+
// Empty query returns all items with score 1.0
|
|
103
|
+
if (query.trim() === "") {
|
|
104
|
+
return items.map((item) => ({ item, score: 1.0, matchedFields: [] }));
|
|
105
|
+
}
|
|
106
|
+
const results = [];
|
|
107
|
+
// Score each item
|
|
108
|
+
for (const item of items) {
|
|
109
|
+
const { score, matchedFields } = calculateScore(item, query);
|
|
110
|
+
if (score > 0) {
|
|
111
|
+
results.push({ item, score, matchedFields });
|
|
112
|
+
}
|
|
113
|
+
}
|
|
114
|
+
// Sort by score descending
|
|
115
|
+
results.sort((a, b) => b.score - a.score);
|
|
116
|
+
// Apply maxResults limit if specified
|
|
117
|
+
if (options.maxResults && options.maxResults > 0) {
|
|
118
|
+
return results.slice(0, options.maxResults);
|
|
119
|
+
}
|
|
120
|
+
return results;
|
|
121
|
+
}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../../src/shell/search/index.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,WAAW,EAAE,MAAM,SAAS,CAAC;AACtC,YAAY,EAAE,aAAa,EAAE,MAAM,SAAS,CAAC"}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export { fuzzySearch } from "./fuzzy";
|
|
@@ -0,0 +1,7 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Telemetry service for tracking events and errors
|
|
3
|
+
*/
|
|
4
|
+
export declare function initTelemetry(env: string): void;
|
|
5
|
+
export declare function track(event: string, props?: Record<string, unknown>): void;
|
|
6
|
+
export declare function trackError(err: unknown, props?: Record<string, unknown>): void;
|
|
7
|
+
//# sourceMappingURL=telemetry.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"telemetry.d.ts","sourceRoot":"","sources":["../../src/shell/telemetry.ts"],"names":[],"mappings":"AAAA;;GAEG;AAIH,wBAAgB,aAAa,CAAC,GAAG,EAAE,MAAM,GAAG,IAAI,CAE/C;AAED,wBAAgB,KAAK,CAAC,KAAK,EAAE,MAAM,EAAE,KAAK,CAAC,EAAE,MAAM,CAAC,MAAM,EAAE,OAAO,CAAC,GAAG,IAAI,CAQ1E;AAED,wBAAgB,UAAU,CAAC,GAAG,EAAE,OAAO,EAAE,KAAK,CAAC,EAAE,MAAM,CAAC,MAAM,EAAE,OAAO,CAAC,GAAG,IAAI,CAQ9E"}
|
|
@@ -0,0 +1,25 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Telemetry service for tracking events and errors
|
|
3
|
+
*/
|
|
4
|
+
let environment = "unknown";
|
|
5
|
+
export function initTelemetry(env) {
|
|
6
|
+
environment = env;
|
|
7
|
+
}
|
|
8
|
+
export function track(event, props) {
|
|
9
|
+
const enrichedProps = {
|
|
10
|
+
...props,
|
|
11
|
+
env: environment,
|
|
12
|
+
timestamp: new Date().toISOString(),
|
|
13
|
+
};
|
|
14
|
+
console.log("[Telemetry]", event, enrichedProps);
|
|
15
|
+
// Future: Send to actual telemetry service (Datadog, Sentry, etc.)
|
|
16
|
+
}
|
|
17
|
+
export function trackError(err, props) {
|
|
18
|
+
const enrichedProps = {
|
|
19
|
+
...props,
|
|
20
|
+
env: environment,
|
|
21
|
+
timestamp: new Date().toISOString(),
|
|
22
|
+
};
|
|
23
|
+
console.error("[Telemetry Error]", err, enrichedProps);
|
|
24
|
+
// Future: Send to error tracking service (Sentry, etc.)
|
|
25
|
+
}
|
|
@@ -0,0 +1,110 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Shell Type Definitions
|
|
3
|
+
*/
|
|
4
|
+
/**
|
|
5
|
+
* Module status in the registry
|
|
6
|
+
*/
|
|
7
|
+
export type ModuleStatus = "active" | "deprecated" | "disabled";
|
|
8
|
+
/**
|
|
9
|
+
* Command within a module that can be searched and invoked
|
|
10
|
+
*/
|
|
11
|
+
export interface ModuleCommand {
|
|
12
|
+
id: string;
|
|
13
|
+
title: string;
|
|
14
|
+
/** i18n key for translated title (optional) */
|
|
15
|
+
titleKey?: string;
|
|
16
|
+
keywords?: string[];
|
|
17
|
+
route: string;
|
|
18
|
+
icon?: string;
|
|
19
|
+
}
|
|
20
|
+
/**
|
|
21
|
+
* Module information as defined in the catalog
|
|
22
|
+
* Note: entry is not included - DynamicModule fetches module.manifest.json at runtime
|
|
23
|
+
*/
|
|
24
|
+
export interface Module {
|
|
25
|
+
/** Unique identifier for the module (e.g., "@admin/users") */
|
|
26
|
+
id: string;
|
|
27
|
+
/** Human-readable title */
|
|
28
|
+
title: string;
|
|
29
|
+
/** i18n key for translated title (optional) */
|
|
30
|
+
titleKey?: string;
|
|
31
|
+
/** Description of what the module does */
|
|
32
|
+
description: string;
|
|
33
|
+
/** i18n key for translated description (optional) */
|
|
34
|
+
descriptionKey?: string;
|
|
35
|
+
/** Category for navigation grouping */
|
|
36
|
+
category: string;
|
|
37
|
+
/** Base route where module is mounted (e.g., "/admin/users") */
|
|
38
|
+
routeBase: string;
|
|
39
|
+
/** Base URL where module is hosted */
|
|
40
|
+
baseUrl?: string;
|
|
41
|
+
/** Keywords for search */
|
|
42
|
+
keywords: string[];
|
|
43
|
+
/** Required permissions */
|
|
44
|
+
permissions: {
|
|
45
|
+
view: string[];
|
|
46
|
+
dangerous?: string[];
|
|
47
|
+
};
|
|
48
|
+
/** Module ownership info */
|
|
49
|
+
owners: {
|
|
50
|
+
team: string;
|
|
51
|
+
supportChannel: string;
|
|
52
|
+
};
|
|
53
|
+
/** Module status */
|
|
54
|
+
status: ModuleStatus;
|
|
55
|
+
/** Optional navigation order */
|
|
56
|
+
navOrder?: number;
|
|
57
|
+
/** Optional icon name */
|
|
58
|
+
icon?: string;
|
|
59
|
+
/** Optional commands */
|
|
60
|
+
commands?: ModuleCommand[];
|
|
61
|
+
}
|
|
62
|
+
/**
|
|
63
|
+
* Catalog structure containing all modules and metadata
|
|
64
|
+
*/
|
|
65
|
+
export interface Catalog {
|
|
66
|
+
/** Version identifier for the catalog */
|
|
67
|
+
version: string;
|
|
68
|
+
/** Timestamp when catalog was generated */
|
|
69
|
+
generatedAt: string;
|
|
70
|
+
/** Array of all registered modules */
|
|
71
|
+
modules: Module[];
|
|
72
|
+
}
|
|
73
|
+
/**
|
|
74
|
+
* ES Module Import Map structure.
|
|
75
|
+
*/
|
|
76
|
+
export interface ImportMap {
|
|
77
|
+
/** Map of module names to their URLs */
|
|
78
|
+
imports: {
|
|
79
|
+
[moduleName: string]: string;
|
|
80
|
+
};
|
|
81
|
+
}
|
|
82
|
+
/**
|
|
83
|
+
* Searchable item for command palette
|
|
84
|
+
*/
|
|
85
|
+
export interface SearchableItem {
|
|
86
|
+
type: "module" | "command";
|
|
87
|
+
id: string;
|
|
88
|
+
title: string;
|
|
89
|
+
/** i18n key for the title */
|
|
90
|
+
titleKey?: string;
|
|
91
|
+
category?: string;
|
|
92
|
+
keywords?: string[];
|
|
93
|
+
description?: string;
|
|
94
|
+
route: string;
|
|
95
|
+
moduleId?: string;
|
|
96
|
+
moduleTitle?: string;
|
|
97
|
+
/** i18n key for the module title */
|
|
98
|
+
moduleTitleKey?: string;
|
|
99
|
+
/** Icon name (Lucide icon in kebab-case) */
|
|
100
|
+
icon?: string;
|
|
101
|
+
}
|
|
102
|
+
/**
|
|
103
|
+
* Search result with score
|
|
104
|
+
*/
|
|
105
|
+
export interface SearchResult {
|
|
106
|
+
item: SearchableItem;
|
|
107
|
+
score: number;
|
|
108
|
+
matchedFields: string[];
|
|
109
|
+
}
|
|
110
|
+
//# sourceMappingURL=types.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"types.d.ts","sourceRoot":"","sources":["../../src/shell/types.ts"],"names":[],"mappings":"AAAA;;GAEG;AAEH;;GAEG;AACH,MAAM,MAAM,YAAY,GAAG,QAAQ,GAAG,YAAY,GAAG,UAAU,CAAC;AAEhE;;GAEG;AACH,MAAM,WAAW,aAAa;IAC5B,EAAE,EAAE,MAAM,CAAC;IACX,KAAK,EAAE,MAAM,CAAC;IACd,+CAA+C;IAC/C,QAAQ,CAAC,EAAE,MAAM,CAAC;IAClB,QAAQ,CAAC,EAAE,MAAM,EAAE,CAAC;IACpB,KAAK,EAAE,MAAM,CAAC;IACd,IAAI,CAAC,EAAE,MAAM,CAAC;CACf;AAED;;;GAGG;AACH,MAAM,WAAW,MAAM;IACrB,8DAA8D;IAC9D,EAAE,EAAE,MAAM,CAAC;IAEX,2BAA2B;IAC3B,KAAK,EAAE,MAAM,CAAC;IAEd,+CAA+C;IAC/C,QAAQ,CAAC,EAAE,MAAM,CAAC;IAElB,0CAA0C;IAC1C,WAAW,EAAE,MAAM,CAAC;IAEpB,qDAAqD;IACrD,cAAc,CAAC,EAAE,MAAM,CAAC;IAExB,uCAAuC;IACvC,QAAQ,EAAE,MAAM,CAAC;IAEjB,gEAAgE;IAChE,SAAS,EAAE,MAAM,CAAC;IAElB,sCAAsC;IACtC,OAAO,CAAC,EAAE,MAAM,CAAC;IAEjB,0BAA0B;IAC1B,QAAQ,EAAE,MAAM,EAAE,CAAC;IAEnB,2BAA2B;IAC3B,WAAW,EAAE;QACX,IAAI,EAAE,MAAM,EAAE,CAAC;QACf,SAAS,CAAC,EAAE,MAAM,EAAE,CAAC;KACtB,CAAC;IAEF,4BAA4B;IAC5B,MAAM,EAAE;QACN,IAAI,EAAE,MAAM,CAAC;QACb,cAAc,EAAE,MAAM,CAAC;KACxB,CAAC;IAEF,oBAAoB;IACpB,MAAM,EAAE,YAAY,CAAC;IAErB,gCAAgC;IAChC,QAAQ,CAAC,EAAE,MAAM,CAAC;IAElB,yBAAyB;IACzB,IAAI,CAAC,EAAE,MAAM,CAAC;IAEd,wBAAwB;IACxB,QAAQ,CAAC,EAAE,aAAa,EAAE,CAAC;CAC5B;AAED;;GAEG;AACH,MAAM,WAAW,OAAO;IACtB,yCAAyC;IACzC,OAAO,EAAE,MAAM,CAAC;IAEhB,2CAA2C;IAC3C,WAAW,EAAE,MAAM,CAAC;IAEpB,sCAAsC;IACtC,OAAO,EAAE,MAAM,EAAE,CAAC;CACnB;AAED;;GAEG;AACH,MAAM,WAAW,SAAS;IACxB,wCAAwC;IACxC,OAAO,EAAE;QACP,CAAC,UAAU,EAAE,MAAM,GAAG,MAAM,CAAC;KAC9B,CAAC;CACH;AAED;;GAEG;AACH,MAAM,WAAW,cAAc;IAC7B,IAAI,EAAE,QAAQ,GAAG,SAAS,CAAC;IAC3B,EAAE,EAAE,MAAM,CAAC;IACX,KAAK,EAAE,MAAM,CAAC;IACd,6BAA6B;IAC7B,QAAQ,CAAC,EAAE,MAAM,CAAC;IAClB,QAAQ,CAAC,EAAE,MAAM,CAAC;IAClB,QAAQ,CAAC,EAAE,MAAM,EAAE,CAAC;IACpB,WAAW,CAAC,EAAE,MAAM,CAAC;IACrB,KAAK,EAAE,MAAM,CAAC;IACd,QAAQ,CAAC,EAAE,MAAM,CAAC;IAClB,WAAW,CAAC,EAAE,MAAM,CAAC;IACrB,oCAAoC;IACpC,cAAc,CAAC,EAAE,MAAM,CAAC;IACxB,4CAA4C;IAC5C,IAAI,CAAC,EAAE,MAAM,CAAC;CACf;AAED;;GAEG;AACH,MAAM,WAAW,YAAY;IAC3B,IAAI,EAAE,cAAc,CAAC;IACrB,KAAK,EAAE,MAAM,CAAC;IACd,aAAa,EAAE,MAAM,EAAE,CAAC;CACzB"}
|
|
@@ -0,0 +1,20 @@
|
|
|
1
|
+
import type { Config } from "tailwindcss";
|
|
2
|
+
/**
|
|
3
|
+
* Returns Tailwind content paths for SDK and UI packages.
|
|
4
|
+
* Automatically detects monorepo (src/) vs npm install (dist/).
|
|
5
|
+
*/
|
|
6
|
+
export declare function getAdminContentPaths(): string[];
|
|
7
|
+
/**
|
|
8
|
+
* Wraps your Tailwind config with admin SDK preset and content paths.
|
|
9
|
+
*
|
|
10
|
+
* @example
|
|
11
|
+
* ```js
|
|
12
|
+
* import { withAdminSdk } from "@nsxbet/admin-sdk/tailwind";
|
|
13
|
+
*
|
|
14
|
+
* export default withAdminSdk({
|
|
15
|
+
* content: ["./index.html", "./src/**\/*.{ts,tsx}"],
|
|
16
|
+
* });
|
|
17
|
+
* ```
|
|
18
|
+
*/
|
|
19
|
+
export declare function withAdminSdk(config?: Partial<Config>): Config;
|
|
20
|
+
//# sourceMappingURL=index.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../src/tailwind/index.ts"],"names":[],"mappings":"AAGA,OAAO,KAAK,EAAE,MAAM,EAAE,MAAM,aAAa,CAAC;AAG1C;;;GAGG;AACH,wBAAgB,oBAAoB,IAAI,MAAM,EAAE,CAgB/C;AAED;;;;;;;;;;;GAWG;AACH,wBAAgB,YAAY,CAAC,MAAM,GAAE,OAAO,CAAC,MAAM,CAAM,GAAG,MAAM,CAUjE"}
|
|
@@ -0,0 +1,42 @@
|
|
|
1
|
+
import { dirname } from "path";
|
|
2
|
+
import { existsSync } from "fs";
|
|
3
|
+
import { createRequire } from "module";
|
|
4
|
+
import { preset } from "@nsxbet/admin-ui/tailwind-preset";
|
|
5
|
+
/**
|
|
6
|
+
* Returns Tailwind content paths for SDK and UI packages.
|
|
7
|
+
* Automatically detects monorepo (src/) vs npm install (dist/).
|
|
8
|
+
*/
|
|
9
|
+
export function getAdminContentPaths() {
|
|
10
|
+
const require = createRequire(import.meta.url);
|
|
11
|
+
const sdkPath = dirname(require.resolve("@nsxbet/admin-sdk/package.json"));
|
|
12
|
+
const uiPath = dirname(require.resolve("@nsxbet/admin-ui/package.json"));
|
|
13
|
+
// Prefer src/ if available (monorepo), fallback to dist/ (published npm)
|
|
14
|
+
const sdkDir = existsSync(`${sdkPath}/src`) ? "src" : "dist";
|
|
15
|
+
const uiDir = existsSync(`${uiPath}/src`) ? "src" : "dist";
|
|
16
|
+
return [
|
|
17
|
+
`${sdkPath}/${sdkDir}/**/*.{ts,tsx,js}`,
|
|
18
|
+
`${uiPath}/${uiDir}/**/*.{ts,tsx,js}`,
|
|
19
|
+
];
|
|
20
|
+
}
|
|
21
|
+
/**
|
|
22
|
+
* Wraps your Tailwind config with admin SDK preset and content paths.
|
|
23
|
+
*
|
|
24
|
+
* @example
|
|
25
|
+
* ```js
|
|
26
|
+
* import { withAdminSdk } from "@nsxbet/admin-sdk/tailwind";
|
|
27
|
+
*
|
|
28
|
+
* export default withAdminSdk({
|
|
29
|
+
* content: ["./index.html", "./src/**\/*.{ts,tsx}"],
|
|
30
|
+
* });
|
|
31
|
+
* ```
|
|
32
|
+
*/
|
|
33
|
+
export function withAdminSdk(config = {}) {
|
|
34
|
+
const adminContent = getAdminContentPaths();
|
|
35
|
+
const userContent = config.content ?? [];
|
|
36
|
+
const userPresets = config.presets ?? [];
|
|
37
|
+
return {
|
|
38
|
+
...config,
|
|
39
|
+
presets: [preset, ...userPresets],
|
|
40
|
+
content: [...(Array.isArray(userContent) ? userContent : []), ...adminContent],
|
|
41
|
+
};
|
|
42
|
+
}
|
|
@@ -0,0 +1,26 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Keycloak configuration for standalone mode
|
|
3
|
+
*/
|
|
4
|
+
export interface KeycloakConfig {
|
|
5
|
+
/** Keycloak server URL (default: http://localhost:8080) */
|
|
6
|
+
url?: string;
|
|
7
|
+
/** Keycloak realm (default: admin) */
|
|
8
|
+
realm?: string;
|
|
9
|
+
/** Keycloak client ID (required) */
|
|
10
|
+
clientId: string;
|
|
11
|
+
}
|
|
12
|
+
/**
|
|
13
|
+
* Keycloak token parsed data
|
|
14
|
+
*/
|
|
15
|
+
export interface KeycloakTokenParsed {
|
|
16
|
+
sub?: string;
|
|
17
|
+
email?: string;
|
|
18
|
+
name?: string;
|
|
19
|
+
preferred_username?: string;
|
|
20
|
+
given_name?: string;
|
|
21
|
+
family_name?: string;
|
|
22
|
+
realm_access?: {
|
|
23
|
+
roles?: string[];
|
|
24
|
+
};
|
|
25
|
+
}
|
|
26
|
+
//# sourceMappingURL=keycloak.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"keycloak.d.ts","sourceRoot":"","sources":["../../src/types/keycloak.ts"],"names":[],"mappings":"AAAA;;GAEG;AACH,MAAM,WAAW,cAAc;IAC7B,2DAA2D;IAC3D,GAAG,CAAC,EAAE,MAAM,CAAC;IAEb,sCAAsC;IACtC,KAAK,CAAC,EAAE,MAAM,CAAC;IAEf,oCAAoC;IACpC,QAAQ,EAAE,MAAM,CAAC;CAClB;AAED;;GAEG;AACH,MAAM,WAAW,mBAAmB;IAClC,GAAG,CAAC,EAAE,MAAM,CAAC;IACb,KAAK,CAAC,EAAE,MAAM,CAAC;IACf,IAAI,CAAC,EAAE,MAAM,CAAC;IACd,kBAAkB,CAAC,EAAE,MAAM,CAAC;IAC5B,UAAU,CAAC,EAAE,MAAM,CAAC;IACpB,WAAW,CAAC,EAAE,MAAM,CAAC;IACrB,YAAY,CAAC,EAAE;QACb,KAAK,CAAC,EAAE,MAAM,EAAE,CAAC;KAClB,CAAC;CACH"}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export {};
|
|
@@ -0,0 +1,83 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Platform API type definitions
|
|
3
|
+
* These types define the global API exposed by the admin shell
|
|
4
|
+
*/
|
|
5
|
+
/**
|
|
6
|
+
* Breadcrumb item for navigation
|
|
7
|
+
*/
|
|
8
|
+
export interface Breadcrumb {
|
|
9
|
+
label: string;
|
|
10
|
+
href?: string;
|
|
11
|
+
}
|
|
12
|
+
/**
|
|
13
|
+
* User information
|
|
14
|
+
*/
|
|
15
|
+
export interface User {
|
|
16
|
+
id: string;
|
|
17
|
+
email: string;
|
|
18
|
+
displayName: string;
|
|
19
|
+
}
|
|
20
|
+
/**
|
|
21
|
+
* Platform API exposed by the admin shell at window.__ADMIN_PLATFORM_API__
|
|
22
|
+
*/
|
|
23
|
+
export interface PlatformAPI {
|
|
24
|
+
/** Current environment (e.g., 'local', 'dev', 'staging', 'prod') */
|
|
25
|
+
env: string;
|
|
26
|
+
/** Current locale (e.g., 'en-US', 'pt-BR') */
|
|
27
|
+
locale: string;
|
|
28
|
+
/** Authentication methods */
|
|
29
|
+
auth: {
|
|
30
|
+
/** Get the current access token (auto-refreshed by shell) */
|
|
31
|
+
getAccessToken: () => Promise<string>;
|
|
32
|
+
/** Check if user has a specific permission (realm role) */
|
|
33
|
+
hasPermission: (permission: string) => boolean;
|
|
34
|
+
/** Get current user information */
|
|
35
|
+
getUser: () => User;
|
|
36
|
+
/** Log out the current user */
|
|
37
|
+
logout: () => void;
|
|
38
|
+
};
|
|
39
|
+
/** Navigation methods */
|
|
40
|
+
nav: {
|
|
41
|
+
/** Navigate to a path (e.g., '/admin/users') */
|
|
42
|
+
navigate: (path: string) => void;
|
|
43
|
+
/** Set breadcrumbs for current page */
|
|
44
|
+
setBreadcrumbs: (items: Breadcrumb[]) => void;
|
|
45
|
+
};
|
|
46
|
+
/** Internationalization methods */
|
|
47
|
+
i18n: {
|
|
48
|
+
/** Current locale */
|
|
49
|
+
locale: string;
|
|
50
|
+
/** Change the locale */
|
|
51
|
+
setLocale: (locale: string) => void;
|
|
52
|
+
/** Subscribe to locale changes, returns unsubscribe function */
|
|
53
|
+
onLocaleChange: (callback: (locale: string) => void) => () => void;
|
|
54
|
+
};
|
|
55
|
+
/** Telemetry methods */
|
|
56
|
+
telemetry: {
|
|
57
|
+
/** Track an event */
|
|
58
|
+
track: (event: string, props?: Record<string, unknown>) => void;
|
|
59
|
+
/** Track an error */
|
|
60
|
+
trackError: (err: unknown, props?: Record<string, unknown>) => void;
|
|
61
|
+
};
|
|
62
|
+
/** Authenticated fetch wrapper */
|
|
63
|
+
fetch: (input: RequestInfo | URL, init?: RequestInit) => Promise<Response>;
|
|
64
|
+
}
|
|
65
|
+
/**
|
|
66
|
+
* Keycloak configuration stored in window
|
|
67
|
+
*/
|
|
68
|
+
export interface KeycloakWindowConfig {
|
|
69
|
+
url: string;
|
|
70
|
+
realm: string;
|
|
71
|
+
clientId: string;
|
|
72
|
+
}
|
|
73
|
+
/**
|
|
74
|
+
* Extend Window interface to include platform API
|
|
75
|
+
*/
|
|
76
|
+
declare global {
|
|
77
|
+
interface Window {
|
|
78
|
+
__ADMIN_PLATFORM_API__?: PlatformAPI;
|
|
79
|
+
__KEYCLOAK_CONFIG__?: KeycloakWindowConfig;
|
|
80
|
+
}
|
|
81
|
+
}
|
|
82
|
+
export {};
|
|
83
|
+
//# sourceMappingURL=platform.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"platform.d.ts","sourceRoot":"","sources":["../../src/types/platform.ts"],"names":[],"mappings":"AAAA;;;GAGG;AAEH;;GAEG;AACH,MAAM,WAAW,UAAU;IACzB,KAAK,EAAE,MAAM,CAAC;IACd,IAAI,CAAC,EAAE,MAAM,CAAC;CACf;AAED;;GAEG;AACH,MAAM,WAAW,IAAI;IACnB,EAAE,EAAE,MAAM,CAAC;IACX,KAAK,EAAE,MAAM,CAAC;IACd,WAAW,EAAE,MAAM,CAAC;CACrB;AAED;;GAEG;AACH,MAAM,WAAW,WAAW;IAC1B,oEAAoE;IACpE,GAAG,EAAE,MAAM,CAAC;IAEZ,8CAA8C;IAC9C,MAAM,EAAE,MAAM,CAAC;IAEf,6BAA6B;IAC7B,IAAI,EAAE;QACJ,6DAA6D;QAC7D,cAAc,EAAE,MAAM,OAAO,CAAC,MAAM,CAAC,CAAC;QAEtC,2DAA2D;QAC3D,aAAa,EAAE,CAAC,UAAU,EAAE,MAAM,KAAK,OAAO,CAAC;QAE/C,mCAAmC;QACnC,OAAO,EAAE,MAAM,IAAI,CAAC;QAEpB,+BAA+B;QAC/B,MAAM,EAAE,MAAM,IAAI,CAAC;KACpB,CAAC;IAEF,yBAAyB;IACzB,GAAG,EAAE;QACH,gDAAgD;QAChD,QAAQ,EAAE,CAAC,IAAI,EAAE,MAAM,KAAK,IAAI,CAAC;QAEjC,uCAAuC;QACvC,cAAc,EAAE,CAAC,KAAK,EAAE,UAAU,EAAE,KAAK,IAAI,CAAC;KAC/C,CAAC;IAEF,mCAAmC;IACnC,IAAI,EAAE;QACJ,qBAAqB;QACrB,MAAM,EAAE,MAAM,CAAC;QAEf,wBAAwB;QACxB,SAAS,EAAE,CAAC,MAAM,EAAE,MAAM,KAAK,IAAI,CAAC;QAEpC,gEAAgE;QAChE,cAAc,EAAE,CAAC,QAAQ,EAAE,CAAC,MAAM,EAAE,MAAM,KAAK,IAAI,KAAK,MAAM,IAAI,CAAC;KACpE,CAAC;IAEF,wBAAwB;IACxB,SAAS,EAAE;QACT,qBAAqB;QACrB,KAAK,EAAE,CAAC,KAAK,EAAE,MAAM,EAAE,KAAK,CAAC,EAAE,MAAM,CAAC,MAAM,EAAE,OAAO,CAAC,KAAK,IAAI,CAAC;QAEhE,qBAAqB;QACrB,UAAU,EAAE,CAAC,GAAG,EAAE,OAAO,EAAE,KAAK,CAAC,EAAE,MAAM,CAAC,MAAM,EAAE,OAAO,CAAC,KAAK,IAAI,CAAC;KACrE,CAAC;IAEF,kCAAkC;IAClC,KAAK,EAAE,CAAC,KAAK,EAAE,WAAW,GAAG,GAAG,EAAE,IAAI,CAAC,EAAE,WAAW,KAAK,OAAO,CAAC,QAAQ,CAAC,CAAC;CAC5E;AAED;;GAEG;AACH,MAAM,WAAW,oBAAoB;IACnC,GAAG,EAAE,MAAM,CAAC;IACZ,KAAK,EAAE,MAAM,CAAC;IACd,QAAQ,EAAE,MAAM,CAAC;CAClB;AAED;;GAEG;AACH,OAAO,CAAC,MAAM,CAAC;IACb,UAAU,MAAM;QACd,sBAAsB,CAAC,EAAE,WAAW,CAAC;QACrC,mBAAmB,CAAC,EAAE,oBAAoB,CAAC;KAC5C;CACF;AAED,OAAO,EAAE,CAAC"}
|
|
@@ -0,0 +1,71 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Shared dependencies that are externalized in module builds.
|
|
3
|
+
* These are provided by the shell via import maps.
|
|
4
|
+
*/
|
|
5
|
+
export declare const SHARED_EXTERNALS: readonly ["react", "react-dom", "react-router-dom", "i18next", "react-i18next"];
|
|
6
|
+
export interface ModuleConfigOptions {
|
|
7
|
+
/**
|
|
8
|
+
* Development server port
|
|
9
|
+
*/
|
|
10
|
+
port: number;
|
|
11
|
+
/**
|
|
12
|
+
* Entry file for the module SPA
|
|
13
|
+
* @default "./src/spa.tsx"
|
|
14
|
+
*/
|
|
15
|
+
entry?: string;
|
|
16
|
+
/**
|
|
17
|
+
* Output directory for built files
|
|
18
|
+
* @default "dist"
|
|
19
|
+
*/
|
|
20
|
+
outDir?: string;
|
|
21
|
+
/**
|
|
22
|
+
* Additional externals to add to SHARED_EXTERNALS
|
|
23
|
+
*/
|
|
24
|
+
additionalExternals?: string[];
|
|
25
|
+
/**
|
|
26
|
+
* Additional Vite plugins (will be spread into plugins array)
|
|
27
|
+
*/
|
|
28
|
+
plugins?: any[];
|
|
29
|
+
/**
|
|
30
|
+
* Override any Vite config options
|
|
31
|
+
*/
|
|
32
|
+
overrides?: Record<string, any>;
|
|
33
|
+
}
|
|
34
|
+
/**
|
|
35
|
+
* Creates a pre-configured Vite config for admin modules.
|
|
36
|
+
*
|
|
37
|
+
* **Note:** This function does NOT include the React plugin automatically.
|
|
38
|
+
* You must import and add it yourself to avoid version conflicts.
|
|
39
|
+
*
|
|
40
|
+
* Includes:
|
|
41
|
+
* - serveDistPlugin (serves dist files during dev)
|
|
42
|
+
* - generateModuleManifestPlugin (generates module.manifest.json)
|
|
43
|
+
* - ES module build format
|
|
44
|
+
* - Externalized shared dependencies
|
|
45
|
+
*
|
|
46
|
+
* @example
|
|
47
|
+
* ```ts
|
|
48
|
+
* // vite.config.ts
|
|
49
|
+
* import { defineModuleConfig } from "@nsxbet/admin-sdk/vite";
|
|
50
|
+
* import react from "@vitejs/plugin-react";
|
|
51
|
+
*
|
|
52
|
+
* export default defineModuleConfig({
|
|
53
|
+
* port: 3003,
|
|
54
|
+
* plugins: [react()],
|
|
55
|
+
* });
|
|
56
|
+
* ```
|
|
57
|
+
*
|
|
58
|
+
* @example With customization
|
|
59
|
+
* ```ts
|
|
60
|
+
* import { defineModuleConfig } from "@nsxbet/admin-sdk/vite";
|
|
61
|
+
* import react from "@vitejs/plugin-react";
|
|
62
|
+
*
|
|
63
|
+
* export default defineModuleConfig({
|
|
64
|
+
* port: 3003,
|
|
65
|
+
* plugins: [react(), myCustomPlugin()],
|
|
66
|
+
* additionalExternals: ["lodash"],
|
|
67
|
+
* });
|
|
68
|
+
* ```
|
|
69
|
+
*/
|
|
70
|
+
export declare function defineModuleConfig(options: ModuleConfigOptions): any;
|
|
71
|
+
//# sourceMappingURL=config.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"config.d.ts","sourceRoot":"","sources":["../../src/vite/config.ts"],"names":[],"mappings":"AAEA;;;GAGG;AACH,eAAO,MAAM,gBAAgB,iFAMnB,CAAC;AAEX,MAAM,WAAW,mBAAmB;IAClC;;OAEG;IACH,IAAI,EAAE,MAAM,CAAC;IAEb;;;OAGG;IACH,KAAK,CAAC,EAAE,MAAM,CAAC;IAEf;;;OAGG;IACH,MAAM,CAAC,EAAE,MAAM,CAAC;IAEhB;;OAEG;IACH,mBAAmB,CAAC,EAAE,MAAM,EAAE,CAAC;IAE/B;;OAEG;IAEH,OAAO,CAAC,EAAE,GAAG,EAAE,CAAC;IAEhB;;OAEG;IAEH,SAAS,CAAC,EAAE,MAAM,CAAC,MAAM,EAAE,GAAG,CAAC,CAAC;CACjC;AAED;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;GAmCG;AAEH,wBAAgB,kBAAkB,CAAC,OAAO,EAAE,mBAAmB,GAAG,GAAG,CA8CpE"}
|
|
@@ -0,0 +1,87 @@
|
|
|
1
|
+
import { generateModuleManifestPlugin, serveDistPlugin } from "./plugins.js";
|
|
2
|
+
/**
|
|
3
|
+
* Shared dependencies that are externalized in module builds.
|
|
4
|
+
* These are provided by the shell via import maps.
|
|
5
|
+
*/
|
|
6
|
+
export const SHARED_EXTERNALS = [
|
|
7
|
+
"react",
|
|
8
|
+
"react-dom",
|
|
9
|
+
"react-router-dom",
|
|
10
|
+
"i18next",
|
|
11
|
+
"react-i18next",
|
|
12
|
+
];
|
|
13
|
+
/**
|
|
14
|
+
* Creates a pre-configured Vite config for admin modules.
|
|
15
|
+
*
|
|
16
|
+
* **Note:** This function does NOT include the React plugin automatically.
|
|
17
|
+
* You must import and add it yourself to avoid version conflicts.
|
|
18
|
+
*
|
|
19
|
+
* Includes:
|
|
20
|
+
* - serveDistPlugin (serves dist files during dev)
|
|
21
|
+
* - generateModuleManifestPlugin (generates module.manifest.json)
|
|
22
|
+
* - ES module build format
|
|
23
|
+
* - Externalized shared dependencies
|
|
24
|
+
*
|
|
25
|
+
* @example
|
|
26
|
+
* ```ts
|
|
27
|
+
* // vite.config.ts
|
|
28
|
+
* import { defineModuleConfig } from "@nsxbet/admin-sdk/vite";
|
|
29
|
+
* import react from "@vitejs/plugin-react";
|
|
30
|
+
*
|
|
31
|
+
* export default defineModuleConfig({
|
|
32
|
+
* port: 3003,
|
|
33
|
+
* plugins: [react()],
|
|
34
|
+
* });
|
|
35
|
+
* ```
|
|
36
|
+
*
|
|
37
|
+
* @example With customization
|
|
38
|
+
* ```ts
|
|
39
|
+
* import { defineModuleConfig } from "@nsxbet/admin-sdk/vite";
|
|
40
|
+
* import react from "@vitejs/plugin-react";
|
|
41
|
+
*
|
|
42
|
+
* export default defineModuleConfig({
|
|
43
|
+
* port: 3003,
|
|
44
|
+
* plugins: [react(), myCustomPlugin()],
|
|
45
|
+
* additionalExternals: ["lodash"],
|
|
46
|
+
* });
|
|
47
|
+
* ```
|
|
48
|
+
*/
|
|
49
|
+
// eslint-disable-next-line @typescript-eslint/no-explicit-any
|
|
50
|
+
export function defineModuleConfig(options) {
|
|
51
|
+
const { port, entry = "./src/spa.tsx", outDir = "dist", additionalExternals = [], plugins = [], overrides = {}, } = options;
|
|
52
|
+
const externals = [...SHARED_EXTERNALS, ...additionalExternals];
|
|
53
|
+
return {
|
|
54
|
+
plugins: [
|
|
55
|
+
serveDistPlugin({ distDir: outDir }),
|
|
56
|
+
generateModuleManifestPlugin(),
|
|
57
|
+
...plugins,
|
|
58
|
+
],
|
|
59
|
+
define: {
|
|
60
|
+
"process.env": {},
|
|
61
|
+
"process.env.NODE_ENV": JSON.stringify("production"),
|
|
62
|
+
},
|
|
63
|
+
build: {
|
|
64
|
+
outDir,
|
|
65
|
+
emptyOutDir: true,
|
|
66
|
+
lib: {
|
|
67
|
+
entry,
|
|
68
|
+
formats: ["es"],
|
|
69
|
+
fileName: () => `assets/spa-[hash].js`,
|
|
70
|
+
},
|
|
71
|
+
rollupOptions: {
|
|
72
|
+
external: externals,
|
|
73
|
+
output: {
|
|
74
|
+
entryFileNames: "assets/[name]-[hash].js",
|
|
75
|
+
chunkFileNames: "assets/[name]-[hash].js",
|
|
76
|
+
},
|
|
77
|
+
},
|
|
78
|
+
},
|
|
79
|
+
server: {
|
|
80
|
+
port,
|
|
81
|
+
},
|
|
82
|
+
preview: {
|
|
83
|
+
port,
|
|
84
|
+
},
|
|
85
|
+
...overrides,
|
|
86
|
+
};
|
|
87
|
+
}
|
|
@@ -0,0 +1,18 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Vite utilities for building admin modules.
|
|
3
|
+
*
|
|
4
|
+
* @example
|
|
5
|
+
* ```ts
|
|
6
|
+
* // vite.config.ts
|
|
7
|
+
* import { defineModuleConfig } from "@nsxbet/admin-sdk/vite";
|
|
8
|
+
*
|
|
9
|
+
* export default defineModuleConfig({
|
|
10
|
+
* port: 3003,
|
|
11
|
+
* });
|
|
12
|
+
* ```
|
|
13
|
+
*
|
|
14
|
+
* @packageDocumentation
|
|
15
|
+
*/
|
|
16
|
+
export { generateModuleManifestPlugin, serveDistPlugin, type GenerateModuleManifestPluginOptions, type ServeDistPluginOptions, } from "./plugins.js";
|
|
17
|
+
export { defineModuleConfig, SHARED_EXTERNALS, type ModuleConfigOptions, } from "./config.js";
|
|
18
|
+
//# sourceMappingURL=index.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../src/vite/index.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;GAcG;AAEH,OAAO,EACL,4BAA4B,EAC5B,eAAe,EACf,KAAK,mCAAmC,EACxC,KAAK,sBAAsB,GAC5B,MAAM,cAAc,CAAC;AAEtB,OAAO,EACL,kBAAkB,EAClB,gBAAgB,EAChB,KAAK,mBAAmB,GACzB,MAAM,aAAa,CAAC"}
|