@magda/typescript-common 2.3.3 → 3.0.0-alpha.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 (249) hide show
  1. package/dist/AspectBuilder.d.ts +1 -1
  2. package/dist/AspectBuilder.js +1 -2
  3. package/dist/AspectCreationFailure.js +3 -4
  4. package/dist/AspectCreationFailure.js.map +1 -1
  5. package/dist/AsyncPage.js +59 -79
  6. package/dist/AsyncPage.js.map +1 -1
  7. package/dist/BaseApiClient.d.ts +3 -3
  8. package/dist/BaseApiClient.js +20 -13
  9. package/dist/BaseApiClient.js.map +1 -1
  10. package/dist/ConnectionResult.d.ts +2 -2
  11. package/dist/ConnectionResult.js +17 -22
  12. package/dist/ConnectionResult.js.map +1 -1
  13. package/dist/ConnectorRecordId.d.ts +1 -1
  14. package/dist/ConnectorRecordId.js +9 -13
  15. package/dist/ConnectorRecordId.js.map +1 -1
  16. package/dist/IndexerApiClient.d.ts +1 -1
  17. package/dist/IndexerApiClient.js +13 -32
  18. package/dist/IndexerApiClient.js.map +1 -1
  19. package/dist/JsonConnector.d.ts +9 -9
  20. package/dist/JsonConnector.js +163 -206
  21. package/dist/JsonConnector.js.map +1 -1
  22. package/dist/JsonTransformer.d.ts +3 -3
  23. package/dist/JsonTransformer.js +71 -75
  24. package/dist/JsonTransformer.js.map +1 -1
  25. package/dist/OpaCompileResponseParser.d.ts +4 -4
  26. package/dist/OpaCompileResponseParser.js +279 -212
  27. package/dist/OpaCompileResponseParser.js.map +1 -1
  28. package/dist/RecordCreationFailure.d.ts +1 -1
  29. package/dist/RecordCreationFailure.js +4 -4
  30. package/dist/RecordCreationFailure.js.map +1 -1
  31. package/dist/SQLUtils.d.ts +3 -3
  32. package/dist/SQLUtils.js +139 -195
  33. package/dist/SQLUtils.js.map +1 -1
  34. package/dist/ServerError.js +2 -4
  35. package/dist/ServerError.js.map +1 -1
  36. package/dist/Try.js +20 -35
  37. package/dist/Try.js.map +1 -1
  38. package/dist/addTrailingSlash.js +1 -4
  39. package/dist/addTrailingSlash.js.map +1 -1
  40. package/dist/appendUrlSegments.js +3 -8
  41. package/dist/appendUrlSegments.js.map +1 -1
  42. package/dist/authorization-api/AccessControlError.d.ts +1 -1
  43. package/dist/authorization-api/AccessControlError.js +2 -8
  44. package/dist/authorization-api/AccessControlError.js.map +1 -1
  45. package/dist/authorization-api/ApiClient.d.ts +3 -3
  46. package/dist/authorization-api/ApiClient.js +211 -272
  47. package/dist/authorization-api/ApiClient.js.map +1 -1
  48. package/dist/authorization-api/AuthError.d.ts +1 -1
  49. package/dist/authorization-api/AuthError.js +2 -8
  50. package/dist/authorization-api/AuthError.js.map +1 -1
  51. package/dist/authorization-api/GenericError.js +2 -4
  52. package/dist/authorization-api/GenericError.js.map +1 -1
  53. package/dist/authorization-api/authMiddleware.d.ts +3 -3
  54. package/dist/authorization-api/authMiddleware.js +19 -40
  55. package/dist/authorization-api/authMiddleware.js.map +1 -1
  56. package/dist/authorization-api/constants.js +9 -12
  57. package/dist/authorization-api/constants.js.map +1 -1
  58. package/dist/authorization-api/model.d.ts +8 -8
  59. package/dist/authorization-api/model.js +1 -2
  60. package/dist/coerceJson.js +1 -3
  61. package/dist/coerceJson.js.map +1 -1
  62. package/dist/createNoCacheFetchOptions.d.ts +1 -1
  63. package/dist/createNoCacheFetchOptions.js +4 -7
  64. package/dist/createNoCacheFetchOptions.js.map +1 -1
  65. package/dist/createServiceError.d.ts +1 -1
  66. package/dist/createServiceError.js +7 -11
  67. package/dist/createServiceError.js.map +1 -1
  68. package/dist/delay.js +1 -3
  69. package/dist/delay.js.map +1 -1
  70. package/dist/express/getNoCacheHeaders.js +1 -3
  71. package/dist/express/getNoCacheHeaders.js.map +1 -1
  72. package/dist/express/setResponseNoCache.d.ts +1 -1
  73. package/dist/express/setResponseNoCache.js +3 -8
  74. package/dist/express/setResponseNoCache.js.map +1 -1
  75. package/dist/express/status.d.ts +14 -15
  76. package/dist/express/status.js +145 -148
  77. package/dist/express/status.js.map +1 -1
  78. package/dist/fetchRequest.d.ts +6 -6
  79. package/dist/fetchRequest.js +36 -51
  80. package/dist/fetchRequest.js.map +1 -1
  81. package/dist/formatServiceError.js +4 -6
  82. package/dist/formatServiceError.js.map +1 -1
  83. package/dist/generated/registry/api.d.ts +67 -55
  84. package/dist/generated/registry/api.js +557 -765
  85. package/dist/generated/registry/api.js.map +1 -1
  86. package/dist/getAbsoluteUrl.js +8 -11
  87. package/dist/getAbsoluteUrl.js.map +1 -1
  88. package/dist/getBasePathFromUrl.js +3 -9
  89. package/dist/getBasePathFromUrl.js.map +1 -1
  90. package/dist/getBoolValWithDefault.js +1 -3
  91. package/dist/getBoolValWithDefault.js.map +1 -1
  92. package/dist/getRequest.js +9 -26
  93. package/dist/getRequest.js.map +1 -1
  94. package/dist/getRequestNoCache.js +4 -21
  95. package/dist/getRequestNoCache.js.map +1 -1
  96. package/dist/getStorageUrl.js +13 -23
  97. package/dist/getStorageUrl.js.map +1 -1
  98. package/dist/getUserAgent.d.ts +2 -0
  99. package/dist/getUserAgent.js +10 -0
  100. package/dist/getUserAgent.js.map +1 -0
  101. package/dist/handleServerError.js +3 -9
  102. package/dist/handleServerError.js.map +1 -1
  103. package/dist/markdownToHtml.js +5 -11
  104. package/dist/markdownToHtml.js.map +1 -1
  105. package/dist/opa/AspectQuery.js +55 -79
  106. package/dist/opa/AspectQuery.js.map +1 -1
  107. package/dist/opa/AuthDecision.d.ts +2 -2
  108. package/dist/opa/AuthDecision.js +52 -69
  109. package/dist/opa/AuthDecision.js.map +1 -1
  110. package/dist/opa/AuthDecisionQueryClient.d.ts +2 -2
  111. package/dist/opa/AuthDecisionQueryClient.js +72 -102
  112. package/dist/opa/AuthDecisionQueryClient.js.map +1 -1
  113. package/dist/pgTypes.js +4 -9
  114. package/dist/pgTypes.js.map +1 -1
  115. package/dist/registry/AuthorizedRegistryClient.d.ts +4 -4
  116. package/dist/registry/AuthorizedRegistryClient.js +55 -95
  117. package/dist/registry/AuthorizedRegistryClient.js.map +1 -1
  118. package/dist/registry/RegistryClient.d.ts +2 -3
  119. package/dist/registry/RegistryClient.js +61 -78
  120. package/dist/registry/RegistryClient.js.map +1 -1
  121. package/dist/registry/TenantConsts.js +3 -6
  122. package/dist/registry/TenantConsts.js.map +1 -1
  123. package/dist/registry/model.js +1 -2
  124. package/dist/registry-manual/api.d.ts +1 -1
  125. package/dist/registry-manual/api.js +18 -7
  126. package/dist/registry-manual/api.js.map +1 -1
  127. package/dist/retry.d.ts +1 -1
  128. package/dist/retry.js +3 -9
  129. package/dist/retry.js.map +1 -1
  130. package/dist/retryBackoff.js +3 -9
  131. package/dist/retryBackoff.js.map +1 -1
  132. package/dist/runLater.js +1 -4
  133. package/dist/runLater.js.map +1 -1
  134. package/dist/session/GetUserId.d.ts +2 -2
  135. package/dist/session/GetUserId.js +10 -16
  136. package/dist/session/GetUserId.js.map +1 -1
  137. package/dist/session/GetUserSession.d.ts +1 -1
  138. package/dist/session/GetUserSession.js +6 -10
  139. package/dist/session/GetUserSession.js.map +1 -1
  140. package/dist/session/addJwtSecretFromEnvVar.js +1 -4
  141. package/dist/session/addJwtSecretFromEnvVar.js.map +1 -1
  142. package/dist/session/buildJwt.d.ts +1 -1
  143. package/dist/session/buildJwt.js +2 -5
  144. package/dist/session/buildJwt.js.map +1 -1
  145. package/dist/session/buildJwtFromReq.d.ts +1 -1
  146. package/dist/session/buildJwtFromReq.js +3 -8
  147. package/dist/session/buildJwtFromReq.js.map +1 -1
  148. package/dist/session/cookieUtils.d.ts +2 -13
  149. package/dist/session/cookieUtils.js +8 -9
  150. package/dist/session/cookieUtils.js.map +1 -1
  151. package/dist/session/destroySession.js +18 -33
  152. package/dist/session/destroySession.js.map +1 -1
  153. package/dist/session/getSessionId.js +5 -11
  154. package/dist/session/getSessionId.js.map +1 -1
  155. package/dist/tenant-api/AuthorizedTenantClient.d.ts +1 -1
  156. package/dist/tenant-api/AuthorizedTenantClient.js +22 -36
  157. package/dist/tenant-api/AuthorizedTenantClient.js.map +1 -1
  158. package/dist/tenant-api/Tenant.js +13 -5
  159. package/dist/tenant-api/Tenant.js.map +1 -1
  160. package/dist/test/JsonConnector.spec.js +56 -61
  161. package/dist/test/JsonConnector.spec.js.map +1 -1
  162. package/dist/test/JsonTransformer.spec.js +15 -19
  163. package/dist/test/JsonTransformer.spec.js.map +1 -1
  164. package/dist/test/arbitraries.d.ts +21 -21
  165. package/dist/test/arbitraries.js +85 -99
  166. package/dist/test/arbitraries.js.map +1 -1
  167. package/dist/test/aspect-templates/organization-details.d.ts +1 -4
  168. package/dist/test/aspect-templates/organization-details.js +1 -1
  169. package/dist/test/aspect-templates/organization-details.js.map +1 -1
  170. package/dist/test/buildApiClient.spec.js +81 -107
  171. package/dist/test/buildApiClient.spec.js.map +1 -1
  172. package/dist/test/buildAuthorizedTenantClient.spec.js +25 -40
  173. package/dist/test/buildAuthorizedTenantClient.spec.js.map +1 -1
  174. package/dist/test/connectors/MockExpressServer.js +9 -23
  175. package/dist/test/connectors/MockExpressServer.js.map +1 -1
  176. package/dist/test/connectors/MockRegistry.d.ts +1 -1
  177. package/dist/test/connectors/MockRegistry.js +11 -18
  178. package/dist/test/connectors/MockRegistry.js.map +1 -1
  179. package/dist/test/connectors/runConnectorTest.js +33 -55
  180. package/dist/test/connectors/runConnectorTest.js.map +1 -1
  181. package/dist/test/createMockAuthDecisionQueryClient.d.ts +4 -4
  182. package/dist/test/createMockAuthDecisionQueryClient.js +4 -9
  183. package/dist/test/createMockAuthDecisionQueryClient.js.map +1 -1
  184. package/dist/test/db/getTestDBConfig.js +1 -3
  185. package/dist/test/db/getTestDBConfig.js.map +1 -1
  186. package/dist/test/db/runMigrationSql.js +37 -58
  187. package/dist/test/db/runMigrationSql.js.map +1 -1
  188. package/dist/test/express/status.spec.js +81 -72
  189. package/dist/test/express/status.spec.js.map +1 -1
  190. package/dist/test/fakeArgv.js +6 -5
  191. package/dist/test/fakeArgv.js.map +1 -1
  192. package/dist/test/getBasePathFromUrl.spec.js +5 -10
  193. package/dist/test/getBasePathFromUrl.spec.js.map +1 -1
  194. package/dist/test/getStorageUrl.spec.js +22 -46
  195. package/dist/test/getStorageUrl.spec.js.map +1 -1
  196. package/dist/test/mockAuthApiHost.js +26 -28
  197. package/dist/test/mockAuthApiHost.js.map +1 -1
  198. package/dist/test/mockAuthorization.js +4 -10
  199. package/dist/test/mockAuthorization.js.map +1 -1
  200. package/dist/test/mockTenantDataStore.d.ts +1 -1
  201. package/dist/test/mockTenantDataStore.js +3 -5
  202. package/dist/test/mockTenantDataStore.js.map +1 -1
  203. package/dist/test/mockUserDataStore.d.ts +1 -1
  204. package/dist/test/mockUserDataStore.js +4 -6
  205. package/dist/test/mockUserDataStore.js.map +1 -1
  206. package/dist/test/registry/buildAuthorizedClient.spec.js +65 -87
  207. package/dist/test/registry/buildAuthorizedClient.spec.js.map +1 -1
  208. package/dist/test/session/buildJwt.spec.js +15 -19
  209. package/dist/test/session/buildJwt.spec.js.map +1 -1
  210. package/dist/test/session/buildJwtForRegistryEsriOpaGroupsAndOwnerTest.spec.js +6 -11
  211. package/dist/test/session/buildJwtForRegistryEsriOpaGroupsAndOwnerTest.spec.js.map +1 -1
  212. package/dist/test/session/buildJwtForRegistryEsriOpaGroupsTest.spec.js +6 -11
  213. package/dist/test/session/buildJwtForRegistryEsriOpaGroupsTest.spec.js.map +1 -1
  214. package/dist/test/session/buildJwtForRegistryEsriOpaOwnerTest.spec.js +6 -11
  215. package/dist/test/session/buildJwtForRegistryEsriOpaOwnerTest.spec.js.map +1 -1
  216. package/dist/test/testAsyncPage.spec.js +84 -105
  217. package/dist/test/testAsyncPage.spec.js.map +1 -1
  218. package/dist/test/testOpaCompileResponseParser.spec.js +192 -196
  219. package/dist/test/testOpaCompileResponseParser.spec.js.map +1 -1
  220. package/dist/test/util.js +1 -5
  221. package/dist/test/util.js.map +1 -1
  222. package/dist/unknown2Error.d.ts +2 -0
  223. package/dist/unknown2Error.js +3 -0
  224. package/dist/unknown2Error.js.map +1 -0
  225. package/dist/util/arrayToMaybe.d.ts +1 -1
  226. package/dist/util/arrayToMaybe.js +3 -6
  227. package/dist/util/arrayToMaybe.js.map +1 -1
  228. package/dist/util/cleanOrgTitle.js +1 -4
  229. package/dist/util/cleanOrgTitle.js.map +1 -1
  230. package/dist/util/escapeRegExp.js +1 -3
  231. package/dist/util/escapeRegExp.js.map +1 -1
  232. package/dist/util/getMinikubeIP.js +3 -9
  233. package/dist/util/getMinikubeIP.js.map +1 -1
  234. package/dist/util/isArray.js +1 -3
  235. package/dist/util/isArray.js.map +1 -1
  236. package/dist/util/isUuid.js +1 -3
  237. package/dist/util/isUuid.js.map +1 -1
  238. package/dist/util/unionToThrowable.d.ts +1 -1
  239. package/dist/util/unionToThrowable.js +3 -9
  240. package/dist/util/unionToThrowable.js.map +1 -1
  241. package/dist/utilityTypes.d.ts +1 -1
  242. package/dist/utilityTypes.js +1 -2
  243. package/package.json +45 -29
  244. package/dist/request.d.ts +0 -3
  245. package/dist/request.js +0 -19
  246. package/dist/request.js.map +0 -1
  247. package/dist/test/jsverify.d.ts +0 -2
  248. package/dist/test/jsverify.js +0 -8
  249. package/dist/test/jsverify.js.map +0 -1
