@squonk/account-server-client 0.1.6-rc.1 → 0.1.9-rc.1

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (49) hide show
  1. package/{custom-instance-d52e4104.d.ts → custom-instance-3334b00b.d.ts} +28 -6
  2. package/index.cjs +103 -2
  3. package/index.cjs.map +3 -3
  4. package/index.d.ts +1 -1
  5. package/index.js +69 -2
  6. package/index.js.map +3 -3
  7. package/organisation/organisation.cjs +111 -2
  8. package/organisation/organisation.cjs.map +3 -3
  9. package/organisation/organisation.d.ts +21 -7
  10. package/organisation/organisation.js +83 -2
  11. package/organisation/organisation.js.map +3 -3
  12. package/organisation/package.json +2 -1
  13. package/package.json +7 -7
  14. package/product/package.json +2 -1
  15. package/product/product.cjs +161 -2
  16. package/product/product.cjs.map +3 -3
  17. package/product/product.d.ts +7 -7
  18. package/product/product.js +127 -2
  19. package/product/product.js.map +3 -3
  20. package/service/package.json +7 -0
  21. package/service/service.cjs +100 -0
  22. package/service/service.cjs.map +7 -0
  23. package/service/service.d.ts +44 -0
  24. package/service/service.js +72 -0
  25. package/service/service.js.map +7 -0
  26. package/src/account-server-api.schemas.ts +295 -0
  27. package/src/custom-instance.ts +52 -0
  28. package/src/index.ts +6 -0
  29. package/src/organisation/organisation.ts +181 -0
  30. package/src/product/product.ts +289 -0
  31. package/src/service/service.ts +124 -0
  32. package/src/unit/unit.ts +322 -0
  33. package/src/user/user.ts +340 -0
  34. package/unit/package.json +2 -1
  35. package/unit/unit.cjs +168 -2
  36. package/unit/unit.cjs.map +3 -3
  37. package/unit/unit.d.ts +54 -5
  38. package/unit/unit.js +133 -2
  39. package/unit/unit.js.map +3 -3
  40. package/user/package.json +2 -1
  41. package/user/user.cjs +176 -2
  42. package/user/user.cjs.map +3 -3
  43. package/user/user.d.ts +13 -13
  44. package/user/user.js +141 -2
  45. package/user/user.js.map +3 -3
  46. package/chunk-33VR3IML.js +0 -2
  47. package/chunk-33VR3IML.js.map +0 -7
  48. package/chunk-3KO3PKBX.cjs +0 -2
  49. package/chunk-3KO3PKBX.cjs.map +0 -7
@@ -2,12 +2,12 @@ import * as axios from 'axios';
2
2
  import { AxiosRequestConfig, AxiosError } from 'axios';
3
3
 
4
4
  /**
5
- * Generated by orval v6.4.0 🍺
5
+ * Generated by orval v6.4.2 🍺
6
6
  * Do not edit manually.
7
7
  * Account Server API
8
8
  * The Informatics Matters Account Server API.
9
9
 
10
- A service that provides access to the Account Server, which gives *registered* users access to **Products**, **Organisations**, **Units** and **Users**.
10
+ A service that provides access to the Account Server, which gives *registered* users access to and management of **Products**, **Organisations**, **Units** and **Users**.
11
11
 
12
12
  * OpenAPI spec version: 0.1
13
13
  */
