@equisoft/account-service-sdk-typescript 3.7.4-snapshot.20220615190058 → 3.8.1-snapshot.20220629125736

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 (224) hide show
  1. package/.openapi-generator/FILES +1 -0
  2. package/.openapi-generator/VERSION +1 -1
  3. package/README.md +2 -2
  4. package/dist/apis/OAuthApi.d.ts +5 -5
  5. package/dist/apis/OAuthApi.js +1 -1
  6. package/dist/apis/OrganizationApi.d.ts +37 -37
  7. package/dist/apis/OrganizationApi.js +1 -1
  8. package/dist/apis/PermissionApi.d.ts +3 -3
  9. package/dist/apis/PermissionApi.js +1 -1
  10. package/dist/apis/RoleApi.d.ts +3 -3
  11. package/dist/apis/RoleApi.js +1 -1
  12. package/dist/apis/ServiceAccountApi.d.ts +17 -17
  13. package/dist/apis/ServiceAccountApi.js +2 -2
  14. package/dist/apis/SessionApi.d.ts +25 -25
  15. package/dist/apis/SessionApi.js +1 -1
  16. package/dist/apis/UserApi.d.ts +33 -33
  17. package/dist/apis/UserApi.js +2 -2
  18. package/dist/models/ApplyPermissionsPayload.d.ts +2 -2
  19. package/dist/models/ApplyPermissionsPayload.js +4 -4
  20. package/dist/models/CreateOrUpdateOAuthClientPayload.d.ts +4 -4
  21. package/dist/models/CreateOrUpdateOAuthClientPayload.js +4 -4
  22. package/dist/models/CreateOrUpdateOrganizationPayload.d.ts +2 -2
  23. package/dist/models/CreateOrUpdateOrganizationPayload.js +4 -4
  24. package/dist/models/CreateOrUpdatePermissionPayload.d.ts +2 -2
  25. package/dist/models/CreateOrUpdatePermissionPayload.js +4 -4
  26. package/dist/models/CreateOrganizationPayload.d.ts +2 -2
  27. package/dist/models/CreateOrganizationPayload.js +4 -4
  28. package/dist/models/CreateOrganizationUserServiceOptionPayload.d.ts +1 -1
  29. package/dist/models/CreateOrganizationUserServiceOptionPayload.js +1 -1
  30. package/dist/models/CreateOrganizationUserServicePayload.d.ts +1 -1
  31. package/dist/models/CreateOrganizationUserServicePayload.js +1 -1
  32. package/dist/models/CreateRole.d.ts +2 -2
  33. package/dist/models/CreateRole.js +4 -4
  34. package/dist/models/DatabaseState.d.ts +8 -8
  35. package/dist/models/DatabaseState.js +7 -9
  36. package/dist/models/EnableEquisoftConnectPayloadSchema.d.ts +1 -1
  37. package/dist/models/EnableEquisoftConnectPayloadSchema.js +1 -1
  38. package/dist/models/ErrorMessage.d.ts +17 -17
  39. package/dist/models/ErrorMessage.js +16 -18
  40. package/dist/models/ErrorPayload.d.ts +2 -2
  41. package/dist/models/ErrorPayload.js +4 -4
  42. package/dist/models/Id.d.ts +1 -1
  43. package/dist/models/Id.js +1 -1
  44. package/dist/models/ImpersonatePayload.d.ts +1 -1
  45. package/dist/models/ImpersonatePayload.js +1 -1
  46. package/dist/models/LegacyRoleSchema.d.ts +2 -2
  47. package/dist/models/LegacyRoleSchema.js +4 -4
  48. package/dist/models/ListOrganizationElement.d.ts +4 -2
  49. package/dist/models/ListOrganizationElement.js +10 -8
  50. package/dist/models/ListUserOrganizations.d.ts +2 -2
  51. package/dist/models/ListUserOrganizations.js +4 -4
  52. package/dist/models/LocalizedString.d.ts +1 -1
  53. package/dist/models/LocalizedString.js +1 -1
  54. package/dist/models/OAuthClient.d.ts +4 -4
  55. package/dist/models/OAuthClient.js +4 -4
  56. package/dist/models/OAuthClientCreated.d.ts +1 -1
  57. package/dist/models/OAuthClientCreated.js +1 -1
  58. package/dist/models/OAuthClientPublicKey.d.ts +1 -1
  59. package/dist/models/OAuthClientPublicKey.js +1 -1
  60. package/dist/models/Organization.d.ts +4 -2
  61. package/dist/models/Organization.js +10 -8
  62. package/dist/models/OrganizationCreated.d.ts +1 -1
  63. package/dist/models/OrganizationCreated.js +1 -1
  64. package/dist/models/OrganizationPathElement.d.ts +2 -2
  65. package/dist/models/OrganizationPathElement.js +4 -4
  66. package/dist/models/OrganizationRoleAttribution.d.ts +3 -2
  67. package/dist/models/OrganizationRoleAttribution.js +7 -6
  68. package/dist/models/OrganizationRoleAttributionPermission.d.ts +2 -2
  69. package/dist/models/OrganizationRoleAttributionPermission.js +4 -4
  70. package/dist/models/OrganizationRoleAttributionRole.d.ts +3 -2
  71. package/dist/models/OrganizationRoleAttributionRole.js +7 -6
  72. package/dist/models/OrganizationRoleAttributions.d.ts +2 -2
  73. package/dist/models/OrganizationRoleAttributions.js +4 -4
  74. package/dist/models/OrganizationServicesElement.d.ts +1 -1
  75. package/dist/models/OrganizationServicesElement.js +1 -1
  76. package/dist/models/OrganizationUserServiceAssociation.d.ts +1 -1
  77. package/dist/models/OrganizationUserServiceAssociation.js +1 -1
  78. package/dist/models/PermissionCode.d.ts +1 -1
  79. package/dist/models/PermissionCode.js +1 -1
  80. package/dist/models/PermissionCreated.d.ts +1 -1
  81. package/dist/models/PermissionCreated.js +1 -1
  82. package/dist/models/PermissionList.d.ts +2 -2
  83. package/dist/models/PermissionList.js +4 -4
  84. package/dist/models/PermissionResourceType.d.ts +6 -6
  85. package/dist/models/PermissionResourceType.js +5 -7
  86. package/dist/models/Role.d.ts +2 -2
  87. package/dist/models/Role.js +4 -4
  88. package/dist/models/RoleCreated.d.ts +2 -2
  89. package/dist/models/RoleCreated.js +4 -4
  90. package/dist/models/RolesOnOrganization.d.ts +5 -2
  91. package/dist/models/RolesOnOrganization.js +13 -10
  92. package/dist/models/ServiceAccess.d.ts +3 -2
  93. package/dist/models/ServiceAccess.js +7 -6
  94. package/dist/models/ServiceAccountCreationSchema.d.ts +1 -1
  95. package/dist/models/ServiceAccountCreationSchema.js +1 -1
  96. package/dist/models/ServiceAccountSchema.d.ts +2 -2
  97. package/dist/models/ServiceAccountSchema.js +4 -4
  98. package/dist/models/ServiceAccountStatus.d.ts +7 -7
  99. package/dist/models/ServiceAccountStatus.js +6 -8
  100. package/dist/models/ServiceAccountUpdateSchema.d.ts +1 -1
  101. package/dist/models/ServiceAccountUpdateSchema.js +1 -1
  102. package/dist/models/ServiceAccountUuidSchema.d.ts +1 -1
  103. package/dist/models/ServiceAccountUuidSchema.js +1 -1
  104. package/dist/models/ServiceName.d.ts +9 -9
  105. package/dist/models/ServiceName.js +8 -10
  106. package/dist/models/Session.d.ts +4 -2
  107. package/dist/models/Session.js +12 -10
  108. package/dist/models/SessionPayload.d.ts +2 -2
  109. package/dist/models/SessionPayload.js +4 -4
  110. package/dist/models/SessionState.d.ts +9 -9
  111. package/dist/models/SessionState.js +8 -10
  112. package/dist/models/SsoProvider.d.ts +1 -1
  113. package/dist/models/SsoProvider.js +1 -1
  114. package/dist/models/SsoToken.d.ts +1 -1
  115. package/dist/models/SsoToken.js +1 -1
  116. package/dist/models/UpdateParentOrganizationPayload.d.ts +1 -1
  117. package/dist/models/UpdateParentOrganizationPayload.js +1 -1
  118. package/dist/models/UpdateUserAccountPayload.d.ts +1 -1
  119. package/dist/models/UpdateUserAccountPayload.js +1 -1
  120. package/dist/models/UpdateUserAccountSsoPayload.d.ts +1 -1
  121. package/dist/models/UpdateUserAccountSsoPayload.js +1 -1
  122. package/dist/models/UpsertServicePayload.d.ts +1 -1
  123. package/dist/models/UpsertServicePayload.js +1 -1
  124. package/dist/models/User.d.ts +6 -2
  125. package/dist/models/User.js +18 -14
  126. package/dist/models/UserAccountOrganizationRoles.d.ts +3 -2
  127. package/dist/models/UserAccountOrganizationRoles.js +7 -6
  128. package/dist/models/UserAccountPermission.d.ts +2 -2
  129. package/dist/models/UserAccountPermission.js +4 -4
  130. package/dist/models/UserAccountRole.d.ts +2 -2
  131. package/dist/models/UserAccountRole.js +4 -4
  132. package/dist/models/UserAccountRoleAttributions.d.ts +2 -2
  133. package/dist/models/UserAccountRoleAttributions.js +4 -4
  134. package/dist/models/UserAccountSearchResult.d.ts +6 -2
  135. package/dist/models/UserAccountSearchResult.js +18 -14
  136. package/dist/models/UserAgreement.d.ts +2 -2
  137. package/dist/models/UserAgreement.js +4 -4
  138. package/dist/models/UserAgreementState.d.ts +6 -6
  139. package/dist/models/UserAgreementState.js +5 -7
  140. package/dist/models/UserPermissions.d.ts +3 -2
  141. package/dist/models/UserPermissions.js +7 -6
  142. package/dist/models/UserServiceAssociation.d.ts +1 -1
  143. package/dist/models/UserServiceAssociation.js +1 -1
  144. package/dist/models/UserSsoProvider.d.ts +1 -1
  145. package/dist/models/UserSsoProvider.js +1 -1
  146. package/dist/models/UserState.d.ts +7 -7
  147. package/dist/models/UserState.js +6 -8
  148. package/dist/runtime.d.ts +46 -29
  149. package/dist/runtime.js +117 -79
  150. package/package.json +1 -1
  151. package/src/apis/OAuthApi.ts +5 -5
  152. package/src/apis/OrganizationApi.ts +37 -37
  153. package/src/apis/PermissionApi.ts +3 -3
  154. package/src/apis/RoleApi.ts +3 -3
  155. package/src/apis/ServiceAccountApi.ts +17 -17
  156. package/src/apis/SessionApi.ts +25 -25
  157. package/src/apis/UserApi.ts +33 -33
  158. package/src/models/ApplyPermissionsPayload.ts +2 -3
  159. package/src/models/CreateOrUpdateOAuthClientPayload.ts +4 -5
  160. package/src/models/CreateOrUpdateOrganizationPayload.ts +2 -3
  161. package/src/models/CreateOrUpdatePermissionPayload.ts +2 -3
  162. package/src/models/CreateOrganizationPayload.ts +2 -3
  163. package/src/models/CreateOrganizationUserServiceOptionPayload.ts +1 -2
  164. package/src/models/CreateOrganizationUserServicePayload.ts +1 -2
  165. package/src/models/CreateRole.ts +2 -3
  166. package/src/models/DatabaseState.ts +10 -8
  167. package/src/models/EnableEquisoftConnectPayloadSchema.ts +1 -2
  168. package/src/models/ErrorMessage.ts +19 -17
  169. package/src/models/ErrorPayload.ts +2 -3
  170. package/src/models/Id.ts +1 -2
  171. package/src/models/ImpersonatePayload.ts +1 -2
  172. package/src/models/LegacyRoleSchema.ts +2 -3
  173. package/src/models/ListOrganizationElement.ts +6 -3
  174. package/src/models/ListUserOrganizations.ts +2 -3
  175. package/src/models/LocalizedString.ts +1 -2
  176. package/src/models/OAuthClient.ts +4 -5
  177. package/src/models/OAuthClientCreated.ts +1 -2
  178. package/src/models/OAuthClientPublicKey.ts +1 -2
  179. package/src/models/Organization.ts +6 -3
  180. package/src/models/OrganizationCreated.ts +1 -2
  181. package/src/models/OrganizationPathElement.ts +2 -3
  182. package/src/models/OrganizationRoleAttribution.ts +4 -3
  183. package/src/models/OrganizationRoleAttributionPermission.ts +2 -3
  184. package/src/models/OrganizationRoleAttributionRole.ts +4 -3
  185. package/src/models/OrganizationRoleAttributions.ts +2 -3
  186. package/src/models/OrganizationServicesElement.ts +1 -2
  187. package/src/models/OrganizationUserServiceAssociation.ts +1 -2
  188. package/src/models/PermissionCode.ts +1 -2
  189. package/src/models/PermissionCreated.ts +1 -2
  190. package/src/models/PermissionList.ts +2 -3
  191. package/src/models/PermissionResourceType.ts +8 -6
  192. package/src/models/Role.ts +2 -3
  193. package/src/models/RoleCreated.ts +2 -3
  194. package/src/models/RolesOnOrganization.ts +8 -3
  195. package/src/models/ServiceAccess.ts +4 -3
  196. package/src/models/ServiceAccountCreationSchema.ts +1 -2
  197. package/src/models/ServiceAccountSchema.ts +2 -3
  198. package/src/models/ServiceAccountStatus.ts +9 -7
  199. package/src/models/ServiceAccountUpdateSchema.ts +1 -2
  200. package/src/models/ServiceAccountUuidSchema.ts +1 -2
  201. package/src/models/ServiceName.ts +11 -9
  202. package/src/models/Session.ts +6 -3
  203. package/src/models/SessionPayload.ts +2 -3
  204. package/src/models/SessionState.ts +11 -9
  205. package/src/models/SsoProvider.ts +1 -2
  206. package/src/models/SsoToken.ts +1 -2
  207. package/src/models/UpdateParentOrganizationPayload.ts +1 -2
  208. package/src/models/UpdateUserAccountPayload.ts +1 -2
  209. package/src/models/UpdateUserAccountSsoPayload.ts +1 -2
  210. package/src/models/UpsertServicePayload.ts +1 -2
  211. package/src/models/User.ts +10 -3
  212. package/src/models/UserAccountOrganizationRoles.ts +4 -3
  213. package/src/models/UserAccountPermission.ts +2 -3
  214. package/src/models/UserAccountRole.ts +2 -3
  215. package/src/models/UserAccountRoleAttributions.ts +2 -3
  216. package/src/models/UserAccountSearchResult.ts +10 -3
  217. package/src/models/UserAgreement.ts +2 -3
  218. package/src/models/UserAgreementState.ts +8 -6
  219. package/src/models/UserPermissions.ts +4 -3
  220. package/src/models/UserServiceAssociation.ts +1 -2
  221. package/src/models/UserSsoProvider.ts +1 -2
  222. package/src/models/UserState.ts +9 -7
  223. package/src/runtime.ts +145 -96
  224. package/tsconfig.esm.json +7 -0