@@ -1,4 +1,3 @@
1
- "use strict";
2
1
  /**
3
2
  *
4
3
  * No description provided (generated by Swagger Codegen https://github.com/swagger-api/swagger-codegen)
@@ -10,140 +9,345 @@
10
9
  * https://github.com/swagger-api/swagger-codegen.git
11
10
  * Do not edit the class manually.
12
11
  */
13
- Object.defineProperty(exports, "__esModule", { value: true });
14
- exports.WebHooksApi = exports.WebHooksApiApiKeys = exports.RecordsApi = exports.RecordsApiApiKeys = exports.RecordHistoryApi = exports.RecordHistoryApiApiKeys = exports.RecordAspectsApi = exports.RecordAspectsApiApiKeys = exports.AspectDefinitionsApi = exports.AspectDefinitionsApiApiKeys = exports.VoidAuth = exports.OAuth = exports.ApiKeyAuth = exports.HttpBasicAuth = exports.WebHookConfig = exports.WebHookAcknowledgementResponse = exports.WebHookAcknowledgement = exports.WebHook = exports.RegistryEvent = exports.RecordSummary = exports.Record = exports.PutRecordsAspectRequest = exports.PatchRecordsRequest = exports.Operation = exports.MultipleDeleteResult = exports.JsonPatch = exports.JsValue = exports.JsObject = exports.EventsPage = exports.DeleteResult = exports.DeleteRecordsAspectArrayItemsRequest = exports.CountResponse = exports.AspectDefinition = exports.ApiError = void 0;
15
- const request = require("request");
12
+ import fetch, { Headers } from 'cross-fetch';
16
13
  let defaultBasePath = 'http://localhost/api/v0/registry/';
17
14
  // ===============================================
18
15
  // This file is autogenerated - Please do not edit
19
16
  // ===============================================
20
17
  /* tslint:disable:no-unused-variable */
