@equisoft/account-service-sdk-typescript 3.8.0 → 3.9.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/.openapi-generator/FILES +1 -0
- package/.openapi-generator/VERSION +1 -1
- package/README.md +2 -2
- package/dist/apis/OAuthApi.d.ts +5 -5
- package/dist/apis/OAuthApi.js +1 -1
- package/dist/apis/OrganizationApi.d.ts +37 -37
- package/dist/apis/OrganizationApi.js +1 -1
- package/dist/apis/PermissionApi.d.ts +3 -3
- package/dist/apis/PermissionApi.js +1 -1
- package/dist/apis/RoleApi.d.ts +3 -3
- package/dist/apis/RoleApi.js +1 -1
- package/dist/apis/ServiceAccountApi.d.ts +17 -17
- package/dist/apis/ServiceAccountApi.js +2 -2
- package/dist/apis/SessionApi.d.ts +25 -25
- package/dist/apis/SessionApi.js +1 -1
- package/dist/apis/UserApi.d.ts +33 -33
- package/dist/apis/UserApi.js +2 -2
- package/dist/models/ApplyPermissionsPayload.d.ts +2 -2
- package/dist/models/ApplyPermissionsPayload.js +4 -4
- package/dist/models/CreateOrUpdateOAuthClientPayload.d.ts +4 -4
- package/dist/models/CreateOrUpdateOAuthClientPayload.js +4 -4
- package/dist/models/CreateOrUpdateOrganizationPayload.d.ts +2 -2
- package/dist/models/CreateOrUpdateOrganizationPayload.js +4 -4
- package/dist/models/CreateOrUpdatePermissionPayload.d.ts +2 -2
- package/dist/models/CreateOrUpdatePermissionPayload.js +4 -4
- package/dist/models/CreateOrganizationPayload.d.ts +2 -2
- package/dist/models/CreateOrganizationPayload.js +4 -4
- package/dist/models/CreateOrganizationUserServiceOptionPayload.d.ts +1 -1
- package/dist/models/CreateOrganizationUserServiceOptionPayload.js +1 -1
- package/dist/models/CreateOrganizationUserServicePayload.d.ts +1 -1
- package/dist/models/CreateOrganizationUserServicePayload.js +1 -1
- package/dist/models/CreateRole.d.ts +2 -2
- package/dist/models/CreateRole.js +4 -4
- package/dist/models/DatabaseState.d.ts +8 -8
- package/dist/models/DatabaseState.js +7 -9
- package/dist/models/EnableEquisoftConnectPayloadSchema.d.ts +1 -1
- package/dist/models/EnableEquisoftConnectPayloadSchema.js +1 -1
- package/dist/models/ErrorMessage.d.ts +17 -17
- package/dist/models/ErrorMessage.js +16 -18
- package/dist/models/ErrorPayload.d.ts +2 -2
- package/dist/models/ErrorPayload.js +4 -4
- package/dist/models/Id.d.ts +1 -1
- package/dist/models/Id.js +1 -1
- package/dist/models/ImpersonatePayload.d.ts +1 -1
- package/dist/models/ImpersonatePayload.js +1 -1
- package/dist/models/LegacyRoleSchema.d.ts +2 -2
- package/dist/models/LegacyRoleSchema.js +4 -4
- package/dist/models/ListOrganizationElement.d.ts +4 -2
- package/dist/models/ListOrganizationElement.js +10 -8
- package/dist/models/ListUserOrganizations.d.ts +2 -2
- package/dist/models/ListUserOrganizations.js +4 -4
- package/dist/models/LocalizedString.d.ts +1 -1
- package/dist/models/LocalizedString.js +1 -1
- package/dist/models/OAuthClient.d.ts +4 -4
- package/dist/models/OAuthClient.js +4 -4
- package/dist/models/OAuthClientCreated.d.ts +1 -1
- package/dist/models/OAuthClientCreated.js +1 -1
- package/dist/models/OAuthClientPublicKey.d.ts +1 -1
- package/dist/models/OAuthClientPublicKey.js +1 -1
- package/dist/models/Organization.d.ts +4 -2
- package/dist/models/Organization.js +10 -8
- package/dist/models/OrganizationCreated.d.ts +1 -1
- package/dist/models/OrganizationCreated.js +1 -1
- package/dist/models/OrganizationPathElement.d.ts +2 -2
- package/dist/models/OrganizationPathElement.js +4 -4
- package/dist/models/OrganizationRoleAttribution.d.ts +3 -2
- package/dist/models/OrganizationRoleAttribution.js +7 -6
- package/dist/models/OrganizationRoleAttributionPermission.d.ts +2 -2
- package/dist/models/OrganizationRoleAttributionPermission.js +4 -4
- package/dist/models/OrganizationRoleAttributionRole.d.ts +3 -2
- package/dist/models/OrganizationRoleAttributionRole.js +7 -6
- package/dist/models/OrganizationRoleAttributions.d.ts +2 -2
- package/dist/models/OrganizationRoleAttributions.js +4 -4
- package/dist/models/OrganizationServicesElement.d.ts +1 -1
- package/dist/models/OrganizationServicesElement.js +1 -1
- package/dist/models/OrganizationUserServiceAssociation.d.ts +1 -1
- package/dist/models/OrganizationUserServiceAssociation.js +1 -1
- package/dist/models/PermissionCode.d.ts +1 -1
- package/dist/models/PermissionCode.js +1 -1
- package/dist/models/PermissionCreated.d.ts +1 -1
- package/dist/models/PermissionCreated.js +1 -1
- package/dist/models/PermissionList.d.ts +2 -2
- package/dist/models/PermissionList.js +4 -4
- package/dist/models/PermissionResourceType.d.ts +6 -6
- package/dist/models/PermissionResourceType.js +5 -7
- package/dist/models/Role.d.ts +2 -2
- package/dist/models/Role.js +4 -4
- package/dist/models/RoleCreated.d.ts +2 -2
- package/dist/models/RoleCreated.js +4 -4
- package/dist/models/RolesOnOrganization.d.ts +5 -2
- package/dist/models/RolesOnOrganization.js +13 -10
- package/dist/models/ServiceAccess.d.ts +3 -2
- package/dist/models/ServiceAccess.js +7 -6
- package/dist/models/ServiceAccountCreationSchema.d.ts +1 -1
- package/dist/models/ServiceAccountCreationSchema.js +1 -1
- package/dist/models/ServiceAccountSchema.d.ts +2 -2
- package/dist/models/ServiceAccountSchema.js +4 -4
- package/dist/models/ServiceAccountStatus.d.ts +7 -7
- package/dist/models/ServiceAccountStatus.js +6 -8
- package/dist/models/ServiceAccountUpdateSchema.d.ts +1 -1
- package/dist/models/ServiceAccountUpdateSchema.js +1 -1
- package/dist/models/ServiceAccountUuidSchema.d.ts +1 -1
- package/dist/models/ServiceAccountUuidSchema.js +1 -1
- package/dist/models/ServiceName.d.ts +9 -9
- package/dist/models/ServiceName.js +8 -10
- package/dist/models/Session.d.ts +4 -2
- package/dist/models/Session.js +12 -10
- package/dist/models/SessionPayload.d.ts +2 -2
- package/dist/models/SessionPayload.js +4 -4
- package/dist/models/SessionState.d.ts +9 -9
- package/dist/models/SessionState.js +8 -10
- package/dist/models/SsoProvider.d.ts +1 -1
- package/dist/models/SsoProvider.js +1 -1
- package/dist/models/SsoToken.d.ts +1 -1
- package/dist/models/SsoToken.js +1 -1
- package/dist/models/UpdateParentOrganizationPayload.d.ts +1 -1
- package/dist/models/UpdateParentOrganizationPayload.js +1 -1
- package/dist/models/UpdateUserAccountPayload.d.ts +1 -1
- package/dist/models/UpdateUserAccountPayload.js +1 -1
- package/dist/models/UpdateUserAccountSsoPayload.d.ts +1 -1
- package/dist/models/UpdateUserAccountSsoPayload.js +1 -1
- package/dist/models/UpsertServicePayload.d.ts +1 -1
- package/dist/models/UpsertServicePayload.js +1 -1
- package/dist/models/User.d.ts +6 -2
- package/dist/models/User.js +18 -14
- package/dist/models/UserAccountOrganizationRoles.d.ts +3 -2
- package/dist/models/UserAccountOrganizationRoles.js +7 -6
- package/dist/models/UserAccountPermission.d.ts +2 -2
- package/dist/models/UserAccountPermission.js +4 -4
- package/dist/models/UserAccountRole.d.ts +2 -2
- package/dist/models/UserAccountRole.js +4 -4
- package/dist/models/UserAccountRoleAttributions.d.ts +2 -2
- package/dist/models/UserAccountRoleAttributions.js +4 -4
- package/dist/models/UserAccountSearchResult.d.ts +6 -2
- package/dist/models/UserAccountSearchResult.js +18 -14
- package/dist/models/UserAgreement.d.ts +2 -2
- package/dist/models/UserAgreement.js +4 -4
- package/dist/models/UserAgreementState.d.ts +6 -6
- package/dist/models/UserAgreementState.js +5 -7
- package/dist/models/UserPermissions.d.ts +3 -2
- package/dist/models/UserPermissions.js +7 -6
- package/dist/models/UserServiceAssociation.d.ts +1 -1
- package/dist/models/UserServiceAssociation.js +1 -1
- package/dist/models/UserSsoProvider.d.ts +1 -1
- package/dist/models/UserSsoProvider.js +1 -1
- package/dist/models/UserState.d.ts +7 -7
- package/dist/models/UserState.js +6 -8
- package/dist/runtime.d.ts +46 -29
- package/dist/runtime.js +117 -79
- package/package.json +1 -1
- package/src/apis/OAuthApi.ts +5 -5
- package/src/apis/OrganizationApi.ts +37 -37
- package/src/apis/PermissionApi.ts +3 -3
- package/src/apis/RoleApi.ts +3 -3
- package/src/apis/ServiceAccountApi.ts +17 -17
- package/src/apis/SessionApi.ts +25 -25
- package/src/apis/UserApi.ts +33 -33
- package/src/models/ApplyPermissionsPayload.ts +2 -3
- package/src/models/CreateOrUpdateOAuthClientPayload.ts +4 -5
- package/src/models/CreateOrUpdateOrganizationPayload.ts +2 -3
- package/src/models/CreateOrUpdatePermissionPayload.ts +2 -3
- package/src/models/CreateOrganizationPayload.ts +2 -3
- package/src/models/CreateOrganizationUserServiceOptionPayload.ts +1 -2
- package/src/models/CreateOrganizationUserServicePayload.ts +1 -2
- package/src/models/CreateRole.ts +2 -3
- package/src/models/DatabaseState.ts +10 -8
- package/src/models/EnableEquisoftConnectPayloadSchema.ts +1 -2
- package/src/models/ErrorMessage.ts +19 -17
- package/src/models/ErrorPayload.ts +2 -3
- package/src/models/Id.ts +1 -2
- package/src/models/ImpersonatePayload.ts +1 -2
- package/src/models/LegacyRoleSchema.ts +2 -3
- package/src/models/ListOrganizationElement.ts +6 -3
- package/src/models/ListUserOrganizations.ts +2 -3
- package/src/models/LocalizedString.ts +1 -2
- package/src/models/OAuthClient.ts +4 -5
- package/src/models/OAuthClientCreated.ts +1 -2
- package/src/models/OAuthClientPublicKey.ts +1 -2
- package/src/models/Organization.ts +6 -3
- package/src/models/OrganizationCreated.ts +1 -2
- package/src/models/OrganizationPathElement.ts +2 -3
- package/src/models/OrganizationRoleAttribution.ts +4 -3
- package/src/models/OrganizationRoleAttributionPermission.ts +2 -3
- package/src/models/OrganizationRoleAttributionRole.ts +4 -3
- package/src/models/OrganizationRoleAttributions.ts +2 -3
- package/src/models/OrganizationServicesElement.ts +1 -2
- package/src/models/OrganizationUserServiceAssociation.ts +1 -2
- package/src/models/PermissionCode.ts +1 -2
- package/src/models/PermissionCreated.ts +1 -2
- package/src/models/PermissionList.ts +2 -3
- package/src/models/PermissionResourceType.ts +8 -6
- package/src/models/Role.ts +2 -3
- package/src/models/RoleCreated.ts +2 -3
- package/src/models/RolesOnOrganization.ts +8 -3
- package/src/models/ServiceAccess.ts +4 -3
- package/src/models/ServiceAccountCreationSchema.ts +1 -2
- package/src/models/ServiceAccountSchema.ts +2 -3
- package/src/models/ServiceAccountStatus.ts +9 -7
- package/src/models/ServiceAccountUpdateSchema.ts +1 -2
- package/src/models/ServiceAccountUuidSchema.ts +1 -2
- package/src/models/ServiceName.ts +11 -9
- package/src/models/Session.ts +6 -3
- package/src/models/SessionPayload.ts +2 -3
- package/src/models/SessionState.ts +11 -9
- package/src/models/SsoProvider.ts +1 -2
- package/src/models/SsoToken.ts +1 -2
- package/src/models/UpdateParentOrganizationPayload.ts +1 -2
- package/src/models/UpdateUserAccountPayload.ts +1 -2
- package/src/models/UpdateUserAccountSsoPayload.ts +1 -2
- package/src/models/UpsertServicePayload.ts +1 -2
- package/src/models/User.ts +10 -3
- package/src/models/UserAccountOrganizationRoles.ts +4 -3
- package/src/models/UserAccountPermission.ts +2 -3
- package/src/models/UserAccountRole.ts +2 -3
- package/src/models/UserAccountRoleAttributions.ts +2 -3
- package/src/models/UserAccountSearchResult.ts +10 -3
- package/src/models/UserAgreement.ts +2 -3
- package/src/models/UserAgreementState.ts +8 -6
- package/src/models/UserPermissions.ts +4 -3
- package/src/models/UserServiceAssociation.ts +1 -2
- package/src/models/UserSsoProvider.ts +1 -2
- package/src/models/UserState.ts +9 -7
- package/src/runtime.ts +145 -96
- 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
|
+
* The version of the OpenAPI document: 3.9.0
|
|
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
|
+
* The version of the OpenAPI document: 3.9.0
|
|
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
|
+
* The version of the OpenAPI document: 3.9.0
|
|
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
|
-
|
package/src/models/UserState.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
|
+
* The version of the OpenAPI document: 3.9.0
|
|
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
|
|
24
|
-
DELETED
|
|
25
|
-
DISABLED
|
|
26
|
-
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
|
+
* The version of the OpenAPI document: 3.9.0
|
|
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
|
-
|
|
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 =
|
|
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
|
-
|
|
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
|
|
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(
|
|
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]) }),
|