@burdenoff/microfe-workspaces 2026.531.3 → 2026.601.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.
@@ -22,7 +22,7 @@ var v = () => {
22
22
  return i.data.addWorkspaceMember;
23
23
  },
24
24
  onSuccess: (e) => {
25
- i.invalidateQueries({ queryKey: ["workspaceMembers", e.workspaceId] }), i.invalidateQueries({ queryKey: ["userWorkspaces"] }), a("workspace-member.added", {
25
+ i.invalidateQueries({ queryKey: ["workspaceMembers", e.workspaceId] }), i.invalidateQueries({ queryKey: ["workspaceMembersInfinite", e.workspaceId] }), i.invalidateQueries({ queryKey: ["userWorkspaces"] }), a("workspace-member.added", {
26
26
  memberId: e.id,
27
27
  workspaceId: e.workspaceId,
28
28
  userId: e.userId,
@@ -54,7 +54,7 @@ var v = () => {
54
54
  return t.data.removeWorkspaceMember;
55
55
  },
56
56
  onSuccess: (e, t) => {
57
- i.invalidateQueries({ queryKey: ["workspaceMembers"] }), i.invalidateQueries({ queryKey: ["userWorkspaces"] }), a("workspace-member.removed", {
57
+ i.invalidateQueries({ queryKey: ["workspaceMembers"] }), i.invalidateQueries({ queryKey: ["workspaceMembersInfinite"] }), i.invalidateQueries({ queryKey: ["userWorkspaces"] }), a("workspace-member.removed", {
58
58
  memberId: t,
59
59
  source: "microfe-workspaces"
60
60
  });
@@ -84,7 +84,7 @@ var v = () => {
84
84
  return t.data.removeUserFromWorkspace;
85
85
  },
86
86
  onSuccess: (e, t) => {
87
- i.invalidateQueries({ queryKey: ["workspaceMembers"] }), i.invalidateQueries({ queryKey: ["userWorkspaces", t] }), a("workspace-member.removed", {
87
+ i.invalidateQueries({ queryKey: ["workspaceMembers"] }), i.invalidateQueries({ queryKey: ["workspaceMembersInfinite"] }), i.invalidateQueries({ queryKey: ["userWorkspaces", t] }), a("workspace-member.removed", {
88
88
  userId: t,
89
89
  source: "microfe-workspaces"
90
90
  });
@@ -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: ['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 = (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<{ cancelInvitation: WorkspaceInvitation }>({\n gateway: 'workspace',\n authToken: authToken || undefined,\n query: print(CancelInvitationDocument),\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!.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: effectiveWorkspaceId || 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,EAA2B;IACxC,WAAW,EAAE,UAAO;IACpB,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,YAAY,MAAS;AAGnB,GAFA,EAAY,kBAAkB,EAAE,UAAU,CAAC,oBAAoB,EAAK,YAAY,EAAE,CAAC,EACnF,EAAY,kBAAkB,EAAE,UAAU,CAAC,iBAAiB,EAAE,CAAC,EAC/D,EAAK,0BAA0B;IAC7B,UAAU,EAAK;IACf,aAAa,EAAK;IAClB,QAAQ,EAAK;IACb,QAAQ;IACT,CAAC;;EAEJ,UAAU,GAAK,MAAU;AACvB,KAAK,+BAA+B;IAClC,aAAa,KAAe,KAAA;IAC5B,QAAQ,GAAO;IACf,QAAQ;IACR,cAAc,EAAmB,EAAI;IACtC,CAAC;;EAEL,CAAC;GAMS,KAA4B,MAAiC;CACxE,IAAM,EAAE,cAAW,mBAAgB,GAAsB,EACnD,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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({\n queryKey: ['workspaceMembersInfinite', data.workspaceId],\n });\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: ['workspaceMembersInfinite'] });\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: ['workspaceMembersInfinite'] });\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 = (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<{ cancelInvitation: WorkspaceInvitation }>({\n gateway: 'workspace',\n authToken: authToken || undefined,\n query: print(CancelInvitationDocument),\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!.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: effectiveWorkspaceId || 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,EAA2B;IACxC,WAAW,EAAE,UAAO;IACpB,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,YAAY,MAAS;AAMnB,GALA,EAAY,kBAAkB,EAAE,UAAU,CAAC,oBAAoB,EAAK,YAAY,EAAE,CAAC,EACnF,EAAY,kBAAkB,EAC5B,UAAU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BAAuB,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"}
@@ -13,8 +13,7 @@ var a = (a) => {
13
13
  let e = await i({
14
14
  gateway: "workspace",
15
15
  authToken: o || void 0,
16
- query: r(t),
17
- variables: { email: a }
16
+ query: r(t)
18
17
  });
19
18
  if (e.errors?.length) throw Error(e.errors[0]?.message || "Failed to fetch pending invitations");
20
19
  return e.data?.myPendingInvitations ?? [];
@@ -1 +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"}
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 // `myPendingInvitations` now resolves the caller's email from the\n // authenticated actor (ctx.actorId) server-side — the gateway enforces\n // @rbac(scopeType: \"self\"), so a client-supplied email is neither sent\n // nor honoured. `email` is still used to gate the query on user-load.\n const result = await graphqlFetch<{ myPendingInvitations: WorkspaceInvitation[] }>({\n gateway: 'workspace',\n authToken: authToken || undefined,\n query: print(GetMyPendingInvitationsDocument),\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;GAOX,IAAM,IAAS,MAAM,EAA8D;IACjF,SAAS;IACT,WAAW,KAAa,KAAA;IACxB,OAAO,EAAM,EAAgC;IAC9C,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"}
@@ -0,0 +1,104 @@
1
+ import { useWorkspacesContext as e } from "../providers/WorkspacesProvider.js";
2
+ import { useWorkspacesEventEmitter as t } from "./useWorkspacesEventEmitter.js";
3
+ import { safeTelemetryError as n } from "../utils/telemetryError.js";
4
+ import { useMutation as r, useQueryClient as i } from "@tanstack/react-query";
5
+ import { graphqlFetch as a } from "@burdenoff/fe-libs/shared/graphql";
6
+ //#region src/hooks/useProjectMemberMutations.ts
7
+ var o = "\n mutation AddProjectMember($input: AddProjectMemberInput!) {\n addProjectMember(input: $input) {\n id\n projectId\n userId\n createdAt\n updatedAt\n deletedAt\n }\n }\n", s = "\n mutation RemoveProjectMember($input: RemoveProjectMemberInput!) {\n removeProjectMember(input: $input)\n }\n", c = (s) => {
8
+ let { authToken: c, workspaceId: l } = e(), u = i(), { emit: d } = t(), f = s || l;
9
+ return r({
10
+ mutationFn: async (e) => {
11
+ let t = await a({
12
+ gateway: "workspace",
13
+ authToken: c || void 0,
14
+ query: o,
15
+ variables: { input: e },
16
+ workspaceId: f || void 0,
17
+ workspaceToken: !0
18
+ });
19
+ if (t.errors?.length) throw Error(t.errors[0]?.message || "GraphQL error");
20
+ if (!t.data?.addProjectMember) throw Error("No data returned from addProjectMember mutation");
21
+ return t.data.addProjectMember;
22
+ },
23
+ onSuccess: (e, t) => {
24
+ u.invalidateQueries({ queryKey: [
25
+ "projectMembers",
26
+ f,
27
+ t.projectId
28
+ ] }), u.invalidateQueries({ queryKey: [
29
+ "projectMembersInfinite",
30
+ f,
31
+ t.projectId
32
+ ] }), u.invalidateQueries({ queryKey: [
33
+ "projectMembersCount",
34
+ f,
35
+ t.projectId
36
+ ] }), d("project-member.added", {
37
+ memberId: e.id,
38
+ projectId: t.projectId,
39
+ userId: t.userId,
40
+ workspaceId: f || void 0,
41
+ source: "microfe-workspaces"
42
+ });
43
+ },
44
+ onError: (e, t) => {
45
+ d("project-member.add_failed", {
46
+ projectId: t?.projectId,
47
+ userId: t?.userId,
48
+ workspaceId: f || void 0,
49
+ source: "microfe-workspaces",
50
+ errorMessage: n(e)
51
+ });
52
+ }
53
+ });
54
+ }, l = (o) => {
55
+ let { authToken: c, workspaceId: l } = e(), u = i(), { emit: d } = t(), f = o || l;
56
+ return r({
57
+ mutationFn: async (e) => {
58
+ let t = await a({
59
+ gateway: "workspace",
60
+ authToken: c || void 0,
61
+ query: s,
62
+ variables: { input: e },
63
+ workspaceId: f || void 0,
64
+ workspaceToken: !0
65
+ });
66
+ if (t.errors?.length) throw Error(t.errors[0]?.message || "GraphQL error");
67
+ if (typeof t.data?.removeProjectMember != "boolean") throw Error("No data returned from removeProjectMember mutation");
68
+ return t.data.removeProjectMember;
69
+ },
70
+ onSuccess: (e, t) => {
71
+ u.invalidateQueries({ queryKey: [
72
+ "projectMembers",
73
+ f,
74
+ t.projectId
75
+ ] }), u.invalidateQueries({ queryKey: [
76
+ "projectMembersInfinite",
77
+ f,
78
+ t.projectId
79
+ ] }), u.invalidateQueries({ queryKey: [
80
+ "projectMembersCount",
81
+ f,
82
+ t.projectId
83
+ ] }), d("project-member.removed", {
84
+ projectId: t.projectId,
85
+ userId: t.userId,
86
+ workspaceId: f || void 0,
87
+ source: "microfe-workspaces"
88
+ });
89
+ },
90
+ onError: (e, t) => {
91
+ d("project-member.remove_failed", {
92
+ projectId: t?.projectId,
93
+ userId: t?.userId,
94
+ workspaceId: f || void 0,
95
+ source: "microfe-workspaces",
96
+ errorMessage: n(e)
97
+ });
98
+ }
99
+ });
100
+ };
101
+ //#endregion
102
+ export { c as useAddProjectMember, l as useRemoveProjectMember };
103
+
104
+ //# sourceMappingURL=useProjectMemberMutations.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"useProjectMemberMutations.js","names":[],"sources":["../../src/hooks/useProjectMemberMutations.ts"],"sourcesContent":["import { useMutation, useQueryClient } from '@tanstack/react-query';\nimport { graphqlFetch } from '@burdenoff/fe-libs/shared/graphql';\nimport { useWorkspacesContext } from '../providers/WorkspacesProvider';\nimport type { AddProjectMemberInput, ProjectMember, RemoveProjectMemberInput } from '../types';\nimport { safeTelemetryError } from '../utils/telemetryError';\nimport { useWorkspacesEventEmitter } from './useWorkspacesEventEmitter';\n\nconst ADD_PROJECT_MEMBER_MUTATION = `\n mutation AddProjectMember($input: AddProjectMemberInput!) {\n addProjectMember(input: $input) {\n id\n projectId\n userId\n createdAt\n updatedAt\n deletedAt\n }\n }\n`;\n\nconst REMOVE_PROJECT_MEMBER_MUTATION = `\n mutation RemoveProjectMember($input: RemoveProjectMemberInput!) {\n removeProjectMember(input: $input)\n }\n`;\n\nexport const useAddProjectMember = (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: AddProjectMemberInput): Promise<ProjectMember> => {\n const result = await graphqlFetch<{ addProjectMember: ProjectMember }>({\n gateway: 'workspace',\n authToken: authToken || undefined,\n query: ADD_PROJECT_MEMBER_MUTATION,\n variables: { input },\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?.addProjectMember) {\n throw new Error('No data returned from addProjectMember mutation');\n }\n\n return result.data.addProjectMember;\n },\n onSuccess: (data, input) => {\n queryClient.invalidateQueries({\n queryKey: ['projectMembers', effectiveWorkspaceId, input.projectId],\n });\n queryClient.invalidateQueries({\n queryKey: ['projectMembersInfinite', effectiveWorkspaceId, input.projectId],\n });\n queryClient.invalidateQueries({\n queryKey: ['projectMembersCount', effectiveWorkspaceId, input.projectId],\n });\n emit('project-member.added', {\n memberId: data.id,\n projectId: input.projectId,\n userId: input.userId,\n workspaceId: effectiveWorkspaceId || undefined,\n source: 'microfe-workspaces',\n });\n },\n onError: (err, input) => {\n emit('project-member.add_failed', {\n projectId: input?.projectId,\n userId: input?.userId,\n workspaceId: effectiveWorkspaceId || undefined,\n source: 'microfe-workspaces',\n errorMessage: safeTelemetryError(err),\n });\n },\n });\n};\n\nexport const useRemoveProjectMember = (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: RemoveProjectMemberInput): Promise<boolean> => {\n const result = await graphqlFetch<{ removeProjectMember: boolean }>({\n gateway: 'workspace',\n authToken: authToken || undefined,\n query: REMOVE_PROJECT_MEMBER_MUTATION,\n variables: { input },\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 (typeof result.data?.removeProjectMember !== 'boolean') {\n throw new Error('No data returned from removeProjectMember mutation');\n }\n\n return result.data.removeProjectMember;\n },\n onSuccess: (_, input) => {\n queryClient.invalidateQueries({\n queryKey: ['projectMembers', effectiveWorkspaceId, input.projectId],\n });\n queryClient.invalidateQueries({\n queryKey: ['projectMembersInfinite', effectiveWorkspaceId, input.projectId],\n });\n queryClient.invalidateQueries({\n queryKey: ['projectMembersCount', effectiveWorkspaceId, input.projectId],\n });\n emit('project-member.removed', {\n projectId: input.projectId,\n userId: input.userId,\n workspaceId: effectiveWorkspaceId || undefined,\n source: 'microfe-workspaces',\n });\n },\n onError: (err, input) => {\n emit('project-member.remove_failed', {\n projectId: input?.projectId,\n userId: input?.userId,\n workspaceId: effectiveWorkspaceId || undefined,\n source: 'microfe-workspaces',\n errorMessage: safeTelemetryError(err),\n });\n },\n });\n};\n"],"mappings":";;;;;;AAOA,IAAM,IAA8B,oNAa9B,IAAiC,wHAM1B,KAAuB,MAAiC;CACnE,IAAM,EAAE,cAAW,mBAAgB,GAAsB,EACnD,IAAc,GAAgB,EAC9B,EAAE,YAAS,GAA2B,EACtC,IAAuB,KAAuB;AAEpD,QAAO,EAAY;EACjB,YAAY,OAAO,MAAyD;GAC1E,IAAM,IAAS,MAAM,EAAkD;IACrE,SAAS;IACT,WAAW,KAAa,KAAA;IACxB,OAAO;IACP,WAAW,EAAE,UAAO;IACpB,aAAa,KAAwB,KAAA;IACrC,gBAA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,YAAY,GAAG,MAAU;AAUvB,GATA,EAAY,kBAAkB,EAC5B,UAAU;IAAC;IAAkB;IAAsB,EAAM;IAAU,EACpE,CAAC,EACF,EAAY,kBAAkB,EAC5B,UAAU;IAAC;IAA0B;IAAsB,EAAM;IAAU,EAC5E,CAAC,EACF,EAAY,kBAAkB,EAC5B,UAAU;IAAC;IAAuB;IAAsB,EAAM;IAAU,EACzE,CAAC,EACF,EAAK,0BAA0B;IAC7B,WAAW,EAAM;IACjB,QAAQ,EAAM;IACd,aAAa,KAAwB,KAAA;IACrC,QAAQ;IACT,CAAC;;EAEJ,UAAU,GAAK,MAAU;AACvB,KAAK,gCAAgC;IACnC,WAAW,GAAO;IAClB,QAAQ,GAAO;IACf,aAAa,KAAwB,KAAA;IACrC,QAAQ;IACR,cAAc,EAAmB,EAAI;IACtC,CAAC;;EAEL,CAAC"}
@@ -0,0 +1,42 @@
1
+ import { useWorkspacesContext as e } from "../providers/WorkspacesProvider.js";
2
+ import { useInfiniteQuery as t } from "@tanstack/react-query";
3
+ import { graphqlFetch as n } from "@burdenoff/fe-libs/shared/graphql";
4
+ //#region src/hooks/useProjectMembers.ts
5
+ var r = "\n query GetProjectMembers($projectId: ID!, $pagination: PaginationInput) {\n projectMembers(filter: { projectId: $projectId }, pagination: $pagination) {\n items {\n id\n projectId\n userId\n createdAt\n updatedAt\n deletedAt\n }\n total\n hasMore\n }\n }\n", i = (i, a, o = 100, s = !0) => {
6
+ let { authToken: c, workspaceId: l } = e(), u = a || l;
7
+ return t({
8
+ queryKey: [
9
+ "projectMembersInfinite",
10
+ u,
11
+ i,
12
+ o
13
+ ],
14
+ initialPageParam: 0,
15
+ queryFn: async ({ pageParam: e }) => {
16
+ let t = await n({
17
+ gateway: "workspace",
18
+ authToken: c || void 0,
19
+ query: r,
20
+ variables: {
21
+ projectId: i,
22
+ pagination: {
23
+ limit: o,
24
+ offset: e
25
+ }
26
+ },
27
+ workspaceId: u || void 0,
28
+ workspaceToken: !0
29
+ });
30
+ if (t.errors?.length) throw Error(t.errors[0]?.message || "GraphQL error");
31
+ if (!t.data?.projectMembers) throw Error("Project members query returned no data");
32
+ return t.data.projectMembers;
33
+ },
34
+ getNextPageParam: (e, t, n) => e.hasMore ? Number(n) + o : void 0,
35
+ enabled: s && !!i && !!u,
36
+ staleTime: 60 * 1e3
37
+ });
38
+ };
39
+ //#endregion
40
+ export { i as useInfiniteProjectMembers };
41
+
42
+ //# sourceMappingURL=useProjectMembers.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"useProjectMembers.js","names":[],"sources":["../../src/hooks/useProjectMembers.ts"],"sourcesContent":["import { useInfiniteQuery, useQuery } from '@tanstack/react-query';\nimport { graphqlFetch } from '@burdenoff/fe-libs/shared/graphql';\nimport { useWorkspacesContext } from '../providers/WorkspacesProvider';\nimport type { PaginationInput, ProjectMember, ProjectMemberList } from '../types';\n\nconst GET_PROJECT_MEMBERS_QUERY = `\n query GetProjectMembers($projectId: ID!, $pagination: PaginationInput) {\n projectMembers(filter: { projectId: $projectId }, pagination: $pagination) {\n items {\n id\n projectId\n userId\n createdAt\n updatedAt\n deletedAt\n }\n total\n hasMore\n }\n }\n`;\n\nconst GET_PROJECT_MEMBER_QUERY = `\n query GetProjectMember($id: ID!) {\n projectMember(id: $id) {\n id\n projectId\n userId\n createdAt\n updatedAt\n deletedAt\n }\n }\n`;\n\nexport const useProjectMembers = (\n projectId: string,\n workspaceIdOverride?: string,\n pagination?: PaginationInput,\n enabled = true\n) => {\n const { authToken, workspaceId } = useWorkspacesContext();\n const effectiveWorkspaceId = workspaceIdOverride || workspaceId;\n\n return useQuery({\n queryKey: ['projectMembers', effectiveWorkspaceId, projectId, pagination],\n queryFn: async (): Promise<ProjectMemberList> => {\n const result = await graphqlFetch<{ projectMembers: ProjectMemberList }>({\n gateway: 'workspace',\n authToken: authToken || undefined,\n query: GET_PROJECT_MEMBERS_QUERY,\n variables: { projectId, pagination },\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?.projectMembers) {\n throw new Error('Project members query returned no data');\n }\n\n return result.data.projectMembers;\n },\n enabled: enabled && !!projectId && !!effectiveWorkspaceId,\n staleTime: 60 * 1000,\n });\n};\n\nexport const useInfiniteProjectMembers = (\n projectId: string,\n workspaceIdOverride?: string,\n pageSize = 100,\n enabled = true\n) => {\n const { authToken, workspaceId } = useWorkspacesContext();\n const effectiveWorkspaceId = workspaceIdOverride || workspaceId;\n\n return useInfiniteQuery({\n queryKey: ['projectMembersInfinite', effectiveWorkspaceId, projectId, pageSize],\n initialPageParam: 0,\n queryFn: async ({ pageParam }): Promise<ProjectMemberList> => {\n const result = await graphqlFetch<{ projectMembers: ProjectMemberList }>({\n gateway: 'workspace',\n authToken: authToken || undefined,\n query: GET_PROJECT_MEMBERS_QUERY,\n variables: {\n projectId,\n pagination: {\n limit: pageSize,\n offset: pageParam,\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?.projectMembers) {\n throw new Error('Project members query returned no data');\n }\n\n return result.data.projectMembers;\n },\n getNextPageParam: (lastPage, _pages, lastPageParam) =>\n lastPage.hasMore ? Number(lastPageParam) + pageSize : undefined,\n enabled: enabled && !!projectId && !!effectiveWorkspaceId,\n staleTime: 60 * 1000,\n });\n};\n\nexport const useProjectMember = (id: string, workspaceIdOverride?: string) => {\n const { authToken, workspaceId } = useWorkspacesContext();\n const effectiveWorkspaceId = workspaceIdOverride || workspaceId;\n\n return useQuery({\n queryKey: ['projectMember', effectiveWorkspaceId, id],\n queryFn: async (): Promise<ProjectMember> => {\n const result = await graphqlFetch<{ projectMember: ProjectMember }>({\n gateway: 'workspace',\n authToken: authToken || undefined,\n query: GET_PROJECT_MEMBER_QUERY,\n variables: { id },\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?.projectMember) {\n throw new Error('Project member query returned no data');\n }\n\n return result.data.projectMember;\n },\n enabled: !!id && !!effectiveWorkspaceId,\n staleTime: 60 * 1000,\n });\n};\n"],"mappings":";;;;AAKA,IAAM,IAA4B,4UAkErB,KACX,GACA,GACA,IAAW,KACX,IAAU,OACP;CACH,IAAM,EAAE,cAAW,mBAAgB,GAAsB,EACnD,IAAuB,KAAuB;AAEpD,QAAO,EAAiB;EACtB,UAAU;GAAC;GAA0B;GAAsB;GAAW;GAAS;EAC/E,kBAAkB;EAClB,SAAS,OAAO,EAAE,mBAA4C;GAC5D,IAAM,IAAS,MAAM,EAAoD;IACvE,SAAS;IACT,WAAW,KAAa,KAAA;IACxB,OAAO;IACP,WAAW;KACT;KACA,YAAY;MACV,OAAO;MACP,QAAQ;MACT;KACF;IACD,aAAa,KAAwB,KAAA;IACrC,gBAAgB;IACjB,CAAC;AAEF,OAAI,EAAO,QAAQ,OACjB,OAAU,MAAM,EAAO,OAAO,IAAI,WAAW,gBAAgB;AAG/D,OAAI,CAAC,EAAO,MAAM,eAChB,OAAU,MAAM,yCAAyC;AAG3D,UAAO,EAAO,KAAK;;EAErB,mBAAmB,GAAU,GAAQ,MACnC,EAAS,UAAU,OAAO,EAAc,GAAG,IAAW,KAAA;EACxD,SAAS,KAAW,CAAC,CAAC,KAAa,CAAC,CAAC;EACrC,WAAW,KAAK;EACjB,CAAC"}
@@ -1,22 +1,22 @@
1
1
  import { useWorkspacesContext as e } from "../providers/WorkspacesProvider.js";
2
2
  import { GetInvitationDocument as t, GetUserWorkspacesDocument as n, GetWorkspaceInvitationsDocument as r, GetWorkspaceMemberDocument as i, GetWorkspaceMembersDocument as a } from "../generated/wspace-operations.js";
3
- import { useQuery as o } from "@tanstack/react-query";
4
- import { print as s } from "graphql";
5
- import { graphqlFetch as c } from "@burdenoff/fe-libs/shared/graphql";
3
+ import { useInfiniteQuery as o, useQuery as s } from "@tanstack/react-query";
4
+ import { print as c } from "graphql";
5
+ import { graphqlFetch as l } from "@burdenoff/fe-libs/shared/graphql";
6
6
  //#region src/hooks/useWorkspaceMembers.ts
7
- var l = (t, n) => {
7
+ var u = (t, n) => {
8
8
  let { authToken: r } = e();
9
- return o({
9
+ return s({
10
10
  queryKey: [
11
11
  "workspaceMembers",
12
12
  t,
13
13
  n
14
14
  ],
15
15
  queryFn: async () => {
16
- let e = await c({
16
+ let e = await l({
17
17
  gateway: "workspace",
18
18
  authToken: r || void 0,
19
- query: s(a),
19
+ query: c(a),
20
20
  variables: {
21
21
  workspaceId: t,
22
22
  pagination: n
@@ -25,47 +25,81 @@ var l = (t, n) => {
25
25
  workspaceToken: !0
26
26
  });
27
27
  if (e.errors?.length) throw Error(e.errors[0]?.message || "GraphQL error");
28
+ if (!e.data?.workspaceMembers) throw Error("Workspace members query returned no data");
28
29
  return e.data.workspaceMembers;
29
30
  },
30
31
  enabled: !!t,
31
32
  staleTime: 300 * 1e3
32
33
  });
33
- }, u = (t) => {
34
- let { authToken: n, workspaceId: r } = e();
34
+ }, d = (t, n = 100, r = !0) => {
35
+ let { authToken: i } = e();
35
36
  return o({
37
+ queryKey: [
38
+ "workspaceMembersInfinite",
39
+ t,
40
+ n
41
+ ],
42
+ initialPageParam: 0,
43
+ queryFn: async ({ pageParam: e }) => {
44
+ let r = await l({
45
+ gateway: "workspace",
46
+ authToken: i || void 0,
47
+ query: c(a),
48
+ variables: {
49
+ workspaceId: t,
50
+ pagination: {
51
+ limit: n,
52
+ offset: e
53
+ }
54
+ },
55
+ workspaceId: t,
56
+ workspaceToken: !0
57
+ });
58
+ if (r.errors?.length) throw Error(r.errors[0]?.message || "GraphQL error");
59
+ if (!r.data?.workspaceMembers) throw Error("Workspace members query returned no data");
60
+ return r.data.workspaceMembers;
61
+ },
62
+ getNextPageParam: (e, t, r) => e.hasMore ? Number(r) + n : void 0,
63
+ enabled: r && !!t,
64
+ staleTime: 300 * 1e3
65
+ });
66
+ }, f = (t) => {
67
+ let { authToken: n, workspaceId: r } = e();
68
+ return s({
36
69
  queryKey: [
37
70
  "workspaceMember",
38
71
  r,
39
72
  t
40
73
  ],
41
74
  queryFn: async () => {
42
- let e = await c({
75
+ let e = await l({
43
76
  gateway: "workspace",
44
77
  authToken: n || void 0,
45
- query: s(i),
78
+ query: c(i),
46
79
  variables: { id: t },
47
80
  workspaceId: r || void 0,
48
81
  workspaceToken: !0
49
82
  });
50
83
  if (e.errors?.length) throw Error(e.errors[0]?.message || "GraphQL error");
84
+ if (!e.data?.workspaceMember) throw Error("Workspace member query returned no data");
51
85
  return e.data.workspaceMember;
52
86
  },
53
87
  enabled: !!t,
54
88
  staleTime: 300 * 1e3
55
89
  });
56
- }, d = (t, r) => {
90
+ }, p = (t, r) => {
57
91
  let { authToken: i, workspaceId: a } = e();
58
- return o({
92
+ return s({
59
93
  queryKey: [
60
94
  "userWorkspaces",
61
95
  t,
62
96
  r
63
97
  ],
64
98
  queryFn: async () => {
65
- let e = await c({
99
+ let e = await l({
66
100
  gateway: "workspace",
67
101
  authToken: i || void 0,
68
- query: s(n),
102
+ query: c(n),
69
103
  variables: {
70
104
  userId: t,
71
105
  pagination: r
@@ -74,14 +108,15 @@ var l = (t, n) => {
74
108
  workspaceToken: !0
75
109
  });
76
110
  if (e.errors?.length) throw Error(e.errors[0]?.message || "GraphQL error");
111
+ if (!e.data?.userWorkspaces) throw Error("User workspaces query returned no data");
77
112
  return e.data.userWorkspaces;
78
113
  },
79
114
  enabled: !!t,
80
115
  staleTime: 300 * 1e3
81
116
  });
82
- }, f = (t, n, i) => {
117
+ }, m = (t, n, i) => {
83
118
  let { authToken: a } = e();
84
- return o({
119
+ return s({
85
120
  queryKey: [
86
121
  "workspaceInvitations",
87
122
  t,
@@ -89,10 +124,10 @@ var l = (t, n) => {
89
124
  i
90
125
  ],
91
126
  queryFn: async () => {
92
- let e = await c({
127
+ let e = await l({
93
128
  gateway: "workspace",
94
129
  authToken: a || void 0,
95
- query: s(r),
130
+ query: c(r),
96
131
  variables: {
97
132
  status: n,
98
133
  pagination: i
@@ -101,20 +136,21 @@ var l = (t, n) => {
101
136
  workspaceToken: !0
102
137
  });
103
138
  if (e.errors?.length) throw Error(e.errors[0]?.message || "GraphQL error");
139
+ if (!e.data?.workspaceInvitations) throw Error("Workspace invitations query returned no data");
104
140
  return e.data.workspaceInvitations;
105
141
  },
106
142
  enabled: !!t,
107
143
  staleTime: 300 * 1e3
108
144
  });
109
- }, p = (n, r = !0) => {
145
+ }, h = (n, r = !0) => {
110
146
  let { authToken: i } = e();
111
- return o({
147
+ return s({
112
148
  queryKey: ["invitation", n],
113
149
  queryFn: async () => {
114
- let e = await c({
150
+ let e = await l({
115
151
  gateway: "workspace",
116
152
  authToken: i || void 0,
117
- query: s(t),
153
+ query: c(t),
118
154
  variables: { id: n }
119
155
  });
120
156
  if (e.errors?.length) throw Error(e.errors[0]?.message || "Failed to fetch invitation");
@@ -127,6 +163,6 @@ var l = (t, n) => {
127
163
  });
128
164
  };
129
165
  //#endregion
130
- export { p as useInvitation, d as useUserWorkspaces, f as useWorkspaceInvitations, u as useWorkspaceMember, l as useWorkspaceMembers };
166
+ export { d as useInfiniteWorkspaceMembers, h as useInvitation, p as useUserWorkspaces, m as useWorkspaceInvitations, f as useWorkspaceMember, u as useWorkspaceMembers };
131
167
 
132
168
  //# sourceMappingURL=useWorkspaceMembers.js.map
@@ -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 } = 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":";;;;;;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F,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;GAOS,KACX,GACA,GACA,MACG;CACH,IAAM,EAAE,iBAAc,GAAsB;AAE5C,QAAO,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"}
1
+ {"version":3,"file":"useWorkspaceMembers.js","names":[],"sources":["../../src/hooks/useWorkspaceMembers.ts"],"sourcesContent":["import { useInfiniteQuery, 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 if (!result.data?.workspaceMembers) {\n throw new Error('Workspace members query returned no data');\n }\n\n return result.data.workspaceMembers;\n },\n enabled: !!workspaceId,\n staleTime: 5 * 60 * 1000,\n });\n};\n\nexport const useInfiniteWorkspaceMembers = (\n workspaceId: string,\n pageSize = 100,\n enabled = true\n) => {\n const { authToken } = useWorkspacesContext();\n\n return useInfiniteQuery({\n queryKey: ['workspaceMembersInfinite', workspaceId, pageSize],\n initialPageParam: 0,\n queryFn: async ({ pageParam }): Promise<MemberList> => {\n const result = await graphqlFetch<{ workspaceMembers: MemberList }>({\n gateway: 'workspace',\n authToken: authToken || undefined,\n query: print(GetWorkspaceMembersDocument),\n variables: {\n workspaceId,\n pagination: {\n limit: pageSize,\n offset: pageParam,\n },\n },\n workspaceId,\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?.workspaceMembers) {\n throw new Error('Workspace members query returned no data');\n }\n\n return result.data.workspaceMembers;\n },\n getNextPageParam: (lastPage, _pages, lastPageParam) =>\n lastPage.hasMore ? Number(lastPageParam) + pageSize : undefined,\n enabled: 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 if (!result.data?.workspaceMember) {\n throw new Error('Workspace member query returned no data');\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 if (!result.data?.userWorkspaces) {\n throw new Error('User workspaces query returned no data');\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 if (!result.data?.workspaceInvitations) {\n throw new Error('Workspace invitations query returned no data');\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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B,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"}
@@ -22,6 +22,10 @@ function n() {
22
22
  canUpdateProject: n(e.PROJECT_UPDATE),
23
23
  canDeleteProject: n(e.PROJECT_DELETE),
24
24
  canArchiveProject: n(e.PROJECT_ARCHIVE),
25
+ canListProjectMembers: n(e.PROJECT_MEMBER_LIST),
26
+ canViewProjectMember: n(e.PROJECT_MEMBER_READ),
27
+ canAddProjectMember: n(e.PROJECT_MEMBER_CREATE),
28
+ canRemoveProjectMember: n(e.PROJECT_MEMBER_DELETE),
25
29
  canViewSettings: n(e.SETTINGS_READ),
26
30
  canUpdateSettings: n(e.SETTINGS_WRITE),
27
31
  canViewActivity: n(e.ACTIVITY_READ)
@@ -1 +1 @@
1
- {"version":3,"file":"useWorkspacePermissions.js","names":[],"sources":["../../src/hooks/useWorkspacePermissions.ts"],"sourcesContent":["/**\n * Workspace MFE - Permission Hook\n *\n * Wraps usePermissions() with typed permission flags for all workspace resources.\n */\n\nimport { usePermissions } from '@burdenoff/fe-libs/shared/providers/shell';\nimport { WORKSPACE_PERMISSIONS } from '../constants/permissions';\n\nexport function useWorkspacePermissions() {\n const { hasPermission, isLoading } = usePermissions();\n\n return {\n isLoading,\n\n // Workspace\n canListWorkspaces: hasPermission(WORKSPACE_PERMISSIONS.WORKSPACE_LIST),\n canViewWorkspace: hasPermission(WORKSPACE_PERMISSIONS.WORKSPACE_READ),\n canCreateWorkspace: hasPermission(WORKSPACE_PERMISSIONS.WORKSPACE_CREATE),\n canUpdateWorkspace: hasPermission(WORKSPACE_PERMISSIONS.WORKSPACE_UPDATE),\n canDeleteWorkspace: hasPermission(WORKSPACE_PERMISSIONS.WORKSPACE_DELETE),\n canArchiveWorkspace: hasPermission(WORKSPACE_PERMISSIONS.WORKSPACE_ARCHIVE),\n\n // Members\n canListMembers: hasPermission(WORKSPACE_PERMISSIONS.MEMBER_LIST),\n canViewMember: hasPermission(WORKSPACE_PERMISSIONS.MEMBER_READ),\n canInviteMember: hasPermission(WORKSPACE_PERMISSIONS.MEMBER_CREATE),\n canUpdateMember: hasPermission(WORKSPACE_PERMISSIONS.MEMBER_UPDATE),\n canRemoveMember: hasPermission(WORKSPACE_PERMISSIONS.MEMBER_DELETE),\n\n // Projects\n canListProjects: hasPermission(WORKSPACE_PERMISSIONS.PROJECT_LIST),\n canViewProject: hasPermission(WORKSPACE_PERMISSIONS.PROJECT_READ),\n canCreateProject: hasPermission(WORKSPACE_PERMISSIONS.PROJECT_CREATE),\n canUpdateProject: hasPermission(WORKSPACE_PERMISSIONS.PROJECT_UPDATE),\n canDeleteProject: hasPermission(WORKSPACE_PERMISSIONS.PROJECT_DELETE),\n canArchiveProject: hasPermission(WORKSPACE_PERMISSIONS.PROJECT_ARCHIVE),\n\n // Settings\n canViewSettings: hasPermission(WORKSPACE_PERMISSIONS.SETTINGS_READ),\n canUpdateSettings: hasPermission(WORKSPACE_PERMISSIONS.SETTINGS_WRITE),\n\n // Activity\n canViewActivity: hasPermission(WORKSPACE_PERMISSIONS.ACTIVITY_READ),\n };\n}\n"],"mappings":";;;AASA,SAAgB,IAA0B;CACxC,IAAM,EAAE,kBAAe,iBAAc,GAAgB;AAErD,QAAO;EACL;EAGA,mBAAmB,EAAc,EAAsB,eAAe;EACtE,kBAAkB,EAAc,EAAsB,eAAe;EACrE,oBAAoB,EAAc,EAAsB,iBAAiB;EACzE,oBAAoB,EAAc,EAAsB,iBAAiB;EACzE,oBAAoB,EAAc,EAAsB,iBAAiB;EACzE,qBAAqB,EAAc,EAAsB,kBAAkB;EAG3E,gBAAgB,EAAc,EAAsB,YAAY;EAChE,eAAe,EAAc,EAAsB,YAAY;EAC/D,iBAAiB,EAAc,EAAsB,cAAc;EACnE,iBAAiB,EAAc,EAAsB,cAAc;EACnE,iBAAiB,EAAc,EAAsB,cAAc;EAGnE,iBAAiB,EAAc,EAAsB,aAAa;EAClE,gBAAgB,EAAc,EAAsB,aAAa;EACjE,kBAAkB,EAAc,EAAsB,eAAe;EACrE,kBAAkB,EAAc,EAAsB,eAAe;EACrE,kBAAkB,EAAc,EAAsB,eAAe;EACrE,mBAAmB,EAAc,EAAsB,gBAAgB;EAGvE,iBAAiB,EAAc,EAAsB,cAAc;EACnE,mBAAmB,EAAc,EAAsB,eAAe;EAGtE,iBAAiB,EAAc,EAAsB,cAAc;EACpE"}
1
+ {"version":3,"file":"useWorkspacePermissions.js","names":[],"sources":["../../src/hooks/useWorkspacePermissions.ts"],"sourcesContent":["/**\n * Workspace MFE - Permission Hook\n *\n * Wraps usePermissions() with typed permission flags for all workspace resources.\n */\n\nimport { usePermissions } from '@burdenoff/fe-libs/shared/providers/shell';\nimport { WORKSPACE_PERMISSIONS } from '../constants/permissions';\n\nexport function useWorkspacePermissions() {\n const { hasPermission, isLoading } = usePermissions();\n\n return {\n isLoading,\n\n // Workspace\n canListWorkspaces: hasPermission(WORKSPACE_PERMISSIONS.WORKSPACE_LIST),\n canViewWorkspace: hasPermission(WORKSPACE_PERMISSIONS.WORKSPACE_READ),\n canCreateWorkspace: hasPermission(WORKSPACE_PERMISSIONS.WORKSPACE_CREATE),\n canUpdateWorkspace: hasPermission(WORKSPACE_PERMISSIONS.WORKSPACE_UPDATE),\n canDeleteWorkspace: hasPermission(WORKSPACE_PERMISSIONS.WORKSPACE_DELETE),\n canArchiveWorkspace: hasPermission(WORKSPACE_PERMISSIONS.WORKSPACE_ARCHIVE),\n\n // Members\n canListMembers: hasPermission(WORKSPACE_PERMISSIONS.MEMBER_LIST),\n canViewMember: hasPermission(WORKSPACE_PERMISSIONS.MEMBER_READ),\n canInviteMember: hasPermission(WORKSPACE_PERMISSIONS.MEMBER_CREATE),\n canUpdateMember: hasPermission(WORKSPACE_PERMISSIONS.MEMBER_UPDATE),\n canRemoveMember: hasPermission(WORKSPACE_PERMISSIONS.MEMBER_DELETE),\n\n // Projects\n canListProjects: hasPermission(WORKSPACE_PERMISSIONS.PROJECT_LIST),\n canViewProject: hasPermission(WORKSPACE_PERMISSIONS.PROJECT_READ),\n canCreateProject: hasPermission(WORKSPACE_PERMISSIONS.PROJECT_CREATE),\n canUpdateProject: hasPermission(WORKSPACE_PERMISSIONS.PROJECT_UPDATE),\n canDeleteProject: hasPermission(WORKSPACE_PERMISSIONS.PROJECT_DELETE),\n canArchiveProject: hasPermission(WORKSPACE_PERMISSIONS.PROJECT_ARCHIVE),\n\n // Project members\n canListProjectMembers: hasPermission(WORKSPACE_PERMISSIONS.PROJECT_MEMBER_LIST),\n canViewProjectMember: hasPermission(WORKSPACE_PERMISSIONS.PROJECT_MEMBER_READ),\n canAddProjectMember: hasPermission(WORKSPACE_PERMISSIONS.PROJECT_MEMBER_CREATE),\n canRemoveProjectMember: hasPermission(WORKSPACE_PERMISSIONS.PROJECT_MEMBER_DELETE),\n\n // Settings\n canViewSettings: hasPermission(WORKSPACE_PERMISSIONS.SETTINGS_READ),\n canUpdateSettings: hasPermission(WORKSPACE_PERMISSIONS.SETTINGS_WRITE),\n\n // Activity\n canViewActivity: hasPermission(WORKSPACE_PERMISSIONS.ACTIVITY_READ),\n };\n}\n"],"mappings":";;;AASA,SAAgB,IAA0B;CACxC,IAAM,EAAE,kBAAe,iBAAc,GAAgB;AAErD,QAAO;EACL;EAGA,mBAAmB,EAAc,EAAsB,eAAe;EACtE,kBAAkB,EAAc,EAAsB,eAAe;EACrE,oBAAoB,EAAc,EAAsB,iBAAiB;EACzE,oBAAoB,EAAc,EAAsB,iBAAiB;EACzE,oBAAoB,EAAc,EAAsB,iBAAiB;EACzE,qBAAqB,EAAc,EAAsB,kBAAkB;EAG3E,gBAAgB,EAAc,EAAsB,YAAY;EAChE,eAAe,EAAc,EAAsB,YAAY;EAC/D,iBAAiB,EAAc,EAAsB,cAAc;EACnE,iBAAiB,EAAc,EAAsB,cAAc;EACnE,iBAAiB,EAAc,EAAsB,cAAc;EAGnE,iBAAiB,EAAc,EAAsB,aAAa;EAClE,gBAAgB,EAAc,EAAsB,aAAa;EACjE,kBAAkB,EAAc,EAAsB,eAAe;EACrE,kBAAkB,EAAc,EAAsB,eAAe;EACrE,kBAAkB,EAAc,EAAsB,eAAe;EACrE,mBAAmB,EAAc,EAAsB,gBAAgB;EAGvE,uBAAuB,EAAc,EAAsB,oBAAoB;EAC/E,sBAAsB,EAAc,EAAsB,oBAAoB;EAC9E,qBAAqB,EAAc,EAAsB,sBAAsB;EAC/E,wBAAwB,EAAc,EAAsB,sBAAsB;EAGlF,iBAAiB,EAAc,EAAsB,cAAc;EACnE,mBAAmB,EAAc,EAAsB,eAAe;EAGtE,iBAAiB,EAAc,EAAsB,cAAc;EACpE"}