@emilgroup/document-sdk 1.1.0 → 1.5.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 (195) hide show
  1. package/.openapi-generator/FILES +4 -0
  2. package/README.md +5 -22
  3. package/api/document-templates-api.ts +29 -19
  4. package/api/documents-api.ts +1 -5
  5. package/api/layouts-api.ts +1 -5
  6. package/api/product-documents-api.ts +113 -5
  7. package/api/search-keywords-api.ts +1 -5
  8. package/api/searchable-document-owners-api.ts +1 -5
  9. package/api/searchable-documents-api.ts +21 -11
  10. package/api.ts +1 -5
  11. package/base.ts +60 -94
  12. package/common.ts +2 -3
  13. package/configuration.ts +1 -9
  14. package/dist/api/document-templates-api.d.ts +21 -12
  15. package/dist/api/document-templates-api.js +24 -22
  16. package/dist/api/documents-api.d.ts +1 -1
  17. package/dist/api/documents-api.js +8 -12
  18. package/dist/api/layouts-api.d.ts +1 -1
  19. package/dist/api/layouts-api.js +6 -10
  20. package/dist/api/product-documents-api.d.ts +62 -1
  21. package/dist/api/product-documents-api.js +99 -9
  22. package/dist/api/search-keywords-api.d.ts +1 -1
  23. package/dist/api/search-keywords-api.js +2 -6
  24. package/dist/api/searchable-document-owners-api.d.ts +1 -1
  25. package/dist/api/searchable-document-owners-api.js +2 -6
  26. package/dist/api/searchable-documents-api.d.ts +13 -4
  27. package/dist/api/searchable-documents-api.js +14 -12
  28. package/dist/api.d.ts +1 -1
  29. package/dist/api.js +1 -1
  30. package/dist/base.d.ts +6 -10
  31. package/dist/base.js +41 -137
  32. package/dist/common.d.ts +2 -3
  33. package/dist/common.js +2 -3
  34. package/dist/configuration.d.ts +1 -8
  35. package/dist/configuration.js +1 -1
  36. package/dist/index.d.ts +1 -1
  37. package/dist/index.js +1 -1
  38. package/dist/models/create-doc-template-request-dto.d.ts +7 -1
  39. package/dist/models/create-doc-template-request-dto.js +1 -1
  40. package/dist/models/create-doc-template-response-class.d.ts +1 -1
  41. package/dist/models/create-doc-template-response-class.js +1 -1
  42. package/dist/models/create-document-request-dto.d.ts +1 -1
  43. package/dist/models/create-document-request-dto.js +1 -1
  44. package/dist/models/create-document-sync-response-class.d.ts +1 -1
  45. package/dist/models/create-document-sync-response-class.js +1 -1
  46. package/dist/models/create-html-template-dto.d.ts +1 -1
  47. package/dist/models/create-html-template-dto.js +1 -1
  48. package/dist/models/create-layout-request-dto.d.ts +1 -1
  49. package/dist/models/create-layout-request-dto.js +1 -1
  50. package/dist/models/create-layout-response-class.d.ts +1 -1
  51. package/dist/models/create-layout-response-class.js +1 -1
  52. package/dist/models/create-presigned-post-request-dto.d.ts +1 -1
  53. package/dist/models/create-presigned-post-request-dto.js +1 -1
  54. package/dist/models/create-presigned-post-response-class.d.ts +1 -1
  55. package/dist/models/create-presigned-post-response-class.js +1 -1
  56. package/dist/models/delete-layout-request-dto.d.ts +1 -1
  57. package/dist/models/delete-layout-request-dto.js +1 -1
  58. package/dist/models/delete-product-document-request-dto.d.ts +1 -1
  59. package/dist/models/delete-product-document-request-dto.js +1 -1
  60. package/dist/models/delete-request-dto.d.ts +1 -1
  61. package/dist/models/delete-request-dto.js +1 -1
  62. package/dist/models/delete-response-class.d.ts +1 -1
  63. package/dist/models/delete-response-class.js +1 -1
  64. package/dist/models/doc-template-class.d.ts +7 -1
  65. package/dist/models/doc-template-class.js +1 -1
  66. package/dist/models/document-class.d.ts +1 -1
  67. package/dist/models/document-class.js +1 -1
  68. package/dist/models/download-document-request-dto.d.ts +1 -1
  69. package/dist/models/download-document-request-dto.js +1 -1
  70. package/dist/models/get-doc-template-request-dto.d.ts +1 -1
  71. package/dist/models/get-doc-template-request-dto.js +1 -1
  72. package/dist/models/get-doc-template-response-class.d.ts +1 -1
  73. package/dist/models/get-doc-template-response-class.js +1 -1
  74. package/dist/models/get-document-download-url-response-class.d.ts +1 -1
  75. package/dist/models/get-document-download-url-response-class.js +1 -1
  76. package/dist/models/get-layout-request-dto.d.ts +1 -1
  77. package/dist/models/get-layout-request-dto.js +1 -1
  78. package/dist/models/get-layout-response-class.d.ts +1 -1
  79. package/dist/models/get-layout-response-class.js +1 -1
  80. package/dist/models/get-product-document-download-url-response-class.d.ts +24 -0
  81. package/dist/models/get-product-document-download-url-response-class.js +15 -0
  82. package/dist/models/get-product-document-response-class.d.ts +1 -1
  83. package/dist/models/get-product-document-response-class.js +1 -1
  84. package/dist/models/get-signed-s3-key-url-response-class.d.ts +1 -1
  85. package/dist/models/get-signed-s3-key-url-response-class.js +1 -1
  86. package/dist/models/grpc-create-doc-template-request-dto.d.ts +55 -0
  87. package/dist/models/grpc-create-doc-template-request-dto.js +15 -0
  88. package/dist/models/grpc-update-doc-template-request-dto.d.ts +61 -0
  89. package/dist/models/grpc-update-doc-template-request-dto.js +15 -0
  90. package/dist/models/html-template-class.d.ts +1 -1
  91. package/dist/models/html-template-class.js +1 -1
  92. package/dist/models/index.d.ts +4 -0
  93. package/dist/models/index.js +4 -0
  94. package/dist/models/layout-class.d.ts +1 -1
  95. package/dist/models/layout-class.js +1 -1
  96. package/dist/models/list-doc-template-request-dto.d.ts +7 -1
  97. package/dist/models/list-doc-template-request-dto.js +1 -1
  98. package/dist/models/list-doc-templates-response-class.d.ts +1 -1
  99. package/dist/models/list-doc-templates-response-class.js +1 -1
  100. package/dist/models/list-documents-response-class.d.ts +1 -1
  101. package/dist/models/list-documents-response-class.js +1 -1
  102. package/dist/models/list-layouts-response-class.d.ts +1 -1
  103. package/dist/models/list-layouts-response-class.js +1 -1
  104. package/dist/models/list-product-documents-response-class.d.ts +1 -1
  105. package/dist/models/list-product-documents-response-class.js +1 -1
  106. package/dist/models/list-request-dto.d.ts +1 -1
  107. package/dist/models/list-request-dto.js +1 -1
  108. package/dist/models/list-search-keywords-request-dto.d.ts +1 -1
  109. package/dist/models/list-search-keywords-request-dto.js +1 -1
  110. package/dist/models/list-search-keywords-response-class.d.ts +1 -1
  111. package/dist/models/list-search-keywords-response-class.js +1 -1
  112. package/dist/models/list-searchable-document-owners-request-dto.d.ts +31 -0
  113. package/dist/models/list-searchable-document-owners-request-dto.js +22 -0
  114. package/dist/models/list-searchable-document-owners-response-class.d.ts +1 -1
  115. package/dist/models/list-searchable-document-owners-response-class.js +1 -1
  116. package/dist/models/list-searchable-documents-request-dto.d.ts +14 -1
  117. package/dist/models/list-searchable-documents-request-dto.js +8 -1
  118. package/dist/models/list-searchable-documents-response-class.d.ts +1 -1
  119. package/dist/models/list-searchable-documents-response-class.js +1 -1
  120. package/dist/models/product-document-class.d.ts +18 -1
  121. package/dist/models/product-document-class.js +12 -2
  122. package/dist/models/searchable-document-class.d.ts +1 -1
  123. package/dist/models/searchable-document-class.js +1 -1
  124. package/dist/models/searchable-document-owner-class.d.ts +1 -1
  125. package/dist/models/searchable-document-owner-class.js +1 -1
  126. package/dist/models/update-doc-template-request-dto.d.ts +7 -1
  127. package/dist/models/update-doc-template-request-dto.js +1 -1
  128. package/dist/models/update-doc-template-response-class.d.ts +1 -1
  129. package/dist/models/update-doc-template-response-class.js +1 -1
  130. package/dist/models/update-document-request-dto.d.ts +1 -1
  131. package/dist/models/update-document-request-dto.js +1 -1
  132. package/dist/models/update-document-response-class.d.ts +1 -1
  133. package/dist/models/update-document-response-class.js +1 -1
  134. package/dist/models/update-html-template-dto.d.ts +1 -1
  135. package/dist/models/update-html-template-dto.js +1 -1
  136. package/dist/models/update-layout-request-dto.d.ts +1 -1
  137. package/dist/models/update-layout-request-dto.js +1 -1
  138. package/dist/models/update-layout-response-class.d.ts +1 -1
  139. package/dist/models/update-layout-response-class.js +1 -1
  140. package/dist/models/upload-product-document-request-dto.d.ts +7 -1
  141. package/dist/models/upload-product-document-request-dto.js +1 -1
  142. package/index.ts +1 -1
  143. package/models/create-doc-template-request-dto.ts +7 -1
  144. package/models/create-doc-template-response-class.ts +1 -1
  145. package/models/create-document-request-dto.ts +1 -1
  146. package/models/create-document-sync-response-class.ts +1 -1
  147. package/models/create-html-template-dto.ts +1 -1
  148. package/models/create-layout-request-dto.ts +1 -1
  149. package/models/create-layout-response-class.ts +1 -1
  150. package/models/create-presigned-post-request-dto.ts +1 -1
  151. package/models/create-presigned-post-response-class.ts +1 -1
  152. package/models/delete-layout-request-dto.ts +1 -1
  153. package/models/delete-product-document-request-dto.ts +1 -1
  154. package/models/delete-request-dto.ts +1 -1
  155. package/models/delete-response-class.ts +1 -1
  156. package/models/doc-template-class.ts +7 -1
  157. package/models/document-class.ts +1 -1
  158. package/models/download-document-request-dto.ts +1 -1
  159. package/models/get-doc-template-request-dto.ts +1 -1
  160. package/models/get-doc-template-response-class.ts +1 -1
  161. package/models/get-document-download-url-response-class.ts +1 -1
  162. package/models/get-layout-request-dto.ts +1 -1
  163. package/models/get-layout-response-class.ts +1 -1
  164. package/models/get-product-document-download-url-response-class.ts +30 -0
  165. package/models/get-product-document-response-class.ts +1 -1
  166. package/models/get-signed-s3-key-url-response-class.ts +1 -1
  167. package/models/grpc-create-doc-template-request-dto.ts +61 -0
  168. package/models/grpc-update-doc-template-request-dto.ts +67 -0
  169. package/models/html-template-class.ts +1 -1
  170. package/models/index.ts +4 -0
  171. package/models/layout-class.ts +1 -1
  172. package/models/list-doc-template-request-dto.ts +7 -1
  173. package/models/list-doc-templates-response-class.ts +1 -1
  174. package/models/list-documents-response-class.ts +1 -1
  175. package/models/list-layouts-response-class.ts +1 -1
  176. package/models/list-product-documents-response-class.ts +1 -1
  177. package/models/list-request-dto.ts +1 -1
  178. package/models/list-search-keywords-request-dto.ts +1 -1
  179. package/models/list-search-keywords-response-class.ts +1 -1
  180. package/models/list-searchable-document-owners-request-dto.ts +40 -0
  181. package/models/list-searchable-document-owners-response-class.ts +1 -1
  182. package/models/list-searchable-documents-request-dto.ts +17 -1
  183. package/models/list-searchable-documents-response-class.ts +1 -1
  184. package/models/product-document-class.ts +19 -1
  185. package/models/searchable-document-class.ts +1 -1
  186. package/models/searchable-document-owner-class.ts +1 -1
  187. package/models/update-doc-template-request-dto.ts +7 -1
  188. package/models/update-doc-template-response-class.ts +1 -1
  189. package/models/update-document-request-dto.ts +1 -1
  190. package/models/update-document-response-class.ts +1 -1
  191. package/models/update-html-template-dto.ts +1 -1
  192. package/models/update-layout-request-dto.ts +1 -1
  193. package/models/update-layout-response-class.ts +1 -1
  194. package/models/upload-product-document-request-dto.ts +7 -1
  195. package/package.json +2 -5