@@ -4,7 +4,7 @@
4
4
  * User account and session management
5
5
  * Provides HTTP endpoints to manage User Accounts and User Sessions.
6
6
  *
7
- * The version of the OpenAPI document: 3.7.4-SNAPSHOT
7
+ * The version of the OpenAPI document: 3.8.1-SNAPSHOT
8
8
  *
9
9
  *
10
10
  * NOTE: This class is auto generated by OpenAPI Generator (https://openapi-generator.tech).
@@ -18,11 +18,13 @@ import {
18
18
  LegacyRoleSchemaFromJSON,
19
19
  LegacyRoleSchemaFromJSONTyped,
20
20
  LegacyRoleSchemaToJSON,
21
+ } from './LegacyRoleSchema';
22
+ import {
21
23
  RolesOnOrganization,
22
24
  RolesOnOrganizationFromJSON,
23
25
  RolesOnOrganizationFromJSONTyped,
24
26
  RolesOnOrganizationToJSON,
25
- } from './';
27
+ } from './RolesOnOrganization';
26
28
 
27
29
  /**
28
30
  *
@@ -73,4 +75,3 @@ export function UserPermissionsToJSON(value?: UserPermissions | null): any {
73
75
  };
74
76
  }
75
77
 
76
-
@@ -4,7 +4,7 @@
4
4
  * User account and session management
5
5
  * Provides HTTP endpoints to manage User Accounts and User Sessions.
6
6
  *
7
- * The version of the OpenAPI document: 3.7.4-SNAPSHOT
7
+ * The version of the OpenAPI document: 3.8.1-SNAPSHOT
8
8
  *
9
9
  *
10
10
  * NOTE: This class is auto generated by OpenAPI Generator (https://openapi-generator.tech).
@@ -78,4 +78,3 @@ export function UserServiceAssociationToJSON(value?: UserServiceAssociation | nu
78
78
  };
79
79
  }
80
80
 
81
-
@@ -4,7 +4,7 @@
4
4
  * User account and session management
5
5
  * Provides HTTP endpoints to manage User Accounts and User Sessions.
6
6
  *
7
- * The version of the OpenAPI document: 3.7.4-SNAPSHOT
7
+ * The version of the OpenAPI document: 3.8.1-SNAPSHOT
8
8
  *
9
9
  *
10
10
  * NOTE: This class is auto generated by OpenAPI Generator (https://openapi-generator.tech).
@@ -54,4 +54,3 @@ export function UserSsoProviderToJSON(value?: UserSsoProvider | null): any {
54
54
  };
55
55
  }
56
56
 
57
-
@@ -4,7 +4,7 @@
4
4
  * User account and session management
5
5
  * Provides HTTP endpoints to manage User Accounts and User Sessions.
6
6
  *
7
- * The version of the OpenAPI document: 3.7.4-SNAPSHOT
7
+ * The version of the OpenAPI document: 3.8.1-SNAPSHOT
8
8
  *
9
9
  *
10
10
  * NOTE: This class is auto generated by OpenAPI Generator (https://openapi-generator.tech).
@@ -12,19 +12,21 @@
12
12
  * Do not edit the class manually.
13
13
  */
