@teamscala/service-boot 0.23.352 → 0.23.353

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/package.json CHANGED
@@ -6,7 +6,7 @@
6
6
  },
7
7
  "name": "@teamscala/service-boot",
8
8
  "type": "module",
9
- "version": "0.23.352",
9
+ "version": "0.23.353",
10
10
  "sideEffects": false,
11
11
  "imports": {
12
12
  "#service-boot/*": "./src/*",
@@ -0,0 +1,20 @@
1
+ import { expect, test } from "bun:test";
2
+ import { registerPrismaClient } from "@teamscala/db/prisma-registry";
3
+ import type { PrismaClient } from "@teamscala/db/client";
4
+ import { discoverBlocks } from "./discover-blocks.ts";
5
+
6
+ test("block discovery reads the global registry through the registered database client", async () => {
7
+ let calls = 0;
8
+ registerPrismaClient({
9
+ registry_entries: {
10
+ findMany: async () => {
11
+ calls += 1;
12
+ return [];
13
+ },
14
+ },
15
+ } as unknown as PrismaClient);
16
+
17
+ const result = await discoverBlocks([]);
18
+ expect(calls).toBe(1);
19
+ expect(result).toEqual({ components: {}, loaded: [], skipped: [] });
20
+ });
@@ -22,8 +22,8 @@
22
22
 
23
23
  import { existsSync } from "node:fs";
24
24
  import { join } from "node:path";
25
+ import { getPrisma } from "@teamscala/db/prisma-registry";
25
26
  import { BlockSchemaConfigSchema } from "@teamscala/db-validation/registry-schemas/block-schema";
26
- import { getServerClient } from "./page-server-orpc/server-client.ts";
27
27
  import * as v from "valibot";
28
28
  import type { RendererComponentEntry } from "./types.ts";
29
29
 
@@ -40,18 +40,6 @@ interface BlockSchemaConfig {
40
40
  defaults?: Record<string, unknown>;
41
41
  }
42
42
 
43
- interface RegistryEntriesModel {
44
- findMany: (args: {
45
- where: Record<string, unknown>;
46
- select: Record<string, unknown>;
47
- orderBy: Record<string, unknown>;
48
- }) => Promise<Array<{ slug: string; config: unknown }>>;
49
- }
50
-
51
- interface PrismaWithRegistry {
52
- registry_entries: RegistryEntriesModel;
53
- }
54
-
55
43
  export async function discoverBlocks(
56
44
  blockPackages: string[],
57
45
  ): Promise<DiscoveredBlocks> {
@@ -92,7 +80,11 @@ export async function discoverBlocks(
92
80
  const loaded: string[] = [];
93
81
  const skipped: string[] = [];
94
82
 
95
- const prisma = (await getServerClient()) as unknown as PrismaWithRegistry;
83
+ // Block schemas are global registry data, not a model owned by this UI
84
+ // service. The page-server ORPC client is intentionally service-scoped and
85
+ // therefore cannot expose registry_entries. Use the registered database
86
+ // client for this shared model, as every other registry reader does.
87
+ const prisma = getPrisma();
96
88
  const rows: Array<{ slug: string; config: unknown }> =
97
89
  await prisma.registry_entries.findMany({
98
90
  where: { type: "block_schema", is_active: true },