@squonk/account-server-client 0.1.5-rc.2 → 0.1.8-rc.1

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (42) hide show
  1. package/{custom-instance-d8cc704b.d.ts → custom-instance-cc5da68e.d.ts} +169 -120
  2. package/index.cjs +103 -2
  3. package/index.cjs.map +3 -3
  4. package/index.d.ts +1 -1
  5. package/index.js +69 -2
  6. package/index.js.map +3 -3
  7. package/organisation/organisation.cjs +111 -2
  8. package/organisation/organisation.cjs.map +3 -3
  9. package/organisation/organisation.d.ts +28 -123
  10. package/organisation/organisation.js +83 -2
  11. package/organisation/organisation.js.map +3 -3
  12. package/organisation/package.json +2 -1
  13. package/package.json +8 -8
  14. package/product/package.json +2 -1
  15. package/product/product.cjs +161 -2
  16. package/product/product.cjs.map +3 -3
  17. package/product/product.d.ts +60 -241
  18. package/product/product.js +127 -2
  19. package/product/product.js.map +3 -3
  20. package/src/account-server-api.schemas.ts +278 -0
  21. package/src/custom-instance.ts +52 -0
  22. package/src/index.ts +6 -0
  23. package/src/organisation/organisation.ts +181 -0
  24. package/src/product/product.ts +289 -0
  25. package/src/unit/unit.ts +322 -0
  26. package/src/user/user.ts +340 -0
  27. package/unit/package.json +2 -1
  28. package/unit/unit.cjs +168 -2
  29. package/unit/unit.cjs.map +3 -3
  30. package/unit/unit.d.ts +58 -122
  31. package/unit/unit.js +133 -2
  32. package/unit/unit.js.map +3 -3
  33. package/user/package.json +2 -1
  34. package/user/user.cjs +176 -2
  35. package/user/user.cjs.map +3 -3
  36. package/user/user.d.ts +20 -246
  37. package/user/user.js +141 -2
  38. package/user/user.js.map +3 -3
  39. package/chunk-OULWOQLW.cjs +0 -2
  40. package/chunk-OULWOQLW.cjs.map +0 -7
  41. package/chunk-WMX3LCLR.js +0 -2
  42. package/chunk-WMX3LCLR.js.map +0 -7
