@nextsparkjs/core 0.1.0-beta.15 → 0.1.0-beta.17

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.
@@ -1 +1 @@
1
- {"version":3,"file":"DashboardShell.d.ts","sourceRoot":"","sources":["../../../../src/components/dashboard/layouts/DashboardShell.tsx"],"names":[],"mappings":"AASA,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;AAgDD,wBAAgB,cAAc,CAAC,EAAE,QAAQ,EAAE,QAAQ,EAAE,EAAE,mBAAmB,2CAQzE"}
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"}
@@ -1,6 +1,5 @@
1
1
  "use client";
2
2
  import { jsx, jsxs } from "react/jsx-runtime";
3
- import { useEffect, useRef } from "react";
4
3
  import { Sidebar } from "./Sidebar";
5
4
  import { TopNavbar } from "./TopNavbar";
6
5
  import { MobileTopBar } from "../mobile/MobileTopBar";
@@ -9,16 +8,14 @@ import { SidebarProvider, useSidebar } from "../../../contexts/sidebar-context";
9
8
  import { cn } from "../../../lib/utils";
10
9
  import { deserializeEntityConfig } from "../../../lib/entities/serialization";
11
10
  import { setServerEntities } from "../../../lib/entities/registry.client";
11
+ let clientHydrated = false;
12
12
  function DashboardShellContent({ children, entities }) {
13
13
  const { isCollapsed } = useSidebar();
14
- const hydratedRef = useRef(false);
15
- useEffect(() => {
16
- if (!hydratedRef.current && entities.length > 0) {
17
- const deserializedEntities = entities.map(deserializeEntityConfig);
18
- setServerEntities(deserializedEntities);
19
- hydratedRef.current = true;
20
- }
21
- }, [entities]);
14
+ if (!clientHydrated && entities.length > 0) {
15
+ const deserializedEntities = entities.map(deserializeEntityConfig);
16
+ setServerEntities(deserializedEntities);
17
+ clientHydrated = true;
18
+ }
22
19
  return /* @__PURE__ */ jsxs("div", { className: "min-h-screen", children: [
23
20
  /* @__PURE__ */ jsx(Sidebar, { className: "hidden lg:flex", entities }),
24
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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AG,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
  };
@@ -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 (updated for new structure)
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
- * Note: Uses require() for server-side loading (this file is server-only)
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
- private loadFromRegistriesServer;
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;AAGtD;;GAEG;AACH,qBAAa,cAAc;IACzB,OAAO,CAAC,QAAQ,CAAuC;IACvD,OAAO,CAAC,WAAW,CAAQ;IAE3B;;OAEG;IACH,QAAQ,CAAC,MAAM,EAAE,YAAY,GAAG,IAAI;IAcpC;;OAEG;IACH,GAAG,CAAC,IAAI,EAAE,MAAM,GAAG,YAAY,GAAG,SAAS;IAI3C;;OAEG;IACH,SAAS,CAAC,IAAI,EAAE,MAAM,GAAG,YAAY,GAAG,SAAS;IAIjD;;OAEG;IACH,MAAM,IAAI,YAAY,EAAE;IAIxB;;OAEG;IACH,UAAU,IAAI,YAAY,EAAE;IAI5B;;OAEG;IACH,YAAY,CAAC,OAAO,EAAE,MAAM,YAAY,CAAC,IAAI,CAAC,CAAC,UAAU,CAAC,GAAG,Y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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 { getRegisteredEntities } from "./queries";
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
- this.entities.set(config.slug, config);
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 (updated for new structure)
35
+ * Get entity configuration by slug
36
+ * Delegates to singleton in queries.ts
21
37
  */
22
38
  get(slug) {
23
- return this.entities.get(slug);
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 this.entities.get(slug);
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
- return Array.from(this.entities.values());
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,62 +212,20 @@ class EntityRegistry {
194
212
  }
195
213
  /**
196
214
  * Initialize registry
197
- * CLIENT-SAFE: Skips on client, loads from registries on server
198
- */
199
- async initialize() {
200
- if (this.initialized) return;
201
- if (typeof window !== "undefined") {
202
- console.log("[EntityRegistry] Client-side: registry ready for manual registration");
203
- this.initialized = true;
204
- return;
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;
213
- }
214
- }
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
215
  *
220
- * Note: Uses require() for server-side loading (this file is server-only)
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.
221
222
  */
222
- loadFromRegistriesServer() {
223
- try {
224
- const { ENTITY_REGISTRY } = require("@nextsparkjs/registries/entity-registry");
225
- const entities = Object.values(ENTITY_REGISTRY).map((entry) => entry.config);
226
- console.log("[EntityRegistry] Loading entities from build-time registry:", entities.length);
227
- entities.forEach((config, index) => {
228
- const name = "slug" in config ? config.slug : `entity-${index}`;
229
- console.log(`[EntityRegistry] Loading entity ${index + 1}/${entities.length}: ${name}`);
230
- try {
231
- this.register(config);
232
- console.log(`[EntityRegistry] \u2705 Successfully registered: ${name}`);
233
- } catch (error) {
234
- const errorMessage = error instanceof Error ? error.message : String(error);
235
- console.error(`[EntityRegistry] \u274C Failed to register ${name}:`, errorMessage);
236
- }
237
- });
238
- console.log("[EntityRegistry] Finished loading entities. Total registered:", this.entities.size);
239
- } catch (error) {
240
- console.error("[EntityRegistry] Error loading entity registry:", error);
241
- const entities = getRegisteredEntities();
242
- if (entities.length > 0) {
243
- console.log("[EntityRegistry] Using fallback cached entities:", entities.length);
244
- entities.forEach((config, index) => {
245
- const name = "slug" in config ? config.slug : `entity-${index}`;
246
- try {
247
- this.register(config);
248
- } catch (regError) {
249
- console.error(`[EntityRegistry] Failed to register ${name}:`, regError);
250
- }
251
- });
252
- }
223
+ async initialize() {
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");
253
229
  }
254
230
  }
255
231
  /**
@@ -267,9 +243,10 @@ class EntityRegistry {
267
243
  }
268
244
  /**
269
245
  * Update an existing entity configuration
246
+ * Delegates to singleton in queries.ts
270
247
  */
271
248
  updateEntity(slug, updates) {
272
- const existing = this.entities.get(slug);
249
+ const existing = this.get(slug);
273
250
  if (!existing) {
274
251
  throw new Error(`Entity "${slug}" not found`);
275
252
  }
@@ -278,19 +255,19 @@ class EntityRegistry {
278
255
  if (!validation.valid) {
279
256
  throw new Error(`Invalid entity update for "${slug}": ${validation.errors.join(", ")}`);
280
257
  }
281
- this.entities.set(slug, updated);
258
+ this.register(updated);
282
259
  if (validation.warnings.length > 0) {
283
260
  console.warn(`Entity "${slug}" update warnings:`, validation.warnings);
284
261
  }
285
262
  }
286
263
  /**
287
264
  * Remove an entity from the registry
265
+ * Delegates to singleton in queries.ts
288
266
  */
289
267
  removeEntity(slug) {
290
- if (!this.entities.has(slug)) {
268
+ if (!removeEntityFromRegistry(slug)) {
291
269
  throw new Error(`Entity "${slug}" not found`);
292
270
  }
293
- this.entities.delete(slug);
294
271
  }
295
272
  /**
296
273
  * Export all entity configurations
@@ -306,9 +283,10 @@ class EntityRegistry {
306
283
  }
307
284
  /**
308
285
  * Check if registry is initialized
286
+ * Delegates to singleton in queries.ts
309
287
  */
310
288
  isInitialized() {
311
- return this.initialized;
289
+ return isRegistryInitialized();
312
290
  }
313
291
  /**
314
292
  * Reset the registry (alias for clear)
@@ -318,10 +296,10 @@ class EntityRegistry {
318
296
  }
319
297
  /**
320
298
  * Clear all registered entities (mainly for testing)
299
+ * Delegates to singleton in queries.ts
321
300
  */
322
301
  clear() {
323
- this.entities.clear();
324
- this.initialized = false;
302
+ clearEntityRegistry();
325
303
  }
326
304
  }
327
305
  const entityRegistry = new EntityRegistry();
@@ -347,8 +325,8 @@ function getRegistryStats() {
347
325
  return {
348
326
  totalEntities: entityRegistry.getAll().length,
349
327
  enabledEntities: entityRegistry.getEnabled().length,
350
- initialized: entityRegistry["initialized"],
351
- source: "build-time registries (THEME_REGISTRY + PLUGIN_REGISTRY)"
328
+ initialized: entityRegistry.isInitialized(),
329
+ source: "singleton (queries.ts)"
352
330
  };
353
331
  }
354
332
  export {
@@ -1,5 +1,5 @@
1
1
  {
2
- "generated": "2026-01-07T02:50:14.297Z",
2
+ "generated": "2026-01-07T13:19:12.399Z",
3
3
  "totalClasses": 999,
4
4
  "classes": [
5
5
  "''",
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@nextsparkjs/core",
3
- "version": "0.1.0-beta.15",
3
+ "version": "0.1.0-beta.17",
4
4
  "description": "NextSpark - The complete SaaS framework for Next.js",
5
5
  "license": "MIT",
6
6
  "author": "NextSpark <hello@nextspark.dev>",
@@ -223,16 +223,6 @@
223
223
  "README.md",
224
224
  "scripts"
225
225
  ],
226
- "scripts": {
227
- "build": "tsup && pnpm build:dts && pnpm build:ui-css",
228
- "build:js": "tsup",
229
- "build:dts": "tsc -p tsconfig.dts.json || echo '⚠️ DTS generation completed with some type errors (partial coverage)'",
230
- "build:ui-css": "node scripts/build/build-ui-css.mjs",
231
- "dev": "tsup --watch",
232
- "test": "jest",
233
- "test:watch": "jest --watch",
234
- "test:coverage": "jest --coverage"
235
- },
236
226
  "peerDependencies": {
237
227
  "next": ">=14.0.0",
238
228
  "react": ">=18.0.0",
@@ -317,5 +307,15 @@
317
307
  "tailwind-merge": "^3.3.1",
318
308
  "uuid": "^13.0.0",
319
309
  "zod": "^4.1.5"
310
+ },
311
+ "scripts": {
312
+ "build": "tsup && pnpm build:dts && pnpm build:ui-css",
313
+ "build:js": "tsup",
314
+ "build:dts": "tsc -p tsconfig.dts.json || echo '⚠️ DTS generation completed with some type errors (partial coverage)'",
315
+ "build:ui-css": "node scripts/build/build-ui-css.mjs",
316
+ "dev": "tsup --watch",
317
+ "test": "jest",
318
+ "test:watch": "jest --watch",
319
+ "test:coverage": "jest --coverage"
320
320
  }
321
- }
321
+ }
File without changes
File without changes
File without changes
File without changes
File without changes
File without changes
File without changes
File without changes
File without changes