@nextsparkjs/core 0.1.0-beta.14 → 0.1.0-beta.16
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/dist/components/dashboard/layouts/DashboardShell.d.ts +1 -1
- package/dist/components/dashboard/layouts/DashboardShell.d.ts.map +1 -1
- package/dist/components/dashboard/layouts/DashboardShell.js +8 -0
- package/dist/lib/entities/queries.d.ts +17 -0
- package/dist/lib/entities/queries.d.ts.map +1 -1
- package/dist/lib/entities/queries.js +24 -0
- package/dist/lib/entities/registry.client.d.ts +1 -1
- package/dist/lib/entities/registry.client.d.ts.map +1 -1
- package/dist/lib/entities/registry.client.js +3 -22
- package/dist/lib/entities/registry.d.ts +25 -13
- package/dist/lib/entities/registry.d.ts.map +1 -1
- package/dist/lib/entities/registry.js +50 -55
- package/dist/styles/classes.json +1 -1
- package/package.json +1 -1
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import type
|
|
1
|
+
import { type SerializableEntityConfig } from '../../../lib/entities/serialization';
|
|
2
2
|
interface DashboardShellProps {
|
|
3
3
|
children: React.ReactNode;
|
|
4
4
|
entities: SerializableEntityConfig[];
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"DashboardShell.d.ts","sourceRoot":"","sources":["../../../../src/components/dashboard/layouts/DashboardShell.tsx"],"names":[],"mappings":"AAQA,OAAO,KAAK,
|
|
1
|
+
{"version":3,"file":"DashboardShell.d.ts","sourceRoot":"","sources":["../../../../src/components/dashboard/layouts/DashboardShell.tsx"],"names":[],"mappings":"AAQA,OAAO,EAA2B,KAAK,wBAAwB,EAAE,MAAM,qCAAqC,CAAA;AAG5G,UAAU,mBAAmB;IAC3B,QAAQ,EAAE,KAAK,CAAC,SAAS,CAAA;IACzB,QAAQ,EAAE,wBAAwB,EAAE,CAAA;CACrC;AAkDD,wBAAgB,cAAc,CAAC,EAAE,QAAQ,EAAE,QAAQ,EAAE,EAAE,mBAAmB,2CAQzE"}
|
|
@@ -6,8 +6,16 @@ import { MobileTopBar } from "../mobile/MobileTopBar";
|
|
|
6
6
|
import { MobileBottomNav } from "../mobile/MobileBottomNav";
|
|
7
7
|
import { SidebarProvider, useSidebar } from "../../../contexts/sidebar-context";
|
|
8
8
|
import { cn } from "../../../lib/utils";
|
|
9
|
+
import { deserializeEntityConfig } from "../../../lib/entities/serialization";
|
|
10
|
+
import { setServerEntities } from "../../../lib/entities/registry.client";
|
|
11
|
+
let clientHydrated = false;
|
|
9
12
|
function DashboardShellContent({ children, entities }) {
|
|
10
13
|
const { isCollapsed } = useSidebar();
|
|
14
|
+
if (!clientHydrated && entities.length > 0) {
|
|
15
|
+
const deserializedEntities = entities.map(deserializeEntityConfig);
|
|
16
|
+
setServerEntities(deserializedEntities);
|
|
17
|
+
clientHydrated = true;
|
|
18
|
+
}
|
|
11
19
|
return /* @__PURE__ */ jsxs("div", { className: "min-h-screen", children: [
|
|
12
20
|
/* @__PURE__ */ jsx(Sidebar, { className: "hidden lg:flex", entities }),
|
|
13
21
|
/* @__PURE__ */ jsx(TopNavbar, { className: "hidden lg:flex", entities }),
|
|
@@ -51,6 +51,23 @@ export interface EntityOwner {
|
|
|
51
51
|
* (webpack resolves the @nextsparkjs/registries alias at compile time)
|
|
52
52
|
*/
|
|
53
53
|
export declare function setEntityRegistry(registry: Record<string, EntityRegistryEntry>, metadata?: EntityRegistryMetadata): void;
|
|
54
|
+
/**
|
|
55
|
+
* Add a single entity to the registry
|
|
56
|
+
* Used by EntityRegistry.register() for programmatic registration
|
|
57
|
+
*/
|
|
58
|
+
export declare function addEntityToRegistry(entry: EntityRegistryEntry): void;
|
|
59
|
+
/**
|
|
60
|
+
* Remove an entity from the registry
|
|
61
|
+
*/
|
|
62
|
+
export declare function removeEntityFromRegistry(name: string): boolean;
|
|
63
|
+
/**
|
|
64
|
+
* Clear the registry (for testing)
|
|
65
|
+
*/
|
|
66
|
+
export declare function clearEntityRegistry(): void;
|
|
67
|
+
/**
|
|
68
|
+
* Check if registry is initialized
|
|
69
|
+
*/
|
|
70
|
+
export declare function isRegistryInitialized(): boolean;
|
|
54
71
|
/**
|
|
55
72
|
* Get all registered entity configs
|
|
56
73
|
*/
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"queries.d.ts","sourceRoot":"","sources":["../../../src/lib/entities/queries.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;GAUG;AAEH,OAAO,KAAK,EAAE,YAAY,EAAE,qBAAqB,EAAE,MAAM,SAAS,CAAA;AAElE;;;;GAIG;AACH,MAAM,WAAW,mBAAmB;IAClC,IAAI,EAAE,MAAM,CAAA;IACZ,MAAM,EAAE,YAAY,GAAG,qBAAqB,CAAA;IAC5C,MAAM,EAAE,MAAM,GAAG,IAAI,CAAA;IACrB,QAAQ,EAAE,MAAM,EAAE,CAAA;IAClB,KAAK,EAAE,MAAM,CAAA;IACb,SAAS,EAAE,MAAM,CAAA;IACjB,WAAW,EAAE,MAAM,CAAA;IACnB,aAAa,CAAC,EAAE;QACd,UAAU,EAAE,MAAM,CAAA;QAClB,SAAS,EAAE,MAAM,CAAA;KAClB,CAAA;IACD,YAAY,CAAC,EAAE;QACb,SAAS,EAAE,MAAM,CAAA;QACjB,QAAQ,EAAE,MAAM,CAAA;KACjB,CAAA;IACD,MAAM,CAAC,EAAE,GAAG,CAAA;IACZ,SAAS,CAAC,EAAE,GAAG,CAAA;CAChB;AAED,MAAM,WAAW,sBAAsB;IACrC,aAAa,EAAE,MAAM,CAAA;IACrB,YAAY,EAAE,MAAM,CAAA;IACpB,QAAQ,EAAE,MAAM,CAAA;IAChB,WAAW,EAAE,MAAM,CAAA;IACnB,WAAW,EAAE,MAAM,EAAE,CAAA;CACtB;AAED,MAAM,WAAW,WAAW;IAC1B,IAAI,EAAE,QAAQ,GAAG,OAAO,CAAA;IACxB,IAAI,EAAE,MAAM,CAAA;CACb;AAMD;;;;GAIG;AACH,wBAAgB,iBAAiB,CAC/B,QAAQ,EAAE,MAAM,CAA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,GAAG,mBAAmB,GAAG,SAAS,CAEvF;AAED;;GAEG;AACH,wBAAgB,iBAAiB,CAAC,UAAU,EAAE,MAAM,GAAG,mBAAmB,EAAE,CAI3E;AAED;;GAEG;AACH,wBAAgB,gBAAgB,CAAC,SAAS,EAAE,MAAM,GAAG,mBAAmB,EAAE,CAIzE;AAED;;GAEG;AACH,wBAAgB,cAAc,CAAC,UAAU,EAAE,MAAM,GAAG,WAAW,GAAG,IAAI,CAWrE;AAED;;GAEG;AACH,wBAAgB,eAAe,CAAC,IAAI,EAAE,MAAM,GAAG,YAAY,GAAG,SAAS,CAItE;AAED;;GAEG;AACH,wBAAgB,yBAAyB,IAAI,sBAAsB,GAAG,IAAI,CAIzE;AAED;;;GAGG;AACH,wBAAgB,iBAAiB,IAAI,MAAM,CAAC,MAAM,EAAE,mBAAmB,CAAC,CAEvE"}
|
|
@@ -6,6 +6,26 @@ function setEntityRegistry(registry, metadata) {
|
|
|
6
6
|
const entityCount = Object.keys(registry || {}).length;
|
|
7
7
|
console.log(`[EntityQueries] Registry set with ${entityCount} entities`);
|
|
8
8
|
}
|
|
9
|
+
function addEntityToRegistry(entry) {
|
|
10
|
+
if (!_cachedRegistry) {
|
|
11
|
+
_cachedRegistry = {};
|
|
12
|
+
}
|
|
13
|
+
_cachedRegistry[entry.name] = entry;
|
|
14
|
+
}
|
|
15
|
+
function removeEntityFromRegistry(name) {
|
|
16
|
+
if (!_cachedRegistry || !_cachedRegistry[name]) {
|
|
17
|
+
return false;
|
|
18
|
+
}
|
|
19
|
+
delete _cachedRegistry[name];
|
|
20
|
+
return true;
|
|
21
|
+
}
|
|
22
|
+
function clearEntityRegistry() {
|
|
23
|
+
_cachedRegistry = null;
|
|
24
|
+
_cachedMetadata = null;
|
|
25
|
+
}
|
|
26
|
+
function isRegistryInitialized() {
|
|
27
|
+
return _cachedRegistry !== null && Object.keys(_cachedRegistry).length > 0;
|
|
28
|
+
}
|
|
9
29
|
function getRegistry() {
|
|
10
30
|
if (_cachedRegistry) return _cachedRegistry;
|
|
11
31
|
console.log("[EntityQueries] Registry not yet initialized (will be set by layout)");
|
|
@@ -90,6 +110,8 @@ function getEntityRegistry() {
|
|
|
90
110
|
return getRegistry();
|
|
91
111
|
}
|
|
92
112
|
export {
|
|
113
|
+
addEntityToRegistry,
|
|
114
|
+
clearEntityRegistry,
|
|
93
115
|
getChildEntities,
|
|
94
116
|
getEntitiesByDepth,
|
|
95
117
|
getEntity,
|
|
@@ -105,5 +127,7 @@ export {
|
|
|
105
127
|
getRegisteredEntities,
|
|
106
128
|
getRootEntities,
|
|
107
129
|
getThemeEntities,
|
|
130
|
+
isRegistryInitialized,
|
|
131
|
+
removeEntityFromRegistry,
|
|
108
132
|
setEntityRegistry
|
|
109
133
|
};
|
|
@@ -39,7 +39,7 @@ export declare const clientEntityRegistry: ClientEntityRegistry;
|
|
|
39
39
|
export declare function setServerEntities(entities: EntityConfig[]): void;
|
|
40
40
|
/**
|
|
41
41
|
* Client-safe function to get all entity configurations
|
|
42
|
-
*
|
|
42
|
+
* Returns entities from the client registry (populated by DashboardShell)
|
|
43
43
|
*/
|
|
44
44
|
export declare function getAllEntityConfigs(): EntityConfig[];
|
|
45
45
|
/**
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"registry.client.d.ts","sourceRoot":"","sources":["../../../src/lib/entities/registry.client.ts"],"names":[],"mappings":"AAAA;;;;;GAKG;AAIH,OAAO,KAAK,EAAE,YAAY,EAAE,MAAM,SAAS,CAAA;AAE3C;;GAEG;AACH,cAAM,oBAAoB;IACxB,OAAO,CAAC,QAAQ,CAAuC;IAEvD;;OAEG;IACH,QAAQ,CAAC,MAAM,EAAE,YAAY,GAAG,IAAI;IAIpC;;OAEG;IACH,GAAG,CAAC,IAAI,EAAE,MAAM,GAAG,YAAY,GAAG,SAAS;IAI3C;;OAEG;IACH,MAAM,IAAI,YAAY,EAAE;IAIxB;;OAEG;IACH,UAAU,IAAI,YAAY,EAAE;IAI5B;;OAEG;IACH,KAAK,IAAI,IAAI;CAGd;AAGD,eAAO,MAAM,oBAAoB,sBAA6B,CAAA;AAE9D;;;GAGG;AACH,wBAAgB,iBAAiB,CAAC,QAAQ,EAAE,YAAY,EAAE,GAAG,IAAI,CAKhE;AAED;;;GAGG;AACH,wBAAgB,mBAAmB,IAAI,YAAY,EAAE,
|
|
1
|
+
{"version":3,"file":"registry.client.d.ts","sourceRoot":"","sources":["../../../src/lib/entities/registry.client.ts"],"names":[],"mappings":"AAAA;;;;;GAKG;AAIH,OAAO,KAAK,EAAE,YAAY,EAAE,MAAM,SAAS,CAAA;AAE3C;;GAEG;AACH,cAAM,oBAAoB;IACxB,OAAO,CAAC,QAAQ,CAAuC;IAEvD;;OAEG;IACH,QAAQ,CAAC,MAAM,EAAE,YAAY,GAAG,IAAI;IAIpC;;OAEG;IACH,GAAG,CAAC,IAAI,EAAE,MAAM,GAAG,YAAY,GAAG,SAAS;IAI3C;;OAEG;IACH,MAAM,IAAI,YAAY,EAAE;IAIxB;;OAEG;IACH,UAAU,IAAI,YAAY,EAAE;IAI5B;;OAEG;IACH,KAAK,IAAI,IAAI;CAGd;AAGD,eAAO,MAAM,oBAAoB,sBAA6B,CAAA;AAE9D;;;GAGG;AACH,wBAAgB,iBAAiB,CAAC,QAAQ,EAAE,YAAY,EAAE,GAAG,IAAI,CAKhE;AAED;;;GAGG;AACH,wBAAgB,mBAAmB,IAAI,YAAY,EAAE,CAUpD;AAED;;;GAGG;AACH,wBAAgB,kBAAkB,IAAI,YAAY,EAAE,CAEnD;AAED;;GAEG;AACH,wBAAgB,cAAc,CAAC,MAAM,EAAE,YAAY,GAAG,IAAI,CAEzD;AAED;;GAEG;AACH,wBAAgB,eAAe,CAAC,IAAI,EAAE,MAAM,GAAG,YAAY,GAAG,SAAS,CAEtE"}
|
|
@@ -41,29 +41,10 @@ function setServerEntities(entities) {
|
|
|
41
41
|
}
|
|
42
42
|
function getAllEntityConfigs() {
|
|
43
43
|
const clientEntities = clientEntityRegistry.getAll();
|
|
44
|
-
if (clientEntities.length
|
|
45
|
-
|
|
46
|
-
}
|
|
47
|
-
try {
|
|
48
|
-
const { ENTITY_REGISTRY } = require("@nextsparkjs/registries/entity-registry");
|
|
49
|
-
const { Package } = require("lucide-react");
|
|
50
|
-
return Object.values(ENTITY_REGISTRY).map((entry) => {
|
|
51
|
-
const config = entry.config;
|
|
52
|
-
return {
|
|
53
|
-
...config,
|
|
54
|
-
icon: config.icon || Package,
|
|
55
|
-
// Use fallback icon if original is missing
|
|
56
|
-
i18n: config.i18n ? {
|
|
57
|
-
...config.i18n,
|
|
58
|
-
loaders: {}
|
|
59
|
-
// Remove loader functions (functions can't be serialized to client)
|
|
60
|
-
} : void 0
|
|
61
|
-
};
|
|
62
|
-
}).filter((config) => config.slug);
|
|
63
|
-
} catch (error) {
|
|
64
|
-
console.error("[EntityRegistry] Failed to load from build-time registry:", error);
|
|
65
|
-
return [];
|
|
44
|
+
if (clientEntities.length === 0) {
|
|
45
|
+
console.log("[EntityRegistry] Client registry empty - waiting for hydration from DashboardShell");
|
|
66
46
|
}
|
|
47
|
+
return clientEntities;
|
|
67
48
|
}
|
|
68
49
|
function getEnabledEntities() {
|
|
69
50
|
return clientEntityRegistry.getEnabled();
|
|
@@ -15,24 +15,34 @@ import type { EntityConfig, EntityLimits, EntityAccessResult, EntityUsageStats,
|
|
|
15
15
|
import type { UserRole } from '../../types/user.types';
|
|
16
16
|
/**
|
|
17
17
|
* EntityRegistry - Central management system for all entities
|
|
18
|
+
*
|
|
19
|
+
* ARCHITECTURE: This class is now a FACADE that delegates to the singleton
|
|
20
|
+
* in queries.ts. There is NO internal Map - all data comes from the shared
|
|
21
|
+
* singleton which is populated by the layout via setEntityRegistry().
|
|
22
|
+
*
|
|
23
|
+
* This unification ensures:
|
|
24
|
+
* - API handlers see the same entities as client components
|
|
25
|
+
* - Works in both monorepo and npm modes
|
|
26
|
+
* - No require() calls that fail in pre-compiled npm packages
|
|
18
27
|
*/
|
|
19
28
|
export declare class EntityRegistry {
|
|
20
|
-
private entities;
|
|
21
|
-
private initialized;
|
|
22
29
|
/**
|
|
23
30
|
* Register a new entity configuration
|
|
31
|
+
* Adds to the singleton in queries.ts
|
|
24
32
|
*/
|
|
25
33
|
register(config: EntityConfig): void;
|
|
26
34
|
/**
|
|
27
|
-
* Get entity configuration by slug
|
|
35
|
+
* Get entity configuration by slug
|
|
36
|
+
* Delegates to singleton in queries.ts
|
|
28
37
|
*/
|
|
29
38
|
get(slug: string): EntityConfig | undefined;
|
|
30
39
|
/**
|
|
31
|
-
* Get entity configuration by slug
|
|
40
|
+
* Get entity configuration by slug (alias for get)
|
|
32
41
|
*/
|
|
33
42
|
getBySlug(slug: string): EntityConfig | undefined;
|
|
34
43
|
/**
|
|
35
44
|
* Get all registered entities
|
|
45
|
+
* Delegates to singleton in queries.ts
|
|
36
46
|
*/
|
|
37
47
|
getAll(): EntityConfig[];
|
|
38
48
|
/**
|
|
@@ -81,17 +91,15 @@ export declare class EntityRegistry {
|
|
|
81
91
|
};
|
|
82
92
|
/**
|
|
83
93
|
* Initialize registry
|
|
84
|
-
* CLIENT-SAFE: Skips on client, loads from registries on server
|
|
85
|
-
*/
|
|
86
|
-
initialize(): Promise<void>;
|
|
87
|
-
/**
|
|
88
|
-
* Server-only registry loading
|
|
89
|
-
* Loads from build-time registries (ENTITY_REGISTRY with static imports)
|
|
90
|
-
* PERFORMANCE: Zero runtime I/O, ~17,255x faster than old dynamic system
|
|
91
94
|
*
|
|
92
|
-
*
|
|
95
|
+
* ARCHITECTURE: This is now a NO-OP for backwards compatibility.
|
|
96
|
+
* The singleton in queries.ts is populated by:
|
|
97
|
+
* - Server: The layout imports registry and calls setEntityRegistry()
|
|
98
|
+
* - Client: DashboardShell calls setServerEntities() during hydration
|
|
99
|
+
*
|
|
100
|
+
* The EntityRegistry class is a facade - it doesn't need initialization.
|
|
93
101
|
*/
|
|
94
|
-
|
|
102
|
+
initialize(): Promise<void>;
|
|
95
103
|
/**
|
|
96
104
|
* Get registry statistics
|
|
97
105
|
*/
|
|
@@ -103,10 +111,12 @@ export declare class EntityRegistry {
|
|
|
103
111
|
};
|
|
104
112
|
/**
|
|
105
113
|
* Update an existing entity configuration
|
|
114
|
+
* Delegates to singleton in queries.ts
|
|
106
115
|
*/
|
|
107
116
|
updateEntity(slug: string, updates: Partial<EntityConfig>): void;
|
|
108
117
|
/**
|
|
109
118
|
* Remove an entity from the registry
|
|
119
|
+
* Delegates to singleton in queries.ts
|
|
110
120
|
*/
|
|
111
121
|
removeEntity(slug: string): void;
|
|
112
122
|
/**
|
|
@@ -119,6 +129,7 @@ export declare class EntityRegistry {
|
|
|
119
129
|
importConfigs(configs: EntityConfig[]): void;
|
|
120
130
|
/**
|
|
121
131
|
* Check if registry is initialized
|
|
132
|
+
* Delegates to singleton in queries.ts
|
|
122
133
|
*/
|
|
123
134
|
isInitialized(): boolean;
|
|
124
135
|
/**
|
|
@@ -127,6 +138,7 @@ export declare class EntityRegistry {
|
|
|
127
138
|
reset(): void;
|
|
128
139
|
/**
|
|
129
140
|
* Clear all registered entities (mainly for testing)
|
|
141
|
+
* Delegates to singleton in queries.ts
|
|
130
142
|
*/
|
|
131
143
|
clear(): void;
|
|
132
144
|
}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"registry.d.ts","sourceRoot":"","sources":["../../../src/lib/entities/registry.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;GAWG;AAEH,OAAO,aAAa,CAAA;AAEpB,OAAO,KAAK,EACV,YAAY,EAEZ,YAAY,EACZ,kBAAkB,EAClB,gBAAgB,EAChB,aAAa,EACb,QAAQ,EACR,QAAQ,EACR,iBAAiB,EACjB,qBAAqB,EAEtB,MAAM,SAAS,CAAA;AAChB,OAAO,KAAK,EAAE,QAAQ,EAAE,MAAM,wBAAwB,CAAA;
|
|
1
|
+
{"version":3,"file":"registry.d.ts","sourceRoot":"","sources":["../../../src/lib/entities/registry.ts"],"names":[],"mappings":"AAAA;;;;;;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B,kBAAkB,IAAI,YAAY,EAAE,CAEnD;AAGD,wBAAgB,eAAe,CAC7B,UAAU,EAAE,MAAM,EAClB,QAAQ,EAAE,QAAQ,EAClB,SAAS,GAAE,QAAQ,EAAO,GACzB,YAAY,CAEd;AAED;;;GAGG;AACH,wBAAsB,iBAAiB,IAAI,OAAO,CAAC,IAAI,CAAC,CAEvD;AAED;;GAEG;AACH,wBAAgB,mBAAmB,IAAI,YAAY,EAAE,CAEpD;AAED;;;GAGG;AACH,wBAAgB,gBAAgB;;;;;EAO/B"}
|
|
@@ -1,38 +1,56 @@
|
|
|
1
1
|
import "server-only";
|
|
2
|
-
import {
|
|
2
|
+
import {
|
|
3
|
+
getEntityBySlug,
|
|
4
|
+
getRegisteredEntities,
|
|
5
|
+
addEntityToRegistry,
|
|
6
|
+
removeEntityFromRegistry,
|
|
7
|
+
clearEntityRegistry,
|
|
8
|
+
isRegistryInitialized
|
|
9
|
+
} from "./queries";
|
|
3
10
|
class EntityRegistry {
|
|
4
|
-
entities = /* @__PURE__ */ new Map();
|
|
5
|
-
initialized = false;
|
|
6
11
|
/**
|
|
7
12
|
* Register a new entity configuration
|
|
13
|
+
* Adds to the singleton in queries.ts
|
|
8
14
|
*/
|
|
9
15
|
register(config) {
|
|
10
16
|
const validation = this.validateConfiguration(config);
|
|
11
17
|
if (!validation.valid) {
|
|
12
18
|
throw new Error(`Invalid entity configuration for "${config.slug}": ${validation.errors.join(", ")}`);
|
|
13
19
|
}
|
|
14
|
-
|
|
20
|
+
const entry = {
|
|
21
|
+
name: config.slug,
|
|
22
|
+
config,
|
|
23
|
+
parent: null,
|
|
24
|
+
children: config.childEntities ? Object.keys(config.childEntities) : [],
|
|
25
|
+
depth: 0,
|
|
26
|
+
tableName: config.tableName || config.slug,
|
|
27
|
+
routePrefix: config.slug
|
|
28
|
+
};
|
|
29
|
+
addEntityToRegistry(entry);
|
|
15
30
|
if (validation.warnings.length > 0) {
|
|
16
31
|
console.warn(`Entity "${config.slug}" configuration warnings:`, validation.warnings);
|
|
17
32
|
}
|
|
18
33
|
}
|
|
19
34
|
/**
|
|
20
|
-
* Get entity configuration by slug
|
|
35
|
+
* Get entity configuration by slug
|
|
36
|
+
* Delegates to singleton in queries.ts
|
|
21
37
|
*/
|
|
22
38
|
get(slug) {
|
|
23
|
-
return
|
|
39
|
+
return getEntityBySlug(slug);
|
|
24
40
|
}
|
|
25
41
|
/**
|
|
26
|
-
* Get entity configuration by slug
|
|
42
|
+
* Get entity configuration by slug (alias for get)
|
|
27
43
|
*/
|
|
28
44
|
getBySlug(slug) {
|
|
29
|
-
return
|
|
45
|
+
return getEntityBySlug(slug);
|
|
30
46
|
}
|
|
31
47
|
/**
|
|
32
48
|
* Get all registered entities
|
|
49
|
+
* Delegates to singleton in queries.ts
|
|
33
50
|
*/
|
|
34
51
|
getAll() {
|
|
35
|
-
|
|
52
|
+
const entities = getRegisteredEntities();
|
|
53
|
+
return entities.filter((e) => "slug" in e && "enabled" in e);
|
|
36
54
|
}
|
|
37
55
|
/**
|
|
38
56
|
* Get only enabled entities
|
|
@@ -194,47 +212,22 @@ class EntityRegistry {
|
|
|
194
212
|
}
|
|
195
213
|
/**
|
|
196
214
|
* Initialize registry
|
|
197
|
-
*
|
|
215
|
+
*
|
|
216
|
+
* ARCHITECTURE: This is now a NO-OP for backwards compatibility.
|
|
217
|
+
* The singleton in queries.ts is populated by:
|
|
218
|
+
* - Server: The layout imports registry and calls setEntityRegistry()
|
|
219
|
+
* - Client: DashboardShell calls setServerEntities() during hydration
|
|
220
|
+
*
|
|
221
|
+
* The EntityRegistry class is a facade - it doesn't need initialization.
|
|
198
222
|
*/
|
|
199
223
|
async initialize() {
|
|
200
|
-
|
|
201
|
-
if (
|
|
202
|
-
console.log(
|
|
203
|
-
|
|
204
|
-
|
|
205
|
-
}
|
|
206
|
-
try {
|
|
207
|
-
this.loadFromRegistriesServer();
|
|
208
|
-
this.initialized = true;
|
|
209
|
-
console.log("[EntityRegistry] Server: initialized from build-time registries");
|
|
210
|
-
} catch (error) {
|
|
211
|
-
console.error("[EntityRegistry] Error initializing from registries:", error);
|
|
212
|
-
this.initialized = true;
|
|
224
|
+
const count = this.getAll().length;
|
|
225
|
+
if (count > 0) {
|
|
226
|
+
console.log(`[EntityRegistry] Already initialized with ${count} entities from singleton`);
|
|
227
|
+
} else {
|
|
228
|
+
console.log("[EntityRegistry] Singleton empty - will be populated by layout import");
|
|
213
229
|
}
|
|
214
230
|
}
|
|
215
|
-
/**
|
|
216
|
-
* Server-only registry loading
|
|
217
|
-
* Loads from build-time registries (ENTITY_REGISTRY with static imports)
|
|
218
|
-
* PERFORMANCE: Zero runtime I/O, ~17,255x faster than old dynamic system
|
|
219
|
-
*
|
|
220
|
-
* Note: Uses static import (zero dynamic imports policy)
|
|
221
|
-
*/
|
|
222
|
-
loadFromRegistriesServer() {
|
|
223
|
-
const entities = getRegisteredEntities();
|
|
224
|
-
console.log("[EntityRegistry] Loading entities from build-time registry:", entities.length);
|
|
225
|
-
entities.forEach((config, index) => {
|
|
226
|
-
const name = "slug" in config ? config.slug : `entity-${index}`;
|
|
227
|
-
console.log(`[EntityRegistry] Loading entity ${index + 1}/${entities.length}: ${name}`);
|
|
228
|
-
try {
|
|
229
|
-
this.register(config);
|
|
230
|
-
console.log(`[EntityRegistry] \u2705 Successfully registered: ${name}`);
|
|
231
|
-
} catch (error) {
|
|
232
|
-
const errorMessage = error instanceof Error ? error.message : String(error);
|
|
233
|
-
console.error(`[EntityRegistry] \u274C Failed to register ${name}:`, errorMessage);
|
|
234
|
-
}
|
|
235
|
-
});
|
|
236
|
-
console.log("[EntityRegistry] Finished loading entities. Total registered:", this.entities.size);
|
|
237
|
-
}
|
|
238
231
|
/**
|
|
239
232
|
* Get registry statistics
|
|
240
233
|
*/
|
|
@@ -250,9 +243,10 @@ class EntityRegistry {
|
|
|
250
243
|
}
|
|
251
244
|
/**
|
|
252
245
|
* Update an existing entity configuration
|
|
246
|
+
* Delegates to singleton in queries.ts
|
|
253
247
|
*/
|
|
254
248
|
updateEntity(slug, updates) {
|
|
255
|
-
const existing = this.
|
|
249
|
+
const existing = this.get(slug);
|
|
256
250
|
if (!existing) {
|
|
257
251
|
throw new Error(`Entity "${slug}" not found`);
|
|
258
252
|
}
|
|
@@ -261,19 +255,19 @@ class EntityRegistry {
|
|
|
261
255
|
if (!validation.valid) {
|
|
262
256
|
throw new Error(`Invalid entity update for "${slug}": ${validation.errors.join(", ")}`);
|
|
263
257
|
}
|
|
264
|
-
this.
|
|
258
|
+
this.register(updated);
|
|
265
259
|
if (validation.warnings.length > 0) {
|
|
266
260
|
console.warn(`Entity "${slug}" update warnings:`, validation.warnings);
|
|
267
261
|
}
|
|
268
262
|
}
|
|
269
263
|
/**
|
|
270
264
|
* Remove an entity from the registry
|
|
265
|
+
* Delegates to singleton in queries.ts
|
|
271
266
|
*/
|
|
272
267
|
removeEntity(slug) {
|
|
273
|
-
if (!
|
|
268
|
+
if (!removeEntityFromRegistry(slug)) {
|
|
274
269
|
throw new Error(`Entity "${slug}" not found`);
|
|
275
270
|
}
|
|
276
|
-
this.entities.delete(slug);
|
|
277
271
|
}
|
|
278
272
|
/**
|
|
279
273
|
* Export all entity configurations
|
|
@@ -289,9 +283,10 @@ class EntityRegistry {
|
|
|
289
283
|
}
|
|
290
284
|
/**
|
|
291
285
|
* Check if registry is initialized
|
|
286
|
+
* Delegates to singleton in queries.ts
|
|
292
287
|
*/
|
|
293
288
|
isInitialized() {
|
|
294
|
-
return
|
|
289
|
+
return isRegistryInitialized();
|
|
295
290
|
}
|
|
296
291
|
/**
|
|
297
292
|
* Reset the registry (alias for clear)
|
|
@@ -301,10 +296,10 @@ class EntityRegistry {
|
|
|
301
296
|
}
|
|
302
297
|
/**
|
|
303
298
|
* Clear all registered entities (mainly for testing)
|
|
299
|
+
* Delegates to singleton in queries.ts
|
|
304
300
|
*/
|
|
305
301
|
clear() {
|
|
306
|
-
|
|
307
|
-
this.initialized = false;
|
|
302
|
+
clearEntityRegistry();
|
|
308
303
|
}
|
|
309
304
|
}
|
|
310
305
|
const entityRegistry = new EntityRegistry();
|
|
@@ -330,8 +325,8 @@ function getRegistryStats() {
|
|
|
330
325
|
return {
|
|
331
326
|
totalEntities: entityRegistry.getAll().length,
|
|
332
327
|
enabledEntities: entityRegistry.getEnabled().length,
|
|
333
|
-
initialized: entityRegistry
|
|
334
|
-
source: "
|
|
328
|
+
initialized: entityRegistry.isInitialized(),
|
|
329
|
+
source: "singleton (queries.ts)"
|
|
335
330
|
};
|
|
336
331
|
}
|
|
337
332
|
export {
|
package/dist/styles/classes.json
CHANGED