@plandesk/api 1.0.2 → 1.0.3

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,5 +1,5 @@
1
1
  import { Hono } from 'hono';
2
- import type { Db } from '@plandesk/db';
2
+ import { type Db } from '@plandesk/db';
3
3
  import type { BetterAuthInstance } from '../better-auth.js';
4
4
  import type { GithubConfig } from '../github.js';
5
5
  export type AuthRouterDeps = {
@@ -1,4 +1,5 @@
1
1
  import { Hono } from 'hono';
2
+ import { listProjects } from '@plandesk/db';
2
3
  import { createOrgOwnerKey } from '../agent-keys.js';
3
4
  import { getAuthContext } from '../auth-context.js';
4
5
  import { getActiveTeamForSession, listTeamsForOrg, } from '../identity.js';
@@ -43,9 +44,15 @@ export function createAuthRouter(deps) {
43
44
  active ?? (workspaces[0] !== undefined ? workspaces[0] : null);
44
45
  }
45
46
  else {
46
- // Loopback: no session row to carry an active team default to the
47
- // first workspace (the org's default team) so the switcher still renders.
48
- activeWorkspace = workspaces[0] !== undefined ? workspaces[0] : null;
47
+ // Loopback: no session row to carry an active team. Default to the first
48
+ // workspace that actually HAS projects, so an imported/populated board
49
+ // (e.g. after legacy-upgrade --into-workspace) opens on its content
50
+ // instead of an empty default team; fall back to the first workspace.
51
+ const localProjects = await listProjects(deps.db, ctx.orgId);
52
+ const populated = new Set(localProjects.map((project) => project.workspaceId));
53
+ activeWorkspace =
54
+ workspaces.find((workspace) => populated.has(workspace.id)) ??
55
+ (workspaces[0] !== undefined ? workspaces[0] : null);
49
56
  }
50
57
  }
51
58
  return c.json({
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@plandesk/api",
3
- "version": "1.0.2",
3
+ "version": "1.0.3",
4
4
  "type": "module",
5
5
  "exports": {
6
6
  ".": {