@approvio/ts-sdk 0.0.28 → 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 +218 -104
- package/dist/index.d.cts +98 -32
- package/dist/index.d.mts +98 -32
- package/dist/index.mjs +212 -105
- package/package.json +2 -2
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,39 +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 {
|
|
96
138
|
period?: string;
|
|
97
139
|
metric?: string;
|
|
98
140
|
}
|
|
99
|
-
declare class ApprovioUserClient extends
|
|
141
|
+
declare class ApprovioUserClient extends OrganizationClient {
|
|
100
142
|
readonly authenticator: CliUserAuthenticator | WebAuthenticator;
|
|
101
|
-
constructor(config: ApprovioServerConfig, authenticator: CliUserAuthenticator | WebAuthenticator);
|
|
143
|
+
constructor(config: ApprovioServerConfig, authenticator: CliUserAuthenticator | WebAuthenticator, organizationId: string);
|
|
102
144
|
listUsers(params?: ListUsersParams): TE.TaskEither<ApprovioError, ListUsers200Response>;
|
|
103
145
|
registerAgent(data: AgentRegistrationRequest): TE.TaskEither<ApprovioError, AgentRegistrationResponse>;
|
|
104
|
-
assignAgentRoles(agentId: string, data: RoleAssignmentRequest): TE.TaskEither<ApprovioError, void>;
|
|
105
|
-
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>;
|
|
106
148
|
createUser(data: UserCreate): TE.TaskEither<ApprovioError, string>;
|
|
107
149
|
getUser(userId: string): TE.TaskEither<ApprovioError, User>;
|
|
108
|
-
assignUserRoles(userId: string, data: RoleAssignmentRequest): TE.TaskEither<ApprovioError, void>;
|
|
109
|
-
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>;
|
|
110
152
|
createWorkflowTemplate(data: WorkflowTemplateCreate): TE.TaskEither<ApprovioError, WorkflowTemplate>;
|
|
111
153
|
listWorkflowTemplates(request?: ListWorkflowTemplatesParams): TE.TaskEither<ApprovioError, ListWorkflowTemplates200Response>;
|
|
112
154
|
getWorkflowTemplate(templateIdentifier: string): TE.TaskEither<ApprovioError, WorkflowTemplate>;
|
|
113
|
-
updateWorkflowTemplate(templateIdentifier: string, data: WorkflowTemplateUpdate): TE.TaskEither<ApprovioError, WorkflowTemplate>;
|
|
155
|
+
updateWorkflowTemplate(templateIdentifier: string, data: WorkflowTemplateUpdate, etag: string): TE.TaskEither<ApprovioError, WorkflowTemplate>;
|
|
114
156
|
deprecateWorkflowTemplate(templateName: string, data?: WorkflowTemplateDeprecate): TE.TaskEither<ApprovioError, WorkflowTemplate>;
|
|
115
157
|
createGroup(data: GroupCreate): TE.TaskEither<ApprovioError, string>;
|
|
116
158
|
listGroups(params?: ListGroupsParams): TE.TaskEither<ApprovioError, ListGroups200Response>;
|
|
@@ -125,31 +167,55 @@ declare class ApprovioUserClient extends BaseApprovioClient {
|
|
|
125
167
|
listSpaces(params?: ListSpacesParams): TE.TaskEither<ApprovioError, ListSpaces200Response>;
|
|
126
168
|
getSpace(spaceId: string): TE.TaskEither<ApprovioError, Space>;
|
|
127
169
|
deleteSpace(spaceId: string): TE.TaskEither<ApprovioError, void>;
|
|
128
|
-
addOrganizationAdminToOrg(organizationName: string, data: OrganizationAdminCreate): TE.TaskEither<ApprovioError, void>;
|
|
129
|
-
listOrganizationAdminsForOrg(organizationName: string, params?: {
|
|
130
|
-
page?: number;
|
|
131
|
-
limit?: number;
|
|
132
|
-
}): TE.TaskEither<ApprovioError, ListOrganizationAdminsForOrg200Response>;
|
|
133
|
-
removeOrganizationAdminFromOrg(organizationName: string, data: OrganizationAdminRemove): TE.TaskEither<ApprovioError, void>;
|
|
134
170
|
getAgent(agentId: string): TE.TaskEither<ApprovioError, AgentGet200Response>;
|
|
135
171
|
getEntityInfo(): TE.TaskEither<ApprovioError, GetEntityInfoUserResponse>;
|
|
136
172
|
listAuditLogs(params?: ListAuditLogsParams): TE.TaskEither<ApprovioError, ListAuditLogs200Response>;
|
|
137
173
|
listMyAuditLogs(params?: ListMyAuditLogsParams): TE.TaskEither<ApprovioError, ListAuditLogs200Response>;
|
|
138
174
|
resolveResources(params: ResourceResolveRequest): TE.TaskEither<ApprovioError, ResourceResolveResponse>;
|
|
139
|
-
getOrganizationEntitlements(
|
|
140
|
-
getOrganizationUsage(
|
|
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>;
|
|
141
191
|
logout(): TE.TaskEither<ApprovioError, void>;
|
|
142
192
|
}
|
|
143
193
|
//#endregion
|
|
144
194
|
//#region src/client/agent.client.d.ts
|
|
145
|
-
declare class ApprovioAgentClient extends
|
|
195
|
+
declare class ApprovioAgentClient extends OrganizationClient {
|
|
146
196
|
readonly authenticator: AgentAuthenticator;
|
|
147
197
|
constructor(config: ApprovioServerConfig, authenticator: AgentAuthenticator);
|
|
148
198
|
getAuthenticator(): Authenticator;
|
|
149
199
|
getEntityInfo(): TE.TaskEither<ApprovioError, GetEntityInfoAgentResponse>;
|
|
150
200
|
}
|
|
151
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
|
|
152
218
|
//#region src/client/utils.d.ts
|
|
153
219
|
declare function isApprovioError(data: unknown): data is APIError;
|
|
154
220
|
//#endregion
|
|
155
|
-
export { AgentAuthenticator, ApprovioAgentClient, ApprovioError, ApprovioServerConfig, ApprovioUserClient, AuthHelper, Authenticator, BaseApprovioClient, CliUserAuthenticator, GetOrganizationUsageParams, 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,39 +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 {
|
|
96
138
|
period?: string;
|
|
97
139
|
metric?: string;
|
|
98
140
|
}
|
|
99
|
-
declare class ApprovioUserClient extends
|
|
141
|
+
declare class ApprovioUserClient extends OrganizationClient {
|
|
100
142
|
readonly authenticator: CliUserAuthenticator | WebAuthenticator;
|
|
101
|
-
constructor(config: ApprovioServerConfig, authenticator: CliUserAuthenticator | WebAuthenticator);
|
|
143
|
+
constructor(config: ApprovioServerConfig, authenticator: CliUserAuthenticator | WebAuthenticator, organizationId: string);
|
|
102
144
|
listUsers(params?: ListUsersParams): TE.TaskEither<ApprovioError, ListUsers200Response>;
|
|
103
145
|
registerAgent(data: AgentRegistrationRequest): TE.TaskEither<ApprovioError, AgentRegistrationResponse>;
|
|
104
|
-
assignAgentRoles(agentId: string, data: RoleAssignmentRequest): TE.TaskEither<ApprovioError, void>;
|
|
105
|
-
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>;
|
|
106
148
|
createUser(data: UserCreate): TE.TaskEither<ApprovioError, string>;
|
|
107
149
|
getUser(userId: string): TE.TaskEither<ApprovioError, User>;
|
|
108
|
-
assignUserRoles(userId: string, data: RoleAssignmentRequest): TE.TaskEither<ApprovioError, void>;
|
|
109
|
-
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>;
|
|
110
152
|
createWorkflowTemplate(data: WorkflowTemplateCreate): TE.TaskEither<ApprovioError, WorkflowTemplate>;
|
|
111
153
|
listWorkflowTemplates(request?: ListWorkflowTemplatesParams): TE.TaskEither<ApprovioError, ListWorkflowTemplates200Response>;
|
|
112
154
|
getWorkflowTemplate(templateIdentifier: string): TE.TaskEither<ApprovioError, WorkflowTemplate>;
|
|
113
|
-
updateWorkflowTemplate(templateIdentifier: string, data: WorkflowTemplateUpdate): TE.TaskEither<ApprovioError, WorkflowTemplate>;
|
|
155
|
+
updateWorkflowTemplate(templateIdentifier: string, data: WorkflowTemplateUpdate, etag: string): TE.TaskEither<ApprovioError, WorkflowTemplate>;
|
|
114
156
|
deprecateWorkflowTemplate(templateName: string, data?: WorkflowTemplateDeprecate): TE.TaskEither<ApprovioError, WorkflowTemplate>;
|
|
115
157
|
createGroup(data: GroupCreate): TE.TaskEither<ApprovioError, string>;
|
|
116
158
|
listGroups(params?: ListGroupsParams): TE.TaskEither<ApprovioError, ListGroups200Response>;
|
|
@@ -125,31 +167,55 @@ declare class ApprovioUserClient extends BaseApprovioClient {
|
|
|
125
167
|
listSpaces(params?: ListSpacesParams): TE.TaskEither<ApprovioError, ListSpaces200Response>;
|
|
126
168
|
getSpace(spaceId: string): TE.TaskEither<ApprovioError, Space>;
|
|
127
169
|
deleteSpace(spaceId: string): TE.TaskEither<ApprovioError, void>;
|
|
128
|
-
addOrganizationAdminToOrg(organizationName: string, data: OrganizationAdminCreate): TE.TaskEither<ApprovioError, void>;
|
|
129
|
-
listOrganizationAdminsForOrg(organizationName: string, params?: {
|
|
130
|
-
page?: number;
|
|
131
|
-
limit?: number;
|
|
132
|
-
}): TE.TaskEither<ApprovioError, ListOrganizationAdminsForOrg200Response>;
|
|
133
|
-
removeOrganizationAdminFromOrg(organizationName: string, data: OrganizationAdminRemove): TE.TaskEither<ApprovioError, void>;
|
|
134
170
|
getAgent(agentId: string): TE.TaskEither<ApprovioError, AgentGet200Response>;
|
|
135
171
|
getEntityInfo(): TE.TaskEither<ApprovioError, GetEntityInfoUserResponse>;
|
|
136
172
|
listAuditLogs(params?: ListAuditLogsParams): TE.TaskEither<ApprovioError, ListAuditLogs200Response>;
|
|
137
173
|
listMyAuditLogs(params?: ListMyAuditLogsParams): TE.TaskEither<ApprovioError, ListAuditLogs200Response>;
|
|
138
174
|
resolveResources(params: ResourceResolveRequest): TE.TaskEither<ApprovioError, ResourceResolveResponse>;
|
|
139
|
-
getOrganizationEntitlements(
|
|
140
|
-
getOrganizationUsage(
|
|
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>;
|
|
141
191
|
logout(): TE.TaskEither<ApprovioError, void>;
|
|
142
192
|
}
|
|
143
193
|
//#endregion
|
|
144
194
|
//#region src/client/agent.client.d.ts
|
|
145
|
-
declare class ApprovioAgentClient extends
|
|
195
|
+
declare class ApprovioAgentClient extends OrganizationClient {
|
|
146
196
|
readonly authenticator: AgentAuthenticator;
|
|
147
197
|
constructor(config: ApprovioServerConfig, authenticator: AgentAuthenticator);
|
|
148
198
|
getAuthenticator(): Authenticator;
|
|
149
199
|
getEntityInfo(): TE.TaskEither<ApprovioError, GetEntityInfoAgentResponse>;
|
|
150
200
|
}
|
|
151
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
|
|
152
218
|
//#region src/client/utils.d.ts
|
|
153
219
|
declare function isApprovioError(data: unknown): data is APIError;
|
|
154
220
|
//#endregion
|
|
155
|
-
export { AgentAuthenticator, ApprovioAgentClient, ApprovioError, ApprovioServerConfig, ApprovioUserClient, AuthHelper, Authenticator, BaseApprovioClient, CliUserAuthenticator, GetOrganizationUsageParams, 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 };
|