14
14
 
15
+
15
16
  /**
16
17
  * States:
17
18
  * * `DELETED` - User is soft deleted or archived.
18
19
  * * `DISABLED` - Temporarily denied login.
19
20
  * * `ENABLED` - Allowed to login.
20
21
  * @export
21
- * @enum {string}
22
22
  */
23
- export enum UserState {
24
- DELETED = 'DELETED',
25
- DISABLED = 'DISABLED',
26
- ENABLED = 'ENABLED'
27
- }
23
+ export const UserState = {
24
+ DELETED: 'DELETED',
25
+ DISABLED: 'DISABLED',
26
+ ENABLED: 'ENABLED'
27
+ } as const;
28
+ export type UserState = typeof UserState[keyof typeof UserState];
29
+
28
30
 
29
31
  export function UserStateFromJSON(json: any): UserState {
30
32
  return UserStateFromJSONTyped(json, false);
package/src/runtime.ts CHANGED
@@ -4,7 +4,7 @@
4
4
  * User account and session management
5
5
  * Provides HTTP endpoints to manage User Accounts and User Sessions.
6
6
  *
7
- * The version of the OpenAPI document: 3.7.4-SNAPSHOT
7
+ * The version of the OpenAPI document: 3.8.1-SNAPSHOT
8
8
  *
9
9
  *
10
10
  * NOTE: This class is auto generated by OpenAPI Generator (https://openapi-generator.tech).
@@ -15,7 +15,76 @@
15
15
 
16
16
  export const BASE_PATH = "http://localhost".replace(/\/+$/, "");
17
17
 
18
- const isBlob = (value: any) => typeof Blob !== 'undefined' && value instanceof Blob;
18
+ export interface ConfigurationParameters {
19
+ basePath?: string; // override base path
20
+ fetchApi?: FetchAPI; // override for fetch implementation
21
+ middleware?: Middleware[]; // middleware to apply before/after fetch requests
22
+ queryParamsStringify?: (params: HTTPQuery) => string; // stringify function for query strings
23
+ username?: string; // parameter for basic security
24
+ password?: string; // parameter for basic security
25
+ apiKey?: string | ((name: string) => string); // parameter for apiKey security
26
+ accessToken?: string | Promise<string> | ((name?: string, scopes?: string[]) => string | Promise<string>); // parameter for oauth2 security
27
+ headers?: HTTPHeaders; //header params we want to use on every request
28
+ credentials?: RequestCredentials; //value for the credentials param we want to use on each request
29
+ }
30
+
31
+ export class Configuration {
32
+ constructor(private configuration: ConfigurationParameters = {}) {}
33
+
34
+ set config(configuration: Configuration) {
35
+ this.configuration = configuration;
36
+ }
37
+
38
+ get basePath(): string {
39
+ return this.configuration.basePath != null ? this.configuration.basePath : BASE_PATH;
40
+ }
41
+
42
+ get fetchApi(): FetchAPI | undefined {
43
+ return this.configuration.fetchApi;
44
+ }
45
+
46
+ get middleware(): Middleware[] {
47
+ return this.configuration.middleware || [];
48
+ }
49
+
50
+ get queryParamsStringify(): (params: HTTPQuery) => string {
51
+ return this.configuration.queryParamsStringify || querystring;
52
+ }
53
+
54
+ get username(): string | undefined {
55
+ return this.configuration.username;
56
+ }
57
+
58
+ get password(): string | undefined {
59
+ return this.configuration.password;
60
+ }
61
+
62
+ get apiKey(): ((name: string) => string) | undefined {
63
+ const apiKey = this.configuration.apiKey;
64
+ if (apiKey) {
65
+ return typeof apiKey === 'function' ? apiKey : () => apiKey;
66
+ }
67
+ return undefined;
68
+ }
69
+
70
+ get accessToken(): ((name?: string, scopes?: string[]) => string | Promise<string>) | undefined {
71
+ const accessToken = this.configuration.accessToken;
72
+ if (accessToken) {
73
+ return typeof accessToken === 'function' ? accessToken : async () => accessToken;
74
+ }
75
+ return undefined;
76
+ }
77
+
78
+ get headers(): HTTPHeaders | undefined {
79
+ return this.configuration.headers;
80
+ }
81
+
82
+ get credentials(): RequestCredentials | undefined {
83
+ return this.configuration.credentials;
84
+ }
85
+ }
86
+
87
+ export const DefaultConfig = new Configuration();
19
88
 
20
89
  /**
21
90
  * This is the base class for all generated API classes.
@@ -24,7 +93,7 @@ export class BaseAPI {
24
93
 
25
94
  private middleware: Middleware[];
26
95
 
27
- constructor(protected configuration = new Configuration()) {
96
+ constructor(protected configuration = DefaultConfig) {
28
97
  this.middleware = configuration.middleware;
29
98
  }
30
99
 
@@ -44,16 +113,16 @@ export class BaseAPI {
44
113
  return this.withMiddleware<T>(...middlewares);
45
114
  }
46
115
 
47
- protected async request(context: RequestOpts, initOverrides?: RequestInit): Promise<Response> {
48
- const { url, init } = this.createFetchParams(context, initOverrides);
116
+ protected async request(context: RequestOpts, initOverrides?: RequestInit | InitOverideFunction): Promise<Response> {
117
+ const { url, init } = await this.createFetchParams(context, initOverrides);
49
118
  const response = await this.fetchApi(url, init);
50
119
  if (response.status >= 200 && response.status < 300) {
51
120
  return response;
52
121
  }
53
- throw response;
122
+ throw new ResponseError(response, 'Response returned an error code');
54
123
  }
55
124
 
56
- private createFetchParams(context: RequestOpts, initOverrides?: RequestInit) {
125
+ private async createFetchParams(context: RequestOpts, initOverrides?: RequestInit | InitOverideFunction) {
57
126
  let url = this.configuration.basePath + context.path;
58
127
  if (context.query !== undefined && Object.keys(context.query).length !== 0) {
59
128
  // only add the querystring to the URL if there are query parameters.
@@ -61,18 +130,40 @@ export class BaseAPI {
61
130
  // do not handle correctly sometimes.
62
131
  url += '?' + this.configuration.queryParamsStringify(context.query);
63
132
  }
64
- const body = ((typeof FormData !== "undefined" && context.body instanceof FormData) || context.body instanceof URLSearchParams || isBlob(context.body))
65
- ? context.body
66
- : JSON.stringify(context.body);
67
133
 
68
134
  const headers = Object.assign({}, this.configuration.headers, context.headers);
69
- const init = {
135
+ Object.keys(headers).forEach(key => headers[key] === undefined ? delete headers[key] : {});
136
+
137
+ const initOverrideFn =
138
+ typeof initOverrides === "function"
139
+ ? initOverrides
140
+ : async () => initOverrides;
141
+
142
+ const initParams = {
70
143
  method: context.method,
71
- headers: headers,
72
- body,
144
+ headers,
145
+ body: context.body,
73
146
  credentials: this.configuration.credentials,
74
- ...initOverrides
75
147
  };
148
+
149
+ const overridedInit: RequestInit = {
150
+ ...initParams,
151
+ ...(await initOverrideFn({
152
+ init: initParams,
153
+ context,
154
+ }))
155
+ }
156
+
157
+ const init: RequestInit = {
158
+ ...overridedInit,
159
+ body:
160
+ isFormData(overridedInit.body) ||
161
+ overridedInit.body instanceof URLSearchParams ||
162
+ isBlob(overridedInit.body)
163
+ ? overridedInit.body
164
+ : JSON.stringify(overridedInit.body),
165
+ };
166
+
76
167
  return { url, init };
77
168
  }
78
169
 
@@ -112,6 +203,21 @@ export class BaseAPI {
112
203
  }
113
204
  };
114
205
 
206
+ function isBlob(value: any): value is Blob {
207
+ return typeof Blob !== 'undefined' && value instanceof Blob
208
+ }
209
+
210
+ function isFormData(value: any): value is FormData {
211
+ return typeof FormData !== "undefined" && value instanceof FormData
212
+ }
213
+
214
+ export class ResponseError extends Error {
215
+ name: "ResponseError" = "ResponseError";
216
+ constructor(public response: Response, msg?: string) {
217
+ super(msg);
218
+ }
219
+ }
220
+
115
221
  export class RequiredError extends Error {
116
222
  name: "RequiredError" = "RequiredError";
117
223
  constructor(public field: string, msg?: string) {
@@ -128,78 +234,16 @@ export const COLLECTION_FORMATS = {
128
234
 
129
235
  export type FetchAPI = WindowOrWorkerGlobalScope['fetch'];
130
236
 
131
- export interface ConfigurationParameters {
132
- basePath?: string; // override base path
133
- fetchApi?: FetchAPI; // override for fetch implementation
134
- middleware?: Middleware[]; // middleware to apply before/after fetch requests
135
- queryParamsStringify?: (params: HTTPQuery) => string; // stringify function for query strings
136
- username?: string; // parameter for basic security
137
- password?: string; // parameter for basic security
138
- apiKey?: string | ((name: string) => string); // parameter for apiKey security
139
- accessToken?: string | Promise<string> | ((name?: string, scopes?: string[]) => string | Promise<string>); // parameter for oauth2 security
140
- headers?: HTTPHeaders; //header params we want to use on every request
141
- credentials?: RequestCredentials; //value for the credentials param we want to use on each request
142
- }
143
-
144
- export class Configuration {
145
- constructor(private configuration: ConfigurationParameters = {}) {}
146
-
147
- get basePath(): string {
148
- return this.configuration.basePath != null ? this.configuration.basePath : BASE_PATH;
149
- }
150
-
151
- get fetchApi(): FetchAPI {
152
- return this.configuration.fetchApi;
153
- }
154
-
155
- get middleware(): Middleware[] {
156
- return this.configuration.middleware || [];
157
- }
158
-
159
- get queryParamsStringify(): (params: HTTPQuery) => string {
160
- return this.configuration.queryParamsStringify || querystring;
161
- }
162
-
163
- get username(): string | undefined {
164
- return this.configuration.username;
165
- }
166
-
167
- get password(): string | undefined {
168
- return this.configuration.password;
169
- }
170
-
171
- get apiKey(): ((name: string) => string) | undefined {
172
- const apiKey = this.configuration.apiKey;
173
- if (apiKey) {
174
- return typeof apiKey === 'function' ? apiKey : () => apiKey;
175
- }
176
- return undefined;
177
- }
178
-
179
- get accessToken(): ((name?: string, scopes?: string[]) => string | Promise<string>) | undefined {
180
- const accessToken = this.configuration.accessToken;
181
- if (accessToken) {
182
- return typeof accessToken === 'function' ? accessToken : async () => accessToken;
183
- }
184
- return undefined;
185
- }
186
-
187
- get headers(): HTTPHeaders | undefined {
188
- return this.configuration.headers;
189
- }
190
-
191
- get credentials(): RequestCredentials | undefined {
192
- return this.configuration.credentials;
193
- }
194
- }
195
-
196
237
  export type Json = any;
197
238
  export type HTTPMethod = 'GET' | 'POST' | 'PUT' | 'PATCH' | 'DELETE' | 'OPTIONS' | 'HEAD';
198
239
  export type HTTPHeaders = { [key: string]: string };
199
- export type HTTPQuery = { [key: string]: string | number | null | boolean | Array<string | number | null | boolean> | HTTPQuery };
240
+ export type HTTPQuery = { [key: string]: string | number | null | boolean | Array<string | number | null | boolean> | Set<string | number | null | boolean> | HTTPQuery };
200
241
  export type HTTPBody = Json | FormData | URLSearchParams;
242
+ export type HTTPRequestInit = { headers?: HTTPHeaders; method: HTTPMethod; credentials?: RequestCredentials; body?: HTTPBody }
201
243
  export type ModelPropertyNaming = 'camelCase' | 'snake_case' | 'PascalCase' | 'original';
202
244
 
245
+ export type InitOverideFunction = (requestContext: { init: HTTPRequestInit, context: RequestOpts }) => Promise<RequestInit>
246
+
203
247
  export interface FetchParams {
204
248
  url: string;
205
249
  init: RequestInit;
@@ -220,26 +264,31 @@ export function exists(json: any, key: string) {
220
264
 
221
265
  export function querystring(params: HTTPQuery, prefix: string = ''): string {
222
266
  return Object.keys(params)
223
- .map((key) => {
224
- const fullKey = prefix + (prefix.length ? `[${key}]` : key);
225
- const value = params[key];
226
- if (value instanceof Array) {
227
- const multiValue = value.map(singleValue => encodeURIComponent(String(singleValue)))
228
- .join(`&${encodeURIComponent(fullKey)}=`);
229
- return `${encodeURIComponent(fullKey)}=${multiValue}`;
230
- }
231
- if (value instanceof Date) {
232
- return `${encodeURIComponent(fullKey)}=${encodeURIComponent(value.toISOString())}`;
233
- }
234
- if (value instanceof Object) {
235
- return querystring(value as HTTPQuery, fullKey);
236
- }
237
- return `${encodeURIComponent(fullKey)}=${encodeURIComponent(String(value))}`;
238
- })
267
+ .map(key => querystringSingleKey(key, params[key], prefix))
239
268
  .filter(part => part.length > 0)
240
269
  .join('&');
241
270
  }
242
271
 
272
+ function querystringSingleKey(key: string, value: string | number | null | boolean | Array<string | number | null | boolean> | Set<string | number | null | boolean> | HTTPQuery, keyPrefix: string = ''): string {
273
+ const fullKey = keyPrefix + (keyPrefix.length ? `[${key}]` : key);
274
+ if (value instanceof Array) {
275
+ const multiValue = value.map(singleValue => encodeURIComponent(String(singleValue)))
276
+ .join(`&${encodeURIComponent(fullKey)}=`);
277
+ return `${encodeURIComponent(fullKey)}=${multiValue}`;
278
+ }
279
+ if (value instanceof Set) {
280
+ const valueAsArray = Array.from(value);
281
+ return querystringSingleKey(key, valueAsArray, keyPrefix);
282
+ }
283
+ if (value instanceof Date) {
284
+ return `${encodeURIComponent(fullKey)}=${encodeURIComponent(value.toISOString())}`;
285
+ }
286
+ if (value instanceof Object) {
287
+ return querystring(value as HTTPQuery, fullKey);
288
+ }
289
+ return `${encodeURIComponent(fullKey)}=${encodeURIComponent(String(value))}`;
290
+ }
291
+
243
292
  export function mapValues(data: any, fn: (item: any) => any) {
244
293
  return Object.keys(data).reduce(
245
294
  (acc, key) => ({ ...acc, [key]: fn(data[key]) }),
@@ -0,0 +1,7 @@
1
+ {
2
+ "extends": "./tsconfig.json",
3
+ "compilerOptions": {
4
+ "module": "esnext",
5
+ "outDir": "dist/esm"
6
+ }
7
+ }