@burdenoff/microfe-workspaces 2026.530.2 → 2026.531.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 (33) hide show
  1. package/dist/WorkspacesRoutes.js +19 -15
  2. package/dist/WorkspacesRoutes.js.map +1 -1
  3. package/dist/components/ProjectCard.js +2 -2
  4. package/dist/components/ProjectCard.js.map +1 -1
  5. package/dist/components/tags/ProjectTagsWidget.js +53 -57
  6. package/dist/components/tags/ProjectTagsWidget.js.map +1 -1
  7. package/dist/generated/wspace-operations.js +24 -9
  8. package/dist/generated/wspace-operations.js.map +1 -1
  9. package/dist/hooks/index.js +1 -0
  10. package/dist/hooks/useMemberMutations.js +2 -2
  11. package/dist/hooks/useMemberMutations.js.map +1 -1
  12. package/dist/hooks/usePendingInvitations.js +29 -0
  13. package/dist/hooks/usePendingInvitations.js.map +1 -0
  14. package/dist/hooks/useProjectMutations.js +107 -6
  15. package/dist/hooks/useProjectMutations.js.map +1 -1
  16. package/dist/hooks/useProjects.js +1 -1
  17. package/dist/hooks/useProjects.js.map +1 -1
  18. package/dist/hooks/useWorkspaceMembers.js +1 -1
  19. package/dist/hooks/useWorkspaceMembers.js.map +1 -1
  20. package/dist/index.js +20 -18
  21. package/dist/pages/InviteAcceptancePage.js +68 -44
  22. package/dist/pages/InviteAcceptancePage.js.map +1 -1
  23. package/dist/pages/PendingInvitesPage.js +254 -0
  24. package/dist/pages/PendingInvitesPage.js.map +1 -0
  25. package/dist/pages/ProjectDetailPage.js +187 -161
  26. package/dist/pages/ProjectDetailPage.js.map +1 -1
  27. package/dist/pages/ProjectsListPage.js +2 -2
  28. package/dist/pages/ProjectsListPage.js.map +1 -1
  29. package/dist/pages/WorkspacesListPage.js +118 -102
  30. package/dist/pages/WorkspacesListPage.js.map +1 -1
  31. package/dist/utils/projectTags.js +28 -2
  32. package/dist/utils/projectTags.js.map +1 -1
  33. package/package.json +1 -1
@@ -1,4 +1,5 @@
1
1
  import "./useWorkspaces.js";
2
+ import "./usePendingInvitations.js";
2
3
  import "./useWorkspaceMembers.js";
3
4
  import "./useMemberMutations.js";
4
5
  import "./useWorkspaceMutations.js";
@@ -181,7 +181,7 @@ var v = () => {
181
181
  return i.data.acceptInvitation;
182
182
  },
