@burdenoff/microfe-workspaces 2026.802.1 → 2026.825.1

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.
Files changed (49) hide show
  1. package/dist/generated/global-operations.js +44 -1
  2. package/dist/generated/global-operations.js.map +1 -1
  3. package/dist/generated/wspace-operations.js +18 -18
  4. package/dist/generated/wspace-operations.js.map +1 -1
  5. package/dist/hooks/useWorkspaceMutations.js +84 -61
  6. package/dist/hooks/useWorkspaceMutations.js.map +1 -1
  7. package/dist/pages/WorkspaceDetailPage.js +152 -114
  8. package/dist/pages/WorkspaceDetailPage.js.map +1 -1
  9. package/dist/pages/dashboard/DashboardCustomizer.js +62 -62
  10. package/dist/pages/dashboard/DashboardCustomizer.js.map +1 -1
  11. package/dist/pages/dashboard/DashboardPage.js +88 -69
  12. package/dist/pages/dashboard/DashboardPage.js.map +1 -1
  13. package/dist/pages/dashboard/config.js +77 -1
  14. package/dist/pages/dashboard/config.js.map +1 -1
  15. package/dist/pages/dashboard/widgets/AgentsWidget.js +56 -54
  16. package/dist/pages/dashboard/widgets/AgentsWidget.js.map +1 -1
  17. package/dist/pages/dashboard/widgets/GroupsWidget.js +29 -31
  18. package/dist/pages/dashboard/widgets/GroupsWidget.js.map +1 -1
  19. package/dist/pages/dashboard/widgets/MembersWidget.js +33 -33
  20. package/dist/pages/dashboard/widgets/MembersWidget.js.map +1 -1
  21. package/dist/pages/dashboard/widgets/ProjectsWidget.js +42 -44
  22. package/dist/pages/dashboard/widgets/ProjectsWidget.js.map +1 -1
  23. package/dist/pages/dashboard/widgets/QuickActionsWidget.js +171 -161
  24. package/dist/pages/dashboard/widgets/QuickActionsWidget.js.map +1 -1
  25. package/dist/pages/dashboard/widgets/RecentActivityWidget.js +54 -44
  26. package/dist/pages/dashboard/widgets/RecentActivityWidget.js.map +1 -1
  27. package/dist/pages/dashboard/widgets/SessionsWidget.js +57 -41
  28. package/dist/pages/dashboard/widgets/SessionsWidget.js.map +1 -1
  29. package/dist/pages/dashboard/widgets/StorageWidget.js +52 -54
  30. package/dist/pages/dashboard/widgets/StorageWidget.js.map +1 -1
  31. package/dist/pages/dashboard/widgets/TagCloudWidget.js +28 -30
  32. package/dist/pages/dashboard/widgets/TagCloudWidget.js.map +1 -1
  33. package/dist/pages/dashboard/widgets/TipsWidget.js +141 -131
  34. package/dist/pages/dashboard/widgets/TipsWidget.js.map +1 -1
  35. package/dist/pages/dashboard/widgets/UpcomingEventsWidget.js +46 -40
  36. package/dist/pages/dashboard/widgets/UpcomingEventsWidget.js.map +1 -1
  37. package/dist/pages/dashboard/widgets/VibesWidget.js +44 -34
  38. package/dist/pages/dashboard/widgets/VibesWidget.js.map +1 -1
  39. package/dist/pages/dashboard/widgets/WelcomeWidget.js +43 -41
  40. package/dist/pages/dashboard/widgets/WelcomeWidget.js.map +1 -1
  41. package/dist/pages/dashboard/widgets/WorkflowRunsWidget.js +68 -62
  42. package/dist/pages/dashboard/widgets/WorkflowRunsWidget.js.map +1 -1
  43. package/dist/pages/dashboard/widgets/WorkflowStatsWidget.js +50 -44
  44. package/dist/pages/dashboard/widgets/WorkflowStatsWidget.js.map +1 -1
  45. package/dist/pages/dashboard/widgets/WorkflowsOverviewWidget.js +59 -49
  46. package/dist/pages/dashboard/widgets/WorkflowsOverviewWidget.js.map +1 -1
  47. package/dist/pages/dashboard/widgets/WorkspacesWidget.js +35 -33
  48. package/dist/pages/dashboard/widgets/WorkspacesWidget.js.map +1 -1
  49. package/package.json +2 -2
@@ -1,34 +1,35 @@
1
1
  import { useWorkspacesContext as e } from "../providers/WorkspacesProvider.js";
