@squonk/account-server-client 0.1.9-rc.1 → 0.1.13-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.
@@ -91,6 +91,14 @@ interface OrganisationDetail {
91
91
  name: string;
92
92
  owner_id?: string;
93
93
  }
94
+ interface ProductType {
95
+ /** A product type, this is a unique string amongst all types known to the Account Server */
96
+ type: string;
97
+ /** A product flavour. Not all types have a flavour, those that do have a type-specific flavour string */
98
+ flavour?: string;
99
+ /** For a product that belongs to a specific service, the service that owns it is provided */
100
+ service?: ServiceGetResponse;
101
+ }
94
102
  declare type ProductInstanceDetailCoins = {
95
103
  used: number;
96
104
  };
@@ -203,6 +211,10 @@ interface ProductUnitGetResponse {
203
211
  /** The Unit's Product */
204
212
  product: ProductUnitGetResponseProduct;
205
213
  }
214
+ interface ProductsGetTypesResponse {
215
+ /** All the Product Types you have access to */
216
+ product_types: ProductType[];
217
+ }
206
218
  declare type ProductsGetResponseProductsItem = ProductDmStorage | ProductDmProjectTier;
207
219
  interface ProductsGetResponse {
208
220
  /** All the Products you have access to */
@@ -253,4 +265,4 @@ declare const setBaseUrl: (baseUrl: string) => void;
253
265
  declare const customInstance: <TReturn>(config: AxiosRequestConfig, options?: AxiosRequestConfig<any> | undefined) => Promise<TReturn>;
254
266
  declare type ErrorType<TError> = AxiosError<TError>;
255
267
 
256
- export { OrganisationUnitsGetResponse as A, OrganisationUnitPostResponse as B, UsersGetResponse as C, OrganisationPostResponse as D, AsError as E, AXIOS_INSTANCE as F, setAuthToken as G, setBaseUrl as H, customInstance as I, ErrorType as J, OrganisationUnitPostBodyBody as O, ProductPatchBodyBody as P, QDummyParameter as Q, ServiceGetResponse as S, UnitProductPostBodyBodyFlavour as U, UnitProductPostBodyBodyType as a, UnitProductPostBodyBody as b, OrganisationPostBodyBody as c, UserDetail as d, UnitDetail as e, ServicesGetResponse as f, OrganisationDetail as g, ProductInstanceDetailCoins as h, ProductInstanceDetail as i, ProductDetailFlavour as j, ProductDetailType as k, ProductDetail as l, ProductCoinsDetail as m, ProductClaimDetail as n, ProductDmStorageDetailCoins as o, ProductDmStorageDetailSize as p, ProductDmStorageDetail as q, ProductDmProjectTier as r, ProductDmStorage as s, UnitsGetResponse as t, UnitProductPostResponse as u, ProductUnitGetResponseProduct as v, ProductUnitGetResponse as w, ProductsGetResponseProductsItem as x, ProductsGetResponse as y, OrganisationsGetResponse as z };
268
+ export { ProductsGetResponse as A, OrganisationsGetResponse as B, OrganisationUnitsGetResponse as C, OrganisationUnitPostResponse as D, UsersGetResponse as E, OrganisationPostResponse as F, AsError as G, AXIOS_INSTANCE as H, setAuthToken as I, setBaseUrl as J, customInstance as K, ErrorType as L, OrganisationUnitPostBodyBody as O, ProductPatchBodyBody as P, QDummyParameter as Q, ServiceGetResponse as S, UnitProductPostBodyBodyFlavour as U, UnitProductPostBodyBodyType as a, UnitProductPostBodyBody as b, OrganisationPostBodyBody as c, UserDetail as d, UnitDetail as e, ServicesGetResponse as f, OrganisationDetail as g, ProductType as h, ProductInstanceDetailCoins as i, ProductInstanceDetail as j, ProductDetailFlavour as k, ProductDetailType as l, ProductDetail as m, ProductCoinsDetail as n, ProductClaimDetail as o, ProductDmStorageDetailCoins as p, ProductDmStorageDetailSize as q, ProductDmStorageDetail as r, ProductDmProjectTier as s, ProductDmStorage as t, UnitsGetResponse as u, UnitProductPostResponse as v, ProductUnitGetResponseProduct as w, ProductUnitGetResponse as x, ProductsGetTypesResponse as y, ProductsGetResponseProductsItem as z };
package/index.cjs.map CHANGED
@@ -1,7 +1,7 @@
1
1
  {
2
2
  "version": 3,
3
3
  "sources": ["../src/index.ts", "../src/account-server-api.schemas.ts", "../src/custom-instance.ts"],
4
- "sourcesContent": ["// Generated by orval\n// account-server-api Is replaced with the api name\nexport * from './account-server-api.schemas';\n\n// Request instance and methods to change the baseUrl and auth token\nexport * from './custom-instance';\n", "/**\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 */\n/**\n * A dummy\n\n */\nexport type QDummyParameter = boolean;\n\nexport type ProductPatchBodyBody = {\n /** The name you want to give the Product */\n name?: string;\n /** The Product's built-in coin alloance. */\n allowance?: number;\n /** The Product's built-in coin limit. If set it must not be less than the allowance. If not set the allowance is used */\n limit?: number;\n};\n\n/**\n * The Flavour of the Product. Used only for Project Tier Products. Do nto set this for Storage products\n */\nexport type UnitProductPostBodyBodyFlavour =\n | \"EVALUATION\"\n | \"BRONZE\"\n | \"SILVER\"\n | \"GOLD\";\n\n// eslint-disable-next-line @typescript-eslint/no-redeclare\nexport const UnitProductPostBodyBodyFlavour = {\n EVALUATION: \"EVALUATION\" as UnitProductPostBodyBodyFlavour,\n BRONZE: \"BRONZE\" as UnitProductPostBodyBodyFlavour,\n SILVER: \"SILVER\" as UnitProductPostBodyBodyFlavour,\n GOLD: \"GOLD\" as UnitProductPostBodyBodyFlavour,\n};\n\n/**\n * 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\n */\nexport type UnitProductPostBodyBodyType =\n | \"DATA_MANAGER_PROJECT_TIER_SUBSCRIPTION\"\n | \"DATA_MANAGER_STORAGE_SUBSCRIPTION\";\n\n// eslint-disable-next-line @typescript-eslint/no-redeclare\nexport const UnitProductPostBodyBodyType = {\n DATA_MANAGER_PROJECT_TIER_SUBSCRIPTION:\n \"DATA_MANAGER_PROJECT_TIER_SUBSCRIPTION\" as UnitProductPostBodyBodyType,\n DATA_MANAGER_STORAGE_SUBSCRIPTION:\n \"DATA_MANAGER_STORAGE_SUBSCRIPTION\" as UnitProductPostBodyBodyType,\n};\n\nexport type UnitProductPostBodyBody = {\n /** The name you want to give the Product */\n name: string;\n /** The service identity for the Product. Products are created for use on a specific service, like a Data Manager instance */\n service_id: number;\n /** 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 */\n type: UnitProductPostBodyBodyType;\n /** The Flavour of the Product. Used only for Project Tier Products. Do nto set this for Storage products */\n flavour?: UnitProductPostBodyBodyFlavour;\n /** The Product's coin alloance. You must provide this for Storage products but you must not provide a value for Project Tier Products */\n allowance?: number;\n /** 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 */\n limit?: number;\n /** The day you would like to be billed for the Product's subscription (a value from 1 and 28) */\n billing_day: number;\n};\n\nexport type OrganisationUnitPostBodyBody = {\n /** The name of the unit */\n name: string;\n};\n\nexport type OrganisationPostBodyBody = {\n /** The name of the organisaion */\n name: string;\n /** The name of the organisation owner. A user ID */\n owner: string;\n};\n\nexport interface UserDetail {\n id: string;\n}\n\nexport interface UnitDetail {\n id: string;\n name: string;\n owner_id?: string;\n}\n\nexport interface ServiceGetResponse {\n id: number;\n kind: string;\n name?: string;\n}\n\nexport interface ServicesGetResponse {\n /** The list of known Servcies\n */\n services: ServiceGetResponse[];\n}\n\nexport interface OrganisationDetail {\n id: string;\n name: string;\n owner_id?: string;\n}\n\nexport type ProductInstanceDetailCoins = {\n used: number;\n};\n\nexport interface ProductInstanceDetail {\n coins: ProductInstanceDetailCoins;\n}\n\nexport type ProductDetailFlavour = \"EVALUATION\" | \"BRONZE\" | \"SILVER\" | \"GOLD\";\n\n// eslint-disable-next-line @typescript-eslint/no-redeclare\nexport const ProductDetailFlavour = {\n EVALUATION: \"EVALUATION\" as ProductDetailFlavour,\n BRONZE: \"BRONZE\" as ProductDetailFlavour,\n SILVER: \"SILVER\" as ProductDetailFlavour,\n GOLD: \"GOLD\" as ProductDetailFlavour,\n};\n\nexport type ProductDetailType =\n | \"DATA_MANAGER_PROJECT_TIER_SUBSCRIPTION\"\n | \"DATA_MANAGER_STORAGE_SUBSCRIPTION\";\n\n// eslint-disable-next-line @typescript-eslint/no-redeclare\nexport const ProductDetailType = {\n DATA_MANAGER_PROJECT_TIER_SUBSCRIPTION:\n \"DATA_MANAGER_PROJECT_TIER_SUBSCRIPTION\" as ProductDetailType,\n DATA_MANAGER_STORAGE_SUBSCRIPTION:\n \"DATA_MANAGER_STORAGE_SUBSCRIPTION\" as ProductDetailType,\n};\n\nexport interface ProductDetail {\n /** The Product ID\n */\n id: string;\n /** The Product Service ID\n */\n service_id?: number;\n type: ProductDetailType;\n flavour?: ProductDetailFlavour;\n name?: string;\n}\n\nexport interface ProductCoinsDetail {\n /** The billing allowance. When you exceed this during the current billign period the *cost multipler* will increase */\n allowance: number;\n /** 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 */\n limit: number;\n /** The total number of coins consumed (in this billing period), exclding the coins that have been consumed for the current day */\n used: number;\n /** 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. */\n at_limit: boolean;\n /** The current burn rate, the approximate amount of coins you are currently consuming each day */\n current_burn_rate: number;\n /** The predicted billing period amount, if costs continue at the current burn rate until the end of the billing period */\n billing_prediction: number;\n /** The day of the month when the bill is due, and the end of the current billign period */\n billing_day: number;\n /** A multipler applied to your coin usage within yoru allowance */\n allowance_multiplier: number;\n /** A multipler that will be applied to coin used beyond your allowance */\n overspend_multiplier: number;\n /** The number of days remaining, in the current billing period */\n remaining_days: number;\n}\n\nexport interface ProductClaimDetail {\n /** The service ID using this Subscription.\n */\n id: string;\n /** A name for the service\n */\n name?: string;\n}\n\nexport type ProductDmStorageDetailCoins = {\n /** The number of coins currently committed for the current day. This is added to the acumulated coins at the start of each day */\n used: number;\n /** The coin cost of a 'unit' of strage or part thereof. The unit size is defined in the storage section of the response */\n unit_cost: number;\n};\n\nexport type ProductDmStorageDetailSize = {\n /** The humanised size of the peak storage used for the current day. The value is reset at the start of each day */\n peak: string;\n /** The humanised size of the current storage used for the current day and used to calculate the 'burn rate' */\n current: string;\n /** The humanised storage unit. The cost of storage is based on the daily peak of the number of units (or part thereof) used */\n unit_size: string;\n /** The peak number of storage units used today */\n units_used: number;\n};\n\nexport interface ProductDmStorageDetail {\n size: ProductDmStorageDetailSize;\n coins: ProductDmStorageDetailCoins;\n}\n\nexport interface ProductDmProjectTier {\n product: ProductDetail;\n organisation: OrganisationDetail;\n unit: UnitDetail;\n storage: ProductDmStorageDetail;\n coins: ProductCoinsDetail;\n instance: ProductInstanceDetail;\n claim?: ProductClaimDetail;\n}\n\nexport interface ProductDmStorage {\n product: ProductDetail;\n organisation: OrganisationDetail;\n unit: UnitDetail;\n storage: ProductDmStorageDetail;\n coins: ProductCoinsDetail;\n}\n\nexport interface UnitsGetResponse {\n /** A list of Units\n */\n units: OrganisationUnitsGetResponse[];\n}\n\nexport interface UnitProductPostResponse {\n /** The products's unique ID */\n id: string;\n}\n\n/**\n * The Unit's Product\n */\nexport type ProductUnitGetResponseProduct =\n | ProductDmStorage\n | ProductDmProjectTier;\n\nexport interface ProductUnitGetResponse {\n /** The Unit's Product */\n product: ProductUnitGetResponseProduct;\n}\n\nexport type ProductsGetResponseProductsItem =\n | ProductDmStorage\n | ProductDmProjectTier;\n\nexport interface ProductsGetResponse {\n /** All the Products you have access to */\n products: ProductsGetResponseProductsItem[];\n}\n\nexport interface OrganisationsGetResponse {\n /** A list of Organisaions */\n organisations: OrganisationDetail[];\n}\n\nexport interface OrganisationUnitsGetResponse {\n organisation: OrganisationDetail;\n /** A list of Units\n */\n units: UnitDetail[];\n}\n\nexport interface OrganisationUnitPostResponse {\n /** The unit's unique ID */\n id: string;\n}\n\nexport interface UsersGetResponse {\n organisation?: OrganisationDetail;\n unit?: UnitDetail;\n /** The list of Organisation Users\n */\n users: UserDetail[];\n}\n\nexport interface OrganisationPostResponse {\n /** The organisation's unique ID */\n id: string;\n}\n\nexport interface AsError {\n /** Brief error text that can be presented to the user */\n error: string;\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;AAAA;;;ACmCO,IAAM,iCAAiC;AAAA,EAC5C,YAAY;AAAA,EACZ,QAAQ;AAAA,EACR,QAAQ;AAAA,EACR,MAAM;AAAA;AAWD,IAAM,8BAA8B;AAAA,EACzC,wCACE;AAAA,EACF,mCACE;AAAA;AAuEG,IAAM,uBAAuB;AAAA,EAClC,YAAY;AAAA,EACZ,QAAQ;AAAA,EACR,QAAQ;AAAA,EACR,MAAM;AAAA;AAQD,IAAM,oBAAoB;AAAA,EAC/B,wCACE;AAAA,EACF,mCACE;AAAA;;;ACnIJ,mBAAsD;AAG/C,IAAM,iBAAiB,qBAAM,OAAO,EAAE,SAAS;AAO/C,IAAM,eAAe,CAAC,UAAkB;AAC7C,iBAAe,SAAS,QAAQ,OAAO,mBAAmB,UAAU;AAAA;AAO/D,IAAM,aAAa,CAAC,YAAoB;AAC7C,iBAAe,SAAS,UAAU;AAAA;AAG7B,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;",
4
+ "sourcesContent": ["// Generated by orval\n// account-server-api Is replaced with the api name\nexport * from './account-server-api.schemas';\n\n// Request instance and methods to change the baseUrl and auth token\nexport * from './custom-instance';\n", "/**\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 */\n/**\n * A dummy\n\n */\nexport type QDummyParameter = boolean;\n\nexport type ProductPatchBodyBody = {\n /** The name you want to give the Product */\n name?: string;\n /** The Product's built-in coin alloance. */\n allowance?: number;\n /** The Product's built-in coin limit. If set it must not be less than the allowance. If not set the allowance is used */\n limit?: number;\n};\n\n/**\n * The Flavour of the Product. Used only for Project Tier Products. Do nto set this for Storage products\n */\nexport type UnitProductPostBodyBodyFlavour =\n | \"EVALUATION\"\n | \"BRONZE\"\n | \"SILVER\"\n | \"GOLD\";\n\n// eslint-disable-next-line @typescript-eslint/no-redeclare\nexport const UnitProductPostBodyBodyFlavour = {\n EVALUATION: \"EVALUATION\" as UnitProductPostBodyBodyFlavour,\n BRONZE: \"BRONZE\" as UnitProductPostBodyBodyFlavour,\n SILVER: \"SILVER\" as UnitProductPostBodyBodyFlavour,\n GOLD: \"GOLD\" as UnitProductPostBodyBodyFlavour,\n};\n\n/**\n * 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\n */\nexport type UnitProductPostBodyBodyType =\n | \"DATA_MANAGER_PROJECT_TIER_SUBSCRIPTION\"\n | \"DATA_MANAGER_STORAGE_SUBSCRIPTION\";\n\n// eslint-disable-next-line @typescript-eslint/no-redeclare\nexport const UnitProductPostBodyBodyType = {\n DATA_MANAGER_PROJECT_TIER_SUBSCRIPTION:\n \"DATA_MANAGER_PROJECT_TIER_SUBSCRIPTION\" as UnitProductPostBodyBodyType,\n DATA_MANAGER_STORAGE_SUBSCRIPTION:\n \"DATA_MANAGER_STORAGE_SUBSCRIPTION\" as UnitProductPostBodyBodyType,\n};\n\nexport type UnitProductPostBodyBody = {\n /** The name you want to give the Product */\n name: string;\n /** The service identity for the Product. Products are created for use on a specific service, like a Data Manager instance */\n service_id: number;\n /** 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 */\n type: UnitProductPostBodyBodyType;\n /** The Flavour of the Product. Used only for Project Tier Products. Do nto set this for Storage products */\n flavour?: UnitProductPostBodyBodyFlavour;\n /** The Product's coin alloance. You must provide this for Storage products but you must not provide a value for Project Tier Products */\n allowance?: number;\n /** 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 */\n limit?: number;\n /** The day you would like to be billed for the Product's subscription (a value from 1 and 28) */\n billing_day: number;\n};\n\nexport type OrganisationUnitPostBodyBody = {\n /** The name of the unit */\n name: string;\n};\n\nexport type OrganisationPostBodyBody = {\n /** The name of the organisaion */\n name: string;\n /** The name of the organisation owner. A user ID */\n owner: string;\n};\n\nexport interface UserDetail {\n id: string;\n}\n\nexport interface UnitDetail {\n id: string;\n name: string;\n owner_id?: string;\n}\n\nexport interface ServiceGetResponse {\n id: number;\n kind: string;\n name?: string;\n}\n\nexport interface ServicesGetResponse {\n /** The list of known Servcies\n */\n services: ServiceGetResponse[];\n}\n\nexport interface OrganisationDetail {\n id: string;\n name: string;\n owner_id?: string;\n}\n\nexport interface ProductType {\n /** A product type, this is a unique string amongst all types known to the Account Server */\n type: string;\n /** A product flavour. Not all types have a flavour, those that do have a type-specific flavour string */\n flavour?: string;\n /** For a product that belongs to a specific service, the service that owns it is provided */\n service?: ServiceGetResponse;\n}\n\nexport type ProductInstanceDetailCoins = {\n used: number;\n};\n\nexport interface ProductInstanceDetail {\n coins: ProductInstanceDetailCoins;\n}\n\nexport type ProductDetailFlavour = \"EVALUATION\" | \"BRONZE\" | \"SILVER\" | \"GOLD\";\n\n// eslint-disable-next-line @typescript-eslint/no-redeclare\nexport const ProductDetailFlavour = {\n EVALUATION: \"EVALUATION\" as ProductDetailFlavour,\n BRONZE: \"BRONZE\" as ProductDetailFlavour,\n SILVER: \"SILVER\" as ProductDetailFlavour,\n GOLD: \"GOLD\" as ProductDetailFlavour,\n};\n\nexport type ProductDetailType =\n | \"DATA_MANAGER_PROJECT_TIER_SUBSCRIPTION\"\n | \"DATA_MANAGER_STORAGE_SUBSCRIPTION\";\n\n// eslint-disable-next-line @typescript-eslint/no-redeclare\nexport const ProductDetailType = {\n DATA_MANAGER_PROJECT_TIER_SUBSCRIPTION:\n \"DATA_MANAGER_PROJECT_TIER_SUBSCRIPTION\" as ProductDetailType,\n DATA_MANAGER_STORAGE_SUBSCRIPTION:\n \"DATA_MANAGER_STORAGE_SUBSCRIPTION\" as ProductDetailType,\n};\n\nexport interface ProductDetail {\n /** The Product ID\n */\n id: string;\n /** The Product Service ID\n */\n service_id?: number;\n type: ProductDetailType;\n flavour?: ProductDetailFlavour;\n name?: string;\n}\n\nexport interface ProductCoinsDetail {\n /** The billing allowance. When you exceed this during the current billign period the *cost multipler* will increase */\n allowance: number;\n /** 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 */\n limit: number;\n /** The total number of coins consumed (in this billing period), exclding the coins that have been consumed for the current day */\n used: number;\n /** 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. */\n at_limit: boolean;\n /** The current burn rate, the approximate amount of coins you are currently consuming each day */\n current_burn_rate: number;\n /** The predicted billing period amount, if costs continue at the current burn rate until the end of the billing period */\n billing_prediction: number;\n /** The day of the month when the bill is due, and the end of the current billign period */\n billing_day: number;\n /** A multipler applied to your coin usage within yoru allowance */\n allowance_multiplier: number;\n /** A multipler that will be applied to coin used beyond your allowance */\n overspend_multiplier: number;\n /** The number of days remaining, in the current billing period */\n remaining_days: number;\n}\n\nexport interface ProductClaimDetail {\n /** The service ID using this Subscription.\n */\n id: string;\n /** A name for the service\n */\n name?: string;\n}\n\nexport type ProductDmStorageDetailCoins = {\n /** The number of coins currently committed for the current day. This is added to the acumulated coins at the start of each day */\n used: number;\n /** The coin cost of a 'unit' of strage or part thereof. The unit size is defined in the storage section of the response */\n unit_cost: number;\n};\n\nexport type ProductDmStorageDetailSize = {\n /** The humanised size of the peak storage used for the current day. The value is reset at the start of each day */\n peak: string;\n /** The humanised size of the current storage used for the current day and used to calculate the 'burn rate' */\n current: string;\n /** The humanised storage unit. The cost of storage is based on the daily peak of the number of units (or part thereof) used */\n unit_size: string;\n /** The peak number of storage units used today */\n units_used: number;\n};\n\nexport interface ProductDmStorageDetail {\n size: ProductDmStorageDetailSize;\n coins: ProductDmStorageDetailCoins;\n}\n\nexport interface ProductDmProjectTier {\n product: ProductDetail;\n organisation: OrganisationDetail;\n unit: UnitDetail;\n storage: ProductDmStorageDetail;\n coins: ProductCoinsDetail;\n instance: ProductInstanceDetail;\n claim?: ProductClaimDetail;\n}\n\nexport interface ProductDmStorage {\n product: ProductDetail;\n organisation: OrganisationDetail;\n unit: UnitDetail;\n storage: ProductDmStorageDetail;\n coins: ProductCoinsDetail;\n}\n\nexport interface UnitsGetResponse {\n /** A list of Units\n */\n units: OrganisationUnitsGetResponse[];\n}\n\nexport interface UnitProductPostResponse {\n /** The products's unique ID */\n id: string;\n}\n\n/**\n * The Unit's Product\n */\nexport type ProductUnitGetResponseProduct =\n | ProductDmStorage\n | ProductDmProjectTier;\n\nexport interface ProductUnitGetResponse {\n /** The Unit's Product */\n product: ProductUnitGetResponseProduct;\n}\n\nexport interface ProductsGetTypesResponse {\n /** All the Product Types you have access to */\n product_types: ProductType[];\n}\n\nexport type ProductsGetResponseProductsItem =\n | ProductDmStorage\n | ProductDmProjectTier;\n\nexport interface ProductsGetResponse {\n /** All the Products you have access to */\n products: ProductsGetResponseProductsItem[];\n}\n\nexport interface OrganisationsGetResponse {\n /** A list of Organisaions */\n organisations: OrganisationDetail[];\n}\n\nexport interface OrganisationUnitsGetResponse {\n organisation: OrganisationDetail;\n /** A list of Units\n */\n units: UnitDetail[];\n}\n\nexport interface OrganisationUnitPostResponse {\n /** The unit's unique ID */\n id: string;\n}\n\nexport interface UsersGetResponse {\n organisation?: OrganisationDetail;\n unit?: UnitDetail;\n /** The list of Organisation Users\n */\n users: UserDetail[];\n}\n\nexport interface OrganisationPostResponse {\n /** The organisation's unique ID */\n id: string;\n}\n\nexport interface AsError {\n /** Brief error text that can be presented to the user */\n error: string;\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;AAAA;;;ACmCO,IAAM,iCAAiC;AAAA,EAC5C,YAAY;AAAA,EACZ,QAAQ;AAAA,EACR,QAAQ;AAAA,EACR,MAAM;AAAA;AAWD,IAAM,8BAA8B;AAAA,EACzC,wCACE;AAAA,EACF,mCACE;AAAA;AAgFG,IAAM,uBAAuB;AAAA,EAClC,YAAY;AAAA,EACZ,QAAQ;AAAA,EACR,QAAQ;AAAA,EACR,MAAM;AAAA;AAQD,IAAM,oBAAoB;AAAA,EAC/B,wCACE;AAAA,EACF,mCACE;AAAA;;;AC5IJ,mBAAsD;AAG/C,IAAM,iBAAiB,qBAAM,OAAO,EAAE,SAAS;AAO/C,IAAM,eAAe,CAAC,UAAkB;AAC7C,iBAAe,SAAS,QAAQ,OAAO,mBAAmB,UAAU;AAAA;AAO/D,IAAM,aAAa,CAAC,YAAoB;AAC7C,iBAAe,SAAS,UAAU;AAAA;AAG7B,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;",
6
6
  "names": []
7
7
  }
package/index.d.ts CHANGED
@@ -1,2 +1,2 @@
1
- export { F as AXIOS_INSTANCE, E as AsError, J as ErrorType, g as OrganisationDetail, c as OrganisationPostBodyBody, D as OrganisationPostResponse, O as OrganisationUnitPostBodyBody, B as OrganisationUnitPostResponse, A as OrganisationUnitsGetResponse, z as OrganisationsGetResponse, n as ProductClaimDetail, m as ProductCoinsDetail, l as ProductDetail, j as ProductDetailFlavour, k as ProductDetailType, r as ProductDmProjectTier, s as ProductDmStorage, q as ProductDmStorageDetail, o as ProductDmStorageDetailCoins, p as ProductDmStorageDetailSize, i as ProductInstanceDetail, h as ProductInstanceDetailCoins, P as ProductPatchBodyBody, w as ProductUnitGetResponse, v as ProductUnitGetResponseProduct, y as ProductsGetResponse, x as ProductsGetResponseProductsItem, Q as QDummyParameter, S as ServiceGetResponse, f as ServicesGetResponse, e as UnitDetail, b as UnitProductPostBodyBody, U as UnitProductPostBodyBodyFlavour, a as UnitProductPostBodyBodyType, u as UnitProductPostResponse, t as UnitsGetResponse, d as UserDetail, C as UsersGetResponse, I as customInstance, G as setAuthToken, H as setBaseUrl } from './custom-instance-3334b00b';
1
+ export { H as AXIOS_INSTANCE, G as AsError, L as ErrorType, g as OrganisationDetail, c as OrganisationPostBodyBody, F as OrganisationPostResponse, O as OrganisationUnitPostBodyBody, D as OrganisationUnitPostResponse, C as OrganisationUnitsGetResponse, B as OrganisationsGetResponse, o as ProductClaimDetail, n as ProductCoinsDetail, m as ProductDetail, k as ProductDetailFlavour, l as ProductDetailType, s as ProductDmProjectTier, t as ProductDmStorage, r as ProductDmStorageDetail, p as ProductDmStorageDetailCoins, q as ProductDmStorageDetailSize, j as ProductInstanceDetail, i as ProductInstanceDetailCoins, P as ProductPatchBodyBody, h as ProductType, x as ProductUnitGetResponse, w as ProductUnitGetResponseProduct, A as ProductsGetResponse, z as ProductsGetResponseProductsItem, y as ProductsGetTypesResponse, Q as QDummyParameter, S as ServiceGetResponse, f as ServicesGetResponse, e as UnitDetail, b as UnitProductPostBodyBody, U as UnitProductPostBodyBodyFlavour, a as UnitProductPostBodyBodyType, v as UnitProductPostResponse, u as UnitsGetResponse, d as UserDetail, E as UsersGetResponse, K as customInstance, I as setAuthToken, J as setBaseUrl } from './custom-instance-108ca7f1';
2
2
  import 'axios';
package/index.js.map CHANGED
@@ -1,7 +1,7 @@
1
1
  {
2
2
  "version": 3,
3
3
  "sources": ["../src/account-server-api.schemas.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 */\n/**\n * A dummy\n\n */\nexport type QDummyParameter = boolean;\n\nexport type ProductPatchBodyBody = {\n /** The name you want to give the Product */\n name?: string;\n /** The Product's built-in coin alloance. */\n allowance?: number;\n /** The Product's built-in coin limit. If set it must not be less than the allowance. If not set the allowance is used */\n limit?: number;\n};\n\n/**\n * The Flavour of the Product. Used only for Project Tier Products. Do nto set this for Storage products\n */\nexport type UnitProductPostBodyBodyFlavour =\n | \"EVALUATION\"\n | \"BRONZE\"\n | \"SILVER\"\n | \"GOLD\";\n\n// eslint-disable-next-line @typescript-eslint/no-redeclare\nexport const UnitProductPostBodyBodyFlavour = {\n EVALUATION: \"EVALUATION\" as UnitProductPostBodyBodyFlavour,\n BRONZE: \"BRONZE\" as UnitProductPostBodyBodyFlavour,\n SILVER: \"SILVER\" as UnitProductPostBodyBodyFlavour,\n GOLD: \"GOLD\" as UnitProductPostBodyBodyFlavour,\n};\n\n/**\n * 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\n */\nexport type UnitProductPostBodyBodyType =\n | \"DATA_MANAGER_PROJECT_TIER_SUBSCRIPTION\"\n | \"DATA_MANAGER_STORAGE_SUBSCRIPTION\";\n\n// eslint-disable-next-line @typescript-eslint/no-redeclare\nexport const UnitProductPostBodyBodyType = {\n DATA_MANAGER_PROJECT_TIER_SUBSCRIPTION:\n \"DATA_MANAGER_PROJECT_TIER_SUBSCRIPTION\" as UnitProductPostBodyBodyType,\n DATA_MANAGER_STORAGE_SUBSCRIPTION:\n \"DATA_MANAGER_STORAGE_SUBSCRIPTION\" as UnitProductPostBodyBodyType,\n};\n\nexport type UnitProductPostBodyBody = {\n /** The name you want to give the Product */\n name: string;\n /** The service identity for the Product. Products are created for use on a specific service, like a Data Manager instance */\n service_id: number;\n /** 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 */\n type: UnitProductPostBodyBodyType;\n /** The Flavour of the Product. Used only for Project Tier Products. Do nto set this for Storage products */\n flavour?: UnitProductPostBodyBodyFlavour;\n /** The Product's coin alloance. You must provide this for Storage products but you must not provide a value for Project Tier Products */\n allowance?: number;\n /** 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 */\n limit?: number;\n /** The day you would like to be billed for the Product's subscription (a value from 1 and 28) */\n billing_day: number;\n};\n\nexport type OrganisationUnitPostBodyBody = {\n /** The name of the unit */\n name: string;\n};\n\nexport type OrganisationPostBodyBody = {\n /** The name of the organisaion */\n name: string;\n /** The name of the organisation owner. A user ID */\n owner: string;\n};\n\nexport interface UserDetail {\n id: string;\n}\n\nexport interface UnitDetail {\n id: string;\n name: string;\n owner_id?: string;\n}\n\nexport interface ServiceGetResponse {\n id: number;\n kind: string;\n name?: string;\n}\n\nexport interface ServicesGetResponse {\n /** The list of known Servcies\n */\n services: ServiceGetResponse[];\n}\n\nexport interface OrganisationDetail {\n id: string;\n name: string;\n owner_id?: string;\n}\n\nexport type ProductInstanceDetailCoins = {\n used: number;\n};\n\nexport interface ProductInstanceDetail {\n coins: ProductInstanceDetailCoins;\n}\n\nexport type ProductDetailFlavour = \"EVALUATION\" | \"BRONZE\" | \"SILVER\" | \"GOLD\";\n\n// eslint-disable-next-line @typescript-eslint/no-redeclare\nexport const ProductDetailFlavour = {\n EVALUATION: \"EVALUATION\" as ProductDetailFlavour,\n BRONZE: \"BRONZE\" as ProductDetailFlavour,\n SILVER: \"SILVER\" as ProductDetailFlavour,\n GOLD: \"GOLD\" as ProductDetailFlavour,\n};\n\nexport type ProductDetailType =\n | \"DATA_MANAGER_PROJECT_TIER_SUBSCRIPTION\"\n | \"DATA_MANAGER_STORAGE_SUBSCRIPTION\";\n\n// eslint-disable-next-line @typescript-eslint/no-redeclare\nexport const ProductDetailType = {\n DATA_MANAGER_PROJECT_TIER_SUBSCRIPTION:\n \"DATA_MANAGER_PROJECT_TIER_SUBSCRIPTION\" as ProductDetailType,\n DATA_MANAGER_STORAGE_SUBSCRIPTION:\n \"DATA_MANAGER_STORAGE_SUBSCRIPTION\" as ProductDetailType,\n};\n\nexport interface ProductDetail {\n /** The Product ID\n */\n id: string;\n /** The Product Service ID\n */\n service_id?: number;\n type: ProductDetailType;\n flavour?: ProductDetailFlavour;\n name?: string;\n}\n\nexport interface ProductCoinsDetail {\n /** The billing allowance. When you exceed this during the current billign period the *cost multipler* will increase */\n allowance: number;\n /** 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 */\n limit: number;\n /** The total number of coins consumed (in this billing period), exclding the coins that have been consumed for the current day */\n used: number;\n /** 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. */\n at_limit: boolean;\n /** The current burn rate, the approximate amount of coins you are currently consuming each day */\n current_burn_rate: number;\n /** The predicted billing period amount, if costs continue at the current burn rate until the end of the billing period */\n billing_prediction: number;\n /** The day of the month when the bill is due, and the end of the current billign period */\n billing_day: number;\n /** A multipler applied to your coin usage within yoru allowance */\n allowance_multiplier: number;\n /** A multipler that will be applied to coin used beyond your allowance */\n overspend_multiplier: number;\n /** The number of days remaining, in the current billing period */\n remaining_days: number;\n}\n\nexport interface ProductClaimDetail {\n /** The service ID using this Subscription.\n */\n id: string;\n /** A name for the service\n */\n name?: string;\n}\n\nexport type ProductDmStorageDetailCoins = {\n /** The number of coins currently committed for the current day. This is added to the acumulated coins at the start of each day */\n used: number;\n /** The coin cost of a 'unit' of strage or part thereof. The unit size is defined in the storage section of the response */\n unit_cost: number;\n};\n\nexport type ProductDmStorageDetailSize = {\n /** The humanised size of the peak storage used for the current day. The value is reset at the start of each day */\n peak: string;\n /** The humanised size of the current storage used for the current day and used to calculate the 'burn rate' */\n current: string;\n /** The humanised storage unit. The cost of storage is based on the daily peak of the number of units (or part thereof) used */\n unit_size: string;\n /** The peak number of storage units used today */\n units_used: number;\n};\n\nexport interface ProductDmStorageDetail {\n size: ProductDmStorageDetailSize;\n coins: ProductDmStorageDetailCoins;\n}\n\nexport interface ProductDmProjectTier {\n product: ProductDetail;\n organisation: OrganisationDetail;\n unit: UnitDetail;\n storage: ProductDmStorageDetail;\n coins: ProductCoinsDetail;\n instance: ProductInstanceDetail;\n claim?: ProductClaimDetail;\n}\n\nexport interface ProductDmStorage {\n product: ProductDetail;\n organisation: OrganisationDetail;\n unit: UnitDetail;\n storage: ProductDmStorageDetail;\n coins: ProductCoinsDetail;\n}\n\nexport interface UnitsGetResponse {\n /** A list of Units\n */\n units: OrganisationUnitsGetResponse[];\n}\n\nexport interface UnitProductPostResponse {\n /** The products's unique ID */\n id: string;\n}\n\n/**\n * The Unit's Product\n */\nexport type ProductUnitGetResponseProduct =\n | ProductDmStorage\n | ProductDmProjectTier;\n\nexport interface ProductUnitGetResponse {\n /** The Unit's Product */\n product: ProductUnitGetResponseProduct;\n}\n\nexport type ProductsGetResponseProductsItem =\n | ProductDmStorage\n | ProductDmProjectTier;\n\nexport interface ProductsGetResponse {\n /** All the Products you have access to */\n products: ProductsGetResponseProductsItem[];\n}\n\nexport interface OrganisationsGetResponse {\n /** A list of Organisaions */\n organisations: OrganisationDetail[];\n}\n\nexport interface OrganisationUnitsGetResponse {\n organisation: OrganisationDetail;\n /** A list of Units\n */\n units: UnitDetail[];\n}\n\nexport interface OrganisationUnitPostResponse {\n /** The unit's unique ID */\n id: string;\n}\n\nexport interface UsersGetResponse {\n organisation?: OrganisationDetail;\n unit?: UnitDetail;\n /** The list of Organisation Users\n */\n users: UserDetail[];\n}\n\nexport interface OrganisationPostResponse {\n /** The organisation's unique ID */\n id: string;\n}\n\nexport interface AsError {\n /** Brief error text that can be presented to the user */\n error: string;\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": ";;;;;;;;;;;;;;;;;;;;;AAmCO,IAAM,iCAAiC;AAAA,EAC5C,YAAY;AAAA,EACZ,QAAQ;AAAA,EACR,QAAQ;AAAA,EACR,MAAM;AAAA;AAWD,IAAM,8BAA8B;AAAA,EACzC,wCACE;AAAA,EACF,mCACE;AAAA;AAuEG,IAAM,uBAAuB;AAAA,EAClC,YAAY;AAAA,EACZ,QAAQ;AAAA,EACR,QAAQ;AAAA,EACR,MAAM;AAAA;AAQD,IAAM,oBAAoB;AAAA,EAC/B,wCACE;AAAA,EACF,mCACE;AAAA;;;ACnIJ;AAGO,IAAM,iBAAiB,MAAM,OAAO,EAAE,SAAS;AAO/C,IAAM,eAAe,CAAC,UAAkB;AAC7C,iBAAe,SAAS,QAAQ,OAAO,mBAAmB,UAAU;AAAA;AAO/D,IAAM,aAAa,CAAC,YAAoB;AAC7C,iBAAe,SAAS,UAAU;AAAA;AAG7B,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;",
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 */\n/**\n * A dummy\n\n */\nexport type QDummyParameter = boolean;\n\nexport type ProductPatchBodyBody = {\n /** The name you want to give the Product */\n name?: string;\n /** The Product's built-in coin alloance. */\n allowance?: number;\n /** The Product's built-in coin limit. If set it must not be less than the allowance. If not set the allowance is used */\n limit?: number;\n};\n\n/**\n * The Flavour of the Product. Used only for Project Tier Products. Do nto set this for Storage products\n */\nexport type UnitProductPostBodyBodyFlavour =\n | \"EVALUATION\"\n | \"BRONZE\"\n | \"SILVER\"\n | \"GOLD\";\n\n// eslint-disable-next-line @typescript-eslint/no-redeclare\nexport const UnitProductPostBodyBodyFlavour = {\n EVALUATION: \"EVALUATION\" as UnitProductPostBodyBodyFlavour,\n BRONZE: \"BRONZE\" as UnitProductPostBodyBodyFlavour,\n SILVER: \"SILVER\" as UnitProductPostBodyBodyFlavour,\n GOLD: \"GOLD\" as UnitProductPostBodyBodyFlavour,\n};\n\n/**\n * 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\n */\nexport type UnitProductPostBodyBodyType =\n | \"DATA_MANAGER_PROJECT_TIER_SUBSCRIPTION\"\n | \"DATA_MANAGER_STORAGE_SUBSCRIPTION\";\n\n// eslint-disable-next-line @typescript-eslint/no-redeclare\nexport const UnitProductPostBodyBodyType = {\n DATA_MANAGER_PROJECT_TIER_SUBSCRIPTION:\n \"DATA_MANAGER_PROJECT_TIER_SUBSCRIPTION\" as UnitProductPostBodyBodyType,\n DATA_MANAGER_STORAGE_SUBSCRIPTION:\n \"DATA_MANAGER_STORAGE_SUBSCRIPTION\" as UnitProductPostBodyBodyType,\n};\n\nexport type UnitProductPostBodyBody = {\n /** The name you want to give the Product */\n name: string;\n /** The service identity for the Product. Products are created for use on a specific service, like a Data Manager instance */\n service_id: number;\n /** 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 */\n type: UnitProductPostBodyBodyType;\n /** The Flavour of the Product. Used only for Project Tier Products. Do nto set this for Storage products */\n flavour?: UnitProductPostBodyBodyFlavour;\n /** The Product's coin alloance. You must provide this for Storage products but you must not provide a value for Project Tier Products */\n allowance?: number;\n /** 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 */\n limit?: number;\n /** The day you would like to be billed for the Product's subscription (a value from 1 and 28) */\n billing_day: number;\n};\n\nexport type OrganisationUnitPostBodyBody = {\n /** The name of the unit */\n name: string;\n};\n\nexport type OrganisationPostBodyBody = {\n /** The name of the organisaion */\n name: string;\n /** The name of the organisation owner. A user ID */\n owner: string;\n};\n\nexport interface UserDetail {\n id: string;\n}\n\nexport interface UnitDetail {\n id: string;\n name: string;\n owner_id?: string;\n}\n\nexport interface ServiceGetResponse {\n id: number;\n kind: string;\n name?: string;\n}\n\nexport interface ServicesGetResponse {\n /** The list of known Servcies\n */\n services: ServiceGetResponse[];\n}\n\nexport interface OrganisationDetail {\n id: string;\n name: string;\n owner_id?: string;\n}\n\nexport interface ProductType {\n /** A product type, this is a unique string amongst all types known to the Account Server */\n type: string;\n /** A product flavour. Not all types have a flavour, those that do have a type-specific flavour string */\n flavour?: string;\n /** For a product that belongs to a specific service, the service that owns it is provided */\n service?: ServiceGetResponse;\n}\n\nexport type ProductInstanceDetailCoins = {\n used: number;\n};\n\nexport interface ProductInstanceDetail {\n coins: ProductInstanceDetailCoins;\n}\n\nexport type ProductDetailFlavour = \"EVALUATION\" | \"BRONZE\" | \"SILVER\" | \"GOLD\";\n\n// eslint-disable-next-line @typescript-eslint/no-redeclare\nexport const ProductDetailFlavour = {\n EVALUATION: \"EVALUATION\" as ProductDetailFlavour,\n BRONZE: \"BRONZE\" as ProductDetailFlavour,\n SILVER: \"SILVER\" as ProductDetailFlavour,\n GOLD: \"GOLD\" as ProductDetailFlavour,\n};\n\nexport type ProductDetailType =\n | \"DATA_MANAGER_PROJECT_TIER_SUBSCRIPTION\"\n | \"DATA_MANAGER_STORAGE_SUBSCRIPTION\";\n\n// eslint-disable-next-line @typescript-eslint/no-redeclare\nexport const ProductDetailType = {\n DATA_MANAGER_PROJECT_TIER_SUBSCRIPTION:\n \"DATA_MANAGER_PROJECT_TIER_SUBSCRIPTION\" as ProductDetailType,\n DATA_MANAGER_STORAGE_SUBSCRIPTION:\n \"DATA_MANAGER_STORAGE_SUBSCRIPTION\" as ProductDetailType,\n};\n\nexport interface ProductDetail {\n /** The Product ID\n */\n id: string;\n /** The Product Service ID\n */\n service_id?: number;\n type: ProductDetailType;\n flavour?: ProductDetailFlavour;\n name?: string;\n}\n\nexport interface ProductCoinsDetail {\n /** The billing allowance. When you exceed this during the current billign period the *cost multipler* will increase */\n allowance: number;\n /** 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 */\n limit: number;\n /** The total number of coins consumed (in this billing period), exclding the coins that have been consumed for the current day */\n used: number;\n /** 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. */\n at_limit: boolean;\n /** The current burn rate, the approximate amount of coins you are currently consuming each day */\n current_burn_rate: number;\n /** The predicted billing period amount, if costs continue at the current burn rate until the end of the billing period */\n billing_prediction: number;\n /** The day of the month when the bill is due, and the end of the current billign period */\n billing_day: number;\n /** A multipler applied to your coin usage within yoru allowance */\n allowance_multiplier: number;\n /** A multipler that will be applied to coin used beyond your allowance */\n overspend_multiplier: number;\n /** The number of days remaining, in the current billing period */\n remaining_days: number;\n}\n\nexport interface ProductClaimDetail {\n /** The service ID using this Subscription.\n */\n id: string;\n /** A name for the service\n */\n name?: string;\n}\n\nexport type ProductDmStorageDetailCoins = {\n /** The number of coins currently committed for the current day. This is added to the acumulated coins at the start of each day */\n used: number;\n /** The coin cost of a 'unit' of strage or part thereof. The unit size is defined in the storage section of the response */\n unit_cost: number;\n};\n\nexport type ProductDmStorageDetailSize = {\n /** The humanised size of the peak storage used for the current day. The value is reset at the start of each day */\n peak: string;\n /** The humanised size of the current storage used for the current day and used to calculate the 'burn rate' */\n current: string;\n /** The humanised storage unit. The cost of storage is based on the daily peak of the number of units (or part thereof) used */\n unit_size: string;\n /** The peak number of storage units used today */\n units_used: number;\n};\n\nexport interface ProductDmStorageDetail {\n size: ProductDmStorageDetailSize;\n coins: ProductDmStorageDetailCoins;\n}\n\nexport interface ProductDmProjectTier {\n product: ProductDetail;\n organisation: OrganisationDetail;\n unit: UnitDetail;\n storage: ProductDmStorageDetail;\n coins: ProductCoinsDetail;\n instance: ProductInstanceDetail;\n claim?: ProductClaimDetail;\n}\n\nexport interface ProductDmStorage {\n product: ProductDetail;\n organisation: OrganisationDetail;\n unit: UnitDetail;\n storage: ProductDmStorageDetail;\n coins: ProductCoinsDetail;\n}\n\nexport interface UnitsGetResponse {\n /** A list of Units\n */\n units: OrganisationUnitsGetResponse[];\n}\n\nexport interface UnitProductPostResponse {\n /** The products's unique ID */\n id: string;\n}\n\n/**\n * The Unit's Product\n */\nexport type ProductUnitGetResponseProduct =\n | ProductDmStorage\n | ProductDmProjectTier;\n\nexport interface ProductUnitGetResponse {\n /** The Unit's Product */\n product: ProductUnitGetResponseProduct;\n}\n\nexport interface ProductsGetTypesResponse {\n /** All the Product Types you have access to */\n product_types: ProductType[];\n}\n\nexport type ProductsGetResponseProductsItem =\n | ProductDmStorage\n | ProductDmProjectTier;\n\nexport interface ProductsGetResponse {\n /** All the Products you have access to */\n products: ProductsGetResponseProductsItem[];\n}\n\nexport interface OrganisationsGetResponse {\n /** A list of Organisaions */\n organisations: OrganisationDetail[];\n}\n\nexport interface OrganisationUnitsGetResponse {\n organisation: OrganisationDetail;\n /** A list of Units\n */\n units: UnitDetail[];\n}\n\nexport interface OrganisationUnitPostResponse {\n /** The unit's unique ID */\n id: string;\n}\n\nexport interface UsersGetResponse {\n organisation?: OrganisationDetail;\n unit?: UnitDetail;\n /** The list of Organisation Users\n */\n users: UserDetail[];\n}\n\nexport interface OrganisationPostResponse {\n /** The organisation's unique ID */\n id: string;\n}\n\nexport interface AsError {\n /** Brief error text that can be presented to the user */\n error: string;\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": ";;;;;;;;;;;;;;;;;;;;;AAmCO,IAAM,iCAAiC;AAAA,EAC5C,YAAY;AAAA,EACZ,QAAQ;AAAA,EACR,QAAQ;AAAA,EACR,MAAM;AAAA;AAWD,IAAM,8BAA8B;AAAA,EACzC,wCACE;AAAA,EACF,mCACE;AAAA;AAgFG,IAAM,uBAAuB;AAAA,EAClC,YAAY;AAAA,EACZ,QAAQ;AAAA,EACR,QAAQ;AAAA,EACR,MAAM;AAAA;AAQD,IAAM,oBAAoB;AAAA,EAC/B,wCACE;AAAA,EACF,mCACE;AAAA;;;AC5IJ;AAGO,IAAM,iBAAiB,MAAM,OAAO,EAAE,SAAS;AAO/C,IAAM,eAAe,CAAC,UAAkB;AAC7C,iBAAe,SAAS,QAAQ,OAAO,mBAAmB,UAAU;AAAA;AAO/D,IAAM,aAAa,CAAC,YAAoB;AAC7C,iBAAe,SAAS,UAAU;AAAA;AAG7B,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;",
6
6
  "names": []
7
7
  }
@@ -1,6 +1,6 @@
1
1
  import * as react_query from 'react-query';
2
2
  import { UseQueryOptions, QueryKey, UseQueryResult, UseMutationOptions } from 'react-query';
3
- import { I as customInstance, z as OrganisationsGetResponse, J as ErrorType, E as AsError, c as OrganisationPostBodyBody, D as OrganisationPostResponse } from '../custom-instance-3334b00b';
3
+ import { K as customInstance, B as OrganisationsGetResponse, L as ErrorType, G as AsError, c as OrganisationPostBodyBody, F as OrganisationPostResponse } from '../custom-instance-108ca7f1';
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;
package/package.json CHANGED
@@ -1,5 +1,5 @@
1
1
  {
2
- "version": "0.1.9-rc.1",
2
+ "version": "0.1.13-rc.1",
3
3
  "author": "Oliver Dudgeon",
4
4
  "name": "@squonk/account-server-client",
5
5
  "private": false,
@@ -43,14 +43,17 @@ var __toModule = (module2) => {
43
43
  __export(exports, {
44
44
  createUnitProduct: () => createUnitProduct,
45
45
  getGetProductQueryKey: () => getGetProductQueryKey,
46
+ getGetProductTypesQueryKey: () => getGetProductTypesQueryKey,
46
47
  getGetProductsForUnitQueryKey: () => getGetProductsForUnitQueryKey,
47
48
  getGetProductsQueryKey: () => getGetProductsQueryKey,
48
49
  getProduct: () => getProduct,
50
+ getProductTypes: () => getProductTypes,
49
51
  getProducts: () => getProducts,
50
52
  getProductsForUnit: () => getProductsForUnit,
51
53
  patchProduct: () => patchProduct,
52
54
  useCreateUnitProduct: () => useCreateUnitProduct,
53
55
  useGetProduct: () => useGetProduct,
56
+ useGetProductTypes: () => useGetProductTypes,
54
57
  useGetProducts: () => useGetProducts,
55
58
  useGetProductsForUnit: () => useGetProductsForUnit,
56
59
  usePatchProduct: () => usePatchProduct
@@ -70,6 +73,19 @@ var customInstance = (config, options) => {
70
73
  };
71
74
 
72
75
  // src/product/product.ts
76
+ var getProductTypes = (options) => {
77
+ return customInstance({ url: `/product-type`, method: "get" }, options);
78
+ };
79
+ var getGetProductTypesQueryKey = () => [`/product-type`];
80
+ var useGetProductTypes = (options) => {
81
+ const { query: queryOptions, request: requestOptions } = options || {};
82
+ const queryKey = (queryOptions == null ? void 0 : queryOptions.queryKey) ?? getGetProductTypesQueryKey();
83
+ const queryFn = () => getProductTypes(requestOptions);
84
+ const query = (0, import_react_query.useQuery)(queryKey, queryFn, queryOptions);
85
+ return __spreadValues({
86
+ queryKey
87
+ }, query);
88
+ };
73
89
  var getProducts = (options) => {
74
90
  return customInstance({ url: `/product`, method: "get" }, options);
75
91
  };
@@ -147,14 +163,17 @@ var usePatchProduct = (options) => {
147
163
  0 && (module.exports = {
148
164
  createUnitProduct,
149
165
  getGetProductQueryKey,
166
+ getGetProductTypesQueryKey,
150
167
  getGetProductsForUnitQueryKey,
151
168
  getGetProductsQueryKey,
152
169
  getProduct,
170
+ getProductTypes,
153
171
  getProducts,
154
172
  getProductsForUnit,
155
173
  patchProduct,
156
174
  useCreateUnitProduct,
157
175
  useGetProduct,
176
+ useGetProductTypes,
158
177
  useGetProducts,
159
178
  useGetProductsForUnit,
160
179
  usePatchProduct
@@ -1,7 +1,7 @@
1
1
  {
2
2
  "version": 3,
3
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": "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",
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 ProductsGetTypesResponse,\n AsError,\n ProductsGetResponse,\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 product types you can purchase\n\n * @summary Gets all Product Types\n */\nexport const getProductTypes = (\n options?: SecondParameter<typeof customInstance>\n) => {\n return customInstance<ProductsGetTypesResponse>(\n { url: `/product-type`, method: \"get\" },\n options\n );\n};\n\nexport const getGetProductTypesQueryKey = () => [`/product-type`];\n\nexport const useGetProductTypes = <\n TData = AsyncReturnType<typeof getProductTypes>,\n TError = ErrorType<AsError | void>\n>(options?: {\n query?: UseQueryOptions<\n AsyncReturnType<typeof getProductTypes>,\n TError,\n TData\n >;\n request?: SecondParameter<typeof customInstance>;\n}): UseQueryResult<TData, TError> & { queryKey: QueryKey } => {\n const { query: queryOptions, request: requestOptions } = options || {};\n\n const queryKey = queryOptions?.queryKey ?? getGetProductTypesQueryKey();\n\n const queryFn: QueryFunction<AsyncReturnType<typeof getProductTypes>> = () =>\n getProductTypes(requestOptions);\n\n const query = useQuery<\n AsyncReturnType<typeof getProductTypes>,\n TError,\n TData\n >(queryKey, queryFn, queryOptions);\n\n return {\n queryKey,\n ...query,\n };\n};\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": "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",
6
6
  "names": []
7
7
  }
@@ -1,9 +1,22 @@
1
1
  import * as react_query from 'react-query';
2
2
  import { UseQueryOptions, QueryKey, UseQueryResult, UseMutationOptions } from 'react-query';
3
- import { I as customInstance, y as ProductsGetResponse, J as ErrorType, E as AsError, b as UnitProductPostBodyBody, u as UnitProductPostResponse, w as ProductUnitGetResponse, P as ProductPatchBodyBody } from '../custom-instance-3334b00b';
3
+ import { K as customInstance, y as ProductsGetTypesResponse, L as ErrorType, G as AsError, A as ProductsGetResponse, b as UnitProductPostBodyBody, v as UnitProductPostResponse, x as ProductUnitGetResponse, P as ProductPatchBodyBody } from '../custom-instance-108ca7f1';
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
+ /**
8
+ * Gets product types you can purchase
9
+
10
+ * @summary Gets all Product Types
11
+ */
12
+ declare const getProductTypes: (options?: SecondParameter<typeof customInstance>) => Promise<ProductsGetTypesResponse>;
13
+ declare const getGetProductTypesQueryKey: () => string[];
14
+ declare const useGetProductTypes: <TData = ProductsGetTypesResponse, TError = ErrorType<void | AsError>>(options?: {
15
+ query?: UseQueryOptions<ProductsGetTypesResponse, TError, TData, QueryKey> | undefined;
16
+ request?: SecondParameter<typeof customInstance>;
17
+ } | undefined) => UseQueryResult<TData, TError> & {
18
+ queryKey: QueryKey;
19
+ };
7
20
  /**
8
21
  * Gets products you have access to, across all Units and Organisations
9
22
 
@@ -76,4 +89,4 @@ declare const usePatchProduct: <TError = ErrorType<AsError>, TContext = unknown>
76
89
  data: ProductPatchBodyBody;
77
90
  }, TContext>;
78
91
 
79
- export { createUnitProduct, getGetProductQueryKey, getGetProductsForUnitQueryKey, getGetProductsQueryKey, getProduct, getProducts, getProductsForUnit, patchProduct, useCreateUnitProduct, useGetProduct, useGetProducts, useGetProductsForUnit, usePatchProduct };
92
+ export { createUnitProduct, getGetProductQueryKey, getGetProductTypesQueryKey, getGetProductsForUnitQueryKey, getGetProductsQueryKey, getProduct, getProductTypes, getProducts, getProductsForUnit, patchProduct, useCreateUnitProduct, useGetProduct, useGetProductTypes, useGetProducts, useGetProductsForUnit, usePatchProduct };
@@ -37,6 +37,19 @@ var customInstance = (config, options) => {
37
37
  };
38
38
 
39
39
  // src/product/product.ts
40
+ var getProductTypes = (options) => {
41
+ return customInstance({ url: `/product-type`, method: "get" }, options);
42
+ };
43
+ var getGetProductTypesQueryKey = () => [`/product-type`];
44
+ var useGetProductTypes = (options) => {
45
+ const { query: queryOptions, request: requestOptions } = options || {};
46
+ const queryKey = (queryOptions == null ? void 0 : queryOptions.queryKey) ?? getGetProductTypesQueryKey();
47
+ const queryFn = () => getProductTypes(requestOptions);
48
+ const query = useQuery(queryKey, queryFn, queryOptions);
49
+ return __spreadValues({
50
+ queryKey
51
+ }, query);
52
+ };
40
53
  var getProducts = (options) => {
41
54
  return customInstance({ url: `/product`, method: "get" }, options);
42
55
  };
@@ -113,14 +126,17 @@ var usePatchProduct = (options) => {
113
126
  export {
114
127
  createUnitProduct,
115
128
  getGetProductQueryKey,
129
+ getGetProductTypesQueryKey,
116
130
  getGetProductsForUnitQueryKey,
117
131
  getGetProductsQueryKey,
118
132
  getProduct,
133
+ getProductTypes,
119
134
  getProducts,
120
135
  getProductsForUnit,
121
136
  patchProduct,
122
137
  useCreateUnitProduct,
123
138
  useGetProduct,
139
+ useGetProductTypes,
124
140
  useGetProducts,
125
141
  useGetProductsForUnit,
126
142
  usePatchProduct
@@ -1,7 +1,7 @@
1
1
  {
2
2
  "version": 3,
3
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": "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",
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 ProductsGetTypesResponse,\n AsError,\n ProductsGetResponse,\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 product types you can purchase\n\n * @summary Gets all Product Types\n */\nexport const getProductTypes = (\n options?: SecondParameter<typeof customInstance>\n) => {\n return customInstance<ProductsGetTypesResponse>(\n { url: `/product-type`, method: \"get\" },\n options\n );\n};\n\nexport const getGetProductTypesQueryKey = () => [`/product-type`];\n\nexport const useGetProductTypes = <\n TData = AsyncReturnType<typeof getProductTypes>,\n TError = ErrorType<AsError | void>\n>(options?: {\n query?: UseQueryOptions<\n AsyncReturnType<typeof getProductTypes>,\n TError,\n TData\n >;\n request?: SecondParameter<typeof customInstance>;\n}): UseQueryResult<TData, TError> & { queryKey: QueryKey } => {\n const { query: queryOptions, request: requestOptions } = options || {};\n\n const queryKey = queryOptions?.queryKey ?? getGetProductTypesQueryKey();\n\n const queryFn: QueryFunction<AsyncReturnType<typeof getProductTypes>> = () =>\n getProductTypes(requestOptions);\n\n const query = useQuery<\n AsyncReturnType<typeof getProductTypes>,\n TError,\n TData\n >(queryKey, queryFn, queryOptions);\n\n return {\n queryKey,\n ...query,\n };\n};\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;;;ADCF,IAAM,kBAAkB,CAC7B,YACG;AACH,SAAO,eACL,EAAE,KAAK,iBAAiB,QAAQ,SAChC;AAAA;AAIG,IAAM,6BAA6B,MAAM,CAAC;AAE1C,IAAM,qBAAqB,CAGhC,YAO4D;AAC5D,QAAM,EAAE,OAAO,cAAc,SAAS,mBAAmB,WAAW;AAEpE,QAAM,WAAW,8CAAc,aAAY;AAE3C,QAAM,UAAkE,MACtE,gBAAgB;AAElB,QAAM,QAAQ,SAIZ,UAAU,SAAS;AAErB,SAAO;AAAA,IACL;AAAA,KACG;AAAA;AASA,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
  }
@@ -1,5 +1,5 @@
1
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';
2
+ import { K as customInstance, f as ServicesGetResponse, L as ErrorType, G as AsError, S as ServiceGetResponse } from '../custom-instance-108ca7f1';
3
3
  import 'axios';
4
4
 
5
5
  /**
@@ -112,6 +112,15 @@ export interface OrganisationDetail {
112
112
  owner_id?: string;
113
113
  }
114
114
 
115
+ export interface ProductType {
116
+ /** A product type, this is a unique string amongst all types known to the Account Server */
117
+ type: string;
118
+ /** A product flavour. Not all types have a flavour, those that do have a type-specific flavour string */
119
+ flavour?: string;
120
+ /** For a product that belongs to a specific service, the service that owns it is provided */
121
+ service?: ServiceGetResponse;
122
+ }
123
+
115
124
  export type ProductInstanceDetailCoins = {
116
125
  used: number;
117
126
  };
@@ -250,6 +259,11 @@ export interface ProductUnitGetResponse {
250
259
  product: ProductUnitGetResponseProduct;
251
260
  }
252
261
 
262
+ export interface ProductsGetTypesResponse {
263
+ /** All the Product Types you have access to */
264
+ product_types: ProductType[];
265
+ }
266
+
253
267
  export type ProductsGetResponseProductsItem =
254
268
  | ProductDmStorage
255
269
  | ProductDmProjectTier;
@@ -19,8 +19,9 @@ import {
19
19
  QueryKey,
20
20
  } from "react-query";
21
21
  import type {
22
- ProductsGetResponse,
22
+ ProductsGetTypesResponse,
23
23
  AsError,
24
+ ProductsGetResponse,
24
25
  UnitProductPostResponse,
25
26
  UnitProductPostBodyBody,
26
27
  ProductUnitGetResponse,
@@ -41,6 +42,52 @@ type SecondParameter<T extends (...args: any) => any> = T extends (
41
42
  ? P
42
43
  : never;
43
44
 
45
+ /**
46
+ * Gets product types you can purchase
47
+
48
+ * @summary Gets all Product Types
49
+ */
50
+ export const getProductTypes = (
51
+ options?: SecondParameter<typeof customInstance>
52
+ ) => {
53
+ return customInstance<ProductsGetTypesResponse>(
54
+ { url: `/product-type`, method: "get" },
55
+ options
56
+ );
57
+ };
58
+
59
+ export const getGetProductTypesQueryKey = () => [`/product-type`];
60
+
61
+ export const useGetProductTypes = <
62
+ TData = AsyncReturnType<typeof getProductTypes>,
63
+ TError = ErrorType<AsError | void>
64
+ >(options?: {
65
+ query?: UseQueryOptions<
66
+ AsyncReturnType<typeof getProductTypes>,
67
+ TError,
68
+ TData
69
+ >;
70
+ request?: SecondParameter<typeof customInstance>;
71
+ }): UseQueryResult<TData, TError> & { queryKey: QueryKey } => {
72
+ const { query: queryOptions, request: requestOptions } = options || {};
73
+
74
+ const queryKey = queryOptions?.queryKey ?? getGetProductTypesQueryKey();
75
+
76
+ const queryFn: QueryFunction<AsyncReturnType<typeof getProductTypes>> = () =>
77
+ getProductTypes(requestOptions);
78
+
79
+ const query = useQuery<
80
+ AsyncReturnType<typeof getProductTypes>,
81
+ TError,
82
+ TData
83
+ >(queryKey, queryFn, queryOptions);
84
+
85
+ return {
86
+ queryKey,
87
+ ...query,
88
+ };
89
+ };
90
+
44
91
  /**
45
92
  * Gets products you have access to, across all Units and Organisations
46
93
 
package/unit/unit.d.ts CHANGED
@@ -1,6 +1,6 @@
1
1
  import * as react_query from 'react-query';
2
2
  import { UseQueryOptions, QueryKey, UseQueryResult, UseMutationOptions } from 'react-query';
3
- import { I as customInstance, A as OrganisationUnitsGetResponse, J as ErrorType, E as AsError, O as OrganisationUnitPostBodyBody, B as OrganisationUnitPostResponse, t as UnitsGetResponse } from '../custom-instance-3334b00b';
3
+ import { K as customInstance, C as OrganisationUnitsGetResponse, L as ErrorType, G as AsError, O as OrganisationUnitPostBodyBody, D as OrganisationUnitPostResponse, u as UnitsGetResponse } from '../custom-instance-108ca7f1';
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;
package/user/user.d.ts CHANGED
@@ -1,6 +1,6 @@
1
1
  import * as react_query from 'react-query';
2
2
  import { UseQueryOptions, QueryKey, UseQueryResult, UseMutationOptions } from 'react-query';
3
- import { I as customInstance, C as UsersGetResponse, J as ErrorType, E as AsError } from '../custom-instance-3334b00b';
3
+ import { K as customInstance, E as UsersGetResponse, L as ErrorType, G as AsError } from '../custom-instance-108ca7f1';
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;