@emilgroup/billing-v2-sdk-node 0.0.0-stage → 1.0.1-beta.0

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 (265) hide show
  1. package/.openapi-generator/FILES +93 -0
  2. package/.openapi-generator/VERSION +1 -0
  3. package/.openapi-generator-ignore +23 -0
  4. package/README.md +83 -2
  5. package/api/bill-runs-api.ts +472 -0
  6. package/api/bills-api.ts +149 -0
  7. package/api/invoices-api.ts +1534 -0
  8. package/api/jobs-api.ts +760 -0
  9. package/api/policy-billings-api.ts +595 -0
  10. package/api.ts +39 -0
  11. package/base.ts +396 -0
  12. package/common.ts +200 -0
  13. package/configuration.ts +118 -0
  14. package/dist/api/bill-runs-api.d.ts +266 -0
  15. package/dist/api/bill-runs-api.js +470 -0
  16. package/dist/api/bills-api.d.ts +87 -0
  17. package/dist/api/bills-api.js +211 -0
  18. package/dist/api/invoices-api.d.ts +847 -0
  19. package/dist/api/invoices-api.js +1357 -0
  20. package/dist/api/jobs-api.d.ts +426 -0
  21. package/dist/api/jobs-api.js +712 -0
  22. package/dist/api/policy-billings-api.d.ts +332 -0
  23. package/dist/api/policy-billings-api.js +565 -0
  24. package/dist/api.d.ts +16 -0
  25. package/dist/api.js +34 -0
  26. package/dist/base.d.ts +97 -0
  27. package/dist/base.js +493 -0
  28. package/dist/common.d.ts +92 -0
  29. package/dist/common.js +278 -0
  30. package/dist/configuration.d.ts +96 -0
  31. package/dist/configuration.js +52 -0
  32. package/dist/index.d.ts +15 -0
  33. package/dist/index.js +36 -0
  34. package/dist/models/any.d.ts +25 -0
  35. package/dist/models/any.js +15 -0
  36. package/dist/models/bill-item.d.ts +132 -0
  37. package/dist/models/bill-item.js +15 -0
  38. package/dist/models/bill-run.d.ts +145 -0
  39. package/dist/models/bill-run.js +15 -0
  40. package/dist/models/bill.d.ts +194 -0
  41. package/dist/models/bill.js +15 -0
  42. package/dist/models/cancel-job-response.d.ts +25 -0
  43. package/dist/models/cancel-job-response.js +15 -0
  44. package/dist/models/create-correction-invoices-request.d.ts +72 -0
  45. package/dist/models/create-correction-invoices-request.js +15 -0
  46. package/dist/models/create-correction-invoices-response.d.ts +31 -0
  47. package/dist/models/create-correction-invoices-response.js +15 -0
  48. package/dist/models/create-detail-export-job-request.d.ts +56 -0
  49. package/dist/models/create-detail-export-job-request.js +15 -0
  50. package/dist/models/create-detail-export-job-response.d.ts +25 -0
  51. package/dist/models/create-detail-export-job-response.js +15 -0
  52. package/dist/models/create-estimated-invoice-for-interval-request.d.ts +42 -0
  53. package/dist/models/create-estimated-invoice-for-interval-request.js +15 -0
  54. package/dist/models/create-estimated-invoice-for-interval-response.d.ts +25 -0
  55. package/dist/models/create-estimated-invoice-for-interval-response.js +15 -0
  56. package/dist/models/create-estimated-invoice-request.d.ts +36 -0
  57. package/dist/models/create-estimated-invoice-request.js +15 -0
  58. package/dist/models/create-estimated-invoice-response.d.ts +25 -0
  59. package/dist/models/create-estimated-invoice-response.js +15 -0
  60. package/dist/models/create-export-job-request.d.ts +68 -0
  61. package/dist/models/create-export-job-request.js +15 -0
  62. package/dist/models/create-export-job-response.d.ts +25 -0
  63. package/dist/models/create-export-job-response.js +15 -0
  64. package/dist/models/create-initial-invoice-request.d.ts +72 -0
  65. package/dist/models/create-initial-invoice-request.js +15 -0
  66. package/dist/models/create-initial-invoice-response.d.ts +25 -0
  67. package/dist/models/create-initial-invoice-response.js +15 -0
  68. package/dist/models/create-invoice-request.d.ts +67 -0
  69. package/dist/models/create-invoice-request.js +15 -0
  70. package/dist/models/create-invoice-response.d.ts +25 -0
  71. package/dist/models/create-invoice-response.js +15 -0
  72. package/dist/models/create-invoice-status-body.d.ts +24 -0
  73. package/dist/models/create-invoice-status-body.js +15 -0
  74. package/dist/models/create-invoice-status-response.d.ts +25 -0
  75. package/dist/models/create-invoice-status-response.js +15 -0
  76. package/dist/models/create-item-request.d.ts +36 -0
  77. package/dist/models/create-item-request.js +15 -0
  78. package/dist/models/create-policy-billing-request.d.ts +42 -0
  79. package/dist/models/create-policy-billing-request.js +15 -0
  80. package/dist/models/create-policy-billing-response.d.ts +25 -0
  81. package/dist/models/create-policy-billing-response.js +15 -0
  82. package/dist/models/create-recurring-invoice-request.d.ts +72 -0
  83. package/dist/models/create-recurring-invoice-request.js +15 -0
  84. package/dist/models/create-recurring-invoice-response.d.ts +31 -0
  85. package/dist/models/create-recurring-invoice-response.js +15 -0
  86. package/dist/models/create-termination-invoice-request.d.ts +60 -0
  87. package/dist/models/create-termination-invoice-request.js +15 -0
  88. package/dist/models/create-termination-invoice-response.d.ts +25 -0
  89. package/dist/models/create-termination-invoice-response.js +15 -0
  90. package/dist/models/create-withdraw-invoice-request.d.ts +48 -0
  91. package/dist/models/create-withdraw-invoice-request.js +15 -0
  92. package/dist/models/create-withdraw-invoice-response.d.ts +25 -0
  93. package/dist/models/create-withdraw-invoice-response.js +15 -0
  94. package/dist/models/estimate-history-entry.d.ts +36 -0
  95. package/dist/models/estimate-history-entry.js +15 -0
  96. package/dist/models/export-column.d.ts +36 -0
  97. package/dist/models/export-column.js +15 -0
  98. package/dist/models/filter-field.d.ts +110 -0
  99. package/dist/models/filter-field.js +15 -0
  100. package/dist/models/filter-value.d.ts +37 -0
  101. package/dist/models/filter-value.js +15 -0
  102. package/dist/models/get-bill-response.d.ts +25 -0
  103. package/dist/models/get-bill-response.js +15 -0
  104. package/dist/models/get-bill-run-filter-catalog-response.d.ts +31 -0
  105. package/dist/models/get-bill-run-filter-catalog-response.js +15 -0
  106. package/dist/models/get-bill-run-response.d.ts +25 -0
  107. package/dist/models/get-bill-run-response.js +15 -0
  108. package/dist/models/get-invoice-filter-catalog-response.d.ts +31 -0
  109. package/dist/models/get-invoice-filter-catalog-response.js +15 -0
  110. package/dist/models/get-invoice-response.d.ts +25 -0
  111. package/dist/models/get-invoice-response.js +15 -0
  112. package/dist/models/get-job-download-response.d.ts +25 -0
  113. package/dist/models/get-job-download-response.js +15 -0
  114. package/dist/models/get-job-filter-catalog-response.d.ts +31 -0
  115. package/dist/models/get-job-filter-catalog-response.js +15 -0
  116. package/dist/models/get-job-response.d.ts +25 -0
  117. package/dist/models/get-job-response.js +15 -0
  118. package/dist/models/get-policies-billing-date-filter-catalog-response.d.ts +31 -0
  119. package/dist/models/get-policies-billing-date-filter-catalog-response.js +15 -0
  120. package/dist/models/get-policies-billing-filter-catalog-response.d.ts +31 -0
  121. package/dist/models/get-policies-billing-filter-catalog-response.js +15 -0
  122. package/dist/models/get-policy-billing-response.d.ts +25 -0
  123. package/dist/models/get-policy-billing-response.js +15 -0
  124. package/dist/models/highlight.d.ts +30 -0
  125. package/dist/models/highlight.js +15 -0
  126. package/dist/models/index.d.ts +75 -0
  127. package/dist/models/index.js +91 -0
  128. package/dist/models/invoice-item.d.ts +204 -0
  129. package/dist/models/invoice-item.js +15 -0
  130. package/dist/models/invoice-payment.d.ts +108 -0
  131. package/dist/models/invoice-payment.js +15 -0
  132. package/dist/models/invoice-payments.d.ts +25 -0
  133. package/dist/models/invoice-payments.js +15 -0
  134. package/dist/models/invoice-status.d.ts +54 -0
  135. package/dist/models/invoice-status.js +15 -0
  136. package/dist/models/invoice.d.ts +275 -0
  137. package/dist/models/invoice.js +15 -0
  138. package/dist/models/job-download.d.ts +36 -0
  139. package/dist/models/job-download.js +15 -0
  140. package/dist/models/job-error.d.ts +30 -0
  141. package/dist/models/job-error.js +15 -0
  142. package/dist/models/job-progress.d.ts +36 -0
  143. package/dist/models/job-progress.js +15 -0
  144. package/dist/models/job.d.ts +134 -0
  145. package/dist/models/job.js +15 -0
  146. package/dist/models/list-bill-runs-response.d.ts +37 -0
  147. package/dist/models/list-bill-runs-response.js +15 -0
  148. package/dist/models/list-invoices-response.d.ts +37 -0
  149. package/dist/models/list-invoices-response.js +15 -0
  150. package/dist/models/list-jobs-response.d.ts +37 -0
  151. package/dist/models/list-jobs-response.js +15 -0
  152. package/dist/models/list-policies-billing-dates-response.d.ts +37 -0
  153. package/dist/models/list-policies-billing-dates-response.js +15 -0
  154. package/dist/models/list-policies-billings-response.d.ts +37 -0
  155. package/dist/models/list-policies-billings-response.js +15 -0
  156. package/dist/models/list-request.d.ts +60 -0
  157. package/dist/models/list-request.js +15 -0
  158. package/dist/models/localized-text.d.ts +30 -0
  159. package/dist/models/localized-text.js +15 -0
  160. package/dist/models/match.d.ts +69 -0
  161. package/dist/models/match.js +15 -0
  162. package/dist/models/payment-term.d.ts +42 -0
  163. package/dist/models/payment-term.js +15 -0
  164. package/dist/models/policy-billing.d.ts +139 -0
  165. package/dist/models/policy-billing.js +15 -0
  166. package/dist/models/request-bill-run-request.d.ts +30 -0
  167. package/dist/models/request-bill-run-request.js +15 -0
  168. package/dist/models/request-bill-run-response.d.ts +25 -0
  169. package/dist/models/request-bill-run-response.js +15 -0
  170. package/dist/models/resolved-billing-config.d.ts +130 -0
  171. package/dist/models/resolved-billing-config.js +15 -0
  172. package/dist/models/revert-invoice-request.d.ts +24 -0
  173. package/dist/models/revert-invoice-request.js +15 -0
  174. package/dist/models/revert-invoice-response.d.ts +25 -0
  175. package/dist/models/revert-invoice-response.js +15 -0
  176. package/dist/models/slice.d.ts +30 -0
  177. package/dist/models/slice.js +15 -0
  178. package/dist/models/status.d.ts +37 -0
  179. package/dist/models/status.js +15 -0
  180. package/dist/models/tax.d.ts +30 -0
  181. package/dist/models/tax.js +15 -0
  182. package/dist/models/update-policy-billing-body.d.ts +24 -0
  183. package/dist/models/update-policy-billing-body.js +15 -0
  184. package/dist/models/update-policy-billing-response.d.ts +25 -0
  185. package/dist/models/update-policy-billing-response.js +15 -0
  186. package/git_push.sh +57 -0
  187. package/index.ts +19 -0
  188. package/models/any.ts +32 -0
  189. package/models/bill-item.ts +138 -0
  190. package/models/bill-run.ts +151 -0
  191. package/models/bill.ts +200 -0
  192. package/models/cancel-job-response.ts +31 -0
  193. package/models/create-correction-invoices-request.ts +78 -0
  194. package/models/create-correction-invoices-response.ts +37 -0
  195. package/models/create-detail-export-job-request.ts +60 -0
  196. package/models/create-detail-export-job-response.ts +31 -0
  197. package/models/create-estimated-invoice-for-interval-request.ts +48 -0
  198. package/models/create-estimated-invoice-for-interval-response.ts +31 -0
  199. package/models/create-estimated-invoice-request.ts +42 -0
  200. package/models/create-estimated-invoice-response.ts +31 -0
  201. package/models/create-export-job-request.ts +74 -0
  202. package/models/create-export-job-response.ts +31 -0
  203. package/models/create-initial-invoice-request.ts +78 -0
  204. package/models/create-initial-invoice-response.ts +31 -0
  205. package/models/create-invoice-request.ts +73 -0
  206. package/models/create-invoice-response.ts +31 -0
  207. package/models/create-invoice-status-body.ts +30 -0
  208. package/models/create-invoice-status-response.ts +31 -0
  209. package/models/create-item-request.ts +42 -0
  210. package/models/create-policy-billing-request.ts +48 -0
  211. package/models/create-policy-billing-response.ts +31 -0
  212. package/models/create-recurring-invoice-request.ts +78 -0
  213. package/models/create-recurring-invoice-response.ts +37 -0
  214. package/models/create-termination-invoice-request.ts +66 -0
  215. package/models/create-termination-invoice-response.ts +31 -0
  216. package/models/create-withdraw-invoice-request.ts +54 -0
  217. package/models/create-withdraw-invoice-response.ts +31 -0
  218. package/models/estimate-history-entry.ts +42 -0
  219. package/models/export-column.ts +42 -0
  220. package/models/filter-field.ts +116 -0
  221. package/models/filter-value.ts +43 -0
  222. package/models/get-bill-response.ts +31 -0
  223. package/models/get-bill-run-filter-catalog-response.ts +37 -0
  224. package/models/get-bill-run-response.ts +31 -0
  225. package/models/get-invoice-filter-catalog-response.ts +37 -0
  226. package/models/get-invoice-response.ts +31 -0
  227. package/models/get-job-download-response.ts +31 -0
  228. package/models/get-job-filter-catalog-response.ts +37 -0
  229. package/models/get-job-response.ts +31 -0
  230. package/models/get-policies-billing-date-filter-catalog-response.ts +37 -0
  231. package/models/get-policies-billing-filter-catalog-response.ts +37 -0
  232. package/models/get-policy-billing-response.ts +31 -0
  233. package/models/highlight.ts +36 -0
  234. package/models/index.ts +75 -0
  235. package/models/invoice-item.ts +210 -0
  236. package/models/invoice-payment.ts +114 -0
  237. package/models/invoice-payments.ts +31 -0
  238. package/models/invoice-status.ts +60 -0
  239. package/models/invoice.ts +281 -0
  240. package/models/job-download.ts +42 -0
  241. package/models/job-error.ts +36 -0
  242. package/models/job-progress.ts +42 -0
  243. package/models/job.ts +140 -0
  244. package/models/list-bill-runs-response.ts +43 -0
  245. package/models/list-invoices-response.ts +43 -0
  246. package/models/list-jobs-response.ts +43 -0
  247. package/models/list-policies-billing-dates-response.ts +43 -0
  248. package/models/list-policies-billings-response.ts +43 -0
  249. package/models/list-request.ts +66 -0
  250. package/models/localized-text.ts +36 -0
  251. package/models/match.ts +75 -0
  252. package/models/payment-term.ts +48 -0
  253. package/models/policy-billing.ts +145 -0
  254. package/models/request-bill-run-request.ts +36 -0
  255. package/models/request-bill-run-response.ts +31 -0
  256. package/models/resolved-billing-config.ts +134 -0
  257. package/models/revert-invoice-request.ts +30 -0
  258. package/models/revert-invoice-response.ts +31 -0
  259. package/models/slice.ts +36 -0
  260. package/models/status.ts +43 -0
  261. package/models/tax.ts +36 -0
  262. package/models/update-policy-billing-body.ts +30 -0
  263. package/models/update-policy-billing-response.ts +31 -0
  264. package/package.json +27 -4
  265. package/tsconfig.json +23 -0