@@ -6,7 +6,7 @@
6
6
  * The EMIL DocumentService API description
7
7
  *
8
8
  * The version of the OpenAPI document: 1.0
9
- *
9
+ * Contact: kontakt@emil.de
10
10
  *
11
11
  * NOTE: This class is auto generated by OpenAPI Generator (https://openapi-generator.tech).
12
12
  * https://openapi-generator.tech
@@ -85,10 +85,6 @@ var axios_1 = __importDefault(require("axios"));
85
85
  var common_1 = require("../common");
86
86
  // @ts-ignore
87
87
  var base_1 = require("../base");
88
- // URLSearchParams not necessarily used
89
- // @ts-ignore
90
- var url_1 = require("url");
91
- var FormData = require('form-data');
92
88
  /**
93
89
  * SearchableDocumentsApi - axios parameter creator
94
90
  * @export
@@ -102,10 +98,11 @@ var SearchableDocumentsApiAxiosParamCreator = function (configuration) {
102
98
  * @param {string} searchText Text to search in the documents.
103
99
  * @param {string} ownerIds List of searched document owner IDs separated with | (search in all documents if an \'*\' list provided).
104
100
  * @param {string} [authorization] Bearer Token
101
+ * @param {'car' | 'homeowner' | 'household' | 'privateLiability'} [product] PBM product the documents belongs to.
105
102
  * @param {*} [options] Override http request option.
106
103
  * @throws {RequiredError}
107
104
  */
108
- listSearchableDocuments: function (searchText, ownerIds, authorization, options) {
105
+ listSearchableDocuments: function (searchText, ownerIds, authorization, product, options) {
109
106
  if (options === void 0) { options = {}; }
110
107
  return __awaiter(_this, void 0, void 0, function () {
111
108
  var localVarPath, localVarUrlObj, baseOptions, baseAccessToken, localVarRequestOptions, localVarHeaderParameter, localVarQueryParameter, headersFromBaseOptions;
@@ -117,7 +114,7 @@ var SearchableDocumentsApiAxiosParamCreator = function (configuration) {
117
114
  // verify required parameter 'ownerIds' is not null or undefined
118
115
  (0, common_1.assertParamExists)('listSearchableDocuments', 'ownerIds', ownerIds);
119
116
  localVarPath = "/documentservice/v1/searchable-documents";
120
- localVarUrlObj = new url_1.URL(localVarPath, common_1.DUMMY_BASE_URL);
117
+ localVarUrlObj = new URL(localVarPath, common_1.DUMMY_BASE_URL);
121
118
  if (configuration) {
122
119
  baseOptions = configuration.baseOptions;
123
120
  baseAccessToken = configuration.accessToken;
@@ -138,6 +135,9 @@ var SearchableDocumentsApiAxiosParamCreator = function (configuration) {
138
135
  if (ownerIds !== undefined) {
139
136
  localVarQueryParameter['ownerIds'] = ownerIds;
140
137
  }
138
+ if (product !== undefined) {
139
+ localVarQueryParameter['product'] = product;
140
+ }
141
141
  if (authorization !== undefined && authorization !== null || baseAccessToken !== undefined && baseAccessToken !== null) {
142
142
  localVarHeaderParameter['Authorization'] = String(authorization ? authorization : baseAccessToken);
143
143
  }
@@ -168,15 +168,16 @@ var SearchableDocumentsApiFp = function (configuration) {
168
168
  * @param {string} searchText Text to search in the documents.
169
169
  * @param {string} ownerIds List of searched document owner IDs separated with | (search in all documents if an \'*\' list provided).
170
170
  * @param {string} [authorization] Bearer Token
171
+ * @param {'car' | 'homeowner' | 'household' | 'privateLiability'} [product] PBM product the documents belongs to.
171
172
  * @param {*} [options] Override http request option.
172
173
  * @throws {RequiredError}
173
174
  */
174
- listSearchableDocuments: function (searchText, ownerIds, authorization, options) {
175
+ listSearchableDocuments: function (searchText, ownerIds, authorization, product, options) {
175
176
  return __awaiter(this, void 0, void 0, function () {
176
177
  var localVarAxiosArgs;
177
178
  return __generator(this, function (_a) {
178
179
  switch (_a.label) {
179
- case 0: return [4 /*yield*/, localVarAxiosParamCreator.listSearchableDocuments(searchText, ownerIds, authorization, options)];
180
+ case 0: return [4 /*yield*/, localVarAxiosParamCreator.listSearchableDocuments(searchText, ownerIds, authorization, product, options)];
180
181
  case 1:
181
182
  localVarAxiosArgs = _a.sent();
182
183
  return [2 /*return*/, (0, common_1.createRequestFunction)(localVarAxiosArgs, axios_1.default, base_1.BASE_PATH, configuration)];
@@ -200,11 +201,12 @@ var SearchableDocumentsApiFactory = function (configuration, basePath, axios) {
200
201
  * @param {string} searchText Text to search in the documents.
201
202
  * @param {string} ownerIds List of searched document owner IDs separated with | (search in all documents if an \'*\' list provided).
202
203
  * @param {string} [authorization] Bearer Token
204
+ * @param {'car' | 'homeowner' | 'household' | 'privateLiability'} [product] PBM product the documents belongs to.
203
205
  * @param {*} [options] Override http request option.
204
206
  * @throws {RequiredError}
205
207
  */
206
- listSearchableDocuments: function (searchText, ownerIds, authorization, options) {
207
- return localVarFp.listSearchableDocuments(searchText, ownerIds, authorization, options).then(function (request) { return request(axios, basePath); });
208
+ listSearchableDocuments: function (searchText, ownerIds, authorization, product, options) {
209
+ return localVarFp.listSearchableDocuments(searchText, ownerIds, authorization, product, options).then(function (request) { return request(axios, basePath); });
208
210
  },
209
211
  };
210
212
  };
@@ -230,7 +232,7 @@ var SearchableDocumentsApi = /** @class */ (function (_super) {
230
232
  */
231
233
  SearchableDocumentsApi.prototype.listSearchableDocuments = function (requestParameters, options) {
232
234
  var _this = this;
233
- return (0, exports.SearchableDocumentsApiFp)(this.configuration).listSearchableDocuments(requestParameters.searchText, requestParameters.ownerIds, requestParameters.authorization, options).then(function (request) { return request(_this.axios, _this.basePath); });
235
+ return (0, exports.SearchableDocumentsApiFp)(this.configuration).listSearchableDocuments(requestParameters.searchText, requestParameters.ownerIds, requestParameters.authorization, requestParameters.product, options).then(function (request) { return request(_this.axios, _this.basePath); });
234
236
  };
235
237
  return SearchableDocumentsApi;
236
238
  }(base_1.BaseAPI));
package/dist/api.d.ts CHANGED
@@ -3,7 +3,7 @@
3
3
  * The EMIL DocumentService API description
4
4
  *
5
5
  * The version of the OpenAPI document: 1.0
6
- *
6
+ * Contact: kontakt@emil.de
7
7
  *
8
8
  * NOTE: This class is auto generated by OpenAPI Generator (https://openapi-generator.tech).
9
9
  * https://openapi-generator.tech
package/dist/api.js CHANGED
@@ -6,7 +6,7 @@
6
6
  * The EMIL DocumentService API description
7
7
  *
8
8
  * The version of the OpenAPI document: 1.0
9
- *
9
+ * Contact: kontakt@emil.de
10
10
  *
11
11
  * NOTE: This class is auto generated by OpenAPI Generator (https://openapi-generator.tech).
12
12
  * https://openapi-generator.tech
package/dist/base.d.ts CHANGED
@@ -3,7 +3,7 @@
3
3
  * The EMIL DocumentService API description
4
4
  *
5
5
  * The version of the OpenAPI document: 1.0
6
- *
6
+ * Contact: kontakt@emil.de
7
7
  *
8
8
  * NOTE: This class is auto generated by OpenAPI Generator (https://openapi-generator.tech).
9
9
  * https://openapi-generator.tech
@@ -49,19 +49,15 @@ export interface RequestArgs {
49
49
  export declare class BaseAPI {
50
50
  protected basePath: string;
51
51
  protected axios: AxiosInstance;
52
- protected configuration: Configuration;
53
- private username?;
54
- private password?;
52
+ protected configuration: Configuration | undefined;
53
+ private tokenData?;
55
54
  constructor(configuration?: Configuration, basePath?: string, axios?: AxiosInstance);
56
- initialize(env?: Environment): Promise<void>;
57
- private loadCredentials;
58
- private readConfigFile;
59
- private readEnvVariables;
60
55
  selectEnvironment(env: Environment): void;
61
56
  authorize(username: string, password: string): Promise<void>;
62
57
  refreshTokenInternal(): Promise<string>;
63
- private extractRefreshToken;
64
- getConfiguration(): Configuration;
58
+ private storeTokenData;
59
+ loadTokenData(): void;
60
+ cleanTokenData(): void;
65
61
  private attachInterceptor;
66
62
  }
67
63
  /**
package/dist/base.js CHANGED
@@ -6,7 +6,7 @@
6
6
  * The EMIL DocumentService API description
7
7
  *
8
8
  * The version of the OpenAPI document: 1.0
9
- *
9
+ * Contact: kontakt@emil.de
10
10
  *
11
11
  * NOTE: This class is auto generated by OpenAPI Generator (https://openapi-generator.tech).
12
12
  * https://openapi-generator.tech
@@ -38,29 +38,6 @@ var __assign = (this && this.__assign) || function () {
38
38
  };
39
39
  return __assign.apply(this, arguments);
40
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
41
  var __awaiter = (this && this.__awaiter) || function (thisArg, _arguments, P, generator) {
65
42
  function adopt(value) { return value instanceof P ? value : new P(function (resolve) { resolve(value); }); }
66
43
  return new (P || (P = Promise))(function (resolve, reject) {
@@ -103,18 +80,11 @@ var __importDefault = (this && this.__importDefault) || function (mod) {
103
80
  Object.defineProperty(exports, "__esModule", { value: true });
104
81
  exports.RequiredError = exports.BaseAPI = exports.resetRetry = exports.Environment = exports.COLLECTION_FORMATS = exports.BASE_PATH = void 0;
105
82
  var configuration_1 = require("./configuration");
83
+ var common_1 = require("./common");
106
84
  // Some imports not used depending on template conditions
107
85
  // @ts-ignore
108
86
  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
87
  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
88
  /**
119
89
  *
120
90
  * @export
@@ -138,6 +108,7 @@ function resetRetry() {
138
108
  }
139
109
  exports.resetRetry = resetRetry;
140
110
  var NETWORK_ERROR_MESSAGE = "Network Error";
111
+ var TOKEN_DATA = 'APP_TOKEN';
141
112
  /**
142
113
  *
143
114
  * @export
@@ -149,101 +120,27 @@ var BaseAPI = /** @class */ (function () {
149
120
  if (axios === void 0) { axios = axios_1.default; }
150
121
  this.basePath = basePath;
151
122
  this.axios = axios;
123
+ this.loadTokenData();
152
124
  if (configuration) {
153
125
  this.configuration = configuration;
154
126
  this.basePath = configuration.basePath || this.basePath;
155
127
  }
156
128
  else {
129
+ var _a = this.tokenData, accessToken = _a.accessToken, username = _a.username;
157
130
  this.configuration = new configuration_1.Configuration({
158
131
  basePath: this.basePath,
132
+ accessToken: accessToken ? "Bearer ".concat(accessToken) : '',
133
+ username: username,
159
134
  });
160
135
  }
161
136
  this.attachInterceptor(axios);
162
137
  }
163
- BaseAPI.prototype.initialize = function (env) {
164
- if (env === void 0) { env = Environment.Production; }
165
- return __awaiter(this, void 0, void 0, function () {
166
- return __generator(this, function (_a) {
167
- switch (_a.label) {
168
- case 0:
169
- this.configuration.basePath = env;
170
- return [4 /*yield*/, this.loadCredentials()];
171
- case 1:
172
- _a.sent();
173
- if (!this.username) return [3 /*break*/, 3];
174
- return [4 /*yield*/, this.authorize(this.username, this.password)];
175
- case 2:
176
- _a.sent();
177
- this.password = null; // to avoid keeping password loaded in memory.
178
- _a.label = 3;
179
- case 3: return [2 /*return*/];
180
- }
181
- });
182
- });
183
- };
184
- BaseAPI.prototype.loadCredentials = function () {
185
- return __awaiter(this, void 0, void 0, function () {
186
- var error_1;
187
- return __generator(this, function (_a) {
188
- switch (_a.label) {
189
- case 0:
190
- _a.trys.push([0, 2, , 3]);
191
- return [4 /*yield*/, this.readConfigFile()];
192
- case 1:
193
- _a.sent();
194
- return [3 /*break*/, 3];
195
- case 2:
196
- error_1 = _a.sent();
197
- console.warn("No credentials file found. Check that ".concat(filePath, " exists."));
198
- return [3 /*break*/, 3];
199
- case 3:
200
- this.readEnvVariables();
201
- if (!this.username) {
202
- console.info("No credentials found in credentials file or environment variables. Either provide some or use \n authorize() function.");
203
- }
204
- return [2 /*return*/];
205
- }
206
- });
207
- });
208
- };
209
- BaseAPI.prototype.readConfigFile = function () {
210
- return __awaiter(this, void 0, void 0, function () {
211
- var file, lines;
212
- var _this = this;
213
- return __generator(this, function (_a) {
214
- switch (_a.label) {
215
- case 0: return [4 /*yield*/, fs.promises.readFile(filePath, 'utf-8')];
216
- case 1:
217
- file = _a.sent();
218
- lines = file.split(os.EOL)
219
- .filter(Boolean);
220
- lines.forEach(function (line) {
221
- if (line.startsWith(KEY_USERNAME)) {
222
- _this.username = line.length > KEY_USERNAME.length + 1 ? line.substring(KEY_USERNAME.length + 1) : '';
223
- }
224
- else if (line.startsWith(KEY_PASSWORD)) {
225
- _this.password = line.length > KEY_PASSWORD.length + 1 ? line.substring(KEY_PASSWORD.length + 1) : '';
226
- }
227
- });
228
- return [2 /*return*/];
229
- }
230
- });
231
- });
232
- };
233
- BaseAPI.prototype.readEnvVariables = function () {
234
- if (process.env.EMIL_USERNAME) {
235
- this.username = process.env.EMIL_USERNAME;
236
- this.password = process.env.EMIL_PASSWORD || '';
237
- return true;
238
- }
239
- return false;
240
- };
241
138
  BaseAPI.prototype.selectEnvironment = function (env) {
242
139
  this.configuration.basePath = env;
243
140
  };
244
141
  BaseAPI.prototype.authorize = function (username, password) {
245
142
  return __awaiter(this, void 0, void 0, function () {
246
- var options, response, accessToken, refreshToken;
143
+ var options, response, accessToken;
247
144
  return __generator(this, function (_a) {
248
145
  switch (_a.label) {
249
146
  case 0:
@@ -263,8 +160,9 @@ var BaseAPI = /** @class */ (function () {
263
160
  accessToken = response.data.accessToken;
264
161
  this.configuration.username = username;
265
162
  this.configuration.accessToken = "Bearer ".concat(accessToken);
266
- refreshToken = this.extractRefreshToken(response);
267
- this.configuration.refreshToken = refreshToken;
163
+ this.tokenData.username = username;
164
+ this.tokenData.accessToken = accessToken;
165
+ this.storeTokenData(__assign({}, this.tokenData));
268
166
  return [2 /*return*/];
269
167
  }
270
168
  });
@@ -272,12 +170,12 @@ var BaseAPI = /** @class */ (function () {
272
170
  };
273
171
  BaseAPI.prototype.refreshTokenInternal = function () {
274
172
  return __awaiter(this, void 0, void 0, function () {
275
- var _a, username, refreshToken, options, accessToken;
276
- return __generator(this, function (_b) {
277
- switch (_b.label) {
173
+ var username, options, accessToken;
174
+ return __generator(this, function (_a) {
175
+ switch (_a.label) {
278
176
  case 0:
279
- _a = this.configuration, username = _a.username, refreshToken = _a.refreshToken;
280
- if (!username || !refreshToken) {
177
+ username = this.configuration.username;
178
+ if (!username) {
281
179
  return [2 /*return*/, ''];
282
180
  }
283
181
  options = {
@@ -285,28 +183,33 @@ var BaseAPI = /** @class */ (function () {
285
183
  url: "".concat(this.configuration.basePath, "/authservice/v1/refresh-token"),
286
184
  headers: {
287
185
  'Content-Type': 'application/json',
288
- Cookie: refreshToken,
289
186
  },
290
187
  data: { username: username },
291
188
  withCredentials: true,
292
189
  };
293
190
  return [4 /*yield*/, axios_1.default.request(options)];
294
191
  case 1:
295
- accessToken = (_b.sent()).data.accessToken;
192
+ accessToken = (_a.sent()).data.accessToken;
296
193
  return [2 /*return*/, accessToken];
297
194
  }
298
195
  });
299
196
  });
300
197
  };
301
- BaseAPI.prototype.extractRefreshToken = function (response) {
302
- if (response.headers && response.headers['set-cookie']
303
- && response.headers['set-cookie'].length > 0) {
304
- return "".concat(response.headers['set-cookie'][0].split(';')[0], ";");
198
+ BaseAPI.prototype.storeTokenData = function (tokenData) {
199
+ if (typeof window !== 'undefined') {
200
+ (0, common_1.defaultStorage)().set(TOKEN_DATA, tokenData);
305
201
  }
306
- return '';
307
202
  };
308
- BaseAPI.prototype.getConfiguration = function () {
309
- return this.configuration;
203
+ BaseAPI.prototype.loadTokenData = function () {
204
+ if (typeof window !== 'undefined') {
205
+ this.tokenData = (0, common_1.defaultStorage)().get(TOKEN_DATA) || {};
206
+ }
207
+ else {
208
+ this.tokenData = {};
209
+ }
210
+ };
211
+ BaseAPI.prototype.cleanTokenData = function () {
212
+ this.storeTokenData(null);
310
213
  };
311
214
  BaseAPI.prototype.attachInterceptor = function (axios) {
312
215
  var _this = this;
@@ -318,8 +221,9 @@ var BaseAPI = /** @class */ (function () {
318
221
  switch (_a.label) {
319
222
  case 0:
320
223
  originalConfig = err.config;
321
- if (!err.response) return [3 /*break*/, 5];
322
- if (!(err.response.status === 401 && !originalConfig._retry)) return [3 /*break*/, 4];
224
+ if (!(err.response && !(err.response instanceof XMLHttpRequest))) return [3 /*break*/, 5];
225
+ if (!((err.response.status === 401 || err.response.status === 403)
226
+ && !originalConfig._retry)) return [3 /*break*/, 4];
323
227
  originalConfig._retry = true;
324
228
  _a.label = 1;
325
229
  case 1:
@@ -328,23 +232,21 @@ var BaseAPI = /** @class */ (function () {
328
232
  case 2:
329
233
  tokenString = _a.sent();
330
234
  accessToken = "Bearer ".concat(tokenString);
331
- originalConfig.headers['Authorization'] = "Bearer ".concat(accessToken);
235
+ delete originalConfig.headers['Authorization'];
236
+ originalConfig.headers['Authorization'] = accessToken;
332
237
  this.configuration.accessToken = accessToken;
333
- return [2 /*return*/, axios.request(originalConfig)];
238
+ this.tokenData.accessToken = tokenString;
239
+ this.storeTokenData(this.tokenData);
240
+ return [2 /*return*/, axios(originalConfig)];
334
241
  case 3:
335
242
  _error_1 = _a.sent();
336
243
  if (_error_1.response && _error_1.response.data) {
337
244
  return [2 /*return*/, Promise.reject(_error_1.response.data)];
338
245
  }
339
246
  return [2 /*return*/, Promise.reject(_error_1)];
340
- case 4:
341
- if (err.response.status === 403 && err.response.data) {
342
- return [2 /*return*/, Promise.reject(err.response.data)];
343
- }
344
- return [3 /*break*/, 9];
247
+ case 4: return [3 /*break*/, 9];
345
248
  case 5:
346
249
  if (!(err.message === NETWORK_ERROR_MESSAGE
347
- && err.isAxiosError
348
250
  && originalConfig.headers.hasOwnProperty('Authorization')
349
251
  && _retry_count < 4)) return [3 /*break*/, 9];
350
252
  _retry_count++;
@@ -358,6 +260,8 @@ var BaseAPI = /** @class */ (function () {
358
260
  _retry = true;
359
261
  originalConfig.headers['Authorization'] = accessToken;
360
262
  this.configuration.accessToken = accessToken;
263
+ this.tokenData.accessToken = tokenString;
264
+ this.storeTokenData(this.tokenData);
361
265
  return [2 /*return*/, axios.request(__assign({}, originalConfig))];
362
266
  case 8:
363
267
  _error_2 = _a.sent();
package/dist/common.d.ts CHANGED
@@ -3,7 +3,7 @@
3
3
  * The EMIL DocumentService API description
4
4
  *
5
5
  * The version of the OpenAPI document: 1.0
6
- *
6
+ * Contact: kontakt@emil.de
7
7
  *
8
8
  * NOTE: This class is auto generated by OpenAPI Generator (https://openapi-generator.tech).
9
9
  * https://openapi-generator.tech
@@ -12,7 +12,6 @@
12
12
  import { Configuration } from "./configuration";
13
13
  import { RequestArgs } from "./base";
14
14
  import { AxiosInstance, AxiosResponse } from 'axios';
15
- import { URL } from 'url';
16
15
  /**
17
16
  *
18
17
  * @export
@@ -69,7 +68,7 @@ export declare const createRequestFunction: (axiosArgs: RequestArgs, globalAxios
69
68
  * The EMIL DocumentService API description
70
69
  *
71
70
  * The version of the OpenAPI document: 1.0
72
- *
71
+ * Contact: kontakt@emil.de
73
72
  *
74
73
  * NOTE: This class is auto generated by OpenAPI Generator (https://openapi-generator.tech).
75
74
  * https://openapi-generator.tech
package/dist/common.js CHANGED
@@ -6,7 +6,7 @@
6
6
  * The EMIL DocumentService API description
7
7
  *
8
8
  * The version of the OpenAPI document: 1.0
9
- *
9
+ * Contact: kontakt@emil.de
10
10
  *
11
11
  * NOTE: This class is auto generated by OpenAPI Generator (https://openapi-generator.tech).
12
12
  * https://openapi-generator.tech
@@ -62,7 +62,6 @@ var __generator = (this && this.__generator) || function (thisArg, body) {
62
62
  Object.defineProperty(exports, "__esModule", { value: true });
63
63
  exports.defaultStorage = exports.LocalStorage = exports.createRequestFunction = exports.toPathString = exports.serializeDataIfNeeded = exports.setSearchParams = exports.setOAuthToObject = exports.setBearerAuthToObject = exports.setBasicAuthToObject = exports.setApiKeyToObject = exports.assertParamExists = exports.DUMMY_BASE_URL = void 0;
64
64
  var base_1 = require("./base");
65
- var url_1 = require("url");
66
65
  /**
67
66
  *
68
67
  * @export
@@ -188,7 +187,7 @@ var setSearchParams = function (url) {
188
187
  for (var _i = 1; _i < arguments.length; _i++) {
189
188
  objects[_i - 1] = arguments[_i];
190
189
  }
191
- var searchParams = new url_1.URLSearchParams(url.search);
190
+ var searchParams = new URLSearchParams(url.search);
192
191
  for (var _a = 0, objects_1 = objects; _a < objects_1.length; _a++) {
193
192
  var object = objects_1[_a];
194
193
  for (var key in object) {
@@ -3,7 +3,7 @@
3
3
  * The EMIL DocumentService API description
4
4
  *
5
5
  * The version of the OpenAPI document: 1.0
6
- *
6
+ * Contact: kontakt@emil.de
7
7
  *
8
8
  * NOTE: This class is auto generated by OpenAPI Generator (https://openapi-generator.tech).
9
9
  * https://openapi-generator.tech
@@ -68,13 +68,6 @@ export declare class Configuration {
68
68
  * @type {new () => FormData}
69
69
  */
70
70
  formDataCtor?: new () => any;
71
- /**
72
- * parameter for automatically refreshing access token for oauth2 security
73
- *
74
- * @type {string}
75
- * @memberof Configuration
76
- */
77
- refreshToken?: string;
78
71
  constructor(param?: ConfigurationParameters);
79
72
  /**
80
73
  * Check if the given MIME is a JSON MIME.
@@ -6,7 +6,7 @@
6
6
  * The EMIL DocumentService API description
7
7
  *
8
8
  * The version of the OpenAPI document: 1.0
9
- *
9
+ * Contact: kontakt@emil.de
10
10
  *
11
11
  * NOTE: This class is auto generated by OpenAPI Generator (https://openapi-generator.tech).
12
12
  * https://openapi-generator.tech
package/dist/index.d.ts CHANGED
@@ -3,7 +3,7 @@
3
3
  * The EMIL DocumentService API description
4
4
  *
5
5
  * The version of the OpenAPI document: 1.0
6
- *
6
+ * Contact: kontakt@emil.de
7
7
  *
8
8
  * NOTE: This class is auto generated by OpenAPI Generator (https://openapi-generator.tech).
9
9
  * https://openapi-generator.tech
package/dist/index.js CHANGED
@@ -6,7 +6,7 @@
6
6
  * The EMIL DocumentService API description
7
7
  *
8
8
  * The version of the OpenAPI document: 1.0
9
- *
9
+ * Contact: kontakt@emil.de
10
10
  *
11
11
  * NOTE: This class is auto generated by OpenAPI Generator (https://openapi-generator.tech).
12
12
  * https://openapi-generator.tech
@@ -3,7 +3,7 @@
3
3
  * The EMIL DocumentService API description
4
4
  *
5
5
  * The version of the OpenAPI document: 1.0
6
- *
6
+ * Contact: kontakt@emil.de
7
7
  *
8
8
  * NOTE: This class is auto generated by OpenAPI Generator (https://openapi-generator.tech).
9
9
  * https://openapi-generator.tech
@@ -46,4 +46,10 @@ export interface CreateDocTemplateRequestDto {
46
46
  * @memberof CreateDocTemplateRequestDto
47
47
  */
48
48
  'productSlug'?: string;
49
+ /**
50
+ * The filename of the document template as it appears when sent to customers.
51
+ * @type {string}
52
+ * @memberof CreateDocTemplateRequestDto
53
+ */
54
+ 'label'?: string;
49
55
  }
@@ -6,7 +6,7 @@
6
6
  * The EMIL DocumentService API description
7
7
  *
8
8
  * The version of the OpenAPI document: 1.0
9
- *
9
+ * Contact: kontakt@emil.de
10
10
  *
11
11
  * NOTE: This class is auto generated by OpenAPI Generator (https://openapi-generator.tech).
12
12
  * https://openapi-generator.tech
@@ -3,7 +3,7 @@
3
3
  * The EMIL DocumentService API description
4
4
  *
5
5
  * The version of the OpenAPI document: 1.0
6
- *
6
+ * Contact: kontakt@emil.de
7
7
  *
8
8
  * NOTE: This class is auto generated by OpenAPI Generator (https://openapi-generator.tech).
9
9
  * https://openapi-generator.tech
@@ -6,7 +6,7 @@
6
6
  * The EMIL DocumentService API description
7
7
  *
8
8
  * The version of the OpenAPI document: 1.0
9
- *
9
+ * Contact: kontakt@emil.de
10
10
  *
11
11
  * NOTE: This class is auto generated by OpenAPI Generator (https://openapi-generator.tech).
12
12
  * https://openapi-generator.tech
@@ -3,7 +3,7 @@
3
3
  * The EMIL DocumentService API description
4
4
  *
5
5
  * The version of the OpenAPI document: 1.0
6
- *
6
+ * Contact: kontakt@emil.de
7
7
  *
8
8
  * NOTE: This class is auto generated by OpenAPI Generator (https://openapi-generator.tech).
9
9
  * https://openapi-generator.tech
@@ -6,7 +6,7 @@
6
6
  * The EMIL DocumentService API description
7
7
  *
8
8
  * The version of the OpenAPI document: 1.0
9
- *
9
+ * Contact: kontakt@emil.de
10
10
  *
11
11
  * NOTE: This class is auto generated by OpenAPI Generator (https://openapi-generator.tech).
12
12
  * https://openapi-generator.tech
@@ -3,7 +3,7 @@
3
3
  * The EMIL DocumentService API description
4
4
  *
5
5
  * The version of the OpenAPI document: 1.0
6
- *
6
+ * Contact: kontakt@emil.de
7
7
  *
8
8
  * NOTE: This class is auto generated by OpenAPI Generator (https://openapi-generator.tech).
9
9
  * https://openapi-generator.tech
@@ -6,7 +6,7 @@
6
6
  * The EMIL DocumentService API description
7
7
  *
8
8
  * The version of the OpenAPI document: 1.0
9
- *
9
+ * Contact: kontakt@emil.de
10
10
  *
11
11
  * NOTE: This class is auto generated by OpenAPI Generator (https://openapi-generator.tech).
12
12
  * https://openapi-generator.tech
@@ -3,7 +3,7 @@
3
3
  * The EMIL DocumentService API description
4
4
  *
5
5
  * The version of the OpenAPI document: 1.0
6
- *
6
+ * Contact: kontakt@emil.de
7
7
  *
8
8
  * NOTE: This class is auto generated by OpenAPI Generator (https://openapi-generator.tech).
9
9
  * https://openapi-generator.tech