@squonk/account-server-client 0.1.6-rc.2 → 0.1.10-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 (49) hide show
  1. package/{custom-instance-d52e4104.d.ts → custom-instance-3334b00b.d.ts} +28 -6
  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 +21 -7
  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 +7 -7
  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 +7 -7
  18. package/product/product.js +127 -2
  19. package/product/product.js.map +3 -3
  20. package/service/package.json +7 -0
  21. package/service/service.cjs +100 -0
  22. package/service/service.cjs.map +7 -0
  23. package/service/service.d.ts +44 -0
  24. package/service/service.js +72 -0
  25. package/service/service.js.map +7 -0
  26. package/src/account-server-api.schemas.ts +295 -0
  27. package/src/custom-instance.ts +52 -0
  28. package/src/index.ts +6 -0
  29. package/src/organisation/organisation.ts +181 -0
  30. package/src/product/product.ts +289 -0
  31. package/src/service/service.ts +124 -0
  32. package/src/unit/unit.ts +322 -0
  33. package/src/user/user.ts +340 -0
  34. package/unit/package.json +2 -1
  35. package/unit/unit.cjs +168 -2
  36. package/unit/unit.cjs.map +3 -3
  37. package/unit/unit.d.ts +54 -5
  38. package/unit/unit.js +133 -2
  39. package/unit/unit.js.map +3 -3
  40. package/user/package.json +2 -1
  41. package/user/user.cjs +176 -2
  42. package/user/user.cjs.map +3 -3
  43. package/user/user.d.ts +13 -13
  44. package/user/user.js +141 -2
  45. package/user/user.js.map +3 -3
  46. package/chunk-33VR3IML.js +0 -2
  47. package/chunk-33VR3IML.js.map +0 -7
  48. package/chunk-3KO3PKBX.cjs +0 -2
  49. package/chunk-3KO3PKBX.cjs.map +0 -7