183
183
  onSuccess: (e) => {
184
- i.invalidateQueries({ queryKey: ["workspaceInvitations"] }), i.invalidateQueries({ queryKey: ["workspaceMembers"] }), i.invalidateQueries({ queryKey: ["userWorkspaces"] }), a("workspace-invitation.accepted", {
184
+ i.invalidateQueries({ queryKey: ["workspaceInvitations"] }), i.invalidateQueries({ queryKey: ["myPendingInvitations"] }), i.invalidateQueries({ queryKey: ["workspaceMembers"] }), i.invalidateQueries({ queryKey: ["userWorkspaces"] }), i.invalidateQueries({ queryKey: ["myWorkspaces"] }), a("workspace-invitation.accepted", {
185
185
  invitationId: e.id,
186
186
  workspaceId: e.workspaceId,
187
187
  source: "microfe-workspaces"
@@ -212,7 +212,7 @@ var v = () => {
212
212
  return r.data.rejectInvitation;
213
213
  },
214
214
  onSuccess: (e) => {
215
- r.invalidateQueries({ queryKey: ["workspaceInvitations"] }), i("workspace-invitation.rejected", {
215
+ r.invalidateQueries({ queryKey: ["workspaceInvitations"] }), r.invalidateQueries({ queryKey: ["myPendingInvitations"] }), i("workspace-invitation.rejected", {
216
216
  invitationId: e.id,
217
217
  workspaceId: e.workspaceId,
218
218
  source: "microfe-workspaces"
@@ -1 +1 @@
1
- {"version":3,"file":"useMemberMutations.js","names":[],"sources":["../../src/hooks/useMemberMutations.ts"],"sourcesContent":["import { useMutation, useQueryClient } from '@tanstack/react-query';\nimport { print } from 'graphql';\nimport { graphqlFetch } from '@burdenoff/fe-libs/shared/graphql';\nimport { useWorkspacesContext } from '../providers/WorkspacesProvider';\nimport {\n AddWorkspaceMemberDocument,\n RemoveWorkspaceMemberDocument,\n RemoveUserFromWorkspaceDocument,\n CreateInvitationDocument,\n UpdateInvitationDocument,\n AcceptInvitationDocument,\n RejectInvitationDocument,\n CancelInvitationDocument,\n ResendInvitationDocument,\n DeleteInvitationDocument,\n BulkCreateInvitationsDocument,\n} from '../generated/wspace-operations';\nimport type {\n WorkspaceMember,\n WorkspaceInvitation,\n AddWorkspaceMemberInput,\n CreateInvitationInput,\n UpdateInvitationInput,\n} from '../types';\nimport { useWorkspacesEventEmitter } from './useWorkspacesEventEmitter';\nimport { safeTelemetryError } from '../utils/telemetryError';\n\n/**\n * Hook to add a member to a workspace\n * Requires x-workspace-id header for workspace context\n */\nexport const useAddWorkspaceMember = () => {\n const { authToken, workspaceId } = useWorkspacesContext();\n const queryClient = useQueryClient();\n const { emit } = useWorkspacesEventEmitter();\n\n return useMutation({\n mutationFn: async (input: AddWorkspaceMemberInput): Promise<WorkspaceMember> => {\n const result = await graphqlFetch<{ addWorkspaceMember: WorkspaceMember }>({\n gateway: 'workspace',\n authToken: authToken || undefined,\n query: print(AddWorkspaceMemberDocument),\n variables: { input },\n workspaceId: workspaceId || undefined,\n workspaceToken: true, // Auto-read from profile context for x-workspace-id header\n });\n\n if (result.errors?.length) {\n throw new Error(result.errors[0]?.message || 'GraphQL error');\n }\n\n return result.data!.addWorkspaceMember;\n },\n onSuccess: (data) => {\n queryClient.invalidateQueries({ queryKey: ['workspaceMembers', data.workspaceId] });\n queryClient.invalidateQueries({ queryKey: ['userWorkspaces'] });\n emit('workspace-member.added', {\n memberId: data.id,\n workspaceId: data.workspaceId,\n userId: data.userId,\n source: 'microfe-workspaces',\n });\n },\n onError: (err, input) => {\n emit('workspace-member.add_failed', {\n workspaceId: workspaceId || undefined,\n userId: input?.userId,\n source: 'microfe-workspaces',\n errorMessage: safeTelemetryError(err),\n });\n },\n });\n};\n\n/**\n * Hook to remove a member from a workspace by member ID\n */\nexport const useRemoveWorkspaceMember = (workspaceIdOverride?: string) => {\n const { authToken, workspaceId } = useWorkspacesContext();\n const queryClient = useQueryClient();\n const { emit } = useWorkspacesEventEmitter();\n const effectiveWorkspaceId = workspaceIdOverride || workspaceId;\n\n return useMutation({\n mutationFn: async (id: string): Promise<boolean> => {\n const result = await graphqlFetch<{ removeWorkspaceMember: boolean }>({\n gateway: 'workspace',\n authToken: authToken || undefined,\n query: print(RemoveWorkspaceMemberDocument),\n variables: { id },\n workspaceId: effectiveWorkspaceId || undefined,\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!.removeWorkspaceMember;\n },\n onSuccess: (_, id) => {\n queryClient.invalidateQueries({ queryKey: ['workspaceMembers'] });\n queryClient.invalidateQueries({ queryKey: ['userWorkspaces'] });\n emit('workspace-member.removed', { memberId: id, source: 'microfe-workspaces' });\n },\n onError: (err, id) => {\n emit('workspace-member.remove_failed', {\n memberId: id,\n workspaceId: effectiveWorkspaceId || undefined,\n source: 'microfe-workspaces',\n errorMessage: safeTelemetryError(err),\n });\n },\n });\n};\n\n/**\n * Hook to remove a user from a workspace\n * Requires x-workspace-id header for workspace context\n */\nexport const useRemoveUserFromWorkspace = (workspaceIdOverride?: string) => {\n const { authToken, workspaceId } = useWorkspacesContext();\n const queryClient = useQueryClient();\n const { emit } = useWorkspacesEventEmitter();\n const effectiveWorkspaceId = workspaceIdOverride || workspaceId;\n\n return useMutation({\n mutationFn: async (userId: string): Promise<boolean> => {\n const result = await graphqlFetch<{ removeUserFromWorkspace: boolean }>({\n gateway: 'workspace',\n authToken: authToken || undefined,\n query: print(RemoveUserFromWorkspaceDocument),\n variables: { userId },\n workspaceId: effectiveWorkspaceId || undefined,\n workspaceToken: true, // Auto-read from profile context for x-workspace-id header\n });\n\n if (result.errors?.length) {\n throw new Error(result.errors[0]?.message || 'GraphQL error');\n }\n\n return result.data!.removeUserFromWorkspace;\n },\n onSuccess: (_, userId) => {\n queryClient.invalidateQueries({ queryKey: ['workspaceMembers'] });\n queryClient.invalidateQueries({ queryKey: ['userWorkspaces', userId] });\n emit('workspace-member.removed', { userId, source: 'microfe-workspaces' });\n },\n onError: (err, userId) => {\n emit('workspace-member.remove_failed', {\n userId,\n workspaceId: effectiveWorkspaceId || undefined,\n source: 'microfe-workspaces',\n errorMessage: safeTelemetryError(err),\n });\n },\n });\n};\n\n/**\n * NOTE: The updateWorkspaceMemberRoles mutation has been removed from the backend.\n * Role management is now handled via invitations - when creating an invitation,\n * you can specify roleIds that will be assigned when the invitation is accepted.\n *\n * Use CreateInvitationInput.roleIds to assign roles to new members.\n */\n\n/**\n * Hook to create a workspace invitation\n * Uses x-workspace-id header as fallback when input.workspaceId is not provided\n */\nexport const useCreateInvitation = (workspaceIdOverride?: string) => {\n const { authToken, workspaceId } = useWorkspacesContext();\n const queryClient = useQueryClient();\n const { emit } = useWorkspacesEventEmitter();\n const effectiveWorkspaceId = workspaceIdOverride || workspaceId;\n\n return useMutation({\n mutationFn: async (input: CreateInvitationInput): Promise<WorkspaceInvitation> => {\n const result = await graphqlFetch<{ createInvitation: WorkspaceInvitation }>({\n gateway: 'workspace',\n authToken: authToken || undefined,\n query: print(CreateInvitationDocument),\n variables: { input },\n workspaceId: input.workspaceId || effectiveWorkspaceId || undefined,\n workspaceToken: true, // Auto-read from profile context for x-workspace-id header fallback\n });\n\n if (result.errors?.length) {\n throw new Error(result.errors[0]?.message || 'GraphQL error');\n }\n\n return result.data!.createInvitation;\n },\n onSuccess: (data) => {\n const wsId = data.workspaceId ?? effectiveWorkspaceId;\n if (wsId) {\n queryClient.invalidateQueries({ queryKey: ['workspaceInvitations', wsId] });\n }\n emit('workspace-invitation.created', {\n invitationId: data.id,\n workspaceId: data.workspaceId,\n email: data.email,\n source: 'microfe-workspaces',\n });\n },\n onError: (err, input) => {\n emit('workspace-invitation.create_failed', {\n workspaceId: input?.workspaceId || effectiveWorkspaceId || undefined,\n email: input?.email,\n source: 'microfe-workspaces',\n errorMessage: safeTelemetryError(err),\n });\n },\n });\n};\n\n/**\n * Hook to update an invitation\n */\nexport const useUpdateInvitation = () => {\n const { authToken, workspaceId } = 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: UpdateInvitationInput;\n }): Promise<WorkspaceInvitation> => {\n const result = await graphqlFetch<{ updateInvitation: WorkspaceInvitation }>({\n gateway: 'workspace',\n authToken: authToken || undefined,\n query: print(UpdateInvitationDocument),\n variables: { id, input },\n workspaceId: workspaceId || undefined,\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!.updateInvitation;\n },\n onSuccess: (data) => {\n queryClient.invalidateQueries({ queryKey: ['workspaceInvitations'] });\n emit('workspace-invitation.updated', {\n invitationId: data.id,\n workspaceId: data.workspaceId,\n source: 'microfe-workspaces',\n });\n },\n onError: (err, variables) => {\n emit('workspace-invitation.update_failed', {\n invitationId: variables?.id,\n workspaceId: workspaceId || undefined,\n source: 'microfe-workspaces',\n errorMessage: safeTelemetryError(err),\n });\n },\n });\n};\n\n/**\n * Hook to accept an invitation\n */\nexport const useAcceptInvitation = () => {\n const { authToken, workspaceId } = useWorkspacesContext();\n const queryClient = useQueryClient();\n const { emit } = useWorkspacesEventEmitter();\n\n return useMutation({\n mutationFn: async (id: string): Promise<WorkspaceInvitation> => {\n const result = await graphqlFetch<{ acceptInvitation: WorkspaceInvitation }>({\n gateway: 'workspace',\n authToken: authToken || undefined,\n query: print(AcceptInvitationDocument),\n variables: { id },\n workspaceId: workspaceId || undefined,\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!.acceptInvitation;\n },\n onSuccess: (data) => {\n queryClient.invalidateQueries({ queryKey: ['workspaceInvitations'] });\n queryClient.invalidateQueries({ queryKey: ['workspaceMembers'] });\n queryClient.invalidateQueries({ queryKey: ['userWorkspaces'] });\n emit('workspace-invitation.accepted', {\n invitationId: data.id,\n workspaceId: data.workspaceId,\n source: 'microfe-workspaces',\n });\n },\n onError: (err, id) => {\n emit('workspace-invitation.accept_failed', {\n invitationId: id,\n workspaceId: workspaceId || undefined,\n source: 'microfe-workspaces',\n errorMessage: safeTelemetryError(err),\n });\n },\n });\n};\n\n/**\n * Hook to reject an invitation\n */\nexport const useRejectInvitation = () => {\n const { authToken, workspaceId } = useWorkspacesContext();\n const queryClient = useQueryClient();\n const { emit } = useWorkspacesEventEmitter();\n\n return useMutation({\n mutationFn: async (id: string): Promise<WorkspaceInvitation> => {\n const result = await graphqlFetch<{ rejectInvitation: WorkspaceInvitation }>({\n gateway: 'workspace',\n authToken: authToken || undefined,\n query: print(RejectInvitationDocument),\n variables: { id },\n workspaceId: workspaceId || undefined,\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!.rejectInvitation;\n },\n onSuccess: (data) => {\n queryClient.invalidateQueries({ queryKey: ['workspaceInvitations'] });\n emit('workspace-invitation.rejected', {\n invitationId: data.id,\n workspaceId: data.workspaceId,\n source: 'microfe-workspaces',\n });\n },\n onError: (err, id) => {\n emit('workspace-invitation.reject_failed', {\n invitationId: id,\n workspaceId: workspaceId || undefined,\n source: 'microfe-workspaces',\n errorMessage: safeTelemetryError(err),\n });\n },\n });\n};\n\n/**\n * Hook to cancel an invitation\n */\nexport const useCancelInvitation = () => {\n const { authToken, workspaceId } = useWorkspacesContext();\n const queryClient = useQueryClient();\n const { emit } = useWorkspacesEventEmitter();\n\n return useMutation({\n mutationFn: async (id: string): Promise<WorkspaceInvitation> => {\n const result = await graphqlFetch<{ cancelInvitation: WorkspaceInvitation }>({\n gateway: 'workspace',\n authToken: authToken || undefined,\n query: print(CancelInvitationDocument),\n variables: { id },\n workspaceId: workspaceId || undefined,\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!.cancelInvitation;\n },\n onSuccess: (data) => {\n queryClient.invalidateQueries({ queryKey: ['workspaceInvitations'] });\n emit('workspace-invitation.cancelled', {\n invitationId: data.id,\n workspaceId: data.workspaceId,\n source: 'microfe-workspaces',\n });\n },\n onError: (err, id) => {\n emit('workspace-invitation.cancel_failed', {\n invitationId: id,\n workspaceId: workspaceId || undefined,\n source: 'microfe-workspaces',\n errorMessage: safeTelemetryError(err),\n });\n },\n });\n};\n\n/**\n * Hook to resend an invitation\n */\nexport const useResendInvitation = (workspaceIdOverride?: string) => {\n const { authToken, workspaceId } = useWorkspacesContext();\n const queryClient = useQueryClient();\n const { emit } = useWorkspacesEventEmitter();\n const effectiveWorkspaceId = workspaceIdOverride || workspaceId;\n\n return useMutation({\n mutationFn: async (id: string): Promise<WorkspaceInvitation> => {\n const result = await graphqlFetch<{ resendInvitation: WorkspaceInvitation }>({\n gateway: 'workspace',\n authToken: authToken || undefined,\n query: print(ResendInvitationDocument),\n variables: { id },\n workspaceId: effectiveWorkspaceId || undefined,\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!.resendInvitation;\n },\n onSuccess: (data) => {\n queryClient.invalidateQueries({ queryKey: ['workspaceInvitations'] });\n emit('workspace-invitation.resent', {\n invitationId: data.id,\n workspaceId: data.workspaceId,\n source: 'microfe-workspaces',\n });\n },\n onError: (err, id) => {\n emit('workspace-invitation.resend_failed', {\n invitationId: id,\n workspaceId: effectiveWorkspaceId || undefined,\n source: 'microfe-workspaces',\n errorMessage: safeTelemetryError(err),\n });\n },\n });\n};\n\n/**\n * Hook to delete an invitation\n */\nexport const useDeleteInvitation = () => {\n const { authToken, workspaceId } = 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<{ deleteInvitation: boolean }>({\n gateway: 'workspace',\n authToken: authToken || undefined,\n query: print(DeleteInvitationDocument),\n variables: { id },\n workspaceId: workspaceId || undefined,\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!.deleteInvitation;\n },\n onSuccess: (_, id) => {\n queryClient.invalidateQueries({ queryKey: ['workspaceInvitations'] });\n emit('workspace-invitation.deleted', { invitationId: id, source: 'microfe-workspaces' });\n },\n onError: (err, id) => {\n emit('workspace-invitation.delete_failed', {\n invitationId: id,\n workspaceId: workspaceId || undefined,\n source: 'microfe-workspaces',\n errorMessage: safeTelemetryError(err),\n });\n },\n });\n};\n\n/**\n * Hook to bulk create invitations\n * Uses x-workspace-id header as fallback when inputs[].workspaceId is not provided\n */\nexport const useBulkCreateInvitations = () => {\n const { authToken, workspaceId } = useWorkspacesContext();\n const queryClient = useQueryClient();\n\n return useMutation({\n mutationFn: async (inputs: CreateInvitationInput[]): Promise<WorkspaceInvitation[]> => {\n const result = await graphqlFetch<{ bulkCreateInvitations: WorkspaceInvitation[] }>({\n gateway: 'workspace',\n authToken: authToken || undefined,\n query: print(BulkCreateInvitationsDocument),\n variables: { inputs },\n workspaceId: inputs[0]?.workspaceId || workspaceId || undefined,\n workspaceToken: true, // Auto-read from profile context for x-workspace-id header fallback\n });\n\n if (result.errors?.length) {\n throw new Error(result.errors[0]?.message || 'GraphQL error');\n }\n\n return result.data!.bulkCreateInvitations;\n },\n onSuccess: () => {\n queryClient.invalidateQueries({ queryKey: ['workspaceInvitations'] });\n },\n });\n};\n"],"mappings":";;;;;;;;AA+BA,IAAa,UAA8B;CACzC,IAAM,EAAE,cAAW,mBAAgB,GAAsB,EACnD,IAAc,GAAgB,EAC9B,EAAE,YAAS,GAA2B;AAE5C,QAAO,EAAY;EACjB,YAAY,OAAO,MAA6D;GAC9E,IAAM,IAAS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E,CAAC,EACrE,EAAK,gCAAgC;IAAE,cAAc;IAAI,QAAQ;IAAsB,CAAC;;EAE1F,UAAU,GAAK,MAAO;AACpB,KAAK,sCAAsC;IACzC,cAAc;IACd,aAAa,KAAe,KAAA;IAC5B,QAAQ;IACR,cAAc,EAAmB,EAAI;IACtC,CAAC;;EAEL,CAAC;GAOS,UAAiC;CAC5C,IAAM,EAAE,cAAW,mBAAgB,GAAsB,EACnD,IAAc,GAAgB;AAEpC,QAAO,EAAY;EACjB,YAAY,OAAO,MAAoE;GACrF,IAAM,IAAS,MAAM,EAA+D;IAClF,SAAS;IACT,WAAW,KAAa,KAAA;IACxB,OAAO,EAAM,EAA8B;IAC3C,WAAW,EAAE,WAAQ;IACrB,aAAa,EAAO,IAAI,eAAe,KAAe,KAAA;IACtD,gBAAgB;IACjB,CAAC;AAEF,OAAI,EAAO,QAAQ,OACjB,OAAU,MAAM,EAAO,OAAO,IAAI,WAAW,gBAAgB;AAG/D,UAAO,EAAO,KAAM;;EAEtB,iBAAiB;AACf,KAAY,kBAAkB,EAAE,UAAU,CAAC,uBAAuB,EAAE,CAAC;;EAExE,CAAC"}
1
+ {"version":3,"file":"useMemberMutations.js","names":[],"sources":["../../src/hooks/useMemberMutations.ts"],"sourcesContent":["import { useMutation, useQueryClient } from '@tanstack/react-query';\nimport { print } from 'graphql';\nimport { graphqlFetch } from '@burdenoff/fe-libs/shared/graphql';\nimport { useWorkspacesContext } from '../providers/WorkspacesProvider';\nimport {\n AddWorkspaceMemberDocument,\n RemoveWorkspaceMemberDocument,\n RemoveUserFromWorkspaceDocument,\n CreateInvitationDocument,\n UpdateInvitationDocument,\n AcceptInvitationDocument,\n RejectInvitationDocument,\n CancelInvitationDocument,\n ResendInvitationDocument,\n DeleteInvitationDocument,\n BulkCreateInvitationsDocument,\n} from '../generated/wspace-operations';\nimport type {\n WorkspaceMember,\n WorkspaceInvitation,\n AddWorkspaceMemberInput,\n CreateInvitationInput,\n UpdateInvitationInput,\n} from '../types';\nimport { useWorkspacesEventEmitter } from './useWorkspacesEventEmitter';\nimport { safeTelemetryError } from '../utils/telemetryError';\n\n/**\n * Hook to add a member to a workspace\n * Requires x-workspace-id header for workspace context\n */\nexport const useAddWorkspaceMember = () => {\n const { authToken, workspaceId } = useWorkspacesContext();\n const queryClient = useQueryClient();\n const { emit } = useWorkspacesEventEmitter();\n\n return useMutation({\n mutationFn: async (input: AddWorkspaceMemberInput): Promise<WorkspaceMember> => {\n const result = await graphqlFetch<{ addWorkspaceMember: WorkspaceMember }>({\n gateway: 'workspace',\n authToken: authToken || undefined,\n query: print(AddWorkspaceMemberDocument),\n variables: { input },\n workspaceId: workspaceId || undefined,\n workspaceToken: true, // Auto-read from profile context for x-workspace-id header\n });\n\n if (result.errors?.length) {\n throw new Error(result.errors[0]?.message || 'GraphQL error');\n }\n\n return result.data!.addWorkspaceMember;\n },\n onSuccess: (data) => {\n queryClient.invalidateQueries({ queryKey: ['workspaceMembers', data.workspaceId] });\n queryClient.invalidateQueries({ queryKey: ['userWorkspaces'] });\n emit('workspace-member.added', {\n memberId: data.id,\n workspaceId: data.workspaceId,\n userId: data.userId,\n source: 'microfe-workspaces',\n });\n },\n onError: (err, input) => {\n emit('workspace-member.add_failed', {\n workspaceId: workspaceId || undefined,\n userId: input?.userId,\n source: 'microfe-workspaces',\n errorMessage: safeTelemetryError(err),\n });\n },\n });\n};\n\n/**\n * Hook to remove a member from a workspace by member ID\n */\nexport const useRemoveWorkspaceMember = (workspaceIdOverride?: string) => {\n const { authToken, workspaceId } = useWorkspacesContext();\n const queryClient = useQueryClient();\n const { emit } = useWorkspacesEventEmitter();\n const effectiveWorkspaceId = workspaceIdOverride || workspaceId;\n\n return useMutation({\n mutationFn: async (id: string): Promise<boolean> => {\n const result = await graphqlFetch<{ removeWorkspaceMember: boolean }>({\n gateway: 'workspace',\n authToken: authToken || undefined,\n query: print(RemoveWorkspaceMemberDocument),\n variables: { id },\n workspaceId: effectiveWorkspaceId || undefined,\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!.removeWorkspaceMember;\n },\n onSuccess: (_, id) => {\n queryClient.invalidateQueries({ queryKey: ['workspaceMembers'] });\n queryClient.invalidateQueries({ queryKey: ['userWorkspaces'] });\n emit('workspace-member.removed', { memberId: id, source: 'microfe-workspaces' });\n },\n onError: (err, id) => {\n emit('workspace-member.remove_failed', {\n memberId: id,\n workspaceId: effectiveWorkspaceId || undefined,\n source: 'microfe-workspaces',\n errorMessage: safeTelemetryError(err),\n });\n },\n });\n};\n\n/**\n * Hook to remove a user from a workspace\n * Requires x-workspace-id header for workspace context\n */\nexport const useRemoveUserFromWorkspace = (workspaceIdOverride?: string) => {\n const { authToken, workspaceId } = useWorkspacesContext();\n const queryClient = useQueryClient();\n const { emit } = useWorkspacesEventEmitter();\n const effectiveWorkspaceId = workspaceIdOverride || workspaceId;\n\n return useMutation({\n mutationFn: async (userId: string): Promise<boolean> => {\n const result = await graphqlFetch<{ removeUserFromWorkspace: boolean }>({\n gateway: 'workspace',\n authToken: authToken || undefined,\n query: print(RemoveUserFromWorkspaceDocument),\n variables: { userId },\n workspaceId: effectiveWorkspaceId || undefined,\n workspaceToken: true, // Auto-read from profile context for x-workspace-id header\n });\n\n if (result.errors?.length) {\n throw new Error(result.errors[0]?.message || 'GraphQL error');\n }\n\n return result.data!.removeUserFromWorkspace;\n },\n onSuccess: (_, userId) => {\n queryClient.invalidateQueries({ queryKey: ['workspaceMembers'] });\n queryClient.invalidateQueries({ queryKey: ['userWorkspaces', userId] });\n emit('workspace-member.removed', { userId, source: 'microfe-workspaces' });\n },\n onError: (err, userId) => {\n emit('workspace-member.remove_failed', {\n userId,\n workspaceId: effectiveWorkspaceId || undefined,\n source: 'microfe-workspaces',\n errorMessage: safeTelemetryError(err),\n });\n },\n });\n};\n\n/**\n * NOTE: The updateWorkspaceMemberRoles mutation has been removed from the backend.\n * Role management is now handled via invitations - when creating an invitation,\n * you can specify roleIds that will be assigned when the invitation is accepted.\n *\n * Use CreateInvitationInput.roleIds to assign roles to new members.\n */\n\n/**\n * Hook to create a workspace invitation\n * Uses x-workspace-id header as fallback when input.workspaceId is not provided\n */\nexport const useCreateInvitation = (workspaceIdOverride?: string) => {\n const { authToken, workspaceId } = useWorkspacesContext();\n const queryClient = useQueryClient();\n const { emit } = useWorkspacesEventEmitter();\n const effectiveWorkspaceId = workspaceIdOverride || workspaceId;\n\n return useMutation({\n mutationFn: async (input: CreateInvitationInput): Promise<WorkspaceInvitation> => {\n const result = await graphqlFetch<{ createInvitation: WorkspaceInvitation }>({\n gateway: 'workspace',\n authToken: authToken || undefined,\n query: print(CreateInvitationDocument),\n variables: { input },\n workspaceId: input.workspaceId || effectiveWorkspaceId || undefined,\n workspaceToken: true, // Auto-read from profile context for x-workspace-id header fallback\n });\n\n if (result.errors?.length) {\n throw new Error(result.errors[0]?.message || 'GraphQL error');\n }\n\n return result.data!.createInvitation;\n },\n onSuccess: (data) => {\n const wsId = data.workspaceId ?? effectiveWorkspaceId;\n if (wsId) {\n queryClient.invalidateQueries({ queryKey: ['workspaceInvitations', wsId] });\n }\n emit('workspace-invitation.created', {\n invitationId: data.id,\n workspaceId: data.workspaceId,\n email: data.email,\n source: 'microfe-workspaces',\n });\n },\n onError: (err, input) => {\n emit('workspace-invitation.create_failed', {\n workspaceId: input?.workspaceId || effectiveWorkspaceId || undefined,\n email: input?.email,\n source: 'microfe-workspaces',\n errorMessage: safeTelemetryError(err),\n });\n },\n });\n};\n\n/**\n * Hook to update an invitation\n */\nexport const useUpdateInvitation = () => {\n const { authToken, workspaceId } = 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: UpdateInvitationInput;\n }): Promise<WorkspaceInvitation> => {\n const result = await graphqlFetch<{ updateInvitation: WorkspaceInvitation }>({\n gateway: 'workspace',\n authToken: authToken || undefined,\n query: print(UpdateInvitationDocument),\n variables: { id, input },\n workspaceId: workspaceId || undefined,\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!.updateInvitation;\n },\n onSuccess: (data) => {\n queryClient.invalidateQueries({ queryKey: ['workspaceInvitations'] });\n emit('workspace-invitation.updated', {\n invitationId: data.id,\n workspaceId: data.workspaceId,\n source: 'microfe-workspaces',\n });\n },\n onError: (err, variables) => {\n emit('workspace-invitation.update_failed', {\n invitationId: variables?.id,\n workspaceId: workspaceId || undefined,\n source: 'microfe-workspaces',\n errorMessage: safeTelemetryError(err),\n });\n },\n });\n};\n\n/**\n * Hook to accept an invitation\n */\nexport const useAcceptInvitation = () => {\n const { authToken, workspaceId } = useWorkspacesContext();\n const queryClient = useQueryClient();\n const { emit } = useWorkspacesEventEmitter();\n\n return useMutation({\n mutationFn: async (id: string): Promise<WorkspaceInvitation> => {\n const result = await graphqlFetch<{ acceptInvitation: WorkspaceInvitation }>({\n gateway: 'workspace',\n authToken: authToken || undefined,\n query: print(AcceptInvitationDocument),\n variables: { id },\n workspaceId: workspaceId || undefined,\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!.acceptInvitation;\n },\n onSuccess: (data) => {\n queryClient.invalidateQueries({ queryKey: ['workspaceInvitations'] });\n queryClient.invalidateQueries({ queryKey: ['myPendingInvitations'] });\n queryClient.invalidateQueries({ queryKey: ['workspaceMembers'] });\n queryClient.invalidateQueries({ queryKey: ['userWorkspaces'] });\n queryClient.invalidateQueries({ queryKey: ['myWorkspaces'] });\n emit('workspace-invitation.accepted', {\n invitationId: data.id,\n workspaceId: data.workspaceId,\n source: 'microfe-workspaces',\n });\n },\n onError: (err, id) => {\n emit('workspace-invitation.accept_failed', {\n invitationId: id,\n workspaceId: workspaceId || undefined,\n source: 'microfe-workspaces',\n errorMessage: safeTelemetryError(err),\n });\n },\n });\n};\n\n/**\n * Hook to reject an invitation\n */\nexport const useRejectInvitation = () => {\n const { authToken, workspaceId } = useWorkspacesContext();\n const queryClient = useQueryClient();\n const { emit } = useWorkspacesEventEmitter();\n\n return useMutation({\n mutationFn: async (id: string): Promise<WorkspaceInvitation> => {\n const result = await graphqlFetch<{ rejectInvitation: WorkspaceInvitation }>({\n gateway: 'workspace',\n authToken: authToken || undefined,\n query: print(RejectInvitationDocument),\n variables: { id },\n workspaceId: workspaceId || undefined,\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!.rejectInvitation;\n },\n onSuccess: (data) => {\n queryClient.invalidateQueries({ queryKey: ['workspaceInvitations'] });\n queryClient.invalidateQueries({ queryKey: ['myPendingInvitations'] });\n emit('workspace-invitation.rejected', {\n invitationId: data.id,\n workspaceId: data.workspaceId,\n source: 'microfe-workspaces',\n });\n },\n onError: (err, id) => {\n emit('workspace-invitation.reject_failed', {\n invitationId: id,\n workspaceId: workspaceId || undefined,\n source: 'microfe-workspaces',\n errorMessage: safeTelemetryError(err),\n });\n },\n });\n};\n\n/**\n * Hook to cancel an invitation\n */\nexport const useCancelInvitation = () => {\n const { authToken, workspaceId } = useWorkspacesContext();\n const queryClient = useQueryClient();\n const { emit } = useWorkspacesEventEmitter();\n\n return useMutation({\n mutationFn: async (id: string): Promise<WorkspaceInvitation> => {\n const result = await graphqlFetch<{ cancelInvitation: WorkspaceInvitation }>({\n gateway: 'workspace',\n authToken: authToken || undefined,\n query: print(CancelInvitationDocument),\n variables: { id },\n workspaceId: workspaceId || undefined,\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!.cancelInvitation;\n },\n onSuccess: (data) => {\n queryClient.invalidateQueries({ queryKey: ['workspaceInvitations'] });\n emit('workspace-invitation.cancelled', {\n invitationId: data.id,\n workspaceId: data.workspaceId,\n source: 'microfe-workspaces',\n });\n },\n onError: (err, id) => {\n emit('workspace-invitation.cancel_failed', {\n invitationId: id,\n workspaceId: workspaceId || undefined,\n source: 'microfe-workspaces',\n errorMessage: safeTelemetryError(err),\n });\n },\n });\n};\n\n/**\n * Hook to resend an invitation\n */\nexport const useResendInvitation = (workspaceIdOverride?: string) => {\n const { authToken, workspaceId } = useWorkspacesContext();\n const queryClient = useQueryClient();\n const { emit } = useWorkspacesEventEmitter();\n const effectiveWorkspaceId = workspaceIdOverride || workspaceId;\n\n return useMutation({\n mutationFn: async (id: string): Promise<WorkspaceInvitation> => {\n const result = await graphqlFetch<{ resendInvitation: WorkspaceInvitation }>({\n gateway: 'workspace',\n authToken: authToken || undefined,\n query: print(ResendInvitationDocument),\n variables: { id },\n workspaceId: effectiveWorkspaceId || undefined,\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!.resendInvitation;\n },\n onSuccess: (data) => {\n queryClient.invalidateQueries({ queryKey: ['workspaceInvitations'] });\n emit('workspace-invitation.resent', {\n invitationId: data.id,\n workspaceId: data.workspaceId,\n source: 'microfe-workspaces',\n });\n },\n onError: (err, id) => {\n emit('workspace-invitation.resend_failed', {\n invitationId: id,\n workspaceId: effectiveWorkspaceId || undefined,\n source: 'microfe-workspaces',\n errorMessage: safeTelemetryError(err),\n });\n },\n });\n};\n\n/**\n * Hook to delete an invitation\n */\nexport const useDeleteInvitation = () => {\n const { authToken, workspaceId } = 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<{ deleteInvitation: boolean }>({\n gateway: 'workspace',\n authToken: authToken || undefined,\n query: print(DeleteInvitationDocument),\n variables: { id },\n workspaceId: workspaceId || undefined,\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!.deleteInvitation;\n },\n onSuccess: (_, id) => {\n queryClient.invalidateQueries({ queryKey: ['workspaceInvitations'] });\n emit('workspace-invitation.deleted', { invitationId: id, source: 'microfe-workspaces' });\n },\n onError: (err, id) => {\n emit('workspace-invitation.delete_failed', {\n invitationId: id,\n workspaceId: workspaceId || undefined,\n source: 'microfe-workspaces',\n errorMessage: safeTelemetryError(err),\n });\n },\n });\n};\n\n/**\n * Hook to bulk create invitations\n * Uses x-workspace-id header as fallback when inputs[].workspaceId is not provided\n */\nexport const useBulkCreateInvitations = () => {\n const { authToken, workspaceId } = useWorkspacesContext();\n const queryClient = useQueryClient();\n\n return useMutation({\n mutationFn: async (inputs: CreateInvitationInput[]): Promise<WorkspaceInvitation[]> => {\n const result = await graphqlFetch<{ bulkCreateInvitations: WorkspaceInvitation[] }>({\n gateway: 'workspace',\n authToken: authToken || undefined,\n query: print(BulkCreateInvitationsDocument),\n variables: { inputs },\n workspaceId: inputs[0]?.workspaceId || workspaceId || undefined,\n workspaceToken: true, // Auto-read from profile context for x-workspace-id header fallback\n });\n\n if (result.errors?.length) {\n throw new Error(result.errors[0]?.message || 'GraphQL error');\n }\n\n return result.data!.bulkCreateInvitations;\n },\n onSuccess: () => {\n queryClient.invalidateQueries({ queryKey: ['workspaceInvitations'] });\n },\n });\n};\n"],"mappings":";;;;;;;;AA+BA,IAAa,UAA8B;CACzC,IAAM,EAAE,cAAW,mBAAgB,GAAsB,EACnD,IAAc,GAAgB,EAC9B,EAAE,YAAS,GAA2B;AAE5C,QAAO,EAAY;EACjB,YAAY,OAAO,MAA6D;GAC9E,IAAM,IAAS,MAAM,EAAsD;IACzE,SAAS;IACT,WAAW,KAAa,KAAA;IACxB,OAAO,EAAM,EAA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G/D,UAAO,EAAO,KAAM;;EAEtB,YAAY,GAAG,MAAO;AAEpB,GADA,EAAY,kBAAkB,EAAE,UAAU,CAAC,uBAAuB,EAAE,CAAC,EACrE,EAAK,gCAAgC;IAAE,cAAc;IAAI,QAAQ;IAAsB,CAAC;;EAE1F,UAAU,GAAK,MAAO;AACpB,KAAK,sCAAsC;IACzC,cAAc;IACd,aAAa,KAAe,KAAA;IAC5B,QAAQ;IACR,cAAc,EAAmB,EAAI;IACtC,CAAC;;EAEL,CAAC;GAOS,UAAiC;CAC5C,IAAM,EAAE,cAAW,mBAAgB,GAAsB,EACnD,IAAc,GAAgB;AAEpC,QAAO,EAAY;EACjB,YAAY,OAAO,MAAoE;GACrF,IAAM,IAAS,MAAM,EAA+D;IAClF,SAAS;IACT,WAAW,KAAa,KAAA;IACxB,OAAO,EAAM,EAA8B;IAC3C,WAAW,EAAE,WAAQ;IACrB,aAAa,EAAO,IAAI,eAAe,KAAe,KAAA;IACtD,gBAAgB;IACjB,CAAC;AAEF,OAAI,EAAO,QAAQ,OACjB,OAAU,MAAM,EAAO,OAAO,IAAI,WAAW,gBAAgB;AAG/D,UAAO,EAAO,KAAM;;EAEtB,iBAAiB;AACf,KAAY,kBAAkB,EAAE,UAAU,CAAC,uBAAuB,EAAE,CAAC;;EAExE,CAAC"}
@@ -0,0 +1,29 @@
1
+ import { useWorkspacesContext as e } from "../providers/WorkspacesProvider.js";
2
+ import { GetMyPendingInvitationsDocument as t } from "../generated/wspace-operations.js";
3
+ import { useQuery as n } from "@tanstack/react-query";
4
+ import { print as r } from "graphql";
5
+ import { graphqlFetch as i } from "@burdenoff/fe-libs/shared/graphql";
6
+ //#region src/hooks/usePendingInvitations.ts
7
+ var a = (a) => {
8
+ let { authToken: o } = e();
9
+ return n({
10
+ queryKey: ["myPendingInvitations", a],
11
+ queryFn: async () => {
12
+ if (!a) return [];
13
+ let e = await i({
14
+ gateway: "workspace",
15
+ authToken: o || void 0,
16
+ query: r(t),
17
+ variables: { email: a }
18
+ });
19
+ if (e.errors?.length) throw Error(e.errors[0]?.message || "Failed to fetch pending invitations");
20
+ return e.data?.myPendingInvitations ?? [];
21
+ },
22
+ enabled: !!a,
23
+ staleTime: 60 * 1e3
24
+ });
25
+ };
26
+ //#endregion
27
+ export { a as useMyPendingInvitations };
28
+
29
+ //# sourceMappingURL=usePendingInvitations.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"usePendingInvitations.js","names":[],"sources":["../../src/hooks/usePendingInvitations.ts"],"sourcesContent":["import { useQuery } from '@tanstack/react-query';\nimport { print } from 'graphql';\nimport { graphqlFetch } from '@burdenoff/fe-libs/shared/graphql';\nimport { useWorkspacesContext } from '../providers/WorkspacesProvider';\nimport { GetMyPendingInvitationsDocument } from '../generated/wspace-operations';\nimport type { WorkspaceInvitation } from '../types';\n\n/**\n * Hook to fetch all pending invitations for the authenticated user's email.\n * Kept in its own module so route-level consumers do not depend on the larger\n * workspace-members hook module just to render the invites surfaces.\n */\nexport const useMyPendingInvitations = (email?: string) => {\n const { authToken } = useWorkspacesContext();\n\n return useQuery({\n queryKey: ['myPendingInvitations', email],\n queryFn: async (): Promise<WorkspaceInvitation[]> => {\n if (!email) {\n return [];\n }\n\n const result = await graphqlFetch<{ myPendingInvitations: WorkspaceInvitation[] }>({\n gateway: 'workspace',\n authToken: authToken || undefined,\n query: print(GetMyPendingInvitationsDocument),\n variables: { email },\n });\n\n if (result.errors?.length) {\n throw new Error(result.errors[0]?.message || 'Failed to fetch pending invitations');\n }\n\n return result.data?.myPendingInvitations ?? [];\n },\n enabled: Boolean(email),\n staleTime: 60 * 1000,\n });\n};\n"],"mappings":";;;;;;AAYA,IAAa,KAA2B,MAAmB;CACzD,IAAM,EAAE,iBAAc,GAAsB;AAE5C,QAAO,EAAS;EACd,UAAU,CAAC,wBAAwB,EAAM;EACzC,SAAS,YAA4C;AACnD,OAAI,CAAC,EACH,QAAO,EAAE;GAGX,IAAM,IAAS,MAAM,EAA8D;IACjF,SAAS;IACT,WAAW,KAAa,KAAA;IACxB,OAAO,EAAM,EAAgC;IAC7C,WAAW,EAAE,UAAO;IACrB,CAAC;AAEF,OAAI,EAAO,QAAQ,OACjB,OAAU,MAAM,EAAO,OAAO,IAAI,WAAW,sCAAsC;AAGrF,UAAO,EAAO,MAAM,wBAAwB,EAAE;;EAEhD,SAAS,EAAQ;EACjB,WAAW,KAAK;EACjB,CAAC"}
@@ -4,7 +4,7 @@ import { safeTelemetryError as n } from "../utils/telemetryError.js";
4
4
  import { useMutation as r, useQueryClient as i } from "@tanstack/react-query";
5
5
  import { graphqlFetch as a } from "@burdenoff/fe-libs/shared/graphql";
6
6
  //#region src/hooks/useProjectMutations.ts
7
- var o = "\n mutation CreateProject($input: CreateProjectInput!) {\n createProject(input: $input) {\n id\n name\n key\n workspaceId\n creatorId\n status\n tags\n createdAt\n }\n }\n", s = "\n mutation UpdateProject($id: ID!, $input: UpdateProjectInput!) {\n updateProject(id: $id, input: $input) {\n id\n name\n key\n status\n config\n tags\n archived\n updatedAt\n }\n }\n", c = "\n mutation DeleteProject($id: ID!) {\n deleteProject(id: $id)\n }\n", l = "\n mutation ArchiveProject($id: ID!) {\n archiveProject(id: $id) {\n id\n archived\n updatedAt\n }\n }\n", u = "\n mutation UnarchiveProject($id: ID!) {\n unarchiveProject(id: $id) {\n id\n archived\n updatedAt\n }\n }\n", d = (s) => {
7
+ var o = "\n mutation CreateProject($input: CreateProjectInput!) {\n createProject(input: $input) {\n id\n name\n key\n workspaceId\n creatorId\n status\n tags\n createdAt\n }\n }\n", s = "\n mutation UpdateProject($id: ID!, $input: UpdateProjectInput!) {\n updateProject(id: $id, input: $input) {\n id\n name\n key\n status\n config\n tags\n archived\n updatedAt\n }\n }\n", c = "\n mutation DeleteProject($id: ID!) {\n deleteProject(id: $id)\n }\n", l = "\n mutation ArchiveProject($id: ID!) {\n archiveProject(id: $id) {\n id\n archived\n updatedAt\n }\n }\n", u = "\n mutation UnarchiveProject($id: ID!) {\n unarchiveProject(id: $id) {\n id\n archived\n updatedAt\n }\n }\n", d = "\n mutation AssignProjectTag($input: AssignTagInput!) {\n assignTag(input: $input) {\n id\n tagId\n entityType\n entityId\n source\n assignedById\n createdAt\n validFrom\n validTo\n metadata\n }\n }\n", f = "\n query GetProjectTagAssignments($entityType: String!, $entityId: ID!) {\n getEntityTags(entityType: $entityType, entityId: $entityId) {\n id\n tagId\n }\n }\n", p = "\n mutation RemoveTagAssignment($id: ID!) {\n removeTagAssignment(id: $id)\n }\n", m = (s) => {
8
8
  let { authToken: c, onProjectCreate: l, workspaceId: u } = e(), d = i(), { emit: f } = t(), p = s || u;
9
9
  return r({
10
10
  mutationFn: async (e) => {
@@ -34,7 +34,7 @@ var o = "\n mutation CreateProject($input: CreateProjectInput!) {\n createPr
34
34
  });
35
35
  }
36
36
  });
37
- }, f = (o) => {
37
+ }, h = (o) => {
38
38
  let { authToken: c, workspaceId: l } = e(), u = i(), { emit: d } = t(), f = o || l;
39
39
  return r({
40
40
  mutationFn: async ({ id: e, input: t }) => {
@@ -68,7 +68,108 @@ var o = "\n mutation CreateProject($input: CreateProjectInput!) {\n createPr
68
68
  });
69
69
  }
70
70
  });
71
- }, p = (o) => {
71
+ }, g = (o) => {
72
+ let { authToken: s, workspaceId: c } = e(), l = i(), { emit: u } = t(), f = o || c;
73
+ return r({
74
+ mutationFn: async (e) => {
75
+ let t = await a({
76
+ gateway: "workspace",
77
+ authToken: s || void 0,
78
+ query: d,
79
+ variables: { input: {
80
+ tagId: e.tagId,
81
+ entityType: "WORKSPACE_PROJECT",
82
+ entityId: e.entityId,
83
+ source: "MANUAL",
84
+ context: {
85
+ workspaceId: f,
86
+ projectId: e.entityId
87
+ }
88
+ } },
89
+ workspaceId: f || void 0,
90
+ workspaceToken: !0
91
+ });
92
+ if (t.errors?.length) throw Error(t.errors[0]?.message || "GraphQL error");
93
+ if (!t.data?.assignTag) throw Error("GraphQL error");
94
+ return {
95
+ id: t.data.assignTag.id,
96
+ tagId: t.data.assignTag.tagId,
97
+ entityType: t.data.assignTag.entityType,
98
+ entityId: t.data.assignTag.entityId,
99
+ source: t.data.assignTag.source,
100
+ assignedBy: t.data.assignTag.assignedById ?? null,
101
+ assignedAt: t.data.assignTag.createdAt ?? null,
102
+ validFrom: t.data.assignTag.validFrom ?? null,
103
+ validTo: t.data.assignTag.validTo ?? null,
104
+ metadata: t.data.assignTag.metadata ?? null,
105
+ tag: null
106
+ };
107
+ },
108
+ onSuccess: (e, t) => {
109
+ l.invalidateQueries({ queryKey: ["projects"] }), l.invalidateQueries({ queryKey: ["project"] }), l.invalidateQueries({ queryKey: ["myProjects"] }), u("project.updated", {
110
+ projectId: t.entityId,
111
+ workspaceId: f || void 0,
112
+ source: "microfe-workspaces"
113
+ });
114
+ },
115
+ onError: (e, t) => {
116
+ u("project.update_failed", {
117
+ projectId: t.entityId,
118
+ workspaceId: f || void 0,
119
+ source: "microfe-workspaces",
120
+ errorMessage: n(e)
121
+ });
122
+ }
123
+ });
124
+ }, _ = (o) => {
125
+ let { authToken: s, workspaceId: c } = e(), l = i(), { emit: u } = t(), d = o || c;
126
+ return r({
127
+ mutationFn: async (e) => {
128
+ let t = e.assignmentId;
129
+ if (!t) {
130
+ let n = await a({
131
+ gateway: "workspace",
132
+ authToken: s || void 0,
133
+ query: f,
134
+ variables: {
135
+ entityType: "WORKSPACE_PROJECT",
136
+ entityId: e.entityId
137
+ },
138
+ workspaceId: d || void 0,
139
+ workspaceToken: !0
140
+ });
141
+ if (n.errors?.length) throw Error(n.errors[0]?.message || "GraphQL error");
142
+ t = n.data?.getEntityTags.find((t) => t.tagId === e.tagId)?.id;
143
+ }
144
+ if (!t) return !1;
145
+ let n = await a({
146
+ gateway: "workspace",
147
+ authToken: s || void 0,
148
+ query: p,
149
+ variables: { id: t },
150
+ workspaceId: d || void 0,
151
+ workspaceToken: !0
152
+ });
153
+ if (n.errors?.length) throw Error(n.errors[0]?.message || "GraphQL error");
154
+ return n.data?.removeTagAssignment ?? !1;
155
+ },
156
+ onSuccess: (e, t) => {
157
+ l.invalidateQueries({ queryKey: ["projects"] }), l.invalidateQueries({ queryKey: ["project"] }), l.invalidateQueries({ queryKey: ["myProjects"] }), u("project.updated", {
158
+ projectId: t.entityId,
159
+ workspaceId: d || void 0,
160
+ source: "microfe-workspaces"
161
+ });
162
+ },
163
+ onError: (e, t) => {
164
+ u("project.update_failed", {
165
+ projectId: t.entityId,
166
+ workspaceId: d || void 0,
167
+ source: "microfe-workspaces",
168
+ errorMessage: n(e)
169
+ });
170
+ }
171
+ });
172
+ }, v = (o) => {
72
173
  let { authToken: s, workspaceId: l } = e(), u = i(), { emit: d } = t(), f = o || l;
73
174
  return r({
74
175
  mutationFn: async (e) => {
@@ -98,7 +199,7 @@ var o = "\n mutation CreateProject($input: CreateProjectInput!) {\n createPr
98
199
  });
99
200
  }
100
201
  });
101
- }, m = (o) => {
202
+ }, y = (o) => {
102
203
  let { authToken: s, workspaceId: c } = e(), u = i(), { emit: d } = t(), f = o || c;
103
204
  return r({
104
205
  mutationFn: async (e) => {
@@ -129,7 +230,7 @@ var o = "\n mutation CreateProject($input: CreateProjectInput!) {\n createPr
129
230
  });
130
231
  }
131
232
  });
132
- }, h = (o) => {
233
+ }, b = (o) => {
133
234
  let { authToken: s, workspaceId: c } = e(), l = i(), { emit: d } = t(), f = o || c;
134
235
  return r({
135
236
  mutationFn: async (e) => {
@@ -162,6 +263,6 @@ var o = "\n mutation CreateProject($input: CreateProjectInput!) {\n createPr
162
263
  });
163
264
  };
164
265
  //#endregion
165
- export { m as useArchiveProject, d as useCreateProject, p as useDeleteProject, h as useUnarchiveProject, f as useUpdateProject };
266
+ export { y as useArchiveProject, m as useCreateProject, v as useDeleteProject, g as useTagProject, b as useUnarchiveProject, _ as useUntagProject, h as useUpdateProject };
166
267
 
167
268
  //# sourceMappingURL=useProjectMutations.js.map
@@ -1 +1 @@
1
- {"version":3,"file":"useProjectMutations.js","names":[],"sources":["../../src/hooks/useProjectMutations.ts"],"sourcesContent":["import { useMutation, useQueryClient } from '@tanstack/react-query';\nimport { graphqlFetch } from '@burdenoff/fe-libs/shared/graphql';\nimport { useWorkspacesContext } from '../providers/WorkspacesProvider';\nimport type { CreateProjectInput, UpdateProjectInput, Project } from '../types';\nimport { useWorkspacesEventEmitter } from './useWorkspacesEventEmitter';\nimport { safeTelemetryError } from '../utils/telemetryError';\n\nconst CREATE_PROJECT_MUTATION = `\n mutation CreateProject($input: CreateProjectInput!) {\n createProject(input: $input) {\n id\n name\n key\n workspaceId\n creatorId\n status\n tags\n createdAt\n }\n }\n`;\n\nconst UPDATE_PROJECT_MUTATION = `\n mutation UpdateProject($id: ID!, $input: UpdateProjectInput!) {\n updateProject(id: $id, input: $input) {\n id\n name\n key\n status\n config\n tags\n archived\n updatedAt\n }\n }\n`;\n\nconst DELETE_PROJECT_MUTATION = `\n mutation DeleteProject($id: ID!) {\n deleteProject(id: $id)\n }\n`;\n\nconst ARCHIVE_PROJECT_MUTATION = `\n mutation ArchiveProject($id: ID!) {\n archiveProject(id: $id) {\n id\n archived\n updatedAt\n }\n }\n`;\n\nconst UNARCHIVE_PROJECT_MUTATION = `\n mutation UnarchiveProject($id: ID!) {\n unarchiveProject(id: $id) {\n id\n archived\n updatedAt\n }\n }\n`;\n\n/**\n * Hook to create a new project\n */\nexport const useCreateProject = (workspaceIdOverride?: string) => {\n const { authToken, onProjectCreate, workspaceId } = useWorkspacesContext();\n const queryClient = useQueryClient();\n const { emit } = useWorkspacesEventEmitter();\n const effectiveWorkspaceId = workspaceIdOverride || workspaceId;\n\n return useMutation({\n mutationFn: async (input: CreateProjectInput): Promise<Project> => {\n const result = await graphqlFetch<{ createProject: Project }>({\n gateway: 'workspace',\n authToken: authToken || undefined,\n query: CREATE_PROJECT_MUTATION,\n variables: { input },\n workspaceId: effectiveWorkspaceId || undefined,\n workspaceToken: true, // Auto-read from profile context for x-workspace-id header (required by gateway RBAC)\n });\n\n if (result.errors?.length) {\n throw new Error(result.errors[0]?.message || 'GraphQL error');\n }\n\n return result.data!.createProject;\n },\n onSuccess: (project) => {\n queryClient.invalidateQueries({ queryKey: ['projects'] });\n queryClient.invalidateQueries({ queryKey: ['myProjects'] });\n emit('project.created', {\n projectId: project.id,\n workspaceId: project.workspaceId,\n source: 'microfe-workspaces',\n });\n if (onProjectCreate) {\n onProjectCreate(project);\n }\n },\n onError: (err) => {\n emit('project.create_failed', {\n workspaceId: effectiveWorkspaceId || undefined,\n source: 'microfe-workspaces',\n errorMessage: safeTelemetryError(err),\n });\n },\n });\n};\n\n/**\n * Hook to update an existing project\n */\nexport const useUpdateProject = (workspaceIdOverride?: string) => {\n const { authToken, workspaceId } = useWorkspacesContext();\n const queryClient = useQueryClient();\n const { emit } = useWorkspacesEventEmitter();\n const effectiveWorkspaceId = workspaceIdOverride || workspaceId;\n\n return useMutation({\n mutationFn: async ({\n id,\n input,\n }: {\n id: string;\n input: UpdateProjectInput;\n }): Promise<Project> => {\n const result = await graphqlFetch<{ updateProject: Project }>({\n gateway: 'workspace',\n authToken: authToken || undefined,\n query: UPDATE_PROJECT_MUTATION,\n variables: { id, input },\n workspaceId: effectiveWorkspaceId || undefined,\n workspaceToken: true, // Auto-read from profile context for x-workspace-id header (required by gateway RBAC)\n });\n\n if (result.errors?.length) {\n throw new Error(result.errors[0]?.message || 'GraphQL error');\n }\n\n return result.data!.updateProject;\n },\n onSuccess: (project) => {\n queryClient.invalidateQueries({ queryKey: ['projects'] });\n queryClient.invalidateQueries({ queryKey: ['project', project.id] });\n queryClient.invalidateQueries({ queryKey: ['myProjects'] });\n emit('project.updated', {\n projectId: project.id,\n workspaceId: project.workspaceId,\n source: 'microfe-workspaces',\n });\n },\n onError: (err, variables) => {\n emit('project.update_failed', {\n projectId: variables?.id,\n workspaceId: effectiveWorkspaceId || undefined,\n source: 'microfe-workspaces',\n errorMessage: safeTelemetryError(err),\n });\n },\n });\n};\n\n/**\n * Hook to delete a project\n */\nexport const useDeleteProject = (workspaceIdOverride?: string) => {\n const { authToken, workspaceId } = useWorkspacesContext();\n const queryClient = useQueryClient();\n const { emit } = useWorkspacesEventEmitter();\n const effectiveWorkspaceId = workspaceIdOverride || workspaceId;\n\n return useMutation({\n mutationFn: async (id: string): Promise<boolean> => {\n const result = await graphqlFetch<{ deleteProject: boolean }>({\n gateway: 'workspace',\n authToken: authToken || undefined,\n query: DELETE_PROJECT_MUTATION,\n variables: { id },\n workspaceId: effectiveWorkspaceId || undefined,\n workspaceToken: true, // Auto-read from profile context for x-workspace-id header (required by gateway RBAC)\n });\n\n if (result.errors?.length) {\n throw new Error(result.errors[0]?.message || 'GraphQL error');\n }\n\n return result.data!.deleteProject;\n },\n onSuccess: (_, id) => {\n queryClient.invalidateQueries({ queryKey: ['projects'] });\n queryClient.invalidateQueries({ queryKey: ['project', id] });\n queryClient.invalidateQueries({ queryKey: ['myProjects'] });\n emit('project.deleted', { projectId: id, source: 'microfe-workspaces' });\n },\n onError: (err, id) => {\n emit('project.delete_failed', {\n projectId: id,\n workspaceId: effectiveWorkspaceId || undefined,\n source: 'microfe-workspaces',\n errorMessage: safeTelemetryError(err),\n });\n },\n });\n};\n\n/**\n * Hook to archive a project\n */\nexport const useArchiveProject = (workspaceIdOverride?: string) => {\n const { authToken, workspaceId } = useWorkspacesContext();\n const queryClient = useQueryClient();\n const { emit } = useWorkspacesEventEmitter();\n const effectiveWorkspaceId = workspaceIdOverride || workspaceId;\n\n return useMutation({\n mutationFn: async (id: string): Promise<Project> => {\n const result = await graphqlFetch<{ archiveProject: Project }>({\n gateway: 'workspace',\n authToken: authToken || undefined,\n query: ARCHIVE_PROJECT_MUTATION,\n variables: { id },\n workspaceId: effectiveWorkspaceId || undefined,\n workspaceToken: true, // Auto-read from profile context for x-workspace-id header (required by gateway RBAC)\n });\n\n if (result.errors?.length) {\n throw new Error(result.errors[0]?.message || 'GraphQL error');\n }\n\n return result.data!.archiveProject;\n },\n onSuccess: (project) => {\n queryClient.invalidateQueries({ queryKey: ['projects'] });\n queryClient.invalidateQueries({ queryKey: ['project', project.id] });\n queryClient.invalidateQueries({ queryKey: ['myProjects'] });\n emit('project.archived', {\n projectId: project.id,\n workspaceId: project.workspaceId,\n source: 'microfe-workspaces',\n });\n },\n onError: (err, id) => {\n emit('project.archive_failed', {\n projectId: id,\n workspaceId: effectiveWorkspaceId || undefined,\n source: 'microfe-workspaces',\n errorMessage: safeTelemetryError(err),\n });\n },\n });\n};\n\n/**\n * Hook to unarchive a project\n */\nexport const useUnarchiveProject = (workspaceIdOverride?: string) => {\n const { authToken, workspaceId } = useWorkspacesContext();\n const queryClient = useQueryClient();\n const { emit } = useWorkspacesEventEmitter();\n const effectiveWorkspaceId = workspaceIdOverride || workspaceId;\n\n return useMutation({\n mutationFn: async (id: string): Promise<Project> => {\n const result = await graphqlFetch<{ unarchiveProject: Project }>({\n gateway: 'workspace',\n authToken: authToken || undefined,\n query: UNARCHIVE_PROJECT_MUTATION,\n variables: { id },\n workspaceId: effectiveWorkspaceId || undefined,\n workspaceToken: true, // Auto-read from profile context for x-workspace-id header (required by gateway RBAC)\n });\n\n if (result.errors?.length) {\n throw new Error(result.errors[0]?.message || 'GraphQL error');\n }\n\n return result.data!.unarchiveProject;\n },\n onSuccess: (project) => {\n queryClient.invalidateQueries({ queryKey: ['projects'] });\n queryClient.invalidateQueries({ queryKey: ['project', project.id] });\n queryClient.invalidateQueries({ queryKey: ['myProjects'] });\n emit('project.unarchived', {\n projectId: project.id,\n workspaceId: project.workspaceId,\n source: 'microfe-workspaces',\n });\n },\n onError: (err, id) => {\n emit('project.unarchive_failed', {\n projectId: id,\n workspaceId: effectiveWorkspaceId || undefined,\n source: 'microfe-workspaces',\n errorMessage: safeTelemetryError(err),\n });\n },\n });\n};\n"],"mappings":";;;;;;AAOA,IAAM,IAA0B,+NAe1B,IAA0B,4OAe1B,IAA0B,6EAM1B,IAA2B,mIAU3B,IAA6B,uIAatB,KAAoB,MAAiC;CAChE,IAAM,EAAE,cAAW,oBAAiB,mBAAgB,GAAsB,EACpE,IAAc,GAA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AM,EAAO,OAAO,IAAI,WAAW,gBAAgB;AAG/D,UAAO,EAAO,KAAM;;EAEtB,YAAY,MAAY;AAItB,GAHA,EAAY,kBAAkB,EAAE,UAAU,CAAC,WAAW,EAAE,CAAC,EACzD,EAAY,kBAAkB,EAAE,UAAU,CAAC,WAAW,EAAQ,GAAG,EAAE,CAAC,EACpE,EAAY,kBAAkB,EAAE,UAAU,CAAC,aAAa,EAAE,CAAC,EAC3D,EAAK,sBAAsB;IACzB,WAAW,EAAQ;IACnB,aAAa,EAAQ;IACrB,QAAQ;IACT,CAAC;;EAEJ,UAAU,GAAK,MAAO;AACpB,KAAK,4BAA4B;IAC/B,WAAW;IACX,aAAa,KAAwB,KAAA;IACrC,QAAQ;IACR,cAAc,EAAmB,EAAI;IACtC,CAAC;;EAEL,CAAC"}
1
+ {"version":3,"file":"useProjectMutations.js","names":[],"sources":["../../src/hooks/useProjectMutations.ts"],"sourcesContent":["import { useMutation, useQueryClient } from '@tanstack/react-query';\nimport { graphqlFetch } from '@burdenoff/fe-libs/shared/graphql';\nimport { useWorkspacesContext } from '../providers/WorkspacesProvider';\nimport type {\n CreateProjectInput,\n UpdateProjectInput,\n Project,\n ProjectTagAssignment,\n} from '../types';\nimport { useWorkspacesEventEmitter } from './useWorkspacesEventEmitter';\nimport { safeTelemetryError } from '../utils/telemetryError';\n\nconst CREATE_PROJECT_MUTATION = `\n mutation CreateProject($input: CreateProjectInput!) {\n createProject(input: $input) {\n id\n name\n key\n workspaceId\n creatorId\n status\n tags\n createdAt\n }\n }\n`;\n\nconst UPDATE_PROJECT_MUTATION = `\n mutation UpdateProject($id: ID!, $input: UpdateProjectInput!) {\n updateProject(id: $id, input: $input) {\n id\n name\n key\n status\n config\n tags\n archived\n updatedAt\n }\n }\n`;\n\nconst DELETE_PROJECT_MUTATION = `\n mutation DeleteProject($id: ID!) {\n deleteProject(id: $id)\n }\n`;\n\nconst ARCHIVE_PROJECT_MUTATION = `\n mutation ArchiveProject($id: ID!) {\n archiveProject(id: $id) {\n id\n archived\n updatedAt\n }\n }\n`;\n\nconst UNARCHIVE_PROJECT_MUTATION = `\n mutation UnarchiveProject($id: ID!) {\n unarchiveProject(id: $id) {\n id\n archived\n updatedAt\n }\n }\n`;\n\nconst TAG_PROJECT_MUTATION = `\n mutation AssignProjectTag($input: AssignTagInput!) {\n assignTag(input: $input) {\n id\n tagId\n entityType\n entityId\n source\n assignedById\n createdAt\n validFrom\n validTo\n metadata\n }\n }\n`;\n\nconst GET_PROJECT_TAG_ASSIGNMENTS_QUERY = `\n query GetProjectTagAssignments($entityType: String!, $entityId: ID!) {\n getEntityTags(entityType: $entityType, entityId: $entityId) {\n id\n tagId\n }\n }\n`;\n\nconst REMOVE_TAG_ASSIGNMENT_MUTATION = `\n mutation RemoveTagAssignment($id: ID!) {\n removeTagAssignment(id: $id)\n }\n`;\n\n/**\n * Hook to create a new project\n */\nexport const useCreateProject = (workspaceIdOverride?: string) => {\n const { authToken, onProjectCreate, workspaceId } = useWorkspacesContext();\n const queryClient = useQueryClient();\n const { emit } = useWorkspacesEventEmitter();\n const effectiveWorkspaceId = workspaceIdOverride || workspaceId;\n\n return useMutation({\n mutationFn: async (input: CreateProjectInput): Promise<Project> => {\n const result = await graphqlFetch<{ createProject: Project }>({\n gateway: 'workspace',\n authToken: authToken || undefined,\n query: CREATE_PROJECT_MUTATION,\n variables: { input },\n workspaceId: effectiveWorkspaceId || undefined,\n workspaceToken: true, // Auto-read from profile context for x-workspace-id header (required by gateway RBAC)\n });\n\n if (result.errors?.length) {\n throw new Error(result.errors[0]?.message || 'GraphQL error');\n }\n\n return result.data!.createProject;\n },\n onSuccess: (project) => {\n queryClient.invalidateQueries({ queryKey: ['projects'] });\n queryClient.invalidateQueries({ queryKey: ['myProjects'] });\n emit('project.created', {\n projectId: project.id,\n workspaceId: project.workspaceId,\n source: 'microfe-workspaces',\n });\n if (onProjectCreate) {\n onProjectCreate(project);\n }\n },\n onError: (err) => {\n emit('project.create_failed', {\n workspaceId: effectiveWorkspaceId || undefined,\n source: 'microfe-workspaces',\n errorMessage: safeTelemetryError(err),\n });\n },\n });\n};\n\n/**\n * Hook to update an existing project\n */\nexport const useUpdateProject = (workspaceIdOverride?: string) => {\n const { authToken, workspaceId } = useWorkspacesContext();\n const queryClient = useQueryClient();\n const { emit } = useWorkspacesEventEmitter();\n const effectiveWorkspaceId = workspaceIdOverride || workspaceId;\n\n return useMutation({\n mutationFn: async ({\n id,\n input,\n }: {\n id: string;\n input: UpdateProjectInput;\n }): Promise<Project> => {\n const result = await graphqlFetch<{ updateProject: Project }>({\n gateway: 'workspace',\n authToken: authToken || undefined,\n query: UPDATE_PROJECT_MUTATION,\n variables: { id, input },\n workspaceId: effectiveWorkspaceId || undefined,\n workspaceToken: true, // Auto-read from profile context for x-workspace-id header (required by gateway RBAC)\n });\n\n if (result.errors?.length) {\n throw new Error(result.errors[0]?.message || 'GraphQL error');\n }\n\n return result.data!.updateProject;\n },\n onSuccess: (project) => {\n queryClient.invalidateQueries({ queryKey: ['projects'] });\n queryClient.invalidateQueries({ queryKey: ['project', project.id] });\n queryClient.invalidateQueries({ queryKey: ['myProjects'] });\n emit('project.updated', {\n projectId: project.id,\n workspaceId: project.workspaceId,\n source: 'microfe-workspaces',\n });\n },\n onError: (err, variables) => {\n emit('project.update_failed', {\n projectId: variables?.id,\n workspaceId: effectiveWorkspaceId || undefined,\n source: 'microfe-workspaces',\n errorMessage: safeTelemetryError(err),\n });\n },\n });\n};\n\n/**\n * Hook to assign a structured tag to a project.\n */\nexport const useTagProject = (workspaceIdOverride?: string) => {\n const { authToken, workspaceId } = useWorkspacesContext();\n const queryClient = useQueryClient();\n const { emit } = useWorkspacesEventEmitter();\n const effectiveWorkspaceId = workspaceIdOverride || workspaceId;\n\n return useMutation({\n mutationFn: async (input: {\n entityId: string;\n tagId: string;\n }): Promise<ProjectTagAssignment> => {\n const result = await graphqlFetch<{\n assignTag: {\n id: string;\n tagId: string;\n entityType: string;\n entityId: string;\n source: string;\n assignedById?: string | null;\n createdAt?: string | null;\n validFrom?: string | null;\n validTo?: string | null;\n metadata?: Record<string, unknown> | null;\n };\n }>({\n gateway: 'workspace',\n authToken: authToken || undefined,\n query: TAG_PROJECT_MUTATION,\n variables: {\n input: {\n tagId: input.tagId,\n entityType: 'WORKSPACE_PROJECT',\n entityId: input.entityId,\n source: 'MANUAL',\n context: {\n workspaceId: effectiveWorkspaceId,\n projectId: input.entityId,\n },\n },\n },\n workspaceId: effectiveWorkspaceId || undefined,\n workspaceToken: true,\n });\n\n if (result.errors?.length) {\n throw new Error(result.errors[0]?.message || 'GraphQL error');\n }\n\n if (!result.data?.assignTag) {\n throw new Error('GraphQL error');\n }\n\n return {\n id: result.data.assignTag.id,\n tagId: result.data.assignTag.tagId,\n entityType: result.data.assignTag.entityType,\n entityId: result.data.assignTag.entityId,\n source: result.data.assignTag.source,\n assignedBy: result.data.assignTag.assignedById ?? null,\n assignedAt: result.data.assignTag.createdAt ?? null,\n validFrom: result.data.assignTag.validFrom ?? null,\n validTo: result.data.assignTag.validTo ?? null,\n metadata: result.data.assignTag.metadata ?? null,\n tag: null,\n };\n },\n onSuccess: (_assignment, input) => {\n queryClient.invalidateQueries({ queryKey: ['projects'] });\n queryClient.invalidateQueries({ queryKey: ['project'] });\n queryClient.invalidateQueries({ queryKey: ['myProjects'] });\n emit('project.updated', {\n projectId: input.entityId,\n workspaceId: effectiveWorkspaceId || undefined,\n source: 'microfe-workspaces',\n });\n },\n onError: (err, input) => {\n emit('project.update_failed', {\n projectId: input.entityId,\n workspaceId: effectiveWorkspaceId || undefined,\n source: 'microfe-workspaces',\n errorMessage: safeTelemetryError(err),\n });\n },\n });\n};\n\n/**\n * Hook to remove a structured tag from a project.\n */\nexport const useUntagProject = (workspaceIdOverride?: string) => {\n const { authToken, workspaceId } = useWorkspacesContext();\n const queryClient = useQueryClient();\n const { emit } = useWorkspacesEventEmitter();\n const effectiveWorkspaceId = workspaceIdOverride || workspaceId;\n\n return useMutation({\n mutationFn: async (input: {\n entityId: string;\n tagId: string;\n assignmentId?: string;\n }): Promise<boolean> => {\n let assignmentId = input.assignmentId;\n\n if (!assignmentId) {\n const lookup = await graphqlFetch<{\n getEntityTags: Array<{\n id: string;\n tagId: string;\n }>;\n }>({\n gateway: 'workspace',\n authToken: authToken || undefined,\n query: GET_PROJECT_TAG_ASSIGNMENTS_QUERY,\n variables: {\n entityType: 'WORKSPACE_PROJECT',\n entityId: input.entityId,\n },\n workspaceId: effectiveWorkspaceId || undefined,\n workspaceToken: true,\n });\n\n if (lookup.errors?.length) {\n throw new Error(lookup.errors[0]?.message || 'GraphQL error');\n }\n\n assignmentId = lookup.data?.getEntityTags.find((entry) => entry.tagId === input.tagId)?.id;\n }\n\n if (!assignmentId) {\n return false;\n }\n\n const result = await graphqlFetch<{ removeTagAssignment: boolean }>({\n gateway: 'workspace',\n authToken: authToken || undefined,\n query: REMOVE_TAG_ASSIGNMENT_MUTATION,\n variables: { id: assignmentId },\n workspaceId: effectiveWorkspaceId || undefined,\n workspaceToken: true,\n });\n\n if (result.errors?.length) {\n throw new Error(result.errors[0]?.message || 'GraphQL error');\n }\n\n return result.data?.removeTagAssignment ?? false;\n },\n onSuccess: (_ok, input) => {\n queryClient.invalidateQueries({ queryKey: ['projects'] });\n queryClient.invalidateQueries({ queryKey: ['project'] });\n queryClient.invalidateQueries({ queryKey: ['myProjects'] });\n emit('project.updated', {\n projectId: input.entityId,\n workspaceId: effectiveWorkspaceId || undefined,\n source: 'microfe-workspaces',\n });\n },\n onError: (err, input) => {\n emit('project.update_failed', {\n projectId: input.entityId,\n workspaceId: effectiveWorkspaceId || undefined,\n source: 'microfe-workspaces',\n errorMessage: safeTelemetryError(err),\n });\n },\n });\n};\n\n/**\n * Hook to delete a project\n */\nexport const useDeleteProject = (workspaceIdOverride?: string) => {\n const { authToken, workspaceId } = useWorkspacesContext();\n const queryClient = useQueryClient();\n const { emit } = useWorkspacesEventEmitter();\n const effectiveWorkspaceId = workspaceIdOverride || workspaceId;\n\n return useMutation({\n mutationFn: async (id: string): Promise<boolean> => {\n const result = await graphqlFetch<{ deleteProject: boolean }>({\n gateway: 'workspace',\n authToken: authToken || undefined,\n query: DELETE_PROJECT_MUTATION,\n variables: { id },\n workspaceId: effectiveWorkspaceId || undefined,\n workspaceToken: true, // Auto-read from profile context for x-workspace-id header (required by gateway RBAC)\n });\n\n if (result.errors?.length) {\n throw new Error(result.errors[0]?.message || 'GraphQL error');\n }\n\n return result.data!.deleteProject;\n },\n onSuccess: (_, id) => {\n queryClient.invalidateQueries({ queryKey: ['projects'] });\n queryClient.invalidateQueries({ queryKey: ['project', id] });\n queryClient.invalidateQueries({ queryKey: ['myProjects'] });\n emit('project.deleted', { projectId: id, source: 'microfe-workspaces' });\n },\n onError: (err, id) => {\n emit('project.delete_failed', {\n projectId: id,\n workspaceId: effectiveWorkspaceId || undefined,\n source: 'microfe-workspaces',\n errorMessage: safeTelemetryError(err),\n });\n },\n });\n};\n\n/**\n * Hook to archive a project\n */\nexport const useArchiveProject = (workspaceIdOverride?: string) => {\n const { authToken, workspaceId } = useWorkspacesContext();\n const queryClient = useQueryClient();\n const { emit } = useWorkspacesEventEmitter();\n const effectiveWorkspaceId = workspaceIdOverride || workspaceId;\n\n return useMutation({\n mutationFn: async (id: string): Promise<Project> => {\n const result = await graphqlFetch<{ archiveProject: Project }>({\n gateway: 'workspace',\n authToken: authToken || undefined,\n query: ARCHIVE_PROJECT_MUTATION,\n variables: { id },\n workspaceId: effectiveWorkspaceId || undefined,\n workspaceToken: true, // Auto-read from profile context for x-workspace-id header (required by gateway RBAC)\n });\n\n if (result.errors?.length) {\n throw new Error(result.errors[0]?.message || 'GraphQL error');\n }\n\n return result.data!.archiveProject;\n },\n onSuccess: (project) => {\n queryClient.invalidateQueries({ queryKey: ['projects'] });\n queryClient.invalidateQueries({ queryKey: ['project', project.id] });\n queryClient.invalidateQueries({ queryKey: ['myProjects'] });\n emit('project.archived', {\n projectId: project.id,\n workspaceId: project.workspaceId,\n source: 'microfe-workspaces',\n });\n },\n onError: (err, id) => {\n emit('project.archive_failed', {\n projectId: id,\n workspaceId: effectiveWorkspaceId || undefined,\n source: 'microfe-workspaces',\n errorMessage: safeTelemetryError(err),\n });\n },\n });\n};\n\n/**\n * Hook to unarchive a project\n */\nexport const useUnarchiveProject = (workspaceIdOverride?: string) => {\n const { authToken, workspaceId } = useWorkspacesContext();\n const queryClient = useQueryClient();\n const { emit } = useWorkspacesEventEmitter();\n const effectiveWorkspaceId = workspaceIdOverride || workspaceId;\n\n return useMutation({\n mutationFn: async (id: string): Promise<Project> => {\n const result = await graphqlFetch<{ unarchiveProject: Project }>({\n gateway: 'workspace',\n authToken: authToken || undefined,\n query: UNARCHIVE_PROJECT_MUTATION,\n variables: { id },\n workspaceId: effectiveWorkspaceId || undefined,\n workspaceToken: true, // Auto-read from profile context for x-workspace-id header (required by gateway RBAC)\n });\n\n if (result.errors?.length) {\n throw new Error(result.errors[0]?.message || 'GraphQL error');\n }\n\n return result.data!.unarchiveProject;\n },\n onSuccess: (project) => {\n queryClient.invalidateQueries({ queryKey: ['projects'] });\n queryClient.invalidateQueries({ queryKey: ['project', project.id] });\n queryClient.invalidateQueries({ queryKey: ['myProjects'] });\n emit('project.unarchived', {\n projectId: project.id,\n workspaceId: project.workspaceId,\n source: 'microfe-workspaces',\n });\n },\n onError: (err, id) => {\n emit('project.unarchive_failed', {\n projectId: id,\n workspaceId: effectiveWorkspaceId || undefined,\n source: 'microfe-workspaces',\n errorMessage: safeTelemetryError(err),\n });\n },\n });\n};\n"],"mappings":";;;;;;AAYA,IAAM,IAA0B,+NAe1B,IAA0B,4OAe1B,IAA0B,6EAM1B,IAA2B,mIAU3B,IAA6B,uIAU7B,IAAuB,sQAiBvB,IAAoC,sLASpC,IAAiC,yFAS1B,KAAoB,MAAiC;CAChE,IAAM,EAAE,cAAW,oBAAiB,mBAAgB,GAAsB,EACpE,IAAc,GAAgB,EAC9B,EAAE,YAAS,GAA2B,EACtC,IAAuB,K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C;IAC/D,SAAS;IACT,WAAW,KAAa,KAAA;IACxB,OAAO;IACP,WAAW,EAAE,OAAI;IACjB,aAAa,KAAwB,KAAA;IACrC,gBAAgB;IACjB,CAAC;AAEF,OAAI,EAAO,QAAQ,OACjB,OAAU,MAAM,EAAO,OAAO,IAAI,WAAW,gBAAgB;AAG/D,UAAO,EAAO,KAAM;;EAEtB,YAAY,MAAY;AAItB,GAHA,EAAY,kBAAkB,EAAE,UAAU,CAAC,WAAW,EAAE,CAAC,EACzD,EAAY,kBAAkB,EAAE,UAAU,CAAC,WAAW,EAAQ,GAAG,EAAE,CAAC,EACpE,EAAY,kBAAkB,EAAE,UAAU,CAAC,aAAa,EAAE,CAAC,EAC3D,EAAK,sBAAsB;IACzB,WAAW,EAAQ;IACnB,aAAa,EAAQ;IACrB,QAAQ;IACT,CAAC;;EAEJ,UAAU,GAAK,MAAO;AACpB,KAAK,4BAA4B;IAC/B,WAAW;IACX,aAAa,KAAwB,KAAA;IACrC,QAAQ;IACR,cAAc,EAAmB,EAAI;IACtC,CAAC;;EAEL,CAAC"}
@@ -2,7 +2,7 @@ import { useWorkspacesContext as e } from "../providers/WorkspacesProvider.js";
2
2
  import { useQuery as t } from "@tanstack/react-query";
3
3
  import { graphqlFetch as n } from "@burdenoff/fe-libs/shared/graphql";
4
4
  //#region src/hooks/useProjects.ts
5
- var r = "\n query GetProjects($filter: ProjectFilterInput, $pagination: PaginationInput) {\n projects(filter: $filter, pagination: $pagination) {\n items {\n id\n name\n key\n workspaceId\n creatorId\n status\n config\n tags\n archived\n createdAt\n updatedAt\n deletedAt\n }\n total\n hasMore\n }\n }\n", i = "\n query GetProject($id: ID!) {\n project(id: $id) {\n id\n name\n key\n workspaceId\n creatorId\n status\n config\n tags\n archived\n createdAt\n updatedAt\n deletedAt\n }\n }\n", a = "\n query GetMyProjects($pagination: PaginationInput) {\n myProjects(pagination: $pagination) {\n items {\n id\n name\n key\n workspaceId\n status\n tags\n archived\n createdAt\n updatedAt\n }\n total\n hasMore\n }\n }\n", o = "\n query GetProjectMembersCount($projectId: ID!) {\n projectMembers(filter: { projectId: $projectId }, pagination: { limit: 1 }) {\n total\n }\n }\n", s = (i, a, o) => {
5
+ var r = "\n query GetProjects($filter: ProjectFilterInput, $pagination: PaginationInput) {\n projects(filter: $filter, pagination: $pagination) {\n items {\n id\n name\n key\n workspaceId\n creatorId\n status\n config\n tags\n tagAssignments {\n id\n tagId\n entityType\n entityId\n source\n assignedBy\n assignedAt\n validFrom\n validTo\n metadata\n tag {\n id\n key\n label\n value\n vocabularyId\n parentId\n hierarchyPath\n color\n icon\n description\n vocabulary {\n key\n }\n }\n }\n archived\n createdAt\n updatedAt\n deletedAt\n }\n total\n hasMore\n }\n }\n", i = "\n query GetProject($id: ID!) {\n project(id: $id) {\n id\n name\n key\n workspaceId\n creatorId\n status\n config\n tags\n tagAssignments {\n id\n tagId\n entityType\n entityId\n source\n assignedBy\n assignedAt\n validFrom\n validTo\n metadata\n tag {\n id\n key\n label\n value\n vocabularyId\n parentId\n hierarchyPath\n color\n icon\n description\n vocabulary {\n key\n }\n }\n }\n archived\n createdAt\n updatedAt\n deletedAt\n }\n }\n", a = "\n query GetMyProjects($pagination: PaginationInput) {\n myProjects(pagination: $pagination) {\n items {\n id\n name\n key\n workspaceId\n status\n tags\n tagAssignments {\n id\n tagId\n entityType\n entityId\n source\n assignedBy\n assignedAt\n validFrom\n validTo\n metadata\n tag {\n id\n key\n label\n value\n vocabularyId\n parentId\n hierarchyPath\n color\n icon\n description\n vocabulary {\n key\n }\n }\n }\n archived\n createdAt\n updatedAt\n }\n total\n hasMore\n }\n }\n", o = "\n query GetProjectMembersCount($projectId: ID!) {\n projectMembers(filter: { projectId: $projectId }, pagination: { limit: 1 }) {\n total\n }\n }\n", s = (i, a, o) => {
6
6
  let { authToken: s, workspaceId: c } = e(), l = i?.workspaceId || o || c;
7
7
  return t({
8
8
  queryKey: [
@@ -1 +1 @@
1
- {"version":3,"file":"useProjects.js","names":[],"sources":["../../src/hooks/useProjects.ts"],"sourcesContent":["import { useQuery } from '@tanstack/react-query';\nimport { graphqlFetch } from '@burdenoff/fe-libs/shared/graphql';\nimport { useWorkspacesContext } from '../providers/WorkspacesProvider';\nimport type { ProjectFilters, ProjectList, Project, PaginationInput } from '../types';\n\nconst GET_PROJECTS_QUERY = `\n query GetProjects($filter: ProjectFilterInput, $pagination: PaginationInput) {\n projects(filter: $filter, pagination: $pagination) {\n items {\n id\n name\n key\n workspaceId\n creatorId\n status\n config\n tags\n archived\n createdAt\n updatedAt\n deletedAt\n }\n total\n hasMore\n }\n }\n`;\n\nconst GET_PROJECT_QUERY = `\n query GetProject($id: ID!) {\n project(id: $id) {\n id\n name\n key\n workspaceId\n creatorId\n status\n config\n tags\n archived\n createdAt\n updatedAt\n deletedAt\n }\n }\n`;\n\nconst GET_MY_PROJECTS_QUERY = `\n query GetMyProjects($pagination: PaginationInput) {\n myProjects(pagination: $pagination) {\n items {\n id\n name\n key\n workspaceId\n status\n tags\n archived\n createdAt\n updatedAt\n }\n total\n hasMore\n }\n }\n`;\n\nconst GET_PROJECT_MEMBERS_COUNT = `\n query GetProjectMembersCount($projectId: ID!) {\n projectMembers(filter: { projectId: $projectId }, pagination: { limit: 1 }) {\n total\n }\n }\n`;\n\n/**\n * Hook to fetch all projects with filtering and pagination\n */\nexport const useProjects = (\n filters?: ProjectFilters,\n pagination?: PaginationInput,\n workspaceIdOverride?: string\n) => {\n const { authToken, workspaceId } = useWorkspacesContext();\n const effectiveWorkspaceId = filters?.workspaceId || workspaceIdOverride || workspaceId;\n\n return useQuery({\n queryKey: ['projects', effectiveWorkspaceId, filters, pagination],\n queryFn: async (): Promise<ProjectList> => {\n const result = await graphqlFetch<{ projects: ProjectList }>({\n gateway: 'workspace',\n authToken: authToken || undefined,\n query: GET_PROJECTS_QUERY,\n variables: {\n filter: {\n ...filters,\n workspaceId: effectiveWorkspaceId,\n },\n pagination,\n },\n workspaceId: effectiveWorkspaceId || undefined,\n workspaceToken: true, // Auto-read from profile context for x-workspace-id header (required by gateway RBAC)\n });\n\n if (result.errors?.length) {\n throw new Error(result.errors[0]?.message || 'GraphQL error');\n }\n\n return result.data!.projects;\n },\n enabled: !!effectiveWorkspaceId,\n staleTime: 5 * 60 * 1000,\n });\n};\n\n/**\n * Hook to fetch a single project by ID\n */\nexport const useProject = (id: string, workspaceIdOverride?: string) => {\n const { authToken, workspaceId } = useWorkspacesContext();\n const effectiveWorkspaceId = workspaceIdOverride || workspaceId;\n\n return useQuery({\n queryKey: ['project', effectiveWorkspaceId, id],\n queryFn: async (): Promise<Project> => {\n const result = await graphqlFetch<{ project: Project }>({\n gateway: 'workspace',\n authToken: authToken || undefined,\n query: GET_PROJECT_QUERY,\n variables: { id },\n workspaceId: effectiveWorkspaceId || undefined,\n workspaceToken: true, // Auto-read from profile context for x-workspace-id header (required by gateway RBAC)\n });\n\n if (result.errors?.length) {\n throw new Error(result.errors[0]?.message || 'GraphQL error');\n }\n\n return result.data!.project;\n },\n enabled: !!id,\n staleTime: 5 * 60 * 1000,\n });\n};\n\n/**\n * Hook to fetch current user's projects\n */\nexport const useMyProjects = (pagination?: PaginationInput) => {\n const { authToken, workspaceId } = useWorkspacesContext();\n\n return useQuery({\n queryKey: ['myProjects', workspaceId, pagination],\n queryFn: async (): Promise<ProjectList> => {\n const result = await graphqlFetch<{ myProjects: ProjectList }>({\n gateway: 'workspace',\n authToken: authToken || undefined,\n query: GET_MY_PROJECTS_QUERY,\n variables: { pagination },\n workspaceId: workspaceId || undefined,\n workspaceToken: true, // Auto-read from profile context for x-workspace-id header (required by gateway RBAC)\n });\n\n if (result.errors?.length) {\n throw new Error(result.errors[0]?.message || 'GraphQL error');\n }\n\n return result.data!.myProjects;\n },\n staleTime: 5 * 60 * 1000,\n });\n};\n\nexport const useProjectMembersCount = (projectId: string, workspaceIdOverride?: string) => {\n const { authToken, workspaceId } = useWorkspacesContext();\n const effectiveWorkspaceId = workspaceIdOverride || workspaceId;\n\n return useQuery({\n queryKey: ['projectMembersCount', effectiveWorkspaceId, projectId],\n queryFn: async (): Promise<number> => {\n const result = await graphqlFetch<{\n projectMembers: { total: number };\n }>({\n gateway: 'workspace',\n authToken: authToken || undefined,\n query: GET_PROJECT_MEMBERS_COUNT,\n variables: { projectId },\n workspaceId: effectiveWorkspaceId || undefined,\n workspaceToken: true,\n });\n\n if (result.errors?.length) {\n throw new Error(result.errors[0]?.message || 'GraphQL error');\n }\n\n return result.data?.projectMembers.total ?? 0;\n },\n enabled: !!projectId && !!effectiveWorkspaceId,\n staleTime: 60 * 1000,\n });\n};\n"],"mappings":";;;;AAKA,IAAM,IAAqB,0ZAuBrB,IAAoB,0PAmBpB,IAAwB,0TAoBxB,IAA4B,qKAWrB,KACX,GACA,GACA,MACG;CACH,IAAM,EAAE,cAAW,mBAAgB,GAAsB,EACnD,IAAuB,GAAS,eAAe,KAAuB;AAE5E,QAAO,EAAS;EACd,UAAU;GAAC;GAAY;GAAsB;GAAS;GAAW;EACjE,SAAS,YAAkC;GACzC,IAAM,IAAS,MAAM,EAAwC;IAC3D,SAAS;IACT,WAAW,KAAa,KAAA;IACxB,OAAO;IACP,WAAW;KACT,QAAQ;MACN,GAAG;MACH,aAAa;MACd;KACD;KACD;IACD,aAAa,KAAwB,KAAA;IACrC,gBAAgB;IACjB,CAAC;AAEF,OAAI,EAAO,QAAQ,OACjB,OAAU,MAAM,EAAO,OAAO,IAAI,WAAW,gBAAgB;AAG/D,UAAO,EAAO,KAAM;;EAEtB,SAAS,CAAC,CAAC;EACX,WAAW,MAAS;EACrB,CAAC;GAMS,KAAc,GAAY,MAAiC;CACtE,IAAM,EAAE,cAAW,mBAAgB,GAAsB,EACnD,IAAuB,KAAuB;AAEpD,QAAO,EAAS;EACd,UAAU;GAAC;GAAW;GAAsB;GAAG;EAC/C,SAAS,YAA8B;GACrC,IAAM,IAAS,MAAM,EAAmC;IACtD,SAAS;IACT,WAAW,KAAa,KAAA;IACxB,OAAO;IACP,WAAW,EAAE,OAAI;IACjB,aAAa,KAAwB,KAAA;IACrC,gBAAgB;IACjB,CAAC;AAEF,OAAI,EAAO,QAAQ,OACjB,OAAU,MAAM,EAAO,OAAO,IAAI,WAAW,gBAAgB;AAG/D,UAAO,EAAO,KAAM;;EAEtB,SAAS,CAAC,CAAC;EACX,WAAW,MAAS;EACrB,CAAC;GAMS,KAAiB,MAAiC;CAC7D,IAAM,EAAE,cAAW,mBAAgB,GAAsB;AAEzD,QAAO,EAAS;EACd,UAAU;GAAC;GAAc;GAAa;GAAW;EACjD,SAAS,YAAkC;GACzC,IAAM,IAAS,MAAM,EAA0C;IAC7D,SAAS;IACT,WAAW,KAAa,KAAA;IACxB,OAAO;IACP,WAAW,EAAE,eAAY;IACzB,aAAa,KAAe,KAAA;IAC5B,gBAAgB;IACjB,CAAC;AAEF,OAAI,EAAO,QAAQ,OACjB,OAAU,MAAM,EAAO,OAAO,IAAI,WAAW,gBAAgB;AAG/D,UAAO,EAAO,KAAM;;EAEtB,WAAW,MAAS;EACrB,CAAC;GAGS,KAA0B,GAAmB,MAAiC;CACzF,IAAM,EAAE,cAAW,mBAAgB,GAAsB,EACnD,IAAuB,KAAuB;AAEpD,QAAO,EAAS;EACd,UAAU;GAAC;GAAuB;GAAsB;GAAU;EAClE,SAAS,YAA6B;GACpC,IAAM,IAAS,MAAM,EAElB;IACD,SAAS;IACT,WAAW,KAAa,KAAA;IACxB,OAAO;IACP,WAAW,EAAE,cAAW;IACxB,aAAa,KAAwB,KAAA;IACrC,gBAAgB;IACjB,CAAC;AAEF,OAAI,EAAO,QAAQ,OACjB,OAAU,MAAM,EAAO,OAAO,IAAI,WAAW,gBAAgB;AAG/D,UAAO,EAAO,MAAM,eAAe,SAAS;;EAE9C,SAAS,CAAC,CAAC,KAAa,CAAC,CAAC;EAC1B,WAAW,KAAK;EACjB,CAAC"}
1
+ {"version":3,"file":"useProjects.js","names":[],"sources":["../../src/hooks/useProjects.ts"],"sourcesContent":["import { useQuery } from '@tanstack/react-query';\nimport { graphqlFetch } from '@burdenoff/fe-libs/shared/graphql';\nimport { useWorkspacesContext } from '../providers/WorkspacesProvider';\nimport type { ProjectFilters, ProjectList, Project, PaginationInput } from '../types';\n\nconst GET_PROJECTS_QUERY = `\n query GetProjects($filter: ProjectFilterInput, $pagination: PaginationInput) {\n projects(filter: $filter, pagination: $pagination) {\n items {\n id\n name\n key\n workspaceId\n creatorId\n status\n config\n tags\n tagAssignments {\n id\n tagId\n entityType\n entityId\n source\n assignedBy\n assignedAt\n validFrom\n validTo\n metadata\n tag {\n id\n key\n label\n value\n vocabularyId\n parentId\n hierarchyPath\n color\n icon\n description\n vocabulary {\n key\n }\n }\n }\n archived\n createdAt\n updatedAt\n deletedAt\n }\n total\n hasMore\n }\n }\n`;\n\nconst GET_PROJECT_QUERY = `\n query GetProject($id: ID!) {\n project(id: $id) {\n id\n name\n key\n workspaceId\n creatorId\n status\n config\n tags\n tagAssignments {\n id\n tagId\n entityType\n entityId\n source\n assignedBy\n assignedAt\n validFrom\n validTo\n metadata\n tag {\n id\n key\n label\n value\n vocabularyId\n parentId\n hierarchyPath\n color\n icon\n description\n vocabulary {\n key\n }\n }\n }\n archived\n createdAt\n updatedAt\n deletedAt\n }\n }\n`;\n\nconst GET_MY_PROJECTS_QUERY = `\n query GetMyProjects($pagination: PaginationInput) {\n myProjects(pagination: $pagination) {\n items {\n id\n name\n key\n workspaceId\n status\n tags\n tagAssignments {\n id\n tagId\n entityType\n entityId\n source\n assignedBy\n assignedAt\n validFrom\n validTo\n metadata\n tag {\n id\n key\n label\n value\n vocabularyId\n parentId\n hierarchyPath\n color\n icon\n description\n vocabulary {\n key\n }\n }\n }\n archived\n createdAt\n updatedAt\n }\n total\n hasMore\n }\n }\n`;\n\nconst GET_PROJECT_MEMBERS_COUNT = `\n query GetProjectMembersCount($projectId: ID!) {\n projectMembers(filter: { projectId: $projectId }, pagination: { limit: 1 }) {\n total\n }\n }\n`;\n\n/**\n * Hook to fetch all projects with filtering and pagination\n */\nexport const useProjects = (\n filters?: ProjectFilters,\n pagination?: PaginationInput,\n workspaceIdOverride?: string\n) => {\n const { authToken, workspaceId } = useWorkspacesContext();\n const effectiveWorkspaceId = filters?.workspaceId || workspaceIdOverride || workspaceId;\n\n return useQuery({\n queryKey: ['projects', effectiveWorkspaceId, filters, pagination],\n queryFn: async (): Promise<ProjectList> => {\n const result = await graphqlFetch<{ projects: ProjectList }>({\n gateway: 'workspace',\n authToken: authToken || undefined,\n query: GET_PROJECTS_QUERY,\n variables: {\n filter: {\n ...filters,\n workspaceId: effectiveWorkspaceId,\n },\n pagination,\n },\n workspaceId: effectiveWorkspaceId || undefined,\n workspaceToken: true, // Auto-read from profile context for x-workspace-id header (required by gateway RBAC)\n });\n\n if (result.errors?.length) {\n throw new Error(result.errors[0]?.message || 'GraphQL error');\n }\n\n return result.data!.projects;\n },\n enabled: !!effectiveWorkspaceId,\n staleTime: 5 * 60 * 1000,\n });\n};\n\n/**\n * Hook to fetch a single project by ID\n */\nexport const useProject = (id: string, workspaceIdOverride?: string) => {\n const { authToken, workspaceId } = useWorkspacesContext();\n const effectiveWorkspaceId = workspaceIdOverride || workspaceId;\n\n return useQuery({\n queryKey: ['project', effectiveWorkspaceId, id],\n queryFn: async (): Promise<Project> => {\n const result = await graphqlFetch<{ project: Project }>({\n gateway: 'workspace',\n authToken: authToken || undefined,\n query: GET_PROJECT_QUERY,\n variables: { id },\n workspaceId: effectiveWorkspaceId || undefined,\n workspaceToken: true, // Auto-read from profile context for x-workspace-id header (required by gateway RBAC)\n });\n\n if (result.errors?.length) {\n throw new Error(result.errors[0]?.message || 'GraphQL error');\n }\n\n return result.data!.project;\n },\n enabled: !!id,\n staleTime: 5 * 60 * 1000,\n });\n};\n\n/**\n * Hook to fetch current user's projects\n */\nexport const useMyProjects = (pagination?: PaginationInput) => {\n const { authToken, workspaceId } = useWorkspacesContext();\n\n return useQuery({\n queryKey: ['myProjects', workspaceId, pagination],\n queryFn: async (): Promise<ProjectList> => {\n const result = await graphqlFetch<{ myProjects: ProjectList }>({\n gateway: 'workspace',\n authToken: authToken || undefined,\n query: GET_MY_PROJECTS_QUERY,\n variables: { pagination },\n workspaceId: workspaceId || undefined,\n workspaceToken: true, // Auto-read from profile context for x-workspace-id header (required by gateway RBAC)\n });\n\n if (result.errors?.length) {\n throw new Error(result.errors[0]?.message || 'GraphQL error');\n }\n\n return result.data!.myProjects;\n },\n staleTime: 5 * 60 * 1000,\n });\n};\n\nexport const useProjectMembersCount = (projectId: string, workspaceIdOverride?: string) => {\n const { authToken, workspaceId } = useWorkspacesContext();\n const effectiveWorkspaceId = workspaceIdOverride || workspaceId;\n\n return useQuery({\n queryKey: ['projectMembersCount', effectiveWorkspaceId, projectId],\n queryFn: async (): Promise<number> => {\n const result = await graphqlFetch<{\n projectMembers: { total: number };\n }>({\n gateway: 'workspace',\n authToken: authToken || undefined,\n query: GET_PROJECT_MEMBERS_COUNT,\n variables: { projectId },\n workspaceId: effectiveWorkspaceId || undefined,\n workspaceToken: true,\n });\n\n if (result.errors?.length) {\n throw new Error(result.errors[0]?.message || 'GraphQL error');\n }\n\n return result.data?.projectMembers.total ?? 0;\n },\n enabled: !!projectId && !!effectiveWorkspaceId,\n staleTime: 60 * 1000,\n });\n};\n"],"mappings":";;;;AAKA,IAAM,IAAqB,46BAkDrB,IAAoB,stBA8CpB,IAAwB,40BA+CxB,IAA4B,qKAWrB,KACX,GACA,GACA,MACG;CACH,IAAM,EAAE,cAAW,mBAAgB,GAAsB,EACnD,IAAuB,GAAS,eAAe,KAAuB;AAE5E,QAAO,EAAS;EACd,UAAU;GAAC;GAAY;GAAsB;GAAS;GAAW;EACjE,SAAS,YAAkC;GACzC,IAAM,IAAS,MAAM,EAAwC;IAC3D,SAAS;IACT,WAAW,KAAa,KAAA;IACxB,OAAO;IACP,WAAW;KACT,QAAQ;MACN,GAAG;MACH,aAAa;MACd;KACD;KACD;IACD,aAAa,KAAwB,KAAA;IACrC,gBAAgB;IACjB,CAAC;AAEF,OAAI,EAA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SAAS;IACT,WAAW,KAAa,KAAA;IACxB,OAAO;IACP,WAAW,EAAE,cAAW;IACxB,aAAa,KAAwB,KAAA;IACrC,gBAAgB;IACjB,CAAC;AAEF,OAAI,EAAO,QAAQ,OACjB,OAAU,MAAM,EAAO,OAAO,IAAI,WAAW,gBAAgB;AAG/D,UAAO,EAAO,MAAM,eAAe,SAAS;;EAE9C,SAAS,CAAC,CAAC,KAAa,CAAC,CAAC;EAC1B,WAAW,KAAK;EACjB,CAAC"}
@@ -107,7 +107,7 @@ var l = (t, n) => {
107
107
  staleTime: 300 * 1e3
108
108
  });
109
109
  }, p = (n, r = !0) => {
110
- let { authToken: i, workspaceId: a } = e();
110
+ let { authToken: i } = e();
111
111
  return o({
112
112
  queryKey: ["invitation", n],
113
113
  queryFn: async () => {
@@ -1 +1 @@
1
- {"version":3,"file":"useWorkspaceMembers.js","names":[],"sources":["../../src/hooks/useWorkspaceMembers.ts"],"sourcesContent":["import { useQuery } from '@tanstack/react-query';\nimport { print } from 'graphql';\nimport { graphqlFetch } from '@burdenoff/fe-libs/shared/graphql';\nimport { useWorkspacesContext } from '../providers/WorkspacesProvider';\nimport {\n GetWorkspaceMembersDocument,\n GetWorkspaceMemberDocument,\n GetUserWorkspacesDocument,\n GetWorkspaceInvitationsDocument,\n GetInvitationDocument,\n} from '../generated/wspace-operations';\nimport type {\n MemberList,\n WorkspaceMember,\n WorkspaceInvitation,\n InvitationList,\n PaginationInput,\n InvitationStatus,\n} from '../types';\n\n/**\n * Hook to fetch all members of the current workspace\n */\nexport const useWorkspaceMembers = (workspaceId: string, pagination?: PaginationInput) => {\n const { authToken } = useWorkspacesContext();\n\n return useQuery({\n queryKey: ['workspaceMembers', workspaceId, pagination],\n queryFn: async (): Promise<MemberList> => {\n const result = await graphqlFetch<{ workspaceMembers: MemberList }>({\n gateway: 'workspace',\n authToken: authToken || undefined,\n query: print(GetWorkspaceMembersDocument),\n variables: { workspaceId, pagination },\n workspaceId,\n workspaceToken: true, // Auto-read from profile context for x-workspace-id header (required by gateway RBAC)\n });\n\n if (result.errors?.length) {\n throw new Error(result.errors[0]?.message || 'GraphQL error');\n }\n\n return result.data!.workspaceMembers;\n },\n enabled: !!workspaceId,\n staleTime: 5 * 60 * 1000,\n });\n};\n\n/**\n * Hook to fetch a single workspace member by ID\n */\nexport const useWorkspaceMember = (id: string) => {\n const { authToken, workspaceId } = useWorkspacesContext();\n\n return useQuery({\n queryKey: ['workspaceMember', workspaceId, id],\n queryFn: async (): Promise<WorkspaceMember> => {\n const result = await graphqlFetch<{ workspaceMember: WorkspaceMember }>({\n gateway: 'workspace',\n authToken: authToken || undefined,\n query: print(GetWorkspaceMemberDocument),\n variables: { id },\n workspaceId: workspaceId || undefined,\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!.workspaceMember;\n },\n enabled: !!id,\n staleTime: 5 * 60 * 1000,\n });\n};\n\n/**\n * Hook to fetch all workspaces a user is a member of\n */\nexport const useUserWorkspaces = (userId: string, pagination?: PaginationInput) => {\n const { authToken, workspaceId } = useWorkspacesContext();\n\n return useQuery({\n queryKey: ['userWorkspaces', userId, pagination],\n queryFn: async (): Promise<MemberList> => {\n const result = await graphqlFetch<{ userWorkspaces: MemberList }>({\n gateway: 'workspace',\n authToken: authToken || undefined,\n query: print(GetUserWorkspacesDocument),\n variables: { userId, pagination },\n workspaceId: workspaceId || undefined,\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!.userWorkspaces;\n },\n enabled: !!userId,\n staleTime: 5 * 60 * 1000,\n });\n};\n\n/**\n * Hook to fetch workspace invitations\n * Requires x-workspace-id header for workspace context\n */\nexport const useWorkspaceInvitations = (\n workspaceId: string,\n status?: InvitationStatus,\n pagination?: PaginationInput\n) => {\n const { authToken } = useWorkspacesContext();\n\n return useQuery({\n queryKey: ['workspaceInvitations', workspaceId, status, pagination],\n queryFn: async (): Promise<InvitationList> => {\n const result = await graphqlFetch<{ workspaceInvitations: InvitationList }>({\n gateway: 'workspace',\n authToken: authToken || undefined,\n query: print(GetWorkspaceInvitationsDocument),\n variables: { status, pagination },\n workspaceId,\n workspaceToken: true, // Auto-read from profile context for x-workspace-id header\n });\n\n if (result.errors?.length) {\n throw new Error(result.errors[0]?.message || 'GraphQL error');\n }\n\n return result.data!.workspaceInvitations;\n },\n enabled: !!workspaceId,\n staleTime: 5 * 60 * 1000,\n });\n};\n\n/**\n * Hook to get a single invitation by ID (for acceptance page)\n */\nexport const useInvitation = (id: string, enabled = true) => {\n const { authToken, workspaceId } = useWorkspacesContext();\n\n return useQuery({\n queryKey: ['invitation', id],\n queryFn: async (): Promise<WorkspaceInvitation> => {\n const result = await graphqlFetch<{ invitation: WorkspaceInvitation }>({\n gateway: 'workspace',\n authToken: authToken || undefined,\n query: print(GetInvitationDocument),\n variables: { id },\n });\n\n if (result.errors?.length) {\n throw new Error(result.errors[0]?.message || 'Failed to fetch invitation');\n }\n\n if (!result.data?.invitation) {\n throw new Error('Invitation not found');\n }\n\n return result.data.invitation;\n },\n enabled: !!id && enabled,\n retry: 1,\n staleTime: 5 * 60 * 1000,\n });\n};\n"],"mappings":";;;;;;AAuBA,IAAa,KAAuB,GAAqB,MAAiC;CACxF,IAAM,EAAE,iBAAc,GAAsB;AAE5C,QAAO,EAAS;EACd,UAAU;GAAC;GAAoB;GAAa;GAAW;EACvD,SAAS,YAAiC;GACxC,IAAM,IAAS,MAAM,EAA+C;IAClE,SAAS;IACT,WAAW,KAAa,KAAA;IACxB,OAAO,EAAM,EAA4B;IACzC,WAAW;KAAE;KAAa;KAAY;IACtC;IACA,gBAAgB;IACjB,CAAC;AAEF,OAAI,EAAO,QAAQ,OACjB,OAAU,MAAM,EAAO,OAAO,IAAI,WAAW,gBAAgB;AAG/D,UAAO,EAAO,KAAM;;EAEtB,SA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AQ;KAAY;IACjC;IACA,gBAAgB;IACjB,CAAC;AAEF,OAAI,EAAO,QAAQ,OACjB,OAAU,MAAM,EAAO,OAAO,IAAI,WAAW,gBAAgB;AAG/D,UAAO,EAAO,KAAM;;EAEtB,SAAS,CAAC,CAAC;EACX,WAAW,MAAS;EACrB,CAAC;GAMS,KAAiB,GAAY,IAAU,OAAS;CAC3D,IAAM,EAAE,cAAW,mBAAgB,GAAsB;AAEzD,QAAO,EAAS;EACd,UAAU,CAAC,cAAc,EAAG;EAC5B,SAAS,YAA0C;GACjD,IAAM,IAAS,MAAM,EAAkD;IACrE,SAAS;IACT,WAAW,KAAa,KAAA;IACxB,OAAO,EAAM,EAAsB;IACnC,WAAW,EAAE,OAAI;IAClB,CAAC;AAEF,OAAI,EAAO,QAAQ,OACjB,OAAU,MAAM,EAAO,OAAO,IAAI,WAAW,6BAA6B;AAG5E,OAAI,CAAC,EAAO,MAAM,WAChB,OAAU,MAAM,uBAAuB;AAGzC,UAAO,EAAO,KAAK;;EAErB,SAAS,CAAC,CAAC,KAAM;EACjB,OAAO;EACP,WAAW,MAAS;EACrB,CAAC"}
1
+ {"version":3,"file":"useWorkspaceMembers.js","names":[],"sources":["../../src/hooks/useWorkspaceMembers.ts"],"sourcesContent":["import { useQuery } from '@tanstack/react-query';\nimport { print } from 'graphql';\nimport { graphqlFetch } from '@burdenoff/fe-libs/shared/graphql';\nimport { useWorkspacesContext } from '../providers/WorkspacesProvider';\nimport {\n GetWorkspaceMembersDocument,\n GetWorkspaceMemberDocument,\n GetUserWorkspacesDocument,\n GetWorkspaceInvitationsDocument,\n GetInvitationDocument,\n} from '../generated/wspace-operations';\nimport type {\n MemberList,\n WorkspaceMember,\n WorkspaceInvitation,\n InvitationList,\n PaginationInput,\n InvitationStatus,\n} from '../types';\n\n/**\n * Hook to fetch all members of the current workspace\n */\nexport const useWorkspaceMembers = (workspaceId: string, pagination?: PaginationInput) => {\n const { authToken } = useWorkspacesContext();\n\n return useQuery({\n queryKey: ['workspaceMembers', workspaceId, pagination],\n queryFn: async (): Promise<MemberList> => {\n const result = await graphqlFetch<{ workspaceMembers: MemberList }>({\n gateway: 'workspace',\n authToken: authToken || undefined,\n query: print(GetWorkspaceMembersDocument),\n variables: { workspaceId, pagination },\n workspaceId,\n workspaceToken: true, // Auto-read from profile context for x-workspace-id header (required by gateway RBAC)\n });\n\n if (result.errors?.length) {\n throw new Error(result.errors[0]?.message || 'GraphQL error');\n }\n\n return result.data!.workspaceMembers;\n },\n enabled: !!workspaceId,\n staleTime: 5 * 60 * 1000,\n });\n};\n\n/**\n * Hook to fetch a single workspace member by ID\n */\nexport const useWorkspaceMember = (id: string) => {\n const { authToken, workspaceId } = useWorkspacesContext();\n\n return useQuery({\n queryKey: ['workspaceMember', workspaceId, id],\n queryFn: async (): Promise<WorkspaceMember> => {\n const result = await graphqlFetch<{ workspaceMember: WorkspaceMember }>({\n gateway: 'workspace',\n authToken: authToken || undefined,\n query: print(GetWorkspaceMemberDocument),\n variables: { id },\n workspaceId: workspaceId || undefined,\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!.workspaceMember;\n },\n enabled: !!id,\n staleTime: 5 * 60 * 1000,\n });\n};\n\n/**\n * Hook to fetch all workspaces a user is a member of\n */\nexport const useUserWorkspaces = (userId: string, pagination?: PaginationInput) => {\n const { authToken, workspaceId } = useWorkspacesContext();\n\n return useQuery({\n queryKey: ['userWorkspaces', userId, pagination],\n queryFn: async (): Promise<MemberList> => {\n const result = await graphqlFetch<{ userWorkspaces: MemberList }>({\n gateway: 'workspace',\n authToken: authToken || undefined,\n query: print(GetUserWorkspacesDocument),\n variables: { userId, pagination },\n workspaceId: workspaceId || undefined,\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!.userWorkspaces;\n },\n enabled: !!userId,\n staleTime: 5 * 60 * 1000,\n });\n};\n\n/**\n * Hook to fetch workspace invitations\n * Requires x-workspace-id header for workspace context\n */\nexport const useWorkspaceInvitations = (\n workspaceId: string,\n status?: InvitationStatus,\n pagination?: PaginationInput\n) => {\n const { authToken } = useWorkspacesContext();\n\n return useQuery({\n queryKey: ['workspaceInvitations', workspaceId, status, pagination],\n queryFn: async (): Promise<InvitationList> => {\n const result = await graphqlFetch<{ workspaceInvitations: InvitationList }>({\n gateway: 'workspace',\n authToken: authToken || undefined,\n query: print(GetWorkspaceInvitationsDocument),\n variables: { status, pagination },\n workspaceId,\n workspaceToken: true, // Auto-read from profile context for x-workspace-id header\n });\n\n if (result.errors?.length) {\n throw new Error(result.errors[0]?.message || 'GraphQL error');\n }\n\n return result.data!.workspaceInvitations;\n },\n enabled: !!workspaceId,\n staleTime: 5 * 60 * 1000,\n });\n};\n\n/**\n * Hook to get a single invitation by ID (for acceptance page)\n */\nexport const useInvitation = (id: string, enabled = true) => {\n const { authToken } = useWorkspacesContext();\n\n return useQuery({\n queryKey: ['invitation', id],\n queryFn: async (): Promise<WorkspaceInvitation> => {\n const result = await graphqlFetch<{ invitation: WorkspaceInvitation }>({\n gateway: 'workspace',\n authToken: authToken || undefined,\n query: print(GetInvitationDocument),\n variables: { id },\n });\n\n if (result.errors?.length) {\n throw new Error(result.errors[0]?.message || 'Failed to fetch invitation');\n }\n\n if (!result.data?.invitation) {\n throw new Error('Invitation not found');\n }\n\n return result.data.invitation;\n },\n enabled: !!id && enabled,\n retry: 1,\n staleTime: 5 * 60 * 1000,\n });\n};\n"],"mappings":";;;;;;AAuBA,IAAa,KAAuB,GAAqB,MAAiC;CACxF,IAAM,EAAE,iBAAc,GAAsB;AAE5C,QAAO,EAAS;EACd,UAAU;GAAC;GAAoB;GAAa;GAAW;EACvD,SAAS,YAAiC;GACxC,IAAM,IAAS,MAAM,EAA+C;IAClE,SAAS;IACT,WAAW,KAAa,KAAA;IACxB,OAAO,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O,EAAS;EACd,UAAU;GAAC;GAAwB;GAAa;GAAQ;GAAW;EACnE,SAAS,YAAqC;GAC5C,IAAM,IAAS,MAAM,EAAuD;IAC1E,SAAS;IACT,WAAW,KAAa,KAAA;IACxB,OAAO,EAAM,EAAgC;IAC7C,WAAW;KAAE;KAAQ;KAAY;IACjC;IACA,gBAAgB;IACjB,CAAC;AAEF,OAAI,EAAO,QAAQ,OACjB,OAAU,MAAM,EAAO,OAAO,IAAI,WAAW,gBAAgB;AAG/D,UAAO,EAAO,KAAM;;EAEtB,SAAS,CAAC,CAAC;EACX,WAAW,MAAS;EACrB,CAAC;GAMS,KAAiB,GAAY,IAAU,OAAS;CAC3D,IAAM,EAAE,iBAAc,GAAsB;AAE5C,QAAO,EAAS;EACd,UAAU,CAAC,cAAc,EAAG;EAC5B,SAAS,YAA0C;GACjD,IAAM,IAAS,MAAM,EAAkD;IACrE,SAAS;IACT,WAAW,KAAa,KAAA;IACxB,OAAO,EAAM,EAAsB;IACnC,WAAW,EAAE,OAAI;IAClB,CAAC;AAEF,OAAI,EAAO,QAAQ,OACjB,OAAU,MAAM,EAAO,OAAO,IAAI,WAAW,6BAA6B;AAG5E,OAAI,CAAC,EAAO,MAAM,WAChB,OAAU,MAAM,uBAAuB;AAGzC,UAAO,EAAO,KAAK;;EAErB,SAAS,CAAC,CAAC,KAAM;EACjB,OAAO;EACP,WAAW,MAAS;EACrB,CAAC"}
package/dist/index.js CHANGED
@@ -2,23 +2,25 @@ import { WorkspacesProvider as e, useWorkspacesContext as t } from "./providers/
2
2
  import { WorkspacesErrorBoundary as n } from "./components/WorkspacesErrorBoundary.js";
3
3
  import { useWorkspacesStore as r } from "./store/workspacesStore.js";
4
4
  import { useMyWorkspaces as i, useWorkspace as a, useWorkspaces as o } from "./hooks/useWorkspaces.js";
5
- import { getMemberRoleClasses as s, getMemberRoleLabel as c, getProjectStatusClasses as l, getProjectStatusIconClass as u, getProjectStatusLabel as d, getWorkspaceStatusBgClass as f, getWorkspaceStatusClasses as p, getWorkspaceStatusIconClass as m, getWorkspaceStatusLabel as h } from "./utils/tokenHelpers.js";
6
- import { WorkspaceCard as g } from "./components/WorkspaceCard.js";
7
- import { WorkspacesRoot as _ } from "./WorkspacesRoot.js";
8
- import { DashboardPage as v } from "./pages/dashboard/DashboardPage.js";
9
- import { useInvitation as y, useUserWorkspaces as b, useWorkspaceInvitations as x, useWorkspaceMember as S, useWorkspaceMembers as C } from "./hooks/useWorkspaceMembers.js";
10
- import { useAcceptInvitation as w, useAddWorkspaceMember as T, useBulkCreateInvitations as E, useCancelInvitation as D, useCreateInvitation as O, useDeleteInvitation as k, useRejectInvitation as A, useRemoveUserFromWorkspace as j, useRemoveWorkspaceMember as M, useResendInvitation as N, useUpdateInvitation as P } from "./hooks/useMemberMutations.js";
11
- import { InviteAcceptancePage as F } from "./pages/InviteAcceptancePage.js";
12
- import { useArchiveWorkspace as I, useCreateWorkspace as L, useDeleteWorkspace as R, useReactivateWorkspace as z, useUpdateWorkspace as B } from "./hooks/useWorkspaceMutations.js";
13
- import { useMyProjects as V, useProject as H, useProjectMembersCount as U, useProjects as W } from "./hooks/useProjects.js";
14
- import { useArchiveProject as G, useCreateProject as K, useDeleteProject as q, useUnarchiveProject as J, useUpdateProject as Y } from "./hooks/useProjectMutations.js";
15
- import { useMyOrganizations as X, useMyTenants as Z } from "./hooks/useTenants.js";
5
+ import { useMyPendingInvitations as s } from "./hooks/usePendingInvitations.js";
6
+ import { getMemberRoleClasses as c, getMemberRoleLabel as l, getProjectStatusClasses as u, getProjectStatusIconClass as d, getProjectStatusLabel as f, getWorkspaceStatusBgClass as p, getWorkspaceStatusClasses as m, getWorkspaceStatusIconClass as h, getWorkspaceStatusLabel as g } from "./utils/tokenHelpers.js";
7
+ import { WorkspaceCard as _ } from "./components/WorkspaceCard.js";
8
+ import { WorkspacesRoot as v } from "./WorkspacesRoot.js";
9
+ import { DashboardPage as y } from "./pages/dashboard/DashboardPage.js";
10
+ import { useInvitation as b, useUserWorkspaces as x, useWorkspaceInvitations as S, useWorkspaceMember as C, useWorkspaceMembers as w } from "./hooks/useWorkspaceMembers.js";
11
+ import { useAcceptInvitation as T, useAddWorkspaceMember as E, useBulkCreateInvitations as D, useCancelInvitation as O, useCreateInvitation as k, useDeleteInvitation as A, useRejectInvitation as j, useRemoveUserFromWorkspace as M, useRemoveWorkspaceMember as N, useResendInvitation as P, useUpdateInvitation as F } from "./hooks/useMemberMutations.js";
12
+ import { InviteAcceptancePage as I } from "./pages/InviteAcceptancePage.js";
13
+ import { PendingInvitesPage as L } from "./pages/PendingInvitesPage.js";
14
+ import { useArchiveWorkspace as R, useCreateWorkspace as z, useDeleteWorkspace as B, useReactivateWorkspace as V, useUpdateWorkspace as H } from "./hooks/useWorkspaceMutations.js";
15
+ import { useMyProjects as U, useProject as W, useProjectMembersCount as G, useProjects as K } from "./hooks/useProjects.js";
16
+ import { useArchiveProject as q, useCreateProject as J, useDeleteProject as Y, useTagProject as X, useUnarchiveProject as Z, useUntagProject as Q, useUpdateProject as $ } from "./hooks/useProjectMutations.js";
17
+ import { useMyOrganizations as ee, useMyTenants as te } from "./hooks/useTenants.js";
16
18
  import "./hooks/index.js";
17
- import { CreateWorkspaceDialog as Q } from "./components/CreateWorkspaceDialog.js";
18
- import { formatDate as $, formatDateTime as ee, formatFileSize as te, formatProjectStatus as ne, formatRelativeTime as re, formatWorkspaceStatus as ie, getInitials as ae, toTitleCase as oe, truncate as se } from "./utils/formatters.js";
19
- import { ProjectCard as ce } from "./components/ProjectCard.js";
20
- import { CreateProjectDialog as le } from "./components/CreateProjectDialog.js";
21
- import { MemberListItem as ue } from "./components/MemberListItem.js";
22
- import { InviteMemberDialog as de } from "./components/InviteMemberDialog.js";
19
+ import { CreateWorkspaceDialog as ne } from "./components/CreateWorkspaceDialog.js";
20
+ import { formatDate as re, formatDateTime as ie, formatFileSize as ae, formatProjectStatus as oe, formatRelativeTime as se, formatWorkspaceStatus as ce, getInitials as le, toTitleCase as ue, truncate as de } from "./utils/formatters.js";
21
+ import { ProjectCard as fe } from "./components/ProjectCard.js";
22
+ import { CreateProjectDialog as pe } from "./components/CreateProjectDialog.js";
23
+ import { MemberListItem as me } from "./components/MemberListItem.js";
24
+ import { InviteMemberDialog as he } from "./components/InviteMemberDialog.js";
23
25
  import "./components/index.js";
24
- export { le as CreateProjectDialog, Q as CreateWorkspaceDialog, v as DashboardPage, F as InviteAcceptancePage, de as InviteMemberDialog, ue as MemberListItem, ce as ProjectCard, g as WorkspaceCard, n as WorkspacesErrorBoundary, e as WorkspacesProvider, _ as WorkspacesRoot, $ as formatDate, ee as formatDateTime, te as formatFileSize, ne as formatProjectStatus, re as formatRelativeTime, ie as formatWorkspaceStatus, ae as getInitials, s as getMemberRoleClasses, c as getMemberRoleLabel, l as getProjectStatusClasses, u as getProjectStatusIconClass, d as getProjectStatusLabel, f as getWorkspaceStatusBgClass, p as getWorkspaceStatusClasses, m as getWorkspaceStatusIconClass, h as getWorkspaceStatusLabel, oe as toTitleCase, se as truncate, w as useAcceptInvitation, T as useAddWorkspaceMember, G as useArchiveProject, I as useArchiveWorkspace, E as useBulkCreateInvitations, D as useCancelInvitation, O as useCreateInvitation, K as useCreateProject, L as useCreateWorkspace, k as useDeleteInvitation, q as useDeleteProject, R as useDeleteWorkspace, y as useInvitation, X as useMyOrganizations, V as useMyProjects, Z as useMyTenants, i as useMyWorkspaces, H as useProject, U as useProjectMembersCount, W as useProjects, z as useReactivateWorkspace, A as useRejectInvitation, j as useRemoveUserFromWorkspace, M as useRemoveWorkspaceMember, N as useResendInvitation, J as useUnarchiveProject, P as useUpdateInvitation, Y as useUpdateProject, B as useUpdateWorkspace, b as useUserWorkspaces, a as useWorkspace, x as useWorkspaceInvitations, S as useWorkspaceMember, C as useWorkspaceMembers, o as useWorkspaces, t as useWorkspacesContext, r as useWorkspacesStore };
26
+ export { pe as CreateProjectDialog, ne as CreateWorkspaceDialog, y as DashboardPage, I as InviteAcceptancePage, he as InviteMemberDialog, me as MemberListItem, L as PendingInvitesPage, fe as ProjectCard, _ as WorkspaceCard, n as WorkspacesErrorBoundary, e as WorkspacesProvider, v as WorkspacesRoot, re as formatDate, ie as formatDateTime, ae as formatFileSize, oe as formatProjectStatus, se as formatRelativeTime, ce as formatWorkspaceStatus, le as getInitials, c as getMemberRoleClasses, l as getMemberRoleLabel, u as getProjectStatusClasses, d as getProjectStatusIconClass, f as getProjectStatusLabel, p as getWorkspaceStatusBgClass, m as getWorkspaceStatusClasses, h as getWorkspaceStatusIconClass, g as getWorkspaceStatusLabel, ue as toTitleCase, de as truncate, T as useAcceptInvitation, E as useAddWorkspaceMember, q as useArchiveProject, R as useArchiveWorkspace, D as useBulkCreateInvitations, O as useCancelInvitation, k as useCreateInvitation, J as useCreateProject, z as useCreateWorkspace, A as useDeleteInvitation, Y as useDeleteProject, B as useDeleteWorkspace, b as useInvitation, ee as useMyOrganizations, s as useMyPendingInvitations, U as useMyProjects, te as useMyTenants, i as useMyWorkspaces, W as useProject, G as useProjectMembersCount, K as useProjects, V as useReactivateWorkspace, j as useRejectInvitation, M as useRemoveUserFromWorkspace, N as useRemoveWorkspaceMember, P as useResendInvitation, X as useTagProject, Z as useUnarchiveProject, Q as useUntagProject, F as useUpdateInvitation, $ as useUpdateProject, H as useUpdateWorkspace, x as useUserWorkspaces, a as useWorkspace, S as useWorkspaceInvitations, C as useWorkspaceMember, w as useWorkspaceMembers, o as useWorkspaces, t as useWorkspacesContext, r as useWorkspacesStore };