@@ -45,6 +45,8 @@ declare const UnitProductPostBodyBodyType: {
45
45
  declare type UnitProductPostBodyBody = {
46
46
  /** The name you want to give the Product */
47
47
  name: string;
48
+ /** The service identity for the Product. Products are created for use on a specific service, like a Data Manager instance */
49
+ service_id: number;
48
50
  /** 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 */
49
51
  type: UnitProductPostBodyBodyType;
50
52
  /** The Flavour of the Product. Used only for Project Tier Products. Do nto set this for Storage products */
@@ -63,6 +65,8 @@ declare type OrganisationUnitPostBodyBody = {
63
65
  declare type OrganisationPostBodyBody = {
64
66
  /** The name of the organisaion */
65
67
  name: string;
68
+ /** The name of the organisation owner. A user ID */
69
+ owner: string;
66
70
  };
67
71
  interface UserDetail {
68
72
  id: string;
@@ -70,12 +74,22 @@ interface UserDetail {
70
74
  interface UnitDetail {
71
75
  id: string;
72
76
  name: string;
73
- owner_id: string;
77
+ owner_id?: string;
78
+ }
79
+ interface ServiceGetResponse {
80
+ id: number;
81
+ kind: string;
82
+ name?: string;
83
+ }
84
+ interface ServicesGetResponse {
85
+ /** The list of known Servcies
86
+ */
87
+ services: ServiceGetResponse[];
74
88
  }
75
89
  interface OrganisationDetail {
76
90
  id: string;
77
91
  name: string;
78
- owner_id: string;
92
+ owner_id?: string;
79
93
  }
80
94
  declare type ProductInstanceDetailCoins = {
81
95
  used: number;
@@ -99,6 +113,9 @@ interface ProductDetail {
99
113
  /** The Product ID
100
114
  */
101
115
  id: string;
116
+ /** The Product Service ID
117
+ */
118
+ service_id?: number;
102
119
  type: ProductDetailType;
103
120
  flavour?: ProductDetailFlavour;
104
121
  name?: string;
@@ -169,6 +186,11 @@ interface ProductDmStorage {
169
186
  storage: ProductDmStorageDetail;
170
187
  coins: ProductCoinsDetail;
171
188
  }
189
+ interface UnitsGetResponse {
190
+ /** A list of Units
191
+ */
192
+ units: OrganisationUnitsGetResponse[];
193
+ }
172
194
  interface UnitProductPostResponse {
173
195
  /** The products's unique ID */
174
196
  id: string;
@@ -211,7 +233,7 @@ interface OrganisationPostResponse {
211
233
  /** The organisation's unique ID */
212
234
  id: string;
213
235
  }
214
- interface Error {
236
+ interface AsError {
215
237
  /** Brief error text that can be presented to the user */
216
238
  error: string;
217
239
  }
@@ -231,4 +253,4 @@ declare const setBaseUrl: (baseUrl: string) => void;
231
253
  declare const customInstance: <TReturn>(config: AxiosRequestConfig, options?: AxiosRequestConfig<any> | undefined) => Promise<TReturn>;
232
254
  declare type ErrorType<TError> = AxiosError<TError>;
233
255
 
234
- export { UsersGetResponse as A, OrganisationPostResponse as B, AXIOS_INSTANCE as C, setAuthToken as D, Error as E, setBaseUrl as F, customInstance as G, ErrorType as H, OrganisationUnitPostBodyBody as O, ProductPatchBodyBody as P, QDummyParameter as Q, UnitProductPostBodyBodyFlavour as U, UnitProductPostBodyBodyType as a, UnitProductPostBodyBody as b, OrganisationPostBodyBody as c, UserDetail as d, UnitDetail as e, OrganisationDetail as f, ProductInstanceDetailCoins as g, ProductInstanceDetail as h, ProductDetailFlavour as i, ProductDetailType as j, ProductDetail as k, ProductCoinsDetail as l, ProductClaimDetail as m, ProductDmStorageDetailCoins as n, ProductDmStorageDetailSize as o, ProductDmStorageDetail as p, ProductDmProjectTier as q, ProductDmStorage as r, UnitProductPostResponse as s, ProductUnitGetResponseProduct as t, ProductUnitGetResponse as u, ProductsGetResponseProductsItem as v, ProductsGetResponse as w, OrganisationsGetResponse as x, OrganisationUnitsGetResponse as y, OrganisationUnitPostResponse as z };
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 };
package/index.cjs CHANGED
@@ -1,2 +1,103 @@
1
- "use strict";Object.defineProperty(exports, "__esModule", {value: true});var _chunk3KO3PKBXcjs = require('./chunk-3KO3PKBX.cjs');var n={EVALUATION:"EVALUATION",BRONZE:"BRONZE",SILVER:"SILVER",GOLD:"GOLD"},a= exports.UnitProductPostBodyBodyType ={DATA_MANAGER_PROJECT_TIER_SUBSCRIPTION:"DATA_MANAGER_PROJECT_TIER_SUBSCRIPTION",DATA_MANAGER_STORAGE_SUBSCRIPTION:"DATA_MANAGER_STORAGE_SUBSCRIPTION"},s= exports.ProductDetailFlavour ={EVALUATION:"EVALUATION",BRONZE:"BRONZE",SILVER:"SILVER",GOLD:"GOLD"},u= exports.ProductDetailType ={DATA_MANAGER_PROJECT_TIER_SUBSCRIPTION:"DATA_MANAGER_PROJECT_TIER_SUBSCRIPTION",DATA_MANAGER_STORAGE_SUBSCRIPTION:"DATA_MANAGER_STORAGE_SUBSCRIPTION"};exports.AXIOS_INSTANCE = _chunk3KO3PKBXcjs.b; exports.ProductDetailFlavour = s; exports.ProductDetailType = u; exports.UnitProductPostBodyBodyFlavour = n; exports.UnitProductPostBodyBodyType = a; exports.customInstance = _chunk3KO3PKBXcjs.e; exports.setAuthToken = _chunk3KO3PKBXcjs.c; exports.setBaseUrl = _chunk3KO3PKBXcjs.d;
2
- //# sourceMappingURL=index.cjs.map
1
+ var __create = Object.create;
2
+ var __defProp = Object.defineProperty;
3
+ var __defProps = Object.defineProperties;
4
+ var __getOwnPropDesc = Object.getOwnPropertyDescriptor;
5
+ var __getOwnPropDescs = Object.getOwnPropertyDescriptors;
6
+ var __getOwnPropNames = Object.getOwnPropertyNames;
7
+ var __getOwnPropSymbols = Object.getOwnPropertySymbols;
8
+ var __getProtoOf = Object.getPrototypeOf;
9
+ var __hasOwnProp = Object.prototype.hasOwnProperty;
10
+ var __propIsEnum = Object.prototype.propertyIsEnumerable;
11
+ var __defNormalProp = (obj, key, value) => key in obj ? __defProp(obj, key, { enumerable: true, configurable: true, writable: true, value }) : obj[key] = value;
12
+ var __spreadValues = (a, b) => {
13
+ for (var prop in b || (b = {}))
14
+ if (__hasOwnProp.call(b, prop))
15
+ __defNormalProp(a, prop, b[prop]);
16
+ if (__getOwnPropSymbols)
17
+ for (var prop of __getOwnPropSymbols(b)) {
18
+ if (__propIsEnum.call(b, prop))
19
+ __defNormalProp(a, prop, b[prop]);
20
+ }
21
+ return a;
22
+ };
23
+ var __spreadProps = (a, b) => __defProps(a, __getOwnPropDescs(b));
24
+ var __markAsModule = (target) => __defProp(target, "__esModule", { value: true });
25
+ var __export = (target, all) => {
26
+ __markAsModule(target);
27
+ for (var name in all)
28
+ __defProp(target, name, { get: all[name], enumerable: true });
29
+ };
30
+ var __reExport = (target, module2, desc) => {
31
+ if (module2 && typeof module2 === "object" || typeof module2 === "function") {
32
+ for (let key of __getOwnPropNames(module2))
33
+ if (!__hasOwnProp.call(target, key) && key !== "default")
34
+ __defProp(target, key, { get: () => module2[key], enumerable: !(desc = __getOwnPropDesc(module2, key)) || desc.enumerable });
35
+ }
36
+ return target;
37
+ };
38
+ var __toModule = (module2) => {
39
+ return __reExport(__markAsModule(__defProp(module2 != null ? __create(__getProtoOf(module2)) : {}, "default", module2 && module2.__esModule && "default" in module2 ? { get: () => module2.default, enumerable: true } : { value: module2, enumerable: true })), module2);
40
+ };
41
+
42
+ // src/index.ts
43
+ __export(exports, {
44
+ AXIOS_INSTANCE: () => AXIOS_INSTANCE,
45
+ ProductDetailFlavour: () => ProductDetailFlavour,
46
+ ProductDetailType: () => ProductDetailType,
47
+ UnitProductPostBodyBodyFlavour: () => UnitProductPostBodyBodyFlavour,
48
+ UnitProductPostBodyBodyType: () => UnitProductPostBodyBodyType,
49
+ customInstance: () => customInstance,
50
+ setAuthToken: () => setAuthToken,
51
+ setBaseUrl: () => setBaseUrl
52
+ });
53
+
54
+ // src/account-server-api.schemas.ts
55
+ var UnitProductPostBodyBodyFlavour = {
56
+ EVALUATION: "EVALUATION",
57
+ BRONZE: "BRONZE",
58
+ SILVER: "SILVER",
59
+ GOLD: "GOLD"
60
+ };
61
+ var UnitProductPostBodyBodyType = {
62
+ DATA_MANAGER_PROJECT_TIER_SUBSCRIPTION: "DATA_MANAGER_PROJECT_TIER_SUBSCRIPTION",
63
+ DATA_MANAGER_STORAGE_SUBSCRIPTION: "DATA_MANAGER_STORAGE_SUBSCRIPTION"
64
+ };
65
+ var ProductDetailFlavour = {
66
+ EVALUATION: "EVALUATION",
67
+ BRONZE: "BRONZE",
68
+ SILVER: "SILVER",
69
+ GOLD: "GOLD"
70
+ };
71
+ var ProductDetailType = {
72
+ DATA_MANAGER_PROJECT_TIER_SUBSCRIPTION: "DATA_MANAGER_PROJECT_TIER_SUBSCRIPTION",
73
+ DATA_MANAGER_STORAGE_SUBSCRIPTION: "DATA_MANAGER_STORAGE_SUBSCRIPTION"
74
+ };
75
+
76
+ // src/custom-instance.ts
77
+ var import_axios = __toModule(require("axios"));
78
+ var AXIOS_INSTANCE = import_axios.default.create({ baseURL: "" });
79
+ var setAuthToken = (token) => {
80
+ AXIOS_INSTANCE.defaults.headers.common["Authorization"] = `Bearer ${token}`;
81
+ };
82
+ var setBaseUrl = (baseUrl) => {
83
+ AXIOS_INSTANCE.defaults.baseURL = baseUrl;
84
+ };
85
+ var customInstance = (config, options) => {
86
+ const source = import_axios.default.CancelToken.source();
87
+ const promise = AXIOS_INSTANCE(__spreadProps(__spreadValues(__spreadValues({}, config), options), { cancelToken: source.token })).then(({ data }) => data);
88
+ promise.cancel = () => {
89
+ source.cancel("Query was cancelled by React Query");
90
+ };
91
+ return promise;
92
+ };
93
+ // Annotate the CommonJS export names for ESM import in node:
94
+ 0 && (module.exports = {
95
+ AXIOS_INSTANCE,
96
+ ProductDetailFlavour,
97
+ ProductDetailType,
98
+ UnitProductPostBodyBodyFlavour,
99
+ UnitProductPostBodyBodyType,
100
+ customInstance,
101
+ setAuthToken,
102
+ setBaseUrl
103
+ });
package/index.cjs.map CHANGED
@@ -1,7 +1,7 @@
1
1
  {
2
2
  "version": 3,
3
- "sources": ["../src/account-server-api.schemas.ts"],
4
- "sourcesContent": ["/**\n * Generated by orval v6.4.0 \uD83C\uDF7A\n * Do not edit manually.\n * Account Server API\n * The Informatics Matters Account Server API.\n\nA service that provides access to the Account Server, which gives *registered* users access to **Products**, **Organisations**, **Units** and **Users**.\n\n * OpenAPI spec version: 0.1\n */\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 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};\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 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 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 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 Error {\n /** Brief error text that can be presented to the user */\n error: string;\n}\n"],
5
- "mappings": "8DAmCO,GAAM,GAAiC,CAC5C,WAAY,aACZ,OAAQ,SACR,OAAQ,SACR,KAAM,QAWK,EAA8B,CACzC,uCACE,yCACF,kCACE,qCAuDS,EAAuB,CAClC,WAAY,aACZ,OAAQ,SACR,OAAQ,SACR,KAAM,QAQK,EAAoB,CAC/B,uCACE,yCACF,kCACE",
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;",
6
6
  "names": []
7
7
  }
package/index.d.ts CHANGED
@@ -1,2 +1,2 @@
1
- export { C as AXIOS_INSTANCE, E as Error, H as ErrorType, f as OrganisationDetail, c as OrganisationPostBodyBody, B as OrganisationPostResponse, O as OrganisationUnitPostBodyBody, z as OrganisationUnitPostResponse, y as OrganisationUnitsGetResponse, x as OrganisationsGetResponse, m as ProductClaimDetail, l as ProductCoinsDetail, k as ProductDetail, i as ProductDetailFlavour, j as ProductDetailType, q as ProductDmProjectTier, r as ProductDmStorage, p as ProductDmStorageDetail, n as ProductDmStorageDetailCoins, o as ProductDmStorageDetailSize, h as ProductInstanceDetail, g as ProductInstanceDetailCoins, P as ProductPatchBodyBody, u as ProductUnitGetResponse, t as ProductUnitGetResponseProduct, w as ProductsGetResponse, v as ProductsGetResponseProductsItem, Q as QDummyParameter, e as UnitDetail, b as UnitProductPostBodyBody, U as UnitProductPostBodyBodyFlavour, a as UnitProductPostBodyBodyType, s as UnitProductPostResponse, d as UserDetail, A as UsersGetResponse, G as customInstance, D as setAuthToken, F as setBaseUrl } from './custom-instance-d52e4104';
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';
2
2
  import 'axios';
package/index.js CHANGED
@@ -1,2 +1,69 @@
1
- import{b as t,c as e,d as o,e as r}from"./chunk-33VR3IML.js";var i={EVALUATION:"EVALUATION",BRONZE:"BRONZE",SILVER:"SILVER",GOLD:"GOLD"},n={DATA_MANAGER_PROJECT_TIER_SUBSCRIPTION:"DATA_MANAGER_PROJECT_TIER_SUBSCRIPTION",DATA_MANAGER_STORAGE_SUBSCRIPTION:"DATA_MANAGER_STORAGE_SUBSCRIPTION"},a={EVALUATION:"EVALUATION",BRONZE:"BRONZE",SILVER:"SILVER",GOLD:"GOLD"},s={DATA_MANAGER_PROJECT_TIER_SUBSCRIPTION:"DATA_MANAGER_PROJECT_TIER_SUBSCRIPTION",DATA_MANAGER_STORAGE_SUBSCRIPTION:"DATA_MANAGER_STORAGE_SUBSCRIPTION"};export{t as AXIOS_INSTANCE,a as ProductDetailFlavour,s as ProductDetailType,i as UnitProductPostBodyBodyFlavour,n as UnitProductPostBodyBodyType,r as customInstance,e as setAuthToken,o as setBaseUrl};
2
- //# sourceMappingURL=index.js.map
1
+ var __defProp = Object.defineProperty;
2
+ var __defProps = Object.defineProperties;
3
+ var __getOwnPropDescs = Object.getOwnPropertyDescriptors;
4
+ var __getOwnPropSymbols = Object.getOwnPropertySymbols;
5
+ var __hasOwnProp = Object.prototype.hasOwnProperty;
6
+ var __propIsEnum = Object.prototype.propertyIsEnumerable;
7
+ var __defNormalProp = (obj, key, value) => key in obj ? __defProp(obj, key, { enumerable: true, configurable: true, writable: true, value }) : obj[key] = value;
8
+ var __spreadValues = (a, b) => {
9
+ for (var prop in b || (b = {}))
10
+ if (__hasOwnProp.call(b, prop))
11
+ __defNormalProp(a, prop, b[prop]);
12
+ if (__getOwnPropSymbols)
13
+ for (var prop of __getOwnPropSymbols(b)) {
14
+ if (__propIsEnum.call(b, prop))
15
+ __defNormalProp(a, prop, b[prop]);
16
+ }
17
+ return a;
18
+ };
19
+ var __spreadProps = (a, b) => __defProps(a, __getOwnPropDescs(b));
20
+
21
+ // src/account-server-api.schemas.ts
22
+ var UnitProductPostBodyBodyFlavour = {
23
+ EVALUATION: "EVALUATION",
24
+ BRONZE: "BRONZE",
25
+ SILVER: "SILVER",
26
+ GOLD: "GOLD"
27
+ };
28
+ var UnitProductPostBodyBodyType = {
29
+ DATA_MANAGER_PROJECT_TIER_SUBSCRIPTION: "DATA_MANAGER_PROJECT_TIER_SUBSCRIPTION",
30
+ DATA_MANAGER_STORAGE_SUBSCRIPTION: "DATA_MANAGER_STORAGE_SUBSCRIPTION"
31
+ };
32
+ var ProductDetailFlavour = {
33
+ EVALUATION: "EVALUATION",
34
+ BRONZE: "BRONZE",
35
+ SILVER: "SILVER",
36
+ GOLD: "GOLD"
37
+ };
38
+ var ProductDetailType = {
39
+ DATA_MANAGER_PROJECT_TIER_SUBSCRIPTION: "DATA_MANAGER_PROJECT_TIER_SUBSCRIPTION",
40
+ DATA_MANAGER_STORAGE_SUBSCRIPTION: "DATA_MANAGER_STORAGE_SUBSCRIPTION"
41
+ };
42
+
43
+ // src/custom-instance.ts
44
+ import Axios from "axios";
45
+ var AXIOS_INSTANCE = Axios.create({ baseURL: "" });
46
+ var setAuthToken = (token) => {
47
+ AXIOS_INSTANCE.defaults.headers.common["Authorization"] = `Bearer ${token}`;
48
+ };
49
+ var setBaseUrl = (baseUrl) => {
50
+ AXIOS_INSTANCE.defaults.baseURL = baseUrl;
51
+ };
52
+ var customInstance = (config, options) => {
53
+ const source = Axios.CancelToken.source();
54
+ const promise = AXIOS_INSTANCE(__spreadProps(__spreadValues(__spreadValues({}, config), options), { cancelToken: source.token })).then(({ data }) => data);
55
+ promise.cancel = () => {
56
+ source.cancel("Query was cancelled by React Query");
57
+ };
58
+ return promise;
59
+ };
60
+ export {
61
+ AXIOS_INSTANCE,
62
+ ProductDetailFlavour,
63
+ ProductDetailType,
64
+ UnitProductPostBodyBodyFlavour,
65
+ UnitProductPostBodyBodyType,
66
+ customInstance,
67
+ setAuthToken,
68
+ setBaseUrl
69
+ };
package/index.js.map CHANGED
@@ -1,7 +1,7 @@
1
1
  {
2
2
  "version": 3,
3
- "sources": ["../src/account-server-api.schemas.ts"],
4
- "sourcesContent": ["/**\n * Generated by orval v6.4.0 \uD83C\uDF7A\n * Do not edit manually.\n * Account Server API\n * The Informatics Matters Account Server API.\n\nA service that provides access to the Account Server, which gives *registered* users access to **Products**, **Organisations**, **Units** and **Users**.\n\n * OpenAPI spec version: 0.1\n */\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 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};\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 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 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 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 Error {\n /** Brief error text that can be presented to the user */\n error: string;\n}\n"],
5
- "mappings": "6DAmCO,GAAM,GAAiC,CAC5C,WAAY,aACZ,OAAQ,SACR,OAAQ,SACR,KAAM,QAWK,EAA8B,CACzC,uCACE,yCACF,kCACE,qCAuDS,EAAuB,CAClC,WAAY,aACZ,OAAQ,SACR,OAAQ,SACR,KAAM,QAQK,EAAoB,CAC/B,uCACE,yCACF,kCACE",
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;",
6
6
  "names": []
7
7
  }
@@ -1,2 +1,111 @@
1
- "use strict";Object.defineProperty(exports, "__esModule", {value: true});var _chunk3KO3PKBXcjs = require('../chunk-3KO3PKBX.cjs');var _reactquery = require('react-query');var p=e=>_chunk3KO3PKBXcjs.e.call(void 0, {url:"/organisation",method:"get"},e),g= exports.getGetOrganisationsQueryKey =()=>["/organisation"],Q= exports.useGetOrganisations =e=>{var i;let{query:t,request:n}=e||{},r=(i=t==null?void 0:t.queryKey)!=null?i:g(),o=_reactquery.useQuery.call(void 0, r,()=>p(n),t);return _chunk3KO3PKBXcjs.a.call(void 0, {queryKey:r},o)},T= exports.createOrganisation =(e,t)=>_chunk3KO3PKBXcjs.e.call(void 0, {url:"/organisation",method:"post",data:e},t),A= exports.useCreateOrganisation =e=>{let{mutation:t,request:n}=e||{};return _reactquery.useMutation.call(void 0, a=>{let{data:o}=a||{};return T(o,n)},t)};exports.createOrganisation = T; exports.getGetOrganisationsQueryKey = g; exports.getOrganisations = p; exports.useCreateOrganisation = A; exports.useGetOrganisations = Q;
2
- //# sourceMappingURL=organisation.cjs.map
1
+ var __create = Object.create;
2
+ var __defProp = Object.defineProperty;
3
+ var __defProps = Object.defineProperties;
4
+ var __getOwnPropDesc = Object.getOwnPropertyDescriptor;
5
+ var __getOwnPropDescs = Object.getOwnPropertyDescriptors;
6
+ var __getOwnPropNames = Object.getOwnPropertyNames;
7
+ var __getOwnPropSymbols = Object.getOwnPropertySymbols;
8
+ var __getProtoOf = Object.getPrototypeOf;
9
+ var __hasOwnProp = Object.prototype.hasOwnProperty;
10
+ var __propIsEnum = Object.prototype.propertyIsEnumerable;
11
+ var __defNormalProp = (obj, key, value) => key in obj ? __defProp(obj, key, { enumerable: true, configurable: true, writable: true, value }) : obj[key] = value;
12
+ var __spreadValues = (a, b) => {
13
+ for (var prop in b || (b = {}))
14
+ if (__hasOwnProp.call(b, prop))
15
+ __defNormalProp(a, prop, b[prop]);
16
+ if (__getOwnPropSymbols)
17
+ for (var prop of __getOwnPropSymbols(b)) {
18
+ if (__propIsEnum.call(b, prop))
19
+ __defNormalProp(a, prop, b[prop]);
20
+ }
21
+ return a;
22
+ };
23
+ var __spreadProps = (a, b) => __defProps(a, __getOwnPropDescs(b));
24
+ var __markAsModule = (target) => __defProp(target, "__esModule", { value: true });
25
+ var __export = (target, all) => {
26
+ __markAsModule(target);
27
+ for (var name in all)
28
+ __defProp(target, name, { get: all[name], enumerable: true });
29
+ };
30
+ var __reExport = (target, module2, desc) => {
31
+ if (module2 && typeof module2 === "object" || typeof module2 === "function") {
32
+ for (let key of __getOwnPropNames(module2))
33
+ if (!__hasOwnProp.call(target, key) && key !== "default")
34
+ __defProp(target, key, { get: () => module2[key], enumerable: !(desc = __getOwnPropDesc(module2, key)) || desc.enumerable });
35
+ }
36
+ return target;
37
+ };
38
+ var __toModule = (module2) => {
39
+ return __reExport(__markAsModule(__defProp(module2 != null ? __create(__getProtoOf(module2)) : {}, "default", module2 && module2.__esModule && "default" in module2 ? { get: () => module2.default, enumerable: true } : { value: module2, enumerable: true })), module2);
40
+ };
41
+
42
+ // src/organisation/organisation.ts
43
+ __export(exports, {
44
+ createOrganisation: () => createOrganisation,
45
+ deleteOrganisation: () => deleteOrganisation,
46
+ getGetOrganisationsQueryKey: () => getGetOrganisationsQueryKey,
47
+ getOrganisations: () => getOrganisations,
48
+ useCreateOrganisation: () => useCreateOrganisation,
49
+ useDeleteOrganisation: () => useDeleteOrganisation,
50
+ useGetOrganisations: () => useGetOrganisations
51
+ });
52
+ var import_react_query = __toModule(require("react-query"));
53
+
54
+ // src/custom-instance.ts
55
+ var import_axios = __toModule(require("axios"));
56
+ var AXIOS_INSTANCE = import_axios.default.create({ baseURL: "" });
57
+ var customInstance = (config, options) => {
58
+ const source = import_axios.default.CancelToken.source();
59
+ const promise = AXIOS_INSTANCE(__spreadProps(__spreadValues(__spreadValues({}, config), options), { cancelToken: source.token })).then(({ data }) => data);
60
+ promise.cancel = () => {
61
+ source.cancel("Query was cancelled by React Query");
62
+ };
63
+ return promise;
64
+ };
65
+
66
+ // src/organisation/organisation.ts
67
+ var getOrganisations = (options) => {
68
+ return customInstance({ url: `/organisation`, method: "get" }, options);
69
+ };
70
+ var getGetOrganisationsQueryKey = () => [`/organisation`];
71
+ var useGetOrganisations = (options) => {
72
+ const { query: queryOptions, request: requestOptions } = options || {};
73
+ const queryKey = (queryOptions == null ? void 0 : queryOptions.queryKey) ?? getGetOrganisationsQueryKey();
74
+ const queryFn = () => getOrganisations(requestOptions);
75
+ const query = (0, import_react_query.useQuery)(queryKey, queryFn, queryOptions);
76
+ return __spreadValues({
77
+ queryKey
78
+ }, query);
79
+ };
80
+ var createOrganisation = (organisationPostBodyBody, options) => {
81
+ return customInstance({ url: `/organisation`, method: "post", data: organisationPostBodyBody }, options);
82
+ };
83
+ var useCreateOrganisation = (options) => {
84
+ const { mutation: mutationOptions, request: requestOptions } = options || {};
85
+ const mutationFn = (props) => {
86
+ const { data } = props || {};
87
+ return createOrganisation(data, requestOptions);
88
+ };
89
+ return (0, import_react_query.useMutation)(mutationFn, mutationOptions);
90
+ };
91
+ var deleteOrganisation = (orgid, options) => {
92
+ return customInstance({ url: `/organisation/${orgid}`, method: "delete", data: void 0 }, options);
93
+ };
94
+ var useDeleteOrganisation = (options) => {
95
+ const { mutation: mutationOptions, request: requestOptions } = options || {};
96
+ const mutationFn = (props) => {
97
+ const { orgid } = props || {};
98
+ return deleteOrganisation(orgid, requestOptions);
99
+ };
100
+ return (0, import_react_query.useMutation)(mutationFn, mutationOptions);
101
+ };
102
+ // Annotate the CommonJS export names for ESM import in node:
103
+ 0 && (module.exports = {
104
+ createOrganisation,
105
+ deleteOrganisation,
106
+ getGetOrganisationsQueryKey,
107
+ getOrganisations,
108
+ useCreateOrganisation,
109
+ useDeleteOrganisation,
110
+ useGetOrganisations
111
+ });
@@ -1,7 +1,7 @@
1
1
  {
2
2
  "version": 3,
3
- "sources": ["../../src/organisation/organisation.ts"],
4
- "sourcesContent": ["/**\n * Generated by orval v6.4.0 \uD83C\uDF7A\n * Do not edit manually.\n * Account Server API\n * The Informatics Matters Account Server API.\n\nA service that provides access to the Account Server, which gives *registered* users access to **Products**, **Organisations**, **Units** and **Users**.\n\n * OpenAPI spec version: 0.1\n */\nimport {\n useQuery,\n useMutation,\n UseQueryOptions,\n UseMutationOptions,\n QueryFunction,\n MutationFunction,\n UseQueryResult,\n QueryKey,\n} from \"react-query\";\nimport type {\n OrganisationsGetResponse,\n Error,\n OrganisationPostResponse,\n OrganisationPostBodyBody,\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 all the Organisations\n\nYou need **admin** rights to use this method\n\n * @summary Gets Organisations\n */\nexport const getOrganisations = (\n options?: SecondParameter<typeof customInstance>\n) => {\n return customInstance<OrganisationsGetResponse>(\n { url: `/organisation`, method: \"get\" },\n options\n );\n};\n\nexport const getGetOrganisationsQueryKey = () => [`/organisation`];\n\nexport const useGetOrganisations = <\n TData = AsyncReturnType<typeof getOrganisations>,\n TError = ErrorType<void | Error>\n>(options?: {\n query?: UseQueryOptions<\n AsyncReturnType<typeof getOrganisations>,\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 ?? getGetOrganisationsQueryKey();\n\n const queryFn: QueryFunction<AsyncReturnType<typeof getOrganisations>> = () =>\n getOrganisations(requestOptions);\n\n const query = useQuery<\n AsyncReturnType<typeof getOrganisations>,\n TError,\n TData\n >(queryKey, queryFn, queryOptions);\n\n return {\n queryKey,\n ...query,\n };\n};\n\n/**\n * Creates a new Organisation\n\nYou need **admin** rights to use this method\n\n * @summary Create a new organisation\n */\nexport const createOrganisation = (\n organisationPostBodyBody: OrganisationPostBodyBody,\n options?: SecondParameter<typeof customInstance>\n) => {\n return customInstance<OrganisationPostResponse>(\n { url: `/organisation`, method: \"post\", data: organisationPostBodyBody },\n options\n );\n};\n\nexport const useCreateOrganisation = <\n TError = ErrorType<Error | void>,\n TContext = unknown\n>(options?: {\n mutation?: UseMutationOptions<\n AsyncReturnType<typeof createOrganisation>,\n TError,\n { data: OrganisationPostBodyBody },\n TContext\n >;\n request?: SecondParameter<typeof customInstance>;\n}) => {\n const { mutation: mutationOptions, request: requestOptions } = options || {};\n\n const mutationFn: MutationFunction<\n AsyncReturnType<typeof createOrganisation>,\n { data: OrganisationPostBodyBody }\n > = (props) => {\n const { data } = props || {};\n\n return createOrganisation(data, requestOptions);\n };\n\n return useMutation<\n AsyncReturnType<typeof createOrganisation>,\n TError,\n { data: OrganisationPostBodyBody },\n TContext\n >(mutationFn, mutationOptions);\n};\n"],
5
- "mappings": "iDAUA,wDAsCO,GAAM,GAAmB,AAC9B,GAEO,EACL,CAAE,IAAK,gBAAiB,OAAQ,OAChC,GAIS,EAA8B,IAAM,CAAC,iBAErC,EAAsB,AAGjC,GAO4D,CArE9D,MAsEE,GAAM,CAAE,MAAO,EAAc,QAAS,GAAmB,GAAW,GAE9D,EAAW,oBAAc,WAAd,OAA0B,IAKrC,EAAQ,EAIZ,EAPuE,IACvE,EAAiB,GAME,GAErB,MAAO,IACL,YACG,IAWM,EAAqB,CAChC,EACA,IAEO,EACL,CAAE,IAAK,gBAAiB,OAAQ,OAAQ,KAAM,GAC9C,GAIS,EAAwB,AAGnC,GAQI,CACJ,GAAM,CAAE,SAAU,EAAiB,QAAS,GAAmB,GAAW,GAW1E,MAAO,GANH,AAAC,GAAU,CACb,GAAM,CAAE,QAAS,GAAS,GAE1B,MAAO,GAAmB,EAAM,IAQpB",
3
+ "sources": ["../../src/organisation/organisation.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 OrganisationsGetResponse,\n AsError,\n OrganisationPostResponse,\n OrganisationPostBodyBody,\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 all the Organisations you are a member of. Admin users can see all Organisations\n\n * @summary Gets Organisations\n */\nexport const getOrganisations = (\n options?: SecondParameter<typeof customInstance>\n) => {\n return customInstance<OrganisationsGetResponse>(\n { url: `/organisation`, method: \"get\" },\n options\n );\n};\n\nexport const getGetOrganisationsQueryKey = () => [`/organisation`];\n\nexport const useGetOrganisations = <\n TData = AsyncReturnType<typeof getOrganisations>,\n TError = ErrorType<void | AsError>\n>(options?: {\n query?: UseQueryOptions<\n AsyncReturnType<typeof getOrganisations>,\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 ?? getGetOrganisationsQueryKey();\n\n const queryFn: QueryFunction<AsyncReturnType<typeof getOrganisations>> = () =>\n getOrganisations(requestOptions);\n\n const query = useQuery<\n AsyncReturnType<typeof getOrganisations>,\n TError,\n TData\n >(queryKey, queryFn, queryOptions);\n\n return {\n queryKey,\n ...query,\n };\n};\n\n/**\n * Creates a new Organisation\n\nYou need **admin** rights to use this method\n\n * @summary Create a new organisation\n */\nexport const createOrganisation = (\n organisationPostBodyBody: OrganisationPostBodyBody,\n options?: SecondParameter<typeof customInstance>\n) => {\n return customInstance<OrganisationPostResponse>(\n { url: `/organisation`, method: \"post\", data: organisationPostBodyBody },\n options\n );\n};\n\nexport const useCreateOrganisation = <\n TError = ErrorType<AsError | void>,\n TContext = unknown\n>(options?: {\n mutation?: UseMutationOptions<\n AsyncReturnType<typeof createOrganisation>,\n TError,\n { data: OrganisationPostBodyBody },\n TContext\n >;\n request?: SecondParameter<typeof customInstance>;\n}) => {\n const { mutation: mutationOptions, request: requestOptions } = options || {};\n\n const mutationFn: MutationFunction<\n AsyncReturnType<typeof createOrganisation>,\n { data: OrganisationPostBodyBody }\n > = (props) => {\n const { data } = props || {};\n\n return createOrganisation(data, requestOptions);\n };\n\n return useMutation<\n AsyncReturnType<typeof createOrganisation>,\n TError,\n { data: OrganisationPostBodyBody },\n TContext\n >(mutationFn, mutationOptions);\n};\n/**\n * Units must first be deleted before an Organisation can be deleted\n\nYou need **admin** rights to use this method\n\n * @summary Deletes an Organisation\n */\nexport const deleteOrganisation = (\n orgid: string,\n options?: SecondParameter<typeof customInstance>\n) => {\n return customInstance<void>(\n { url: `/organisation/${orgid}`, method: \"delete\", data: undefined },\n options\n );\n};\n\nexport const useDeleteOrganisation = <\n TError = ErrorType<AsError>,\n TContext = unknown\n>(options?: {\n mutation?: UseMutationOptions<\n AsyncReturnType<typeof deleteOrganisation>,\n TError,\n { orgid: string },\n TContext\n >;\n request?: SecondParameter<typeof customInstance>;\n}) => {\n const { mutation: mutationOptions, request: requestOptions } = options || {};\n\n const mutationFn: MutationFunction<\n AsyncReturnType<typeof deleteOrganisation>,\n { orgid: string }\n > = (props) => {\n const { orgid } = props || {};\n\n return deleteOrganisation(orgid, requestOptions);\n };\n\n return useMutation<\n AsyncReturnType<typeof deleteOrganisation>,\n TError,\n { orgid: string },\n TContext\n >(mutationFn, mutationOptions);\n};\n", "/** Based off the example custom-instance from Orval docs\n * https://github.com/anymaniax/orval/blob/master/samples/react-app-with-react-query/src/api/mutator/custom-instance.ts\n *\n * See https://react-query.tanstack.com/guides/query-cancellation\n *\n * TODO: Considering using Fetch-API instead of axios. This instance will have to change. Could be\n * achieved without changing much using `redaxios`\n * Or use 'ky'\n */\n\nimport Axios, { AxiosError, AxiosRequestConfig } from 'axios';\n\n// ? Need the baseUrl or does it default to ''?\nexport const AXIOS_INSTANCE = Axios.create({ baseURL: '' });\n\n/**\n * Set the access token to be added as the `Authorization: Bearer 'token'` header\n * Useful for client only apps where a proxy API route isn't involved to securely add the access token\n * @param token access token\n */\nexport const setAuthToken = (token: string) => {\n AXIOS_INSTANCE.defaults.headers.common['Authorization'] = `Bearer ${token}`;\n};\n\n/**\n * Set the url to which request paths are added to.\n * @param baseUrl origin + subpath e.g. 'https://example.com/subpath' or '/subpath'\n */\nexport const setBaseUrl = (baseUrl: string) => {\n AXIOS_INSTANCE.defaults.baseURL = baseUrl;\n};\n\nexport const customInstance = <TReturn>(\n config: AxiosRequestConfig,\n options?: AxiosRequestConfig,\n): Promise<TReturn> => {\n const source = Axios.CancelToken.source();\n\n const promise = AXIOS_INSTANCE({ ...config, ...options, cancelToken: source.token }).then(\n ({ data }) => data,\n );\n\n // Promise doesn't have a cancel method but react-query requires this method to make cancellations general.\n // This can either be a any assertion or a @ts-ignore comment.\n (promise as any).cancel = () => {\n source.cancel('Query was cancelled by React Query');\n };\n\n return promise;\n};\n\nexport type ErrorType<TError> = AxiosError<TError>;\n"],
5
+ "mappings": ";;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAUA,yBASO;;;ACTP,mBAAsD;AAG/C,IAAM,iBAAiB,qBAAM,OAAO,EAAE,SAAS;AAmB/C,IAAM,iBAAiB,CAC5B,QACA,YACqB;AACrB,QAAM,SAAS,qBAAM,YAAY;AAEjC,QAAM,UAAU,eAAe,gDAAK,SAAW,UAAhB,EAAyB,aAAa,OAAO,UAAS,KACnF,CAAC,EAAE,WAAW;AAKhB,EAAC,QAAgB,SAAS,MAAM;AAC9B,WAAO,OAAO;AAAA;AAGhB,SAAO;AAAA;;;ADFF,IAAM,mBAAmB,CAC9B,YACG;AACH,SAAO,eACL,EAAE,KAAK,iBAAiB,QAAQ,SAChC;AAAA;AAIG,IAAM,8BAA8B,MAAM,CAAC;AAE3C,IAAM,sBAAsB,CAGjC,YAO4D;AAC5D,QAAM,EAAE,OAAO,cAAc,SAAS,mBAAmB,WAAW;AAEpE,QAAM,WAAW,8CAAc,aAAY;AAE3C,QAAM,UAAmE,MACvE,iBAAiB;AAEnB,QAAM,QAAQ,iCAIZ,UAAU,SAAS;AAErB,SAAO;AAAA,IACL;AAAA,KACG;AAAA;AAWA,IAAM,qBAAqB,CAChC,0BACA,YACG;AACH,SAAO,eACL,EAAE,KAAK,iBAAiB,QAAQ,QAAQ,MAAM,4BAC9C;AAAA;AAIG,IAAM,wBAAwB,CAGnC,YAQI;AACJ,QAAM,EAAE,UAAU,iBAAiB,SAAS,mBAAmB,WAAW;AAE1E,QAAM,aAGF,CAAC,UAAU;AACb,UAAM,EAAE,SAAS,SAAS;AAE1B,WAAO,mBAAmB,MAAM;AAAA;AAGlC,SAAO,oCAKL,YAAY;AAAA;AAST,IAAM,qBAAqB,CAChC,OACA,YACG;AACH,SAAO,eACL,EAAE,KAAK,iBAAiB,SAAS,QAAQ,UAAU,MAAM,UACzD;AAAA;AAIG,IAAM,wBAAwB,CAGnC,YAQI;AACJ,QAAM,EAAE,UAAU,iBAAiB,SAAS,mBAAmB,WAAW;AAE1E,QAAM,aAGF,CAAC,UAAU;AACb,UAAM,EAAE,UAAU,SAAS;AAE3B,WAAO,mBAAmB,OAAO;AAAA;AAGnC,SAAO,oCAKL,YAAY;AAAA;",
6
6
  "names": []
7
7
  }
@@ -1,19 +1,17 @@
1
1
  import * as react_query from 'react-query';
2
2
  import { UseQueryOptions, QueryKey, UseQueryResult, UseMutationOptions } from 'react-query';
3
- import { G as customInstance, x as OrganisationsGetResponse, H as ErrorType, E as Error, c as OrganisationPostBodyBody, B as OrganisationPostResponse } from '../custom-instance-d52e4104';
3
+ import { I as customInstance, z as OrganisationsGetResponse, J as ErrorType, E as AsError, c as OrganisationPostBodyBody, D as OrganisationPostResponse } from '../custom-instance-3334b00b';
4
4
  import 'axios';
5
5
 
6
6
  declare type SecondParameter<T extends (...args: any) => any> = T extends (config: any, args: infer P) => any ? P : never;
7
7
  /**
8
- * Gets all the Organisations
9
-
10
- You need **admin** rights to use this method
8
+ * Gets all the Organisations you are a member of. Admin users can see all Organisations
11
9
 
12
10
  * @summary Gets Organisations
13
11
  */
14
12
  declare const getOrganisations: (options?: SecondParameter<typeof customInstance>) => Promise<OrganisationsGetResponse>;
15
13
  declare const getGetOrganisationsQueryKey: () => string[];
16
- declare const useGetOrganisations: <TData = OrganisationsGetResponse, TError = ErrorType<void | Error>>(options?: {
14
+ declare const useGetOrganisations: <TData = OrganisationsGetResponse, TError = ErrorType<void | AsError>>(options?: {
17
15
  query?: UseQueryOptions<OrganisationsGetResponse, TError, TData, QueryKey> | undefined;
18
16
  request?: SecondParameter<typeof customInstance>;
19
17
  } | undefined) => UseQueryResult<TData, TError> & {
@@ -27,7 +25,7 @@ You need **admin** rights to use this method
27
25
  * @summary Create a new organisation
28
26
  */
29
27
  declare const createOrganisation: (organisationPostBodyBody: OrganisationPostBodyBody, options?: SecondParameter<typeof customInstance>) => Promise<OrganisationPostResponse>;
30
- declare const useCreateOrganisation: <TError = ErrorType<void | Error>, TContext = unknown>(options?: {
28
+ declare const useCreateOrganisation: <TError = ErrorType<void | AsError>, TContext = unknown>(options?: {
31
29
  mutation?: UseMutationOptions<OrganisationPostResponse, TError, {
32
30
  data: OrganisationPostBodyBody;
33
31
  }, TContext> | undefined;
@@ -35,5 +33,21 @@ declare const useCreateOrganisation: <TError = ErrorType<void | Error>, TContext
35
33
  } | undefined) => react_query.UseMutationResult<OrganisationPostResponse, TError, {
36
34
  data: OrganisationPostBodyBody;
37
35
  }, TContext>;
36
+ /**
37
+ * Units must first be deleted before an Organisation can be deleted
38
+
39
+ You need **admin** rights to use this method
40
+
41
+ * @summary Deletes an Organisation
42
+ */
43
+ declare const deleteOrganisation: (orgid: string, options?: SecondParameter<typeof customInstance>) => Promise<void>;
44
+ declare const useDeleteOrganisation: <TError = ErrorType<AsError>, TContext = unknown>(options?: {
45
+ mutation?: UseMutationOptions<void, TError, {
46
+ orgid: string;
47
+ }, TContext> | undefined;
48
+ request?: SecondParameter<typeof customInstance>;
49
+ } | undefined) => react_query.UseMutationResult<void, TError, {
50
+ orgid: string;
51
+ }, TContext>;
38
52
 
39
- export { createOrganisation, getGetOrganisationsQueryKey, getOrganisations, useCreateOrganisation, useGetOrganisations };
53
+ export { createOrganisation, deleteOrganisation, getGetOrganisationsQueryKey, getOrganisations, useCreateOrganisation, useDeleteOrganisation, useGetOrganisations };