From 3224934904fc0ade71faa8bb07ab0ebe7fbce97f Mon Sep 17 00:00:00 2001 From: jrmartin Date: Mon, 24 Mar 2025 09:06:25 +0100 Subject: [PATCH 01/11] #91 - Update endpoint to use organizations from backend --- src/api/endpoints/index.ts | 8 +- src/api/endpoints/interLexURIStructureAPI.ts | 1572 +++++++++++++++-- .../SingleOrganization/CreateForkDialog.jsx | 2 +- src/components/organizations/index.jsx | 2 +- 4 files changed, 1385 insertions(+), 199 deletions(-) diff --git a/src/api/endpoints/index.ts b/src/api/endpoints/index.ts index 1155e7f3..e3e0d0a7 100644 --- a/src/api/endpoints/index.ts +++ b/src/api/endpoints/index.ts @@ -13,14 +13,14 @@ const useApi = () => api; const BASE_GROUP = "base"; const BASE_EXTENSION = "jsonld"; -export const getOrganizations = async () => { +export const getOrganizations = async (group) => { /** Call endpoint for retrieving organizations, this is a mock endpoint created by us */ - const { getOrganizations } = useMockApi(); + const { getPrivRoleOtherGroup } = useApi(); /** Call Endpoint */ - return await getOrganizations().then((data) => { - return data as Organizations; + return await getPrivRoleOtherGroup(group).then((data) => { + return data; }) .catch((error) => { return error; diff --git a/src/api/endpoints/interLexURIStructureAPI.ts b/src/api/endpoints/interLexURIStructureAPI.ts index 2b79b428..1ff240c8 100644 --- a/src/api/endpoints/interLexURIStructureAPI.ts +++ b/src/api/endpoints/interLexURIStructureAPI.ts @@ -1058,6 +1058,195 @@ export const useGetEndpointsGroup = , signal?: AbortSignal +) => { + return customInstance( + { + url: `https://uri.olympiangods.org/${group}/contributions`, + method: 'GET', + signal + }, + options + ); +} + +export const getGetEndpointsContributionsQueryKeyExtension = (group: string,) => { + return [`https://uri.olympiangods.org/${group}/contributions`] as const; +} + +export const getGetEndpointsContributionsQueryOptionsExtension = < + TData = Awaited>, + TError = ErrorType +>( + group: string, + options?: { + query?: Partial>, TError, TData>>, + request?: SecondParameter + } +) => { + const { query: queryOptions, request: requestOptions } = options ?? {}; + + const queryKey = queryOptions?.queryKey ?? getGetEndpointsContributionsQueryKeyExtension(group); + + const queryFn: QueryFunction>> = ({ signal }) => + getEndpointsContributionsExtension(group, requestOptions, signal); + + return { + queryKey, + queryFn, + enabled: !!group, + ...queryOptions + } as UseQueryOptions>, TError, TData> & { queryKey: QueryKey }; +} + +export type GetEndpointsContributionsQueryResultExtension = NonNullable>> +export type GetEndpointsContributionsQueryErrorExtension = ErrorType + +export const useGetEndpointsContributionsExtension = < + TData = Awaited>, + TError = ErrorType +>( + group: string, + options?: { + query?: Partial>, TError, TData>>, + request?: SecondParameter + } +): UseQueryResult & { queryKey: QueryKey } => { + const queryOptions = getGetEndpointsContributionsQueryOptionsExtension(group, options); + const query = useQuery(queryOptions) as UseQueryResult & { queryKey: QueryKey }; + query.queryKey = queryOptions.queryKey; + return query; +} + +// Second version with `/contributions/interlex` +export const getEndpointsContributionsExtensionInterlex = ( + group: string, + options?: SecondParameter, signal?: AbortSignal +) => { + return customInstance( + { + url: `https://uri.olympiangods.org/${group}/contributions/interlex`, + method: 'GET', + signal + }, + options + ); +} + +export const getGetEndpointsContributionsQueryKeyExtensionInterlex = (group: string,) => { + return [`https://uri.olympiangods.org/${group}/contributions/interlex`] as const; +} + +export const getGetEndpointsContributionsQueryOptionsExtensionInterlex = < + TData = Awaited>, + TError = ErrorType +>( + group: string, + options?: { + query?: Partial>, TError, TData>>, + request?: SecondParameter + } +) => { + const { query: queryOptions, request: requestOptions } = options ?? {}; + + const queryKey = queryOptions?.queryKey ?? getGetEndpointsContributionsQueryKeyExtensionInterlex(group); + + const queryFn: QueryFunction>> = ({ signal }) => + getEndpointsContributionsExtensionInterlex(group, requestOptions, signal); + + return { + queryKey, + queryFn, + enabled: !!group, + ...queryOptions + } as UseQueryOptions>, TError, TData> & { queryKey: QueryKey }; +} + +export type GetEndpointsContributionsQueryResultExtensionInterlex = NonNullable>> +export type GetEndpointsContributionsQueryErrorExtensionInterlex = ErrorType + +export const useGetEndpointsContributionsExtensionInterlex = < + TData = Awaited>, + TError = ErrorType +>( + group: string, + options?: { + query?: Partial>, TError, TData>>, + request?: SecondParameter + } +): UseQueryResult & { queryKey: QueryKey } => { + const queryOptions = getGetEndpointsContributionsQueryOptionsExtensionInterlex(group, options); + const query = useQuery(queryOptions) as UseQueryResult & { queryKey: QueryKey }; + query.queryKey = queryOptions.queryKey; + return query; +} + +// --------------------------------------- + +export const getEndpointsCuriesExtension = ( + group: string, + options?: SecondParameter, signal?: AbortSignal +) => { + return customInstance( + { + url: `https://uri.olympiangods.org/${group}/curies`, + method: 'GET', + signal + }, + options + ); +} + +export const getGetEndpointsCuriesQueryKeyExtension = (group: string,) => { + return [`https://uri.olympiangods.org/${group}/curies`] as const; +} + +export const getGetEndpointsCuriesQueryOptionsExtension = < + TData = Awaited>, + TError = ErrorType +>( + group: string, + options?: { + query?: Partial>, TError, TData>>, + request?: SecondParameter + } +) => { + const { query: queryOptions, request: requestOptions } = options ?? {}; + + const queryKey = queryOptions?.queryKey ?? getGetEndpointsCuriesQueryKeyExtension(group); + + const queryFn: QueryFunction>> = ({ signal }) => + getEndpointsCuriesExtension(group, requestOptions, signal); + + return { + queryKey, + queryFn, + enabled: !!group, + ...queryOptions + } as UseQueryOptions>, TError, TData> & { queryKey: QueryKey }; +} + +export type GetEndpointsCuriesQueryResultExtension = NonNullable>> +export type GetEndpointsCuriesQueryErrorExtension = ErrorType + +export const useGetEndpointsCuriesExtension = < + TData = Awaited>, + TError = ErrorType +>( + group: string, + options?: { + query?: Partial>, TError, TData>>, + request?: SecondParameter + } +): UseQueryResult & { queryKey: QueryKey } => { + const queryOptions = getGetEndpointsCuriesQueryOptionsExtension(group, options); + const query = useQuery(queryOptions) as UseQueryResult & { queryKey: QueryKey }; + query.queryKey = queryOptions.queryKey; + return query; +} + export const postEndpointsCuries = ( group: string, options?: SecondParameter,) => { @@ -1169,6 +1358,148 @@ export const useGetEndpointsCuries = ,signal?: AbortSignal +) => { + + + return customInstance( + {url: `https://uri.olympiangods.org/${group}/diff/${otherGroupDiff}/curies`, method: 'GET', signal + }, + options); + } + + +export const getGetDiffCuriesQueryKey = (group: string, + otherGroupDiff: string,) => { + return [`https://uri.olympiangods.org/${group}/diff/${otherGroupDiff}/curies`] as const; + } + + +export const getGetDiffCuriesQueryOptions = >, TError = ErrorType>(group: string, + otherGroupDiff: string, options?: { query?:Partial>, TError, TData>>, request?: SecondParameter} +) => { + +const {query: queryOptions, request: requestOptions} = options ?? {}; + + const queryKey = queryOptions?.queryKey ?? getGetDiffCuriesQueryKey(group,otherGroupDiff); + + + + const queryFn: QueryFunction>> = ({ signal }) => getDiffCuries(group,otherGroupDiff, requestOptions, signal); + + + + + + return { queryKey, queryFn, enabled: !!(group && otherGroupDiff), ...queryOptions} as UseQueryOptions>, TError, TData> & { queryKey: QueryKey } +} + +export type GetDiffCuriesQueryResult = NonNullable>> +export type GetDiffCuriesQueryError = ErrorType + +export const useGetDiffCuries = >, TError = ErrorType>( + group: string, + otherGroupDiff: string, options?: { query?:Partial>, TError, TData>>, request?: SecondParameter} + + ): UseQueryResult & { queryKey: QueryKey } => { + + const queryOptions = getGetDiffCuriesQueryOptions(group,otherGroupDiff,options) + + const query = useQuery(queryOptions) as UseQueryResult & { queryKey: QueryKey }; + + query.queryKey = queryOptions.queryKey ; + + return query; +} + + +export const getDiffCuriesExtension = ( + group: string, + otherGroupDiff: string, + prefixIriCurie: string, + extension: string, + options?: SecondParameter, signal?: AbortSignal +) => { + return customInstance( + { + url: `https://uri.olympiangods.org/${group}/diff/${otherGroupDiff}/curies/${prefixIriCurie}.${extension}`, + method: 'GET', + signal + }, + options + ); +} + +export const getGetDiffCuriesQueryKeyExtension = ( + group: string, + otherGroupDiff: string, + prefixIriCurie: string, + extension: string, +) => { + return [`https://uri.olympiangods.org/${group}/diff/${otherGroupDiff}/curies/${prefixIriCurie}.${extension}`] as const; +} + +export const getGetDiffCuriesQueryOptionsExtension = < + TData = Awaited>, + TError = ErrorType +>( + group: string, + otherGroupDiff: string, + prefixIriCurie: string, + extension: string, + options?: { + query?: Partial>, TError, TData>>, + request?: SecondParameter + } +) => { + const { query: queryOptions, request: requestOptions } = options ?? {}; + + const queryKey = queryOptions?.queryKey ?? getGetDiffCuriesQueryKeyExtension(group, otherGroupDiff, prefixIriCurie, extension); + + const queryFn: QueryFunction>> = ({ signal }) => + getDiffCuriesExtension(group, otherGroupDiff, prefixIriCurie, extension, requestOptions, signal); + + return { + queryKey, + queryFn, + enabled: !!(group && otherGroupDiff && prefixIriCurie && extension), + ...queryOptions + } as UseQueryOptions>, TError, TData> & { queryKey: QueryKey }; +} + +export type GetDiffCuriesQueryResultExtension = NonNullable>> +export type GetDiffCuriesQueryErrorExtension = ErrorType + +export const useGetDiffCuriesExtension = < + TData = Awaited>, + TError = ErrorType +>( + group: string, + otherGroupDiff: string, + prefixIriCurie: string, + extension: string, + options?: { + query?: Partial>, TError, TData>>, + request?: SecondParameter + } +): UseQueryResult & { queryKey: QueryKey } => { + + const queryOptions = getGetDiffCuriesQueryOptionsExtension(group, otherGroupDiff, prefixIriCurie, extension, options); + + const query = useQuery(queryOptions) as UseQueryResult & { queryKey: QueryKey }; + + query.queryKey = queryOptions.queryKey; + + return query; +} + + export const getDiffLexical = ( group: string, otherGroupDiff: string, @@ -1230,6 +1561,75 @@ export const useGetDiffLexical = ,signal?: AbortSignal +) => { + + + return customInstance( + {url: `https://uri.olympiangods.org/${group}/diff/${otherGroupDiff}/ontologies`, method: 'GET', signal + }, + options); + } + + +export const getGetDiffOntologiesQueryKey = (group: string, + otherGroupDiff: string,) => { + return [`https://uri.olympiangods.org/${group}/diff/${otherGroupDiff}/ontologies`] as const; + } + + +export const getGetDiffOntologiesQueryOptions = >, TError = ErrorType>(group: string, + otherGroupDiff: string, options?: { query?:Partial>, TError, TData>>, request?: SecondParameter} +) => { + +const {query: queryOptions, request: requestOptions} = options ?? {}; + + const queryKey = queryOptions?.queryKey ?? getGetDiffOntologiesQueryKey(group,otherGroupDiff); + + + + const queryFn: QueryFunction>> = ({ signal }) => getDiffOntologies(group,otherGroupDiff, requestOptions, signal); + + + + + + return { queryKey, queryFn, enabled: !!(group && otherGroupDiff), ...queryOptions} as UseQueryOptions>, TError, TData> & { queryKey: QueryKey } +} + +export type GetDiffOntologiesQueryResult = NonNullable>> +export type GetDiffOntologiesQueryError = ErrorType + +/** + * @summary The terminal ontologies query does go on endpoints + */ +export const useGetDiffOntologies = >, TError = ErrorType>( + group: string, + otherGroupDiff: string, options?: { query?:Partial>, TError, TData>>, request?: SecondParameter} + + ): UseQueryResult & { queryKey: QueryKey } => { + + const queryOptions = getGetDiffOntologiesQueryOptions(group,otherGroupDiff,options) + + const query = useQuery(queryOptions) as UseQueryResult & { queryKey: QueryKey }; + + query.queryKey = queryOptions.queryKey ; + + return query; +} + + + + /** * @summary needed because ontologies appear under other routes */ @@ -1703,87 +2103,96 @@ export const useGetDiffOntologiesUrisVersion = ,signal?: AbortSignal -) => { - - - return customInstance( - {url: `https://uri.olympiangods.org/${group}/diff/${otherGroupDiff}/ontologies/${ontPath}/${filename}.${extension}`, method: 'GET', signal - }, - options); - } - - -export const getGetDiffOntologiesQueryKey = (group: string, - otherGroupDiff: string, - ontPath: string, - filename: string, - extension: string,) => { - return [`https://uri.olympiangods.org/${group}/diff/${otherGroupDiff}/ontologies/${ontPath}/${filename}.${extension}`] as const; - } - - -export const getGetDiffOntologiesQueryOptions = >, TError = ErrorType>(group: string, - otherGroupDiff: string, - ontPath: string, - filename: string, - extension: string, options?: { query?:Partial>, TError, TData>>, request?: SecondParameter} -) => { - -const {query: queryOptions, request: requestOptions} = options ?? {}; - - const queryKey = queryOptions?.queryKey ?? getGetDiffOntologiesQueryKey(group,otherGroupDiff,ontPath,filename,extension); - - - - const queryFn: QueryFunction>> = ({ signal }) => getDiffOntologies(group,otherGroupDiff,ontPath,filename,extension, requestOptions, signal); - - - - - - return { queryKey, queryFn, enabled: !!(group && otherGroupDiff && ontPath && filename && extension), ...queryOptions} as UseQueryOptions>, TError, TData> & { queryKey: QueryKey } -} - -export type GetDiffOntologiesQueryResult = NonNullable>> -export type GetDiffOntologiesQueryError = ErrorType +export const getDiffOntologiesExtension = ( + group: string, + otherGroupDiff: string, + ontPath: string, + filename: string, + extension: string, + options?: SecondParameter, signal?: AbortSignal +) => { + return customInstance( + { + url: `https://uri.olympiangods.org/${group}/diff/${otherGroupDiff}/ontologies/${ontPath}/${filename}.${extension}`, + method: 'GET', + signal + }, + options + ); +} + +export const getGetDiffOntologiesQueryKeyExtension = ( + group: string, + otherGroupDiff: string, + ontPath: string, + filename: string, + extension: string, +) => { + return [`https://uri.olympiangods.org/${group}/diff/${otherGroupDiff}/ontologies/${ontPath}/${filename}.${extension}`] as const; +} + +export const getGetDiffOntologiesQueryOptionsExtension = < + TData = Awaited>, + TError = ErrorType +>( + group: string, + otherGroupDiff: string, + ontPath: string, + filename: string, + extension: string, + options?: { + query?: Partial>, TError, TData>>, + request?: SecondParameter + } +) => { + const { query: queryOptions, request: requestOptions } = options ?? {}; + + const queryKey = queryOptions?.queryKey ?? getGetDiffOntologiesQueryKeyExtension(group, otherGroupDiff, ontPath, filename, extension); + + const queryFn: QueryFunction>> = ({ signal }) => + getDiffOntologiesExtension(group, otherGroupDiff, ontPath, filename, extension, requestOptions, signal); + + return { + queryKey, + queryFn, + enabled: !!(group && otherGroupDiff && ontPath && filename && extension), + ...queryOptions + } as UseQueryOptions>, TError, TData> & { queryKey: QueryKey }; +} + +export type GetDiffOntologiesQueryResultExtension = NonNullable>> +export type GetDiffOntologiesQueryErrorExtension = ErrorType /** - * @summary needed because ontologies appear under other routes - */ -export const useGetDiffOntologies = >, TError = ErrorType>( - group: string, - otherGroupDiff: string, - ontPath: string, - filename: string, - extension: string, options?: { query?:Partial>, TError, TData>>, request?: SecondParameter} - - ): UseQueryResult & { queryKey: QueryKey } => { - - const queryOptions = getGetDiffOntologiesQueryOptions(group,otherGroupDiff,ontPath,filename,extension,options) - - const query = useQuery(queryOptions) as UseQueryResult & { queryKey: QueryKey }; - - query.queryKey = queryOptions.queryKey ; +* @summary needed because ontologies appear under other routes +*/ +export const useGetDiffOntologiesExtension = < + TData = Awaited>, + TError = ErrorType +>( + group: string, + otherGroupDiff: string, + ontPath: string, + filename: string, + extension: string, + options?: { + query?: Partial>, TError, TData>>, + request?: SecondParameter + } +): UseQueryResult & { queryKey: QueryKey } => { + + const queryOptions = getGetDiffOntologiesQueryOptionsExtension(group, otherGroupDiff, ontPath, filename, extension, options); + + const query = useQuery(queryOptions) as UseQueryResult & { queryKey: QueryKey }; + + query.queryKey = queryOptions.queryKey; return query; } - - - /** * @summary needed because ontologies appear under other routes */ @@ -2137,6 +2546,157 @@ export const useGetDiffUris = >, return query; } + + + +export const getDiffVersionsCuries = ( + group: string, + otherGroupDiff: string, + epochVerstrId: string, + options?: SecondParameter,signal?: AbortSignal +) => { + + + return customInstance( + {url: `https://uri.olympiangods.org/${group}/diff/${otherGroupDiff}/versions/${epochVerstrId}/curies`, method: 'GET', signal + }, + options); + } + + +export const getGetDiffVersionsCuriesQueryKey = (group: string, + otherGroupDiff: string, + epochVerstrId: string,) => { + return [`https://uri.olympiangods.org/${group}/diff/${otherGroupDiff}/versions/${epochVerstrId}/curies`] as const; + } + + +export const getGetDiffVersionsCuriesQueryOptions = >, TError = ErrorType>(group: string, + otherGroupDiff: string, + epochVerstrId: string, options?: { query?:Partial>, TError, TData>>, request?: SecondParameter} +) => { + +const {query: queryOptions, request: requestOptions} = options ?? {}; + + const queryKey = queryOptions?.queryKey ?? getGetDiffVersionsCuriesQueryKey(group,otherGroupDiff,epochVerstrId); + + + + const queryFn: QueryFunction>> = ({ signal }) => getDiffVersionsCuries(group,otherGroupDiff,epochVerstrId, requestOptions, signal); + + + + + + return { queryKey, queryFn, enabled: !!(group && otherGroupDiff && epochVerstrId), ...queryOptions} as UseQueryOptions>, TError, TData> & { queryKey: QueryKey } +} + +export type GetDiffVersionsCuriesQueryResult = NonNullable>> +export type GetDiffVersionsCuriesQueryError = ErrorType + +export const useGetDiffVersionsCuries = >, TError = ErrorType>( + group: string, + otherGroupDiff: string, + epochVerstrId: string, options?: { query?:Partial>, TError, TData>>, request?: SecondParameter} + + ): UseQueryResult & { queryKey: QueryKey } => { + + const queryOptions = getGetDiffVersionsCuriesQueryOptions(group,otherGroupDiff,epochVerstrId,options) + + const query = useQuery(queryOptions) as UseQueryResult & { queryKey: QueryKey }; + + query.queryKey = queryOptions.queryKey ; + + return query; +} + +export const getDiffVersionsCuriesExtension = ( + group: string, + otherGroupDiff: string, + epochVerstrId: string, + prefixIriCurie: string, + extension: string, + options?: SecondParameter, signal?: AbortSignal +) => { + return customInstance( + { + url: `https://uri.olympiangods.org/${group}/diff/${otherGroupDiff}/versions/${epochVerstrId}/curies/${prefixIriCurie}.${extension}`, + method: 'GET', + signal + }, + options + ); +} + +export const getGetDiffVersionsCuriesQueryKeyExtension = ( + group: string, + otherGroupDiff: string, + epochVerstrId: string, + prefixIriCurie: string, + extension: string, +) => { + return [`https://uri.olympiangods.org/${group}/diff/${otherGroupDiff}/versions/${epochVerstrId}/curies/${prefixIriCurie}.${extension}`] as const; +} + +export const getGetDiffVersionsCuriesQueryOptionsExtension = < + TData = Awaited>, + TError = ErrorType +>( + group: string, + otherGroupDiff: string, + epochVerstrId: string, + prefixIriCurie: string, + extension: string, + options?: { + query?: Partial>, TError, TData>>, + request?: SecondParameter + } +) => { + const { query: queryOptions, request: requestOptions } = options ?? {}; + + const queryKey = queryOptions?.queryKey ?? getGetDiffVersionsCuriesQueryKeyExtension(group, otherGroupDiff, epochVerstrId, prefixIriCurie, extension); + + const queryFn: QueryFunction>> = ({ signal }) => + getDiffVersionsCuriesExtension(group, otherGroupDiff, epochVerstrId, prefixIriCurie, extension, requestOptions, signal); + + return { + queryKey, + queryFn, + enabled: !!(group && otherGroupDiff && epochVerstrId && prefixIriCurie && extension), + ...queryOptions + } as UseQueryOptions>, TError, TData> & { queryKey: QueryKey }; +} + +export type GetDiffVersionsCuriesQueryResultExtension = NonNullable>> +export type GetDiffVersionsCuriesQueryErrorExtension = ErrorType + +export const useGetDiffVersionsCuriesExtension = < + TData = Awaited>, + TError = ErrorType +>( + group: string, + otherGroupDiff: string, + epochVerstrId: string, + prefixIriCurie: string, + extension: string, + options?: { + query?: Partial>, TError, TData>>, + request?: SecondParameter + } +): UseQueryResult & { queryKey: QueryKey } => { + + const queryOptions = getGetDiffVersionsCuriesQueryOptionsExtension(group, otherGroupDiff, epochVerstrId, prefixIriCurie, extension, options); + + const query = useQuery(queryOptions) as UseQueryResult & { queryKey: QueryKey }; + + query.queryKey = queryOptions.queryKey; + + return query; +} + + + + export const getDiffVersionsReadable = ( group: string, otherGroupDiff: string, @@ -4227,6 +4787,139 @@ const {mutation: mutationOptions, request: requestOptions} = options ?? {}; return useMutation(mutationOptions); } + +export const getOwnCuriesExtension = ( + group: string, + otherGroup: string, + prefixIriCurie: string, + extension: string, + options?: SecondParameter,signal?: AbortSignal +) => { + + + return customInstance( + {url: `https://uri.olympiangods.org/${group}/own/${otherGroup}/curies/${prefixIriCurie}.${extension}`, method: 'GET', signal + }, + options); + } + + +export const getGetOwnCuriesQueryKeyExtension = (group: string, + otherGroup: string, + prefixIriCurie: string, + extension: string,) => { + return [`https://uri.olympiangods.org/${group}/own/${otherGroup}/curies/${prefixIriCurie}.${extension}`] as const; + } + + +export const getGetOwnCuriesQueryOptionsExtension = >, TError = ErrorType>(group: string, + otherGroup: string, + prefixIriCurie: string, + extension: string, options?: { query?:Partial>, TError, TData>>, request?: SecondParameter} +) => { + +const {query: queryOptions, request: requestOptions} = options ?? {}; + + const queryKey = queryOptions?.queryKey ?? getGetOwnCuriesQueryKeyExtension(group,otherGroup,prefixIriCurie,extension); + + + + const queryFn: QueryFunction>> = ({ signal }) => getOwnCuriesExtension(group,otherGroup,prefixIriCurie,extension, requestOptions, signal); + + + + + + return { queryKey, queryFn, enabled: !!(group && otherGroup && prefixIriCurie && extension), ...queryOptions} as UseQueryOptions>, TError, TData> & { queryKey: QueryKey } +} + +export type GetOwnCuriesQueryResultExtension = NonNullable>> +export type GetOwnCuriesQueryErrorExtension = ErrorType + +export const useGetOwnCuriesExtension = >, TError = ErrorType>( + group: string, + otherGroup: string, + prefixIriCurie: string, + extension: string, options?: { query?:Partial>, TError, TData>>, request?: SecondParameter} + + ): UseQueryResult & { queryKey: QueryKey } => { + + const queryOptions = getGetOwnCuriesQueryOptionsExtension(group,otherGroup,prefixIriCurie,extension,options) + + const query = useQuery(queryOptions) as UseQueryResult & { queryKey: QueryKey }; + + query.queryKey = queryOptions.queryKey ; + + return query; +} + + + + +/** + * @summary The terminal ontologies query does go on endpoints + */ +export const getOwnOntologies = ( + group: string, + otherGroup: string, + options?: SecondParameter,signal?: AbortSignal +) => { + + + return customInstance( + {url: `https://uri.olympiangods.org/${group}/own/${otherGroup}/ontologies`, method: 'GET', signal + }, + options); + } + + +export const getGetOwnOntologiesQueryKey = (group: string, + otherGroup: string,) => { + return [`https://uri.olympiangods.org/${group}/own/${otherGroup}/ontologies`] as const; + } + + +export const getGetOwnOntologiesQueryOptions = >, TError = ErrorType>(group: string, + otherGroup: string, options?: { query?:Partial>, TError, TData>>, request?: SecondParameter} +) => { + +const {query: queryOptions, request: requestOptions} = options ?? {}; + + const queryKey = queryOptions?.queryKey ?? getGetOwnOntologiesQueryKey(group,otherGroup); + + + + const queryFn: QueryFunction>> = ({ signal }) => getOwnOntologies(group,otherGroup, requestOptions, signal); + + + + + + return { queryKey, queryFn, enabled: !!(group && otherGroup), ...queryOptions} as UseQueryOptions>, TError, TData> & { queryKey: QueryKey } +} + +export type GetOwnOntologiesQueryResult = NonNullable>> +export type GetOwnOntologiesQueryError = ErrorType + +/** + * @summary The terminal ontologies query does go on endpoints + */ +export const useGetOwnOntologies = >, TError = ErrorType>( + group: string, + otherGroup: string, options?: { query?:Partial>, TError, TData>>, request?: SecondParameter} + + ): UseQueryResult & { queryKey: QueryKey } => { + + const queryOptions = getGetOwnOntologiesQueryOptions(group,otherGroup,options) + + const query = useQuery(queryOptions) as UseQueryResult & { queryKey: QueryKey }; + + query.queryKey = queryOptions.queryKey ; + + return query; +} + + /** @@ -5010,87 +5703,100 @@ export const usePostOwnOntologiesUrisVersion = , const mutationOptions = getPostOwnOntologiesUrisVersionMutationOptions(options); - return useMutation(mutationOptions); - } - -/** - * @summary needed because ontologies appear under other routes - */ -export const getOwnOntologies = ( - group: string, - otherGroup: string, - ontPath: string, - filename: string, - extension: string, - options?: SecondParameter,signal?: AbortSignal -) => { - - - return customInstance( - {url: `https://uri.olympiangods.org/${group}/own/${otherGroup}/ontologies/${ontPath}/${filename}.${extension}`, method: 'GET', signal - }, - options); - } - - -export const getGetOwnOntologiesQueryKey = (group: string, - otherGroup: string, - ontPath: string, - filename: string, - extension: string,) => { - return [`https://uri.olympiangods.org/${group}/own/${otherGroup}/ontologies/${ontPath}/${filename}.${extension}`] as const; - } - - -export const getGetOwnOntologiesQueryOptions = >, TError = ErrorType>(group: string, - otherGroup: string, - ontPath: string, - filename: string, - extension: string, options?: { query?:Partial>, TError, TData>>, request?: SecondParameter} -) => { - -const {query: queryOptions, request: requestOptions} = options ?? {}; - - const queryKey = queryOptions?.queryKey ?? getGetOwnOntologiesQueryKey(group,otherGroup,ontPath,filename,extension); - - - - const queryFn: QueryFunction>> = ({ signal }) => getOwnOntologies(group,otherGroup,ontPath,filename,extension, requestOptions, signal); - - - - - - return { queryKey, queryFn, enabled: !!(group && otherGroup && ontPath && filename && extension), ...queryOptions} as UseQueryOptions>, TError, TData> & { queryKey: QueryKey } -} - -export type GetOwnOntologiesQueryResult = NonNullable>> -export type GetOwnOntologiesQueryError = ErrorType - -/** - * @summary needed because ontologies appear under other routes - */ -export const useGetOwnOntologies = >, TError = ErrorType>( - group: string, - otherGroup: string, - ontPath: string, - filename: string, - extension: string, options?: { query?:Partial>, TError, TData>>, request?: SecondParameter} - - ): UseQueryResult & { queryKey: QueryKey } => { - - const queryOptions = getGetOwnOntologiesQueryOptions(group,otherGroup,ontPath,filename,extension,options) - - const query = useQuery(queryOptions) as UseQueryResult & { queryKey: QueryKey }; + return useMutation(mutationOptions); + } +/** + * @summary needed because ontologies appear under other routes + */ +export const getOwnOntologiesExtension = ( + group: string, + otherGroup: string, + ontPath: string, + filename: string, + extension: string, + options?: SecondParameter, signal?: AbortSignal +) => { + return customInstance( + { + url: `https://uri.olympiangods.org/${group}/own/${otherGroup}/ontologies/${ontPath}/${filename}.${extension}`, + method: 'GET', + signal + }, + options + ); +} + +export const getGetOwnOntologiesQueryKeyExtension = ( + group: string, + otherGroup: string, + ontPath: string, + filename: string, + extension: string, +) => { + return [`https://uri.olympiangods.org/${group}/own/${otherGroup}/ontologies/${ontPath}/${filename}.${extension}`] as const; +} + +export const getGetOwnOntologiesQueryOptionsExtension = < + TData = Awaited>, + TError = ErrorType +>( + group: string, + otherGroup: string, + ontPath: string, + filename: string, + extension: string, + options?: { + query?: Partial>, TError, TData>>, + request?: SecondParameter + } +) => { + const { query: queryOptions, request: requestOptions } = options ?? {}; + + const queryKey = queryOptions?.queryKey ?? getGetOwnOntologiesQueryKeyExtension(group, otherGroup, ontPath, filename, extension); + + const queryFn: QueryFunction>> = ({ signal }) => + getOwnOntologiesExtension(group, otherGroup, ontPath, filename, extension, requestOptions, signal); + + return { + queryKey, + queryFn, + enabled: !!(group && otherGroup && ontPath && filename && extension), + ...queryOptions + } as UseQueryOptions>, TError, TData> & { queryKey: QueryKey }; +} + +export type GetOwnOntologiesQueryResultExtension = NonNullable>> +export type GetOwnOntologiesQueryErrorExtension = ErrorType - query.queryKey = queryOptions.queryKey ; +/** +* @summary needed because ontologies appear under other routes +*/ +export const useGetOwnOntologiesExtension = < + TData = Awaited>, + TError = ErrorType +>( + group: string, + otherGroup: string, + ontPath: string, + filename: string, + extension: string, + options?: { + query?: Partial>, TError, TData>>, + request?: SecondParameter + } +): UseQueryResult & { queryKey: QueryKey } => { + + const queryOptions = getGetOwnOntologiesQueryOptionsExtension(group, otherGroup, ontPath, filename, extension, options); + + const query = useQuery(queryOptions) as UseQueryResult & { queryKey: QueryKey }; + + query.queryKey = queryOptions.queryKey; return query; } - /** * @summary needed because ontologies appear under other routes */ @@ -5558,6 +6264,154 @@ export const useGetOwnUris = >, TE return query; } + + + +export const getOwnVersionsCuries = ( + group: string, + otherGroup: string, + epochVerstrId: string, + options?: SecondParameter,signal?: AbortSignal +) => { + + + return customInstance( + {url: `https://uri.olympiangods.org/${group}/own/${otherGroup}/versions/${epochVerstrId}/curies`, method: 'GET', signal + }, + options); + } + + +export const getGetOwnVersionsCuriesQueryKey = (group: string, + otherGroup: string, + epochVerstrId: string,) => { + return [`https://uri.olympiangods.org/${group}/own/${otherGroup}/versions/${epochVerstrId}/curies`] as const; + } + + +export const getGetOwnVersionsCuriesQueryOptions = >, TError = ErrorType>(group: string, + otherGroup: string, + epochVerstrId: string, options?: { query?:Partial>, TError, TData>>, request?: SecondParameter} +) => { + +const {query: queryOptions, request: requestOptions} = options ?? {}; + + const queryKey = queryOptions?.queryKey ?? getGetOwnVersionsCuriesQueryKey(group,otherGroup,epochVerstrId); + + + + const queryFn: QueryFunction>> = ({ signal }) => getOwnVersionsCuries(group,otherGroup,epochVerstrId, requestOptions, signal); + + + + + + return { queryKey, queryFn, enabled: !!(group && otherGroup && epochVerstrId), ...queryOptions} as UseQueryOptions>, TError, TData> & { queryKey: QueryKey } +} + +export type GetOwnVersionsCuriesQueryResult = NonNullable>> +export type GetOwnVersionsCuriesQueryError = ErrorType + +export const useGetOwnVersionsCuries = >, TError = ErrorType>( + group: string, + otherGroup: string, + epochVerstrId: string, options?: { query?:Partial>, TError, TData>>, request?: SecondParameter} + + ): UseQueryResult & { queryKey: QueryKey } => { + + const queryOptions = getGetOwnVersionsCuriesQueryOptions(group,otherGroup,epochVerstrId,options) + + const query = useQuery(queryOptions) as UseQueryResult & { queryKey: QueryKey }; + + query.queryKey = queryOptions.queryKey ; + + return query; +} + +export const getOwnVersionsCuriesExtension = ( + group: string, + otherGroup: string, + epochVerstrId: string, + prefixIriCurie: string, + extension: string, + options?: SecondParameter, signal?: AbortSignal +) => { + return customInstance( + { + url: `https://uri.olympiangods.org/${group}/own/${otherGroup}/versions/${epochVerstrId}/curies/${prefixIriCurie}.${extension}`, + method: 'GET', + signal + }, + options + ); +} + +export const getGetOwnVersionsCuriesQueryKeyExtension = ( + group: string, + otherGroup: string, + epochVerstrId: string, + prefixIriCurie: string, + extension: string, +) => { + return [`https://uri.olympiangods.org/${group}/own/${otherGroup}/versions/${epochVerstrId}/curies/${prefixIriCurie}.${extension}`] as const; +} + +export const getGetOwnVersionsCuriesQueryOptionsExtension = < + TData = Awaited>, + TError = ErrorType +>( + group: string, + otherGroup: string, + epochVerstrId: string, + prefixIriCurie: string, + extension: string, + options?: { + query?: Partial>, TError, TData>>, + request?: SecondParameter + } +) => { + const { query: queryOptions, request: requestOptions } = options ?? {}; + + const queryKey = queryOptions?.queryKey ?? getGetOwnVersionsCuriesQueryKeyExtension(group, otherGroup, epochVerstrId, prefixIriCurie, extension); + + const queryFn: QueryFunction>> = ({ signal }) => + getOwnVersionsCuriesExtension(group, otherGroup, epochVerstrId, prefixIriCurie, extension, requestOptions, signal); + + return { + queryKey, + queryFn, + enabled: !!(group && otherGroup && epochVerstrId && prefixIriCurie && extension), + ...queryOptions + } as UseQueryOptions>, TError, TData> & { queryKey: QueryKey }; +} + +export type GetOwnVersionsCuriesQueryResultExtension = NonNullable>> +export type GetOwnVersionsCuriesQueryErrorExtension = ErrorType + +export const useGetOwnVersionsCuriesExtension = < + TData = Awaited>, + TError = ErrorType +>( + group: string, + otherGroup: string, + epochVerstrId: string, + prefixIriCurie: string, + extension: string, + options?: { + query?: Partial>, TError, TData>>, + request?: SecondParameter + } +): UseQueryResult & { queryKey: QueryKey } => { + + const queryOptions = getGetOwnVersionsCuriesQueryOptionsExtension(group, otherGroup, epochVerstrId, prefixIriCurie, extension, options); + + const query = useQuery(queryOptions) as UseQueryResult & { queryKey: QueryKey }; + + query.queryKey = queryOptions.queryKey; + + return query; +} + export const getOwnVersionsReadable = ( group: string, otherGroup: string, @@ -7263,107 +8117,105 @@ const {mutation: mutationOptions, request: requestOptions} = options ?? {}; return useMutation(mutationOptions); } - -export const deletePrivRoleOtherGroup = ( + +export const getPrivUserRole = ( group: string, - otherRoleGroup: string, - options?: SecondParameter,) => { + options?: SecondParameter,signal?: AbortSignal +) => { return customInstance( - {url: `https://uri.olympiangods.org/${group}/priv/role-other/${otherRoleGroup}`, method: 'DELETE' + {url: `https://uri.olympiangods.org/${group}/priv/role`, method: 'GET', signal }, options); } +export const getGetPrivUserRoleQueryKey = (group: string,) => { + return [`https://uri.olympiangods.org/${group}/priv/role`] as const; + } -export const getDeletePrivRoleOtherGroupMutationOptions = , - TContext = unknown>(options?: { mutation?:UseMutationOptions>, TError,{group: string;otherRoleGroup: string}, TContext>, request?: SecondParameter} -): UseMutationOptions>, TError,{group: string;otherRoleGroup: string}, TContext> => { -const {mutation: mutationOptions, request: requestOptions} = options ?? {}; + +export const getGetPrivUserRoleQueryOptions = >, TError = ErrorType>(group: string, options?: { query?:Partial>, TError, TData>>, request?: SecondParameter} +) => { + +const {query: queryOptions, request: requestOptions} = options ?? {}; + + const queryKey = queryOptions?.queryKey ?? getGetPrivUserRoleQueryKey(group); + + + + const queryFn: QueryFunction>> = ({ signal }) => getPrivUserRole(group, requestOptions, signal); + - const mutationFn: MutationFunction>, {group: string;otherRoleGroup: string}> = (props) => { - const {group,otherRoleGroup} = props ?? {}; + return { queryKey, queryFn, enabled: !!(group), ...queryOptions} as UseQueryOptions>, TError, TData> & { queryKey: QueryKey } +} - return deletePrivRoleOtherGroup(group,otherRoleGroup,requestOptions) - } +export type GetPrivUserRoleQueryResult = NonNullable>> +export type GetPrivUserRoleQueryError = ErrorType - +export const useGetPrivUserRole = >, TError = ErrorType>( + group: string, options?: { query?:Partial>, TError, TData>>, request?: SecondParameter} + ): UseQueryResult & { queryKey: QueryKey } => { - return { mutationFn, ...mutationOptions }} + const queryOptions = getGetPrivUserRoleQueryOptions(group,options) - export type DeletePrivRoleOtherGroupMutationResult = NonNullable>> - - export type DeletePrivRoleOtherGroupMutationError = ErrorType + const query = useQuery(queryOptions) as UseQueryResult & { queryKey: QueryKey }; - export const useDeletePrivRoleOtherGroup = , - TContext = unknown>(options?: { mutation?:UseMutationOptions>, TError,{group: string;otherRoleGroup: string}, TContext>, request?: SecondParameter} -): UseMutationResult< - Awaited>, - TError, - {group: string;otherRoleGroup: string}, - TContext - > => { + query.queryKey = queryOptions.queryKey ; - const mutationOptions = getDeletePrivRoleOtherGroupMutationOptions(options); + return query; +} - return useMutation(mutationOptions); - } - -export const getPrivUserRole = ( +export const getPrivRoleOtherGroup = ( group: string, - user: string, options?: SecondParameter,signal?: AbortSignal ) => { return customInstance( - {url: `https://uri.olympiangods.org/${group}/priv/role/${user}`, method: 'GET', signal + {url: `https://uri.olympiangods.org/${group}/priv/role-other`, method: 'GET', signal }, options); } -export const getGetPrivUserRoleQueryKey = (group: string, - user: string,) => { - return [`https://uri.olympiangods.org/${group}/priv/role/${user}`] as const; +export const getGetPrivRoleOtherGroupQueryKey = (group: string,) => { + return [`https://uri.olympiangods.org/${group}/priv/role-other`] as const; } -export const getGetPrivUserRoleQueryOptions = >, TError = ErrorType>(group: string, - user: string, options?: { query?:Partial>, TError, TData>>, request?: SecondParameter} +export const getGetPrivRoleOtherGroupQueryOptions = >, TError = ErrorType>(group: string, options?: { query?:Partial>, TError, TData>>, request?: SecondParameter} ) => { const {query: queryOptions, request: requestOptions} = options ?? {}; - const queryKey = queryOptions?.queryKey ?? getGetPrivUserRoleQueryKey(group,user); + const queryKey = queryOptions?.queryKey ?? getGetPrivRoleOtherGroupQueryKey(group); - const queryFn: QueryFunction>> = ({ signal }) => getPrivUserRole(group,user, requestOptions, signal); + const queryFn: QueryFunction>> = ({ signal }) => getPrivRoleOtherGroup(group, requestOptions, signal); - return { queryKey, queryFn, enabled: !!(group && user), ...queryOptions} as UseQueryOptions>, TError, TData> & { queryKey: QueryKey } + return { queryKey, queryFn, enabled: !!(group), ...queryOptions} as UseQueryOptions>, TError, TData> & { queryKey: QueryKey } } -export type GetPrivUserRoleQueryResult = NonNullable>> -export type GetPrivUserRoleQueryError = ErrorType +export type GetPrivRoleOtherGroupQueryResult = NonNullable>> +export type GetPrivRoleOtherGroupQueryError = ErrorType -export const useGetPrivUserRole = >, TError = ErrorType>( - group: string, - user: string, options?: { query?:Partial>, TError, TData>>, request?: SecondParameter} +export const useGetPrivRoleOtherGroup = >, TError = ErrorType>( + group: string, options?: { query?:Partial>, TError, TData>>, request?: SecondParameter} ): UseQueryResult & { queryKey: QueryKey } => { - const queryOptions = getGetPrivUserRoleQueryOptions(group,user,options) + const queryOptions = getGetPrivRoleOtherGroupQueryOptions(group,options) const query = useQuery(queryOptions) as UseQueryResult & { queryKey: QueryKey }; @@ -7372,8 +8224,200 @@ export const useGetPrivUserRole = , signal?: AbortSignal +) => { + return customInstance( + { + url: `https://uri.olympiangods.org/${group}/priv/role-other/${otherRoleGroup}`, + method: 'GET', + signal + }, + options + ); +} + +export const getGetPrivRoleOtherGroupQueryKeyOther = ( + group: string, + otherRoleGroup: string, +) => { + return [`https://uri.olympiangods.org/${group}/priv/role-other/${otherRoleGroup}`] as const; +} + +export const getGetPrivRoleOtherGroupQueryOptionsOther = < + TData = Awaited>, + TError = ErrorType +>( + group: string, + otherRoleGroup: string, + options?: { + query?: Partial>, TError, TData>>, + request?: SecondParameter + } +) => { + const { query: queryOptions, request: requestOptions } = options ?? {}; + + const queryKey = queryOptions?.queryKey ?? getGetPrivRoleOtherGroupQueryKeyOther(group, otherRoleGroup); + + const queryFn: QueryFunction>> = ({ signal }) => + getPrivRoleOtherGroupOther(group, otherRoleGroup, requestOptions, signal); + + return { + queryKey, + queryFn, + enabled: !!(group && otherRoleGroup), + ...queryOptions + } as UseQueryOptions>, TError, TData> & { queryKey: QueryKey }; +} + +export type GetPrivRoleOtherGroupQueryResultOther = NonNullable>> +export type GetPrivRoleOtherGroupQueryErrorOther = ErrorType + +export const useGetPrivRoleOtherGroupOther = < + TData = Awaited>, + TError = ErrorType +>( + group: string, + otherRoleGroup: string, + options?: { + query?: Partial>, TError, TData>>, + request?: SecondParameter + } +): UseQueryResult & { queryKey: QueryKey } => { + + const queryOptions = getGetPrivRoleOtherGroupQueryOptionsOther(group, otherRoleGroup, options); + + const query = useQuery(queryOptions) as UseQueryResult & { queryKey: QueryKey }; + + query.queryKey = queryOptions.queryKey; + + return query; +} + +export const deletePrivRoleOtherGroup = ( + group: string, + otherRoleGroup: string, + options?: SecondParameter,) => { + + + return customInstance( + {url: `https://uri.olympiangods.org/${group}/priv/role-other/${otherRoleGroup}`, method: 'DELETE' + }, + options); + } + + + +export const getDeletePrivRoleOtherGroupMutationOptions = , + TContext = unknown>(options?: { mutation?:UseMutationOptions>, TError,{group: string;otherRoleGroup: string}, TContext>, request?: SecondParameter} +): UseMutationOptions>, TError,{group: string;otherRoleGroup: string}, TContext> => { +const {mutation: mutationOptions, request: requestOptions} = options ?? {}; + + + + + const mutationFn: MutationFunction>, {group: string;otherRoleGroup: string}> = (props) => { + const {group,otherRoleGroup} = props ?? {}; + + return deletePrivRoleOtherGroup(group,otherRoleGroup,requestOptions) + } + + + + + return { mutationFn, ...mutationOptions }} + + export type DeletePrivRoleOtherGroupMutationResult = NonNullable>> + + export type DeletePrivRoleOtherGroupMutationError = ErrorType + + export const useDeletePrivRoleOtherGroup = , + TContext = unknown>(options?: { mutation?:UseMutationOptions>, TError,{group: string;otherRoleGroup: string}, TContext>, request?: SecondParameter} +): UseMutationResult< + Awaited>, + TError, + {group: string;otherRoleGroup: string}, + TContext + > => { + + const mutationOptions = getDeletePrivRoleOtherGroupMutationOptions(options); + return useMutation(mutationOptions); + } + export const getPrivUserRoleUser = ( + group: string, + user: string, + options?: SecondParameter, signal?: AbortSignal + ) => { + return customInstance( + { + url: `https://uri.olympiangods.org/${group}/priv/role/${user}`, + method: 'GET', + signal + }, + options + ); + } + + export const getGetPrivUserRoleQueryKeyUser = ( + group: string, + user: string, + ) => { + return [`https://uri.olympiangods.org/${group}/priv/role/${user}`] as const; + } + + export const getGetPrivUserRoleQueryOptionsUser = < + TData = Awaited>, + TError = ErrorType + >( + group: string, + user: string, + options?: { + query?: Partial>, TError, TData>>, + request?: SecondParameter + } + ) => { + const { query: queryOptions, request: requestOptions } = options ?? {}; + + const queryKey = queryOptions?.queryKey ?? getGetPrivUserRoleQueryKeyUser(group, user); + + const queryFn: QueryFunction>> = ({ signal }) => + getPrivUserRoleUser(group, user, requestOptions, signal); + + return { + queryKey, + queryFn, + enabled: !!(group && user), + ...queryOptions + } as UseQueryOptions>, TError, TData> & { queryKey: QueryKey }; + } + + export type GetPrivUserRoleQueryResultUser = NonNullable>> + export type GetPrivUserRoleQueryErrorUser = ErrorType + + export const useGetPrivUserRoleUser = < + TData = Awaited>, + TError = ErrorType + >( + group: string, + user: string, + options?: { + query?: Partial>, TError, TData>>, + request?: SecondParameter + } + ): UseQueryResult & { queryKey: QueryKey } => { + + const queryOptions = getGetPrivUserRoleQueryOptionsUser(group, user, options); + + const query = useQuery(queryOptions) as UseQueryResult & { queryKey: QueryKey }; + + query.queryKey = queryOptions.queryKey; + + return query; + } export const deletePrivUserRole = ( group: string, @@ -8195,6 +9239,148 @@ export const useGetEndpointsUris = ,signal?: AbortSignal +) => { + + + return customInstance( + {url: `https://uri.olympiangods.org/${group}/versions/${epochVerstrId}/curies`, method: 'GET', signal + }, + options); + } + + +export const getGetVersionsCuriesQueryKey = (group: string, + epochVerstrId: string,) => { + return [`https://uri.olympiangods.org/${group}/versions/${epochVerstrId}/curies`] as const; + } + + +export const getGetVersionsCuriesQueryOptions = >, TError = ErrorType>(group: string, + epochVerstrId: string, options?: { query?:Partial>, TError, TData>>, request?: SecondParameter} +) => { + +const {query: queryOptions, request: requestOptions} = options ?? {}; + + const queryKey = queryOptions?.queryKey ?? getGetVersionsCuriesQueryKey(group,epochVerstrId); + + + + const queryFn: QueryFunction>> = ({ signal }) => getVersionsCuries(group,epochVerstrId, requestOptions, signal); + + + + + + return { queryKey, queryFn, enabled: !!(group && epochVerstrId), ...queryOptions} as UseQueryOptions>, TError, TData> & { queryKey: QueryKey } +} + +export type GetVersionsCuriesQueryResult = NonNullable>> +export type GetVersionsCuriesQueryError = ErrorType + +export const useGetVersionsCuries = >, TError = ErrorType>( + group: string, + epochVerstrId: string, options?: { query?:Partial>, TError, TData>>, request?: SecondParameter} + + ): UseQueryResult & { queryKey: QueryKey } => { + + const queryOptions = getGetVersionsCuriesQueryOptions(group,epochVerstrId,options) + + const query = useQuery(queryOptions) as UseQueryResult & { queryKey: QueryKey }; + + query.queryKey = queryOptions.queryKey ; + + return query; +} + +export const getVersionsCuriesExtension = ( + group: string, + epochVerstrId: string, + prefixIriCurie: string, + extension: string, + options?: SecondParameter, signal?: AbortSignal +) => { + return customInstance( + { + url: `https://uri.olympiangods.org/${group}/versions/${epochVerstrId}/curies/${prefixIriCurie}.${extension}`, + method: 'GET', + signal + }, + options + ); +} + +export const getGetVersionsCuriesQueryKeyExtension = ( + group: string, + epochVerstrId: string, + prefixIriCurie: string, + extension: string, +) => { + return [`https://uri.olympiangods.org/${group}/versions/${epochVerstrId}/curies/${prefixIriCurie}.${extension}`] as const; +} + +export const getGetVersionsCuriesQueryOptionsExtension = < + TData = Awaited>, + TError = ErrorType +>( + group: string, + epochVerstrId: string, + prefixIriCurie: string, + extension: string, + options?: { + query?: Partial>, TError, TData>>, + request?: SecondParameter + } +) => { + const { query: queryOptions, request: requestOptions } = options ?? {}; + + const queryKey = queryOptions?.queryKey ?? getGetVersionsCuriesQueryKeyExtension(group, epochVerstrId, prefixIriCurie, extension); + + const queryFn: QueryFunction>> = ({ signal }) => + getVersionsCuriesExtension(group, epochVerstrId, prefixIriCurie, extension, requestOptions, signal); + + return { + queryKey, + queryFn, + enabled: !!(group && epochVerstrId && prefixIriCurie && extension), + ...queryOptions + } as UseQueryOptions>, TError, TData> & { queryKey: QueryKey }; +} + +export type GetVersionsCuriesQueryResultExtension = NonNullable>> +export type GetVersionsCuriesQueryErrorExtension = ErrorType + +export const useGetVersionsCuriesExtension = < + TData = Awaited>, + TError = ErrorType +>( + group: string, + epochVerstrId: string, + prefixIriCurie: string, + extension: string, + options?: { + query?: Partial>, TError, TData>>, + request?: SecondParameter + } +): UseQueryResult & { queryKey: QueryKey } => { + + const queryOptions = getGetVersionsCuriesQueryOptionsExtension(group, epochVerstrId, prefixIriCurie, extension, options); + + const query = useQuery(queryOptions) as UseQueryResult & { queryKey: QueryKey }; + + query.queryKey = queryOptions.queryKey; + + return query; +} + + + export const getVersionsReadable = ( group: string, epochVerstrId: string, diff --git a/src/components/SingleOrganization/CreateForkDialog.jsx b/src/components/SingleOrganization/CreateForkDialog.jsx index 503a4542..0e879396 100644 --- a/src/components/SingleOrganization/CreateForkDialog.jsx +++ b/src/components/SingleOrganization/CreateForkDialog.jsx @@ -60,7 +60,7 @@ const CreateForkDialog = ({ open, handleClose, onSubmit }) => { ); const fetchOrganizations = async () => { - const organizations = await getOrganizations() + const organizations = await getOrganizations("base") setOrganizations(organizations); setLoading(false) } diff --git a/src/components/organizations/index.jsx b/src/components/organizations/index.jsx index e0673821..41647540 100644 --- a/src/components/organizations/index.jsx +++ b/src/components/organizations/index.jsx @@ -11,7 +11,7 @@ const Organizations = () => { const [loading, setLoading] = useState(true); const fetchOrganizations = async() => { - const organizations = await getOrganizations() + const organizations = await getOrganizations("base") setOrganizations(organizations); setLoading(false) } From 31492a9cdd0f393da23484f3de0928ffb3b34c0a Mon Sep 17 00:00:00 2001 From: jrmartin Date: Mon, 24 Mar 2025 18:16:51 +0100 Subject: [PATCH 02/11] #91 - Create links to endpoints contacting olympian gods --- src/api/endpoints/index.ts | 27 ++++++++++++++++---------- src/components/Auth/Login.jsx | 9 +++++++-- src/components/organizations/index.jsx | 5 +++-- src/contexts/DataContext.jsx | 6 +++++- 4 files changed, 32 insertions(+), 15 deletions(-) diff --git a/src/api/endpoints/index.ts b/src/api/endpoints/index.ts index e3e0d0a7..43aeaaac 100644 --- a/src/api/endpoints/index.ts +++ b/src/api/endpoints/index.ts @@ -14,8 +14,6 @@ const BASE_GROUP = "base"; const BASE_EXTENSION = "jsonld"; export const getOrganizations = async (group) => { - /** Call endpoint for retrieving organizations, this is a mock endpoint - created by us */ const { getPrivRoleOtherGroup } = useApi(); /** Call Endpoint */ @@ -28,8 +26,6 @@ export const getOrganizations = async (group) => { } export const getOrganization = async (id) => { - /** Call endpoint for retrieving organizations, this is a mock endpoint - created by us */ const { getOrganization } = useMockApi(); /** Call Endpoint */ @@ -42,8 +38,6 @@ export const getOrganization = async (id) => { } export const getOrganizationTerms = async (id) => { - /** Call endpoint for retrieving organizations, this is a mock endpoint - created by us */ const { getOrganizationsTerms } = useMockApi(); /** Call Endpoint */ @@ -55,6 +49,19 @@ export const getOrganizationTerms = async (id) => { }); } +export const newOrganization = async (organization) => { + const { postPrivOrgNew } = useApi(); + + /** Call Endpoint */ + return postPrivOrgNew(organization).then((response) => { + console.log("Post new organization ", response) + return response + }) + .catch((error) => { + return error; + }); +} + export const getOrganizationCuries = async (id) => { const { getOrganizationsCuries } = useMockApi(); @@ -192,10 +199,10 @@ export const searchAll = async (term, filters = {}) => { } export const patchTerm = async (group, termID, term) => { - const patchEndpointsIlx= ""; + const {patchEndpointsIlx} = useApi(); /** Call Endpoint */ - return patchEndpointsIlx(group, termID).then((data) => { + return patchEndpointsIlx(group, termID, term).then((data) => { let termParsed = getTerm(data.data); let response = { status : data.status, @@ -210,10 +217,10 @@ export const patchTerm = async (group, termID, term) => { } export const addTerm = async (group, term) => { - const { addTerm } = useMockApi(); + const { postPrivEntityNew } = useApi(); /** Call Endpoint */ - return addTerm(group, term).then((data) => { + return postPrivEntityNew(group, term).then((data) => { let termParsed = getTerm(data.data); let response = { status : data.status, diff --git a/src/components/Auth/Login.jsx b/src/components/Auth/Login.jsx index 5aeed8b9..ed3816dd 100644 --- a/src/components/Auth/Login.jsx +++ b/src/components/Auth/Login.jsx @@ -15,6 +15,8 @@ import { CheckedIcon, UncheckedIcon, OrcidIcon } from "../../Icons"; import FormField from "./UI/Formfield"; import PasswordField from "./UI/PasswordField"; import { handleLogin } from "../../api/endpoints/index"; +import {GlobalDataContext} from "../../contexts/DataContext"; +import { useContext } from 'react'; const Login = () => { const [formData, setFormData] = React.useState({ @@ -22,6 +24,8 @@ const Login = () => { password: "", }); + const { setUserData } = useContext(GlobalDataContext); + const handleInputChange = (e) => { const { name, value } = e.target; setFormData((prev) => ({ @@ -32,8 +36,9 @@ const Login = () => { const loginUser = async () => { try { - await handleLogin(formData.email, formData.password); - console.log("Login successful"); + const response = await handleLogin(formData.email, formData.password); + console.log("Login successful ", response); + setUserData(response.data) } catch (error) { console.error("Login error:", error); } diff --git a/src/components/organizations/index.jsx b/src/components/organizations/index.jsx index 41647540..10c1b79a 100644 --- a/src/components/organizations/index.jsx +++ b/src/components/organizations/index.jsx @@ -1,5 +1,5 @@ import {useEffect, useState } from "react"; -import { getOrganizations } from "../../api/endpoints"; +import { getOrganizations, newOrganization } from "../../api/endpoints"; import OrganizationsList from "../common/OrganizationsList"; import {Box, Typography, CircularProgress} from "@mui/material"; @@ -19,6 +19,7 @@ const Organizations = () => { useEffect( () => { setLoading(true) fetchOrganizations(); + newOrganization("test"); }, []); if (loading) { @@ -30,7 +31,7 @@ const Organizations = () => { return ( - {organizations.length} Organizations + {organizations?.length} Organizations diff --git a/src/contexts/DataContext.jsx b/src/contexts/DataContext.jsx index fc3ba719..d83e9e7b 100644 --- a/src/contexts/DataContext.jsx +++ b/src/contexts/DataContext.jsx @@ -34,6 +34,9 @@ const GlobalDataProvider = ({ children }) => { setEditBulkSearchFilters(filters); }; + const setUserData = (user) => { + setUser(user) + } // eslint-disable-next-line react-hooks/exhaustive-deps const fetchUser= useCallback(debounce(async () => { @@ -47,6 +50,7 @@ const GlobalDataProvider = ({ children }) => { const dataContextValue = { user, + setUserData, activeOntology, setOntologyData, searchOrganizationFilters, @@ -57,7 +61,7 @@ const GlobalDataProvider = ({ children }) => { setPredicatesSingleTermData, editBulkSearchFilters, setEditBulkSearchData - }; + }; return ( From db6a4c17d0d3948a9fe1ee78cb5e3fdcf7ae1c34 Mon Sep 17 00:00:00 2001 From: Aiga115 Date: Wed, 26 Mar 2025 17:50:37 +0100 Subject: [PATCH 03/11] ILEX-91-B add basic dialog --- src/components/common/BasicDialog.jsx | 46 +++++++++++++++++++++++ src/components/organizations/index.jsx | 51 +++++++++++++++++++++++--- 2 files changed, 92 insertions(+), 5 deletions(-) create mode 100644 src/components/common/BasicDialog.jsx diff --git a/src/components/common/BasicDialog.jsx b/src/components/common/BasicDialog.jsx new file mode 100644 index 00000000..dd88956a --- /dev/null +++ b/src/components/common/BasicDialog.jsx @@ -0,0 +1,46 @@ +import PropTypes from "prop-types"; +import { Dialog, DialogTitle, DialogContent, IconButton } from "@mui/material"; +import CloseIcon from '@mui/icons-material/Close'; + +import { vars } from "../../theme/variables"; +const { gray400, gray600 } = vars; + +const BasicDialog = ({ open, title, handleClose, children, sx }) => { + + return ( + + {title} + + + + + {children} + + + ); +}; + +BasicDialog.propTypes = { + children: PropTypes.node.isRequired, + title: PropTypes.string.isRequired, + open: PropTypes.bool.isRequired, + handleClose: PropTypes.func.isRequired, + sx: PropTypes.object, +}; + +export default BasicDialog; \ No newline at end of file diff --git a/src/components/organizations/index.jsx b/src/components/organizations/index.jsx index 10c1b79a..d67a6b02 100644 --- a/src/components/organizations/index.jsx +++ b/src/components/organizations/index.jsx @@ -1,14 +1,26 @@ import {useEffect, useState } from "react"; import { getOrganizations, newOrganization } from "../../api/endpoints"; import OrganizationsList from "../common/OrganizationsList"; -import {Box, Typography, CircularProgress} from "@mui/material"; +import { Box, Typography, CircularProgress, Stack, Button, Link } from "@mui/material"; +import BasicDialog from "../common/BasicDialog"; +import GroupAddOutlinedIcon from "@mui/icons-material/GroupAddOutlined"; import { vars } from "../../theme/variables"; -const { gray700 } = vars; +const { gray600, gray700, brand700, brand800 } = vars; + +const linkStyles = { + color: brand700, + fontWeight: 600, + textDecoration: "none", + "&:hover": { + color: brand800 + } +} const Organizations = () => { const [organizations, setOrganizations] = useState([]); const [loading, setLoading] = useState(true); + const [open, setOpen] = useState(false); const fetchOrganizations = async() => { const organizations = await getOrganizations("base") @@ -22,6 +34,14 @@ const Organizations = () => { newOrganization("test"); }, []); + const handleOpen = () => { + setOpen(true); + }; + + const handleClose = () => { + setOpen(false); + }; + if (loading) { return @@ -30,10 +50,31 @@ const Organizations = () => { return ( - - {organizations?.length} Organizations - + + + {organizations?.length} Organizations + + + + + + Creating an organization requires the help of an admin. Please reach out to {' '} + + organisation@interlex.org + + {' '} for assistance. + + ); } From 998b2a4249e993969af975ed119af4cfd6ff4d30 Mon Sep 17 00:00:00 2001 From: Aiga115 Date: Wed, 9 Apr 2025 16:46:36 +0200 Subject: [PATCH 04/11] ILEX-91-B unnecessary code deletion --- src/components/Auth/Login.jsx | 1 - 1 file changed, 1 deletion(-) diff --git a/src/components/Auth/Login.jsx b/src/components/Auth/Login.jsx index 1739ccea..d70f7688 100644 --- a/src/components/Auth/Login.jsx +++ b/src/components/Auth/Login.jsx @@ -33,7 +33,6 @@ const Login = () => { }); const [errors, setErrors] = React.useState({}); const [isLoading, setIsLoading] = React.useState(false); - const { setUserData } = React.useContext(GlobalDataContext); const navigate = useNavigate(); React.useEffect(() => { From 6fb29ff2e51cabb4b5a6e6da9d490b0cf9683fdb Mon Sep 17 00:00:00 2001 From: Aiga115 Date: Thu, 10 Apr 2025 17:56:00 +0200 Subject: [PATCH 05/11] ILEX-91-B add organization endpoint to api service --- src/api/endpoints/apiService.ts | 4 +++- src/components/Auth/Login.jsx | 3 +-- src/config.js | 1 + 3 files changed, 5 insertions(+), 3 deletions(-) diff --git a/src/api/endpoints/apiService.ts b/src/api/endpoints/apiService.ts index 7c51d35d..6ae3b73e 100644 --- a/src/api/endpoints/apiService.ts +++ b/src/api/endpoints/apiService.ts @@ -16,4 +16,6 @@ export interface RegisterRequest { } export const login = createPostRequest(API_CONFIG.REAL_API.SIGNIN, "application/x-www-form-urlencoded") -export const register = createPostRequest(API_CONFIG.REAL_API.NEWUSER_ILX, "application/x-www-form-urlencoded") \ No newline at end of file +export const register = createPostRequest(API_CONFIG.REAL_API.NEWUSER_ILX, "application/x-www-form-urlencoded") + +export const getOrganizations = createPostRequest(API_CONFIG.REAL_API.GET_ORGANIZATIONS, "application/json"); \ No newline at end of file diff --git a/src/components/Auth/Login.jsx b/src/components/Auth/Login.jsx index d70f7688..bf9645d0 100644 --- a/src/components/Auth/Login.jsx +++ b/src/components/Auth/Login.jsx @@ -33,6 +33,7 @@ const Login = () => { }); const [errors, setErrors] = React.useState({}); const [isLoading, setIsLoading] = React.useState(false); + const { setUserData } = React.useContext(GlobalDataContext); const navigate = useNavigate(); React.useEffect(() => { @@ -64,8 +65,6 @@ const Login = () => { // eslint-disable-next-line react-hooks/exhaustive-deps }, [isLoading]); - const { setUserData } = useContext(GlobalDataContext); - const handleInputChange = (e) => { const { name, value } = e.target; setFormData((prev) => ({ ...prev, [name]: value })); diff --git a/src/config.js b/src/config.js index 3363167f..63c2ccea 100644 --- a/src/config.js +++ b/src/config.js @@ -27,6 +27,7 @@ export const API_CONFIG = { ORCID_SIGNIN: "/u/ops/orcid-new", NEWUSER_ILX: "/u/ops/user-new", NEWUSER_ORCID: "/u/ops/orcid-new", + GET_ORGANIZATIONS: "/priv/org-new", }, OLYMPIAN_GODS : "https://uri.olympiangods.org", BASE_SCICRUNCH_URL: "/api/elasticsearch?key=", From 465e1c5f736ab8a44d81ae620e9d6b82016e4cd6 Mon Sep 17 00:00:00 2001 From: Aiga115 Date: Thu, 10 Apr 2025 19:09:08 +0200 Subject: [PATCH 06/11] ILEX-91-B temporary changes --- src/api/endpoints/apiActions.ts | 15 +++++++++++++++ src/api/endpoints/apiService.ts | 4 ++-- src/components/organizations/index.jsx | 14 ++++++++------ src/config.js | 2 +- 4 files changed, 26 insertions(+), 9 deletions(-) diff --git a/src/api/endpoints/apiActions.ts b/src/api/endpoints/apiActions.ts index 77fd1ec0..1a166208 100644 --- a/src/api/endpoints/apiActions.ts +++ b/src/api/endpoints/apiActions.ts @@ -21,6 +21,21 @@ export const createPostRequest = (endpoint: string, contentTyp } } +export const createPostRequestAnother = (endpoint: string, contentType = "application/json") => { + return (data?: D, options?: SecondParameter) => { + return customInstance( + { + url: "https://uri.olympiangods.org/aigul/priv/org-new", + method: "POST", + headers: { + "Content-Type": contentType, + }, + }, + options, + ) + } +} + export const createGetRequest = (endpoint: string, contentType?: string) => { return (params?: P, options?: SecondParameter, signal?: AbortSignal) => { const config: AxiosRequestConfig = { diff --git a/src/api/endpoints/apiService.ts b/src/api/endpoints/apiService.ts index 6ae3b73e..8d0c6fa4 100644 --- a/src/api/endpoints/apiService.ts +++ b/src/api/endpoints/apiService.ts @@ -1,4 +1,4 @@ -import { createPostRequest } from "./apiActions"; +import { createPostRequest, createPostRequestAnother } from "./apiActions"; import { API_CONFIG } from "../../config"; export interface LoginRequest { @@ -18,4 +18,4 @@ export interface RegisterRequest { export const login = createPostRequest(API_CONFIG.REAL_API.SIGNIN, "application/x-www-form-urlencoded") export const register = createPostRequest(API_CONFIG.REAL_API.NEWUSER_ILX, "application/x-www-form-urlencoded") -export const getOrganizations = createPostRequest(API_CONFIG.REAL_API.GET_ORGANIZATIONS, "application/json"); \ No newline at end of file +export const getOrganizations = createPostRequestAnother(API_CONFIG.REAL_API.GET_ORGANIZATIONS, "application/json"); \ No newline at end of file diff --git a/src/components/organizations/index.jsx b/src/components/organizations/index.jsx index d67a6b02..8bdfc0bf 100644 --- a/src/components/organizations/index.jsx +++ b/src/components/organizations/index.jsx @@ -1,9 +1,10 @@ import {useEffect, useState } from "react"; -import { getOrganizations, newOrganization } from "../../api/endpoints"; +// import { getOrganizations, newOrganization } from "../../api/endpoints"; import OrganizationsList from "../common/OrganizationsList"; import { Box, Typography, CircularProgress, Stack, Button, Link } from "@mui/material"; import BasicDialog from "../common/BasicDialog"; import GroupAddOutlinedIcon from "@mui/icons-material/GroupAddOutlined"; +import { getOrganizations } from "../../api/endpoints/apiService"; import { vars } from "../../theme/variables"; const { gray600, gray700, brand700, brand800 } = vars; @@ -23,7 +24,8 @@ const Organizations = () => { const [open, setOpen] = useState(false); const fetchOrganizations = async() => { - const organizations = await getOrganizations("base") + const organizations = await getOrganizations() + console.log("organizations: ", organizations) setOrganizations(organizations); setLoading(false) } @@ -31,7 +33,7 @@ const Organizations = () => { useEffect( () => { setLoading(true) fetchOrganizations(); - newOrganization("test"); + // newOrganization("aigul"); }, []); const handleOpen = () => { @@ -51,12 +53,12 @@ const Organizations = () => { return ( - + {/* {organizations?.length} Organizations - + */} - + {/* */} Date: Mon, 21 Apr 2025 11:31:35 +0200 Subject: [PATCH 07/11] ILEX-91-B some temporary changes --- src/api/endpoints/apiActions.ts | 12 +++++- src/components/organizations/index.jsx | 54 +++++++++++++++++++++----- 2 files changed, 55 insertions(+), 11 deletions(-) diff --git a/src/api/endpoints/apiActions.ts b/src/api/endpoints/apiActions.ts index 1a166208..e9a3b961 100644 --- a/src/api/endpoints/apiActions.ts +++ b/src/api/endpoints/apiActions.ts @@ -1,6 +1,7 @@ import { AxiosRequestConfig } from 'axios'; import { customInstance } from '../../../mock/mutator/customClient'; import { API_CONFIG } from '../../config'; +import { useCookies } from 'react-cookie' type SecondParameter any> = Parameters[1]; @@ -22,14 +23,23 @@ export const createPostRequest = (endpoint: string, contentTyp } export const createPostRequestAnother = (endpoint: string, contentType = "application/json") => { - return (data?: D, options?: SecondParameter) => { + return (data?: any, options?: SecondParameter) => { + console.log("data session: ", data.session) return customInstance( { url: "https://uri.olympiangods.org/aigul/priv/org-new", method: "POST", + // data: "a test", headers: { "Content-Type": contentType, + "session": data.session, + "Access-Control-Allow-Origin": "http://127.0.0.1:5173", + // "Access-Control-Allow-Credentials": "true", + // "Access-Control-Allow-Headers": "content-type", + // "Access-Control-Allow-Methods": "PUT, POST, GET, DELETE, PATCH, OPTIONS", + // "Cookie": `session=${data.session}` }, + withCredentials: true }, options, ) diff --git a/src/components/organizations/index.jsx b/src/components/organizations/index.jsx index 8bdfc0bf..31b778c6 100644 --- a/src/components/organizations/index.jsx +++ b/src/components/organizations/index.jsx @@ -1,10 +1,11 @@ import {useEffect, useState } from "react"; -// import { getOrganizations, newOrganization } from "../../api/endpoints"; +import { newOrganization } from "../../api/endpoints"; import OrganizationsList from "../common/OrganizationsList"; import { Box, Typography, CircularProgress, Stack, Button, Link } from "@mui/material"; import BasicDialog from "../common/BasicDialog"; import GroupAddOutlinedIcon from "@mui/icons-material/GroupAddOutlined"; import { getOrganizations } from "../../api/endpoints/apiService"; +import { useCookies } from 'react-cookie' import { vars } from "../../theme/variables"; const { gray600, gray700, brand700, brand800 } = vars; @@ -20,21 +21,20 @@ const linkStyles = { const Organizations = () => { const [organizations, setOrganizations] = useState([]); - const [loading, setLoading] = useState(true); + const [loading, setLoading] = useState(false); const [open, setOpen] = useState(false); + const [cookies, setCookie] = useCookies(['session']); const fetchOrganizations = async() => { const organizations = await getOrganizations() - console.log("organizations: ", organizations) - setOrganizations(organizations); setLoading(false) } - useEffect( () => { - setLoading(true) - fetchOrganizations(); - // newOrganization("aigul"); - }, []); + // useEffect( () => { + // setLoading(true) + // fetchOrganizations(); + // newOrganization("aigul"); + // }, []); const handleOpen = () => { setOpen(true); @@ -44,6 +44,40 @@ const Organizations = () => { setOpen(false); }; + const handleSubmit = async (e) => { + e.preventDefault(); + setLoading(true); + // setError(null); + + try { + // Your API URL and cookie details + const apiUrl = 'http://127.0.0.1:5173/aigul/priv/org-new'; + const cookieName = 'authCookie'; + + // const response = await fetch(apiUrl, { + // method: 'POST', + // headers: { + // 'Content-Type': 'application/json', + // }, + // credentials: 'include', + // body: "a test" + // }); + const response = getOrganizations(cookies) + + if (!response.ok) { + throw new Error(`API error: ${response.status}`); + } + const data = await response.json(); + console.log("data: ", data) + // setResponse(data); + } catch (err) { + console.log('An unknown error occurred: ', err); + } finally { + setLoading(false); + } + } + console.log("cookies: ", cookies) + if (loading) { return @@ -56,7 +90,7 @@ const Organizations = () => { {/* {organizations?.length} Organizations */} - + {/* */} Date: Mon, 21 Apr 2025 12:02:55 +0200 Subject: [PATCH 08/11] reverse proxy for priv endpoints --- src/components/Auth/Login.jsx | 1 + src/components/organizations/index.jsx | 28 +++++++++++++------------- vite.config.js | 22 ++++++++++++++++++++ 3 files changed, 37 insertions(+), 14 deletions(-) diff --git a/src/components/Auth/Login.jsx b/src/components/Auth/Login.jsx index 698abcdf..40945384 100644 --- a/src/components/Auth/Login.jsx +++ b/src/components/Auth/Login.jsx @@ -49,6 +49,7 @@ const Login = () => { if (!e.data || !e.data.orcid_meta) return; // TODO: get the session cookie when here and add it to our domain. // also store the user info once logged from here in the local storage for future usage. + console.log(e.data); const { code, orcid_meta, cookies } = e.data; const _cookies = JSON.parse(cookies); // create a cookie with the name "session" and the value of the session cookie diff --git a/src/components/organizations/index.jsx b/src/components/organizations/index.jsx index 31b778c6..164a7af0 100644 --- a/src/components/organizations/index.jsx +++ b/src/components/organizations/index.jsx @@ -48,21 +48,21 @@ const Organizations = () => { e.preventDefault(); setLoading(true); // setError(null); - + try { // Your API URL and cookie details - const apiUrl = 'http://127.0.0.1:5173/aigul/priv/org-new'; - const cookieName = 'authCookie'; - - // const response = await fetch(apiUrl, { - // method: 'POST', - // headers: { - // 'Content-Type': 'application/json', - // }, - // credentials: 'include', - // body: "a test" - // }); - const response = getOrganizations(cookies) + const apiUrl = '/dariodippi/priv/org-new'; + // const cookieName = 'authCookie'; + + const response = await fetch(apiUrl, { + method: 'POST', + headers: { + 'Content-Type': 'application/json', + }, + credentials: 'include', + body: "a test" + }); + // const response = getOrganizations(cookies) if (!response.ok) { throw new Error(`API error: ${response.status}`); @@ -90,7 +90,7 @@ const Organizations = () => { {/* {organizations?.length} Organizations */} - + {/* */} { + console.log(_options); + proxy.on('error', (err, _req, _res) => { + console.log('proxy error', err); + console.log('proxy request', _req); + console.log('proxy response', _res); + }); + proxy.on('proxyReq', (proxyReq, req, _res) => { + console.log('Sending Request to the Target:', req.method, req.url); + console.log('Response:', _res); + console.log('Request:', proxyReq); + }); + proxy.on('proxyRes', (proxyRes, req, _res) => { + console.log('Received response', _res); + console.log('Received Response from the Target:', proxyRes.statusCode, req.url); + }); + }, + }, }, }, }); From e9aa47b9f9874e19161d79710b5d9eb0bf94a704 Mon Sep 17 00:00:00 2001 From: Aiga115 Date: Mon, 21 Apr 2025 22:36:16 +0200 Subject: [PATCH 09/11] ILEX-91-B finish connection to api call --- src/api/endpoints/apiActions.ts | 38 ++----- src/api/endpoints/apiService.ts | 20 +++- src/components/common/OrganizationsList.jsx | 4 +- src/components/organizations/index.jsx | 109 ++++++++++---------- src/config.js | 3 +- 5 files changed, 83 insertions(+), 91 deletions(-) diff --git a/src/api/endpoints/apiActions.ts b/src/api/endpoints/apiActions.ts index e9a3b961..df86c7f4 100644 --- a/src/api/endpoints/apiActions.ts +++ b/src/api/endpoints/apiActions.ts @@ -10,35 +10,12 @@ export const createPostRequest = (endpoint: string, contentTyp return (data?: D, options?: SecondParameter) => { return customInstance( { - url: API_CONFIG.BASE_URL + endpoint, + url: endpoint, method: "POST", data: data, headers: { "Content-Type": contentType, }, - }, - options, - ) - } -} - -export const createPostRequestAnother = (endpoint: string, contentType = "application/json") => { - return (data?: any, options?: SecondParameter) => { - console.log("data session: ", data.session) - return customInstance( - { - url: "https://uri.olympiangods.org/aigul/priv/org-new", - method: "POST", - // data: "a test", - headers: { - "Content-Type": contentType, - "session": data.session, - "Access-Control-Allow-Origin": "http://127.0.0.1:5173", - // "Access-Control-Allow-Credentials": "true", - // "Access-Control-Allow-Headers": "content-type", - // "Access-Control-Allow-Methods": "PUT, POST, GET, DELETE, PATCH, OPTIONS", - // "Cookie": `session=${data.session}` - }, withCredentials: true }, options, @@ -49,10 +26,11 @@ export const createPostRequestAnother = (endpoint: string, con export const createGetRequest = (endpoint: string, contentType?: string) => { return (params?: P, options?: SecondParameter, signal?: AbortSignal) => { const config: AxiosRequestConfig = { - url: API_CONFIG.BASE_URL + endpoint, + url: endpoint, method: "GET", - params, - signal, + // params, + // signal, + withCredentials: true } if (contentType) { @@ -61,7 +39,9 @@ export const createGetRequest = (endpoint: string, contentType "Content-Type": contentType, } } - - return customInstance(config, options) + + return customInstance(config, options).then(response => { + return response; + }); } } \ No newline at end of file diff --git a/src/api/endpoints/apiService.ts b/src/api/endpoints/apiService.ts index 8d0c6fa4..a7a322f2 100644 --- a/src/api/endpoints/apiService.ts +++ b/src/api/endpoints/apiService.ts @@ -1,5 +1,7 @@ -import { createPostRequest, createPostRequestAnother } from "./apiActions"; +import React from "react"; +import { createPostRequest, createGetRequest } from "./apiActions"; import { API_CONFIG } from "../../config"; +import { GlobalDataContext } from "../../contexts/DataContext"; export interface LoginRequest { username: string @@ -18,4 +20,18 @@ export interface RegisterRequest { export const login = createPostRequest(API_CONFIG.REAL_API.SIGNIN, "application/x-www-form-urlencoded") export const register = createPostRequest(API_CONFIG.REAL_API.NEWUSER_ILX, "application/x-www-form-urlencoded") -export const getOrganizations = createPostRequestAnother(API_CONFIG.REAL_API.GET_ORGANIZATIONS, "application/json"); \ No newline at end of file +export const createNewOrganization = ({group, data} : {group: string, data: any}) => { + const endpoint = `/${group}${API_CONFIG.REAL_API.CREATE_NEW_ORGANIZATION}`; + return createPostRequest(endpoint, "application/json")(data); +}; + +// export const getOrganizations = (group: string) => { +// const endpoint = `/${group}${API_CONFIG.REAL_API.GET_ORGANIZATIONS}`; +// return createGetRequest(endpoint)(); +// }; + +export const getOrganizations = (group: string) => { + console.log("group: ", group) + const endpoint = `/${group}${API_CONFIG.REAL_API.GET_ORGANIZATIONS}`; + return createGetRequest(endpoint, "application/json")(); +}; \ No newline at end of file diff --git a/src/components/common/OrganizationsList.jsx b/src/components/common/OrganizationsList.jsx index d70ba765..0da0e8b3 100644 --- a/src/components/common/OrganizationsList.jsx +++ b/src/components/common/OrganizationsList.jsx @@ -73,7 +73,7 @@ const OrganizationsList = ({organizations, viewJoinButton = true}) => { } } }}> - { + {organizations.length > 0 && ( organizations?.map((organization, index) => ( navigate(`/organizations/${organization.name}`)}> @@ -104,7 +104,7 @@ const OrganizationsList = ({organizations, viewJoinButton = true}) => { } secondary={organization.description} /> )) - } + )} ); } diff --git a/src/components/organizations/index.jsx b/src/components/organizations/index.jsx index 164a7af0..c2eeb210 100644 --- a/src/components/organizations/index.jsx +++ b/src/components/organizations/index.jsx @@ -1,11 +1,9 @@ -import {useEffect, useState } from "react"; -import { newOrganization } from "../../api/endpoints"; +import { useEffect, useState } from "react"; import OrganizationsList from "../common/OrganizationsList"; import { Box, Typography, CircularProgress, Stack, Button, Link } from "@mui/material"; import BasicDialog from "../common/BasicDialog"; import GroupAddOutlinedIcon from "@mui/icons-material/GroupAddOutlined"; -import { getOrganizations } from "../../api/endpoints/apiService"; -import { useCookies } from 'react-cookie' +import { createNewOrganization, getOrganizations } from "../../api/endpoints/apiService"; import { vars } from "../../theme/variables"; const { gray600, gray700, brand700, brand800 } = vars; @@ -23,18 +21,27 @@ const Organizations = () => { const [organizations, setOrganizations] = useState([]); const [loading, setLoading] = useState(false); const [open, setOpen] = useState(false); - const [cookies, setCookie] = useCookies(['session']); + const [message, setMessage] = useState(); const fetchOrganizations = async() => { - const organizations = await getOrganizations() - setLoading(false) + setLoading(true); + + try { + const response = await getOrganizations("aigul") + if(response.length > 0){ + setOrganizations(response) + } + } catch (err) { + console.log('An unknown error occurred: ', err); + } finally { + setLoading(false); + } } - // useEffect( () => { - // setLoading(true) - // fetchOrganizations(); - // newOrganization("aigul"); - // }, []); + useEffect( () => { + setLoading(true) + fetchOrganizations(); + }, []); const handleOpen = () => { setOpen(true); @@ -44,39 +51,27 @@ const Organizations = () => { setOpen(false); }; - const handleSubmit = async (e) => { - e.preventDefault(); + const createOrganization = async (event) => { + event.preventDefault(); setLoading(true); - // setError(null); try { - // Your API URL and cookie details - const apiUrl = '/dariodippi/priv/org-new'; - // const cookieName = 'authCookie'; - - const response = await fetch(apiUrl, { - method: 'POST', - headers: { - 'Content-Type': 'application/json', - }, - credentials: 'include', - body: "a test" - }); - // const response = getOrganizations(cookies) + const response = await createNewOrganization({ group: "aigul", data: "a test" }) + console.log("response: ", response) - if (!response.ok) { - throw new Error(`API error: ${response.status}`); - } - const data = await response.json(); - console.log("data: ", data) - // setResponse(data); } catch (err) { console.log('An unknown error occurred: ', err); + + console.log("error.res.status: ", err.response.status) + if(err.response.status === 501) { + setMessage(err.response.data) + } } finally { setLoading(false); } + + handleOpen() } - console.log("cookies: ", cookies) if (loading) { return @@ -87,30 +82,30 @@ const Organizations = () => { return ( - {/* + {organizations?.length} Organizations - */} - - - {/* */} - - - Creating an organization requires the help of an admin. Please reach out to {' '} - - organisation@interlex.org - - {' '} for assistance. - + + + + {message && ( + + + {message?.split(/(\S+@\S+\.\S+)/).map((part, i) => + part.match(/\S+@\S+\.\S+/) ? {part} : part + )} + + + )} ); } diff --git a/src/config.js b/src/config.js index 0672f64c..8873acc4 100644 --- a/src/config.js +++ b/src/config.js @@ -27,7 +27,8 @@ export const API_CONFIG = { ORCID_SIGNIN: "/u/ops/orcid-new", NEWUSER_ILX: "/u/ops/user-new", NEWUSER_ORCID: "/u/ops/orcid-new", - GET_ORGANIZATIONS: "/priv/org-new", + CREATE_NEW_ORGANIZATION: "/priv/org-new", + GET_ORGANIZATIONS: "/priv/role-other" }, OLYMPIAN_GODS : "https://uri.olympiangods.org", BASE_SCICRUNCH_URL: "/api/elasticsearch?apikey=", From 7c719e88606d8b289a28a3dc5a34d2f4ded21fe5 Mon Sep 17 00:00:00 2001 From: Aiga115 Date: Mon, 21 Apr 2025 23:00:31 +0200 Subject: [PATCH 10/11] ILEX-91-B make groupname common --- src/components/organizations/index.jsx | 7 +++++-- 1 file changed, 5 insertions(+), 2 deletions(-) diff --git a/src/components/organizations/index.jsx b/src/components/organizations/index.jsx index c2eeb210..cac635b0 100644 --- a/src/components/organizations/index.jsx +++ b/src/components/organizations/index.jsx @@ -23,11 +23,14 @@ const Organizations = () => { const [open, setOpen] = useState(false); const [message, setMessage] = useState(); + // TODO: change this to be dynamic when we get the response from api call + const groupname = "aigul" + const fetchOrganizations = async() => { setLoading(true); try { - const response = await getOrganizations("aigul") + const response = await getOrganizations(groupname) if(response.length > 0){ setOrganizations(response) } @@ -56,7 +59,7 @@ const Organizations = () => { setLoading(true); try { - const response = await createNewOrganization({ group: "aigul", data: "a test" }) + const response = await createNewOrganization({ group: groupname, data: "a test" }) console.log("response: ", response) } catch (err) { From 2d24fc756de21db56c4011f1079dc9d651dd8f80 Mon Sep 17 00:00:00 2001 From: Aiga115 Date: Tue, 22 Apr 2025 12:43:00 +0200 Subject: [PATCH 11/11] ILEX-91-B clean up the code --- src/api/endpoints/apiActions.ts | 4 ++-- src/api/endpoints/apiService.ts | 6 ------ src/api/endpoints/index.ts | 1 - src/components/Auth/Login.jsx | 1 - src/components/organizations/index.jsx | 8 ++++---- 5 files changed, 6 insertions(+), 14 deletions(-) diff --git a/src/api/endpoints/apiActions.ts b/src/api/endpoints/apiActions.ts index df86c7f4..5210009f 100644 --- a/src/api/endpoints/apiActions.ts +++ b/src/api/endpoints/apiActions.ts @@ -28,8 +28,8 @@ export const createGetRequest = (endpoint: string, contentType const config: AxiosRequestConfig = { url: endpoint, method: "GET", - // params, - // signal, + params, + signal, withCredentials: true } diff --git a/src/api/endpoints/apiService.ts b/src/api/endpoints/apiService.ts index a7a322f2..50b9e820 100644 --- a/src/api/endpoints/apiService.ts +++ b/src/api/endpoints/apiService.ts @@ -25,13 +25,7 @@ export const createNewOrganization = ({group, data} : {group: string, data: any} return createPostRequest(endpoint, "application/json")(data); }; -// export const getOrganizations = (group: string) => { -// const endpoint = `/${group}${API_CONFIG.REAL_API.GET_ORGANIZATIONS}`; -// return createGetRequest(endpoint)(); -// }; - export const getOrganizations = (group: string) => { - console.log("group: ", group) const endpoint = `/${group}${API_CONFIG.REAL_API.GET_ORGANIZATIONS}`; return createGetRequest(endpoint, "application/json")(); }; \ No newline at end of file diff --git a/src/api/endpoints/index.ts b/src/api/endpoints/index.ts index e51b7d0a..cba7a7d1 100644 --- a/src/api/endpoints/index.ts +++ b/src/api/endpoints/index.ts @@ -54,7 +54,6 @@ export const newOrganization = async (organization) => { /** Call Endpoint */ return postPrivOrgNew(organization).then((response) => { - console.log("Post new organization ", response) return response }) .catch((error) => { diff --git a/src/components/Auth/Login.jsx b/src/components/Auth/Login.jsx index 40945384..698abcdf 100644 --- a/src/components/Auth/Login.jsx +++ b/src/components/Auth/Login.jsx @@ -49,7 +49,6 @@ const Login = () => { if (!e.data || !e.data.orcid_meta) return; // TODO: get the session cookie when here and add it to our domain. // also store the user info once logged from here in the local storage for future usage. - console.log(e.data); const { code, orcid_meta, cookies } = e.data; const _cookies = JSON.parse(cookies); // create a cookie with the name "session" and the value of the session cookie diff --git a/src/components/organizations/index.jsx b/src/components/organizations/index.jsx index cac635b0..8f5a8e73 100644 --- a/src/components/organizations/index.jsx +++ b/src/components/organizations/index.jsx @@ -35,7 +35,7 @@ const Organizations = () => { setOrganizations(response) } } catch (err) { - console.log('An unknown error occurred: ', err); + console.error('An unknown error occurred: ', err); } finally { setLoading(false); } @@ -59,11 +59,11 @@ const Organizations = () => { setLoading(true); try { + // eslint-disable-next-line no-unused-vars const response = await createNewOrganization({ group: groupname, data: "a test" }) - console.log("response: ", response) } catch (err) { - console.log('An unknown error occurred: ', err); + console.error('An unknown error occurred: ', err); console.log("error.res.status: ", err.response.status) if(err.response.status === 501) { @@ -88,7 +88,7 @@ const Organizations = () => { {organizations?.length} Organizations - + {message && (