@cosmicdrift/kumiko-framework 0.216.0 → 0.218.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/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@cosmicdrift/kumiko-framework",
3
- "version": "0.216.0",
3
+ "version": "0.218.0",
4
4
  "description": "Framework core — engine, pipeline, API, DB, and every other bit that makes Kumiko go.",
5
5
  "license": "BUSL-1.1",
6
6
  "author": "Marc Frost <marc@cosmicdriftgamestudio.com>",
@@ -194,7 +194,7 @@
194
194
  "./package.json": "./package.json"
195
195
  },
196
196
  "dependencies": {
197
- "@cosmicdrift/kumiko-types": "0.216.0",
197
+ "@cosmicdrift/kumiko-types": "0.218.0",
198
198
  "bullmq": "^5.76.7",
199
199
  "bun-types": "^1.3.13",
200
200
  "hono": "^4.13.1",
@@ -210,7 +210,7 @@
210
210
  "zod": "^4.4.3"
211
211
  },
212
212
  "devDependencies": {
213
- "@cosmicdrift/kumiko-dispatcher-live": "0.216.0",
213
+ "@cosmicdrift/kumiko-dispatcher-live": "0.218.0",
214
214
  "bun-types": "^1.3.13",
215
215
  "pino-pretty": "^13.1.3"
216
216
  },
@@ -9,7 +9,7 @@ import { createSystemUser } from "../engine/system-user";
9
9
  import { type SessionUser, SYSTEM_TENANT_ID, type TenantId } from "../engine/types";
10
10
  import { NotFoundError } from "../errors";
11
11
  import type { Dispatcher } from "../pipeline/dispatcher";
12
- import { parseStringArrayJson } from "../utils/parse-string-array-json";
12
+ import { parseRoles } from "../utils/serialization";
13
13
  import { Routes } from "./api-constants";
14
14
  import {
15
15
  AUTH_COOKIE_NAME,
@@ -1361,11 +1361,10 @@ export function createAuthRoutes(
1361
1361
  config.userQuery,
1362
1362
  { id: user.id },
1363
1363
  createSystemUser(user.tenantId),
1364
- )) as { roles?: string | null } | null;
1365
- const raw = userRow?.roles;
1366
- if (typeof raw === "string" && raw.length > 0) {
1367
- globalRoles = parseStringArrayJson(raw);
1368
- }
1364
+ )) as { roles?: unknown } | null;
1365
+ // roles is jsonb string[] (multiSelect); parseRoles also accepts legacy
1366
+ // JSON-encoded text from pre-0.217.0 rows.
1367
+ globalRoles = parseRoles(userRow?.roles ?? null);
1369
1368
  } catch (e) {
1370
1369
  // Non-fatal: globale Rollen kann nicht aufgelöst werden → switch
1371
1370
  // läuft weiter mit nur tenant-rollen. Server-error mit nur dem
@@ -7,7 +7,13 @@
7
7
  import { afterAll, beforeAll, beforeEach, describe, expect, test } from "bun:test";
8
8
  import { type BunTestDb, createTestDb } from "../../bun-db/__tests__/bun-test-db";
9
9
  import { asRawClient } from "../../db/query";
10
- import { createDateField, createEntity, createNumberField, createTextField } from "../../engine";
10
+ import {
11
+ createDateField,
12
+ createEntity,
13
+ createNumberField,
14
+ createTextField,
15
+ SYSTEM_TENANT_ID,
16
+ } from "../../engine";
11
17
  import { UnprocessableError } from "../../errors";
12
18
  import { createEventsTable } from "../../event-store";
13
19
  import { TestUsers, unsafeCreateEntityTable } from "../../stack";
@@ -499,6 +505,45 @@ describe("event-store-executor.list — runtime SearchAdapter (Tier 2.7e Audit-F
499
505
  });
500
506
  expect(res.rows).toHaveLength(0);
501
507
  });
508
+
509
+ test("system-mode list: search uses SYSTEM_TENANT_ID (not session tenant)", async () => {
510
+ const systemTdb = createTenantDb(testDb.db, admin.tenantId, "system");
511
+ let searchedTenant: string | undefined;
512
+ const mockAdapter = {
513
+ configure: async () => {},
514
+ index: async () => {},
515
+ indexBatch: async () => {},
516
+ remove: async () => {},
517
+ search: async (tenantId: string) => {
518
+ searchedTenant = tenantId;
519
+ return [];
520
+ },
521
+ reset: async () => {},
522
+ } as never;
523
+ await exec.list({ limit: 50, search: "x" }, admin, systemTdb, {
524
+ searchAdapter: mockAdapter,
525
+ });
526
+ expect(searchedTenant).toBe(SYSTEM_TENANT_ID);
527
+ });
528
+
529
+ test("tenant-mode list: search still uses session tenantId", async () => {
530
+ let searchedTenant: string | undefined;
531
+ const mockAdapter = {
532
+ configure: async () => {},
533
+ index: async () => {},
534
+ indexBatch: async () => {},
535
+ remove: async () => {},
536
+ search: async (tenantId: string) => {
537
+ searchedTenant = tenantId;
538
+ return [];
539
+ },
540
+ reset: async () => {},
541
+ } as never;
542
+ await exec.list({ limit: 50, search: "x" }, admin, tdb, {
543
+ searchAdapter: mockAdapter,
544
+ });
545
+ expect(searchedTenant).toBe(admin.tenantId);
546
+ });
502
547
  });
503
548
 
504
549
  describe("event-store-executor.list — keyset cursor mit custom sort (#2265)", () => {
@@ -138,7 +138,10 @@ export function createReadVerbs(ctx: ExecutorContext): Pick<EventStoreExecutor,
138
138
  },
139
139
  });
140
140
  }
141
- const results = await effectiveSearchAdapter.search(user.tenantId, payload.search, {
141
+ // system-mode lists (r.systemScope / cross-tenant) index under SYSTEM_TENANT_ID;
142
+ // searching the caller's session tenant misses the roster and can 500 on Meili.
143
+ const searchTenantId = db.mode === "system" ? SYSTEM_TENANT_ID : user.tenantId;
144
+ const results = await effectiveSearchAdapter.search(searchTenantId, payload.search, {
142
145
  filterType: entityName,
143
146
  });
144
147
  filterIds = results.map((r) => r.entityId);