@approvio/ts-sdk 0.0.27 → 1.0.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/dist/index.cjs +220 -100
- package/dist/index.d.cts +102 -30
- package/dist/index.d.mts +102 -30
- package/dist/index.mjs +214 -101
- package/package.json +3 -3
package/dist/index.d.cts
CHANGED
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
import { AxiosInstance } from "axios";
|
|
2
|
-
import { APIError, AddGroupEntitiesRequest, AgentGet200Response, AgentRegistrationRequest, AgentRegistrationResponse, AgentTokenResponse, AuthProvider, CanVoteResponse, GetEntityInfo200Response, GetEntityInfoAgentResponse, GetEntityInfoUserResponse, GetWorkflowParams, GetWorkflowVotes200Response, Group, GroupCreate, ListAuditLogs200Response, ListAuditLogsParams, ListGroupEntities200Response, ListGroups200Response, ListGroupsParams, ListMyAuditLogsParams,
|
|
2
|
+
import { APIError, Account, AddGroupEntitiesRequest, AgentChallengeRequest, AgentChallengeResponse, AgentGet200Response, AgentRegistrationRequest, AgentRegistrationResponse, AgentTokenRequest, AgentTokenResponse, AuthProvider, CanVoteResponse, CliOrganizationSelection, GetEntityInfo200Response, GetEntityInfoAgentResponse, GetEntityInfoUserResponse, GetWorkflowParams, GetWorkflowVotes200Response, Group, GroupCreate, InvitationAccept, InvitationCreate, InvitationCreated, ListAuditLogs200Response, ListAuditLogsParams, ListGroupEntities200Response, ListGroups200Response, ListGroupsParams, ListMyAuditLogsParams, ListRoleTemplates200Response, ListSpaces200Response, ListSpacesParams, ListUsers200Response, ListUsersParams, ListWorkflowTemplates200Response, ListWorkflowTemplatesParams, ListWorkflowVotesParams, ListWorkflows200Response, ListWorkflowsParams, Membership, MembershipList, MembershipRoleUpdate, OrganizationCreate, OrganizationCreateResponse, OrganizationEntitlementsResponse, OrganizationList, OrganizationSummary, OrganizationUpdate, OrganizationUsageResponse, PrivilegedTokenExchangeRequest, PrivilegedTokenResponse, RemoveGroupEntitiesRequest, ResourceResolveRequest, ResourceResolveResponse, RoleAssignmentRequest, RoleRemovalRequest, Space, SpaceCreate, TokenResponse, User, UserCreate, WebOrganizationSwitch, WebSessionContext, Workflow, WorkflowCreate, WorkflowTemplate, WorkflowTemplateCreate, WorkflowTemplateDeprecate, WorkflowTemplateUpdate, WorkflowVoteRequest } from "@approvio/api";
|
|
3
3
|
import * as TE from "fp-ts/lib/TaskEither.js";
|
|
4
4
|
|
|
5
5
|
//#region src/interfaces.d.ts
|
|
@@ -32,13 +32,38 @@ declare class WebAuthenticator implements Authenticator {
|
|
|
32
32
|
customizeAxios(axios: AxiosInstance): void;
|
|
33
33
|
}
|
|
34
34
|
//#endregion
|
|
35
|
+
//#region src/client/errors.d.ts
|
|
36
|
+
declare class LocationNotFoundError extends Error {
|
|
37
|
+
constructor();
|
|
38
|
+
}
|
|
39
|
+
declare class NetworkError extends Error {
|
|
40
|
+
constructor(message: string);
|
|
41
|
+
}
|
|
42
|
+
declare class UnexpectedEntityTypeError extends Error {
|
|
43
|
+
readonly expected: string;
|
|
44
|
+
readonly received: string;
|
|
45
|
+
constructor(expected: string, received: string);
|
|
46
|
+
}
|
|
47
|
+
declare class OrganizationContextChangedError extends Error {
|
|
48
|
+
readonly status: number;
|
|
49
|
+
constructor(status: number, message: string);
|
|
50
|
+
}
|
|
51
|
+
declare class OrganizationSuspendedError extends Error {
|
|
52
|
+
readonly status: number;
|
|
53
|
+
constructor(status: number, message: string);
|
|
54
|
+
}
|
|
55
|
+
//#endregion
|
|
35
56
|
//#region src/client/base.client.d.ts
|
|
36
57
|
type SerializablePrimitive = string | number | boolean | null | undefined;
|
|
37
58
|
type SerializableValue = SerializablePrimitive | SerializablePrimitive[];
|
|
38
59
|
type SafeQueryParams<T> = { [K in keyof T]: T[K] extends SerializableValue ? T[K] : never };
|
|
39
60
|
type ApprovioError = (APIError & {
|
|
40
61
|
status: number;
|
|
41
|
-
}) | Error;
|
|
62
|
+
}) | OrganizationContextChangedError | OrganizationSuspendedError | Error;
|
|
63
|
+
interface Versioned<T> {
|
|
64
|
+
data: T;
|
|
65
|
+
etag: string;
|
|
66
|
+
}
|
|
42
67
|
declare abstract class BaseApprovioClient {
|
|
43
68
|
protected readonly config: ApprovioServerConfig;
|
|
44
69
|
protected readonly authenticator: Authenticator;
|
|
@@ -46,22 +71,16 @@ declare abstract class BaseApprovioClient {
|
|
|
46
71
|
constructor(config: ApprovioServerConfig, authenticator: Authenticator);
|
|
47
72
|
protected handleError(error: unknown): ApprovioError;
|
|
48
73
|
protected get<Response, Params extends SafeQueryParams<Params> = Record<string, SerializableValue>>(url: string, params?: Params): TE.TaskEither<ApprovioError, Response>;
|
|
49
|
-
protected
|
|
74
|
+
protected getVersioned<Response, Params extends SafeQueryParams<Params> = Record<string, SerializableValue>>(url: string, params?: Params): TE.TaskEither<ApprovioError, Versioned<Response>>;
|
|
75
|
+
protected post<T>(url: string, data?: unknown, headers?: Record<string, string>): TE.TaskEither<ApprovioError, T>;
|
|
76
|
+
protected postVersioned<T>(url: string, data: unknown, headers?: Record<string, string>): TE.TaskEither<ApprovioError, Versioned<T>>;
|
|
50
77
|
protected postWithLocation<T>(url: string, data?: unknown): TE.TaskEither<ApprovioError, {
|
|
51
78
|
data: T;
|
|
52
79
|
location: string;
|
|
53
80
|
}>;
|
|
54
|
-
protected put<T>(url: string, data?: unknown): TE.TaskEither<ApprovioError, T>;
|
|
55
|
-
protected
|
|
56
|
-
|
|
57
|
-
listWorkflows(params?: ListWorkflowsParams): TE.TaskEither<ApprovioError, ListWorkflows200Response>;
|
|
58
|
-
createWorkflow(data: WorkflowCreate): TE.TaskEither<ApprovioError, void>;
|
|
59
|
-
voteOnWorkflow(workflowId: string, data: WorkflowVoteRequest): TE.TaskEither<ApprovioError, void>;
|
|
60
|
-
canVoteOnWorkflow(workflowId: string): TE.TaskEither<ApprovioError, CanVoteResponse>;
|
|
61
|
-
listRoleTemplates(): TE.TaskEither<ApprovioError, ListRoleTemplates200Response>;
|
|
62
|
-
getEntityInfo(): TE.TaskEither<ApprovioError, GetEntityInfo200Response>;
|
|
63
|
-
listVotes(workflowId: string, params?: ListWorkflowVotesParams): TE.TaskEither<ApprovioError, GetWorkflowVotes200Response>;
|
|
64
|
-
getAuthProviders(): TE.TaskEither<ApprovioError, AuthProvider[]>;
|
|
81
|
+
protected put<T>(url: string, data?: unknown, headers?: Record<string, string>): TE.TaskEither<ApprovioError, T>;
|
|
82
|
+
protected patch<T>(url: string, data?: unknown, headers?: Record<string, string>): TE.TaskEither<ApprovioError, T>;
|
|
83
|
+
protected delete<T>(url: string, data?: unknown, headers?: Record<string, string>): TE.TaskEither<ApprovioError, T>;
|
|
65
84
|
}
|
|
66
85
|
//#endregion
|
|
67
86
|
//#region src/auth/auth.helpers.d.ts
|
|
@@ -78,35 +97,62 @@ declare class AuthHelper {
|
|
|
78
97
|
//#endregion
|
|
79
98
|
//#region src/auth/agent.authenticator.d.ts
|
|
80
99
|
declare class AgentAuthenticator implements TokenBaseAuthenticator {
|
|
100
|
+
readonly organizationId: string;
|
|
81
101
|
private readonly privateKey;
|
|
82
102
|
private accessToken;
|
|
83
103
|
private refreshToken;
|
|
84
104
|
private readonly onTokenRefreshed?;
|
|
85
105
|
private readonly endpoint;
|
|
86
106
|
private readonly axios;
|
|
87
|
-
constructor(endpoint: string, privateKey: string, accessToken: string, refreshToken: string, onTokenRefreshed?: ((accessToken: string, refreshToken: string) => void) | undefined);
|
|
107
|
+
constructor(endpoint: string, organizationId: string, privateKey: string, accessToken: string, refreshToken: string, onTokenRefreshed?: ((accessToken: string, refreshToken: string) => void) | undefined);
|
|
88
108
|
customizeAxios(axios: AxiosInstance): void;
|
|
89
109
|
getAccessToken(): Promise<string>;
|
|
90
110
|
private renewToken;
|
|
91
111
|
private generateDpopProof;
|
|
92
112
|
}
|
|
93
113
|
//#endregion
|
|
114
|
+
//#region src/client/organization.client.d.ts
|
|
115
|
+
declare abstract class OrganizationClient extends BaseApprovioClient {
|
|
116
|
+
readonly organizationId: string;
|
|
117
|
+
constructor(config: ApprovioServerConfig, authenticator: Authenticator, organizationId: string);
|
|
118
|
+
protected organizationPath(path: string): string;
|
|
119
|
+
getWorkflow(workflowId: string, params?: GetWorkflowParams): TE.TaskEither<ApprovioError, Workflow>;
|
|
120
|
+
listWorkflows(params?: ListWorkflowsParams): TE.TaskEither<ApprovioError, ListWorkflows200Response>;
|
|
121
|
+
createWorkflow(data: WorkflowCreate): TE.TaskEither<ApprovioError, void>;
|
|
122
|
+
voteOnWorkflow(workflowId: string, data: WorkflowVoteRequest): TE.TaskEither<ApprovioError, void>;
|
|
123
|
+
canVoteOnWorkflow(workflowId: string): TE.TaskEither<ApprovioError, CanVoteResponse>;
|
|
124
|
+
listRoleTemplates(): TE.TaskEither<ApprovioError, ListRoleTemplates200Response>;
|
|
125
|
+
getEntityInfo(): TE.TaskEither<ApprovioError, GetEntityInfo200Response>;
|
|
126
|
+
listVotes(workflowId: string, params?: ListWorkflowVotesParams): TE.TaskEither<ApprovioError, GetWorkflowVotes200Response>;
|
|
127
|
+
generateAgentChallenge(data: AgentChallengeRequest): TE.TaskEither<ApprovioError, AgentChallengeResponse>;
|
|
128
|
+
exchangeAgentToken(data: AgentTokenRequest): TE.TaskEither<ApprovioError, AgentTokenResponse>;
|
|
129
|
+
initiateWebPrivilegeToken(): TE.TaskEither<ApprovioError, {
|
|
130
|
+
authorizationUrl: string;
|
|
131
|
+
}>;
|
|
132
|
+
exchangeWebPrivilegeToken(data: PrivilegedTokenExchangeRequest): TE.TaskEither<ApprovioError, void>;
|
|
133
|
+
exchangeCliPrivilegeToken(data: PrivilegedTokenExchangeRequest): TE.TaskEither<ApprovioError, PrivilegedTokenResponse>;
|
|
134
|
+
}
|
|
135
|
+
//#endregion
|
|
94
136
|
//#region src/client/user.client.d.ts
|
|
95
|
-
|
|
137
|
+
interface GetOrganizationUsageParams {
|
|
138
|
+
period?: string;
|
|
139
|
+
metric?: string;
|
|
140
|
+
}
|
|
141
|
+
declare class ApprovioUserClient extends OrganizationClient {
|
|
96
142
|
readonly authenticator: CliUserAuthenticator | WebAuthenticator;
|
|
97
|
-
constructor(config: ApprovioServerConfig, authenticator: CliUserAuthenticator | WebAuthenticator);
|
|
143
|
+
constructor(config: ApprovioServerConfig, authenticator: CliUserAuthenticator | WebAuthenticator, organizationId: string);
|
|
98
144
|
listUsers(params?: ListUsersParams): TE.TaskEither<ApprovioError, ListUsers200Response>;
|
|
99
145
|
registerAgent(data: AgentRegistrationRequest): TE.TaskEither<ApprovioError, AgentRegistrationResponse>;
|
|
100
|
-
assignAgentRoles(agentId: string, data: RoleAssignmentRequest): TE.TaskEither<ApprovioError, void>;
|
|
101
|
-
removeAgentRoles(agentId: string, data: RoleRemovalRequest): TE.TaskEither<ApprovioError, void>;
|
|
146
|
+
assignAgentRoles(agentId: string, data: RoleAssignmentRequest, etag: string): TE.TaskEither<ApprovioError, void>;
|
|
147
|
+
removeAgentRoles(agentId: string, data: RoleRemovalRequest, etag: string): TE.TaskEither<ApprovioError, void>;
|
|
102
148
|
createUser(data: UserCreate): TE.TaskEither<ApprovioError, string>;
|
|
103
149
|
getUser(userId: string): TE.TaskEither<ApprovioError, User>;
|
|
104
|
-
assignUserRoles(userId: string, data: RoleAssignmentRequest): TE.TaskEither<ApprovioError, void>;
|
|
105
|
-
removeUserRoles(userId: string, data: RoleRemovalRequest): TE.TaskEither<ApprovioError, void>;
|
|
150
|
+
assignUserRoles(userId: string, data: RoleAssignmentRequest, etag: string): TE.TaskEither<ApprovioError, void>;
|
|
151
|
+
removeUserRoles(userId: string, data: RoleRemovalRequest, etag: string): TE.TaskEither<ApprovioError, void>;
|
|
106
152
|
createWorkflowTemplate(data: WorkflowTemplateCreate): TE.TaskEither<ApprovioError, WorkflowTemplate>;
|
|
107
153
|
listWorkflowTemplates(request?: ListWorkflowTemplatesParams): TE.TaskEither<ApprovioError, ListWorkflowTemplates200Response>;
|
|
108
154
|
getWorkflowTemplate(templateIdentifier: string): TE.TaskEither<ApprovioError, WorkflowTemplate>;
|
|
109
|
-
updateWorkflowTemplate(templateIdentifier: string, data: WorkflowTemplateUpdate): TE.TaskEither<ApprovioError, WorkflowTemplate>;
|
|
155
|
+
updateWorkflowTemplate(templateIdentifier: string, data: WorkflowTemplateUpdate, etag: string): TE.TaskEither<ApprovioError, WorkflowTemplate>;
|
|
110
156
|
deprecateWorkflowTemplate(templateName: string, data?: WorkflowTemplateDeprecate): TE.TaskEither<ApprovioError, WorkflowTemplate>;
|
|
111
157
|
createGroup(data: GroupCreate): TE.TaskEither<ApprovioError, string>;
|
|
112
158
|
listGroups(params?: ListGroupsParams): TE.TaskEither<ApprovioError, ListGroups200Response>;
|
|
@@ -121,29 +167,55 @@ declare class ApprovioUserClient extends BaseApprovioClient {
|
|
|
121
167
|
listSpaces(params?: ListSpacesParams): TE.TaskEither<ApprovioError, ListSpaces200Response>;
|
|
122
168
|
getSpace(spaceId: string): TE.TaskEither<ApprovioError, Space>;
|
|
123
169
|
deleteSpace(spaceId: string): TE.TaskEither<ApprovioError, void>;
|
|
124
|
-
addOrganizationAdminToOrg(organizationName: string, data: OrganizationAdminCreate): TE.TaskEither<ApprovioError, void>;
|
|
125
|
-
listOrganizationAdminsForOrg(organizationName: string, params?: {
|
|
126
|
-
page?: number;
|
|
127
|
-
limit?: number;
|
|
128
|
-
}): TE.TaskEither<ApprovioError, ListOrganizationAdminsForOrg200Response>;
|
|
129
|
-
removeOrganizationAdminFromOrg(organizationName: string, data: OrganizationAdminRemove): TE.TaskEither<ApprovioError, void>;
|
|
130
170
|
getAgent(agentId: string): TE.TaskEither<ApprovioError, AgentGet200Response>;
|
|
131
171
|
getEntityInfo(): TE.TaskEither<ApprovioError, GetEntityInfoUserResponse>;
|
|
132
172
|
listAuditLogs(params?: ListAuditLogsParams): TE.TaskEither<ApprovioError, ListAuditLogs200Response>;
|
|
133
173
|
listMyAuditLogs(params?: ListMyAuditLogsParams): TE.TaskEither<ApprovioError, ListAuditLogs200Response>;
|
|
134
174
|
resolveResources(params: ResourceResolveRequest): TE.TaskEither<ApprovioError, ResourceResolveResponse>;
|
|
175
|
+
getOrganizationEntitlements(): TE.TaskEither<ApprovioError, OrganizationEntitlementsResponse>;
|
|
176
|
+
getOrganizationUsage(params?: GetOrganizationUsageParams): TE.TaskEither<ApprovioError, OrganizationUsageResponse>;
|
|
177
|
+
getOrganization(): TE.TaskEither<ApprovioError, OrganizationSummary>;
|
|
178
|
+
updateOrganization(data: OrganizationUpdate, etag: string): TE.TaskEither<ApprovioError, OrganizationSummary>;
|
|
179
|
+
deleteOrganization(etag: string): TE.TaskEither<ApprovioError, OrganizationSummary>;
|
|
180
|
+
suspendOrganization(etag: string): TE.TaskEither<ApprovioError, OrganizationSummary>;
|
|
181
|
+
resumeOrganization(etag: string): TE.TaskEither<ApprovioError, OrganizationSummary>;
|
|
182
|
+
listMembers(params?: {
|
|
183
|
+
page?: number;
|
|
184
|
+
limit?: number;
|
|
185
|
+
}): TE.TaskEither<ApprovioError, MembershipList>;
|
|
186
|
+
changeMemberRole(membershipId: string, data: MembershipRoleUpdate, etag: string): TE.TaskEither<ApprovioError, Membership>;
|
|
187
|
+
removeMember(membershipId: string, etag: string): TE.TaskEither<ApprovioError, void>;
|
|
188
|
+
createInvitation(data: InvitationCreate): TE.TaskEither<ApprovioError, InvitationCreated>;
|
|
189
|
+
revokeInvitation(invitationId: string): TE.TaskEither<ApprovioError, void>;
|
|
190
|
+
acceptInvitation(invitationId: string, data: InvitationAccept): TE.TaskEither<ApprovioError, Membership>;
|
|
135
191
|
logout(): TE.TaskEither<ApprovioError, void>;
|
|
136
192
|
}
|
|
137
193
|
//#endregion
|
|
138
194
|
//#region src/client/agent.client.d.ts
|
|
139
|
-
declare class ApprovioAgentClient extends
|
|
195
|
+
declare class ApprovioAgentClient extends OrganizationClient {
|
|
140
196
|
readonly authenticator: AgentAuthenticator;
|
|
141
197
|
constructor(config: ApprovioServerConfig, authenticator: AgentAuthenticator);
|
|
142
198
|
getAuthenticator(): Authenticator;
|
|
143
199
|
getEntityInfo(): TE.TaskEither<ApprovioError, GetEntityInfoAgentResponse>;
|
|
144
200
|
}
|
|
145
201
|
//#endregion
|
|
202
|
+
//#region src/client/platform.client.d.ts
|
|
203
|
+
declare class ApprovioPlatformClient extends BaseApprovioClient {
|
|
204
|
+
constructor(config: ApprovioServerConfig, authenticator: Authenticator);
|
|
205
|
+
getAuthProviders(): TE.TaskEither<ApprovioError, AuthProvider[]>;
|
|
206
|
+
getOwnAccount(): TE.TaskEither<ApprovioError, Account>;
|
|
207
|
+
listOwnOrganizations(params?: {
|
|
208
|
+
page?: number;
|
|
209
|
+
limit?: number;
|
|
210
|
+
}): TE.TaskEither<ApprovioError, OrganizationList>;
|
|
211
|
+
createOrganization(data: OrganizationCreate): TE.TaskEither<ApprovioError, OrganizationCreateResponse>;
|
|
212
|
+
getWebSession(): TE.TaskEither<ApprovioError, Versioned<WebSessionContext>>;
|
|
213
|
+
switchWebOrganization(data: WebOrganizationSwitch, etag: string): TE.TaskEither<ApprovioError, Versioned<WebSessionContext>>;
|
|
214
|
+
selectCliOrganization(data: CliOrganizationSelection): TE.TaskEither<ApprovioError, TokenResponse>;
|
|
215
|
+
logout(): TE.TaskEither<ApprovioError, void>;
|
|
216
|
+
}
|
|
217
|
+
//#endregion
|
|
146
218
|
//#region src/client/utils.d.ts
|
|
147
219
|
declare function isApprovioError(data: unknown): data is APIError;
|
|
148
220
|
//#endregion
|
|
149
|
-
export { AgentAuthenticator, ApprovioAgentClient, ApprovioError, ApprovioServerConfig, ApprovioUserClient, AuthHelper, Authenticator, BaseApprovioClient, CliUserAuthenticator, SafeQueryParams, TokenBaseAuthenticator, WebAuthenticator, isApprovioError };
|
|
221
|
+
export { AgentAuthenticator, ApprovioAgentClient, ApprovioError, ApprovioPlatformClient, ApprovioServerConfig, ApprovioUserClient, AuthHelper, Authenticator, BaseApprovioClient, CliUserAuthenticator, GetOrganizationUsageParams, LocationNotFoundError, NetworkError, OrganizationClient, OrganizationContextChangedError, OrganizationSuspendedError, SafeQueryParams, TokenBaseAuthenticator, UnexpectedEntityTypeError, Versioned, WebAuthenticator, isApprovioError };
|
package/dist/index.d.mts
CHANGED
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import { APIError, AddGroupEntitiesRequest, AgentGet200Response, AgentRegistrationRequest, AgentRegistrationResponse, AgentTokenResponse, AuthProvider, CanVoteResponse, GetEntityInfo200Response, GetEntityInfoAgentResponse, GetEntityInfoUserResponse, GetWorkflowParams, GetWorkflowVotes200Response, Group, GroupCreate, ListAuditLogs200Response, ListAuditLogsParams, ListGroupEntities200Response, ListGroups200Response, ListGroupsParams, ListMyAuditLogsParams,
|
|
1
|
+
import { APIError, Account, AddGroupEntitiesRequest, AgentChallengeRequest, AgentChallengeResponse, AgentGet200Response, AgentRegistrationRequest, AgentRegistrationResponse, AgentTokenRequest, AgentTokenResponse, AuthProvider, CanVoteResponse, CliOrganizationSelection, GetEntityInfo200Response, GetEntityInfoAgentResponse, GetEntityInfoUserResponse, GetWorkflowParams, GetWorkflowVotes200Response, Group, GroupCreate, InvitationAccept, InvitationCreate, InvitationCreated, ListAuditLogs200Response, ListAuditLogsParams, ListGroupEntities200Response, ListGroups200Response, ListGroupsParams, ListMyAuditLogsParams, ListRoleTemplates200Response, ListSpaces200Response, ListSpacesParams, ListUsers200Response, ListUsersParams, ListWorkflowTemplates200Response, ListWorkflowTemplatesParams, ListWorkflowVotesParams, ListWorkflows200Response, ListWorkflowsParams, Membership, MembershipList, MembershipRoleUpdate, OrganizationCreate, OrganizationCreateResponse, OrganizationEntitlementsResponse, OrganizationList, OrganizationSummary, OrganizationUpdate, OrganizationUsageResponse, PrivilegedTokenExchangeRequest, PrivilegedTokenResponse, RemoveGroupEntitiesRequest, ResourceResolveRequest, ResourceResolveResponse, RoleAssignmentRequest, RoleRemovalRequest, Space, SpaceCreate, TokenResponse, User, UserCreate, WebOrganizationSwitch, WebSessionContext, Workflow, WorkflowCreate, WorkflowTemplate, WorkflowTemplateCreate, WorkflowTemplateDeprecate, WorkflowTemplateUpdate, WorkflowVoteRequest } from "@approvio/api";
|
|
2
2
|
import { AxiosInstance } from "axios";
|
|
3
3
|
import * as TE from "fp-ts/lib/TaskEither.js";
|
|
4
4
|
|
|
@@ -32,13 +32,38 @@ declare class WebAuthenticator implements Authenticator {
|
|
|
32
32
|
customizeAxios(axios: AxiosInstance): void;
|
|
33
33
|
}
|
|
34
34
|
//#endregion
|
|
35
|
+
//#region src/client/errors.d.ts
|
|
36
|
+
declare class LocationNotFoundError extends Error {
|
|
37
|
+
constructor();
|
|
38
|
+
}
|
|
39
|
+
declare class NetworkError extends Error {
|
|
40
|
+
constructor(message: string);
|
|
41
|
+
}
|
|
42
|
+
declare class UnexpectedEntityTypeError extends Error {
|
|
43
|
+
readonly expected: string;
|
|
44
|
+
readonly received: string;
|
|
45
|
+
constructor(expected: string, received: string);
|
|
46
|
+
}
|
|
47
|
+
declare class OrganizationContextChangedError extends Error {
|
|
48
|
+
readonly status: number;
|
|
49
|
+
constructor(status: number, message: string);
|
|
50
|
+
}
|
|
51
|
+
declare class OrganizationSuspendedError extends Error {
|
|
52
|
+
readonly status: number;
|
|
53
|
+
constructor(status: number, message: string);
|
|
54
|
+
}
|
|
55
|
+
//#endregion
|
|
35
56
|
//#region src/client/base.client.d.ts
|
|
36
57
|
type SerializablePrimitive = string | number | boolean | null | undefined;
|
|
37
58
|
type SerializableValue = SerializablePrimitive | SerializablePrimitive[];
|
|
38
59
|
type SafeQueryParams<T> = { [K in keyof T]: T[K] extends SerializableValue ? T[K] : never };
|
|
39
60
|
type ApprovioError = (APIError & {
|
|
40
61
|
status: number;
|
|
41
|
-
}) | Error;
|
|
62
|
+
}) | OrganizationContextChangedError | OrganizationSuspendedError | Error;
|
|
63
|
+
interface Versioned<T> {
|
|
64
|
+
data: T;
|
|
65
|
+
etag: string;
|
|
66
|
+
}
|
|
42
67
|
declare abstract class BaseApprovioClient {
|
|
43
68
|
protected readonly config: ApprovioServerConfig;
|
|
44
69
|
protected readonly authenticator: Authenticator;
|
|
@@ -46,22 +71,16 @@ declare abstract class BaseApprovioClient {
|
|
|
46
71
|
constructor(config: ApprovioServerConfig, authenticator: Authenticator);
|
|
47
72
|
protected handleError(error: unknown): ApprovioError;
|
|
48
73
|
protected get<Response, Params extends SafeQueryParams<Params> = Record<string, SerializableValue>>(url: string, params?: Params): TE.TaskEither<ApprovioError, Response>;
|
|
49
|
-
protected
|
|
74
|
+
protected getVersioned<Response, Params extends SafeQueryParams<Params> = Record<string, SerializableValue>>(url: string, params?: Params): TE.TaskEither<ApprovioError, Versioned<Response>>;
|
|
75
|
+
protected post<T>(url: string, data?: unknown, headers?: Record<string, string>): TE.TaskEither<ApprovioError, T>;
|
|
76
|
+
protected postVersioned<T>(url: string, data: unknown, headers?: Record<string, string>): TE.TaskEither<ApprovioError, Versioned<T>>;
|
|
50
77
|
protected postWithLocation<T>(url: string, data?: unknown): TE.TaskEither<ApprovioError, {
|
|
51
78
|
data: T;
|
|
52
79
|
location: string;
|
|
53
80
|
}>;
|
|
54
|
-
protected put<T>(url: string, data?: unknown): TE.TaskEither<ApprovioError, T>;
|
|
55
|
-
protected
|
|
56
|
-
|
|
57
|
-
listWorkflows(params?: ListWorkflowsParams): TE.TaskEither<ApprovioError, ListWorkflows200Response>;
|
|
58
|
-
createWorkflow(data: WorkflowCreate): TE.TaskEither<ApprovioError, void>;
|
|
59
|
-
voteOnWorkflow(workflowId: string, data: WorkflowVoteRequest): TE.TaskEither<ApprovioError, void>;
|
|
60
|
-
canVoteOnWorkflow(workflowId: string): TE.TaskEither<ApprovioError, CanVoteResponse>;
|
|
61
|
-
listRoleTemplates(): TE.TaskEither<ApprovioError, ListRoleTemplates200Response>;
|
|
62
|
-
getEntityInfo(): TE.TaskEither<ApprovioError, GetEntityInfo200Response>;
|
|
63
|
-
listVotes(workflowId: string, params?: ListWorkflowVotesParams): TE.TaskEither<ApprovioError, GetWorkflowVotes200Response>;
|
|
64
|
-
getAuthProviders(): TE.TaskEither<ApprovioError, AuthProvider[]>;
|
|
81
|
+
protected put<T>(url: string, data?: unknown, headers?: Record<string, string>): TE.TaskEither<ApprovioError, T>;
|
|
82
|
+
protected patch<T>(url: string, data?: unknown, headers?: Record<string, string>): TE.TaskEither<ApprovioError, T>;
|
|
83
|
+
protected delete<T>(url: string, data?: unknown, headers?: Record<string, string>): TE.TaskEither<ApprovioError, T>;
|
|
65
84
|
}
|
|
66
85
|
//#endregion
|
|
67
86
|
//#region src/auth/auth.helpers.d.ts
|
|
@@ -78,35 +97,62 @@ declare class AuthHelper {
|
|
|
78
97
|
//#endregion
|
|
79
98
|
//#region src/auth/agent.authenticator.d.ts
|
|
80
99
|
declare class AgentAuthenticator implements TokenBaseAuthenticator {
|
|
100
|
+
readonly organizationId: string;
|
|
81
101
|
private readonly privateKey;
|
|
82
102
|
private accessToken;
|
|
83
103
|
private refreshToken;
|
|
84
104
|
private readonly onTokenRefreshed?;
|
|
85
105
|
private readonly endpoint;
|
|
86
106
|
private readonly axios;
|
|
87
|
-
constructor(endpoint: string, privateKey: string, accessToken: string, refreshToken: string, onTokenRefreshed?: ((accessToken: string, refreshToken: string) => void) | undefined);
|
|
107
|
+
constructor(endpoint: string, organizationId: string, privateKey: string, accessToken: string, refreshToken: string, onTokenRefreshed?: ((accessToken: string, refreshToken: string) => void) | undefined);
|
|
88
108
|
customizeAxios(axios: AxiosInstance): void;
|
|
89
109
|
getAccessToken(): Promise<string>;
|
|
90
110
|
private renewToken;
|
|
91
111
|
private generateDpopProof;
|
|
92
112
|
}
|
|
93
113
|
//#endregion
|
|
114
|
+
//#region src/client/organization.client.d.ts
|
|
115
|
+
declare abstract class OrganizationClient extends BaseApprovioClient {
|
|
116
|
+
readonly organizationId: string;
|
|
117
|
+
constructor(config: ApprovioServerConfig, authenticator: Authenticator, organizationId: string);
|
|
118
|
+
protected organizationPath(path: string): string;
|
|
119
|
+
getWorkflow(workflowId: string, params?: GetWorkflowParams): TE.TaskEither<ApprovioError, Workflow>;
|
|
120
|
+
listWorkflows(params?: ListWorkflowsParams): TE.TaskEither<ApprovioError, ListWorkflows200Response>;
|
|
121
|
+
createWorkflow(data: WorkflowCreate): TE.TaskEither<ApprovioError, void>;
|
|
122
|
+
voteOnWorkflow(workflowId: string, data: WorkflowVoteRequest): TE.TaskEither<ApprovioError, void>;
|
|
123
|
+
canVoteOnWorkflow(workflowId: string): TE.TaskEither<ApprovioError, CanVoteResponse>;
|
|
124
|
+
listRoleTemplates(): TE.TaskEither<ApprovioError, ListRoleTemplates200Response>;
|
|
125
|
+
getEntityInfo(): TE.TaskEither<ApprovioError, GetEntityInfo200Response>;
|
|
126
|
+
listVotes(workflowId: string, params?: ListWorkflowVotesParams): TE.TaskEither<ApprovioError, GetWorkflowVotes200Response>;
|
|
127
|
+
generateAgentChallenge(data: AgentChallengeRequest): TE.TaskEither<ApprovioError, AgentChallengeResponse>;
|
|
128
|
+
exchangeAgentToken(data: AgentTokenRequest): TE.TaskEither<ApprovioError, AgentTokenResponse>;
|
|
129
|
+
initiateWebPrivilegeToken(): TE.TaskEither<ApprovioError, {
|
|
130
|
+
authorizationUrl: string;
|
|
131
|
+
}>;
|
|
132
|
+
exchangeWebPrivilegeToken(data: PrivilegedTokenExchangeRequest): TE.TaskEither<ApprovioError, void>;
|
|
133
|
+
exchangeCliPrivilegeToken(data: PrivilegedTokenExchangeRequest): TE.TaskEither<ApprovioError, PrivilegedTokenResponse>;
|
|
134
|
+
}
|
|
135
|
+
//#endregion
|
|
94
136
|
//#region src/client/user.client.d.ts
|
|
95
|
-
|
|
137
|
+
interface GetOrganizationUsageParams {
|
|
138
|
+
period?: string;
|
|
139
|
+
metric?: string;
|
|
140
|
+
}
|
|
141
|
+
declare class ApprovioUserClient extends OrganizationClient {
|
|
96
142
|
readonly authenticator: CliUserAuthenticator | WebAuthenticator;
|
|
97
|
-
constructor(config: ApprovioServerConfig, authenticator: CliUserAuthenticator | WebAuthenticator);
|
|
143
|
+
constructor(config: ApprovioServerConfig, authenticator: CliUserAuthenticator | WebAuthenticator, organizationId: string);
|
|
98
144
|
listUsers(params?: ListUsersParams): TE.TaskEither<ApprovioError, ListUsers200Response>;
|
|
99
145
|
registerAgent(data: AgentRegistrationRequest): TE.TaskEither<ApprovioError, AgentRegistrationResponse>;
|
|
100
|
-
assignAgentRoles(agentId: string, data: RoleAssignmentRequest): TE.TaskEither<ApprovioError, void>;
|
|
101
|
-
removeAgentRoles(agentId: string, data: RoleRemovalRequest): TE.TaskEither<ApprovioError, void>;
|
|
146
|
+
assignAgentRoles(agentId: string, data: RoleAssignmentRequest, etag: string): TE.TaskEither<ApprovioError, void>;
|
|
147
|
+
removeAgentRoles(agentId: string, data: RoleRemovalRequest, etag: string): TE.TaskEither<ApprovioError, void>;
|
|
102
148
|
createUser(data: UserCreate): TE.TaskEither<ApprovioError, string>;
|
|
103
149
|
getUser(userId: string): TE.TaskEither<ApprovioError, User>;
|
|
104
|
-
assignUserRoles(userId: string, data: RoleAssignmentRequest): TE.TaskEither<ApprovioError, void>;
|
|
105
|
-
removeUserRoles(userId: string, data: RoleRemovalRequest): TE.TaskEither<ApprovioError, void>;
|
|
150
|
+
assignUserRoles(userId: string, data: RoleAssignmentRequest, etag: string): TE.TaskEither<ApprovioError, void>;
|
|
151
|
+
removeUserRoles(userId: string, data: RoleRemovalRequest, etag: string): TE.TaskEither<ApprovioError, void>;
|
|
106
152
|
createWorkflowTemplate(data: WorkflowTemplateCreate): TE.TaskEither<ApprovioError, WorkflowTemplate>;
|
|
107
153
|
listWorkflowTemplates(request?: ListWorkflowTemplatesParams): TE.TaskEither<ApprovioError, ListWorkflowTemplates200Response>;
|
|
108
154
|
getWorkflowTemplate(templateIdentifier: string): TE.TaskEither<ApprovioError, WorkflowTemplate>;
|
|
109
|
-
updateWorkflowTemplate(templateIdentifier: string, data: WorkflowTemplateUpdate): TE.TaskEither<ApprovioError, WorkflowTemplate>;
|
|
155
|
+
updateWorkflowTemplate(templateIdentifier: string, data: WorkflowTemplateUpdate, etag: string): TE.TaskEither<ApprovioError, WorkflowTemplate>;
|
|
110
156
|
deprecateWorkflowTemplate(templateName: string, data?: WorkflowTemplateDeprecate): TE.TaskEither<ApprovioError, WorkflowTemplate>;
|
|
111
157
|
createGroup(data: GroupCreate): TE.TaskEither<ApprovioError, string>;
|
|
112
158
|
listGroups(params?: ListGroupsParams): TE.TaskEither<ApprovioError, ListGroups200Response>;
|
|
@@ -121,29 +167,55 @@ declare class ApprovioUserClient extends BaseApprovioClient {
|
|
|
121
167
|
listSpaces(params?: ListSpacesParams): TE.TaskEither<ApprovioError, ListSpaces200Response>;
|
|
122
168
|
getSpace(spaceId: string): TE.TaskEither<ApprovioError, Space>;
|
|
123
169
|
deleteSpace(spaceId: string): TE.TaskEither<ApprovioError, void>;
|
|
124
|
-
addOrganizationAdminToOrg(organizationName: string, data: OrganizationAdminCreate): TE.TaskEither<ApprovioError, void>;
|
|
125
|
-
listOrganizationAdminsForOrg(organizationName: string, params?: {
|
|
126
|
-
page?: number;
|
|
127
|
-
limit?: number;
|
|
128
|
-
}): TE.TaskEither<ApprovioError, ListOrganizationAdminsForOrg200Response>;
|
|
129
|
-
removeOrganizationAdminFromOrg(organizationName: string, data: OrganizationAdminRemove): TE.TaskEither<ApprovioError, void>;
|
|
130
170
|
getAgent(agentId: string): TE.TaskEither<ApprovioError, AgentGet200Response>;
|
|
131
171
|
getEntityInfo(): TE.TaskEither<ApprovioError, GetEntityInfoUserResponse>;
|
|
132
172
|
listAuditLogs(params?: ListAuditLogsParams): TE.TaskEither<ApprovioError, ListAuditLogs200Response>;
|
|
133
173
|
listMyAuditLogs(params?: ListMyAuditLogsParams): TE.TaskEither<ApprovioError, ListAuditLogs200Response>;
|
|
134
174
|
resolveResources(params: ResourceResolveRequest): TE.TaskEither<ApprovioError, ResourceResolveResponse>;
|
|
175
|
+
getOrganizationEntitlements(): TE.TaskEither<ApprovioError, OrganizationEntitlementsResponse>;
|
|
176
|
+
getOrganizationUsage(params?: GetOrganizationUsageParams): TE.TaskEither<ApprovioError, OrganizationUsageResponse>;
|
|
177
|
+
getOrganization(): TE.TaskEither<ApprovioError, OrganizationSummary>;
|
|
178
|
+
updateOrganization(data: OrganizationUpdate, etag: string): TE.TaskEither<ApprovioError, OrganizationSummary>;
|
|
179
|
+
deleteOrganization(etag: string): TE.TaskEither<ApprovioError, OrganizationSummary>;
|
|
180
|
+
suspendOrganization(etag: string): TE.TaskEither<ApprovioError, OrganizationSummary>;
|
|
181
|
+
resumeOrganization(etag: string): TE.TaskEither<ApprovioError, OrganizationSummary>;
|
|
182
|
+
listMembers(params?: {
|
|
183
|
+
page?: number;
|
|
184
|
+
limit?: number;
|
|
185
|
+
}): TE.TaskEither<ApprovioError, MembershipList>;
|
|
186
|
+
changeMemberRole(membershipId: string, data: MembershipRoleUpdate, etag: string): TE.TaskEither<ApprovioError, Membership>;
|
|
187
|
+
removeMember(membershipId: string, etag: string): TE.TaskEither<ApprovioError, void>;
|
|
188
|
+
createInvitation(data: InvitationCreate): TE.TaskEither<ApprovioError, InvitationCreated>;
|
|
189
|
+
revokeInvitation(invitationId: string): TE.TaskEither<ApprovioError, void>;
|
|
190
|
+
acceptInvitation(invitationId: string, data: InvitationAccept): TE.TaskEither<ApprovioError, Membership>;
|
|
135
191
|
logout(): TE.TaskEither<ApprovioError, void>;
|
|
136
192
|
}
|
|
137
193
|
//#endregion
|
|
138
194
|
//#region src/client/agent.client.d.ts
|
|
139
|
-
declare class ApprovioAgentClient extends
|
|
195
|
+
declare class ApprovioAgentClient extends OrganizationClient {
|
|
140
196
|
readonly authenticator: AgentAuthenticator;
|
|
141
197
|
constructor(config: ApprovioServerConfig, authenticator: AgentAuthenticator);
|
|
142
198
|
getAuthenticator(): Authenticator;
|
|
143
199
|
getEntityInfo(): TE.TaskEither<ApprovioError, GetEntityInfoAgentResponse>;
|
|
144
200
|
}
|
|
145
201
|
//#endregion
|
|
202
|
+
//#region src/client/platform.client.d.ts
|
|
203
|
+
declare class ApprovioPlatformClient extends BaseApprovioClient {
|
|
204
|
+
constructor(config: ApprovioServerConfig, authenticator: Authenticator);
|
|
205
|
+
getAuthProviders(): TE.TaskEither<ApprovioError, AuthProvider[]>;
|
|
206
|
+
getOwnAccount(): TE.TaskEither<ApprovioError, Account>;
|
|
207
|
+
listOwnOrganizations(params?: {
|
|
208
|
+
page?: number;
|
|
209
|
+
limit?: number;
|
|
210
|
+
}): TE.TaskEither<ApprovioError, OrganizationList>;
|
|
211
|
+
createOrganization(data: OrganizationCreate): TE.TaskEither<ApprovioError, OrganizationCreateResponse>;
|
|
212
|
+
getWebSession(): TE.TaskEither<ApprovioError, Versioned<WebSessionContext>>;
|
|
213
|
+
switchWebOrganization(data: WebOrganizationSwitch, etag: string): TE.TaskEither<ApprovioError, Versioned<WebSessionContext>>;
|
|
214
|
+
selectCliOrganization(data: CliOrganizationSelection): TE.TaskEither<ApprovioError, TokenResponse>;
|
|
215
|
+
logout(): TE.TaskEither<ApprovioError, void>;
|
|
216
|
+
}
|
|
217
|
+
//#endregion
|
|
146
218
|
//#region src/client/utils.d.ts
|
|
147
219
|
declare function isApprovioError(data: unknown): data is APIError;
|
|
148
220
|
//#endregion
|
|
149
|
-
export { AgentAuthenticator, ApprovioAgentClient, ApprovioError, ApprovioServerConfig, ApprovioUserClient, AuthHelper, Authenticator, BaseApprovioClient, CliUserAuthenticator, SafeQueryParams, TokenBaseAuthenticator, WebAuthenticator, isApprovioError };
|
|
221
|
+
export { AgentAuthenticator, ApprovioAgentClient, ApprovioError, ApprovioPlatformClient, ApprovioServerConfig, ApprovioUserClient, AuthHelper, Authenticator, BaseApprovioClient, CliUserAuthenticator, GetOrganizationUsageParams, LocationNotFoundError, NetworkError, OrganizationClient, OrganizationContextChangedError, OrganizationSuspendedError, SafeQueryParams, TokenBaseAuthenticator, UnexpectedEntityTypeError, Versioned, WebAuthenticator, isApprovioError };
|