2
- import { ArchiveWorkspaceDocument as t, DeleteWorkspaceDocument as n, ReactivateWorkspaceDocument as r, UpdateWorkspaceDocument as i } from "../generated/wspace-operations.js";
3
- import { useWorkspacesEventEmitter as a } from "./useWorkspacesEventEmitter.js";
4
- import { safeTelemetryError as o } from "../utils/telemetryError.js";
5
- import { useMutation as s, useQueryClient as c } from "@tanstack/react-query";
6
- import { print as l } from "graphql";
7
- import { graphqlFetch as u } from "@burdenoff/fe-libs/shared/graphql";
2
+ import { DeleteWorkspaceDocument as t, UpdateWorkspaceDocument as n } from "../generated/wspace-operations.js";
3
+ import { ActivateGlobalWorkspaceDocument as r, ArchiveGlobalWorkspaceDocument as i, UpdateGlobalWorkspaceDocument as a } from "../generated/global-operations.js";
4
+ import { useWorkspacesEventEmitter as o } from "./useWorkspacesEventEmitter.js";
5
+ import { safeTelemetryError as s } from "../utils/telemetryError.js";
6
+ import { useMutation as c, useQueryClient as l } from "@tanstack/react-query";
7
+ import { print as u } from "graphql";
8
+ import { graphqlFetch as d } from "@burdenoff/fe-libs/shared/graphql";
8
9
  //#region src/hooks/useWorkspaceMutations.ts