@@ -1,7 +1,7 @@
1
1
  {
2
2
  "version": 3,
3
- "sources": ["../../src/product/product.ts"],
4
- "sourcesContent": ["/**\n * Generated by orval v6.4.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 UseQueryResult,\n QueryKey,\n} from \"react-query\";\nimport type {\n ProductsGetResponse,\n Error,\n UnitProductPostResponse,\n UnitProductPostBodyBody,\n ProductUnitGetResponse,\n ProductPatchBodyBody,\n} 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 products you have access to across all Units and Organisations\n\n * @summary Gets all Products\n */\nexport const getProducts = (\n options?: SecondParameter<typeof customInstance>\n) => {\n return customInstance<ProductsGetResponse>(\n { url: `/product`, method: \"get\" },\n options\n );\n};\n\nexport const getGetProductsQueryKey = () => [`/product`];\n\nexport const useGetProducts = <\n TData = AsyncReturnType<typeof getProducts>,\n TError = ErrorType<Error | void>\n>(options?: {\n query?: UseQueryOptions<AsyncReturnType<typeof getProducts>, TError, TData>;\n request?: SecondParameter<typeof customInstance>;\n}): UseQueryResult<TData, TError> & { queryKey: QueryKey } => {\n const { query: queryOptions, request: requestOptions } = options || {};\n\n const queryKey = queryOptions?.queryKey ?? getGetProductsQueryKey();\n\n const queryFn: QueryFunction<AsyncReturnType<typeof getProducts>> = () =>\n getProducts(requestOptions);\n\n const query = useQuery<AsyncReturnType<typeof getProducts>, TError, TData>(\n queryKey,\n queryFn,\n queryOptions\n );\n\n return {\n queryKey,\n ...query,\n };\n};\n\n/**\n * @summary Creates a Product for an Organisational Unit\n */\nexport const createUnitProduct = (\n unitid: string,\n unitProductPostBodyBody: UnitProductPostBodyBody,\n options?: SecondParameter<typeof customInstance>\n) => {\n return customInstance<UnitProductPostResponse>(\n {\n url: `/product/unit/${unitid}`,\n method: \"post\",\n data: unitProductPostBodyBody,\n },\n options\n );\n};\n\nexport const useCreateUnitProduct = <\n TError = ErrorType<Error | void>,\n TContext = unknown\n>(options?: {\n mutation?: UseMutationOptions<\n AsyncReturnType<typeof createUnitProduct>,\n TError,\n { unitid: string; data: UnitProductPostBodyBody },\n TContext\n >;\n request?: SecondParameter<typeof customInstance>;\n}) => {\n const { mutation: mutationOptions, request: requestOptions } = options || {};\n\n const mutationFn: MutationFunction<\n AsyncReturnType<typeof createUnitProduct>,\n { unitid: string; data: UnitProductPostBodyBody }\n > = (props) => {\n const { unitid, data } = props || {};\n\n return createUnitProduct(unitid, data, requestOptions);\n };\n\n return useMutation<\n AsyncReturnType<typeof createUnitProduct>,\n TError,\n { unitid: string; data: UnitProductPostBodyBody },\n TContext\n >(mutationFn, mutationOptions);\n};\n/**\n * Gets products you have access to based on an Organisational Unit\n\n * @summary Gets Products for an Organisational Unit\n */\nexport const getProductsForUnit = (\n unitid: string,\n options?: SecondParameter<typeof customInstance>\n) => {\n return customInstance<ProductsGetResponse>(\n { url: `/product/unit/${unitid}`, method: \"get\" },\n options\n );\n};\n\nexport const getGetProductsForUnitQueryKey = (unitid: string) => [\n `/product/unit/${unitid}`,\n];\n\nexport const useGetProductsForUnit = <\n TData = AsyncReturnType<typeof getProductsForUnit>,\n TError = ErrorType<void | Error>\n>(\n unitid: string,\n options?: {\n query?: UseQueryOptions<\n AsyncReturnType<typeof getProductsForUnit>,\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 ?? getGetProductsForUnitQueryKey(unitid);\n\n const queryFn: QueryFunction<\n AsyncReturnType<typeof getProductsForUnit>\n > = () => getProductsForUnit(unitid, requestOptions);\n\n const query = useQuery<\n AsyncReturnType<typeof getProductsForUnit>,\n TError,\n TData\n >(queryKey, queryFn, { enabled: !!unitid, ...queryOptions });\n\n return {\n queryKey,\n ...query,\n };\n};\n\n/**\n * Gets a Unit's Product\n\n * @summary Gets a Unit's Product\n */\nexport const getProduct = (\n unitid: string,\n productid: string,\n options?: SecondParameter<typeof customInstance>\n) => {\n return customInstance<ProductUnitGetResponse>(\n { url: `/product/unit/${unitid}/product/${productid}`, method: \"get\" },\n options\n );\n};\n\nexport const getGetProductQueryKey = (unitid: string, productid: string) => [\n `/product/unit/${unitid}/product/${productid}`,\n];\n\nexport const useGetProduct = <\n TData = AsyncReturnType<typeof getProduct>,\n TError = ErrorType<Error | void>\n>(\n unitid: string,\n productid: string,\n options?: {\n query?: UseQueryOptions<AsyncReturnType<typeof getProduct>, TError, TData>;\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 ?? getGetProductQueryKey(unitid, productid);\n\n const queryFn: QueryFunction<AsyncReturnType<typeof getProduct>> = () =>\n getProduct(unitid, productid, requestOptions);\n\n const query = useQuery<AsyncReturnType<typeof getProduct>, TError, TData>(\n queryKey,\n queryFn,\n { enabled: !!(unitid && productid), ...queryOptions }\n );\n\n return {\n queryKey,\n ...query,\n };\n};\n\n/**\n * Used to update some adjustable parameters of a Product, i.e. to extend the Allowance or Limit. Curently you can only patch storage Products\n\n * @summary Adjust an existing Product\n */\nexport const patchProduct = (\n unitid: string,\n productid: string,\n productPatchBodyBody: ProductPatchBodyBody,\n options?: SecondParameter<typeof customInstance>\n) => {\n return customInstance<void>(\n {\n url: `/product/unit/${unitid}/product/${productid}`,\n method: \"patch\",\n data: productPatchBodyBody,\n },\n options\n );\n};\n\nexport const usePatchProduct = <\n TError = ErrorType<Error>,\n TContext = unknown\n>(options?: {\n mutation?: UseMutationOptions<\n AsyncReturnType<typeof patchProduct>,\n TError,\n { unitid: string; productid: string; data: ProductPatchBodyBody },\n TContext\n >;\n request?: SecondParameter<typeof customInstance>;\n}) => {\n const { mutation: mutationOptions, request: requestOptions } = options || {};\n\n const mutationFn: MutationFunction<\n AsyncReturnType<typeof patchProduct>,\n { unitid: string; productid: string; data: ProductPatchBodyBody }\n > = (props) => {\n const { unitid, productid, data } = props || {};\n\n return patchProduct(unitid, productid, data, requestOptions);\n };\n\n return useMutation<\n AsyncReturnType<typeof patchProduct>,\n TError,\n { unitid: string; productid: string; data: ProductPatchBodyBody },\n TContext\n >(mutationFn, mutationOptions);\n};\n"],
5
- "mappings": "gDAUA,wDAsCO,GAAM,GAAc,AACzB,GAEO,EACL,CAAE,IAAK,WAAY,OAAQ,OAC3B,GAIS,EAAyB,IAAM,CAAC,YAEhC,EAAiB,AAG5B,GAG4D,CAjE9D,MAkEE,GAAM,CAAE,MAAO,EAAc,QAAS,GAAmB,GAAW,GAE9D,EAAW,oBAAc,WAAd,OAA0B,IAKrC,EAAQ,EACZ,EAJkE,IAClE,EAAY,GAKZ,GAGF,MAAO,IACL,YACG,IAOM,EAAoB,CAC/B,EACA,EACA,IAEO,EACL,CACE,IAAK,iBAAiB,IACtB,OAAQ,OACR,KAAM,GAER,GAIS,EAAuB,AAGlC,GAQI,CACJ,GAAM,CAAE,SAAU,EAAiB,QAAS,GAAmB,GAAW,GAW1E,MAAO,GANH,AAAC,GAAU,CACb,GAAM,CAAE,SAAQ,QAAS,GAAS,GAElC,MAAO,GAAkB,EAAQ,EAAM,IAQ3B,IAOH,EAAqB,CAChC,EACA,IAEO,EACL,CAAE,IAAK,iBAAiB,IAAU,OAAQ,OAC1C,GAIS,EAAgC,AAAC,GAAmB,CAC/D,iBAAiB,KAGN,EAAwB,CAInC,EACA,IAQ2D,CArK7D,MAsKE,GAAM,CAAE,MAAO,EAAc,QAAS,GAAmB,GAAW,GAE9D,EACJ,oBAAc,WAAd,OAA0B,EAA8B,GAMpD,EAAQ,EAIZ,EANE,IAAM,EAAmB,EAAQ,GAMhB,GAAE,QAAS,CAAC,CAAC,GAAW,IAE7C,MAAO,IACL,YACG,IASM,EAAa,CACxB,EACA,EACA,IAEO,EACL,CAAE,IAAK,iBAAiB,aAAkB,IAAa,OAAQ,OAC/D,GAIS,EAAwB,CAAC,EAAgB,IAAsB,CAC1E,iBAAiB,aAAkB,KAGxB,EAAgB,CAI3B,EACA,EACA,IAI2D,CAzN7D,MA0NE,GAAM,CAAE,MAAO,EAAc,QAAS,GAAmB,GAAW,GAE9D,EACJ,oBAAc,WAAd,OAA0B,EAAsB,EAAQ,GAKpD,EAAQ,EACZ,EAJiE,IACjE,EAAW,EAAQ,EAAW,GAK9B,GAAE,QAAS,CAAC,CAAE,IAAU,IAAe,IAGzC,MAAO,IACL,YACG,IASM,EAAe,CAC1B,EACA,EACA,EACA,IAEO,EACL,CACE,IAAK,iBAAiB,aAAkB,IACxC,OAAQ,QACR,KAAM,GAER,GAIS,EAAkB,AAG7B,GAQI,CACJ,GAAM,CAAE,SAAU,EAAiB,QAAS,GAAmB,GAAW,GAW1E,MAAO,GANH,AAAC,GAAU,CACb,GAAM,CAAE,SAAQ,YAAW,QAAS,GAAS,GAE7C,MAAO,GAAa,EAAQ,EAAW,EAAM,IAQjC",
3
+ "sources": ["../../src/product/product.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 {\n ProductsGetResponse,\n AsError,\n UnitProductPostResponse,\n UnitProductPostBodyBody,\n ProductUnitGetResponse,\n ProductPatchBodyBody,\n} 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 products you have access to, across all Units and Organisations\n\n * @summary Gets all Products\n */\nexport const getProducts = (\n options?: SecondParameter<typeof customInstance>\n) => {\n return customInstance<ProductsGetResponse>(\n { url: `/product`, method: \"get\" },\n options\n );\n};\n\nexport const getGetProductsQueryKey = () => [`/product`];\n\nexport const useGetProducts = <\n TData = AsyncReturnType<typeof getProducts>,\n TError = ErrorType<AsError | void>\n>(options?: {\n query?: UseQueryOptions<AsyncReturnType<typeof getProducts>, TError, TData>;\n request?: SecondParameter<typeof customInstance>;\n}): UseQueryResult<TData, TError> & { queryKey: QueryKey } => {\n const { query: queryOptions, request: requestOptions } = options || {};\n\n const queryKey = queryOptions?.queryKey ?? getGetProductsQueryKey();\n\n const queryFn: QueryFunction<AsyncReturnType<typeof getProducts>> = () =>\n getProducts(requestOptions);\n\n const query = useQuery<AsyncReturnType<typeof getProducts>, TError, TData>(\n queryKey,\n queryFn,\n queryOptions\n );\n\n return {\n queryKey,\n ...query,\n };\n};\n\n/**\n * @summary Creates a Product for an Organisational Unit\n */\nexport const createUnitProduct = (\n unitid: string,\n unitProductPostBodyBody: UnitProductPostBodyBody,\n options?: SecondParameter<typeof customInstance>\n) => {\n return customInstance<UnitProductPostResponse>(\n {\n url: `/product/unit/${unitid}`,\n method: \"post\",\n data: unitProductPostBodyBody,\n },\n options\n );\n};\n\nexport const useCreateUnitProduct = <\n TError = ErrorType<AsError | void>,\n TContext = unknown\n>(options?: {\n mutation?: UseMutationOptions<\n AsyncReturnType<typeof createUnitProduct>,\n TError,\n { unitid: string; data: UnitProductPostBodyBody },\n TContext\n >;\n request?: SecondParameter<typeof customInstance>;\n}) => {\n const { mutation: mutationOptions, request: requestOptions } = options || {};\n\n const mutationFn: MutationFunction<\n AsyncReturnType<typeof createUnitProduct>,\n { unitid: string; data: UnitProductPostBodyBody }\n > = (props) => {\n const { unitid, data } = props || {};\n\n return createUnitProduct(unitid, data, requestOptions);\n };\n\n return useMutation<\n AsyncReturnType<typeof createUnitProduct>,\n TError,\n { unitid: string; data: UnitProductPostBodyBody },\n TContext\n >(mutationFn, mutationOptions);\n};\n/**\n * Gets products you have access to based on an Organisational Unit\n\n * @summary Gets Products for an Organisational Unit\n */\nexport const getProductsForUnit = (\n unitid: string,\n options?: SecondParameter<typeof customInstance>\n) => {\n return customInstance<ProductsGetResponse>(\n { url: `/product/unit/${unitid}`, method: \"get\" },\n options\n );\n};\n\nexport const getGetProductsForUnitQueryKey = (unitid: string) => [\n `/product/unit/${unitid}`,\n];\n\nexport const useGetProductsForUnit = <\n TData = AsyncReturnType<typeof getProductsForUnit>,\n TError = ErrorType<void | AsError>\n>(\n unitid: string,\n options?: {\n query?: UseQueryOptions<\n AsyncReturnType<typeof getProductsForUnit>,\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 ?? getGetProductsForUnitQueryKey(unitid);\n\n const queryFn: QueryFunction<\n AsyncReturnType<typeof getProductsForUnit>\n > = () => getProductsForUnit(unitid, requestOptions);\n\n const query = useQuery<\n AsyncReturnType<typeof getProductsForUnit>,\n TError,\n TData\n >(queryKey, queryFn, { enabled: !!unitid, ...queryOptions });\n\n return {\n queryKey,\n ...query,\n };\n};\n\n/**\n * Gets a Unit's Product\n\n * @summary Gets a Unit's Product\n */\nexport const getProduct = (\n unitid: string,\n productid: string,\n options?: SecondParameter<typeof customInstance>\n) => {\n return customInstance<ProductUnitGetResponse>(\n { url: `/product/unit/${unitid}/product/${productid}`, method: \"get\" },\n options\n );\n};\n\nexport const getGetProductQueryKey = (unitid: string, productid: string) => [\n `/product/unit/${unitid}/product/${productid}`,\n];\n\nexport const useGetProduct = <\n TData = AsyncReturnType<typeof getProduct>,\n TError = ErrorType<AsError | void>\n>(\n unitid: string,\n productid: string,\n options?: {\n query?: UseQueryOptions<AsyncReturnType<typeof getProduct>, TError, TData>;\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 ?? getGetProductQueryKey(unitid, productid);\n\n const queryFn: QueryFunction<AsyncReturnType<typeof getProduct>> = () =>\n getProduct(unitid, productid, requestOptions);\n\n const query = useQuery<AsyncReturnType<typeof getProduct>, TError, TData>(\n queryKey,\n queryFn,\n { enabled: !!(unitid && productid), ...queryOptions }\n );\n\n return {\n queryKey,\n ...query,\n };\n};\n\n/**\n * Used to update some adjustable parameters of a Product, i.e. to extend the Allowance or Limit. Curently you can only patch storage Products\n\n * @summary Adjust an existing Product\n */\nexport const patchProduct = (\n unitid: string,\n productid: string,\n productPatchBodyBody: ProductPatchBodyBody,\n options?: SecondParameter<typeof customInstance>\n) => {\n return customInstance<void>(\n {\n url: `/product/unit/${unitid}/product/${productid}`,\n method: \"patch\",\n data: productPatchBodyBody,\n },\n options\n );\n};\n\nexport const usePatchProduct = <\n TError = ErrorType<AsError>,\n TContext = unknown\n>(options?: {\n mutation?: UseMutationOptions<\n AsyncReturnType<typeof patchProduct>,\n TError,\n { unitid: string; productid: string; data: ProductPatchBodyBody },\n TContext\n >;\n request?: SecondParameter<typeof customInstance>;\n}) => {\n const { mutation: mutationOptions, request: requestOptions } = options || {};\n\n const mutationFn: MutationFunction<\n AsyncReturnType<typeof patchProduct>,\n { unitid: string; productid: string; data: ProductPatchBodyBody }\n > = (props) => {\n const { unitid, productid, data } = props || {};\n\n return patchProduct(unitid, productid, data, requestOptions);\n };\n\n return useMutation<\n AsyncReturnType<typeof patchProduct>,\n TError,\n { unitid: string; productid: string; data: ProductPatchBodyBody },\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;;;ADAF,IAAM,cAAc,CACzB,YACG;AACH,SAAO,eACL,EAAE,KAAK,YAAY,QAAQ,SAC3B;AAAA;AAIG,IAAM,yBAAyB,MAAM,CAAC;AAEtC,IAAM,iBAAiB,CAG5B,YAG4D;AAC5D,QAAM,EAAE,OAAO,cAAc,SAAS,mBAAmB,WAAW;AAEpE,QAAM,WAAW,8CAAc,aAAY;AAE3C,QAAM,UAA8D,MAClE,YAAY;AAEd,QAAM,QAAQ,SACZ,UACA,SACA;AAGF,SAAO;AAAA,IACL;AAAA,KACG;AAAA;AAOA,IAAM,oBAAoB,CAC/B,QACA,yBACA,YACG;AACH,SAAO,eACL;AAAA,IACE,KAAK,iBAAiB;AAAA,IACtB,QAAQ;AAAA,IACR,MAAM;AAAA,KAER;AAAA;AAIG,IAAM,uBAAuB,CAGlC,YAQI;AACJ,QAAM,EAAE,UAAU,iBAAiB,SAAS,mBAAmB,WAAW;AAE1E,QAAM,aAGF,CAAC,UAAU;AACb,UAAM,EAAE,QAAQ,SAAS,SAAS;AAElC,WAAO,kBAAkB,QAAQ,MAAM;AAAA;AAGzC,SAAO,YAKL,YAAY;AAAA;AAOT,IAAM,qBAAqB,CAChC,QACA,YACG;AACH,SAAO,eACL,EAAE,KAAK,iBAAiB,UAAU,QAAQ,SAC1C;AAAA;AAIG,IAAM,gCAAgC,CAAC,WAAmB;AAAA,EAC/D,iBAAiB;AAAA;AAGZ,IAAM,wBAAwB,CAInC,QACA,YAQ2D;AAC3D,QAAM,EAAE,OAAO,cAAc,SAAS,mBAAmB,WAAW;AAEpE,QAAM,WACJ,8CAAc,aAAY,8BAA8B;AAE1D,QAAM,UAEF,MAAM,mBAAmB,QAAQ;AAErC,QAAM,QAAQ,SAIZ,UAAU,SAAS,iBAAE,SAAS,CAAC,CAAC,UAAW;AAE7C,SAAO;AAAA,IACL;AAAA,KACG;AAAA;AASA,IAAM,aAAa,CACxB,QACA,WACA,YACG;AACH,SAAO,eACL,EAAE,KAAK,iBAAiB,kBAAkB,aAAa,QAAQ,SAC/D;AAAA;AAIG,IAAM,wBAAwB,CAAC,QAAgB,cAAsB;AAAA,EAC1E,iBAAiB,kBAAkB;AAAA;AAG9B,IAAM,gBAAgB,CAI3B,QACA,WACA,YAI2D;AAC3D,QAAM,EAAE,OAAO,cAAc,SAAS,mBAAmB,WAAW;AAEpE,QAAM,WACJ,8CAAc,aAAY,sBAAsB,QAAQ;AAE1D,QAAM,UAA6D,MACjE,WAAW,QAAQ,WAAW;AAEhC,QAAM,QAAQ,SACZ,UACA,SACA,iBAAE,SAAS,CAAC,CAAE,WAAU,cAAe;AAGzC,SAAO;AAAA,IACL;AAAA,KACG;AAAA;AASA,IAAM,eAAe,CAC1B,QACA,WACA,sBACA,YACG;AACH,SAAO,eACL;AAAA,IACE,KAAK,iBAAiB,kBAAkB;AAAA,IACxC,QAAQ;AAAA,IACR,MAAM;AAAA,KAER;AAAA;AAIG,IAAM,kBAAkB,CAG7B,YAQI;AACJ,QAAM,EAAE,UAAU,iBAAiB,SAAS,mBAAmB,WAAW;AAE1E,QAAM,aAGF,CAAC,UAAU;AACb,UAAM,EAAE,QAAQ,WAAW,SAAS,SAAS;AAE7C,WAAO,aAAa,QAAQ,WAAW,MAAM;AAAA;AAG/C,SAAO,YAKL,YAAY;AAAA;",
6
6
  "names": []
7
7
  }
@@ -0,0 +1,7 @@
1
+ {
2
+ "module": "./service.js",
3
+ "main": "./service.cjs",
4
+ "types": "./service.d.ts",
5
+ "sideEffects": false,
6
+ "type": "module"
7
+ }
@@ -0,0 +1,100 @@
1
+ var __create = Object.create;
2
+ var __defProp = Object.defineProperty;
3
+ var __defProps = Object.defineProperties;
4
+ var __getOwnPropDesc = Object.getOwnPropertyDescriptor;
5
+ var __getOwnPropDescs = Object.getOwnPropertyDescriptors;
6
+ var __getOwnPropNames = Object.getOwnPropertyNames;
7
+ var __getOwnPropSymbols = Object.getOwnPropertySymbols;
8
+ var __getProtoOf = Object.getPrototypeOf;
9
+ var __hasOwnProp = Object.prototype.hasOwnProperty;
10
+ var __propIsEnum = Object.prototype.propertyIsEnumerable;
11
+ var __defNormalProp = (obj, key, value) => key in obj ? __defProp(obj, key, { enumerable: true, configurable: true, writable: true, value }) : obj[key] = value;
12
+ var __spreadValues = (a, b) => {
13
+ for (var prop in b || (b = {}))
14
+ if (__hasOwnProp.call(b, prop))
15
+ __defNormalProp(a, prop, b[prop]);
16
+ if (__getOwnPropSymbols)
17
+ for (var prop of __getOwnPropSymbols(b)) {
18
+ if (__propIsEnum.call(b, prop))
19
+ __defNormalProp(a, prop, b[prop]);
20
+ }
21
+ return a;
22
+ };
23
+ var __spreadProps = (a, b) => __defProps(a, __getOwnPropDescs(b));
24
+ var __markAsModule = (target) => __defProp(target, "__esModule", { value: true });
25
+ var __export = (target, all) => {
26
+ __markAsModule(target);
27
+ for (var name in all)
28
+ __defProp(target, name, { get: all[name], enumerable: true });
29
+ };
30
+ var __reExport = (target, module2, desc) => {
31
+ if (module2 && typeof module2 === "object" || typeof module2 === "function") {
32
+ for (let key of __getOwnPropNames(module2))
33
+ if (!__hasOwnProp.call(target, key) && key !== "default")
34
+ __defProp(target, key, { get: () => module2[key], enumerable: !(desc = __getOwnPropDesc(module2, key)) || desc.enumerable });
35
+ }
36
+ return target;
37
+ };
38
+ var __toModule = (module2) => {
39
+ return __reExport(__markAsModule(__defProp(module2 != null ? __create(__getProtoOf(module2)) : {}, "default", module2 && module2.__esModule && "default" in module2 ? { get: () => module2.default, enumerable: true } : { value: module2, enumerable: true })), module2);
40
+ };
41
+
42
+ // src/service/service.ts
43
+ __export(exports, {
44
+ getGetServiceQueryKey: () => getGetServiceQueryKey,
45
+ getGetServicesQueryKey: () => getGetServicesQueryKey,
46
+ getService: () => getService,
47
+ getServices: () => getServices,
48
+ useGetService: () => useGetService,
49
+ useGetServices: () => useGetServices
50
+ });
51
+ var import_react_query = __toModule(require("react-query"));
52
+
53
+ // src/custom-instance.ts
54
+ var import_axios = __toModule(require("axios"));
55
+ var AXIOS_INSTANCE = import_axios.default.create({ baseURL: "" });
56
+ var customInstance = (config, options) => {
57
+ const source = import_axios.default.CancelToken.source();
58
+ const promise = AXIOS_INSTANCE(__spreadProps(__spreadValues(__spreadValues({}, config), options), { cancelToken: source.token })).then(({ data }) => data);
59
+ promise.cancel = () => {
60
+ source.cancel("Query was cancelled by React Query");
61
+ };
62
+ return promise;
63
+ };
64
+
65
+ // src/service/service.ts
66
+ var getServices = (options) => {
67
+ return customInstance({ url: `/service`, method: "get" }, options);
68
+ };
69
+ var getGetServicesQueryKey = () => [`/service`];
70
+ var useGetServices = (options) => {
71
+ const { query: queryOptions, request: requestOptions } = options || {};
72
+ const queryKey = (queryOptions == null ? void 0 : queryOptions.queryKey) ?? getGetServicesQueryKey();
73
+ const queryFn = () => getServices(requestOptions);
74
+ const query = (0, import_react_query.useQuery)(queryKey, queryFn, queryOptions);
75
+ return __spreadValues({
76
+ queryKey
77
+ }, query);
78
+ };
79
+ var getService = (svcid, options) => {
80
+ return customInstance({ url: `/service/${svcid}`, method: "get" }, options);
81
+ };
82
+ var getGetServiceQueryKey = (svcid) => [`/service/${svcid}`];
83
+ var useGetService = (svcid, options) => {
84
+ const { query: queryOptions, request: requestOptions } = options || {};
85
+ const queryKey = (queryOptions == null ? void 0 : queryOptions.queryKey) ?? getGetServiceQueryKey(svcid);
86
+ const queryFn = () => getService(svcid, requestOptions);
87
+ const query = (0, import_react_query.useQuery)(queryKey, queryFn, __spreadValues({ enabled: !!svcid }, queryOptions));
88
+ return __spreadValues({
89
+ queryKey
90
+ }, query);
91
+ };
92
+ // Annotate the CommonJS export names for ESM import in node:
93
+ 0 && (module.exports = {
94
+ getGetServiceQueryKey,
95
+ getGetServicesQueryKey,
96
+ getService,
97
+ getServices,
98
+ useGetService,
99
+ useGetServices
100
+ });
@@ -0,0 +1,7 @@
1
+ {
2
+ "version": 3,
3
+ "sources": ["../../src/service/service.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 UseQueryOptions,\n QueryFunction,\n UseQueryResult,\n QueryKey,\n} from \"react-query\";\nimport type {\n ServicesGetResponse,\n AsError,\n ServiceGetResponse,\n} 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 services known to the Account Server\n\n * @summary Gets all Services\n */\nexport const getServices = (\n options?: SecondParameter<typeof customInstance>\n) => {\n return customInstance<ServicesGetResponse>(\n { url: `/service`, method: \"get\" },\n options\n );\n};\n\nexport const getGetServicesQueryKey = () => [`/service`];\n\nexport const useGetServices = <\n TData = AsyncReturnType<typeof getServices>,\n TError = ErrorType<AsError | void>\n>(options?: {\n query?: UseQueryOptions<AsyncReturnType<typeof getServices>, TError, TData>;\n request?: SecondParameter<typeof customInstance>;\n}): UseQueryResult<TData, TError> & { queryKey: QueryKey } => {\n const { query: queryOptions, request: requestOptions } = options || {};\n\n const queryKey = queryOptions?.queryKey ?? getGetServicesQueryKey();\n\n const queryFn: QueryFunction<AsyncReturnType<typeof getServices>> = () =>\n getServices(requestOptions);\n\n const query = useQuery<AsyncReturnType<typeof getServices>, TError, TData>(\n queryKey,\n queryFn,\n queryOptions\n );\n\n return {\n queryKey,\n ...query,\n };\n};\n\n/**\n * Gets a known service\n\n * @summary Gets a specific Service\n */\nexport const getService = (\n svcid: number,\n options?: SecondParameter<typeof customInstance>\n) => {\n return customInstance<ServiceGetResponse>(\n { url: `/service/${svcid}`, method: \"get\" },\n options\n );\n};\n\nexport const getGetServiceQueryKey = (svcid: number) => [`/service/${svcid}`];\n\nexport const useGetService = <\n TData = AsyncReturnType<typeof getService>,\n TError = ErrorType<AsError | void>\n>(\n svcid: number,\n options?: {\n query?: UseQueryOptions<AsyncReturnType<typeof getService>, TError, TData>;\n request?: SecondParameter<typeof customInstance>;\n }\n): UseQueryResult<TData, TError> & { queryKey: QueryKey } => {\n const { query: queryOptions, request: requestOptions } = options || {};\n\n const queryKey = queryOptions?.queryKey ?? getGetServiceQueryKey(svcid);\n\n const queryFn: QueryFunction<AsyncReturnType<typeof getService>> = () =>\n getService(svcid, requestOptions);\n\n const query = useQuery<AsyncReturnType<typeof getService>, TError, TData>(\n queryKey,\n queryFn,\n { enabled: !!svcid, ...queryOptions }\n );\n\n return {\n queryKey,\n ...query,\n };\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;AAUA,yBAMO;;;ACNP,mBAAsD;AAG/C,IAAM,iBAAiB,qBAAM,OAAO,EAAE,SAAS;AAmB/C,IAAM,iBAAiB,CAC5B,QACA,YACqB;AACrB,QAAM,SAAS,qBAAM,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;;;ADNF,IAAM,cAAc,CACzB,YACG;AACH,SAAO,eACL,EAAE,KAAK,YAAY,QAAQ,SAC3B;AAAA;AAIG,IAAM,yBAAyB,MAAM,CAAC;AAEtC,IAAM,iBAAiB,CAG5B,YAG4D;AAC5D,QAAM,EAAE,OAAO,cAAc,SAAS,mBAAmB,WAAW;AAEpE,QAAM,WAAW,8CAAc,aAAY;AAE3C,QAAM,UAA8D,MAClE,YAAY;AAEd,QAAM,QAAQ,iCACZ,UACA,SACA;AAGF,SAAO;AAAA,IACL;AAAA,KACG;AAAA;AASA,IAAM,aAAa,CACxB,OACA,YACG;AACH,SAAO,eACL,EAAE,KAAK,YAAY,SAAS,QAAQ,SACpC;AAAA;AAIG,IAAM,wBAAwB,CAAC,UAAkB,CAAC,YAAY;AAE9D,IAAM,gBAAgB,CAI3B,OACA,YAI2D;AAC3D,QAAM,EAAE,OAAO,cAAc,SAAS,mBAAmB,WAAW;AAEpE,QAAM,WAAW,8CAAc,aAAY,sBAAsB;AAEjE,QAAM,UAA6D,MACjE,WAAW,OAAO;AAEpB,QAAM,QAAQ,iCACZ,UACA,SACA,iBAAE,SAAS,CAAC,CAAC,SAAU;AAGzB,SAAO;AAAA,IACL;AAAA,KACG;AAAA;",
6
+ "names": []
7
+ }
@@ -0,0 +1,44 @@
1
+ import { UseQueryOptions, QueryKey, UseQueryResult } from 'react-query';
2
+ import { I as customInstance, f as ServicesGetResponse, J as ErrorType, E as AsError, S as ServiceGetResponse } from '../custom-instance-3334b00b';
3
+ import 'axios';
4
+
5
+ /**
6
+ * Generated by orval v6.4.2 🍺
7
+ * Do not edit manually.
8
+ * Account Server API
9
+ * The Informatics Matters Account Server API.
10
+
11
+ A service that provides access to the Account Server, which gives *registered* users access to and management of **Products**, **Organisations**, **Units** and **Users**.
12
+
13
+ * OpenAPI spec version: 0.1
14
+ */
15
+
16
+ declare type SecondParameter<T extends (...args: any) => any> = T extends (config: any, args: infer P) => any ? P : never;
17
+ /**
18
+ * Gets services known to the Account Server
19
+
20
+ * @summary Gets all Services
21
+ */
22
+ declare const getServices: (options?: SecondParameter<typeof customInstance>) => Promise<ServicesGetResponse>;
23
+ declare const getGetServicesQueryKey: () => string[];
24
+ declare const useGetServices: <TData = ServicesGetResponse, TError = ErrorType<void | AsError>>(options?: {
25
+ query?: UseQueryOptions<ServicesGetResponse, TError, TData, QueryKey> | undefined;
26
+ request?: SecondParameter<typeof customInstance>;
27
+ } | undefined) => UseQueryResult<TData, TError> & {
28
+ queryKey: QueryKey;
29
+ };
30
+ /**
31
+ * Gets a known service
32
+
33
+ * @summary Gets a specific Service
34
+ */
35
+ declare const getService: (svcid: number, options?: SecondParameter<typeof customInstance>) => Promise<ServiceGetResponse>;
36
+ declare const getGetServiceQueryKey: (svcid: number) => string[];
37
+ declare const useGetService: <TData = ServiceGetResponse, TError = ErrorType<void | AsError>>(svcid: number, options?: {
38
+ query?: UseQueryOptions<ServiceGetResponse, TError, TData, QueryKey> | undefined;
39
+ request?: SecondParameter<typeof customInstance>;
40
+ } | undefined) => UseQueryResult<TData, TError> & {
41
+ queryKey: QueryKey;
42
+ };
43
+
44
+ export { getGetServiceQueryKey, getGetServicesQueryKey, getService, getServices, useGetService, useGetServices };
@@ -0,0 +1,72 @@
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/service/service.ts
22
+ import {
23
+ useQuery
24
+ } from "react-query";
25
+
26
+ // src/custom-instance.ts
27
+ import Axios from "axios";
28
+ var AXIOS_INSTANCE = Axios.create({ baseURL: "" });
29
+ var customInstance = (config, options) => {
30
+ const source = Axios.CancelToken.source();
31
+ const promise = AXIOS_INSTANCE(__spreadProps(__spreadValues(__spreadValues({}, config), options), { cancelToken: source.token })).then(({ data }) => data);
32
+ promise.cancel = () => {
33
+ source.cancel("Query was cancelled by React Query");
34
+ };
35
+ return promise;
36
+ };
37
+
38
+ // src/service/service.ts
39
+ var getServices = (options) => {
40
+ return customInstance({ url: `/service`, method: "get" }, options);
41
+ };
42
+ var getGetServicesQueryKey = () => [`/service`];
43
+ var useGetServices = (options) => {
44
+ const { query: queryOptions, request: requestOptions } = options || {};
45
+ const queryKey = (queryOptions == null ? void 0 : queryOptions.queryKey) ?? getGetServicesQueryKey();
46
+ const queryFn = () => getServices(requestOptions);
47
+ const query = useQuery(queryKey, queryFn, queryOptions);
48
+ return __spreadValues({
49
+ queryKey
50
+ }, query);
51
+ };
52
+ var getService = (svcid, options) => {
53
+ return customInstance({ url: `/service/${svcid}`, method: "get" }, options);
54
+ };
55
+ var getGetServiceQueryKey = (svcid) => [`/service/${svcid}`];
56
+ var useGetService = (svcid, options) => {
57
+ const { query: queryOptions, request: requestOptions } = options || {};
58
+ const queryKey = (queryOptions == null ? void 0 : queryOptions.queryKey) ?? getGetServiceQueryKey(svcid);
59
+ const queryFn = () => getService(svcid, requestOptions);
60
+ const query = useQuery(queryKey, queryFn, __spreadValues({ enabled: !!svcid }, queryOptions));
61
+ return __spreadValues({
62
+ queryKey
63
+ }, query);
64
+ };
65
+ export {
66
+ getGetServiceQueryKey,
67
+ getGetServicesQueryKey,
68
+ getService,
69
+ getServices,
70
+ useGetService,
71
+ useGetServices
72
+ };
@@ -0,0 +1,7 @@
1
+ {
2
+ "version": 3,
3
+ "sources": ["../../src/service/service.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 UseQueryOptions,\n QueryFunction,\n UseQueryResult,\n QueryKey,\n} from \"react-query\";\nimport type {\n ServicesGetResponse,\n AsError,\n ServiceGetResponse,\n} 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 services known to the Account Server\n\n * @summary Gets all Services\n */\nexport const getServices = (\n options?: SecondParameter<typeof customInstance>\n) => {\n return customInstance<ServicesGetResponse>(\n { url: `/service`, method: \"get\" },\n options\n );\n};\n\nexport const getGetServicesQueryKey = () => [`/service`];\n\nexport const useGetServices = <\n TData = AsyncReturnType<typeof getServices>,\n TError = ErrorType<AsError | void>\n>(options?: {\n query?: UseQueryOptions<AsyncReturnType<typeof getServices>, TError, TData>;\n request?: SecondParameter<typeof customInstance>;\n}): UseQueryResult<TData, TError> & { queryKey: QueryKey } => {\n const { query: queryOptions, request: requestOptions } = options || {};\n\n const queryKey = queryOptions?.queryKey ?? getGetServicesQueryKey();\n\n const queryFn: QueryFunction<AsyncReturnType<typeof getServices>> = () =>\n getServices(requestOptions);\n\n const query = useQuery<AsyncReturnType<typeof getServices>, TError, TData>(\n queryKey,\n queryFn,\n queryOptions\n );\n\n return {\n queryKey,\n ...query,\n };\n};\n\n/**\n * Gets a known service\n\n * @summary Gets a specific Service\n */\nexport const getService = (\n svcid: number,\n options?: SecondParameter<typeof customInstance>\n) => {\n return customInstance<ServiceGetResponse>(\n { url: `/service/${svcid}`, method: \"get\" },\n options\n );\n};\n\nexport const getGetServiceQueryKey = (svcid: number) => [`/service/${svcid}`];\n\nexport const useGetService = <\n TData = AsyncReturnType<typeof getService>,\n TError = ErrorType<AsError | void>\n>(\n svcid: number,\n options?: {\n query?: UseQueryOptions<AsyncReturnType<typeof getService>, TError, TData>;\n request?: SecondParameter<typeof customInstance>;\n }\n): UseQueryResult<TData, TError> & { queryKey: QueryKey } => {\n const { query: queryOptions, request: requestOptions } = options || {};\n\n const queryKey = queryOptions?.queryKey ?? getGetServiceQueryKey(svcid);\n\n const queryFn: QueryFunction<AsyncReturnType<typeof getService>> = () =>\n getService(svcid, requestOptions);\n\n const query = useQuery<AsyncReturnType<typeof getService>, TError, TData>(\n queryKey,\n queryFn,\n { enabled: !!svcid, ...queryOptions }\n );\n\n return {\n queryKey,\n ...query,\n };\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;;;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;;;ADNF,IAAM,cAAc,CACzB,YACG;AACH,SAAO,eACL,EAAE,KAAK,YAAY,QAAQ,SAC3B;AAAA;AAIG,IAAM,yBAAyB,MAAM,CAAC;AAEtC,IAAM,iBAAiB,CAG5B,YAG4D;AAC5D,QAAM,EAAE,OAAO,cAAc,SAAS,mBAAmB,WAAW;AAEpE,QAAM,WAAW,8CAAc,aAAY;AAE3C,QAAM,UAA8D,MAClE,YAAY;AAEd,QAAM,QAAQ,SACZ,UACA,SACA;AAGF,SAAO;AAAA,IACL;AAAA,KACG;AAAA;AASA,IAAM,aAAa,CACxB,OACA,YACG;AACH,SAAO,eACL,EAAE,KAAK,YAAY,SAAS,QAAQ,SACpC;AAAA;AAIG,IAAM,wBAAwB,CAAC,UAAkB,CAAC,YAAY;AAE9D,IAAM,gBAAgB,CAI3B,OACA,YAI2D;AAC3D,QAAM,EAAE,OAAO,cAAc,SAAS,mBAAmB,WAAW;AAEpE,QAAM,WAAW,8CAAc,aAAY,sBAAsB;AAEjE,QAAM,UAA6D,MACjE,WAAW,OAAO;AAEpB,QAAM,QAAQ,SACZ,UACA,SACA,iBAAE,SAAS,CAAC,CAAC,SAAU;AAGzB,SAAO;AAAA,IACL;AAAA,KACG;AAAA;",
6
+ "names": []
7
+ }
@@ -0,0 +1,295 @@
1
+ /**
2
+ * Generated by orval v6.4.2 🍺
3
+ * Do not edit manually.
4
+ * Account Server API
5
+ * The Informatics Matters Account Server API.
6
+
7
+ A service that provides access to the Account Server, which gives *registered* users access to and management of **Products**, **Organisations**, **Units** and **Users**.
8
+
9
+ * OpenAPI spec version: 0.1
10
+ */
11
+ /**
12
+ * A dummy
13
+
14
+ */
15
+ export type QDummyParameter = boolean;
16
+
17
+ export type ProductPatchBodyBody = {
18
+ /** The name you want to give the Product */
19
+ name?: string;
20
+ /** The Product's built-in coin alloance. */
21
+ allowance?: number;
22
+ /** The Product's built-in coin limit. If set it must not be less than the allowance. If not set the allowance is used */
23
+ limit?: number;
24
+ };
25
+
26
+ /**
27
+ * The Flavour of the Product. Used only for Project Tier Products. Do nto set this for Storage products
28
+ */
29
+ export type UnitProductPostBodyBodyFlavour =
30
+ | "EVALUATION"
31
+ | "BRONZE"
32
+ | "SILVER"
33
+ | "GOLD";
34
+
35
+ // eslint-disable-next-line @typescript-eslint/no-redeclare
36
+ export const UnitProductPostBodyBodyFlavour = {
37
+ EVALUATION: "EVALUATION" as UnitProductPostBodyBodyFlavour,
38
+ BRONZE: "BRONZE" as UnitProductPostBodyBodyFlavour,
39
+ SILVER: "SILVER" as UnitProductPostBodyBodyFlavour,
40
+ GOLD: "GOLD" as UnitProductPostBodyBodyFlavour,
41
+ };
42
+
43
+ /**
44
+ * The Type of Product. Storage subscriptions require an **Allowance** to be defined and the **Flavour** must not be providec. Project Tier subscriptions have built-in allowances and Limits so you must not provide values for these for these products
45
+ */
46
+ export type UnitProductPostBodyBodyType =
47
+ | "DATA_MANAGER_PROJECT_TIER_SUBSCRIPTION"
48
+ | "DATA_MANAGER_STORAGE_SUBSCRIPTION";
49
+
50
+ // eslint-disable-next-line @typescript-eslint/no-redeclare
51
+ export const UnitProductPostBodyBodyType = {
52
+ DATA_MANAGER_PROJECT_TIER_SUBSCRIPTION:
53
+ "DATA_MANAGER_PROJECT_TIER_SUBSCRIPTION" as UnitProductPostBodyBodyType,
54
+ DATA_MANAGER_STORAGE_SUBSCRIPTION:
55
+ "DATA_MANAGER_STORAGE_SUBSCRIPTION" as UnitProductPostBodyBodyType,
56
+ };
57
+
58
+ export type UnitProductPostBodyBody = {
59
+ /** The name you want to give the Product */
60
+ name: string;
61
+ /** The service identity for the Product. Products are created for use on a specific service, like a Data Manager instance */
62
+ service_id: number;
63
+ /** The Type of Product. Storage subscriptions require an **Allowance** to be defined and the **Flavour** must not be providec. Project Tier subscriptions have built-in allowances and Limits so you must not provide values for these for these products */
64
+ type: UnitProductPostBodyBodyType;
65
+ /** The Flavour of the Product. Used only for Project Tier Products. Do nto set this for Storage products */
66
+ flavour?: UnitProductPostBodyBodyFlavour;
67
+ /** The Product's coin alloance. You must provide this for Storage products but you must not provide a value for Project Tier Products */
68
+ allowance?: number;
69
+ /** The Product's built-in coin limit. If set it must not be less than the allowance. If not set the allowance is used. You can provide this for Storage products but you must not provide a value for Project Tier Products */
70
+ limit?: number;
71
+ /** The day you would like to be billed for the Product's subscription (a value from 1 and 28) */
72
+ billing_day: number;
73
+ };
74
+
75
+ export type OrganisationUnitPostBodyBody = {
76
+ /** The name of the unit */
77
+ name: string;
78
+ };
79
+
80
+ export type OrganisationPostBodyBody = {
81
+ /** The name of the organisaion */
82
+ name: string;
83
+ /** The name of the organisation owner. A user ID */
84
+ owner: string;
85
+ };
86
+
87
+ export interface UserDetail {
88
+ id: string;
89
+ }
90
+
91
+ export interface UnitDetail {
92
+ id: string;
93
+ name: string;
94
+ owner_id?: string;
95
+ }
96
+
97
+ export interface ServiceGetResponse {
98
+ id: number;
99
+ kind: string;
100
+ name?: string;
101
+ }
102
+
103
+ export interface ServicesGetResponse {
104
+ /** The list of known Servcies
105
+ */
106
+ services: ServiceGetResponse[];
107
+ }
108
+
109
+ export interface OrganisationDetail {
110
+ id: string;
111
+ name: string;
112
+ owner_id?: string;
113
+ }
114
+
115
+ export type ProductInstanceDetailCoins = {
116
+ used: number;
117
+ };
118
+
119
+ export interface ProductInstanceDetail {
120
+ coins: ProductInstanceDetailCoins;
121
+ }
122
+
123
+ export type ProductDetailFlavour = "EVALUATION" | "BRONZE" | "SILVER" | "GOLD";
124
+
125
+ // eslint-disable-next-line @typescript-eslint/no-redeclare
126
+ export const ProductDetailFlavour = {
127
+ EVALUATION: "EVALUATION" as ProductDetailFlavour,
128
+ BRONZE: "BRONZE" as ProductDetailFlavour,
129
+ SILVER: "SILVER" as ProductDetailFlavour,
130
+ GOLD: "GOLD" as ProductDetailFlavour,
131
+ };
132
+
133
+ export type ProductDetailType =
134
+ | "DATA_MANAGER_PROJECT_TIER_SUBSCRIPTION"
135
+ | "DATA_MANAGER_STORAGE_SUBSCRIPTION";
136
+
137
+ // eslint-disable-next-line @typescript-eslint/no-redeclare
138
+ export const ProductDetailType = {
139
+ DATA_MANAGER_PROJECT_TIER_SUBSCRIPTION:
140
+ "DATA_MANAGER_PROJECT_TIER_SUBSCRIPTION" as ProductDetailType,
141
+ DATA_MANAGER_STORAGE_SUBSCRIPTION:
142
+ "DATA_MANAGER_STORAGE_SUBSCRIPTION" as ProductDetailType,
143
+ };
144
+
145
+ export interface ProductDetail {
146
+ /** The Product ID
147
+ */
148
+ id: string;
149
+ /** The Product Service ID
150
+ */
151
+ service_id?: number;
152
+ type: ProductDetailType;
153
+ flavour?: ProductDetailFlavour;
154
+ name?: string;
155
+ }
156
+
157
+ export interface ProductCoinsDetail {
158
+ /** The billing allowance. When you exceed this during the current billign period the *cost multipler* will increase */
159
+ allowance: number;
160
+ /** The limit on your billing period spend. You can exceed the allowance but you cannot exceed the spend limit. Once reached the dependent may be restricted */
161
+ limit: number;
162
+ /** The total number of coins consumed (in this billing period), exclding the coins that have been consumed for the current day */
163
+ used: number;
164
+ /** True if the product is oeprating at or beyond its coin limit. When it is authority to perform actions using the product are severly limited. */
165
+ at_limit: boolean;
166
+ /** The current burn rate, the approximate amount of coins you are currently consuming each day */
167
+ current_burn_rate: number;
168
+ /** The predicted billing period amount, if costs continue at the current burn rate until the end of the billing period */
169
+ billing_prediction: number;
170
+ /** The day of the month when the bill is due, and the end of the current billign period */
171
+ billing_day: number;
172
+ /** A multipler applied to your coin usage within yoru allowance */
173
+ allowance_multiplier: number;
174
+ /** A multipler that will be applied to coin used beyond your allowance */
175
+ overspend_multiplier: number;
176
+ /** The number of days remaining, in the current billing period */
177
+ remaining_days: number;
178
+ }
179
+
180
+ export interface ProductClaimDetail {
181
+ /** The service ID using this Subscription.
182
+ */
183
+ id: string;
184
+ /** A name for the service
185
+ */
186
+ name?: string;
187
+ }
188
+
189
+ export type ProductDmStorageDetailCoins = {
190
+ /** The number of coins currently committed for the current day. This is added to the acumulated coins at the start of each day */
191
+ used: number;
192
+ /** The coin cost of a 'unit' of strage or part thereof. The unit size is defined in the storage section of the response */
193
+ unit_cost: number;
194
+ };
195
+
196
+ export type ProductDmStorageDetailSize = {
197
+ /** The humanised size of the peak storage used for the current day. The value is reset at the start of each day */
198
+ peak: string;
199
+ /** The humanised size of the current storage used for the current day and used to calculate the 'burn rate' */
200
+ current: string;
201
+ /** The humanised storage unit. The cost of storage is based on the daily peak of the number of units (or part thereof) used */
202
+ unit_size: string;
203
+ /** The peak number of storage units used today */
204
+ units_used: number;
205
+ };
206
+
207
+ export interface ProductDmStorageDetail {
208
+ size: ProductDmStorageDetailSize;
209
+ coins: ProductDmStorageDetailCoins;
210
+ }
211
+
212
+ export interface ProductDmProjectTier {
213
+ product: ProductDetail;
214
+ organisation: OrganisationDetail;
215
+ unit: UnitDetail;
216
+ storage: ProductDmStorageDetail;
217
+ coins: ProductCoinsDetail;
218
+ instance: ProductInstanceDetail;
219
+ claim?: ProductClaimDetail;
220
+ }
221
+
222
+ export interface ProductDmStorage {
223
+ product: ProductDetail;
224
+ organisation: OrganisationDetail;
225
+ unit: UnitDetail;
226
+ storage: ProductDmStorageDetail;
227
+ coins: ProductCoinsDetail;
228
+ }
229
+
230
+ export interface UnitsGetResponse {
231
+ /** A list of Units
232
+ */
233
+ units: OrganisationUnitsGetResponse[];
234
+ }
235
+
236
+ export interface UnitProductPostResponse {
237
+ /** The products's unique ID */
238
+ id: string;
239
+ }
240
+
241
+ /**
242
+ * The Unit's Product
243
+ */
244
+ export type ProductUnitGetResponseProduct =
245
+ | ProductDmStorage
246
+ | ProductDmProjectTier;
247
+
248
+ export interface ProductUnitGetResponse {
249
+ /** The Unit's Product */
250
+ product: ProductUnitGetResponseProduct;
251
+ }
252
+
253
+ export type ProductsGetResponseProductsItem =
254
+ | ProductDmStorage
255
+ | ProductDmProjectTier;
256
+
257
+ export interface ProductsGetResponse {
258
+ /** All the Products you have access to */
259
+ products: ProductsGetResponseProductsItem[];
260
+ }
261
+
262
+ export interface OrganisationsGetResponse {
263
+ /** A list of Organisaions */
264
+ organisations: OrganisationDetail[];
265
+ }
266
+
267
+ export interface OrganisationUnitsGetResponse {
268
+ organisation: OrganisationDetail;
269
+ /** A list of Units
270
+ */
271
+ units: UnitDetail[];
272
+ }
273
+
274
+ export interface OrganisationUnitPostResponse {
275
+ /** The unit's unique ID */
276
+ id: string;
277
+ }
278
+
279
+ export interface UsersGetResponse {
280
+ organisation?: OrganisationDetail;
281
+ unit?: UnitDetail;
282
+ /** The list of Organisation Users
283
+ */
284
+ users: UserDetail[];
285
+ }
286
+
287
+ export interface OrganisationPostResponse {
288
+ /** The organisation's unique ID */
289
+ id: string;
290
+ }
291
+
292
+ export interface AsError {
293
+ /** Brief error text that can be presented to the user */
294
+ error: string;
295
+ }