21
- class ApiError {
18
+ export class ApiError {
19
+ 'message';
22
20
  }
23
- exports.ApiError = ApiError;
24
21
  /**
25
22
  * A type of aspect in the registry, unique for a tenant.
26
23
  */
27
- class AspectDefinition {
24
+ export class AspectDefinition {
25
+ /**
26
+ * The identifier for the aspect type.
27
+ */
28
+ 'id';
29
+ /**
30
+ * The name of the aspect.
31
+ */
32
+ 'name';
33
+ /**
34
+ * The JSON Schema of this aspect.
35
+ */
36
+ 'jsonSchema';
28
37
  }
29
- exports.AspectDefinition = AspectDefinition;
30
- class CountResponse {
38
+ export class CountResponse {
39
+ 'count';
31
40
  }
32
- exports.CountResponse = CountResponse;
33
- class DeleteRecordsAspectArrayItemsRequest {
41
+ export class DeleteRecordsAspectArrayItemsRequest {
42
+ 'recordIds';
43
+ 'jsonPath';
44
+ 'items';
34
45
  }
35
- exports.DeleteRecordsAspectArrayItemsRequest = DeleteRecordsAspectArrayItemsRequest;
36
- class DeleteResult {
46
+ export class DeleteResult {
47
+ 'deleted';
37
48
  }
38
- exports.DeleteResult = DeleteResult;
39
49
  /**
40
50
  * A page of events.
41
51
  */
42
- class EventsPage {
52
+ export class EventsPage {
53
+ /**
54
+ * Whether there are more events available.
55
+ */
56
+ 'hasMore';
57
+ /**
58
+ * A token to be used to get the next page of events.
59
+ */
60
+ 'nextPageToken';
61
+ /**
62
+ * The events in this page.
63
+ */
64
+ 'events';
43
65
  }
44
- exports.EventsPage = EventsPage;
45
- class JsObject {
66
+ export class JsObject {
67
+ 'fields';
46
68
  }
47
- exports.JsObject = JsObject;
48
- class JsValue {
69
+ export class JsValue {
49
70
  }
50
- exports.JsValue = JsValue;
51
- class JsonPatch {
71
+ export class JsonPatch {
72
+ 'ops';
52
73
  }
53
- exports.JsonPatch = JsonPatch;
54
- class MultipleDeleteResult {
74
+ export class MultipleDeleteResult {
75
+ 'count';
55
76
  }
56
- exports.MultipleDeleteResult = MultipleDeleteResult;
57
- class Operation {
77
+ export class Operation {
58
78
  }
59
- exports.Operation = Operation;
60
- class PatchRecordsRequest {
79
+ export class PatchRecordsRequest {
80
+ 'recordIds';
81
+ 'jsonPath';
61
82
  }
62
- exports.PatchRecordsRequest = PatchRecordsRequest;
63
- class PutRecordsAspectRequest {
83
+ export class PutRecordsAspectRequest {
84
+ 'recordIds';
85
+ 'data';
64
86
  }
65
- exports.PutRecordsAspectRequest = PutRecordsAspectRequest;
66
87
  /**
67
88
  * A record in the registry, usually including data for one or more aspects, unique for a tenant.
68
89
  */
69
- class Record {
90
+ export class Record {
91
+ /**
92
+ * The identifier of the record
93
+ */
94
+ 'id';
95
+ /**
96
+ * The name of the record
97
+ */
98
+ 'name';
99
+ /**
100
+ * The aspects included in this record
101
+ */
102
+ 'aspects';
103
+ /**
104
+ * A tag representing the action by the source of this record (e.g. an id for a individual crawl of a data portal).
105
+ */
106
+ 'sourceTag';
107
+ /**
108
+ * The identifier of a tenant
109
+ */
110
+ 'tenantId';
70
111
  }
71
- exports.Record = Record;
72
112
  /**
73
113
  * A summary of a record in the registry. Summaries specify which aspects are available, but do not include data for any aspects.
74
114
  */
75
- class RecordSummary {
115
+ export class RecordSummary {
116
+ /**
117
+ * The identifier of the record
118
+ */
119
+ 'id';
120
+ /**
121
+ * The name of the record
122
+ */
123
+ 'name';
124
+ /**
125
+ * The list of aspect IDs for which this record has data
126
+ */
127
+ 'aspects';
128
+ /**
129
+ * The identifier of the tenant
130
+ */
131
+ 'tenantId';
76
132
  }
77
- exports.RecordSummary = RecordSummary;
78
- class RegistryEvent {
133
+ export class RegistryEvent {
134
+ 'id';
135
+ 'eventTime';
136
+ 'eventType';
137
+ 'userId';
138
+ 'data';
139
+ 'tenantId';
79
140
  }
80
- exports.RegistryEvent = RegistryEvent;
81
- class WebHook {
141
+ export class WebHook {
142
+ 'id';
143
+ 'name';
144
+ 'active';
145
+ 'lastEvent';
146
+ 'url';
147
+ 'eventTypes';
148
+ 'isWaitingForResponse';
149
+ 'config';
150
+ 'enabled';
151
+ 'lastRetryTime';
152
+ 'retryCount';
153
+ 'isRunning';
154
+ 'isProcessing';
155
+ 'ownerId';
156
+ 'creatorId';
157
+ 'editorId';
158
+ 'createTime';
159
+ 'editTime';
82
160
  }
83
- exports.WebHook = WebHook;
84
161
  /**
85
162
  * Asynchronously acknowledges receipt of a web hook notification.
86
163
  */
87
- class WebHookAcknowledgement {
164
+ export class WebHookAcknowledgement {
165
+ /**
166
+ * True if the web hook was received successfully and the listener is ready for further notifications. False if the web hook was not received and the same notification should be repeated.
167
+ */
168
+ 'succeeded';
169
+ /**
170
+ * The ID of the last event received by the listener. This should be the value of the `lastEventId` property of the web hook payload that is being acknowledged. This value is ignored if `succeeded` is false.
171
+ */
172
+ 'lastEventIdReceived';
173
+ /**
174
+ * Should the webhook be active or inactive?
175
+ */
176
+ 'active';
88
177
  }
89
- exports.WebHookAcknowledgement = WebHookAcknowledgement;
90
178
  /**
91
179
  * The response to an asynchronous web hook acknowledgement.
92
180
  */
93
- class WebHookAcknowledgementResponse {
181
+ export class WebHookAcknowledgementResponse {
182
+ /**
183
+ * The ID of the last event successfully received by the listener. Further notifications will start after this event.
184
+ */
185
+ 'lastEventIdReceived';
186
+ }
187
+ export class WebHookConfig {
188
+ 'aspects';
189
+ 'optionalAspects';
190
+ 'includeEvents';
191
+ 'includeRecords';
192
+ 'includeAspectDefinitions';
193
+ 'dereference';
194
+ }
195
+ export function setRequestOptionsHeader(requestOptions, headerName, headerValue) {
196
+ if (headerValue === null || typeof headerValue === 'undefined') {
197
+ return;
198
+ }
199
+ if (!requestOptions?.headers) {
200
+ requestOptions.headers = new Headers();
201
+ }
202
+ if (requestOptions.headers instanceof Headers) {
203
+ requestOptions.headers.set(headerName, headerValue);
204
+ }
205
+ else {
206
+ requestOptions.headers[headerName] = headerValue;
207
+ }
94
208
  }
95
- exports.WebHookAcknowledgementResponse = WebHookAcknowledgementResponse;
96
- class WebHookConfig {
209
+ export const isPlainObj = (value) => !!value && Object.getPrototypeOf(value) === Object.prototype;
210
+ export const isTextMimeType = (contentType) => /text\/.*/i.test(contentType) || /[\/|\+]xml.*/i.test(contentType);
211
+ export const isNotEmpty = (val) => val !== null && val !== undefined;
212
+ export async function fetchWithRequestOptions(requestOptions) {
213
+ const { uri, qs, json, encoding, form, formData, ...fetchOptions } = requestOptions;
214
+ const url = new URL(uri);
215
+ if (qs && Object.keys(qs).length > 0) {
216
+ for (const key in qs) {
217
+ const value = qs[key];
218
+ url.searchParams.delete(key);
219
+ if (!isNotEmpty(value)) {
220
+ url.searchParams.append(key, '');
221
+ continue;
222
+ }
223
+ if (Array.isArray(value)) {
224
+ value.forEach((v) => url.searchParams.append(key, v));
225
+ }
226
+ else {
227
+ url.searchParams.append(key, value);
228
+ }
229
+ }
230
+ }
231
+ if (fetchOptions?.body) {
232
+ const body = fetchOptions.body;
233
+ const requireJsonStringify = isPlainObj(body) || Array.isArray(body);
234
+ if (json || requireJsonStringify) {
235
+ setRequestOptionsHeader(fetchOptions, 'Content-Type', 'application/json');
236
+ }
237
+ if (requireJsonStringify) {
238
+ fetchOptions.body = JSON.stringify(body);
239
+ }
240
+ else {
241
+ fetchOptions.body = body;
242
+ }
243
+ }
244
+ if (form && formData) {
245
+ throw new Error('Only one of form or formData can be set for request options');
246
+ }
247
+ if (fetchOptions?.body && (form || formData)) {
248
+ throw new Error('Only one of body or form or formData can be set for request options');
249
+ }
250
+ if (form) {
251
+ setRequestOptionsHeader(fetchOptions, 'Content-Type', 'application/x-www-form-urlencoded');
252
+ if (typeof form === 'string') {
253
+ fetchOptions.body = form;
254
+ }
255
+ else {
256
+ const params = new URLSearchParams();
257
+ for (const key in form) {
258
+ params.append(key, form[key]);
259
+ }
260
+ fetchOptions.body = params;
261
+ }
262
+ }
263
+ if (formData) {
264
+ const form = new FormData();
265
+ for (const key in formData) {
266
+ form.append(key, formData[key]);
267
+ }
268
+ fetchOptions.body = form;
269
+ }
270
+ const res = await fetch(url, fetchOptions);
271
+ let contentType = res.headers.get('Content-Type');
272
+ contentType = contentType ? contentType : '';
273
+ let body;
274
+ if (encoding === null) {
275
+ body = await res.blob();
276
+ }
277
+ else if (contentType === 'application/json') {
278
+ body = await res.json();
279
+ }
280
+ else if (isTextMimeType(contentType)) {
281
+ body = await res.text();
282
+ }
283
+ else {
284
+ if (typeof encoding === 'string' && encoding) {
285
+ const buffer = await res.arrayBuffer();
286
+ const decoder = new TextDecoder(encoding);
287
+ body = decoder.decode(buffer);
288
+ }
289
+ else {
290
+ body = await res.text();
291
+ }
292
+ }
293
+ if (res.ok) {
294
+ return { response: res, body };
295
+ }
296
+ else {
297
+ throw { response: res, body };
298
+ }
97
299
  }
98
- exports.WebHookConfig = WebHookConfig;
99
- class HttpBasicAuth {
300
+ export class HttpBasicAuth {
301
+ username;
302
+ password;
100
303
  applyToRequest(requestOptions) {
101
- requestOptions.auth = {
102
- username: this.username, password: this.password
103
- };
304
+ const basicAuthValue = Buffer.from(this.username + ':' + this.password, 'utf-8').toString('base64');
305
+ setRequestOptionsHeader(requestOptions, 'Authorization', 'Basic ' + basicAuthValue);
104
306
  }
105
307
  }
106
- exports.HttpBasicAuth = HttpBasicAuth;
107
- class ApiKeyAuth {
308
+ export class ApiKeyAuth {
309
+ location;
310
+ paramName;
311
+ apiKey;
108
312
  constructor(location, paramName) {
109
313
  this.location = location;
110
314
  this.paramName = paramName;
111
315
  }
112
316
  applyToRequest(requestOptions) {
113
- if (this.location == "query") {
317
+ if (this.location == 'query') {
318
+ if (!requestOptions.qs) {
319
+ requestOptions.qs = {};
320
+ }
114
321
  requestOptions.qs[this.paramName] = this.apiKey;
115
322
  }
116
- else if (this.location == "header" && requestOptions && requestOptions.headers) {
117
- requestOptions.headers[this.paramName] = this.apiKey;
323
+ else if (this.location == 'header') {
324
+ setRequestOptionsHeader(requestOptions, this.paramName, this.apiKey);
118
325
  }
119
326
  }
120
327
  }
121
- exports.ApiKeyAuth = ApiKeyAuth;
122
- class OAuth {
328
+ export class OAuth {
329
+ accessToken;
123
330
  applyToRequest(requestOptions) {
124
- if (requestOptions && requestOptions.headers) {
125
- requestOptions.headers["Authorization"] = "Bearer " + this.accessToken;
126
- }
331
+ setRequestOptionsHeader(requestOptions, 'Authorization', 'Bearer ' + this.accessToken);
127
332
  }
128
333
  }
129
- exports.OAuth = OAuth;
130
- class VoidAuth {
334
+ export class VoidAuth {
335
+ username;
336
+ password;
131
337
  applyToRequest(_) {
132
338
  // Do nothing
133
339
  }
134
340
  }
135
- exports.VoidAuth = VoidAuth;
136
- var AspectDefinitionsApiApiKeys;
341
+ export var AspectDefinitionsApiApiKeys;
137
342
  (function (AspectDefinitionsApiApiKeys) {
138
- })(AspectDefinitionsApiApiKeys = exports.AspectDefinitionsApiApiKeys || (exports.AspectDefinitionsApiApiKeys = {}));
139
- class AspectDefinitionsApi {
343
+ })(AspectDefinitionsApiApiKeys || (AspectDefinitionsApiApiKeys = {}));
344
+ export class AspectDefinitionsApi {
345
+ basePath = defaultBasePath;
346
+ defaultHeaders = {};
347
+ authentications = {
348
+ 'default': new VoidAuth(),
349
+ };
140
350
  constructor(basePathOrUsername, password, basePath) {
141
- this.basePath = defaultBasePath;
142
- this.defaultHeaders = {};
143
- this._useQuerystring = false;
144
- this.authentications = {
145
- 'default': new VoidAuth(),
146
- };
147
351
  if (password) {
148
352
  if (basePath) {
149
353
  this.basePath = basePath;
@@ -155,9 +359,6 @@ class AspectDefinitionsApi {
155
359
  }
156
360
  }
157
361
  }
158
- set useQuerystring(value) {
159
- this._useQuerystring = value;
160
- }
161
362
  setApiKey(key, value) {
162
363
  this.authentications[AspectDefinitionsApiApiKeys[key]].apiKey = value;
163
364
  }
@@ -185,15 +386,18 @@ class AspectDefinitionsApi {
185
386
  if (xMagdaSession === null || xMagdaSession === undefined) {
186
387
  throw new Error('Required parameter xMagdaSession was null or undefined when calling create.');
187
388
  }
188
- headerParams['X-Magda-Tenant-Id'] = xMagdaTenantId;
189
- headerParams['X-Magda-Session'] = xMagdaSession;
389
+ if (isNotEmpty(xMagdaTenantId)) {
390
+ headerParams['X-Magda-Tenant-Id'] = xMagdaTenantId;
391
+ }
392
+ if (isNotEmpty(xMagdaSession)) {
393
+ headerParams['X-Magda-Session'] = xMagdaSession;
394
+ }
190
395
  let useFormData = false;
191
- let requestOptions = {
396
+ const requestOptions = {
192
397
  method: 'POST',
193
398
  qs: queryParameters,
194
399
  headers: headerParams,
195
400
  uri: localVarPath,
196
- useQuerystring: this._useQuerystring,
197
401
  json: true,
198
402
  body: aspect,
199
403
  };
@@ -206,21 +410,7 @@ class AspectDefinitionsApi {
206
410
  requestOptions.form = formParams;
207
411
  }
208
412
  }
209
- return new Promise((resolve, reject) => {
210
- request(requestOptions, (error, response, body) => {
211
- if (error) {
212
- reject(error);
213
- }
214
- else {
215
- if (response.statusCode >= 200 && response.statusCode <= 299) {
216
- resolve({ response: response, body: body });
217
- }
218
- else {
219
- reject({ response: response, body: body });
220
- }
221
- }
222
- });
223
- });
413
+ return fetchWithRequestOptions(requestOptions);
224
414
  }
225
415
  /**
226
416
  * Get a list of all aspects
@@ -237,15 +427,18 @@ class AspectDefinitionsApi {
237
427
  if (xMagdaTenantId === null || xMagdaTenantId === undefined) {
238
428
  throw new Error('Required parameter xMagdaTenantId was null or undefined when calling getAll.');
239
429
  }
240
- headerParams['X-Magda-Tenant-Id'] = xMagdaTenantId;
241
- headerParams['X-Magda-Session'] = xMagdaSession;
430
+ if (isNotEmpty(xMagdaTenantId)) {
431
+ headerParams['X-Magda-Tenant-Id'] = xMagdaTenantId;
432
+ }
433
+ if (isNotEmpty(xMagdaSession)) {
434
+ headerParams['X-Magda-Session'] = xMagdaSession;
435
+ }
242
436
  let useFormData = false;
243
- let requestOptions = {
437
+ const requestOptions = {
244
438
  method: 'GET',
245
439
  qs: queryParameters,
246
440
  headers: headerParams,
247
441
  uri: localVarPath,
248
- useQuerystring: this._useQuerystring,
249
442
  json: true,
250
443
  };
251
444
  this.authentications.default.applyToRequest(requestOptions);
@@ -257,21 +450,7 @@ class AspectDefinitionsApi {
257
450
  requestOptions.form = formParams;
258
451
  }
259
452
  }
260
- return new Promise((resolve, reject) => {
261
- request(requestOptions, (error, response, body) => {
262
- if (error) {
263
- reject(error);
264
- }
265
- else {
266
- if (response.statusCode >= 200 && response.statusCode <= 299) {
267
- resolve({ response: response, body: body });
268
- }
269
- else {
270
- reject({ response: response, body: body });
271
- }
272
- }
273
- });
274
- });
453
+ return fetchWithRequestOptions(requestOptions);
275
454
  }
276
455
  /**
277
456
  * Get an aspect by ID
@@ -294,15 +473,18 @@ class AspectDefinitionsApi {
294
473
  if (id === null || id === undefined) {
295
474
  throw new Error('Required parameter id was null or undefined when calling getById.');
296
475
  }
297
- headerParams['X-Magda-Tenant-Id'] = xMagdaTenantId;
298
- headerParams['X-Magda-Session'] = xMagdaSession;
476
+ if (isNotEmpty(xMagdaTenantId)) {
477
+ headerParams['X-Magda-Tenant-Id'] = xMagdaTenantId;
478
+ }
479
+ if (isNotEmpty(xMagdaSession)) {
480
+ headerParams['X-Magda-Session'] = xMagdaSession;
481
+ }
299
482
  let useFormData = false;
300
- let requestOptions = {
483
+ const requestOptions = {
301
484
  method: 'GET',
302
485
  qs: queryParameters,
303
486
  headers: headerParams,
304
487
  uri: localVarPath,
305
- useQuerystring: this._useQuerystring,
306
488
  json: true,
307
489
  };
308
490
  this.authentications.default.applyToRequest(requestOptions);
@@ -314,21 +496,7 @@ class AspectDefinitionsApi {
314
496
  requestOptions.form = formParams;
315
497
  }
316
498
  }
317
- return new Promise((resolve, reject) => {
318
- request(requestOptions, (error, response, body) => {
319
- if (error) {
320
- reject(error);
321
- }
322
- else {
323
- if (response.statusCode >= 200 && response.statusCode <= 299) {
324
- resolve({ response: response, body: body });
325
- }
326
- else {
327
- reject({ response: response, body: body });
328
- }
329
- }
330
- });
331
- });
499
+ return fetchWithRequestOptions(requestOptions);
332
500
  }
333
501
  /**
334
502
  * Modify an aspect by applying a JSON Patch
@@ -360,15 +528,18 @@ class AspectDefinitionsApi {
360
528
  if (xMagdaSession === null || xMagdaSession === undefined) {
361
529
  throw new Error('Required parameter xMagdaSession was null or undefined when calling patchById.');
362
530
  }
363
- headerParams['X-Magda-Tenant-Id'] = xMagdaTenantId;
364
- headerParams['X-Magda-Session'] = xMagdaSession;
531
+ if (isNotEmpty(xMagdaTenantId)) {
532
+ headerParams['X-Magda-Tenant-Id'] = xMagdaTenantId;
533
+ }
534
+ if (isNotEmpty(xMagdaSession)) {
535
+ headerParams['X-Magda-Session'] = xMagdaSession;
536
+ }
365
537
  let useFormData = false;
366
- let requestOptions = {
538
+ const requestOptions = {
367
539
  method: 'PATCH',
368
540
  qs: queryParameters,
369
541
  headers: headerParams,
370
542
  uri: localVarPath,
371
- useQuerystring: this._useQuerystring,
372
543
  json: true,
373
544
  body: aspectPatch,
374
545
  };
@@ -381,21 +552,7 @@ class AspectDefinitionsApi {
381
552
  requestOptions.form = formParams;
382
553
  }
383
554
  }
384
- return new Promise((resolve, reject) => {
385
- request(requestOptions, (error, response, body) => {
386
- if (error) {
387
- reject(error);
388
- }
389
- else {
390
- if (response.statusCode >= 200 && response.statusCode <= 299) {
391
- resolve({ response: response, body: body });
392
- }
393
- else {
394
- reject({ response: response, body: body });
395
- }
396
- }
397
- });
398
- });
555
+ return fetchWithRequestOptions(requestOptions);
399
556
  }
400
557
  /**
401
558
  * Modify an aspect by ID
@@ -427,15 +584,18 @@ class AspectDefinitionsApi {
427
584
  if (xMagdaSession === null || xMagdaSession === undefined) {
428
585
  throw new Error('Required parameter xMagdaSession was null or undefined when calling putById.');
429
586
  }
430
- headerParams['X-Magda-Tenant-Id'] = xMagdaTenantId;
431
- headerParams['X-Magda-Session'] = xMagdaSession;
587
+ if (isNotEmpty(xMagdaTenantId)) {
588
+ headerParams['X-Magda-Tenant-Id'] = xMagdaTenantId;
589
+ }
590
+ if (isNotEmpty(xMagdaSession)) {
591
+ headerParams['X-Magda-Session'] = xMagdaSession;
592
+ }
432
593
  let useFormData = false;
433
- let requestOptions = {
594
+ const requestOptions = {
434
595
  method: 'PUT',
435
596
  qs: queryParameters,
436
597
  headers: headerParams,
437
598
  uri: localVarPath,
438
- useQuerystring: this._useQuerystring,
439
599
  json: true,
440
600
  body: aspect,
441
601
  };
@@ -448,35 +608,19 @@ class AspectDefinitionsApi {
448
608
  requestOptions.form = formParams;
449
609
  }
450
610
  }
451
- return new Promise((resolve, reject) => {
452
- request(requestOptions, (error, response, body) => {
453
- if (error) {
454
- reject(error);
455
- }
456
- else {
457
- if (response.statusCode >= 200 && response.statusCode <= 299) {
458
- resolve({ response: response, body: body });
459
- }
460
- else {
461
- reject({ response: response, body: body });
462
- }
463
- }
464
- });
465
- });
611
+ return fetchWithRequestOptions(requestOptions);
466
612
  }
467
613
  }
468
- exports.AspectDefinitionsApi = AspectDefinitionsApi;
469
- var RecordAspectsApiApiKeys;
614
+ export var RecordAspectsApiApiKeys;
470
615
  (function (RecordAspectsApiApiKeys) {
471
- })(RecordAspectsApiApiKeys = exports.RecordAspectsApiApiKeys || (exports.RecordAspectsApiApiKeys = {}));
472
- class RecordAspectsApi {
616
+ })(RecordAspectsApiApiKeys || (RecordAspectsApiApiKeys = {}));
617
+ export class RecordAspectsApi {
618
+ basePath = defaultBasePath;
619
+ defaultHeaders = {};
620
+ authentications = {
621
+ 'default': new VoidAuth(),
622
+ };
473
623
  constructor(basePathOrUsername, password, basePath) {
474
- this.basePath = defaultBasePath;
475
- this.defaultHeaders = {};
476
- this._useQuerystring = false;
477
- this.authentications = {
478
- 'default': new VoidAuth(),
479
- };
480
624
  if (password) {
481
625
  if (basePath) {
482
626
  this.basePath = basePath;
@@ -488,9 +632,6 @@ class RecordAspectsApi {
488
632
  }
489
633
  }
490
634
  }
491
- set useQuerystring(value) {
492
- this._useQuerystring = value;
493
- }
494
635
  setApiKey(key, value) {
495
636
  this.authentications[RecordAspectsApiApiKeys[key]].apiKey = value;
496
637
  }
@@ -525,15 +666,18 @@ class RecordAspectsApi {
525
666
  if (xMagdaTenantId === null || xMagdaTenantId === undefined) {
526
667
  throw new Error('Required parameter xMagdaTenantId was null or undefined when calling deleteById.');
527
668
  }
528
- headerParams['X-Magda-Session'] = xMagdaSession;
529
- headerParams['X-Magda-Tenant-Id'] = xMagdaTenantId;
669
+ if (isNotEmpty(xMagdaSession)) {
670
+ headerParams['X-Magda-Session'] = xMagdaSession;
671
+ }
672
+ if (isNotEmpty(xMagdaTenantId)) {
673
+ headerParams['X-Magda-Tenant-Id'] = xMagdaTenantId;
674
+ }
530
675
  let useFormData = false;
531
- let requestOptions = {
676
+ const requestOptions = {
532
677
  method: 'DELETE',
533
678
  qs: queryParameters,
534
679
  headers: headerParams,
535
680
  uri: localVarPath,
536
- useQuerystring: this._useQuerystring,
537
681
  json: true,
538
682
  };
539
683
  this.authentications.default.applyToRequest(requestOptions);
@@ -545,21 +689,7 @@ class RecordAspectsApi {
545
689
  requestOptions.form = formParams;
546
690
  }
547
691
  }
548
- return new Promise((resolve, reject) => {
549
- request(requestOptions, (error, response, body) => {
550
- if (error) {
551
- reject(error);
552
- }
553
- else {
554
- if (response.statusCode >= 200 && response.statusCode <= 299) {
555
- resolve({ response: response, body: body });
556
- }
557
- else {
558
- reject({ response: response, body: body });
559
- }
560
- }
561
- });
562
- });
692
+ return fetchWithRequestOptions(requestOptions);
563
693
  }
564
694
  /**
565
695
  * Get a list of a record&#39;s aspects
@@ -598,15 +728,18 @@ class RecordAspectsApi {
598
728
  if (limit !== undefined) {
599
729
  queryParameters['limit'] = limit;
600
730
  }
601
- headerParams['X-Magda-Tenant-Id'] = xMagdaTenantId;
602
- headerParams['X-Magda-Session'] = xMagdaSession;
731
+ if (isNotEmpty(xMagdaTenantId)) {
732
+ headerParams['X-Magda-Tenant-Id'] = xMagdaTenantId;
733
+ }
734
+ if (isNotEmpty(xMagdaSession)) {
735
+ headerParams['X-Magda-Session'] = xMagdaSession;
736
+ }
603
737
  let useFormData = false;
604
- let requestOptions = {
738
+ const requestOptions = {
605
739
  method: 'GET',
606
740
  qs: queryParameters,
607
741
  headers: headerParams,
608
742
  uri: localVarPath,
609
- useQuerystring: this._useQuerystring,
610
743
  json: true,
611
744
  };
612
745
  this.authentications.default.applyToRequest(requestOptions);
@@ -618,21 +751,7 @@ class RecordAspectsApi {
618
751
  requestOptions.form = formParams;
619
752
  }
620
753
  }
621
- return new Promise((resolve, reject) => {
622
- request(requestOptions, (error, response, body) => {
623
- if (error) {
624
- reject(error);
625
- }
626
- else {
627
- if (response.statusCode >= 200 && response.statusCode <= 299) {
628
- resolve({ response: response, body: body });
629
- }
630
- else {
631
- reject({ response: response, body: body });
632
- }
633
- }
634
- });
635
- });
754
+ return fetchWithRequestOptions(requestOptions);
636
755
  }
637
756
  /**
638
757
  * Get the number of aspects that a record has
@@ -659,15 +778,18 @@ class RecordAspectsApi {
659
778
  if (keyword !== undefined) {
660
779
  queryParameters['keyword'] = keyword;
661
780
  }
662
- headerParams['X-Magda-Tenant-Id'] = xMagdaTenantId;
663
- headerParams['X-Magda-Session'] = xMagdaSession;
781
+ if (isNotEmpty(xMagdaTenantId)) {
782
+ headerParams['X-Magda-Tenant-Id'] = xMagdaTenantId;
783
+ }
784
+ if (isNotEmpty(xMagdaSession)) {
785
+ headerParams['X-Magda-Session'] = xMagdaSession;
786
+ }
664
787
  let useFormData = false;
665
- let requestOptions = {
788
+ const requestOptions = {
666
789
  method: 'GET',
667
790
  qs: queryParameters,
668
791
  headers: headerParams,
669
792
  uri: localVarPath,
670
- useQuerystring: this._useQuerystring,
671
793
  json: true,
672
794
  };
673
795
  this.authentications.default.applyToRequest(requestOptions);
@@ -679,21 +801,7 @@ class RecordAspectsApi {
679
801
  requestOptions.form = formParams;
680
802
  }
681
803
  }
682
- return new Promise((resolve, reject) => {
683
- request(requestOptions, (error, response, body) => {
684
- if (error) {
685
- reject(error);
686
- }
687
- else {
688
- if (response.statusCode >= 200 && response.statusCode <= 299) {
689
- resolve({ response: response, body: body });
690
- }
691
- else {
692
- reject({ response: response, body: body });
693
- }
694
- }
695
- });
696
- });
804
+ return fetchWithRequestOptions(requestOptions);
697
805
  }
698
806
  /**
699
807
  * Get a record aspect by ID
@@ -722,15 +830,18 @@ class RecordAspectsApi {
722
830
  if (aspectId === null || aspectId === undefined) {
723
831
  throw new Error('Required parameter aspectId was null or undefined when calling getById.');
724
832
  }
725
- headerParams['X-Magda-Tenant-Id'] = xMagdaTenantId;
726
- headerParams['X-Magda-Session'] = xMagdaSession;
833
+ if (isNotEmpty(xMagdaTenantId)) {
834
+ headerParams['X-Magda-Tenant-Id'] = xMagdaTenantId;
835
+ }
836
+ if (isNotEmpty(xMagdaSession)) {
837
+ headerParams['X-Magda-Session'] = xMagdaSession;
838
+ }
727
839
  let useFormData = false;
728
- let requestOptions = {
840
+ const requestOptions = {
729
841
  method: 'GET',
730
842
  qs: queryParameters,
731
843
  headers: headerParams,
732
844
  uri: localVarPath,
733
- useQuerystring: this._useQuerystring,
734
845
  json: true,
735
846
  };
736
847
  this.authentications.default.applyToRequest(requestOptions);
@@ -742,21 +853,7 @@ class RecordAspectsApi {
742
853
  requestOptions.form = formParams;
743
854
  }
744
855
  }
745
- return new Promise((resolve, reject) => {
746
- request(requestOptions, (error, response, body) => {
747
- if (error) {
748
- reject(error);
749
- }
750
- else {
751
- if (response.statusCode >= 200 && response.statusCode <= 299) {
752
- resolve({ response: response, body: body });
753
- }
754
- else {
755
- reject({ response: response, body: body });
756
- }
757
- }
758
- });
759
- });
856
+ return fetchWithRequestOptions(requestOptions);
760
857
  }
761
858
  /**
762
859
  * Modify a record aspect by applying a JSON Patch
@@ -794,15 +891,18 @@ class RecordAspectsApi {
794
891
  if (xMagdaTenantId === null || xMagdaTenantId === undefined) {
795
892
  throw new Error('Required parameter xMagdaTenantId was null or undefined when calling patchById.');
796
893
  }
797
- headerParams['X-Magda-Session'] = xMagdaSession;
798
- headerParams['X-Magda-Tenant-Id'] = xMagdaTenantId;
894
+ if (isNotEmpty(xMagdaSession)) {
895
+ headerParams['X-Magda-Session'] = xMagdaSession;
896
+ }
897
+ if (isNotEmpty(xMagdaTenantId)) {
898
+ headerParams['X-Magda-Tenant-Id'] = xMagdaTenantId;
899
+ }
799
900
  let useFormData = false;
800
- let requestOptions = {
901
+ const requestOptions = {
801
902
  method: 'PATCH',
802
903
  qs: queryParameters,
803
904
  headers: headerParams,
804
905
  uri: localVarPath,
805
- useQuerystring: this._useQuerystring,
806
906
  json: true,
807
907
  body: aspectPatch,
808
908
  };
@@ -815,21 +915,7 @@ class RecordAspectsApi {
815
915
  requestOptions.form = formParams;
816
916
  }
817
917
  }
818
- return new Promise((resolve, reject) => {
819
- request(requestOptions, (error, response, body) => {
820
- if (error) {
821
- reject(error);
822
- }
823
- else {
824
- if (response.statusCode >= 200 && response.statusCode <= 299) {
825
- resolve({ response: response, body: body });
826
- }
827
- else {
828
- reject({ response: response, body: body });
829
- }
830
- }
831
- });
832
- });
918
+ return fetchWithRequestOptions(requestOptions);
833
919
  }
834
920
  /**
835
921
  * Modify a record aspect by ID
@@ -871,15 +957,18 @@ class RecordAspectsApi {
871
957
  if (merge !== undefined) {
872
958
  queryParameters['merge'] = merge;
873
959
  }
874
- headerParams['X-Magda-Session'] = xMagdaSession;
875
- headerParams['X-Magda-Tenant-Id'] = xMagdaTenantId;
960
+ if (isNotEmpty(xMagdaSession)) {
961
+ headerParams['X-Magda-Session'] = xMagdaSession;
962
+ }
963
+ if (isNotEmpty(xMagdaTenantId)) {
964
+ headerParams['X-Magda-Tenant-Id'] = xMagdaTenantId;
965
+ }
876
966
  let useFormData = false;
877
- let requestOptions = {
967
+ const requestOptions = {
878
968
  method: 'PUT',
879
969
  qs: queryParameters,
880
970
  headers: headerParams,
881
971
  uri: localVarPath,
882
- useQuerystring: this._useQuerystring,
883
972
  json: true,
884
973
  body: aspect,
885
974
  };
@@ -892,35 +981,19 @@ class RecordAspectsApi {
892
981
  requestOptions.form = formParams;
893
982
  }
894
983
  }
895
- return new Promise((resolve, reject) => {
896
- request(requestOptions, (error, response, body) => {
897
- if (error) {
898
- reject(error);
899
- }
900
- else {
901
- if (response.statusCode >= 200 && response.statusCode <= 299) {
902
- resolve({ response: response, body: body });
903
- }
904
- else {
905
- reject({ response: response, body: body });
906
- }
907
- }
908
- });
909
- });
984
+ return fetchWithRequestOptions(requestOptions);
910
985
  }
911
986
  }
912
- exports.RecordAspectsApi = RecordAspectsApi;
913
- var RecordHistoryApiApiKeys;
987
+ export var RecordHistoryApiApiKeys;
914
988
  (function (RecordHistoryApiApiKeys) {
915
- })(RecordHistoryApiApiKeys = exports.RecordHistoryApiApiKeys || (exports.RecordHistoryApiApiKeys = {}));
916
- class RecordHistoryApi {
989
+ })(RecordHistoryApiApiKeys || (RecordHistoryApiApiKeys = {}));
990
+ export class RecordHistoryApi {
991
+ basePath = defaultBasePath;
992
+ defaultHeaders = {};
993
+ authentications = {
994
+ 'default': new VoidAuth(),
995
+ };
917
996
  constructor(basePathOrUsername, password, basePath) {
918
- this.basePath = defaultBasePath;
919
- this.defaultHeaders = {};
920
- this._useQuerystring = false;
921
- this.authentications = {
922
- 'default': new VoidAuth(),
923
- };
924
997
  if (password) {
925
998
  if (basePath) {
926
999
  this.basePath = basePath;
@@ -932,9 +1005,6 @@ class RecordHistoryApi {
932
1005
  }
933
1006
  }
934
1007
  }
935
- set useQuerystring(value) {
936
- this._useQuerystring = value;
937
- }
938
1008
  setApiKey(key, value) {
939
1009
  this.authentications[RecordHistoryApiApiKeys[key]].apiKey = value;
940
1010
  }
@@ -987,15 +1057,18 @@ class RecordHistoryApi {
987
1057
  if (reversePageTokenOrder !== undefined) {
988
1058
  queryParameters['reversePageTokenOrder'] = reversePageTokenOrder;
989
1059
  }
990
- headerParams['X-Magda-Tenant-Id'] = xMagdaTenantId;
991
- headerParams['X-Magda-Session'] = xMagdaSession;
1060
+ if (isNotEmpty(xMagdaTenantId)) {
1061
+ headerParams['X-Magda-Tenant-Id'] = xMagdaTenantId;
1062
+ }
1063
+ if (isNotEmpty(xMagdaSession)) {
1064
+ headerParams['X-Magda-Session'] = xMagdaSession;
1065
+ }
992
1066
  let useFormData = false;
993
- let requestOptions = {
1067
+ const requestOptions = {
994
1068
  method: 'GET',
995
1069
  qs: queryParameters,
996
1070
  headers: headerParams,
997
1071
  uri: localVarPath,
998
- useQuerystring: this._useQuerystring,
999
1072
  json: true,
1000
1073
  };
1001
1074
  this.authentications.default.applyToRequest(requestOptions);
@@ -1007,21 +1080,7 @@ class RecordHistoryApi {
1007
1080
  requestOptions.form = formParams;
1008
1081
  }
1009
1082
  }
1010
- return new Promise((resolve, reject) => {
1011
- request(requestOptions, (error, response, body) => {
1012
- if (error) {
1013
- reject(error);
1014
- }
1015
- else {
1016
- if (response.statusCode >= 200 && response.statusCode <= 299) {
1017
- resolve({ response: response, body: body });
1018
- }
1019
- else {
1020
- reject({ response: response, body: body });
1021
- }
1022
- }
1023
- });
1024
- });
1083
+ return fetchWithRequestOptions(requestOptions);
1025
1084
  }
1026
1085
  /**
1027
1086
  * Get the version of a record that existed after a given event was applied
@@ -1049,14 +1108,15 @@ class RecordHistoryApi {
1049
1108
  if (eventId === null || eventId === undefined) {
1050
1109
  throw new Error('Required parameter eventId was null or undefined when calling version.');
1051
1110
  }
1052
- headerParams['X-Magda-Tenant-Id'] = xMagdaTenantId;
1111
+ if (isNotEmpty(xMagdaTenantId)) {
1112
+ headerParams['X-Magda-Tenant-Id'] = xMagdaTenantId;
1113
+ }
1053
1114
  let useFormData = false;
1054
- let requestOptions = {
1115
+ const requestOptions = {
1055
1116
  method: 'GET',
1056
1117
  qs: queryParameters,
1057
1118
  headers: headerParams,
1058
1119
  uri: localVarPath,
1059
- useQuerystring: this._useQuerystring,
1060
1120
  json: true,
1061
1121
  };
1062
1122
  this.authentications.default.applyToRequest(requestOptions);
@@ -1068,35 +1128,19 @@ class RecordHistoryApi {
1068
1128
  requestOptions.form = formParams;
1069
1129
  }
1070
1130
  }
1071
- return new Promise((resolve, reject) => {
1072
- request(requestOptions, (error, response, body) => {
1073
- if (error) {
1074
- reject(error);
1075
- }
1076
- else {
1077
- if (response.statusCode >= 200 && response.statusCode <= 299) {
1078
- resolve({ response: response, body: body });
1079
- }
1080
- else {
1081
- reject({ response: response, body: body });
1082
- }
1083
- }
1084
- });
1085
- });
1131
+ return fetchWithRequestOptions(requestOptions);
1086
1132
  }
1087
1133
  }
1088
- exports.RecordHistoryApi = RecordHistoryApi;
1089
- var RecordsApiApiKeys;
1134
+ export var RecordsApiApiKeys;
1090
1135
  (function (RecordsApiApiKeys) {
1091
- })(RecordsApiApiKeys = exports.RecordsApiApiKeys || (exports.RecordsApiApiKeys = {}));
1092
- class RecordsApi {
1136
+ })(RecordsApiApiKeys || (RecordsApiApiKeys = {}));
1137
+ export class RecordsApi {
1138
+ basePath = defaultBasePath;
1139
+ defaultHeaders = {};
1140
+ authentications = {
1141
+ 'default': new VoidAuth(),
1142
+ };
1093
1143
  constructor(basePathOrUsername, password, basePath) {
1094
- this.basePath = defaultBasePath;
1095
- this.defaultHeaders = {};
1096
- this._useQuerystring = false;
1097
- this.authentications = {
1098
- 'default': new VoidAuth(),
1099
- };
1100
1144
  if (password) {
1101
1145
  if (basePath) {
1102
1146
  this.basePath = basePath;
@@ -1108,9 +1152,6 @@ class RecordsApi {
1108
1152
  }
1109
1153
  }
1110
1154
  }
1111
- set useQuerystring(value) {
1112
- this._useQuerystring = value;
1113
- }
1114
1155
  setApiKey(key, value) {
1115
1156
  this.authentications[RecordsApiApiKeys[key]].apiKey = value;
1116
1157
  }
@@ -1138,15 +1179,18 @@ class RecordsApi {
1138
1179
  if (xMagdaSession === null || xMagdaSession === undefined) {
1139
1180
  throw new Error('Required parameter xMagdaSession was null or undefined when calling create.');
1140
1181
  }
1141
- headerParams['X-Magda-Tenant-Id'] = xMagdaTenantId;
1142
- headerParams['X-Magda-Session'] = xMagdaSession;
1182
+ if (isNotEmpty(xMagdaTenantId)) {
1183
+ headerParams['X-Magda-Tenant-Id'] = xMagdaTenantId;
1184
+ }
1185
+ if (isNotEmpty(xMagdaSession)) {
1186
+ headerParams['X-Magda-Session'] = xMagdaSession;
1187
+ }
1143
1188
  let useFormData = false;
1144
- let requestOptions = {
1189
+ const requestOptions = {
1145
1190
  method: 'POST',
1146
1191
  qs: queryParameters,
1147
1192
  headers: headerParams,
1148
1193
  uri: localVarPath,
1149
- useQuerystring: this._useQuerystring,
1150
1194
  json: true,
1151
1195
  body: record,
1152
1196
  };
@@ -1159,21 +1203,7 @@ class RecordsApi {
1159
1203
  requestOptions.form = formParams;
1160
1204
  }
1161
1205
  }
1162
- return new Promise((resolve, reject) => {
1163
- request(requestOptions, (error, response, body) => {
1164
- if (error) {
1165
- reject(error);
1166
- }
1167
- else {
1168
- if (response.statusCode >= 200 && response.statusCode <= 299) {
1169
- resolve({ response: response, body: body });
1170
- }
1171
- else {
1172
- reject({ response: response, body: body });
1173
- }
1174
- }
1175
- });
1176
- });
1206
+ return fetchWithRequestOptions(requestOptions);
1177
1207
  }
1178
1208
  /**
1179
1209
  * Delete a record
@@ -1200,15 +1230,18 @@ class RecordsApi {
1200
1230
  if (xMagdaSession === null || xMagdaSession === undefined) {
1201
1231
  throw new Error('Required parameter xMagdaSession was null or undefined when calling deleteById.');
1202
1232
  }
1203
- headerParams['X-Magda-Tenant-Id'] = xMagdaTenantId;
1204
- headerParams['X-Magda-Session'] = xMagdaSession;
1233
+ if (isNotEmpty(xMagdaTenantId)) {
1234
+ headerParams['X-Magda-Tenant-Id'] = xMagdaTenantId;
1235
+ }
1236
+ if (isNotEmpty(xMagdaSession)) {
1237
+ headerParams['X-Magda-Session'] = xMagdaSession;
1238
+ }
1205
1239
  let useFormData = false;
1206
- let requestOptions = {
1240
+ const requestOptions = {
1207
1241
  method: 'DELETE',
1208
1242
  qs: queryParameters,
1209
1243
  headers: headerParams,
1210
1244
  uri: localVarPath,
1211
- useQuerystring: this._useQuerystring,
1212
1245
  json: true,
1213
1246
  };
1214
1247
  this.authentications.default.applyToRequest(requestOptions);
@@ -1220,21 +1253,7 @@ class RecordsApi {
1220
1253
  requestOptions.form = formParams;
1221
1254
  }
1222
1255
  }
1223
- return new Promise((resolve, reject) => {
1224
- request(requestOptions, (error, response, body) => {
1225
- if (error) {
1226
- reject(error);
1227
- }
1228
- else {
1229
- if (response.statusCode >= 200 && response.statusCode <= 299) {
1230
- resolve({ response: response, body: body });
1231
- }
1232
- else {
1233
- reject({ response: response, body: body });
1234
- }
1235
- }
1236
- });
1237
- });
1256
+ return fetchWithRequestOptions(requestOptions);
1238
1257
  }
1239
1258
  /**
1240
1259
  * Remove items from records&#39; aspect data
@@ -1266,15 +1285,18 @@ class RecordsApi {
1266
1285
  if (xMagdaSession === null || xMagdaSession === undefined) {
1267
1286
  throw new Error('Required parameter xMagdaSession was null or undefined when calling deleteRecordsAspectArrayItems.');
1268
1287
  }
1269
- headerParams['X-Magda-Tenant-Id'] = xMagdaTenantId;
1270
- headerParams['X-Magda-Session'] = xMagdaSession;
1288
+ if (isNotEmpty(xMagdaTenantId)) {
1289
+ headerParams['X-Magda-Tenant-Id'] = xMagdaTenantId;
1290
+ }
1291
+ if (isNotEmpty(xMagdaSession)) {
1292
+ headerParams['X-Magda-Session'] = xMagdaSession;
1293
+ }
1271
1294
  let useFormData = false;
1272
- let requestOptions = {
1295
+ const requestOptions = {
1273
1296
  method: 'DELETE',
1274
1297
  qs: queryParameters,
1275
1298
  headers: headerParams,
1276
1299
  uri: localVarPath,
1277
- useQuerystring: this._useQuerystring,
1278
1300
  json: true,
1279
1301
  body: requestData,
1280
1302
  };
@@ -1287,21 +1309,7 @@ class RecordsApi {
1287
1309
  requestOptions.form = formParams;
1288
1310
  }
1289
1311
  }
1290
- return new Promise((resolve, reject) => {
1291
- request(requestOptions, (error, response, body) => {
1292
- if (error) {
1293
- reject(error);
1294
- }
1295
- else {
1296
- if (response.statusCode >= 200 && response.statusCode <= 299) {
1297
- resolve({ response: response, body: body });
1298
- }
1299
- else {
1300
- reject({ response: response, body: body });
1301
- }
1302
- }
1303
- });
1304
- });
1312
+ return fetchWithRequestOptions(requestOptions);
1305
1313
  }
1306
1314
  /**
1307
1315
  * Get a list of all records
@@ -1370,15 +1378,18 @@ class RecordsApi {
1370
1378
  if (q !== undefined) {
1371
1379
  queryParameters['q'] = q;
1372
1380
  }
1373
- headerParams['X-Magda-Tenant-Id'] = xMagdaTenantId;
1374
- headerParams['X-Magda-Session'] = xMagdaSession;
1381
+ if (isNotEmpty(xMagdaTenantId)) {
1382
+ headerParams['X-Magda-Tenant-Id'] = xMagdaTenantId;
1383
+ }
1384
+ if (isNotEmpty(xMagdaSession)) {
1385
+ headerParams['X-Magda-Session'] = xMagdaSession;
1386
+ }
1375
1387
  let useFormData = false;
1376
- let requestOptions = {
1388
+ const requestOptions = {
1377
1389
  method: 'GET',
1378
1390
  qs: queryParameters,
1379
1391
  headers: headerParams,
1380
1392
  uri: localVarPath,
1381
- useQuerystring: this._useQuerystring,
1382
1393
  json: true,
1383
1394
  };
1384
1395
  this.authentications.default.applyToRequest(requestOptions);
@@ -1390,21 +1401,7 @@ class RecordsApi {
1390
1401
  requestOptions.form = formParams;
1391
1402
  }
1392
1403
  }
1393
- return new Promise((resolve, reject) => {
1394
- request(requestOptions, (error, response, body) => {
1395
- if (error) {
1396
- reject(error);
1397
- }
1398
- else {
1399
- if (response.statusCode >= 200 && response.statusCode <= 299) {
1400
- resolve({ response: response, body: body });
1401
- }
1402
- else {
1403
- reject({ response: response, body: body });
1404
- }
1405
- }
1406
- });
1407
- });
1404
+ return fetchWithRequestOptions(requestOptions);
1408
1405
  }
1409
1406
  /**
1410
1407
  * Get a list of all records as summaries
@@ -1441,15 +1438,18 @@ class RecordsApi {
1441
1438
  if (q !== undefined) {
1442
1439
  queryParameters['q'] = q;
1443
1440
  }
1444
- headerParams['X-Magda-Tenant-Id'] = xMagdaTenantId;
1445
- headerParams['X-Magda-Session'] = xMagdaSession;
1441
+ if (isNotEmpty(xMagdaTenantId)) {
1442
+ headerParams['X-Magda-Tenant-Id'] = xMagdaTenantId;
1443
+ }
1444
+ if (isNotEmpty(xMagdaSession)) {
1445
+ headerParams['X-Magda-Session'] = xMagdaSession;
1446
+ }
1446
1447
  let useFormData = false;
1447
- let requestOptions = {
1448
+ const requestOptions = {
1448
1449
  method: 'GET',
1449
1450
  qs: queryParameters,
1450
1451
  headers: headerParams,
1451
1452
  uri: localVarPath,
1452
- useQuerystring: this._useQuerystring,
1453
1453
  json: true,
1454
1454
  };
1455
1455
  this.authentications.default.applyToRequest(requestOptions);
@@ -1461,21 +1461,7 @@ class RecordsApi {
1461
1461
  requestOptions.form = formParams;
1462
1462
  }
1463
1463
  }
1464
- return new Promise((resolve, reject) => {
1465
- request(requestOptions, (error, response, body) => {
1466
- if (error) {
1467
- reject(error);
1468
- }
1469
- else {
1470
- if (response.statusCode >= 200 && response.statusCode <= 299) {
1471
- resolve({ response: response, body: body });
1472
- }
1473
- else {
1474
- reject({ response: response, body: body });
1475
- }
1476
- }
1477
- });
1478
- });
1464
+ return fetchWithRequestOptions(requestOptions);
1479
1465
  }
1480
1466
  /**
1481
1467
  * Get a record by ID
@@ -1510,15 +1496,18 @@ class RecordsApi {
1510
1496
  if (dereference !== undefined) {
1511
1497
  queryParameters['dereference'] = dereference;
1512
1498
  }
1513
- headerParams['X-Magda-Tenant-Id'] = xMagdaTenantId;
1514
- headerParams['X-Magda-Session'] = xMagdaSession;
1499
+ if (isNotEmpty(xMagdaTenantId)) {
1500
+ headerParams['X-Magda-Tenant-Id'] = xMagdaTenantId;
1501
+ }
1502
+ if (isNotEmpty(xMagdaSession)) {
1503
+ headerParams['X-Magda-Session'] = xMagdaSession;
1504
+ }
1515
1505
  let useFormData = false;
1516
- let requestOptions = {
1506
+ const requestOptions = {
1517
1507
  method: 'GET',
1518
1508
  qs: queryParameters,
1519
1509
  headers: headerParams,
1520
1510
  uri: localVarPath,
1521
- useQuerystring: this._useQuerystring,
1522
1511
  json: true,
1523
1512
  };
1524
1513
  this.authentications.default.applyToRequest(requestOptions);
@@ -1530,21 +1519,7 @@ class RecordsApi {
1530
1519
  requestOptions.form = formParams;
1531
1520
  }
1532
1521
  }
1533
- return new Promise((resolve, reject) => {
1534
- request(requestOptions, (error, response, body) => {
1535
- if (error) {
1536
- reject(error);
1537
- }
1538
- else {
1539
- if (response.statusCode >= 200 && response.statusCode <= 299) {
1540
- resolve({ response: response, body: body });
1541
- }
1542
- else {
1543
- reject({ response: response, body: body });
1544
- }
1545
- }
1546
- });
1547
- });
1522
+ return fetchWithRequestOptions(requestOptions);
1548
1523
  }
1549
1524
  /**
1550
1525
  * Get a record in full by ID
@@ -1567,15 +1542,18 @@ class RecordsApi {
1567
1542
  if (xMagdaTenantId === null || xMagdaTenantId === undefined) {
1568
1543
  throw new Error('Required parameter xMagdaTenantId was null or undefined when calling getByIdInFull.');
1569
1544
  }
1570
- headerParams['X-Magda-Tenant-Id'] = xMagdaTenantId;
1571
- headerParams['X-Magda-Session'] = xMagdaSession;
1545
+ if (isNotEmpty(xMagdaTenantId)) {
1546
+ headerParams['X-Magda-Tenant-Id'] = xMagdaTenantId;
1547
+ }
1548
+ if (isNotEmpty(xMagdaSession)) {
1549
+ headerParams['X-Magda-Session'] = xMagdaSession;
1550
+ }
1572
1551
  let useFormData = false;
1573
- let requestOptions = {
1552
+ const requestOptions = {
1574
1553
  method: 'GET',
1575
1554
  qs: queryParameters,
1576
1555
  headers: headerParams,
1577
1556
  uri: localVarPath,
1578
- useQuerystring: this._useQuerystring,
1579
1557
  json: true,
1580
1558
  };
1581
1559
  this.authentications.default.applyToRequest(requestOptions);
@@ -1587,21 +1565,7 @@ class RecordsApi {
1587
1565
  requestOptions.form = formParams;
1588
1566
  }
1589
1567
  }
1590
- return new Promise((resolve, reject) => {
1591
- request(requestOptions, (error, response, body) => {
1592
- if (error) {
1593
- reject(error);
1594
- }
1595
- else {
1596
- if (response.statusCode >= 200 && response.statusCode <= 299) {
1597
- resolve({ response: response, body: body });
1598
- }
1599
- else {
1600
- reject({ response: response, body: body });
1601
- }
1602
- }
1603
- });
1604
- });
1568
+ return fetchWithRequestOptions(requestOptions);
1605
1569
  }
1606
1570
  /**
1607
1571
  * Get a summary record by ID
@@ -1624,15 +1588,18 @@ class RecordsApi {
1624
1588
  if (xMagdaTenantId === null || xMagdaTenantId === undefined) {
1625
1589
  throw new Error('Required parameter xMagdaTenantId was null or undefined when calling getByIdSummary.');
1626
1590
  }
1627
- headerParams['X-Magda-Tenant-Id'] = xMagdaTenantId;
1628
- headerParams['X-Magda-Session'] = xMagdaSession;
1591
+ if (isNotEmpty(xMagdaTenantId)) {
1592
+ headerParams['X-Magda-Tenant-Id'] = xMagdaTenantId;
1593
+ }
1594
+ if (isNotEmpty(xMagdaSession)) {
1595
+ headerParams['X-Magda-Session'] = xMagdaSession;
1596
+ }
1629
1597
  let useFormData = false;
1630
- let requestOptions = {
1598
+ const requestOptions = {
1631
1599
  method: 'GET',
1632
1600
  qs: queryParameters,
1633
1601
  headers: headerParams,
1634
1602
  uri: localVarPath,
1635
- useQuerystring: this._useQuerystring,
1636
1603
  json: true,
1637
1604
  };
1638
1605
  this.authentications.default.applyToRequest(requestOptions);
@@ -1644,21 +1611,7 @@ class RecordsApi {
1644
1611
  requestOptions.form = formParams;
1645
1612
  }
1646
1613
  }
1647
- return new Promise((resolve, reject) => {
1648
- request(requestOptions, (error, response, body) => {
1649
- if (error) {
1650
- reject(error);
1651
- }
1652
- else {
1653
- if (response.statusCode >= 200 && response.statusCode <= 299) {
1654
- resolve({ response: response, body: body });
1655
- }
1656
- else {
1657
- reject({ response: response, body: body });
1658
- }
1659
- }
1660
- });
1661
- });
1614
+ return fetchWithRequestOptions(requestOptions);
1662
1615
  }
1663
1616
  /**
1664
1617
  * Get the count of records matching the parameters. If no parameters are specified, the count will be approximate for performance reasons.
@@ -1691,15 +1644,18 @@ class RecordsApi {
1691
1644
  if (q !== undefined) {
1692
1645
  queryParameters['q'] = q;
1693
1646
  }
1694
- headerParams['X-Magda-Tenant-Id'] = xMagdaTenantId;
1695
- headerParams['X-Magda-Session'] = xMagdaSession;
1647
+ if (isNotEmpty(xMagdaTenantId)) {
1648
+ headerParams['X-Magda-Tenant-Id'] = xMagdaTenantId;
1649
+ }
1650
+ if (isNotEmpty(xMagdaSession)) {
1651
+ headerParams['X-Magda-Session'] = xMagdaSession;
1652
+ }
1696
1653
  let useFormData = false;
1697
- let requestOptions = {
1654
+ const requestOptions = {
1698
1655
  method: 'GET',
1699
1656
  qs: queryParameters,
1700
1657
  headers: headerParams,
1701
1658
  uri: localVarPath,
1702
- useQuerystring: this._useQuerystring,
1703
1659
  json: true,
1704
1660
  };
1705
1661
  this.authentications.default.applyToRequest(requestOptions);
@@ -1711,21 +1667,7 @@ class RecordsApi {
1711
1667
  requestOptions.form = formParams;
1712
1668
  }
1713
1669
  }
1714
- return new Promise((resolve, reject) => {
1715
- request(requestOptions, (error, response, body) => {
1716
- if (error) {
1717
- reject(error);
1718
- }
1719
- else {
1720
- if (response.statusCode >= 200 && response.statusCode <= 299) {
1721
- resolve({ response: response, body: body });
1722
- }
1723
- else {
1724
- reject({ response: response, body: body });
1725
- }
1726
- }
1727
- });
1728
- });
1670
+ return fetchWithRequestOptions(requestOptions);
1729
1671
  }
1730
1672
  /**
1731
1673
  * Get a list tokens for paging through the records
@@ -1750,15 +1692,18 @@ class RecordsApi {
1750
1692
  if (limit !== undefined) {
1751
1693
  queryParameters['limit'] = limit;
1752
1694
  }
1753
- headerParams['X-Magda-Tenant-Id'] = xMagdaTenantId;
1754
- headerParams['X-Magda-Session'] = xMagdaSession;
1695
+ if (isNotEmpty(xMagdaTenantId)) {
1696
+ headerParams['X-Magda-Tenant-Id'] = xMagdaTenantId;
1697
+ }
1698
+ if (isNotEmpty(xMagdaSession)) {
1699
+ headerParams['X-Magda-Session'] = xMagdaSession;
1700
+ }
1755
1701
  let useFormData = false;
1756
- let requestOptions = {
1702
+ const requestOptions = {
1757
1703
  method: 'GET',
1758
1704
  qs: queryParameters,
1759
1705
  headers: headerParams,
1760
1706
  uri: localVarPath,
1761
- useQuerystring: this._useQuerystring,
1762
1707
  json: true,
1763
1708
  };
1764
1709
  this.authentications.default.applyToRequest(requestOptions);
@@ -1770,21 +1715,7 @@ class RecordsApi {
1770
1715
  requestOptions.form = formParams;
1771
1716
  }
1772
1717
  }
1773
- return new Promise((resolve, reject) => {
1774
- request(requestOptions, (error, response, body) => {
1775
- if (error) {
1776
- reject(error);
1777
- }
1778
- else {
1779
- if (response.statusCode >= 200 && response.statusCode <= 299) {
1780
- resolve({ response: response, body: body });
1781
- }
1782
- else {
1783
- reject({ response: response, body: body });
1784
- }
1785
- }
1786
- });
1787
- });
1718
+ return fetchWithRequestOptions(requestOptions);
1788
1719
  }
1789
1720
  /**
1790
1721
  * Modify a record by applying a JSON Patch
@@ -1816,15 +1747,18 @@ class RecordsApi {
1816
1747
  if (xMagdaSession === null || xMagdaSession === undefined) {
1817
1748
  throw new Error('Required parameter xMagdaSession was null or undefined when calling patchById.');
1818
1749
  }
1819
- headerParams['X-Magda-Tenant-Id'] = xMagdaTenantId;
1820
- headerParams['X-Magda-Session'] = xMagdaSession;
1750
+ if (isNotEmpty(xMagdaTenantId)) {
1751
+ headerParams['X-Magda-Tenant-Id'] = xMagdaTenantId;
1752
+ }
1753
+ if (isNotEmpty(xMagdaSession)) {
1754
+ headerParams['X-Magda-Session'] = xMagdaSession;
1755
+ }
1821
1756
  let useFormData = false;
1822
- let requestOptions = {
1757
+ const requestOptions = {
1823
1758
  method: 'PATCH',
1824
1759
  qs: queryParameters,
1825
1760
  headers: headerParams,
1826
1761
  uri: localVarPath,
1827
- useQuerystring: this._useQuerystring,
1828
1762
  json: true,
1829
1763
  body: recordPatch,
1830
1764
  };
@@ -1837,21 +1771,7 @@ class RecordsApi {
1837
1771
  requestOptions.form = formParams;
1838
1772
  }
1839
1773
  }
1840
- return new Promise((resolve, reject) => {
1841
- request(requestOptions, (error, response, body) => {
1842
- if (error) {
1843
- reject(error);
1844
- }
1845
- else {
1846
- if (response.statusCode >= 200 && response.statusCode <= 299) {
1847
- resolve({ response: response, body: body });
1848
- }
1849
- else {
1850
- reject({ response: response, body: body });
1851
- }
1852
- }
1853
- });
1854
- });
1774
+ return fetchWithRequestOptions(requestOptions);
1855
1775
  }
1856
1776
  /**
1857
1777
  * Modify a list of records by applying the same JSON Patch
@@ -1877,15 +1797,18 @@ class RecordsApi {
1877
1797
  if (xMagdaSession === null || xMagdaSession === undefined) {
1878
1798
  throw new Error('Required parameter xMagdaSession was null or undefined when calling patchRecords.');
1879
1799
  }
1880
- headerParams['X-Magda-Tenant-Id'] = xMagdaTenantId;
1881
- headerParams['X-Magda-Session'] = xMagdaSession;
1800
+ if (isNotEmpty(xMagdaTenantId)) {
1801
+ headerParams['X-Magda-Tenant-Id'] = xMagdaTenantId;
1802
+ }
1803
+ if (isNotEmpty(xMagdaSession)) {
1804
+ headerParams['X-Magda-Session'] = xMagdaSession;
1805
+ }
1882
1806
  let useFormData = false;
1883
- let requestOptions = {
1807
+ const requestOptions = {
1884
1808
  method: 'PATCH',
1885
1809
  qs: queryParameters,
1886
1810
  headers: headerParams,
1887
1811
  uri: localVarPath,
1888
- useQuerystring: this._useQuerystring,
1889
1812
  json: true,
1890
1813
  body: requestData,
1891
1814
  };
@@ -1898,21 +1821,7 @@ class RecordsApi {
1898
1821
  requestOptions.form = formParams;
1899
1822
  }
1900
1823
  }
1901
- return new Promise((resolve, reject) => {
1902
- request(requestOptions, (error, response, body) => {
1903
- if (error) {
1904
- reject(error);
1905
- }
1906
- else {
1907
- if (response.statusCode >= 200 && response.statusCode <= 299) {
1908
- resolve({ response: response, body: body });
1909
- }
1910
- else {
1911
- reject({ response: response, body: body });
1912
- }
1913
- }
1914
- });
1915
- });
1824
+ return fetchWithRequestOptions(requestOptions);
1916
1825
  }
1917
1826
  /**
1918
1827
  * Modify a record by ID
@@ -1948,15 +1857,18 @@ class RecordsApi {
1948
1857
  if (merge !== undefined) {
1949
1858
  queryParameters['merge'] = merge;
1950
1859
  }
1951
- headerParams['X-Magda-Tenant-Id'] = xMagdaTenantId;
1952
- headerParams['X-Magda-Session'] = xMagdaSession;
1860
+ if (isNotEmpty(xMagdaTenantId)) {
1861
+ headerParams['X-Magda-Tenant-Id'] = xMagdaTenantId;
1862
+ }
1863
+ if (isNotEmpty(xMagdaSession)) {
1864
+ headerParams['X-Magda-Session'] = xMagdaSession;
1865
+ }
1953
1866
  let useFormData = false;
1954
- let requestOptions = {
1867
+ const requestOptions = {
1955
1868
  method: 'PUT',
1956
1869
  qs: queryParameters,
1957
1870
  headers: headerParams,
1958
1871
  uri: localVarPath,
1959
- useQuerystring: this._useQuerystring,
1960
1872
  json: true,
1961
1873
  body: record,
1962
1874
  };
@@ -1969,21 +1881,7 @@ class RecordsApi {
1969
1881
  requestOptions.form = formParams;
1970
1882
  }
1971
1883
  }
1972
- return new Promise((resolve, reject) => {
1973
- request(requestOptions, (error, response, body) => {
1974
- if (error) {
1975
- reject(error);
1976
- }
1977
- else {
1978
- if (response.statusCode >= 200 && response.statusCode <= 299) {
1979
- resolve({ response: response, body: body });
1980
- }
1981
- else {
1982
- reject({ response: response, body: body });
1983
- }
1984
- }
1985
- });
1986
- });
1884
+ return fetchWithRequestOptions(requestOptions);
1987
1885
  }
1988
1886
  /**
1989
1887
  * Modify a list of records&#39;s aspect with same new data
@@ -2019,15 +1917,18 @@ class RecordsApi {
2019
1917
  if (merge !== undefined) {
2020
1918
  queryParameters['merge'] = merge;
2021
1919
  }
2022
- headerParams['X-Magda-Tenant-Id'] = xMagdaTenantId;
2023
- headerParams['X-Magda-Session'] = xMagdaSession;
1920
+ if (isNotEmpty(xMagdaTenantId)) {
1921
+ headerParams['X-Magda-Tenant-Id'] = xMagdaTenantId;
1922
+ }
1923
+ if (isNotEmpty(xMagdaSession)) {
1924
+ headerParams['X-Magda-Session'] = xMagdaSession;
1925
+ }
2024
1926
  let useFormData = false;
2025
- let requestOptions = {
1927
+ const requestOptions = {
2026
1928
  method: 'PUT',
2027
1929
  qs: queryParameters,
2028
1930
  headers: headerParams,
2029
1931
  uri: localVarPath,
2030
- useQuerystring: this._useQuerystring,
2031
1932
  json: true,
2032
1933
  body: requestData,
2033
1934
  };
@@ -2040,21 +1941,7 @@ class RecordsApi {
2040
1941
  requestOptions.form = formParams;
2041
1942
  }
2042
1943
  }
2043
- return new Promise((resolve, reject) => {
2044
- request(requestOptions, (error, response, body) => {
2045
- if (error) {
2046
- reject(error);
2047
- }
2048
- else {
2049
- if (response.statusCode >= 200 && response.statusCode <= 299) {
2050
- resolve({ response: response, body: body });
2051
- }
2052
- else {
2053
- reject({ response: response, body: body });
2054
- }
2055
- }
2056
- });
2057
- });
1944
+ return fetchWithRequestOptions(requestOptions);
2058
1945
  }
2059
1946
  /**
2060
1947
  * Trim by source tag
@@ -2091,15 +1978,18 @@ class RecordsApi {
2091
1978
  if (sourceId !== undefined) {
2092
1979
  queryParameters['sourceId'] = sourceId;
2093
1980
  }
2094
- headerParams['X-Magda-Tenant-Id'] = xMagdaTenantId;
2095
- headerParams['X-Magda-Session'] = xMagdaSession;
1981
+ if (isNotEmpty(xMagdaTenantId)) {
1982
+ headerParams['X-Magda-Tenant-Id'] = xMagdaTenantId;
1983
+ }
1984
+ if (isNotEmpty(xMagdaSession)) {
1985
+ headerParams['X-Magda-Session'] = xMagdaSession;
1986
+ }
2096
1987
  let useFormData = false;
2097
- let requestOptions = {
1988
+ const requestOptions = {
2098
1989
  method: 'DELETE',
2099
1990
  qs: queryParameters,
2100
1991
  headers: headerParams,
2101
1992
  uri: localVarPath,
2102
- useQuerystring: this._useQuerystring,
2103
1993
  json: true,
2104
1994
  };
2105
1995
  this.authentications.default.applyToRequest(requestOptions);
@@ -2111,35 +2001,19 @@ class RecordsApi {
2111
2001
  requestOptions.form = formParams;
2112
2002
  }
2113
2003
  }
2114
- return new Promise((resolve, reject) => {
2115
- request(requestOptions, (error, response, body) => {
2116
- if (error) {
2117
- reject(error);
2118
- }
2119
- else {
2120
- if (response.statusCode >= 200 && response.statusCode <= 299) {
2121
- resolve({ response: response, body: body });
2122
- }
2123
- else {
2124
- reject({ response: response, body: body });
2125
- }
2126
- }
2127
- });
2128
- });
2004
+ return fetchWithRequestOptions(requestOptions);
2129
2005
  }
2130
2006
  }
2131
- exports.RecordsApi = RecordsApi;
2132
- var WebHooksApiApiKeys;
2007
+ export var WebHooksApiApiKeys;
2133
2008
  (function (WebHooksApiApiKeys) {
2134
- })(WebHooksApiApiKeys = exports.WebHooksApiApiKeys || (exports.WebHooksApiApiKeys = {}));
2135
- class WebHooksApi {
2009
+ })(WebHooksApiApiKeys || (WebHooksApiApiKeys = {}));
2010
+ export class WebHooksApi {
2011
+ basePath = defaultBasePath;
2012
+ defaultHeaders = {};
2013
+ authentications = {
2014
+ 'default': new VoidAuth(),
2015
+ };
2136
2016
  constructor(basePathOrUsername, password, basePath) {
2137
- this.basePath = defaultBasePath;
2138
- this.defaultHeaders = {};
2139
- this._useQuerystring = false;
2140
- this.authentications = {
2141
- 'default': new VoidAuth(),
2142
- };
2143
2017
  if (password) {
2144
2018
  if (basePath) {
2145
2019
  this.basePath = basePath;
@@ -2151,9 +2025,6 @@ class WebHooksApi {
2151
2025
  }
2152
2026
  }
2153
2027
  }
2154
- set useQuerystring(value) {
2155
- this._useQuerystring = value;
2156
- }
2157
2028
  setApiKey(key, value) {
2158
2029
  this.authentications[WebHooksApiApiKeys[key]].apiKey = value;
2159
2030
  }
@@ -2182,14 +2053,15 @@ class WebHooksApi {
2182
2053
  if (xMagdaSession === null || xMagdaSession === undefined) {
2183
2054
  throw new Error('Required parameter xMagdaSession was null or undefined when calling ack.');
2184
2055
  }
2185
- headerParams['X-Magda-Session'] = xMagdaSession;
2056
+ if (isNotEmpty(xMagdaSession)) {
2057
+ headerParams['X-Magda-Session'] = xMagdaSession;
2058
+ }
2186
2059
  let useFormData = false;
2187
- let requestOptions = {
2060
+ const requestOptions = {
2188
2061
  method: 'POST',
2189
2062
  qs: queryParameters,
2190
2063
  headers: headerParams,
2191
2064
  uri: localVarPath,
2192
- useQuerystring: this._useQuerystring,
2193
2065
  json: true,
2194
2066
  body: acknowledgement,
2195
2067
  };
@@ -2202,21 +2074,7 @@ class WebHooksApi {
2202
2074
  requestOptions.form = formParams;
2203
2075
  }
2204
2076
  }
2205
- return new Promise((resolve, reject) => {
2206
- request(requestOptions, (error, response, body) => {
2207
- if (error) {
2208
- reject(error);
2209
- }
2210
- else {
2211
- if (response.statusCode >= 200 && response.statusCode <= 299) {
2212
- resolve({ response: response, body: body });
2213
- }
2214
- else {
2215
- reject({ response: response, body: body });
2216
- }
2217
- }
2218
- });
2219
- });
2077
+ return fetchWithRequestOptions(requestOptions);
2220
2078
  }
2221
2079
  /**
2222
2080
  * Create a new web hook
@@ -2237,14 +2095,15 @@ class WebHooksApi {
2237
2095
  if (xMagdaSession === null || xMagdaSession === undefined) {
2238
2096
  throw new Error('Required parameter xMagdaSession was null or undefined when calling create.');
2239
2097
  }
2240
- headerParams['X-Magda-Session'] = xMagdaSession;
2098
+ if (isNotEmpty(xMagdaSession)) {
2099
+ headerParams['X-Magda-Session'] = xMagdaSession;
2100
+ }
2241
2101
  let useFormData = false;
2242
- let requestOptions = {
2102
+ const requestOptions = {
2243
2103
  method: 'POST',
2244
2104
  qs: queryParameters,
2245
2105
  headers: headerParams,
2246
2106
  uri: localVarPath,
2247
- useQuerystring: this._useQuerystring,
2248
2107
  json: true,
2249
2108
  body: hook,
2250
2109
  };
@@ -2257,21 +2116,7 @@ class WebHooksApi {
2257
2116
  requestOptions.form = formParams;
2258
2117
  }
2259
2118
  }
2260
- return new Promise((resolve, reject) => {
2261
- request(requestOptions, (error, response, body) => {
2262
- if (error) {
2263
- reject(error);
2264
- }
2265
- else {
2266
- if (response.statusCode >= 200 && response.statusCode <= 299) {
2267
- resolve({ response: response, body: body });
2268
- }
2269
- else {
2270
- reject({ response: response, body: body });
2271
- }
2272
- }
2273
- });
2274
- });
2119
+ return fetchWithRequestOptions(requestOptions);
2275
2120
  }
2276
2121
  /**
2277
2122
  * Delete a web hook
@@ -2293,14 +2138,15 @@ class WebHooksApi {
2293
2138
  if (xMagdaSession === null || xMagdaSession === undefined) {
2294
2139
  throw new Error('Required parameter xMagdaSession was null or undefined when calling deleteById.');
2295
2140
  }
2296
- headerParams['X-Magda-Session'] = xMagdaSession;
2141
+ if (isNotEmpty(xMagdaSession)) {
2142
+ headerParams['X-Magda-Session'] = xMagdaSession;
2143
+ }
2297
2144
  let useFormData = false;
2298
- let requestOptions = {
2145
+ const requestOptions = {
2299
2146
  method: 'DELETE',
2300
2147
  qs: queryParameters,
2301
2148
  headers: headerParams,
2302
2149
  uri: localVarPath,
2303
- useQuerystring: this._useQuerystring,
2304
2150
  json: true,
2305
2151
  };
2306
2152
  this.authentications.default.applyToRequest(requestOptions);
@@ -2312,21 +2158,7 @@ class WebHooksApi {
2312
2158
  requestOptions.form = formParams;
2313
2159
  }
2314
2160
  }
2315
- return new Promise((resolve, reject) => {
2316
- request(requestOptions, (error, response, body) => {
2317
- if (error) {
2318
- reject(error);
2319
- }
2320
- else {
2321
- if (response.statusCode >= 200 && response.statusCode <= 299) {
2322
- resolve({ response: response, body: body });
2323
- }
2324
- else {
2325
- reject({ response: response, body: body });
2326
- }
2327
- }
2328
- });
2329
- });
2161
+ return fetchWithRequestOptions(requestOptions);
2330
2162
  }
2331
2163
  /**
2332
2164
  * Get a list of all web hooks
@@ -2342,14 +2174,15 @@ class WebHooksApi {
2342
2174
  if (xMagdaSession === null || xMagdaSession === undefined) {
2343
2175
  throw new Error('Required parameter xMagdaSession was null or undefined when calling getAll.');
2344
2176
  }
2345
- headerParams['X-Magda-Session'] = xMagdaSession;
2177
+ if (isNotEmpty(xMagdaSession)) {
2178
+ headerParams['X-Magda-Session'] = xMagdaSession;
2179
+ }
2346
2180
  let useFormData = false;
2347
- let requestOptions = {
2181
+ const requestOptions = {
2348
2182
  method: 'GET',
2349
2183
  qs: queryParameters,
2350
2184
  headers: headerParams,
2351
2185
  uri: localVarPath,
2352
- useQuerystring: this._useQuerystring,
2353
2186
  json: true,
2354
2187
  };
2355
2188
  this.authentications.default.applyToRequest(requestOptions);
@@ -2361,21 +2194,7 @@ class WebHooksApi {
2361
2194
  requestOptions.form = formParams;
2362
2195
  }
2363
2196
  }
2364
- return new Promise((resolve, reject) => {
2365
- request(requestOptions, (error, response, body) => {
2366
- if (error) {
2367
- reject(error);
2368
- }
2369
- else {
2370
- if (response.statusCode >= 200 && response.statusCode <= 299) {
2371
- resolve({ response: response, body: body });
2372
- }
2373
- else {
2374
- reject({ response: response, body: body });
2375
- }
2376
- }
2377
- });
2378
- });
2197
+ return fetchWithRequestOptions(requestOptions);
2379
2198
  }
2380
2199
  /**
2381
2200
  * Get a web hook by ID
@@ -2397,14 +2216,15 @@ class WebHooksApi {
2397
2216
  if (xMagdaSession === null || xMagdaSession === undefined) {
2398
2217
  throw new Error('Required parameter xMagdaSession was null or undefined when calling getById.');
2399
2218
  }
2400
- headerParams['X-Magda-Session'] = xMagdaSession;
2219
+ if (isNotEmpty(xMagdaSession)) {
2220
+ headerParams['X-Magda-Session'] = xMagdaSession;
2221
+ }
2401
2222
  let useFormData = false;
2402
- let requestOptions = {
2223
+ const requestOptions = {
2403
2224
  method: 'GET',
2404
2225
  qs: queryParameters,
2405
2226
  headers: headerParams,
2406
2227
  uri: localVarPath,
2407
- useQuerystring: this._useQuerystring,
2408
2228
  json: true,
2409
2229
  };
2410
2230
  this.authentications.default.applyToRequest(requestOptions);
@@ -2416,21 +2236,7 @@ class WebHooksApi {
2416
2236
  requestOptions.form = formParams;
2417
2237
  }
2418
2238
  }
2419
- return new Promise((resolve, reject) => {
2420
- request(requestOptions, (error, response, body) => {
2421
- if (error) {
2422
- reject(error);
2423
- }
2424
- else {
2425
- if (response.statusCode >= 200 && response.statusCode <= 299) {
2426
- resolve({ response: response, body: body });
2427
- }
2428
- else {
2429
- reject({ response: response, body: body });
2430
- }
2431
- }
2432
- });
2433
- });
2239
+ return fetchWithRequestOptions(requestOptions);
2434
2240
  }
2435
2241
  /**
2436
2242
  * Modify a web hook by ID
@@ -2457,14 +2263,15 @@ class WebHooksApi {
2457
2263
  if (xMagdaSession === null || xMagdaSession === undefined) {
2458
2264
  throw new Error('Required parameter xMagdaSession was null or undefined when calling putById.');
2459
2265
  }
2460
- headerParams['X-Magda-Session'] = xMagdaSession;
2266
+ if (isNotEmpty(xMagdaSession)) {
2267
+ headerParams['X-Magda-Session'] = xMagdaSession;
2268
+ }
2461
2269
  let useFormData = false;
2462
- let requestOptions = {
2270
+ const requestOptions = {
2463
2271
  method: 'PUT',
2464
2272
  qs: queryParameters,
2465
2273
  headers: headerParams,
2466
2274
  uri: localVarPath,
2467
- useQuerystring: this._useQuerystring,
2468
2275
  json: true,
2469
2276
  body: hook,
2470
2277
  };
@@ -2477,22 +2284,7 @@ class WebHooksApi {
2477
2284
  requestOptions.form = formParams;
2478
2285
  }
2479
2286
  }
2480
- return new Promise((resolve, reject) => {
2481
- request(requestOptions, (error, response, body) => {
2482
- if (error) {
2483
- reject(error);
2484
- }
2485
- else {
2486
- if (response.statusCode >= 200 && response.statusCode <= 299) {
2487
- resolve({ response: response, body: body });
2488
- }
2489
- else {
2490
- reject({ response: response, body: body });
2491
- }
2492
- }
2493
- });
2494
- });
2287
+ return fetchWithRequestOptions(requestOptions);
2495
2288
  }
2496
2289
  }
2497
- exports.WebHooksApi = WebHooksApi;
2498
2290
  //# sourceMappingURL=api.js.map