package/user/user.cjs.map CHANGED
@@ -1,7 +1,7 @@
1
1
  {
2
2
  "version": 3,
3
- "sources": ["../../src/user/user.ts"],
4
- "sourcesContent": ["/**\n * Generated by orval v6.3.0 \uD83C\uDF7A\n * Do not edit manually.\n * Account Server API\n * The Informatics Matters Account Server API.\n\nA service that provides access to the Account Server, which gives *registered* users access to **Products**, **Organisations**, **Units** and **Users**.\n\n * OpenAPI spec version: 0.1\n */\nimport {\n useQuery,\n useMutation,\n UseQueryOptions,\n UseMutationOptions,\n QueryFunction,\n MutationFunction,\n} from \"react-query\";\nimport type { UsersGetResponse, Error } from \"../account-server-api.schemas\";\nimport { customInstance } from \".././custom-instance\";\n\ntype AsyncReturnType<T extends (...args: any) => Promise<any>> = T extends (\n ...args: any\n) => Promise<infer R>\n ? R\n : any;\n\ntype SecondParameter<T extends (...args: any) => any> = T extends (\n config: any,\n args: infer P\n) => any\n ? P\n : never;\n\n/**\n * Gets users in an organisation\n\n * @summary Gets users in an organisation\n */\nexport const getOrganisationUsers = (\n orgid: string,\n options?: SecondParameter<typeof customInstance>\n) => {\n return customInstance<UsersGetResponse>(\n { url: `/organisation/${orgid}/user`, method: \"get\" },\n options\n );\n};\n\nexport const getGetOrganisationUsersQueryKey = (orgid: string) => [\n `/organisation/${orgid}/user`,\n];\n\nexport const useGetOrganisationUsers = <\n TData = AsyncReturnType<typeof getOrganisationUsers>,\n TError = Error | void\n>(\n orgid: string,\n options?: {\n query?: UseQueryOptions<\n AsyncReturnType<typeof getOrganisationUsers>,\n TError,\n TData\n >;\n request?: SecondParameter<typeof customInstance>;\n }\n) => {\n const { query: queryOptions, request: requestOptions } = options || {};\n\n const queryKey =\n queryOptions?.queryKey ?? getGetOrganisationUsersQueryKey(orgid);\n\n const queryFn: QueryFunction<AsyncReturnType<typeof getOrganisationUsers>> =\n () => getOrganisationUsers(orgid, requestOptions);\n\n const query = useQuery<\n AsyncReturnType<typeof getOrganisationUsers>,\n TError,\n TData\n >(queryKey, queryFn, { enabled: !!orgid, ...queryOptions });\n\n return {\n queryKey,\n ...query,\n };\n};\n\n/**\n * Adds a user to an organisation\n\n * @summary Adds a user to an organisation\n */\nexport const addOrganisationUser = (\n orgid: string,\n userid: string,\n options?: SecondParameter<typeof customInstance>\n) => {\n return customInstance<void>(\n {\n url: `/organisation/${orgid}/user/${userid}`,\n method: \"put\",\n data: undefined,\n },\n options\n );\n};\n\nexport const useAddOrganisationUser = <\n TError = Error,\n TContext = unknown\n>(options?: {\n mutation?: UseMutationOptions<\n AsyncReturnType<typeof addOrganisationUser>,\n TError,\n { orgid: string; userid: string },\n TContext\n >;\n request?: SecondParameter<typeof customInstance>;\n}) => {\n const { mutation: mutationOptions, request: requestOptions } = options || {};\n\n const mutationFn: MutationFunction<\n AsyncReturnType<typeof addOrganisationUser>,\n { orgid: string; userid: string }\n > = (props) => {\n const { orgid, userid } = props || {};\n\n return addOrganisationUser(orgid, userid, requestOptions);\n };\n\n return useMutation<\n AsyncReturnType<typeof addOrganisationUser>,\n TError,\n { orgid: string; userid: string },\n TContext\n >(mutationFn, mutationOptions);\n};\n/**\n * Removes a user to an organisation\n\n * @summary Deletes a user from an organisation\n */\nexport const deleteOrganisationUser = (\n orgid: string,\n userid: string,\n options?: SecondParameter<typeof customInstance>\n) => {\n return customInstance<void>(\n { url: `/organisation/${orgid}/user/${userid}`, method: \"delete\" },\n options\n );\n};\n\nexport const useDeleteOrganisationUser = <\n TError = Error,\n TContext = unknown\n>(options?: {\n mutation?: UseMutationOptions<\n AsyncReturnType<typeof deleteOrganisationUser>,\n TError,\n { orgid: string; userid: string },\n TContext\n >;\n request?: SecondParameter<typeof customInstance>;\n}) => {\n const { mutation: mutationOptions, request: requestOptions } = options || {};\n\n const mutationFn: MutationFunction<\n AsyncReturnType<typeof deleteOrganisationUser>,\n { orgid: string; userid: string }\n > = (props) => {\n const { orgid, userid } = props || {};\n\n return deleteOrganisationUser(orgid, userid, requestOptions);\n };\n\n return useMutation<\n AsyncReturnType<typeof deleteOrganisationUser>,\n TError,\n { orgid: string; userid: string },\n TContext\n >(mutationFn, mutationOptions);\n};\n/**\n * Gets users in an Organisational Unit\n\n * @summary Gets users in an Organisational Unit\n */\nexport const getOrganisationUnitUsers = (\n unitid: string,\n options?: SecondParameter<typeof customInstance>\n) => {\n return customInstance<UsersGetResponse>(\n { url: `/unit/${unitid}/user`, method: \"get\" },\n options\n );\n};\n\nexport const getGetOrganisationUnitUsersQueryKey = (unitid: string) => [\n `/unit/${unitid}/user`,\n];\n\nexport const useGetOrganisationUnitUsers = <\n TData = AsyncReturnType<typeof getOrganisationUnitUsers>,\n TError = Error | void\n>(\n unitid: string,\n options?: {\n query?: UseQueryOptions<\n AsyncReturnType<typeof getOrganisationUnitUsers>,\n TError,\n TData\n >;\n request?: SecondParameter<typeof customInstance>;\n }\n) => {\n const { query: queryOptions, request: requestOptions } = options || {};\n\n const queryKey =\n queryOptions?.queryKey ?? getGetOrganisationUnitUsersQueryKey(unitid);\n\n const queryFn: QueryFunction<\n AsyncReturnType<typeof getOrganisationUnitUsers>\n > = () => getOrganisationUnitUsers(unitid, requestOptions);\n\n const query = useQuery<\n AsyncReturnType<typeof getOrganisationUnitUsers>,\n TError,\n TData\n >(queryKey, queryFn, { enabled: !!unitid, ...queryOptions });\n\n return {\n queryKey,\n ...query,\n };\n};\n\n/**\n * Adds a user to an Organisationall Unit\n\n * @summary Adds a user to an Organisational Unit\n */\nexport const addOrganisationUnitUser = (\n unitid: string,\n userid: string,\n options?: SecondParameter<typeof customInstance>\n) => {\n return customInstance<void>(\n { url: `/unit/${unitid}/user/${userid}`, method: \"put\", data: undefined },\n options\n );\n};\n\nexport const useAddOrganisationUnitUser = <\n TError = Error,\n TContext = unknown\n>(options?: {\n mutation?: UseMutationOptions<\n AsyncReturnType<typeof addOrganisationUnitUser>,\n TError,\n { unitid: string; userid: string },\n TContext\n >;\n request?: SecondParameter<typeof customInstance>;\n}) => {\n const { mutation: mutationOptions, request: requestOptions } = options || {};\n\n const mutationFn: MutationFunction<\n AsyncReturnType<typeof addOrganisationUnitUser>,\n { unitid: string; userid: string }\n > = (props) => {\n const { unitid, userid } = props || {};\n\n return addOrganisationUnitUser(unitid, userid, requestOptions);\n };\n\n return useMutation<\n AsyncReturnType<typeof addOrganisationUnitUser>,\n TError,\n { unitid: string; userid: string },\n TContext\n >(mutationFn, mutationOptions);\n};\n/**\n * Removes a user to an Organisational Unit\n\n * @summary Deletes a user from an Organisational Unit\n */\nexport const deleteOrganisationUnitUser = (\n unitid: string,\n userid: string,\n options?: SecondParameter<typeof customInstance>\n) => {\n return customInstance<void>(\n { url: `/unit/${unitid}/user/${userid}`, method: \"delete\" },\n options\n );\n};\n\nexport const useDeleteOrganisationUnitUser = <\n TError = Error,\n TContext = unknown\n>(options?: {\n mutation?: UseMutationOptions<\n AsyncReturnType<typeof deleteOrganisationUnitUser>,\n TError,\n { unitid: string; userid: string },\n TContext\n >;\n request?: SecondParameter<typeof customInstance>;\n}) => {\n const { mutation: mutationOptions, request: requestOptions } = options || {};\n\n const mutationFn: MutationFunction<\n AsyncReturnType<typeof deleteOrganisationUnitUser>,\n { unitid: string; userid: string }\n > = (props) => {\n const { unitid, userid } = props || {};\n\n return deleteOrganisationUnitUser(unitid, userid, requestOptions);\n };\n\n return useMutation<\n AsyncReturnType<typeof deleteOrganisationUnitUser>,\n TError,\n { unitid: string; userid: string },\n TContext\n >(mutationFn, mutationOptions);\n};\n"],
5
- "mappings": "iDAUA,wDA6BO,GAAM,GAAuB,CAClC,EACA,IAEO,EACL,CAAE,IAAK,iBAAiB,SAAc,OAAQ,OAC9C,GAIS,EAAkC,AAAC,GAAkB,CAChE,iBAAiB,UAGN,EAA0B,CAIrC,EACA,IAQG,CAlEL,MAmEE,GAAM,CAAE,MAAO,EAAc,QAAS,GAAmB,GAAW,GAE9D,EACJ,oBAAc,WAAd,OAA0B,EAAgC,GAKtD,EAAQ,EAIZ,EANA,IAAM,EAAqB,EAAO,GAMf,GAAE,QAAS,CAAC,CAAC,GAAU,IAE5C,MAAO,IACL,YACG,IASM,EAAsB,CACjC,EACA,EACA,IAEO,EACL,C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G3C,GAQI,CACJ,GAAM,CAAE,SAAU,EAAiB,QAAS,GAAmB,GAAW,GAW1E,MAAO,GANH,AAAC,GAAU,CACb,GAAM,CAAE,SAAQ,UAAW,GAAS,GAEpC,MAAO,GAA2B,EAAQ,EAAQ,IAQtC",
3
+ "sources": ["../../src/user/user.ts", "../../src/custom-instance.ts"],
4
+ "sourcesContent": ["/**\n * Generated by orval v6.4.2 \uD83C\uDF7A\n * Do not edit manually.\n * Account Server API\n * The Informatics Matters Account Server API.\n\nA service that provides access to the Account Server, which gives *registered* users access to and management of **Products**, **Organisations**, **Units** and **Users**.\n\n * OpenAPI spec version: 0.1\n */\nimport {\n useQuery,\n useMutation,\n UseQueryOptions,\n UseMutationOptions,\n QueryFunction,\n MutationFunction,\n UseQueryResult,\n QueryKey,\n} from \"react-query\";\nimport type { UsersGetResponse, AsError } from \"../account-server-api.schemas\";\nimport { customInstance, ErrorType } from \".././custom-instance\";\n\ntype AsyncReturnType<T extends (...args: any) => Promise<any>> = T extends (\n ...args: any\n) => Promise<infer R>\n ? R\n : any;\n\ntype SecondParameter<T extends (...args: any) => any> = T extends (\n config: any,\n args: infer P\n) => any\n ? P\n : never;\n\n/**\n * Gets users in an Organisation. You have to be in the Organisation or an Admin user to use this endpoint\n\n * @summary Gets users in an organisation\n */\nexport const getOrganisationUsers = (\n orgid: string,\n options?: SecondParameter<typeof customInstance>\n) => {\n return customInstance<UsersGetResponse>(\n { url: `/organisation/${orgid}/user`, method: \"get\" },\n options\n );\n};\n\nexport const getGetOrganisationUsersQueryKey = (orgid: string) => [\n `/organisation/${orgid}/user`,\n];\n\nexport const useGetOrganisationUsers = <\n TData = AsyncReturnType<typeof getOrganisationUsers>,\n TError = ErrorType<AsError | void>\n>(\n orgid: string,\n options?: {\n query?: UseQueryOptions<\n AsyncReturnType<typeof getOrganisationUsers>,\n TError,\n TData\n >;\n request?: SecondParameter<typeof customInstance>;\n }\n): UseQueryResult<TData, TError> & { queryKey: QueryKey } => {\n const { query: queryOptions, request: requestOptions } = options || {};\n\n const queryKey =\n queryOptions?.queryKey ?? getGetOrganisationUsersQueryKey(orgid);\n\n const queryFn: QueryFunction<\n AsyncReturnType<typeof getOrganisationUsers>\n > = () => getOrganisationUsers(orgid, requestOptions);\n\n const query = useQuery<\n AsyncReturnType<typeof getOrganisationUsers>,\n TError,\n TData\n >(queryKey, queryFn, { enabled: !!orgid, ...queryOptions });\n\n return {\n queryKey,\n ...query,\n };\n};\n\n/**\n * Adds a user to an organisation. You have to be in the Organisation or an Admin user to use this endpoint\n\n * @summary Adds a user to an organisation\n */\nexport const addOrganisationUser = (\n orgid: string,\n userid: string,\n options?: SecondParameter<typeof customInstance>\n) => {\n return customInstance<void>(\n {\n url: `/organisation/${orgid}/user/${userid}`,\n method: \"put\",\n data: undefined,\n },\n options\n );\n};\n\nexport const useAddOrganisationUser = <\n TError = ErrorType<AsError>,\n TContext = unknown\n>(options?: {\n mutation?: UseMutationOptions<\n AsyncReturnType<typeof addOrganisationUser>,\n TError,\n { orgid: string; userid: string },\n TContext\n >;\n request?: SecondParameter<typeof customInstance>;\n}) => {\n const { mutation: mutationOptions, request: requestOptions } = options || {};\n\n const mutationFn: MutationFunction<\n AsyncReturnType<typeof addOrganisationUser>,\n { orgid: string; userid: string }\n > = (props) => {\n const { orgid, userid } = props || {};\n\n return addOrganisationUser(orgid, userid, requestOptions);\n };\n\n return useMutation<\n AsyncReturnType<typeof addOrganisationUser>,\n TError,\n { orgid: string; userid: string },\n TContext\n >(mutationFn, mutationOptions);\n};\n/**\n * Removes a user from an organisation. You have to be in the Organisation or an Admin user to use this endpoint\n\n * @summary Deletes a user from an organisation\n */\nexport const deleteOrganisationUser = (\n orgid: string,\n userid: string,\n options?: SecondParameter<typeof customInstance>\n) => {\n return customInstance<void>(\n {\n url: `/organisation/${orgid}/user/${userid}`,\n method: \"delete\",\n data: undefined,\n },\n options\n );\n};\n\nexport const useDeleteOrganisationUser = <\n TError = ErrorType<AsError>,\n TContext = unknown\n>(options?: {\n mutation?: UseMutationOptions<\n AsyncReturnType<typeof deleteOrganisationUser>,\n TError,\n { orgid: string; userid: string },\n TContext\n >;\n request?: SecondParameter<typeof customInstance>;\n}) => {\n const { mutation: mutationOptions, request: requestOptions } = options || {};\n\n const mutationFn: MutationFunction<\n AsyncReturnType<typeof deleteOrganisationUser>,\n { orgid: string; userid: string }\n > = (props) => {\n const { orgid, userid } = props || {};\n\n return deleteOrganisationUser(orgid, userid, requestOptions);\n };\n\n return useMutation<\n AsyncReturnType<typeof deleteOrganisationUser>,\n TError,\n { orgid: string; userid: string },\n TContext\n >(mutationFn, mutationOptions);\n};\n/**\n * Gets users in an Organisational Unit. You have to be in the Organisation or Unit or an Admin user to use this endpoint\n\n * @summary Gets users in an Organisational Unit\n */\nexport const getOrganisationUnitUsers = (\n unitid: string,\n options?: SecondParameter<typeof customInstance>\n) => {\n return customInstance<UsersGetResponse>(\n { url: `/unit/${unitid}/user`, method: \"get\" },\n options\n );\n};\n\nexport const getGetOrganisationUnitUsersQueryKey = (unitid: string) => [\n `/unit/${unitid}/user`,\n];\n\nexport const useGetOrganisationUnitUsers = <\n TData = AsyncReturnType<typeof getOrganisationUnitUsers>,\n TError = ErrorType<AsError | void>\n>(\n unitid: string,\n options?: {\n query?: UseQueryOptions<\n AsyncReturnType<typeof getOrganisationUnitUsers>,\n TError,\n TData\n >;\n request?: SecondParameter<typeof customInstance>;\n }\n): UseQueryResult<TData, TError> & { queryKey: QueryKey } => {\n const { query: queryOptions, request: requestOptions } = options || {};\n\n const queryKey =\n queryOptions?.queryKey ?? getGetOrganisationUnitUsersQueryKey(unitid);\n\n const queryFn: QueryFunction<\n AsyncReturnType<typeof getOrganisationUnitUsers>\n > = () => getOrganisationUnitUsers(unitid, requestOptions);\n\n const query = useQuery<\n AsyncReturnType<typeof getOrganisationUnitUsers>,\n TError,\n TData\n >(queryKey, queryFn, { enabled: !!unitid, ...queryOptions });\n\n return {\n queryKey,\n ...query,\n };\n};\n\n/**\n * Adds a user to an Organisationall Unit. You have to be in the Organisation or Unit or an Admin user to use this endpoint\n\n * @summary Adds a user to an Organisational Unit\n */\nexport const addOrganisationUnitUser = (\n unitid: string,\n userid: string,\n options?: SecondParameter<typeof customInstance>\n) => {\n return customInstance<void>(\n { url: `/unit/${unitid}/user/${userid}`, method: \"put\", data: undefined },\n options\n );\n};\n\nexport const useAddOrganisationUnitUser = <\n TError = ErrorType<AsError>,\n TContext = unknown\n>(options?: {\n mutation?: UseMutationOptions<\n AsyncReturnType<typeof addOrganisationUnitUser>,\n TError,\n { unitid: string; userid: string },\n TContext\n >;\n request?: SecondParameter<typeof customInstance>;\n}) => {\n const { mutation: mutationOptions, request: requestOptions } = options || {};\n\n const mutationFn: MutationFunction<\n AsyncReturnType<typeof addOrganisationUnitUser>,\n { unitid: string; userid: string }\n > = (props) => {\n const { unitid, userid } = props || {};\n\n return addOrganisationUnitUser(unitid, userid, requestOptions);\n };\n\n return useMutation<\n AsyncReturnType<typeof addOrganisationUnitUser>,\n TError,\n { unitid: string; userid: string },\n TContext\n >(mutationFn, mutationOptions);\n};\n/**\n * Removes a user from an Organisational Unit. You have to be in the Organisation or Unit or an Admin user to use this endpoint\n\n * @summary Deletes a user from an Organisational Unit\n */\nexport const deleteOrganisationUnitUser = (\n unitid: string,\n userid: string,\n options?: SecondParameter<typeof customInstance>\n) => {\n return customInstance<void>(\n {\n url: `/unit/${unitid}/user/${userid}`,\n method: \"delete\",\n data: undefined,\n },\n options\n );\n};\n\nexport const useDeleteOrganisationUnitUser = <\n TError = ErrorType<AsError>,\n TContext = unknown\n>(options?: {\n mutation?: UseMutationOptions<\n AsyncReturnType<typeof deleteOrganisationUnitUser>,\n TError,\n { unitid: string; userid: string },\n TContext\n >;\n request?: SecondParameter<typeof customInstance>;\n}) => {\n const { mutation: mutationOptions, request: requestOptions } = options || {};\n\n const mutationFn: MutationFunction<\n AsyncReturnType<typeof deleteOrganisationUnitUser>,\n { unitid: string; userid: string }\n > = (props) => {\n const { unitid, userid } = props || {};\n\n return deleteOrganisationUnitUser(unitid, userid, requestOptions);\n };\n\n return useMutation<\n AsyncReturnType<typeof deleteOrganisationUnitUser>,\n TError,\n { unitid: string; userid: string },\n TContext\n >(mutationFn, mutationOptions);\n};\n", "/** Based off the example custom-instance from Orval docs\n * https://github.com/anymaniax/orval/blob/master/samples/react-app-with-react-query/src/api/mutator/custom-instance.ts\n *\n * See https://react-query.tanstack.com/guides/query-cancellation\n *\n * TODO: Considering using Fetch-API instead of axios. This instance will have to change. Could be\n * achieved without changing much using `redaxios`\n * Or use 'ky'\n */\n\nimport Axios, { AxiosError, AxiosRequestConfig } from 'axios';\n\n// ? Need the baseUrl or does it default to ''?\nexport const AXIOS_INSTANCE = Axios.create({ baseURL: '' });\n\n/**\n * Set the access token to be added as the `Authorization: Bearer 'token'` header\n * Useful for client only apps where a proxy API route isn't involved to securely add the access token\n * @param token access token\n */\nexport const setAuthToken = (token: string) => {\n AXIOS_INSTANCE.defaults.headers.common['Authorization'] = `Bearer ${token}`;\n};\n\n/**\n * Set the url to which request paths are added to.\n * @param baseUrl origin + subpath e.g. 'https://example.com/subpath' or '/subpath'\n */\nexport const setBaseUrl = (baseUrl: string) => {\n AXIOS_INSTANCE.defaults.baseURL = baseUrl;\n};\n\nexport const customInstance = <TReturn>(\n config: AxiosRequestConfig,\n options?: AxiosRequestConfig,\n): Promise<TReturn> => {\n const source = Axios.CancelToken.source();\n\n const promise = AXIOS_INSTANCE({ ...config, ...options, cancelToken: source.token }).then(\n ({ data }) => data,\n );\n\n // Promise doesn't have a cancel method but react-query requires this method to make cancellations general.\n // This can either be a any assertion or a @ts-ignore comment.\n (promise as any).cancel = () => {\n source.cancel('Query was cancelled by React Query');\n };\n\n return promise;\n};\n\nexport type ErrorType<TError> = AxiosError<TError>;\n"],
5
+ "mappings": ";;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAA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AA;AAIG,IAAM,gCAAgC,CAG3C,YAQI;AACJ,QAAM,EAAE,UAAU,iBAAiB,SAAS,mBAAmB,WAAW;AAE1E,QAAM,aAGF,CAAC,UAAU;AACb,UAAM,EAAE,QAAQ,WAAW,SAAS;AAEpC,WAAO,2BAA2B,QAAQ,QAAQ;AAAA;AAGpD,SAAO,oCAKL,YAAY;AAAA;",
6
6
  "names": []
7
7
  }
