@shipfox/client-onboarding 12.0.1 → 13.0.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.
@@ -10,6 +10,7 @@ import {projectExistenceQueryOptions} from '@shipfox/client-projects';
10
10
  import {
11
11
  userWorkspacesQueryOptions,
12
12
  WorkspaceSetupLoadError,
13
+ type WorkspaceSetupRouteOptions,
13
14
  type WorkspaceSetupState,
14
15
  } from '@shipfox/client-shell/runtime';
15
16
  import type {QueryClient} from '@tanstack/react-query';
@@ -17,15 +18,12 @@ import {redirect} from '@tanstack/react-router';
17
18
 
18
19
  const TRAILING_SLASHES_RE = /\/+$/u;
19
20
 
20
- export interface WorkspaceSetupRouteOptions {
21
- queryClient: QueryClient;
22
- workspaceId: string;
23
- pathname: string;
24
- }
21
+ export type {WorkspaceSetupRouteOptions} from '@shipfox/client-shell/runtime';
25
22
 
26
23
  export async function loadWorkspaceSetupRoute({
27
24
  queryClient,
28
25
  workspaceId,
26
+ workspaceSlug,
29
27
  pathname,
30
28
  }: WorkspaceSetupRouteOptions): Promise<WorkspaceSetupState> {
31
29
  const workspace = await fetchWorkspaceSummary(queryClient, workspaceId);
@@ -45,10 +43,10 @@ export async function loadWorkspaceSetupRoute({
45
43
  const normalizedPathname = normalizePath(pathname);
46
44
 
47
45
  if (projects.projects.length > 0) {
48
- if (isIntegrationsIndexPath(normalizedPathname, workspaceId)) {
46
+ if (isIntegrationsIndexPath(normalizedPathname, workspaceSlug)) {
49
47
  throw redirect({
50
- to: '/workspaces/$wid/settings/integrations',
51
- params: {wid: workspaceId},
48
+ to: '/w/$workspaceSlug/settings/integrations',
49
+ params: {workspaceSlug},
52
50
  replace: true,
53
51
  });
54
52
  }
@@ -60,41 +58,41 @@ export async function loadWorkspaceSetupRoute({
60
58
  const hasSourceConnection = sourceConnections.length > 0;
61
59
 
62
60
  if (!hasSourceConnection) {
63
- if (isIntegrationSetupPath(normalizedPathname, workspaceId)) {
61
+ if (isIntegrationSetupPath(normalizedPathname, workspaceSlug)) {
64
62
  return {hideProjectNavigation: true};
65
63
  }
66
64
 
67
65
  throw redirect({
68
- to: '/workspaces/$wid/integrations',
69
- params: {wid: workspaceId},
66
+ to: '/w/$workspaceSlug/integrations',
67
+ params: {workspaceSlug},
70
68
  replace: true,
71
69
  });
72
70
  }
73
71
 
74
- if (isAgentSettingsPath(normalizedPathname, workspaceId)) {
72
+ if (isAgentSettingsPath(normalizedPathname, workspaceSlug)) {
75
73
  return {hideProjectNavigation: true};
76
74
  }
77
75
 
78
76
  const providerHandled = await hasHandledModelProviderOnboarding(queryClient, workspaceId);
79
77
  if (!providerHandled) {
80
- if (isModelProviderOnboardingPath(normalizedPathname, workspaceId)) {
78
+ if (isModelProviderOnboardingPath(normalizedPathname, workspaceSlug)) {
81
79
  return {hideProjectNavigation: true};
82
80
  }
83
81
 
84
82
  throw redirect({
85
- to: '/workspaces/$wid/model-provider',
86
- params: {wid: workspaceId},
83
+ to: '/w/$workspaceSlug/model-provider',
84
+ params: {workspaceSlug},
87
85
  replace: true,
88
86
  });
89
87
  }
90
88
 
91
- if (isProjectCreationPath(normalizedPathname, workspaceId)) {
89
+ if (isProjectCreationPath(normalizedPathname, workspaceSlug)) {
92
90
  return {hideProjectNavigation: true};
93
91
  }
94
92
 
95
93
  throw redirect({
96
- to: '/workspaces/$wid/projects/new',
97
- params: {wid: workspaceId},
94
+ to: '/w/$workspaceSlug/projects/new',
95
+ params: {workspaceSlug},
98
96
  replace: true,
99
97
  });
100
98
  }
@@ -157,31 +155,31 @@ function normalizePath(pathname: string) {
157
155
  return pathname.replace(TRAILING_SLASHES_RE, '');
158
156
  }
159
157
 
160
- function workspacePath(workspaceId: string, suffix: string) {
161
- return `/workspaces/${workspaceId}${suffix}`;
158
+ function workspacePath(workspaceSlug: string, suffix: string) {
159
+ return `/w/${workspaceSlug}${suffix}`;
162
160
  }
163
161
 
164
- function isIntegrationsIndexPath(pathname: string, workspaceId: string) {
165
- return pathname === workspacePath(workspaceId, '/integrations');
162
+ function isIntegrationsIndexPath(pathname: string, workspaceSlug: string) {
163
+ return pathname === workspacePath(workspaceSlug, '/integrations');
166
164
  }
167
165
 
168
- function isIntegrationSetupPath(pathname: string, workspaceId: string) {
169
- const basePath = workspacePath(workspaceId, '/integrations');
166
+ function isIntegrationSetupPath(pathname: string, workspaceSlug: string) {
167
+ const basePath = workspacePath(workspaceSlug, '/integrations');
170
168
  return (
171
169
  pathname === basePath ||
172
170
  pathname.startsWith(`${basePath}/`) ||
173
- pathname === workspacePath(workspaceId, '/settings/integrations')
171
+ pathname === workspacePath(workspaceSlug, '/settings/integrations')
174
172
  );
175
173
  }
176
174
 
177
- function isProjectCreationPath(pathname: string, workspaceId: string) {
178
- return pathname === workspacePath(workspaceId, '/projects/new');
175
+ function isProjectCreationPath(pathname: string, workspaceSlug: string) {
176
+ return pathname === workspacePath(workspaceSlug, '/projects/new');
179
177
  }
180
178
 
181
- function isModelProviderOnboardingPath(pathname: string, workspaceId: string) {
182
- return pathname === workspacePath(workspaceId, '/model-provider');
179
+ function isModelProviderOnboardingPath(pathname: string, workspaceSlug: string) {
180
+ return pathname === workspacePath(workspaceSlug, '/model-provider');
183
181
  }
184
182
 
185
- function isAgentSettingsPath(pathname: string, workspaceId: string) {
186
- return pathname === workspacePath(workspaceId, '/settings/agents');
183
+ function isAgentSettingsPath(pathname: string, workspaceSlug: string) {
184
+ return pathname === workspacePath(workspaceSlug, '/settings/agents');
187
185
  }