9
- var d = "\n mutation CreateGlobalWorkspace($input: CreateWorkspaceInput!) {\n createWorkspace(input: $input) {\n id\n name\n slug\n type\n status\n tenantId\n organizationId\n createdAt\n }\n }\n";
10
- function f(e, t) {
10
+ var f = "\n mutation CreateGlobalWorkspace($input: CreateWorkspaceInput!) {\n createWorkspace(input: $input) {\n id\n name\n slug\n type\n status\n tenantId\n organizationId\n createdAt\n }\n }\n";
11
+ function p(e, t) {
11
12
  e.invalidateQueries({ queryKey: ["workspaces"] }), t && (e.invalidateQueries({ queryKey: ["workspace", t] }), e.invalidateQueries({ queryKey: [
12
13
  "dashboard",
13
14
  "workspace",
14
15
  t
15
16
  ] })), e.invalidateQueries({ queryKey: ["myWorkspaces"] }), e.invalidateQueries({ queryKey: ["myTenants"] }), e.invalidateQueries({ queryKey: ["myOrganizations"] }), e.invalidateQueries({ queryKey: ["dashboard", "global"] });
16
17
  }
17
- var p = () => {
18
- let { authToken: t, onWorkspaceCreate: n } = e(), r = c(), { emit: i } = a();
19
- return s({
18
+ var m = () => {
19
+ let { authToken: t, onWorkspaceCreate: n } = e(), r = l(), { emit: i } = o();
20
+ return c({
20
21
  mutationFn: async (e) => {
21
- let n = await u({
22
+ let n = await d({
22
23
  gateway: "global",
23
24
  authToken: t || void 0,
24
- query: d,
25
+ query: f,
25
26
  variables: { input: e }
26
27
  });
27
28
  if (n.errors?.length) throw Error(n.errors[0]?.message || "Failed to create workspace");
28
29
  return n.data.createWorkspace;
29
30
  },
30
31
  onSuccess: (e) => {
31
- f(r, e.id), i("workspace.created", {
32
+ p(r, e.id), i("workspace.created", {
32
33
  workspaceId: e.id,
33
34
  source: "microfe-workspaces"
34
35
  }), n && n(e);
@@ -36,49 +37,73 @@ var p = () => {
36
37
  onError: (e) => {
37
38
  i("workspace.create_failed", {
38
39
  source: "microfe-workspaces",
39
- errorMessage: o(e)
40
+ errorMessage: s(e)
40
41
  });
41
42
  }
42
43
  });
43
- }, m = () => {
44
- let { authToken: t } = e(), n = c(), { emit: r } = a();
45
- return s({
46
- mutationFn: async ({ id: e, input: n }) => {
47
- let r = await u({
44
+ }, h = () => {
45
+ let { authToken: t } = e(), r = l(), { emit: i } = o();
46
+ return c({
47
+ mutationFn: async ({ id: e, input: r }) => {
48
+ let { name: i, ...o } = r, s;
49
+ if (i !== void 0) {
50
+ let n = await d({
51
+ gateway: "global",
52
+ authToken: t || void 0,
53
+ query: u(a),
54
+ variables: {
55
+ id: e,
56
+ input: { name: i }
57
+ }
58
+ });
59
+ if (n.errors?.length) throw Error(n.errors[0]?.message || "GraphQL error");
60
+ s = n.data.updateWorkspace;
61
+ }
62
+ if (!Object.values(o).some((e) => e !== void 0)) {
63
+ if (!s) throw Error("No workspace changes were provided");
64
+ return s;
65
+ }
66
+ let c = await d({
48
67
  gateway: "workspace",
49
68
  authToken: t || void 0,
50
- query: l(i),
69
+ query: u(n),
51
70
  variables: {
52
71
  id: e,
53
- input: n
72
+ input: o
54
73
  },
55
74
  workspaceToken: !0
56
75
  });
57
- if (r.errors?.length) throw Error(r.errors[0]?.message || "GraphQL error");
58
- return r.data.updateWorkspace;
76
+ if (c.errors?.length) throw Error(c.errors[0]?.message || "GraphQL error");
77
+ return {
78
+ ...c.data.updateWorkspace,
79
+ ...s ? { name: s.name } : {}
80
+ };
59
81
  },
60
82
  onSuccess: (e) => {
61
- f(n, e.id), r("workspace.updated", {
83
+ r.setQueryData(["workspace", e.id], (t) => ({
84
+ ...t,
85
+ ...e
86
+ })), p(r, e.id), i("workspace.updated", {
62
87
  workspaceId: e.id,
63
88
  source: "microfe-workspaces"
64
89
  });
65
90
  },
66
91
  onError: (e, t) => {
67
- r("workspace.update_failed", {
92
+ i("workspace.update_failed", {
68
93
  workspaceId: t?.id,
69
94
  source: "microfe-workspaces",
70
- errorMessage: o(e)
95
+ errorMessage: s(e)
71
96
  });
72
97
  }
73
98
  });
74
- }, h = () => {
75
- let { authToken: t } = e(), r = c(), { emit: i } = a();
76
- return s({
99
+ }, g = () => {
100
+ let { authToken: n } = e(), r = l(), { emit: i } = o();
101
+ return c({
77
102
  mutationFn: async (e) => {
78
- let r = await u({
103
+ let r = await d({
79
104
  gateway: "workspace",
80
- authToken: t || void 0,
81
- query: l(n),
105
+ authToken: n || void 0,
106
+ query: u(t),
82
107
  variables: { id: e },
83
108
  workspaceToken: !0
84
109
  });
@@ -86,7 +111,7 @@ var p = () => {
86
111
  return r.data.deleteWorkspace;
87
112
  },
88
113
  onSuccess: (e, t) => {
89
- f(r, t), i("workspace.deleted", {
114
+ p(r, t), i("workspace.deleted", {
90
115
  workspaceId: t,
91
116
  source: "microfe-workspaces"
92
117
  });
@@ -95,54 +120,52 @@ var p = () => {
95
120
  i("workspace.delete_failed", {
96
121
  workspaceId: t,
97
122
  source: "microfe-workspaces",
98
- errorMessage: o(e)
123
+ errorMessage: s(e)
99
124
  });
100
125
  }
101
126
  });
102
- }, g = () => {
103
- let { authToken: n } = e(), r = c(), { emit: i } = a();
104
- return s({
127
+ }, _ = () => {
128
+ let { authToken: t } = e(), n = l(), { emit: r } = o();
129
+ return c({
105
130
  mutationFn: async (e) => {
106
- let r = await u({
107
- gateway: "workspace",
108
- authToken: n || void 0,
109
- query: l(t),
110
- variables: { id: e },
111
- workspaceToken: !0
131
+ let n = await d({
132
+ gateway: "global",
133
+ authToken: t || void 0,
134
+ query: u(i),
135
+ variables: { id: e }
112
136
  });
113
- if (r.errors?.length) throw Error(r.errors[0]?.message || "GraphQL error");
114
- return r.data.updateWorkspace;
137
+ if (n.errors?.length) throw Error(n.errors[0]?.message || "GraphQL error");
138
+ return n.data.archiveWorkspace;
115
139
  },
116
140
  onSuccess: (e) => {
117
- f(r, e.id), i("workspace.archived", {
141
+ p(n, e.id), r("workspace.archived", {
118
142
  workspaceId: e.id,
119
143
  source: "microfe-workspaces"
120
144
  });
121
145
  },
122
146
  onError: (e, t) => {
123
- i("workspace.archive_failed", {
147
+ r("workspace.archive_failed", {
124
148
  workspaceId: t,
125
149
  source: "microfe-workspaces",
126
- errorMessage: o(e)
150
+ errorMessage: s(e)
127
151
  });
128
152
  }
129
153
  });
130
- }, _ = () => {
131
- let { authToken: t } = e(), n = c(), { emit: i } = a();
132
- return s({
154
+ }, v = () => {
155
+ let { authToken: t } = e(), n = l(), { emit: i } = o();
156
+ return c({
133
157
  mutationFn: async (e) => {
134
- let n = await u({
135
- gateway: "workspace",
158
+ let n = await d({
159
+ gateway: "global",
136
160
  authToken: t || void 0,
137
- query: l(r),
138
- variables: { id: e },
139
- workspaceToken: !0
161
+ query: u(r),
162
+ variables: { id: e }
140
163
  });
141
164
  if (n.errors?.length) throw Error(n.errors[0]?.message || "GraphQL error");
142
- return n.data.updateWorkspace;
165
+ return n.data.activateWorkspace;
143
166
  },
144
167
  onSuccess: (e) => {
145
- f(n, e.id), i("workspace.reactivated", {
168
+ p(n, e.id), i("workspace.reactivated", {
146
169
  workspaceId: e.id,
147
170
  source: "microfe-workspaces"
148
171
  });
@@ -151,12 +174,12 @@ var p = () => {
151
174
  i("workspace.reactivate_failed", {
152
175
  workspaceId: t,
153
176
  source: "microfe-workspaces",
154
- errorMessage: o(e)
177
+ errorMessage: s(e)
155
178
  });
156
179
  }
157
180
  });
158
181
  };
159
182
  //#endregion
160
- export { g as useArchiveWorkspace, p as useCreateWorkspace, h as useDeleteWorkspace, _ as useReactivateWorkspace, m as useUpdateWorkspace };
183
+ export { _ as useArchiveWorkspace, m as useCreateWorkspace, g as useDeleteWorkspace, v as useReactivateWorkspace, h as useUpdateWorkspace };
161
184
 
162
185
  //# sourceMappingURL=useWorkspaceMutations.js.map
@@ -1 +1 @@
1
- {"version":3,"file":"useWorkspaceMutations.js","names":[],"sources":["../../src/hooks/useWorkspaceMutations.ts"],"sourcesContent":["import { useMutation, useQueryClient, type QueryClient } from '@tanstack/react-query';\nimport { print } from 'graphql';\nimport { graphqlFetch } from '@burdenoff/fe-libs/shared/graphql';\nimport { useWorkspacesContext } from '../providers/WorkspacesProvider';\nimport { useWorkspacesEventEmitter } from './useWorkspacesEventEmitter';\nimport {\n UpdateWorkspaceDocument,\n DeleteWorkspaceDocument,\n ArchiveWorkspaceDocument,\n ReactivateWorkspaceDocument,\n} from '../generated/wspace-operations';\nimport type { CreateWorkspaceInput, UpdateWorkspaceInput, Workspace } from '../types';\nimport { safeTelemetryError } from '../utils/telemetryError';\n\n/**\n * GraphQL mutation to create workspace via global-tenant-svc\n * This creates workspace in global layer, which then syncs to wspace layer\n */\nconst CREATE_GLOBAL_WORKSPACE = `\n mutation CreateGlobalWorkspace($input: CreateWorkspaceInput!) {\n createWorkspace(input: $input) {\n id\n name\n slug\n type\n status\n tenantId\n organizationId\n createdAt\n }\n }\n`;\n\nfunction invalidateWorkspaceViews(queryClient: QueryClient, workspaceId?: string) {\n queryClient.invalidateQueries({ queryKey: ['workspaces'] });\n if (workspaceId) {\n queryClient.invalidateQueries({ queryKey: ['workspace', workspaceId] });\n queryClient.invalidateQueries({ queryKey: ['dashboard', 'workspace', workspaceId] });\n }\n queryClient.invalidateQueries({ queryKey: ['myWorkspaces'] });\n queryClient.invalidateQueries({ queryKey: ['myTenants'] });\n queryClient.invalidateQueries({ queryKey: ['myOrganizations'] });\n queryClient.invalidateQueries({ queryKey: ['dashboard', 'global'] });\n}\n\n/**\n * Hook to create a new workspace\n *\n * Creates workspace via global-tenant-svc (global gateway), which then\n * automatically syncs to wspace-workspace-svc. This ensures proper\n * tenant/org hierarchy management in the global layer.\n *\n * Required input fields:\n * - tenantId: Select from myTenants query\n * - organizationId: Select from myOrganizations query\n * - name: Display name\n * - slug: URL-friendly identifier (unique within tenant)\n */\nexport const useCreateWorkspace = () => {\n const { authToken, onWorkspaceCreate } = useWorkspacesContext();\n const queryClient = useQueryClient();\n const { emit } = useWorkspacesEventEmitter();\n\n return useMutation({\n mutationFn: async (input: CreateWorkspaceInput): Promise<Workspace> => {\n // Call global gateway for workspace creation\n const result = await graphqlFetch<{ createWorkspace: Workspace }>({\n gateway: 'global', // Use global gateway, not workspace gateway\n authToken: authToken || undefined,\n query: CREATE_GLOBAL_WORKSPACE,\n variables: { input },\n });\n\n if (result.errors?.length) {\n throw new Error(result.errors[0]?.message || 'Failed to create workspace');\n }\n\n return result.data!.createWorkspace;\n },\n onSuccess: (workspace) => {\n // Invalidate both global and workspace layer queries\n invalidateWorkspaceViews(queryClient, workspace.id);\n emit('workspace.created', { workspaceId: workspace.id, source: 'microfe-workspaces' });\n if (onWorkspaceCreate) {\n onWorkspaceCreate(workspace);\n }\n },\n onError: (err) => {\n emit('workspace.create_failed', {\n source: 'microfe-workspaces',\n errorMessage: safeTelemetryError(err),\n });\n },\n });\n};\n\n/**\n * Hook to update an existing workspace\n */\nexport const useUpdateWorkspace = () => {\n const { authToken } = useWorkspacesContext();\n const queryClient = useQueryClient();\n const { emit } = useWorkspacesEventEmitter();\n\n return useMutation({\n mutationFn: async ({\n id,\n input,\n }: {\n id: string;\n input: UpdateWorkspaceInput;\n }): Promise<Workspace> => {\n const result = await graphqlFetch<{ updateWorkspace: Workspace }>({\n gateway: 'workspace',\n authToken: authToken || undefined,\n query: print(UpdateWorkspaceDocument),\n variables: { id, input },\n workspaceToken: true, // Required by gateway RBAC for wspace-scoped operations\n });\n\n if (result.errors?.length) {\n throw new Error(result.errors[0]?.message || 'GraphQL error');\n }\n\n return result.data!.updateWorkspace;\n },\n onSuccess: (workspace) => {\n invalidateWorkspaceViews(queryClient, workspace.id);\n emit('workspace.updated', { workspaceId: workspace.id, source: 'microfe-workspaces' });\n },\n onError: (err, variables) => {\n emit('workspace.update_failed', {\n workspaceId: variables?.id,\n source: 'microfe-workspaces',\n errorMessage: safeTelemetryError(err),\n });\n },\n });\n};\n\n/**\n * Hook to delete a workspace\n */\nexport const useDeleteWorkspace = () => {\n const { authToken } = useWorkspacesContext();\n const queryClient = useQueryClient();\n const { emit } = useWorkspacesEventEmitter();\n\n return useMutation({\n mutationFn: async (id: string): Promise<boolean> => {\n const result = await graphqlFetch<{ deleteWorkspace: boolean }>({\n gateway: 'workspace',\n authToken: authToken || undefined,\n query: print(DeleteWorkspaceDocument),\n variables: { id },\n workspaceToken: true, // Required by gateway RBAC for wspace-scoped operations\n });\n\n if (result.errors?.length) {\n throw new Error(result.errors[0]?.message || 'GraphQL error');\n }\n\n return result.data!.deleteWorkspace;\n },\n onSuccess: (_, id) => {\n invalidateWorkspaceViews(queryClient, id);\n emit('workspace.deleted', { workspaceId: id, source: 'microfe-workspaces' });\n },\n onError: (err, id) => {\n emit('workspace.delete_failed', {\n workspaceId: id,\n source: 'microfe-workspaces',\n errorMessage: safeTelemetryError(err),\n });\n },\n });\n};\n\n/**\n * Hook to archive a workspace\n */\nexport const useArchiveWorkspace = () => {\n const { authToken } = useWorkspacesContext();\n const queryClient = useQueryClient();\n const { emit } = useWorkspacesEventEmitter();\n\n return useMutation({\n mutationFn: async (id: string): Promise<Workspace> => {\n const result = await graphqlFetch<{ updateWorkspace: Workspace }>({\n gateway: 'workspace',\n authToken: authToken || undefined,\n query: print(ArchiveWorkspaceDocument),\n variables: { id },\n workspaceToken: true, // Required by gateway RBAC for wspace-scoped operations\n });\n\n if (result.errors?.length) {\n throw new Error(result.errors[0]?.message || 'GraphQL error');\n }\n\n return result.data!.updateWorkspace;\n },\n onSuccess: (workspace) => {\n invalidateWorkspaceViews(queryClient, workspace.id);\n emit('workspace.archived', { workspaceId: workspace.id, source: 'microfe-workspaces' });\n },\n onError: (err, id) => {\n emit('workspace.archive_failed', {\n workspaceId: id,\n source: 'microfe-workspaces',\n errorMessage: safeTelemetryError(err),\n });\n },\n });\n};\n\n/**\n * Hook to reactivate an archived workspace\n */\nexport const useReactivateWorkspace = () => {\n const { authToken } = useWorkspacesContext();\n const queryClient = useQueryClient();\n const { emit } = useWorkspacesEventEmitter();\n\n return useMutation({\n mutationFn: async (id: string): Promise<Workspace> => {\n const result = await graphqlFetch<{ updateWorkspace: Workspace }>({\n gateway: 'workspace',\n authToken: authToken || undefined,\n query: print(ReactivateWorkspaceDocument),\n variables: { id },\n workspaceToken: true, // Required by gateway RBAC for wspace-scoped operations\n });\n\n if (result.errors?.length) {\n throw new Error(result.errors[0]?.message || 'GraphQL error');\n }\n\n return result.data!.updateWorkspace;\n },\n onSuccess: (workspace) => {\n invalidateWorkspaceViews(queryClient, workspace.id);\n emit('workspace.reactivated', { workspaceId: workspace.id, source: 'microfe-workspaces' });\n },\n onError: (err, id) => {\n emit('workspace.reactivate_failed', {\n workspaceId: id,\n source: 'microfe-workspaces',\n errorMessage: safeTelemetryError(err),\n });\n },\n });\n};\n"],"mappings":";;;;;;;;AAkBA,IAAM,IAA0B;AAehC,SAAS,EAAyB,GAA0B,GAAsB;AAShF,CARA,EAAY,kBAAkB,EAAE,UAAU,CAAC,aAAa,EAAE,CAAC,EACvD,MACF,EAAY,kBAAkB,EAAE,UAAU,CAAC,aAAa,EAAY,EAAE,CAAC,EACvE,EAAY,kBAAkB,EAAE,UAAU;EAAC;EAAa;EAAa;EAAY,EAAE,CAAC,GAEtF,EAAY,kBAAkB,EAAE,UAAU,CAAC,eAAe,EAAE,CAAC,EAC7D,EAAY,kBAAkB,EAAE,UAAU,CAAC,YAAY,EAAE,CAAC,EAC1D,EAAY,kBAAkB,EAAE,UAAU,CAAC,kBAAkB,EAAE,CAAC,EAChE,EAAY,kBAAkB,EAA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BAA4B;IAC/B,aAAa;IACb,QAAQ;IACR,cAAc,EAAmB,EAAI;IACtC,CAAC;;EAEL,CAAC;GAMS,UAA+B;CAC1C,IAAM,EAAE,iBAAc,GAAsB,EACtC,IAAc,GAAgB,EAC9B,EAAE,YAAS,GAA2B;AAE5C,QAAO,EAAY;EACjB,YAAY,OAAO,MAAmC;GACpD,IAAM,IAAS,MAAM,EAA6C;IAChE,SAAS;IACT,WAAW,KAAa,KAAA;IACxB,OAAO,EAAM,EAA4B;IACzC,WAAW,EAAE,OAAI;IACjB,gBAAgB;IACjB,CAAC;AAEF,OAAI,EAAO,QAAQ,OACjB,OAAU,MAAM,EAAO,OAAO,IAAI,WAAW,gBAAgB;AAG/D,UAAO,EAAO,KAAM;;EAEtB,YAAY,MAAc;AAExB,GADA,EAAyB,GAAa,EAAU,GAAG,EACnD,EAAK,yBAAyB;IAAE,aAAa,EAAU;IAAI,QAAQ;IAAsB,CAAC;;EAE5F,UAAU,GAAK,MAAO;AACpB,KAAK,+BAA+B;IAClC,aAAa;IACb,QAAQ;IACR,cAAc,EAAmB,EAAI;IACtC,CAAC;;EAEL,CAAC"}
1
+ {"version":3,"file":"useWorkspaceMutations.js","names":[],"sources":["../../src/hooks/useWorkspaceMutations.ts"],"sourcesContent":["import { useMutation, useQueryClient, type QueryClient } from '@tanstack/react-query';\nimport { print } from 'graphql';\nimport { graphqlFetch } from '@burdenoff/fe-libs/shared/graphql';\nimport { useWorkspacesContext } from '../providers/WorkspacesProvider';\nimport { useWorkspacesEventEmitter } from './useWorkspacesEventEmitter';\nimport { UpdateWorkspaceDocument, DeleteWorkspaceDocument } from '../generated/wspace-operations';\nimport {\n ActivateGlobalWorkspaceDocument,\n ArchiveGlobalWorkspaceDocument,\n UpdateGlobalWorkspaceDocument,\n} from '../generated/global-operations';\nimport type { CreateWorkspaceInput, UpdateWorkspaceInput, Workspace } from '../types';\nimport { safeTelemetryError } from '../utils/telemetryError';\n\n/**\n * GraphQL mutation to create workspace via global-tenant-svc\n * This creates workspace in global layer, which then syncs to wspace layer\n */\nconst CREATE_GLOBAL_WORKSPACE = `\n mutation CreateGlobalWorkspace($input: CreateWorkspaceInput!) {\n createWorkspace(input: $input) {\n id\n name\n slug\n type\n status\n tenantId\n organizationId\n createdAt\n }\n }\n`;\n\nfunction invalidateWorkspaceViews(queryClient: QueryClient, workspaceId?: string) {\n queryClient.invalidateQueries({ queryKey: ['workspaces'] });\n if (workspaceId) {\n queryClient.invalidateQueries({ queryKey: ['workspace', workspaceId] });\n queryClient.invalidateQueries({ queryKey: ['dashboard', 'workspace', workspaceId] });\n }\n queryClient.invalidateQueries({ queryKey: ['myWorkspaces'] });\n queryClient.invalidateQueries({ queryKey: ['myTenants'] });\n queryClient.invalidateQueries({ queryKey: ['myOrganizations'] });\n queryClient.invalidateQueries({ queryKey: ['dashboard', 'global'] });\n}\n\n/**\n * Hook to create a new workspace\n *\n * Creates workspace via global-tenant-svc (global gateway), which then\n * automatically syncs to wspace-workspace-svc. This ensures proper\n * tenant/org hierarchy management in the global layer.\n *\n * Required input fields:\n * - tenantId: Select from myTenants query\n * - organizationId: Select from myOrganizations query\n * - name: Display name\n * - slug: URL-friendly identifier (unique within tenant)\n */\nexport const useCreateWorkspace = () => {\n const { authToken, onWorkspaceCreate } = useWorkspacesContext();\n const queryClient = useQueryClient();\n const { emit } = useWorkspacesEventEmitter();\n\n return useMutation({\n mutationFn: async (input: CreateWorkspaceInput): Promise<Workspace> => {\n // Call global gateway for workspace creation\n const result = await graphqlFetch<{ createWorkspace: Workspace }>({\n gateway: 'global', // Use global gateway, not workspace gateway\n authToken: authToken || undefined,\n query: CREATE_GLOBAL_WORKSPACE,\n variables: { input },\n });\n\n if (result.errors?.length) {\n throw new Error(result.errors[0]?.message || 'Failed to create workspace');\n }\n\n return result.data!.createWorkspace;\n },\n onSuccess: (workspace) => {\n // Invalidate both global and workspace layer queries\n invalidateWorkspaceViews(queryClient, workspace.id);\n emit('workspace.created', { workspaceId: workspace.id, source: 'microfe-workspaces' });\n if (onWorkspaceCreate) {\n onWorkspaceCreate(workspace);\n }\n },\n onError: (err) => {\n emit('workspace.create_failed', {\n source: 'microfe-workspaces',\n errorMessage: safeTelemetryError(err),\n });\n },\n });\n};\n\n/**\n * Hook to update an existing workspace\n */\nexport const useUpdateWorkspace = () => {\n const { authToken } = useWorkspacesContext();\n const queryClient = useQueryClient();\n const { emit } = useWorkspacesEventEmitter();\n\n return useMutation({\n mutationFn: async ({\n id,\n input,\n }: {\n id: string;\n input: UpdateWorkspaceInput;\n }): Promise<Workspace> => {\n const { name, ...workspaceLayerInput } = input;\n let updatedWorkspace: Workspace | undefined;\n\n if (name !== undefined) {\n const globalResult = await graphqlFetch<{ updateWorkspace: Workspace }>({\n gateway: 'global',\n authToken: authToken || undefined,\n query: print(UpdateGlobalWorkspaceDocument),\n variables: { id, input: { name } },\n });\n\n if (globalResult.errors?.length) {\n throw new Error(globalResult.errors[0]?.message || 'GraphQL error');\n }\n\n updatedWorkspace = globalResult.data!.updateWorkspace;\n }\n\n const hasWorkspaceLayerChanges = Object.values(workspaceLayerInput).some(\n (value) => value !== undefined\n );\n if (!hasWorkspaceLayerChanges) {\n if (!updatedWorkspace) {\n throw new Error('No workspace changes were provided');\n }\n return updatedWorkspace;\n }\n\n const workspaceResult = await graphqlFetch<{ updateWorkspace: Workspace }>({\n gateway: 'workspace',\n authToken: authToken || undefined,\n query: print(UpdateWorkspaceDocument),\n variables: { id, input: workspaceLayerInput },\n workspaceToken: true, // Required by gateway RBAC for wspace-scoped operations\n });\n\n if (workspaceResult.errors?.length) {\n throw new Error(workspaceResult.errors[0]?.message || 'GraphQL error');\n }\n\n return {\n ...workspaceResult.data!.updateWorkspace,\n ...(updatedWorkspace ? { name: updatedWorkspace.name } : {}),\n };\n },\n onSuccess: (workspace) => {\n queryClient.setQueryData(['workspace', workspace.id], (current: Workspace | undefined) => ({\n ...current,\n ...workspace,\n }));\n invalidateWorkspaceViews(queryClient, workspace.id);\n emit('workspace.updated', { workspaceId: workspace.id, source: 'microfe-workspaces' });\n },\n onError: (err, variables) => {\n emit('workspace.update_failed', {\n workspaceId: variables?.id,\n source: 'microfe-workspaces',\n errorMessage: safeTelemetryError(err),\n });\n },\n });\n};\n\n/**\n * Hook to delete a workspace\n */\nexport const useDeleteWorkspace = () => {\n const { authToken } = useWorkspacesContext();\n const queryClient = useQueryClient();\n const { emit } = useWorkspacesEventEmitter();\n\n return useMutation({\n mutationFn: async (id: string): Promise<boolean> => {\n const result = await graphqlFetch<{ deleteWorkspace: boolean }>({\n gateway: 'workspace',\n authToken: authToken || undefined,\n query: print(DeleteWorkspaceDocument),\n variables: { id },\n workspaceToken: true, // Required by gateway RBAC for wspace-scoped operations\n });\n\n if (result.errors?.length) {\n throw new Error(result.errors[0]?.message || 'GraphQL error');\n }\n\n return result.data!.deleteWorkspace;\n },\n onSuccess: (_, id) => {\n invalidateWorkspaceViews(queryClient, id);\n emit('workspace.deleted', { workspaceId: id, source: 'microfe-workspaces' });\n },\n onError: (err, id) => {\n emit('workspace.delete_failed', {\n workspaceId: id,\n source: 'microfe-workspaces',\n errorMessage: safeTelemetryError(err),\n });\n },\n });\n};\n\n/**\n * Hook to archive a workspace\n */\nexport const useArchiveWorkspace = () => {\n const { authToken } = useWorkspacesContext();\n const queryClient = useQueryClient();\n const { emit } = useWorkspacesEventEmitter();\n\n return useMutation({\n mutationFn: async (id: string): Promise<Workspace> => {\n const result = await graphqlFetch<{ archiveWorkspace: Workspace }>({\n gateway: 'global',\n authToken: authToken || undefined,\n query: print(ArchiveGlobalWorkspaceDocument),\n variables: { id },\n });\n\n if (result.errors?.length) {\n throw new Error(result.errors[0]?.message || 'GraphQL error');\n }\n\n return result.data!.archiveWorkspace;\n },\n onSuccess: (workspace) => {\n invalidateWorkspaceViews(queryClient, workspace.id);\n emit('workspace.archived', { workspaceId: workspace.id, source: 'microfe-workspaces' });\n },\n onError: (err, id) => {\n emit('workspace.archive_failed', {\n workspaceId: id,\n source: 'microfe-workspaces',\n errorMessage: safeTelemetryError(err),\n });\n },\n });\n};\n\n/**\n * Hook to reactivate an archived workspace\n */\nexport const useReactivateWorkspace = () => {\n const { authToken } = useWorkspacesContext();\n const queryClient = useQueryClient();\n const { emit } = useWorkspacesEventEmitter();\n\n return useMutation({\n mutationFn: async (id: string): Promise<Workspace> => {\n const result = await graphqlFetch<{ activateWorkspace: Workspace }>({\n gateway: 'global',\n authToken: authToken || undefined,\n query: print(ActivateGlobalWorkspaceDocument),\n variables: { id },\n });\n\n if (result.errors?.length) {\n throw new Error(result.errors[0]?.message || 'GraphQL error');\n }\n\n return result.data!.activateWorkspace;\n },\n onSuccess: (workspace) => {\n invalidateWorkspaceViews(queryClient, workspace.id);\n emit('workspace.reactivated', { workspaceId: workspace.id, source: 'microfe-workspaces' });\n },\n onError: (err, id) => {\n emit('workspace.reactivate_failed', {\n workspaceId: id,\n source: 'microfe-workspaces',\n errorMessage: safeTelemetryError(err),\n });\n },\n });\n};\n"],"mappings":";;;;;;;;;AAkBA,IAAM,IAA0B;AAehC,SAAS,EAAyB,GAA0B,GAAsB;AAShF,CARA,EAAY,kBAAkB,EAAE,UAAU,CAAC,aAAa,EAAE,CAAC,EACvD,MACF,EAAY,kBAAkB,EAAE,UAAU,CAAC,aAAa,EAAY,EAAE,CAAC,EACvE,EAAY,kBAAkB,EAAE,UAAU;EAAC;EAAa;EAAa;EAAY,EAAE,CAAC,GAEtF,EAAY,kBAAkB,EAAE,UAAU,CAAC,eAAe,EAAE,CAAC,EAC7D,EAAY,kBAAkB,EAAE,UAAU,CAAC,YAAY,EAAE,CAAC,EAC1D,EAAY,kBAAkB,EAAE,UAAU,CAAC,kBAAkB,EAAE,CAAC,EAChE,EAAY,kBAAkB,EAAE,UAAU,CAAC,aAAa,SAAS,EAAE,CAAC;;AAgBtE,IAAa,UAA2B;CACtC,IAAM,EAAE,cAAW,yBAAsB,GAAsB,EACzD,IAAc,GAAgB,EAC9B,EAAE,YAAS,GAA2B;AAE5C,QAAO,E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