package/user/user.d.ts CHANGED
@@ -1,142 +1,29 @@
1
1
  import * as react_query from 'react-query';
2
- import { UseQueryOptions, UseMutationOptions } from 'react-query';
3
- import { z as customInstance, U as UsersGetResponse, E as Error } from '../custom-instance-d8cc704b';
2
+ import { UseQueryOptions, QueryKey, UseQueryResult, UseMutationOptions } from 'react-query';
3
+ import { H as customInstance, B as UsersGetResponse, I as ErrorType, D as AsError } from '../custom-instance-cc5da68e';
4
4
  import 'axios';
5
5
 
6
6
  declare type SecondParameter<T extends (...args: any) => any> = T extends (config: any, args: infer P) => any ? P : never;
7
7
  /**
8
- * Gets users in an organisation
8
+ * Gets users in an Organisation. You have to be in the Organisation or an Admin user to use this endpoint
9
9
 
10
10
  * @summary Gets users in an organisation
11
11
  */
12
12
  declare const getOrganisationUsers: (orgid: string, options?: SecondParameter<typeof customInstance>) => Promise<UsersGetResponse>;
13
13
  declare const getGetOrganisationUsersQueryKey: (orgid: string) => string[];
14
- declare const useGetOrganisationUsers: <TData = UsersGetResponse, TError = void | Error>(orgid: string, options?: {
15
- query?: UseQueryOptions<UsersGetResponse, TError, TData, react_query.QueryKey> | undefined;
14
+ declare const useGetOrganisationUsers: <TData = UsersGetResponse, TError = ErrorType<void | AsError>>(orgid: string, options?: {
15
+ query?: UseQueryOptions<UsersGetResponse, TError, TData, QueryKey> | undefined;
16
16
  request?: SecondParameter<typeof customInstance>;
17
- } | undefined) => {
18
- data: undefined;
19
- error: null;
20
- isError: false;
21
- isIdle: true;
22
- isLoading: false;
23
- isLoadingError: false;
24
- isRefetchError: false;
25
- isSuccess: false;
26
- status: "idle";
27
- dataUpdatedAt: number;
28
- errorUpdatedAt: number;
29
- failureCount: number;
30
- isFetched: boolean;
31
- isFetchedAfterMount: boolean;
32
- isFetching: boolean;
33
- isPlaceholderData: boolean;
34
- isPreviousData: boolean;
35
- isRefetching: boolean;
36
- isStale: boolean;
37
- refetch: <TPageData>(options?: (react_query.RefetchOptions & react_query.RefetchQueryFilters<TPageData>) | undefined) => Promise<react_query.QueryObserverResult<TData, TError>>;
38
- remove: () => void;
39
- queryKey: react_query.QueryKey;
40
- } | {
41
- data: undefined;
42
- error: TError;
43
- isError: true;
44
- isIdle: false;
45
- isLoading: false;
46
- isLoadingError: true;
47
- isRefetchError: false;
48
- isSuccess: false;
49
- status: "error";
50
- dataUpdatedAt: number;
51
- errorUpdatedAt: number;
52
- failureCount: number;
53
- isFetched: boolean;
54
- isFetchedAfterMount: boolean;
55
- isFetching: boolean;
56
- isPlaceholderData: boolean;
57
- isPreviousData: boolean;
58
- isRefetching: boolean;
59
- isStale: boolean;
60
- refetch: <TPageData>(options?: (react_query.RefetchOptions & react_query.RefetchQueryFilters<TPageData>) | undefined) => Promise<react_query.QueryObserverResult<TData, TError>>;
61
- remove: () => void;
62
- queryKey: react_query.QueryKey;
63
- } | {
64
- data: undefined;
65
- error: null;
66
- isError: false;
67
- isIdle: false;
68
- isLoading: true;
69
- isLoadingError: false;
70
- isRefetchError: false;
71
- isSuccess: false;
72
- status: "loading";
73
- dataUpdatedAt: number;
74
- errorUpdatedAt: number;
75
- failureCount: number;
76
- isFetched: boolean;
77
- isFetchedAfterMount: boolean;
78
- isFetching: boolean;
79
- isPlaceholderData: boolean;
80
- isPreviousData: boolean;
81
- isRefetching: boolean;
82
- isStale: boolean;
83
- refetch: <TPageData>(options?: (react_query.RefetchOptions & react_query.RefetchQueryFilters<TPageData>) | undefined) => Promise<react_query.QueryObserverResult<TData, TError>>;
84
- remove: () => void;
85
- queryKey: react_query.QueryKey;
86
- } | {
87
- data: TData;
88
- error: TError;
89
- isError: true;
90
- isIdle: false;
91
- isLoading: false;
92
- isLoadingError: false;
93
- isRefetchError: true;
94
- isSuccess: false;
95
- status: "error";
96
- dataUpdatedAt: number;
97
- errorUpdatedAt: number;
98
- failureCount: number;
99
- isFetched: boolean;
100
- isFetchedAfterMount: boolean;
101
- isFetching: boolean;
102
- isPlaceholderData: boolean;
103
- isPreviousData: boolean;
104
- isRefetching: boolean;
105
- isStale: boolean;
106
- refetch: <TPageData>(options?: (react_query.RefetchOptions & react_query.RefetchQueryFilters<TPageData>) | undefined) => Promise<react_query.QueryObserverResult<TData, TError>>;
107
- remove: () => void;
108
- queryKey: react_query.QueryKey;
109
- } | {
110
- data: TData;
111
- error: null;
112
- isError: false;
113
- isIdle: false;
114
- isLoading: false;
115
- isLoadingError: false;
116
- isRefetchError: false;
117
- isSuccess: true;
118
- status: "success";
119
- dataUpdatedAt: number;
120
- errorUpdatedAt: number;
121
- failureCount: number;
122
- isFetched: boolean;
123
- isFetchedAfterMount: boolean;
124
- isFetching: boolean;
125
- isPlaceholderData: boolean;
126
- isPreviousData: boolean;
127
- isRefetching: boolean;
128
- isStale: boolean;
129
- refetch: <TPageData>(options?: (react_query.RefetchOptions & react_query.RefetchQueryFilters<TPageData>) | undefined) => Promise<react_query.QueryObserverResult<TData, TError>>;
130
- remove: () => void;
131
- queryKey: react_query.QueryKey;
17
+ } | undefined) => UseQueryResult<TData, TError> & {
18
+ queryKey: QueryKey;
132
19
  };
133
20
  /**
134
- * Adds a user to an organisation
21
+ * Adds a user to an organisation. You have to be in the Organisation or an Admin user to use this endpoint
135
22
 
136
23
  * @summary Adds a user to an organisation
137
24
  */
138
25
  declare const addOrganisationUser: (orgid: string, userid: string, options?: SecondParameter<typeof customInstance>) => Promise<void>;
139
- declare const useAddOrganisationUser: <TError = Error, TContext = unknown>(options?: {
26
+ declare const useAddOrganisationUser: <TError = ErrorType<AsError>, TContext = unknown>(options?: {
140
27
  mutation?: UseMutationOptions<void, TError, {
141
28
  orgid: string;
142
29
  userid: string;
@@ -147,12 +34,12 @@ declare const useAddOrganisationUser: <TError = Error, TContext = unknown>(optio
147
34
  userid: string;
148
35
  }, TContext>;
149
36
  /**
150
- * Removes a user to an organisation
37
+ * Removes a user from an organisation. You have to be in the Organisation or an Admin user to use this endpoint
151
38
 
152
39
  * @summary Deletes a user from an organisation
153
40
  */
154
41
  declare const deleteOrganisationUser: (orgid: string, userid: string, options?: SecondParameter<typeof customInstance>) => Promise<void>;
155
- declare const useDeleteOrganisationUser: <TError = Error, TContext = unknown>(options?: {
42
+ declare const useDeleteOrganisationUser: <TError = ErrorType<AsError>, TContext = unknown>(options?: {
156
43
  mutation?: UseMutationOptions<void, TError, {
157
44
  orgid: string;
158
45
  userid: string;
@@ -163,138 +50,25 @@ declare const useDeleteOrganisationUser: <TError = Error, TContext = unknown>(op
163
50
  userid: string;
164
51
  }, TContext>;
165
52
  /**
166
- * Gets users in an Organisational Unit
53
+ * Gets users in an Organisational Unit. You have to be in the Organisation or Unit or an Admin user to use this endpoint
167
54
 
168
55
  * @summary Gets users in an Organisational Unit
169
56
  */
170
57
  declare const getOrganisationUnitUsers: (unitid: string, options?: SecondParameter<typeof customInstance>) => Promise<UsersGetResponse>;
171
58
  declare const getGetOrganisationUnitUsersQueryKey: (unitid: string) => string[];
172
- declare const useGetOrganisationUnitUsers: <TData = UsersGetResponse, TError = void | Error>(unitid: string, options?: {
173
- query?: UseQueryOptions<UsersGetResponse, TError, TData, react_query.QueryKey> | undefined;
59
+ declare const useGetOrganisationUnitUsers: <TData = UsersGetResponse, TError = ErrorType<void | AsError>>(unitid: string, options?: {
60
+ query?: UseQueryOptions<UsersGetResponse, TError, TData, QueryKey> | undefined;
174
61
  request?: SecondParameter<typeof customInstance>;
175
- } | undefined) => {
176
- data: undefined;
177
- error: null;
178
- isError: false;
179
- isIdle: true;
180
- isLoading: false;
181
- isLoadingError: false;
182
- isRefetchError: false;
183
- isSuccess: false;
184
- status: "idle";
185
- dataUpdatedAt: number;
186
- errorUpdatedAt: number;
187
- failureCount: number;
188
- isFetched: boolean;
189
- isFetchedAfterMount: boolean;
190
- isFetching: boolean;
191
- isPlaceholderData: boolean;
192
- isPreviousData: boolean;
193
- isRefetching: boolean;
194
- isStale: boolean;
195
- refetch: <TPageData>(options?: (react_query.RefetchOptions & react_query.RefetchQueryFilters<TPageData>) | undefined) => Promise<react_query.QueryObserverResult<TData, TError>>;
196
- remove: () => void;
197
- queryKey: react_query.QueryKey;
198
- } | {
199
- data: undefined;
200
- error: TError;
201
- isError: true;
202
- isIdle: false;
203
- isLoading: false;
204
- isLoadingError: true;
205
- isRefetchError: false;
206
- isSuccess: false;
207
- status: "error";
208
- dataUpdatedAt: number;
209
- errorUpdatedAt: number;
210
- failureCount: number;
211
- isFetched: boolean;
212
- isFetchedAfterMount: boolean;
213
- isFetching: boolean;
214
- isPlaceholderData: boolean;
215
- isPreviousData: boolean;
216
- isRefetching: boolean;
217
- isStale: boolean;
218
- refetch: <TPageData>(options?: (react_query.RefetchOptions & react_query.RefetchQueryFilters<TPageData>) | undefined) => Promise<react_query.QueryObserverResult<TData, TError>>;
219
- remove: () => void;
220
- queryKey: react_query.QueryKey;
221
- } | {
222
- data: undefined;
223
- error: null;
224
- isError: false;
225
- isIdle: false;
226
- isLoading: true;
227
- isLoadingError: false;
228
- isRefetchError: false;
229
- isSuccess: false;
230
- status: "loading";
231
- dataUpdatedAt: number;
232
- errorUpdatedAt: number;
233
- failureCount: number;
234
- isFetched: boolean;
235
- isFetchedAfterMount: boolean;
236
- isFetching: boolean;
237
- isPlaceholderData: boolean;
238
- isPreviousData: boolean;
239
- isRefetching: boolean;
240
- isStale: boolean;
241
- refetch: <TPageData>(options?: (react_query.RefetchOptions & react_query.RefetchQueryFilters<TPageData>) | undefined) => Promise<react_query.QueryObserverResult<TData, TError>>;
242
- remove: () => void;
243
- queryKey: react_query.QueryKey;
244
- } | {
245
- data: TData;
246
- error: TError;
247
- isError: true;
248
- isIdle: false;
249
- isLoading: false;
250
- isLoadingError: false;
251
- isRefetchError: true;
252
- isSuccess: false;
253
- status: "error";
254
- dataUpdatedAt: number;
255
- errorUpdatedAt: number;
256
- failureCount: number;
257
- isFetched: boolean;
258
- isFetchedAfterMount: boolean;
259
- isFetching: boolean;
260
- isPlaceholderData: boolean;
261
- isPreviousData: boolean;
262
- isRefetching: boolean;
263
- isStale: boolean;
264
- refetch: <TPageData>(options?: (react_query.RefetchOptions & react_query.RefetchQueryFilters<TPageData>) | undefined) => Promise<react_query.QueryObserverResult<TData, TError>>;
265
- remove: () => void;
266
- queryKey: react_query.QueryKey;
267
- } | {
268
- data: TData;
269
- error: null;
270
- isError: false;
271
- isIdle: false;
272
- isLoading: false;
273
- isLoadingError: false;
274
- isRefetchError: false;
275
- isSuccess: true;
276
- status: "success";
277
- dataUpdatedAt: number;
278
- errorUpdatedAt: number;
279
- failureCount: number;
280
- isFetched: boolean;
281
- isFetchedAfterMount: boolean;
282
- isFetching: boolean;
283
- isPlaceholderData: boolean;
284
- isPreviousData: boolean;
285
- isRefetching: boolean;
286
- isStale: boolean;
287
- refetch: <TPageData>(options?: (react_query.RefetchOptions & react_query.RefetchQueryFilters<TPageData>) | undefined) => Promise<react_query.QueryObserverResult<TData, TError>>;
288
- remove: () => void;
289
- queryKey: react_query.QueryKey;
62
+ } | undefined) => UseQueryResult<TData, TError> & {
63
+ queryKey: QueryKey;
290
64
  };
291
65
  /**
292
- * Adds a user to an Organisationall Unit
66
+ * Adds a user to an Organisationall Unit. You have to be in the Organisation or Unit or an Admin user to use this endpoint
293
67
 
294
68
  * @summary Adds a user to an Organisational Unit
295
69
  */
296
70
  declare const addOrganisationUnitUser: (unitid: string, userid: string, options?: SecondParameter<typeof customInstance>) => Promise<void>;
297
- declare const useAddOrganisationUnitUser: <TError = Error, TContext = unknown>(options?: {
71
+ declare const useAddOrganisationUnitUser: <TError = ErrorType<AsError>, TContext = unknown>(options?: {
298
72
  mutation?: UseMutationOptions<void, TError, {
299
73
  unitid: string;
300
74
  userid: string;
@@ -305,12 +79,12 @@ declare const useAddOrganisationUnitUser: <TError = Error, TContext = unknown>(o
305
79
  userid: string;
306
80
  }, TContext>;
307
81
  /**
308
- * Removes a user to an Organisational Unit
82
+ * Removes a user from an Organisational Unit. You have to be in the Organisation or Unit or an Admin user to use this endpoint
309
83
 
310
84
  * @summary Deletes a user from an Organisational Unit
311
85
  */
312
86
  declare const deleteOrganisationUnitUser: (unitid: string, userid: string, options?: SecondParameter<typeof customInstance>) => Promise<void>;
313
- declare const useDeleteOrganisationUnitUser: <TError = Error, TContext = unknown>(options?: {
87
+ declare const useDeleteOrganisationUnitUser: <TError = ErrorType<AsError>, TContext = unknown>(options?: {
314
88
  mutation?: UseMutationOptions<void, TError, {
315
89
  unitid: string;
316
90
  userid: string;
package/user/user.js CHANGED
@@ -1,2 +1,141 @@
1
- import{a as y,e as a}from"../chunk-WMX3LCLR.js";import{useQuery as g,useMutation as c}from"react-query";var d=(t,n)=>a({url:`/organisation/${t}/user`,method:"get"},n),p=t=>[`/organisation/${t}/user`],P=(t,n)=>{var u;let{query:e,request:i}=n||{},r=(u=e==null?void 0:e.queryKey)!=null?u:p(t),s=g(r,()=>d(t,i),y({enabled:!!t},e));return y({queryKey:r},s)},m=(t,n,e)=>a({url:`/organisation/${t}/user/${n}`,method:"put",data:void 0},e),I=t=>{let{mutation:n,request:e}=t||{};return c(r=>{let{orgid:o,userid:s}=r||{};return m(o,s,e)},n)},U=(t,n,e)=>a({url:`/organisation/${t}/user/${n}`,method:"delete"},e),S=t=>{let{mutation:n,request:e}=t||{};return c(r=>{let{orgid:o,userid:s}=r||{};return U(o,s,e)},n)},T=(t,n)=>a({url:`/unit/${t}/user`,method:"get"},n),O=t=>[`/unit/${t}/user`],C=(t,n)=>{var u;let{query:e,request:i}=n||{},r=(u=e==null?void 0:e.queryKey)!=null?u:O(t),s=g(r,()=>T(t,i),y({enabled:!!t},e));return y({queryKey:r},s)},f=(t,n,e)=>a({url:`/unit/${t}/user/${n}`,method:"put",data:void 0},e),$=t=>{let{mutation:n,request:e}=t||{};return c(r=>{let{unitid:o,userid:s}=r||{};return f(o,s,e)},n)},q=(t,n,e)=>a({url:`/unit/${t}/user/${n}`,method:"delete"},e),M=t=>{let{mutation:n,request:e}=t||{};return c(r=>{let{unitid:o,userid:s}=r||{};return q(o,s,e)},n)};export{f as addOrganisationUnitUser,m as addOrganisationUser,q as deleteOrganisationUnitUser,U as deleteOrganisationUser,O as getGetOrganisationUnitUsersQueryKey,p as getGetOrganisationUsersQueryKey,T as getOrganisationUnitUsers,d as getOrganisationUsers,$ as useAddOrganisationUnitUser,I as useAddOrganisationUser,M as useDeleteOrganisationUnitUser,S as useDeleteOrganisationUser,C as useGetOrganisationUnitUsers,P as useGetOrganisationUsers};
2
- //# sourceMappingURL=user.js.map
1
+ var __defProp = Object.defineProperty;
2
+ var __defProps = Object.defineProperties;
3
+ var __getOwnPropDescs = Object.getOwnPropertyDescriptors;
4
+ var __getOwnPropSymbols = Object.getOwnPropertySymbols;
5
+ var __hasOwnProp = Object.prototype.hasOwnProperty;
6
+ var __propIsEnum = Object.prototype.propertyIsEnumerable;
7
+ var __defNormalProp = (obj, key, value) => key in obj ? __defProp(obj, key, { enumerable: true, configurable: true, writable: true, value }) : obj[key] = value;
8
+ var __spreadValues = (a, b) => {
9
+ for (var prop in b || (b = {}))
10
+ if (__hasOwnProp.call(b, prop))
11
+ __defNormalProp(a, prop, b[prop]);
12
+ if (__getOwnPropSymbols)
13
+ for (var prop of __getOwnPropSymbols(b)) {
14
+ if (__propIsEnum.call(b, prop))
15
+ __defNormalProp(a, prop, b[prop]);
16
+ }
17
+ return a;
18
+ };
19
+ var __spreadProps = (a, b) => __defProps(a, __getOwnPropDescs(b));
20
+
21
+ // src/user/user.ts
22
+ import {
23
+ useQuery,
24
+ useMutation
25
+ } from "react-query";
26
+
27
+ // src/custom-instance.ts
28
+ import Axios from "axios";
29
+ var AXIOS_INSTANCE = Axios.create({ baseURL: "" });
30
+ var customInstance = (config, options) => {
31
+ const source = Axios.CancelToken.source();
32
+ const promise = AXIOS_INSTANCE(__spreadProps(__spreadValues(__spreadValues({}, config), options), { cancelToken: source.token })).then(({ data }) => data);
33
+ promise.cancel = () => {
34
+ source.cancel("Query was cancelled by React Query");
35
+ };
36
+ return promise;
37
+ };
38
+
39
+ // src/user/user.ts
40
+ var getOrganisationUsers = (orgid, options) => {
41
+ return customInstance({ url: `/organisation/${orgid}/user`, method: "get" }, options);
42
+ };
43
+ var getGetOrganisationUsersQueryKey = (orgid) => [
44
+ `/organisation/${orgid}/user`
45
+ ];
46
+ var useGetOrganisationUsers = (orgid, options) => {
47
+ const { query: queryOptions, request: requestOptions } = options || {};
48
+ const queryKey = (queryOptions == null ? void 0 : queryOptions.queryKey) ?? getGetOrganisationUsersQueryKey(orgid);
49
+ const queryFn = () => getOrganisationUsers(orgid, requestOptions);
50
+ const query = useQuery(queryKey, queryFn, __spreadValues({ enabled: !!orgid }, queryOptions));
51
+ return __spreadValues({
52
+ queryKey
53
+ }, query);
54
+ };
55
+ var addOrganisationUser = (orgid, userid, options) => {
56
+ return customInstance({
57
+ url: `/organisation/${orgid}/user/${userid}`,
58
+ method: "put",
59
+ data: void 0
60
+ }, options);
61
+ };
62
+ var useAddOrganisationUser = (options) => {
63
+ const { mutation: mutationOptions, request: requestOptions } = options || {};
64
+ const mutationFn = (props) => {
65
+ const { orgid, userid } = props || {};
66
+ return addOrganisationUser(orgid, userid, requestOptions);
67
+ };
68
+ return useMutation(mutationFn, mutationOptions);
69
+ };
70
+ var deleteOrganisationUser = (orgid, userid, options) => {
71
+ return customInstance({
72
+ url: `/organisation/${orgid}/user/${userid}`,
73
+ method: "delete",
74
+ data: void 0
75
+ }, options);
76
+ };
77
+ var useDeleteOrganisationUser = (options) => {
78
+ const { mutation: mutationOptions, request: requestOptions } = options || {};
79
+ const mutationFn = (props) => {
80
+ const { orgid, userid } = props || {};
81
+ return deleteOrganisationUser(orgid, userid, requestOptions);
82
+ };
83
+ return useMutation(mutationFn, mutationOptions);
84
+ };
85
+ var getOrganisationUnitUsers = (unitid, options) => {
86
+ return customInstance({ url: `/unit/${unitid}/user`, method: "get" }, options);
87
+ };
88
+ var getGetOrganisationUnitUsersQueryKey = (unitid) => [
89
+ `/unit/${unitid}/user`
90
+ ];
91
+ var useGetOrganisationUnitUsers = (unitid, options) => {
92
+ const { query: queryOptions, request: requestOptions } = options || {};
93
+ const queryKey = (queryOptions == null ? void 0 : queryOptions.queryKey) ?? getGetOrganisationUnitUsersQueryKey(unitid);
94
+ const queryFn = () => getOrganisationUnitUsers(unitid, requestOptions);
95
+ const query = useQuery(queryKey, queryFn, __spreadValues({ enabled: !!unitid }, queryOptions));
96
+ return __spreadValues({
97
+ queryKey
98
+ }, query);
99
+ };
100
+ var addOrganisationUnitUser = (unitid, userid, options) => {
101
+ return customInstance({ url: `/unit/${unitid}/user/${userid}`, method: "put", data: void 0 }, options);
102
+ };
103
+ var useAddOrganisationUnitUser = (options) => {
104
+ const { mutation: mutationOptions, request: requestOptions } = options || {};
105
+ const mutationFn = (props) => {
106
+ const { unitid, userid } = props || {};
107
+ return addOrganisationUnitUser(unitid, userid, requestOptions);
108
+ };
109
+ return useMutation(mutationFn, mutationOptions);
110
+ };
111
+ var deleteOrganisationUnitUser = (unitid, userid, options) => {
112
+ return customInstance({
113
+ url: `/unit/${unitid}/user/${userid}`,
114
+ method: "delete",
115
+ data: void 0
116
+ }, options);
117
+ };
118
+ var useDeleteOrganisationUnitUser = (options) => {
119
+ const { mutation: mutationOptions, request: requestOptions } = options || {};
120
+ const mutationFn = (props) => {
121
+ const { unitid, userid } = props || {};
122
+ return deleteOrganisationUnitUser(unitid, userid, requestOptions);
123
+ };
124
+ return useMutation(mutationFn, mutationOptions);
125
+ };
126
+ export {
127
+ addOrganisationUnitUser,
128
+ addOrganisationUser,
129
+ deleteOrganisationUnitUser,
130
+ deleteOrganisationUser,
131
+ getGetOrganisationUnitUsersQueryKey,
132
+ getGetOrganisationUsersQueryKey,
133
+ getOrganisationUnitUsers,
134
+ getOrganisationUsers,
135
+ useAddOrganisationUnitUser,
136
+ useAddOrganisationUser,
137
+ useDeleteOrganisationUnitUser,
138
+ useDeleteOrganisationUser,
139
+ useGetOrganisationUnitUsers,
140
+ useGetOrganisationUsers
141
+ };
package/user/user.js.map CHANGED
@@ -1,7 +1,7 @@
1
1
  {
2
2
  "version": 3,
3
- "sources": ["../../src/user/user.ts"],
4
- "sourcesContent": ["/**\n * Generated by orval v6.3.0 \uD83C\uDF7A\n * Do not edit manually.\n * Account Server API\n * The Informatics Matters Account Server API.\n\nA service that provides access to the Account Server, which gives *registered* users access to **Products**, **Organisations**, **Units** and **Users**.\n\n * OpenAPI spec version: 0.1\n */\nimport {\n useQuery,\n useMutation,\n UseQueryOptions,\n UseMutationOptions,\n QueryFunction,\n MutationFunction,\n} from \"react-query\";\nimport type { UsersGetResponse, Error } from \"../account-server-api.schemas\";\nimport { customInstance } from \".././custom-instance\";\n\ntype AsyncReturnType<T extends (...args: any) => Promise<any>> = T extends (\n ...args: any\n) => Promise<infer R>\n ? R\n : any;\n\ntype SecondParameter<T extends (...args: any) => any> = T extends (\n config: any,\n args: infer P\n) => any\n ? P\n : never;\n\n/**\n * Gets users in an organisation\n\n * @summary Gets users in an organisation\n */\nexport const getOrganisationUsers = (\n orgid: string,\n options?: SecondParameter<typeof customInstance>\n) => {\n return customInstance<UsersGetResponse>(\n { url: `/organisation/${orgid}/user`, method: \"get\" },\n options\n );\n};\n\nexport const getGetOrganisationUsersQueryKey = (orgid: string) => [\n `/organisation/${orgid}/user`,\n];\n\nexport const useGetOrganisationUsers = <\n TData = AsyncReturnType<typeof getOrganisationUsers>,\n TError = Error | void\n>(\n orgid: string,\n options?: {\n query?: UseQueryOptions<\n AsyncReturnType<typeof getOrganisationUsers>,\n TError,\n TData\n >;\n request?: SecondParameter<typeof customInstance>;\n }\n) => {\n const { query: queryOptions, request: requestOptions } = options || {};\n\n const queryKey =\n queryOptions?.queryKey ?? getGetOrganisationUsersQueryKey(orgid);\n\n const queryFn: QueryFunction<AsyncReturnType<typeof getOrganisationUsers>> =\n () => getOrganisationUsers(orgid, requestOptions);\n\n const query = useQuery<\n AsyncReturnType<typeof getOrganisationUsers>,\n TError,\n TData\n >(queryKey, queryFn, { enabled: !!orgid, ...queryOptions });\n\n return {\n queryKey,\n ...query,\n };\n};\n\n/**\n * Adds a user to an organisation\n\n * @summary Adds a user to an organisation\n */\nexport const addOrganisationUser = (\n orgid: string,\n userid: string,\n options?: SecondParameter<typeof customInstance>\n) => {\n return customInstance<void>(\n {\n url: `/organisation/${orgid}/user/${userid}`,\n method: \"put\",\n data: undefined,\n },\n options\n );\n};\n\nexport const useAddOrganisationUser = <\n TError = Error,\n TContext = unknown\n>(options?: {\n mutation?: UseMutationOptions<\n AsyncReturnType<typeof addOrganisationUser>,\n TError,\n { orgid: string; userid: string },\n TContext\n >;\n request?: SecondParameter<typeof customInstance>;\n}) => {\n const { mutation: mutationOptions, request: requestOptions } = options || {};\n\n const mutationFn: MutationFunction<\n AsyncReturnType<typeof addOrganisationUser>,\n { orgid: string; userid: string }\n > = (props) => {\n const { orgid, userid } = props || {};\n\n return addOrganisationUser(orgid, userid, requestOptions);\n };\n\n return useMutation<\n AsyncReturnType<typeof addOrganisationUser>,\n TError,\n { orgid: string; userid: string },\n TContext\n >(mutationFn, mutationOptions);\n};\n/**\n * Removes a user to an organisation\n\n * @summary Deletes a user from an organisation\n */\nexport const deleteOrganisationUser = (\n orgid: string,\n userid: string,\n options?: SecondParameter<typeof customInstance>\n) => {\n return customInstance<void>(\n { url: `/organisation/${orgid}/user/${userid}`, method: \"delete\" },\n options\n );\n};\n\nexport const useDeleteOrganisationUser = <\n TError = Error,\n TContext = unknown\n>(options?: {\n mutation?: UseMutationOptions<\n AsyncReturnType<typeof deleteOrganisationUser>,\n TError,\n { orgid: string; userid: string },\n TContext\n >;\n request?: SecondParameter<typeof customInstance>;\n}) => {\n const { mutation: mutationOptions, request: requestOptions } = options || {};\n\n const mutationFn: MutationFunction<\n AsyncReturnType<typeof deleteOrganisationUser>,\n { orgid: string; userid: string }\n > = (props) => {\n const { orgid, userid } = props || {};\n\n return deleteOrganisationUser(orgid, userid, requestOptions);\n };\n\n return useMutation<\n AsyncReturnType<typeof deleteOrganisationUser>,\n TError,\n { orgid: string; userid: string },\n TContext\n >(mutationFn, mutationOptions);\n};\n/**\n * Gets users in an Organisational Unit\n\n * @summary Gets users in an Organisational Unit\n */\nexport const getOrganisationUnitUsers = (\n unitid: string,\n options?: SecondParameter<typeof customInstance>\n) => {\n return customInstance<UsersGetResponse>(\n { url: `/unit/${unitid}/user`, method: \"get\" },\n options\n );\n};\n\nexport const getGetOrganisationUnitUsersQueryKey = (unitid: string) => [\n `/unit/${unitid}/user`,\n];\n\nexport const useGetOrganisationUnitUsers = <\n TData = AsyncReturnType<typeof getOrganisationUnitUsers>,\n TError = Error | void\n>(\n unitid: string,\n options?: {\n query?: UseQueryOptions<\n AsyncReturnType<typeof getOrganisationUnitUsers>,\n TError,\n TData\n >;\n request?: SecondParameter<typeof customInstance>;\n }\n) => {\n const { query: queryOptions, request: requestOptions } = options || {};\n\n const queryKey =\n queryOptions?.queryKey ?? getGetOrganisationUnitUsersQueryKey(unitid);\n\n const queryFn: QueryFunction<\n AsyncReturnType<typeof getOrganisationUnitUsers>\n > = () => getOrganisationUnitUsers(unitid, requestOptions);\n\n const query = useQuery<\n AsyncReturnType<typeof getOrganisationUnitUsers>,\n TError,\n TData\n >(queryKey, queryFn, { enabled: !!unitid, ...queryOptions });\n\n return {\n queryKey,\n ...query,\n };\n};\n\n/**\n * Adds a user to an Organisationall Unit\n\n * @summary Adds a user to an Organisational Unit\n */\nexport const addOrganisationUnitUser = (\n unitid: string,\n userid: string,\n options?: SecondParameter<typeof customInstance>\n) => {\n return customInstance<void>(\n { url: `/unit/${unitid}/user/${userid}`, method: \"put\", data: undefined },\n options\n );\n};\n\nexport const useAddOrganisationUnitUser = <\n TError = Error,\n TContext = unknown\n>(options?: {\n mutation?: UseMutationOptions<\n AsyncReturnType<typeof addOrganisationUnitUser>,\n TError,\n { unitid: string; userid: string },\n TContext\n >;\n request?: SecondParameter<typeof customInstance>;\n}) => {\n const { mutation: mutationOptions, request: requestOptions } = options || {};\n\n const mutationFn: MutationFunction<\n AsyncReturnType<typeof addOrganisationUnitUser>,\n { unitid: string; userid: string }\n > = (props) => {\n const { unitid, userid } = props || {};\n\n return addOrganisationUnitUser(unitid, userid, requestOptions);\n };\n\n return useMutation<\n AsyncReturnType<typeof addOrganisationUnitUser>,\n TError,\n { unitid: string; userid: string },\n TContext\n >(mutationFn, mutationOptions);\n};\n/**\n * Removes a user to an Organisational Unit\n\n * @summary Deletes a user from an Organisational Unit\n */\nexport const deleteOrganisationUnitUser = (\n unitid: string,\n userid: string,\n options?: SecondParameter<typeof customInstance>\n) => {\n return customInstance<void>(\n { url: `/unit/${unitid}/user/${userid}`, method: \"delete\" },\n options\n );\n};\n\nexport const useDeleteOrganisationUnitUser = <\n TError = Error,\n TContext = unknown\n>(options?: {\n mutation?: UseMutationOptions<\n AsyncReturnType<typeof deleteOrganisationUnitUser>,\n TError,\n { unitid: string; userid: string },\n TContext\n >;\n request?: SecondParameter<typeof customInstance>;\n}) => {\n const { mutation: mutationOptions, request: requestOptions } = options || {};\n\n const mutationFn: MutationFunction<\n AsyncReturnType<typeof deleteOrganisationUnitUser>,\n { unitid: string; userid: string }\n > = (props) => {\n const { unitid, userid } = props || {};\n\n return deleteOrganisationUnitUser(unitid, userid, requestOptions);\n };\n\n return useMutation<\n AsyncReturnType<typeof deleteOrganisationUnitUser>,\n TError,\n { unitid: string; userid: string },\n TContext\n >(mutationFn, mutationOptions);\n};\n"],
5
- "mappings": "gDAUA,wDA6BO,GAAM,GAAuB,CAClC,EACA,IAEO,EACL,CAAE,IAAK,iBAAiB,SAAc,OAAQ,OAC9C,GAIS,EAAkC,AAAC,GAAkB,CAChE,iBAAiB,UAGN,EAA0B,CAIrC,EACA,IAQG,CAl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SAAU,EAAiB,QAAS,GAAmB,GAAW,GAW1E,MAAO,GANH,AAAC,GAAU,CACb,GAAM,CAAE,SAAQ,UAAW,GAAS,GAEpC,MAAO,GAAwB,EAAQ,EAAQ,IAQnC,IAOH,EAA6B,CACxC,EACA,EACA,IAEO,EACL,CAAE,IAAK,SAAS,UAAe,IAAU,OAAQ,UACjD,GAIS,EAAgC,AAG3C,GAQI,CACJ,GAAM,CAAE,SAAU,EAAiB,QAAS,GAAmB,GAAW,GAW1E,MAAO,GANH,AAAC,GAAU,CACb,GAAM,CAAE,SAAQ,UAAW,GAAS,GAEpC,MAAO,GAA2B,EAAQ,EAAQ,IAQtC",
3
+ "sources": ["../../src/user/user.ts", "../../src/custom-instance.ts"],
4
+ "sourcesContent": ["/**\n * Generated by orval v6.4.2 \uD83C\uDF7A\n * Do not edit manually.\n * Account Server API\n * The Informatics Matters Account Server API.\n\nA service that provides access to the Account Server, which gives *registered* users access to and management of **Products**, **Organisations**, **Units** and **Users**.\n\n * OpenAPI spec version: 0.1\n */\nimport {\n useQuery,\n useMutation,\n UseQueryOptions,\n UseMutationOptions,\n QueryFunction,\n MutationFunction,\n UseQueryResult,\n QueryKey,\n} from \"react-query\";\nimport type { UsersGetResponse, AsError } from \"../account-server-api.schemas\";\nimport { customInstance, ErrorType } from \".././custom-instance\";\n\ntype AsyncReturnType<T extends (...args: any) => Promise<any>> = T extends (\n ...args: any\n) => Promise<infer R>\n ? R\n : any;\n\ntype SecondParameter<T extends (...args: any) => any> = T extends (\n config: any,\n args: infer P\n) => any\n ? P\n : never;\n\n/**\n * Gets users in an Organisation. You have to be in the Organisation or an Admin user to use this endpoint\n\n * @summary Gets users in an organisation\n */\nexport const getOrganisationUsers = (\n orgid: string,\n options?: SecondParameter<typeof customInstance>\n) => {\n return customInstance<UsersGetResponse>(\n { url: `/organisation/${orgid}/user`, method: \"get\" },\n options\n );\n};\n\nexport const getGetOrganisationUsersQueryKey = (orgid: string) => [\n `/organisation/${orgid}/user`,\n];\n\nexport const useGetOrganisationUsers = <\n TData = AsyncReturnType<typeof getOrganisationUsers>,\n TError = ErrorType<AsError | void>\n>(\n orgid: string,\n options?: {\n query?: UseQueryOptions<\n AsyncReturnType<typeof getOrganisationUsers>,\n TError,\n TData\n >;\n request?: SecondParameter<typeof customInstance>;\n }\n): UseQueryResult<TData, TError> & { queryKey: QueryKey } => {\n const { query: queryOptions, request: requestOptions } = options || {};\n\n const queryKey =\n queryOptions?.queryKey ?? getGetOrganisationUsersQueryKey(orgid);\n\n const queryFn: QueryFunction<\n AsyncReturnType<typeof getOrganisationUsers>\n > = () => getOrganisationUsers(orgid, requestOptions);\n\n const query = useQuery<\n AsyncReturnType<typeof getOrganisationUsers>,\n TError,\n TData\n >(queryKey, queryFn, { enabled: !!orgid, ...queryOptions });\n\n return {\n queryKey,\n ...query,\n };\n};\n\n/**\n * Adds a user to an organisation. You have to be in the Organisation or an Admin user to use this endpoint\n\n * @summary Adds a user to an organisation\n */\nexport const addOrganisationUser = (\n orgid: string,\n userid: string,\n options?: SecondParameter<typeof customInstance>\n) => {\n return customInstance<void>(\n {\n url: `/organisation/${orgid}/user/${userid}`,\n method: \"put\",\n data: undefined,\n },\n options\n );\n};\n\nexport const useAddOrganisationUser = <\n TError = ErrorType<AsError>,\n TContext = unknown\n>(options?: {\n mutation?: UseMutationOptions<\n AsyncReturnType<typeof addOrganisationUser>,\n TError,\n { orgid: string; userid: string },\n TContext\n >;\n request?: SecondParameter<typeof customInstance>;\n}) => {\n const { mutation: mutationOptions, request: requestOptions } = options || {};\n\n const mutationFn: MutationFunction<\n AsyncReturnType<typeof addOrganisationUser>,\n { orgid: string; userid: string }\n > = (props) => {\n const { orgid, userid } = props || {};\n\n return addOrganisationUser(orgid, userid, requestOptions);\n };\n\n return useMutation<\n AsyncReturnType<typeof addOrganisationUser>,\n TError,\n { orgid: string; userid: string },\n TContext\n >(mutationFn, mutationOptions);\n};\n/**\n * Removes a user from an organisation. You have to be in the Organisation or an Admin user to use this endpoint\n\n * @summary Deletes a user from an organisation\n */\nexport const deleteOrganisationUser = (\n orgid: string,\n userid: string,\n options?: SecondParameter<typeof customInstance>\n) => {\n return customInstance<void>(\n {\n url: `/organisation/${orgid}/user/${userid}`,\n method: \"delete\",\n data: undefined,\n },\n options\n );\n};\n\nexport const useDeleteOrganisationUser = <\n TError = ErrorType<AsError>,\n TContext = unknown\n>(options?: {\n mutation?: UseMutationOptions<\n AsyncReturnType<typeof deleteOrganisationUser>,\n TError,\n { orgid: string; userid: string },\n TContext\n >;\n request?: SecondParameter<typeof customInstance>;\n}) => {\n const { mutation: mutationOptions, request: requestOptions } = options || {};\n\n const mutationFn: MutationFunction<\n AsyncReturnType<typeof deleteOrganisationUser>,\n { orgid: string; userid: string }\n > = (props) => {\n const { orgid, userid } = props || {};\n\n return deleteOrganisationUser(orgid, userid, requestOptions);\n };\n\n return useMutation<\n AsyncReturnType<typeof deleteOrganisationUser>,\n TError,\n { orgid: string; userid: string },\n TContext\n >(mutationFn, mutationOptions);\n};\n/**\n * Gets users in an Organisational Unit. You have to be in the Organisation or Unit or an Admin user to use this endpoint\n\n * @summary Gets users in an Organisational Unit\n */\nexport const getOrganisationUnitUsers = (\n unitid: string,\n options?: SecondParameter<typeof customInstance>\n) => {\n return customInstance<UsersGetResponse>(\n { url: `/unit/${unitid}/user`, method: \"get\" },\n options\n );\n};\n\nexport const getGetOrganisationUnitUsersQueryKey = (unitid: string) => [\n `/unit/${unitid}/user`,\n];\n\nexport const useGetOrganisationUnitUsers = <\n TData = AsyncReturnType<typeof getOrganisationUnitUsers>,\n TError = ErrorType<AsError | void>\n>(\n unitid: string,\n options?: {\n query?: UseQueryOptions<\n AsyncReturnType<typeof getOrganisationUnitUsers>,\n TError,\n TData\n >;\n request?: SecondParameter<typeof customInstance>;\n }\n): UseQueryResult<TData, TError> & { queryKey: QueryKey } => {\n const { query: queryOptions, request: requestOptions } = options || {};\n\n const queryKey =\n queryOptions?.queryKey ?? getGetOrganisationUnitUsersQueryKey(unitid);\n\n const queryFn: QueryFunction<\n AsyncReturnType<typeof getOrganisationUnitUsers>\n > = () => getOrganisationUnitUsers(unitid, requestOptions);\n\n const query = useQuery<\n AsyncReturnType<typeof getOrganisationUnitUsers>,\n TError,\n TData\n >(queryKey, queryFn, { enabled: !!unitid, ...queryOptions });\n\n return {\n queryKey,\n ...query,\n };\n};\n\n/**\n * Adds a user to an Organisationall Unit. You have to be in the Organisation or Unit or an Admin user to use this endpoint\n\n * @summary Adds a user to an Organisational Unit\n */\nexport const addOrganisationUnitUser = (\n unitid: string,\n userid: string,\n options?: SecondParameter<typeof customInstance>\n) => {\n return customInstance<void>(\n { url: `/unit/${unitid}/user/${userid}`, method: \"put\", data: undefined },\n options\n );\n};\n\nexport const useAddOrganisationUnitUser = <\n TError = ErrorType<AsError>,\n TContext = unknown\n>(options?: {\n mutation?: UseMutationOptions<\n AsyncReturnType<typeof addOrganisationUnitUser>,\n TError,\n { unitid: string; userid: string },\n TContext\n >;\n request?: SecondParameter<typeof customInstance>;\n}) => {\n const { mutation: mutationOptions, request: requestOptions } = options || {};\n\n const mutationFn: MutationFunction<\n AsyncReturnType<typeof addOrganisationUnitUser>,\n { unitid: string; userid: string }\n > = (props) => {\n const { unitid, userid } = props || {};\n\n return addOrganisationUnitUser(unitid, userid, requestOptions);\n };\n\n return useMutation<\n AsyncReturnType<typeof addOrganisationUnitUser>,\n TError,\n { unitid: string; userid: string },\n TContext\n >(mutationFn, mutationOptions);\n};\n/**\n * Removes a user from an Organisational Unit. You have to be in the Organisation or Unit or an Admin user to use this endpoint\n\n * @summary Deletes a user from an Organisational Unit\n */\nexport const deleteOrganisationUnitUser = (\n unitid: string,\n userid: string,\n options?: SecondParameter<typeof customInstance>\n) => {\n return customInstance<void>(\n {\n url: `/unit/${unitid}/user/${userid}`,\n method: \"delete\",\n data: undefined,\n },\n options\n );\n};\n\nexport const useDeleteOrganisationUnitUser = <\n TError = ErrorType<AsError>,\n TContext = unknown\n>(options?: {\n mutation?: UseMutationOptions<\n AsyncReturnType<typeof deleteOrganisationUnitUser>,\n TError,\n { unitid: string; userid: string },\n TContext\n >;\n request?: SecondParameter<typeof customInstance>;\n}) => {\n const { mutation: mutationOptions, request: requestOptions } = options || {};\n\n const mutationFn: MutationFunction<\n AsyncReturnType<typeof deleteOrganisationUnitUser>,\n { unitid: string; userid: string }\n > = (props) => {\n const { unitid, userid } = props || {};\n\n return deleteOrganisationUnitUser(unitid, userid, requestOptions);\n };\n\n return useMutation<\n AsyncReturnType<typeof deleteOrganisationUnitUser>,\n TError,\n { unitid: string; userid: string },\n TContext\n >(mutationFn, mutationOptions);\n};\n", "/** Based off the example custom-instance from Orval docs\n * https://github.com/anymaniax/orval/blob/master/samples/react-app-with-react-query/src/api/mutator/custom-instance.ts\n *\n * See https://react-query.tanstack.com/guides/query-cancellation\n *\n * TODO: Considering using Fetch-API instead of axios. This instance will have to change. Could be\n * achieved without changing much using `redaxios`\n * Or use 'ky'\n */\n\nimport Axios, { AxiosError, AxiosRequestConfig } from 'axios';\n\n// ? Need the baseUrl or does it default to ''?\nexport const AXIOS_INSTANCE = Axios.create({ baseURL: '' });\n\n/**\n * Set the access token to be added as the `Authorization: Bearer 'token'` header\n * Useful for client only apps where a proxy API route isn't involved to securely add the access token\n * @param token access token\n */\nexport const setAuthToken = (token: string) => {\n AXIOS_INSTANCE.defaults.headers.common['Authorization'] = `Bearer ${token}`;\n};\n\n/**\n * Set the url to which request paths are added to.\n * @param baseUrl origin + subpath e.g. 'https://example.com/subpath' or '/subpath'\n */\nexport const setBaseUrl = (baseUrl: string) => {\n AXIOS_INSTANCE.defaults.baseURL = baseUrl;\n};\n\nexport const customInstance = <TReturn>(\n config: AxiosRequestConfig,\n options?: AxiosRequestConfig,\n): Promise<TReturn> => {\n const source = Axios.CancelToken.source();\n\n const promise = AXIOS_INSTANCE({ ...config, ...options, cancelToken: source.token }).then(\n ({ data }) => data,\n );\n\n // Promise doesn't have a cancel method but react-query requires this method to make cancellations general.\n // This can either be a any assertion or a @ts-ignore comment.\n (promise as any).cancel = () => {\n source.cancel('Query was cancelled by React Query');\n };\n\n return promise;\n};\n\nexport type ErrorType<TError> = AxiosError<TError>;\n"],
5
+ "mappings": ";;;;;;;;;;;;;;;;;;;;;AAUA;AAAA;AAAA;AAAA;;;ACAA;AAGO,IAAM,iBAAiB,MAAM,OAAO,EAAE,SAAS;AAmB/C,IAAM,iBAAiB,CAC5B,QACA,YACqB;AACrB,QAAM,SAAS,MAAM,YAAY;AAEjC,QAAM,UAAU,eAAe,gDAAK,SAAW,UAAhB,EAAyB,aAAa,OAAO,UAAS,KACnF,CAAC,EAAE,WAAW;AAKhB,EAAC,QAAgB,SAAS,MAAM;AAC9B,WAAO,OAAO;AAAA;AAGhB,SAAO;AAAA;;;ADPF,IAAM,uBAAuB,CAClC,OACA,YACG;AACH,SAAO,eACL,EAAE,KAAK,iBAAiB,cAAc,QAAQ,SAC9C;AAAA;AAIG,IAAM,kCAAkC,CAAC,UAAkB;AAAA,EAChE,iBAAiB;AAAA;AAGZ,IAAM,0BAA0B,CAIrC,OACA,YAQ2D;AAC3D,QAAM,EAAE,OAAO,cAAc,SAAS,mBAAmB,WAAW;AAEpE,QAAM,WACJ,8CAAc,aAAY,gCAAgC;AAE5D,QAAM,UAEF,MAAM,qBAAqB,OAAO;AAEtC,QAAM,QAAQ,SAIZ,UAAU,SAAS,iBAAE,SAAS,CAAC,CAAC,SAAU;AAE5C,SAAO;AAAA,IACL;AAAA,KACG;AAAA;AASA,IAAM,sBAAsB,CACjC,OACA,QACA,YACG;AACH,SAAO,eACL;AAAA,IACE,KAAK,iBAAiB,cAAc;AAAA,IACpC,QAAQ;AAAA,IACR,MAAM;AAAA,KAER;AAAA;AAIG,IAAM,yBAAyB,CAGpC,YAQI;AACJ,QAAM,EAAE,UAAU,iBAAiB,SAAS,mBAAmB,WAAW;AAE1E,QAAM,aAGF,CAAC,UAAU;AACb,UAAM,EAAE,OAAO,WAAW,SAAS;AAEnC,WAAO,oB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C,QACA,QACA,YACG;AACH,SAAO,eACL;AAAA,IACE,KAAK,SAAS,eAAe;AAAA,IAC7B,QAAQ;AAAA,IACR,MAAM;AAAA,KAER;AAAA;AAIG,IAAM,gCAAgC,CAG3C,YAQI;AACJ,QAAM,EAAE,UAAU,iBAAiB,SAAS,mBAAmB,WAAW;AAE1E,QAAM,aAGF,CAAC,UAAU;AACb,UAAM,EAAE,QAAQ,WAAW,SAAS;AAEpC,WAAO,2BAA2B,QAAQ,QAAQ;AAAA;AAGpD,SAAO,YAKL,YAAY;AAAA;",
6
6
  "names": []
7
7
  }
@@ -1,2 +0,0 @@
1
- "use strict";Object.defineProperty(exports, "__esModule", {value: true}); function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; }var x=Object.defineProperty,A=Object.defineProperties;var R=Object.getOwnPropertyDescriptors;var c=Object.getOwnPropertySymbols;var m=Object.prototype.hasOwnProperty,f=Object.prototype.propertyIsEnumerable;var a=(e,o,s)=>o in e?x(e,o,{enumerable:!0,configurable:!0,writable:!0,value:s}):e[o]=s,t= exports.a =(e,o)=>{for(var s in o||(o={}))m.call(o,s)&&a(e,s,o[s]);if(c)for(var s of c(o))f.call(o,s)&&a(e,s,o[s]);return e},i=(e,o)=>A(e,R(o));var _axios = require('axios'); var _axios2 = _interopRequireDefault(_axios);var n=_axios2.default.create({baseURL:""}),d= exports.c =e=>{n.defaults.headers.common.Authorization=`Bearer ${e}`},h= exports.d =e=>{n.defaults.baseURL=e},k= exports.e =(e,o)=>{let s=_axios2.default.CancelToken.source(),r=n(i(t(t({},e),o),{cancelToken:s.token})).then(({data:l})=>l);return r.cancel=()=>{s.cancel("Query was cancelled by React Query")},r};exports.a = t; exports.b = n; exports.c = d; exports.d = h; exports.e = k;
2
- //# sourceMappingURL=chunk-OULWOQLW.cjs.map
@@ -1,7 +0,0 @@
1
- {
2
- "version": 3,
3
- "sources": ["../src/custom-instance.ts"],
4
- "sourcesContent": ["/** Based off the example custom-instance from Orval docs\n * https://github.com/anymaniax/orval/blob/master/samples/react-app-with-react-query/src/api/mutator/custom-instance.ts\n *\n * See https://react-query.tanstack.com/guides/query-cancellation\n *\n * TODO: Considering using Fetch-API instead of axios. This instance will have to change. Could be\n * achieved without changing much using `redaxios`\n * Or use 'ky'\n */\n\nimport Axios, { AxiosRequestConfig } from 'axios';\n\n// ? Need the baseUrl or does it default to ''?\nexport const AXIOS_INSTANCE = Axios.create({ baseURL: '' });\n\n/**\n * Set the access token to be added as the `Authorization: Bearer 'token'` header\n * Useful for client only apps where a proxy API route isn't involved to securely add the access token\n * @param token access token\n */\nexport const setAuthToken = (token: string) => {\n AXIOS_INSTANCE.defaults.headers.common['Authorization'] = `Bearer ${token}`;\n};\n\n/**\n * Set the url to which request paths are added to.\n * @param baseUrl origin + subpath e.g. 'https://example.com/subpath' or '/subpath'\n */\nexport const setBaseUrl = (baseUrl: string) => {\n AXIOS_INSTANCE.defaults.baseURL = baseUrl;\n};\n\nexport const customInstance = <TReturn>(\n config: AxiosRequestConfig,\n options?: AxiosRequestConfig,\n): Promise<TReturn> => {\n const source = Axios.CancelToken.source();\n\n const promise = AXIOS_INSTANCE({ ...config, ...options, cancelToken: source.token }).then(\n ({ data }) => data,\n );\n\n // Promise doesn't have a cancel method but react-query requires this method to make cancellations general.\n // This can either be a any assertion or a @ts-ignore comment.\n (promise as any).cancel = () => {\n source.cancel('Query was cancelled by React Query');\n };\n\n return promise;\n};\n"],
5
- "mappings": "6aAUA,qBAGO,GAAM,GAAiB,EAAM,OAAO,CAAE,QAAS,KAOzC,EAAe,AAAC,GAAkB,CAC7C,EAAe,SAAS,QAAQ,OAAO,cAAmB,UAAU,KAOzD,EAAa,AAAC,GAAoB,CAC7C,EAAe,SAAS,QAAU,GAGvB,EAAiB,CAC5B,EACA,IACqB,CACrB,GAAM,GAAS,EAAM,YAAY,SAE3B,EAAU,EAAe,SAAK,GAAW,GAAhB,CAAyB,YAAa,EAAO,SAAS,KACnF,CAAC,CAAE,UAAW,GAKhB,MAAC,GAAgB,OAAS,IAAM,CAC9B,EAAO,OAAO,uCAGT",
6
- "names": []
7
- }