package/dist/base.d.ts ADDED
@@ -0,0 +1,97 @@
1
+ /**
2
+ * EMIL Billing Service
3
+ * The billing service: bills, bill runs, invoices and policy billings.
4
+ *
5
+ * The version of the OpenAPI document: 2.0
6
+ *
7
+ *
8
+ * NOTE: This class is auto generated by OpenAPI Generator (https://openapi-generator.tech).
9
+ * https://openapi-generator.tech
10
+ * Do not edit the class manually.
11
+ */
12
+ import { Configuration } from "./configuration";
13
+ import { AxiosInstance, AxiosRequestConfig } from 'axios';
14
+ export declare const BASE_PATH: string;
15
+ /**
16
+ *
17
+ * @export
18
+ */
19
+ export declare const COLLECTION_FORMATS: {
20
+ csv: string;
21
+ ssv: string;
22
+ tsv: string;
23
+ pipes: string;
24
+ };
25
+ export interface LoginClass {
26
+ accessToken: string;
27
+ permissions: string;
28
+ }
29
+ export interface SwitchWorkspaceRequest {
30
+ username: string;
31
+ targetWorkspace: string;
32
+ }
33
+ export interface SwitchWorkspaceResponseClass {
34
+ accessToken: string;
35
+ permissions: string;
36
+ }
37
+ export declare enum Environment {
38
+ Production = "https://apiv2.emil.de",
39
+ Test = "https://apiv2-test.emil.de",
40
+ Staging = "https://apiv2-staging.emil.de",
41
+ Development = "https://apiv2-dev.emil.de",
42
+ ProductionZurich = "https://eu-central-2.apiv2.emil.de",
43
+ StagingZurich = "https://eu-central-2.apiv2-staging.emil.de"
44
+ }
45
+ export declare function resetRetry(): void;
46
+ /**
47
+ *
48
+ * @export
49
+ * @interface RequestArgs
50
+ */
51
+ export interface RequestArgs {
52
+ url: string;
53
+ options: AxiosRequestConfig;
54
+ }
55
+ /**
56
+ *
57
+ * @export
58
+ * @class BaseAPI
59
+ */
60
+ export declare class BaseAPI {
61
+ protected basePath: string;
62
+ protected axios: AxiosInstance;
63
+ protected configuration: Configuration;
64
+ private username?;
65
+ private password?;
66
+ private static readonly REQUEST_OWNER;
67
+ private ownAccount;
68
+ protected withOwner(options?: AxiosRequestConfig): AxiosRequestConfig;
69
+ private sentByOtherAccount;
70
+ constructor(configuration?: Configuration, basePath?: string, axios?: AxiosInstance);
71
+ initialize(env?: Environment, targetWorkspace?: string): Promise<void>;
72
+ private loadCredentials;
73
+ private readConfigFile;
74
+ private readEnvVariables;
75
+ selectEnvironment(env: Environment): void;
76
+ authorize(username: string, password: string, targetWorkspace?: string): Promise<void>;
77
+ switchWorkspace(targetWorkspace: string): Promise<void>;
78
+ refreshTokenInternal(): Promise<string>;
79
+ private extractRefreshToken;
80
+ getConfiguration(): Configuration;
81
+ private sharedRefresh;
82
+ private refreshRunning;
83
+ private static shareRefresh;
84
+ private mayRefreshAfterNetworkError;
85
+ private attachInterceptor;
86
+ }
87
+ /**
88
+ *
89
+ * @export
90
+ * @class RequiredError
91
+ * @extends {Error}
92
+ */
93
+ export declare class RequiredError extends Error {
94
+ field: string;
95
+ name: "RequiredError";
96
+ constructor(field: string, msg?: string);
97
+ }
package/dist/base.js ADDED
@@ -0,0 +1,493 @@
1
+ "use strict";
2
+ /* tslint:disable */
3
+ /* eslint-disable */
4
+ /**
5
+ * EMIL Billing Service
6
+ * The billing service: bills, bill runs, invoices and policy billings.
7
+ *
8
+ * The version of the OpenAPI document: 2.0
9
+ *
10
+ *
11
+ * NOTE: This class is auto generated by OpenAPI Generator (https://openapi-generator.tech).
12
+ * https://openapi-generator.tech
13
+ * Do not edit the class manually.
14
+ */
15
+ var __extends = (this && this.__extends) || (function () {
16
+ var extendStatics = function (d, b) {
17
+ extendStatics = Object.setPrototypeOf ||
18
+ ({ __proto__: [] } instanceof Array && function (d, b) { d.__proto__ = b; }) ||
19
+ function (d, b) { for (var p in b) if (Object.prototype.hasOwnProperty.call(b, p)) d[p] = b[p]; };
20
+ return extendStatics(d, b);
21
+ };
22
+ return function (d, b) {
23
+ if (typeof b !== "function" && b !== null)
24
+ throw new TypeError("Class extends value " + String(b) + " is not a constructor or null");
25
+ extendStatics(d, b);
26
+ function __() { this.constructor = d; }
27
+ d.prototype = b === null ? Object.create(b) : (__.prototype = b.prototype, new __());
28
+ };
29
+ })();
30
+ var __assign = (this && this.__assign) || function () {
31
+ __assign = Object.assign || function(t) {
32
+ for (var s, i = 1, n = arguments.length; i < n; i++) {
33
+ s = arguments[i];
34
+ for (var p in s) if (Object.prototype.hasOwnProperty.call(s, p))
35
+ t[p] = s[p];
36
+ }
37
+ return t;
38
+ };
39
+ return __assign.apply(this, arguments);
40
+ };
41
+ var __createBinding = (this && this.__createBinding) || (Object.create ? (function(o, m, k, k2) {
42
+ if (k2 === undefined) k2 = k;
43
+ var desc = Object.getOwnPropertyDescriptor(m, k);
44
+ if (!desc || ("get" in desc ? !m.__esModule : desc.writable || desc.configurable)) {
45
+ desc = { enumerable: true, get: function() { return m[k]; } };
46
+ }
47
+ Object.defineProperty(o, k2, desc);
48
+ }) : (function(o, m, k, k2) {
49
+ if (k2 === undefined) k2 = k;
50
+ o[k2] = m[k];
51
+ }));
52
+ var __setModuleDefault = (this && this.__setModuleDefault) || (Object.create ? (function(o, v) {
53
+ Object.defineProperty(o, "default", { enumerable: true, value: v });
54
+ }) : function(o, v) {
55
+ o["default"] = v;
56
+ });
57
+ var __importStar = (this && this.__importStar) || function (mod) {
58
+ if (mod && mod.__esModule) return mod;
59
+ var result = {};
60
+ if (mod != null) for (var k in mod) if (k !== "default" && Object.prototype.hasOwnProperty.call(mod, k)) __createBinding(result, mod, k);
61
+ __setModuleDefault(result, mod);
62
+ return result;
63
+ };
64
+ var __awaiter = (this && this.__awaiter) || function (thisArg, _arguments, P, generator) {
65
+ function adopt(value) { return value instanceof P ? value : new P(function (resolve) { resolve(value); }); }
66
+ return new (P || (P = Promise))(function (resolve, reject) {
67
+ function fulfilled(value) { try { step(generator.next(value)); } catch (e) { reject(e); } }
68
+ function rejected(value) { try { step(generator["throw"](value)); } catch (e) { reject(e); } }
69
+ function step(result) { result.done ? resolve(result.value) : adopt(result.value).then(fulfilled, rejected); }
70
+ step((generator = generator.apply(thisArg, _arguments || [])).next());
71
+ });
72
+ };
73
+ var __generator = (this && this.__generator) || function (thisArg, body) {
74
+ var _ = { label: 0, sent: function() { if (t[0] & 1) throw t[1]; return t[1]; }, trys: [], ops: [] }, f, y, t, g;
75
+ return g = { next: verb(0), "throw": verb(1), "return": verb(2) }, typeof Symbol === "function" && (g[Symbol.iterator] = function() { return this; }), g;
76
+ function verb(n) { return function (v) { return step([n, v]); }; }
77
+ function step(op) {
78
+ if (f) throw new TypeError("Generator is already executing.");
79
+ while (g && (g = 0, op[0] && (_ = 0)), _) try {
80
+ if (f = 1, y && (t = op[0] & 2 ? y["return"] : op[0] ? y["throw"] || ((t = y["return"]) && t.call(y), 0) : y.next) && !(t = t.call(y, op[1])).done) return t;
81
+ if (y = 0, t) op = [op[0] & 2, t.value];
82
+ switch (op[0]) {
83
+ case 0: case 1: t = op; break;
84
+ case 4: _.label++; return { value: op[1], done: false };
85
+ case 5: _.label++; y = op[1]; op = [0]; continue;
86
+ case 7: op = _.ops.pop(); _.trys.pop(); continue;
87
+ default:
88
+ if (!(t = _.trys, t = t.length > 0 && t[t.length - 1]) && (op[0] === 6 || op[0] === 2)) { _ = 0; continue; }
89
+ if (op[0] === 3 && (!t || (op[1] > t[0] && op[1] < t[3]))) { _.label = op[1]; break; }
90
+ if (op[0] === 6 && _.label < t[1]) { _.label = t[1]; t = op; break; }
91
+ if (t && _.label < t[2]) { _.label = t[2]; _.ops.push(op); break; }
92
+ if (t[2]) _.ops.pop();
93
+ _.trys.pop(); continue;
94
+ }
95
+ op = body.call(thisArg, _);
96
+ } catch (e) { op = [6, e]; y = 0; } finally { f = t = 0; }
97
+ if (op[0] & 5) throw op[1]; return { value: op[0] ? op[1] : void 0, done: true };
98
+ }
99
+ };
100
+ var __importDefault = (this && this.__importDefault) || function (mod) {
101
+ return (mod && mod.__esModule) ? mod : { "default": mod };
102
+ };
103
+ Object.defineProperty(exports, "__esModule", { value: true });
104
+ exports.RequiredError = exports.BaseAPI = exports.resetRetry = exports.Environment = exports.COLLECTION_FORMATS = exports.BASE_PATH = void 0;
105
+ var configuration_1 = require("./configuration");
106
+ // Some imports not used depending on template conditions
107
+ // @ts-ignore
108
+ var axios_1 = __importDefault(require("axios"));
109
+ var fs = __importStar(require("fs"));
110
+ var path = __importStar(require("path"));
111
+ var os = __importStar(require("os"));
112
+ exports.BASE_PATH = "https://apiv2.emil.de".replace(/\/+$/, "");
113
+ var CONFIG_DIRECTORY = '.emil';
114
+ var CONFIG_FILENAME = 'credentials';
115
+ var KEY_USERNAME = 'emil_username';
116
+ var KEY_PASSWORD = 'emil_password';
117
+ var filePath = os.homedir() + path.sep + CONFIG_DIRECTORY + path.sep + CONFIG_FILENAME;
118
+ /**
119
+ *
120
+ * @export
121
+ */
122
+ exports.COLLECTION_FORMATS = {
123
+ csv: ",",
124
+ ssv: " ",
125
+ tsv: "\t",
126
+ pipes: "|",
127
+ };
128
+ var Environment;
129
+ (function (Environment) {
130
+ Environment["Production"] = "https://apiv2.emil.de";
131
+ Environment["Test"] = "https://apiv2-test.emil.de";
132
+ Environment["Staging"] = "https://apiv2-staging.emil.de";
133
+ Environment["Development"] = "https://apiv2-dev.emil.de";
134
+ Environment["ProductionZurich"] = "https://eu-central-2.apiv2.emil.de";
135
+ Environment["StagingZurich"] = "https://eu-central-2.apiv2-staging.emil.de";
136
+ })(Environment = exports.Environment || (exports.Environment = {}));
137
+ var _retry_count = 0;
138
+ var _retry = null;
139
+ function resetRetry() {
140
+ _retry_count = 0;
141
+ }
142
+ exports.resetRetry = resetRetry;
143
+ var NETWORK_ERROR_MESSAGE = "Network Error";
144
+ // Refreshes in flight per configuration (BaseAPI.shareRefresh): SDK objects that share a configuration share its token.
145
+ var refreshesInFlight = new Map();
146
+ /**
147
+ *
148
+ * @export
149
+ * @class BaseAPI
150
+ */
151
+ var BaseAPI = /** @class */ (function () {
152
+ function BaseAPI(configuration, basePath, axios) {
153
+ if (basePath === void 0) { basePath = exports.BASE_PATH; }
154
+ if (axios === void 0) { axios = axios_1.default; }
155
+ this.basePath = basePath;
156
+ this.axios = axios;
157
+ if (configuration) {
158
+ this.configuration = configuration;
159
+ this.basePath = configuration.basePath || this.basePath;
160
+ }
161
+ else {
162
+ this.configuration = new configuration_1.Configuration({
163
+ basePath: this.basePath,
164
+ });
165
+ }
166
+ this.attachInterceptor(axios);
167
+ }
168
+ BaseAPI.prototype.ownAccount = function () {
169
+ return (this.configuration.username || '').toLowerCase();
170
+ };
171
+ BaseAPI.prototype.withOwner = function (options) {
172
+ var _a;
173
+ // An object without a username cannot refresh itself: its requests stay unmarked, as before.
174
+ if (!this.ownAccount()) {
175
+ return __assign({}, options);
176
+ }
177
+ return __assign(__assign({}, options), (_a = {}, _a[BaseAPI.REQUEST_OWNER] = this.ownAccount(), _a));
178
+ };
179
+ // Sent for another account: only that account's SDK objects handle it. Unmarked requests as before.
180
+ BaseAPI.prototype.sentByOtherAccount = function (config) {
181
+ var owner = config === null || config === void 0 ? void 0 : config[BaseAPI.REQUEST_OWNER];
182
+ return owner !== undefined && owner !== this.ownAccount();
183
+ };
184
+ BaseAPI.prototype.initialize = function (env, targetWorkspace) {
185
+ if (env === void 0) { env = Environment.Production; }
186
+ return __awaiter(this, void 0, void 0, function () {
187
+ return __generator(this, function (_a) {
188
+ switch (_a.label) {
189
+ case 0:
190
+ this.configuration.basePath = env;
191
+ return [4 /*yield*/, this.loadCredentials()];
192
+ case 1:
193
+ _a.sent();
194
+ if (!this.username) return [3 /*break*/, 3];
195
+ return [4 /*yield*/, this.authorize(this.username, this.password, targetWorkspace)];
196
+ case 2:
197
+ _a.sent();
198
+ this.password = null; // to avoid keeping password loaded in memory.
199
+ _a.label = 3;
200
+ case 3: return [2 /*return*/];
201
+ }
202
+ });
203
+ });
204
+ };
205
+ BaseAPI.prototype.loadCredentials = function () {
206
+ return __awaiter(this, void 0, void 0, function () {
207
+ var error_1;
208
+ return __generator(this, function (_a) {
209
+ switch (_a.label) {
210
+ case 0:
211
+ _a.trys.push([0, 2, , 3]);
212
+ return [4 /*yield*/, this.readConfigFile()];
213
+ case 1:
214
+ _a.sent();
215
+ return [3 /*break*/, 3];
216
+ case 2:
217
+ error_1 = _a.sent();
218
+ console.warn("No credentials file found. Check that ".concat(filePath, " exists."));
219
+ return [3 /*break*/, 3];
220
+ case 3:
221
+ this.readEnvVariables();
222
+ if (!this.username) {
223
+ console.info("No credentials found in credentials file or environment variables. Either provide some or use \n authorize() function.");
224
+ }
225
+ return [2 /*return*/];
226
+ }
227
+ });
228
+ });
229
+ };
230
+ BaseAPI.prototype.readConfigFile = function () {
231
+ return __awaiter(this, void 0, void 0, function () {
232
+ var file, lines;
233
+ var _this = this;
234
+ return __generator(this, function (_a) {
235
+ switch (_a.label) {
236
+ case 0: return [4 /*yield*/, fs.promises.readFile(filePath, 'utf-8')];
237
+ case 1:
238
+ file = _a.sent();
239
+ lines = file.split(os.EOL)
240
+ .filter(Boolean);
241
+ lines.forEach(function (line) {
242
+ if (line.startsWith(KEY_USERNAME)) {
243
+ _this.username = line.length > KEY_USERNAME.length + 1 ? line.substring(KEY_USERNAME.length + 1) : '';
244
+ }
245
+ else if (line.startsWith(KEY_PASSWORD)) {
246
+ _this.password = line.length > KEY_PASSWORD.length + 1 ? line.substring(KEY_PASSWORD.length + 1) : '';
247
+ }
248
+ });
249
+ return [2 /*return*/];
250
+ }
251
+ });
252
+ });
253
+ };
254
+ BaseAPI.prototype.readEnvVariables = function () {
255
+ if (process.env.EMIL_USERNAME) {
256
+ this.username = process.env.EMIL_USERNAME;
257
+ this.password = process.env.EMIL_PASSWORD || '';
258
+ return true;
259
+ }
260
+ return false;
261
+ };
262
+ BaseAPI.prototype.selectEnvironment = function (env) {
263
+ this.configuration.basePath = env;
264
+ };
265
+ BaseAPI.prototype.authorize = function (username, password, targetWorkspace) {
266
+ return __awaiter(this, void 0, void 0, function () {
267
+ var options, response, accessToken, refreshToken;
268
+ return __generator(this, function (_a) {
269
+ switch (_a.label) {
270
+ case 0:
271
+ options = {
272
+ method: 'POST',
273
+ url: "".concat(this.configuration.basePath, "/authservice/v1/login"),
274
+ headers: { 'Content-Type': 'application/json' },
275
+ data: {
276
+ username: username,
277
+ password: password,
278
+ },
279
+ withCredentials: true,
280
+ };
281
+ return [4 /*yield*/, axios_1.default.request(options)];
282
+ case 1:
283
+ response = _a.sent();
284
+ accessToken = response.data.accessToken;
285
+ this.configuration.username = username;
286
+ this.configuration.accessToken = "Bearer ".concat(accessToken);
287
+ refreshToken = this.extractRefreshToken(response);
288
+ this.configuration.refreshToken = refreshToken;
289
+ if (!targetWorkspace) return [3 /*break*/, 3];
290
+ return [4 /*yield*/, this.switchWorkspace(targetWorkspace)];
291
+ case 2:
292
+ _a.sent();
293
+ _a.label = 3;
294
+ case 3: return [2 /*return*/];
295
+ }
296
+ });
297
+ });
298
+ };
299
+ BaseAPI.prototype.switchWorkspace = function (targetWorkspace) {
300
+ return __awaiter(this, void 0, void 0, function () {
301
+ var options, response, accessToken, refreshToken;
302
+ return __generator(this, function (_a) {
303
+ switch (_a.label) {
304
+ case 0:
305
+ options = {
306
+ method: 'POST',
307
+ url: "".concat(this.configuration.basePath, "/authservice/v1/workspaces/switch"),
308
+ headers: {
309
+ 'Content-Type': 'application/json',
310
+ 'Authorization': "Bearer ".concat(this.configuration.accessToken),
311
+ 'Cookie': this.configuration.refreshToken,
312
+ },
313
+ data: {
314
+ username: this.configuration.username,
315
+ targetWorkspace: targetWorkspace,
316
+ },
317
+ withCredentials: true,
318
+ };
319
+ return [4 /*yield*/, axios_1.default.request(options)];
320
+ case 1:
321
+ response = _a.sent();
322
+ accessToken = response.data.accessToken;
323
+ this.configuration.accessToken = "Bearer ".concat(accessToken);
324
+ refreshToken = this.extractRefreshToken(response);
325
+ if (refreshToken) {
326
+ this.configuration.refreshToken = refreshToken;
327
+ }
328
+ return [2 /*return*/];
329
+ }
330
+ });
331
+ });
332
+ };
333
+ BaseAPI.prototype.refreshTokenInternal = function () {
334
+ return __awaiter(this, void 0, void 0, function () {
335
+ var _a, username, refreshToken, options, accessToken;
336
+ return __generator(this, function (_b) {
337
+ switch (_b.label) {
338
+ case 0:
339
+ _a = this.configuration, username = _a.username, refreshToken = _a.refreshToken;
340
+ if (!username || !refreshToken) {
341
+ return [2 /*return*/, ''];
342
+ }
343
+ options = {
344
+ method: 'POST',
345
+ url: "".concat(this.configuration.basePath, "/authservice/v1/refresh-token"),
346
+ headers: {
347
+ 'Content-Type': 'application/json',
348
+ Cookie: refreshToken,
349
+ },
350
+ data: { username: username },
351
+ withCredentials: true,
352
+ _retry: true,
353
+ };
354
+ return [4 /*yield*/, axios_1.default.request(options)];
355
+ case 1:
356
+ accessToken = (_b.sent()).data.accessToken;
357
+ return [2 /*return*/, accessToken];
358
+ }
359
+ });
360
+ });
361
+ };
362
+ BaseAPI.prototype.extractRefreshToken = function (response) {
363
+ if (response.headers && response.headers['set-cookie']
364
+ && response.headers['set-cookie'].length > 0) {
365
+ return "".concat(response.headers['set-cookie'][0].split(';')[0], ";");
366
+ }
367
+ return '';
368
+ };
369
+ BaseAPI.prototype.getConfiguration = function () {
370
+ return this.configuration;
371
+ };
372
+ BaseAPI.prototype.sharedRefresh = function () {
373
+ var _this = this;
374
+ return BaseAPI.shareRefresh(refreshesInFlight, this.configuration, function () { return _this.refreshTokenInternal(); });
375
+ };
376
+ BaseAPI.prototype.refreshRunning = function () {
377
+ return refreshesInFlight.has(this.configuration);
378
+ };
379
+ // Joins the refresh already in flight for this key, or starts one: calls refused at the same time wait for
380
+ // one refresh instead of each starting their own (a refresh token may be single-use). The entry is removed
381
+ // when the refresh settles.
382
+ BaseAPI.shareRefresh = function (inFlight, key, start) {
383
+ var running = inFlight.get(key);
384
+ if (running) {
385
+ return running;
386
+ }
387
+ var refresh = start();
388
+ inFlight.set(key, refresh);
389
+ var settled = function () { inFlight.delete(key); };
390
+ refresh.then(settled, settled);
391
+ return refresh;
392
+ };
393
+ // A refused call that joins a refresh already running is not a new try: only started refreshes count toward
394
+ // the limit, so every call refused at the same time is retried.
395
+ BaseAPI.prototype.mayRefreshAfterNetworkError = function () {
396
+ if (this.refreshRunning()) {
397
+ return true;
398
+ }
399
+ if (_retry_count >= 4) {
400
+ return false;
401
+ }
402
+ _retry_count++;
403
+ return true;
404
+ };
405
+ BaseAPI.prototype.attachInterceptor = function (axios) {
406
+ var _this = this;
407
+ axios.interceptors.response.use(function (res) {
408
+ return res;
409
+ }, function (err) { return __awaiter(_this, void 0, void 0, function () {
410
+ var originalConfig, tokenString, accessToken, _error_1, tokenString, accessToken, _error_2;
411
+ return __generator(this, function (_a) {
412
+ switch (_a.label) {
413
+ case 0:
414
+ originalConfig = err.config;
415
+ if (this.sentByOtherAccount(originalConfig)) {
416
+ return [2 /*return*/, Promise.reject(err)];
417
+ }
418
+ if (!err.response) return [3 /*break*/, 5];
419
+ if (!(err.response.status === 401 && !originalConfig._retry)) return [3 /*break*/, 4];
420
+ originalConfig._retry = true;
421
+ _a.label = 1;
422
+ case 1:
423
+ _a.trys.push([1, 3, , 4]);
424
+ return [4 /*yield*/, this.sharedRefresh()];
425
+ case 2:
426
+ tokenString = _a.sent();
427
+ accessToken = "Bearer ".concat(tokenString);
428
+ originalConfig.headers['Authorization'] = accessToken;
429
+ this.configuration.accessToken = accessToken;
430
+ return [2 /*return*/, axios.request(originalConfig)];
431
+ case 3:
432
+ _error_1 = _a.sent();
433
+ if (_error_1.response && _error_1.response.data) {
434
+ return [2 /*return*/, Promise.reject(_error_1.response.data)];
435
+ }
436
+ return [2 /*return*/, Promise.reject(_error_1)];
437
+ case 4:
438
+ if (err.response.status === 403 && err.response.data) {
439
+ return [2 /*return*/, Promise.reject(err.response.data)];
440
+ }
441
+ return [3 /*break*/, 9];
442
+ case 5:
443
+ if (!(err.message === NETWORK_ERROR_MESSAGE
444
+ && err.isAxiosError
445
+ && !originalConfig._retry
446
+ && originalConfig.headers.hasOwnProperty('Authorization')
447
+ && this.mayRefreshAfterNetworkError())) return [3 /*break*/, 9];
448
+ _a.label = 6;
449
+ case 6:
450
+ _a.trys.push([6, 8, , 9]);
451
+ return [4 /*yield*/, this.sharedRefresh()];
452
+ case 7:
453
+ tokenString = _a.sent();
454
+ accessToken = "Bearer ".concat(tokenString);
455
+ _retry = true;
456
+ originalConfig.headers['Authorization'] = accessToken;
457
+ this.configuration.accessToken = accessToken;
458
+ return [2 /*return*/, axios.request(__assign({}, originalConfig))];
459
+ case 8:
460
+ _error_2 = _a.sent();
461
+ if (_error_2.response && _error_2.response.data) {
462
+ return [2 /*return*/, Promise.reject(_error_2.response.data)];
463
+ }
464
+ return [2 /*return*/, Promise.reject(_error_2)];
465
+ case 9: return [2 /*return*/, Promise.reject(err)];
466
+ }
467
+ });
468
+ }); });
469
+ };
470
+ // Marks each request with the account (username) of the SDK object that sent it: only SDK objects of that
471
+ // account refresh and resend it, never an object of another account in the same app.
472
+ BaseAPI.REQUEST_OWNER = '_emilSdkOwner';
473
+ return BaseAPI;
474
+ }());
475
+ exports.BaseAPI = BaseAPI;
476
+ ;
477
+ /**
478
+ *
479
+ * @export
480
+ * @class RequiredError
481
+ * @extends {Error}
482
+ */
483
+ var RequiredError = /** @class */ (function (_super) {
484
+ __extends(RequiredError, _super);
485
+ function RequiredError(field, msg) {
486
+ var _this = _super.call(this, msg) || this;
487
+ _this.field = field;
488
+ _this.name = "RequiredError";
489
+ return _this;
490
+ }
491
+ return RequiredError;
492
+ }(Error));
493
+ exports.RequiredError = RequiredError;
@@ -0,0 +1,92 @@
1
+ /**
2
+ * EMIL Billing Service
3
+ * The billing service: bills, bill runs, invoices and policy billings.
4
+ *
5
+ * The version of the OpenAPI document: 2.0
6
+ *
7
+ *
8
+ * NOTE: This class is auto generated by OpenAPI Generator (https://openapi-generator.tech).
9
+ * https://openapi-generator.tech
10
+ * Do not edit the class manually.
11
+ */
12
+ import { Configuration } from "./configuration";
13
+ import { RequestArgs } from "./base";
14
+ import { AxiosInstance, AxiosResponse } from 'axios';
15
+ import { URL } from 'url';
16
+ /**
17
+ *
18
+ * @export
19
+ */
20
+ export declare const DUMMY_BASE_URL = "https://example.com";
21
+ /**
22
+ *
23
+ * @throws {RequiredError}
24
+ * @export
25
+ */
26
+ export declare const assertParamExists: (functionName: string, paramName: string, paramValue: unknown) => void;
27
+ /**
28
+ *
29
+ * @export
30
+ */
31
+ export declare const setApiKeyToObject: (object: any, keyParamName: string, configuration?: Configuration) => Promise<void>;
32
+ /**
33
+ *
34
+ * @export
35
+ */
36
+ export declare const setBasicAuthToObject: (object: any, configuration?: Configuration) => void;
37
+ /**
38
+ *
39
+ * @export
40
+ */
41
+ export declare const setBearerAuthToObject: (object: any, configuration?: Configuration) => Promise<void>;
42
+ /**
43
+ *
44
+ * @export
45
+ */
46
+ export declare const setOAuthToObject: (object: any, name: string, scopes: string[], configuration?: Configuration) => Promise<void>;
47
+ /**
48
+ *
49
+ * @export
50
+ */
51
+ export declare const setSearchParams: (url: URL, ...objects: any[]) => void;
52
+ /**
53
+ *
54
+ * @export
55
+ */
56
+ export declare const serializeDataIfNeeded: (value: any, requestOptions: any, configuration?: Configuration) => any;
57
+ /**
58
+ *
59
+ * @export
60
+ */
61
+ export declare const toPathString: (url: URL) => string;
62
+ /**
63
+ *
64
+ * @export
65
+ */
66
+ export declare const createRequestFunction: (axiosArgs: RequestArgs, globalAxios: AxiosInstance, BASE_PATH: string, configuration?: Configuration) => <T = unknown, R = AxiosResponse<T, any, {}, any>>(axios?: AxiosInstance, basePath?: string) => Promise<R>;
67
+ /**
68
+ * EMIL Billing Service
69
+ * The billing service: bills, bill runs, invoices and policy billings.
70
+ *
71
+ * The version of the OpenAPI document: 2.0
72
+ *
73
+ *
74
+ * NOTE: This class is auto generated by OpenAPI Generator (https://openapi-generator.tech).
75
+ * https://openapi-generator.tech
76
+ * Do not edit the class manually.
77
+ */
78
+ export interface IStorageConverter<D, SD> {
79
+ toStorageData(data: D): SD;
80
+ fromStorageData(storageData: SD): D;
81
+ }
82
+ export interface IStorage {
83
+ get<T>(key: string, converter?: IStorageConverter<T, any>): T | null;
84
+ set<T>(key: string, value: T, converter?: IStorageConverter<T, any>): void;
85
+ }
86
+ export declare class LocalStorage implements IStorage {
87
+ readonly storage: Storage;
88
+ constructor();
89
+ get<T>(key: string, converter?: IStorageConverter<T, any>): T | null;
90
+ set<T>(key: string, value: T, converter?: IStorageConverter<T, any>): void;
91
+ }
92
+ export declare const defaultStorage: () => IStorage;