@approvio/ts-sdk 0.0.9 → 0.0.11
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 +10 -80
- package/dist/index.d.cts +13 -20
- package/dist/index.d.mts +13 -20
- package/dist/index.mjs +10 -81
- package/package.json +2 -2
package/dist/index.cjs
CHANGED
|
@@ -25,6 +25,7 @@ let jose = require("jose");
|
|
|
25
25
|
jose = __toESM(jose);
|
|
26
26
|
let axios = require("axios");
|
|
27
27
|
axios = __toESM(axios);
|
|
28
|
+
let _approvio_api = require("@approvio/api");
|
|
28
29
|
let node_crypto = require("node:crypto");
|
|
29
30
|
node_crypto = __toESM(node_crypto);
|
|
30
31
|
let fp_ts_TaskEither = require("fp-ts/TaskEither");
|
|
@@ -42,7 +43,7 @@ function isJwtTokenExpired(token) {
|
|
|
42
43
|
* Checks if the given data matches the APIError structure.
|
|
43
44
|
*/
|
|
44
45
|
function isApprovioError(data) {
|
|
45
|
-
return
|
|
46
|
+
return (0, _approvio_api.isAPIError)(data);
|
|
46
47
|
}
|
|
47
48
|
function validateURL(url) {
|
|
48
49
|
try {
|
|
@@ -295,7 +296,10 @@ var BaseApprovioClient = class {
|
|
|
295
296
|
this.config = config;
|
|
296
297
|
this.authenticator = authenticator;
|
|
297
298
|
validateURL(config.endpoint);
|
|
298
|
-
this.axios = axios.default.create({
|
|
299
|
+
this.axios = axios.default.create({
|
|
300
|
+
baseURL: removeTrailingSlash(config.endpoint),
|
|
301
|
+
paramsSerializer: { indexes: null }
|
|
302
|
+
});
|
|
299
303
|
this.authenticator.customizeAxios(this.axios);
|
|
300
304
|
}
|
|
301
305
|
handleError(error) {
|
|
@@ -368,7 +372,7 @@ var BaseApprovioClient = class {
|
|
|
368
372
|
const queryParams = {
|
|
369
373
|
page: params?.page,
|
|
370
374
|
limit: params?.limit,
|
|
371
|
-
|
|
375
|
+
includeOnlyNonTerminalState: params?.includeOnlyNonTerminalState,
|
|
372
376
|
include: params?.include
|
|
373
377
|
};
|
|
374
378
|
return this.get("/workflows", queryParams);
|
|
@@ -414,30 +418,18 @@ var ApprovioUserClient = class extends BaseApprovioClient {
|
|
|
414
418
|
super(config, authenticator);
|
|
415
419
|
this.authenticator = authenticator;
|
|
416
420
|
}
|
|
417
|
-
/**
|
|
418
|
-
* Lists users.
|
|
419
|
-
*/
|
|
420
421
|
listUsers(params) {
|
|
421
422
|
return this.get("/users", params);
|
|
422
423
|
}
|
|
423
424
|
registerAgent(data) {
|
|
424
425
|
return this.post("/agents/register", data);
|
|
425
426
|
}
|
|
426
|
-
/**
|
|
427
|
-
* Assign roles to an agent.
|
|
428
|
-
*/
|
|
429
427
|
assignAgentRoles(agentId, data) {
|
|
430
428
|
return this.put(`/agents/${agentId}/roles`, data);
|
|
431
429
|
}
|
|
432
|
-
/**
|
|
433
|
-
* Remove roles from an agent.
|
|
434
|
-
*/
|
|
435
430
|
removeAgentRoles(agentId, data) {
|
|
436
431
|
return this.delete(`/agents/${agentId}/roles`, data);
|
|
437
432
|
}
|
|
438
|
-
/**
|
|
439
|
-
* Creates a new user.
|
|
440
|
-
*/
|
|
441
433
|
createUser(data) {
|
|
442
434
|
return (0, fp_ts_function.pipe)(this.postWithLocation("/users", data), fp_ts_TaskEither.map(({ location }) => location), fp_ts_TaskEither.chain((location) => {
|
|
443
435
|
const id = location.split("/").pop();
|
|
@@ -445,57 +437,30 @@ var ApprovioUserClient = class extends BaseApprovioClient {
|
|
|
445
437
|
return fp_ts_TaskEither.right(id);
|
|
446
438
|
}));
|
|
447
439
|
}
|
|
448
|
-
/**
|
|
449
|
-
* Get user details.
|
|
450
|
-
*/
|
|
451
440
|
getUser(userId) {
|
|
452
441
|
return this.get(`/users/${userId}`);
|
|
453
442
|
}
|
|
454
|
-
/**
|
|
455
|
-
* Assign roles to a user.
|
|
456
|
-
*/
|
|
457
443
|
assignUserRoles(userId, data) {
|
|
458
444
|
return this.put(`/users/${userId}/roles`, data);
|
|
459
445
|
}
|
|
460
|
-
/**
|
|
461
|
-
* Remove roles from a user.
|
|
462
|
-
*/
|
|
463
446
|
removeUserRoles(userId, data) {
|
|
464
447
|
return this.delete(`/users/${userId}/roles`, data);
|
|
465
448
|
}
|
|
466
|
-
/**
|
|
467
|
-
* Create a new workflow template.
|
|
468
|
-
*/
|
|
469
449
|
createWorkflowTemplate(data) {
|
|
470
450
|
return this.post("/workflow-templates", data);
|
|
471
451
|
}
|
|
472
|
-
|
|
473
|
-
|
|
474
|
-
*/
|
|
475
|
-
listWorkflowTemplates(params) {
|
|
476
|
-
return this.get("/workflow-templates", params);
|
|
452
|
+
listWorkflowTemplates(request) {
|
|
453
|
+
return this.get("/workflow-templates", request);
|
|
477
454
|
}
|
|
478
|
-
/**
|
|
479
|
-
* Get workflow template details.
|
|
480
|
-
*/
|
|
481
455
|
getWorkflowTemplate(templateIdentifier) {
|
|
482
456
|
return this.get(`/workflow-templates/${templateIdentifier}`);
|
|
483
457
|
}
|
|
484
|
-
/**
|
|
485
|
-
* Update a workflow template.
|
|
486
|
-
*/
|
|
487
458
|
updateWorkflowTemplate(templateIdentifier, data) {
|
|
488
459
|
return this.put(`/workflow-templates/${templateIdentifier}`, data);
|
|
489
460
|
}
|
|
490
|
-
/**
|
|
491
|
-
* Deprecate a workflow template.
|
|
492
|
-
*/
|
|
493
461
|
deprecateWorkflowTemplate(templateName, data) {
|
|
494
462
|
return this.post(`/workflow-templates/${templateName}/deprecate`, data);
|
|
495
463
|
}
|
|
496
|
-
/**
|
|
497
|
-
* Create a new group.
|
|
498
|
-
*/
|
|
499
464
|
createGroup(data) {
|
|
500
465
|
return (0, fp_ts_function.pipe)(this.postWithLocation("/groups", data), fp_ts_TaskEither.map(({ location }) => location), fp_ts_TaskEither.chain((location) => {
|
|
501
466
|
const id = location.split("/").pop();
|
|
@@ -503,75 +468,39 @@ var ApprovioUserClient = class extends BaseApprovioClient {
|
|
|
503
468
|
return fp_ts_TaskEither.right(id);
|
|
504
469
|
}));
|
|
505
470
|
}
|
|
506
|
-
/**
|
|
507
|
-
* List groups.
|
|
508
|
-
*/
|
|
509
471
|
listGroups(params) {
|
|
510
472
|
return this.get("/groups", params);
|
|
511
473
|
}
|
|
512
|
-
/**
|
|
513
|
-
* Get group details.
|
|
514
|
-
*/
|
|
515
474
|
getGroup(groupIdentifier) {
|
|
516
475
|
return this.get(`/groups/${groupIdentifier}`);
|
|
517
476
|
}
|
|
518
|
-
/**
|
|
519
|
-
* List entities in a group.
|
|
520
|
-
*/
|
|
521
477
|
listGroupEntities(groupId, params) {
|
|
522
478
|
return this.get(`/groups/${groupId}/entities`, params);
|
|
523
479
|
}
|
|
524
|
-
/**
|
|
525
|
-
* Add entities to a group.
|
|
526
|
-
*/
|
|
527
480
|
addGroupEntities(groupId, data) {
|
|
528
481
|
return this.post(`/groups/${groupId}/entities`, data);
|
|
529
482
|
}
|
|
530
|
-
/**
|
|
531
|
-
* Remove entities from a group.
|
|
532
|
-
*/
|
|
533
483
|
removeGroupEntities(groupId, data) {
|
|
534
484
|
return this.delete(`/groups/${groupId}/entities`, data);
|
|
535
485
|
}
|
|
536
|
-
/**
|
|
537
|
-
* Create a new space.
|
|
538
|
-
*/
|
|
539
486
|
createSpace(data) {
|
|
540
487
|
return this.post("/spaces", data);
|
|
541
488
|
}
|
|
542
|
-
/**
|
|
543
|
-
* List spaces.
|
|
544
|
-
*/
|
|
545
489
|
listSpaces(params) {
|
|
546
490
|
return this.get("/spaces", params);
|
|
547
491
|
}
|
|
548
|
-
/**
|
|
549
|
-
* Get space details.
|
|
550
|
-
*/
|
|
551
492
|
getSpace(spaceId) {
|
|
552
493
|
return this.get(`/spaces/${spaceId}`);
|
|
553
494
|
}
|
|
554
|
-
/**
|
|
555
|
-
* Delete a space.
|
|
556
|
-
*/
|
|
557
495
|
deleteSpace(spaceId) {
|
|
558
496
|
return this.delete(`/spaces/${spaceId}`);
|
|
559
497
|
}
|
|
560
|
-
/**
|
|
561
|
-
* Add an organization admin.
|
|
562
|
-
*/
|
|
563
498
|
addOrganizationAdminToOrg(organizationName, data) {
|
|
564
499
|
return this.post(`/organization/${organizationName}/admins`, data);
|
|
565
500
|
}
|
|
566
|
-
/**
|
|
567
|
-
* List organization admins.
|
|
568
|
-
*/
|
|
569
501
|
listOrganizationAdminsForOrg(organizationName, params) {
|
|
570
502
|
return this.get(`/organization/${organizationName}/admins`, params);
|
|
571
503
|
}
|
|
572
|
-
/**
|
|
573
|
-
* Remove an organization admin.
|
|
574
|
-
*/
|
|
575
504
|
removeOrganizationAdminFromOrg(organizationName, data) {
|
|
576
505
|
return this.delete(`/organization/${organizationName}/admins`, data);
|
|
577
506
|
}
|
|
@@ -601,3 +530,4 @@ exports.AuthHelper = AuthHelper;
|
|
|
601
530
|
exports.BaseApprovioClient = BaseApprovioClient;
|
|
602
531
|
exports.CliUserAuthenticator = CliUserAuthenticator;
|
|
603
532
|
exports.WebAuthenticator = WebAuthenticator;
|
|
533
|
+
exports.isApprovioError = isApprovioError;
|
package/dist/index.d.cts
CHANGED
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
import { AxiosInstance } from "axios";
|
|
2
|
-
import { APIError, AddGroupEntitiesRequest, AgentGet200Response, AgentRegistrationRequest, AgentRegistrationResponse, AgentTokenResponse, CanVoteResponse, GetEntityInfo200Response, GetWorkflowParams, Group, GroupCreate, ListGroupEntities200Response, ListGroups200Response, ListOrganizationAdminsForOrg200Response, ListRoleTemplates200Response, ListSpaces200Response, ListUsers200Response, ListWorkflowTemplates200Response, ListWorkflows200Response, ListWorkflowsParams, OrganizationAdminCreate, OrganizationAdminRemove, RemoveGroupEntitiesRequest, RoleAssignmentRequest, RoleRemovalRequest, Space, SpaceCreate, TokenResponse, User, UserCreate, Workflow, WorkflowCreate, WorkflowTemplate, WorkflowTemplateCreate, WorkflowTemplateDeprecate, WorkflowTemplateUpdate, WorkflowVoteRequest } from "@approvio/api";
|
|
2
|
+
import { APIError, AddGroupEntitiesRequest, AgentGet200Response, AgentRegistrationRequest, AgentRegistrationResponse, AgentTokenResponse, CanVoteResponse, GetEntityInfo200Response, GetWorkflowParams, Group, GroupCreate, ListGroupEntities200Response, ListGroups200Response, ListGroupsParams, ListOrganizationAdminsForOrg200Response, ListRoleTemplates200Response, ListSpaces200Response, ListSpacesParams, ListUsers200Response, ListUsersParams, ListWorkflowTemplates200Response, ListWorkflowTemplatesParams, ListWorkflows200Response, ListWorkflowsParams, OrganizationAdminCreate, OrganizationAdminRemove, RemoveGroupEntitiesRequest, RoleAssignmentRequest, RoleRemovalRequest, Space, SpaceCreate, TokenResponse, User, UserCreate, Workflow, WorkflowCreate, WorkflowTemplate, WorkflowTemplateCreate, WorkflowTemplateDeprecate, WorkflowTemplateUpdate, WorkflowVoteRequest } from "@approvio/api";
|
|
3
3
|
import * as TE from "fp-ts/TaskEither";
|
|
4
4
|
|
|
5
5
|
//#region src/interfaces.d.ts
|
|
@@ -32,6 +32,9 @@ declare class WebAuthenticator implements Authenticator {
|
|
|
32
32
|
}
|
|
33
33
|
//#endregion
|
|
34
34
|
//#region src/client/base.client.d.ts
|
|
35
|
+
type SerializablePrimitive = string | number | boolean | null | undefined;
|
|
36
|
+
type SerializableValue = SerializablePrimitive | SerializablePrimitive[];
|
|
37
|
+
type SafeQueryParams<T> = { [K in keyof T]: T[K] extends SerializableValue ? T[K] : never };
|
|
35
38
|
type ApprovioError = (APIError & {
|
|
36
39
|
status: number;
|
|
37
40
|
}) | Error;
|
|
@@ -41,7 +44,7 @@ declare abstract class BaseApprovioClient {
|
|
|
41
44
|
protected readonly axios: AxiosInstance;
|
|
42
45
|
constructor(config: ApprovioServerConfig, authenticator: Authenticator);
|
|
43
46
|
protected handleError(error: unknown): ApprovioError;
|
|
44
|
-
protected get<
|
|
47
|
+
protected get<Response, Params extends SafeQueryParams<Params> = Record<string, SerializableValue>>(url: string, params?: Params): TE.TaskEither<ApprovioError, Response>;
|
|
45
48
|
protected post<T>(url: string, data?: unknown): TE.TaskEither<ApprovioError, T>;
|
|
46
49
|
protected postWithLocation<T>(url: string, data?: unknown): TE.TaskEither<ApprovioError, {
|
|
47
50
|
data: T;
|
|
@@ -87,11 +90,7 @@ declare class AgentAuthenticator implements TokenBaseAuthenticator {
|
|
|
87
90
|
declare class ApprovioUserClient extends BaseApprovioClient {
|
|
88
91
|
readonly authenticator: CliUserAuthenticator | WebAuthenticator;
|
|
89
92
|
constructor(config: ApprovioServerConfig, authenticator: CliUserAuthenticator | WebAuthenticator);
|
|
90
|
-
listUsers(params?:
|
|
91
|
-
search?: string;
|
|
92
|
-
page?: number;
|
|
93
|
-
limit?: number;
|
|
94
|
-
}): TE.TaskEither<ApprovioError, ListUsers200Response>;
|
|
93
|
+
listUsers(params?: ListUsersParams): TE.TaskEither<ApprovioError, ListUsers200Response>;
|
|
95
94
|
registerAgent(data: AgentRegistrationRequest): TE.TaskEither<ApprovioError, AgentRegistrationResponse>;
|
|
96
95
|
assignAgentRoles(agentId: string, data: RoleAssignmentRequest): TE.TaskEither<ApprovioError, void>;
|
|
97
96
|
removeAgentRoles(agentId: string, data: RoleRemovalRequest): TE.TaskEither<ApprovioError, void>;
|
|
@@ -100,18 +99,12 @@ declare class ApprovioUserClient extends BaseApprovioClient {
|
|
|
100
99
|
assignUserRoles(userId: string, data: RoleAssignmentRequest): TE.TaskEither<ApprovioError, void>;
|
|
101
100
|
removeUserRoles(userId: string, data: RoleRemovalRequest): TE.TaskEither<ApprovioError, void>;
|
|
102
101
|
createWorkflowTemplate(data: WorkflowTemplateCreate): TE.TaskEither<ApprovioError, WorkflowTemplate>;
|
|
103
|
-
listWorkflowTemplates(
|
|
104
|
-
page?: number;
|
|
105
|
-
limit?: number;
|
|
106
|
-
}): TE.TaskEither<ApprovioError, ListWorkflowTemplates200Response>;
|
|
102
|
+
listWorkflowTemplates(request?: ListWorkflowTemplatesParams): TE.TaskEither<ApprovioError, ListWorkflowTemplates200Response>;
|
|
107
103
|
getWorkflowTemplate(templateIdentifier: string): TE.TaskEither<ApprovioError, WorkflowTemplate>;
|
|
108
104
|
updateWorkflowTemplate(templateIdentifier: string, data: WorkflowTemplateUpdate): TE.TaskEither<ApprovioError, WorkflowTemplate>;
|
|
109
105
|
deprecateWorkflowTemplate(templateName: string, data?: WorkflowTemplateDeprecate): TE.TaskEither<ApprovioError, WorkflowTemplate>;
|
|
110
106
|
createGroup(data: GroupCreate): TE.TaskEither<ApprovioError, string>;
|
|
111
|
-
listGroups(params?:
|
|
112
|
-
page?: number;
|
|
113
|
-
limit?: number;
|
|
114
|
-
}): TE.TaskEither<ApprovioError, ListGroups200Response>;
|
|
107
|
+
listGroups(params?: ListGroupsParams): TE.TaskEither<ApprovioError, ListGroups200Response>;
|
|
115
108
|
getGroup(groupIdentifier: string): TE.TaskEither<ApprovioError, Group>;
|
|
116
109
|
listGroupEntities(groupId: string, params?: {
|
|
117
110
|
page?: number;
|
|
@@ -120,10 +113,7 @@ declare class ApprovioUserClient extends BaseApprovioClient {
|
|
|
120
113
|
addGroupEntities(groupId: string, data: AddGroupEntitiesRequest): TE.TaskEither<ApprovioError, Group>;
|
|
121
114
|
removeGroupEntities(groupId: string, data: RemoveGroupEntitiesRequest): TE.TaskEither<ApprovioError, Group>;
|
|
122
115
|
createSpace(data: SpaceCreate): TE.TaskEither<ApprovioError, void>;
|
|
123
|
-
listSpaces(params?:
|
|
124
|
-
page?: number;
|
|
125
|
-
limit?: number;
|
|
126
|
-
}): TE.TaskEither<ApprovioError, ListSpaces200Response>;
|
|
116
|
+
listSpaces(params?: ListSpacesParams): TE.TaskEither<ApprovioError, ListSpaces200Response>;
|
|
127
117
|
getSpace(spaceId: string): TE.TaskEither<ApprovioError, Space>;
|
|
128
118
|
deleteSpace(spaceId: string): TE.TaskEither<ApprovioError, void>;
|
|
129
119
|
addOrganizationAdminToOrg(organizationName: string, data: OrganizationAdminCreate): TE.TaskEither<ApprovioError, void>;
|
|
@@ -142,4 +132,7 @@ declare class ApprovioAgentClient extends BaseApprovioClient {
|
|
|
142
132
|
getAuthenticator(): Authenticator;
|
|
143
133
|
}
|
|
144
134
|
//#endregion
|
|
145
|
-
|
|
135
|
+
//#region src/client/utils.d.ts
|
|
136
|
+
declare function isApprovioError(data: unknown): data is APIError;
|
|
137
|
+
//#endregion
|
|
138
|
+
export { AgentAuthenticator, ApprovioAgentClient, ApprovioError, ApprovioServerConfig, ApprovioUserClient, AuthHelper, Authenticator, BaseApprovioClient, CliUserAuthenticator, SafeQueryParams, TokenBaseAuthenticator, WebAuthenticator, isApprovioError };
|
package/dist/index.d.mts
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
import { AxiosInstance } from "axios";
|
|
2
|
+
import { APIError, AddGroupEntitiesRequest, AgentGet200Response, AgentRegistrationRequest, AgentRegistrationResponse, AgentTokenResponse, CanVoteResponse, GetEntityInfo200Response, GetWorkflowParams, Group, GroupCreate, ListGroupEntities200Response, ListGroups200Response, ListGroupsParams, ListOrganizationAdminsForOrg200Response, ListRoleTemplates200Response, ListSpaces200Response, ListSpacesParams, ListUsers200Response, ListUsersParams, ListWorkflowTemplates200Response, ListWorkflowTemplatesParams, ListWorkflows200Response, ListWorkflowsParams, OrganizationAdminCreate, OrganizationAdminRemove, RemoveGroupEntitiesRequest, RoleAssignmentRequest, RoleRemovalRequest, Space, SpaceCreate, TokenResponse, User, UserCreate, Workflow, WorkflowCreate, WorkflowTemplate, WorkflowTemplateCreate, WorkflowTemplateDeprecate, WorkflowTemplateUpdate, WorkflowVoteRequest } from "@approvio/api";
|
|
2
3
|
import * as TE from "fp-ts/TaskEither";
|
|
3
|
-
import { APIError, AddGroupEntitiesRequest, AgentGet200Response, AgentRegistrationRequest, AgentRegistrationResponse, AgentTokenResponse, CanVoteResponse, GetEntityInfo200Response, GetWorkflowParams, Group, GroupCreate, ListGroupEntities200Response, ListGroups200Response, ListOrganizationAdminsForOrg200Response, ListRoleTemplates200Response, ListSpaces200Response, ListUsers200Response, ListWorkflowTemplates200Response, ListWorkflows200Response, ListWorkflowsParams, OrganizationAdminCreate, OrganizationAdminRemove, RemoveGroupEntitiesRequest, RoleAssignmentRequest, RoleRemovalRequest, Space, SpaceCreate, TokenResponse, User, UserCreate, Workflow, WorkflowCreate, WorkflowTemplate, WorkflowTemplateCreate, WorkflowTemplateDeprecate, WorkflowTemplateUpdate, WorkflowVoteRequest } from "@approvio/api";
|
|
4
4
|
|
|
5
5
|
//#region src/interfaces.d.ts
|
|
6
6
|
interface Authenticator {
|
|
@@ -32,6 +32,9 @@ declare class WebAuthenticator implements Authenticator {
|
|
|
32
32
|
}
|
|
33
33
|
//#endregion
|
|
34
34
|
//#region src/client/base.client.d.ts
|
|
35
|
+
type SerializablePrimitive = string | number | boolean | null | undefined;
|
|
36
|
+
type SerializableValue = SerializablePrimitive | SerializablePrimitive[];
|
|
37
|
+
type SafeQueryParams<T> = { [K in keyof T]: T[K] extends SerializableValue ? T[K] : never };
|
|
35
38
|
type ApprovioError = (APIError & {
|
|
36
39
|
status: number;
|
|
37
40
|
}) | Error;
|
|
@@ -41,7 +44,7 @@ declare abstract class BaseApprovioClient {
|
|
|
41
44
|
protected readonly axios: AxiosInstance;
|
|
42
45
|
constructor(config: ApprovioServerConfig, authenticator: Authenticator);
|
|
43
46
|
protected handleError(error: unknown): ApprovioError;
|
|
44
|
-
protected get<
|
|
47
|
+
protected get<Response, Params extends SafeQueryParams<Params> = Record<string, SerializableValue>>(url: string, params?: Params): TE.TaskEither<ApprovioError, Response>;
|
|
45
48
|
protected post<T>(url: string, data?: unknown): TE.TaskEither<ApprovioError, T>;
|
|
46
49
|
protected postWithLocation<T>(url: string, data?: unknown): TE.TaskEither<ApprovioError, {
|
|
47
50
|
data: T;
|
|
@@ -87,11 +90,7 @@ declare class AgentAuthenticator implements TokenBaseAuthenticator {
|
|
|
87
90
|
declare class ApprovioUserClient extends BaseApprovioClient {
|
|
88
91
|
readonly authenticator: CliUserAuthenticator | WebAuthenticator;
|
|
89
92
|
constructor(config: ApprovioServerConfig, authenticator: CliUserAuthenticator | WebAuthenticator);
|
|
90
|
-
listUsers(params?:
|
|
91
|
-
search?: string;
|
|
92
|
-
page?: number;
|
|
93
|
-
limit?: number;
|
|
94
|
-
}): TE.TaskEither<ApprovioError, ListUsers200Response>;
|
|
93
|
+
listUsers(params?: ListUsersParams): TE.TaskEither<ApprovioError, ListUsers200Response>;
|
|
95
94
|
registerAgent(data: AgentRegistrationRequest): TE.TaskEither<ApprovioError, AgentRegistrationResponse>;
|
|
96
95
|
assignAgentRoles(agentId: string, data: RoleAssignmentRequest): TE.TaskEither<ApprovioError, void>;
|
|
97
96
|
removeAgentRoles(agentId: string, data: RoleRemovalRequest): TE.TaskEither<ApprovioError, void>;
|
|
@@ -100,18 +99,12 @@ declare class ApprovioUserClient extends BaseApprovioClient {
|
|
|
100
99
|
assignUserRoles(userId: string, data: RoleAssignmentRequest): TE.TaskEither<ApprovioError, void>;
|
|
101
100
|
removeUserRoles(userId: string, data: RoleRemovalRequest): TE.TaskEither<ApprovioError, void>;
|
|
102
101
|
createWorkflowTemplate(data: WorkflowTemplateCreate): TE.TaskEither<ApprovioError, WorkflowTemplate>;
|
|
103
|
-
listWorkflowTemplates(
|
|
104
|
-
page?: number;
|
|
105
|
-
limit?: number;
|
|
106
|
-
}): TE.TaskEither<ApprovioError, ListWorkflowTemplates200Response>;
|
|
102
|
+
listWorkflowTemplates(request?: ListWorkflowTemplatesParams): TE.TaskEither<ApprovioError, ListWorkflowTemplates200Response>;
|
|
107
103
|
getWorkflowTemplate(templateIdentifier: string): TE.TaskEither<ApprovioError, WorkflowTemplate>;
|
|
108
104
|
updateWorkflowTemplate(templateIdentifier: string, data: WorkflowTemplateUpdate): TE.TaskEither<ApprovioError, WorkflowTemplate>;
|
|
109
105
|
deprecateWorkflowTemplate(templateName: string, data?: WorkflowTemplateDeprecate): TE.TaskEither<ApprovioError, WorkflowTemplate>;
|
|
110
106
|
createGroup(data: GroupCreate): TE.TaskEither<ApprovioError, string>;
|
|
111
|
-
listGroups(params?:
|
|
112
|
-
page?: number;
|
|
113
|
-
limit?: number;
|
|
114
|
-
}): TE.TaskEither<ApprovioError, ListGroups200Response>;
|
|
107
|
+
listGroups(params?: ListGroupsParams): TE.TaskEither<ApprovioError, ListGroups200Response>;
|
|
115
108
|
getGroup(groupIdentifier: string): TE.TaskEither<ApprovioError, Group>;
|
|
116
109
|
listGroupEntities(groupId: string, params?: {
|
|
117
110
|
page?: number;
|
|
@@ -120,10 +113,7 @@ declare class ApprovioUserClient extends BaseApprovioClient {
|
|
|
120
113
|
addGroupEntities(groupId: string, data: AddGroupEntitiesRequest): TE.TaskEither<ApprovioError, Group>;
|
|
121
114
|
removeGroupEntities(groupId: string, data: RemoveGroupEntitiesRequest): TE.TaskEither<ApprovioError, Group>;
|
|
122
115
|
createSpace(data: SpaceCreate): TE.TaskEither<ApprovioError, void>;
|
|
123
|
-
listSpaces(params?:
|
|
124
|
-
page?: number;
|
|
125
|
-
limit?: number;
|
|
126
|
-
}): TE.TaskEither<ApprovioError, ListSpaces200Response>;
|
|
116
|
+
listSpaces(params?: ListSpacesParams): TE.TaskEither<ApprovioError, ListSpaces200Response>;
|
|
127
117
|
getSpace(spaceId: string): TE.TaskEither<ApprovioError, Space>;
|
|
128
118
|
deleteSpace(spaceId: string): TE.TaskEither<ApprovioError, void>;
|
|
129
119
|
addOrganizationAdminToOrg(organizationName: string, data: OrganizationAdminCreate): TE.TaskEither<ApprovioError, void>;
|
|
@@ -142,4 +132,7 @@ declare class ApprovioAgentClient extends BaseApprovioClient {
|
|
|
142
132
|
getAuthenticator(): Authenticator;
|
|
143
133
|
}
|
|
144
134
|
//#endregion
|
|
145
|
-
|
|
135
|
+
//#region src/client/utils.d.ts
|
|
136
|
+
declare function isApprovioError(data: unknown): data is APIError;
|
|
137
|
+
//#endregion
|
|
138
|
+
export { AgentAuthenticator, ApprovioAgentClient, ApprovioError, ApprovioServerConfig, ApprovioUserClient, AuthHelper, Authenticator, BaseApprovioClient, CliUserAuthenticator, SafeQueryParams, TokenBaseAuthenticator, WebAuthenticator, isApprovioError };
|
package/dist/index.mjs
CHANGED
|
@@ -1,6 +1,7 @@
|
|
|
1
1
|
import * as jose from "jose";
|
|
2
2
|
import { decodeJwt } from "jose";
|
|
3
3
|
import axios from "axios";
|
|
4
|
+
import { isAPIError } from "@approvio/api";
|
|
4
5
|
import * as crypto$1 from "node:crypto";
|
|
5
6
|
import * as TE from "fp-ts/TaskEither";
|
|
6
7
|
import { pipe } from "fp-ts/function";
|
|
@@ -16,7 +17,7 @@ function isJwtTokenExpired(token) {
|
|
|
16
17
|
* Checks if the given data matches the APIError structure.
|
|
17
18
|
*/
|
|
18
19
|
function isApprovioError(data) {
|
|
19
|
-
return data
|
|
20
|
+
return isAPIError(data);
|
|
20
21
|
}
|
|
21
22
|
function validateURL(url) {
|
|
22
23
|
try {
|
|
@@ -269,7 +270,10 @@ var BaseApprovioClient = class {
|
|
|
269
270
|
this.config = config;
|
|
270
271
|
this.authenticator = authenticator;
|
|
271
272
|
validateURL(config.endpoint);
|
|
272
|
-
this.axios = axios.create({
|
|
273
|
+
this.axios = axios.create({
|
|
274
|
+
baseURL: removeTrailingSlash(config.endpoint),
|
|
275
|
+
paramsSerializer: { indexes: null }
|
|
276
|
+
});
|
|
273
277
|
this.authenticator.customizeAxios(this.axios);
|
|
274
278
|
}
|
|
275
279
|
handleError(error) {
|
|
@@ -342,7 +346,7 @@ var BaseApprovioClient = class {
|
|
|
342
346
|
const queryParams = {
|
|
343
347
|
page: params?.page,
|
|
344
348
|
limit: params?.limit,
|
|
345
|
-
|
|
349
|
+
includeOnlyNonTerminalState: params?.includeOnlyNonTerminalState,
|
|
346
350
|
include: params?.include
|
|
347
351
|
};
|
|
348
352
|
return this.get("/workflows", queryParams);
|
|
@@ -388,30 +392,18 @@ var ApprovioUserClient = class extends BaseApprovioClient {
|
|
|
388
392
|
super(config, authenticator);
|
|
389
393
|
this.authenticator = authenticator;
|
|
390
394
|
}
|
|
391
|
-
/**
|
|
392
|
-
* Lists users.
|
|
393
|
-
*/
|
|
394
395
|
listUsers(params) {
|
|
395
396
|
return this.get("/users", params);
|
|
396
397
|
}
|
|
397
398
|
registerAgent(data) {
|
|
398
399
|
return this.post("/agents/register", data);
|
|
399
400
|
}
|
|
400
|
-
/**
|
|
401
|
-
* Assign roles to an agent.
|
|
402
|
-
*/
|
|
403
401
|
assignAgentRoles(agentId, data) {
|
|
404
402
|
return this.put(`/agents/${agentId}/roles`, data);
|
|
405
403
|
}
|
|
406
|
-
/**
|
|
407
|
-
* Remove roles from an agent.
|
|
408
|
-
*/
|
|
409
404
|
removeAgentRoles(agentId, data) {
|
|
410
405
|
return this.delete(`/agents/${agentId}/roles`, data);
|
|
411
406
|
}
|
|
412
|
-
/**
|
|
413
|
-
* Creates a new user.
|
|
414
|
-
*/
|
|
415
407
|
createUser(data) {
|
|
416
408
|
return pipe(this.postWithLocation("/users", data), TE.map(({ location }) => location), TE.chain((location) => {
|
|
417
409
|
const id = location.split("/").pop();
|
|
@@ -419,57 +411,30 @@ var ApprovioUserClient = class extends BaseApprovioClient {
|
|
|
419
411
|
return TE.right(id);
|
|
420
412
|
}));
|
|
421
413
|
}
|
|
422
|
-
/**
|
|
423
|
-
* Get user details.
|
|
424
|
-
*/
|
|
425
414
|
getUser(userId) {
|
|
426
415
|
return this.get(`/users/${userId}`);
|
|
427
416
|
}
|
|
428
|
-
/**
|
|
429
|
-
* Assign roles to a user.
|
|
430
|
-
*/
|
|
431
417
|
assignUserRoles(userId, data) {
|
|
432
418
|
return this.put(`/users/${userId}/roles`, data);
|
|
433
419
|
}
|
|
434
|
-
/**
|
|
435
|
-
* Remove roles from a user.
|
|
436
|
-
*/
|
|
437
420
|
removeUserRoles(userId, data) {
|
|
438
421
|
return this.delete(`/users/${userId}/roles`, data);
|
|
439
422
|
}
|
|
440
|
-
/**
|
|
441
|
-
* Create a new workflow template.
|
|
442
|
-
*/
|
|
443
423
|
createWorkflowTemplate(data) {
|
|
444
424
|
return this.post("/workflow-templates", data);
|
|
445
425
|
}
|
|
446
|
-
|
|
447
|
-
|
|
448
|
-
*/
|
|
449
|
-
listWorkflowTemplates(params) {
|
|
450
|
-
return this.get("/workflow-templates", params);
|
|
426
|
+
listWorkflowTemplates(request) {
|
|
427
|
+
return this.get("/workflow-templates", request);
|
|
451
428
|
}
|
|
452
|
-
/**
|
|
453
|
-
* Get workflow template details.
|
|
454
|
-
*/
|
|
455
429
|
getWorkflowTemplate(templateIdentifier) {
|
|
456
430
|
return this.get(`/workflow-templates/${templateIdentifier}`);
|
|
457
431
|
}
|
|
458
|
-
/**
|
|
459
|
-
* Update a workflow template.
|
|
460
|
-
*/
|
|
461
432
|
updateWorkflowTemplate(templateIdentifier, data) {
|
|
462
433
|
return this.put(`/workflow-templates/${templateIdentifier}`, data);
|
|
463
434
|
}
|
|
464
|
-
/**
|
|
465
|
-
* Deprecate a workflow template.
|
|
466
|
-
*/
|
|
467
435
|
deprecateWorkflowTemplate(templateName, data) {
|
|
468
436
|
return this.post(`/workflow-templates/${templateName}/deprecate`, data);
|
|
469
437
|
}
|
|
470
|
-
/**
|
|
471
|
-
* Create a new group.
|
|
472
|
-
*/
|
|
473
438
|
createGroup(data) {
|
|
474
439
|
return pipe(this.postWithLocation("/groups", data), TE.map(({ location }) => location), TE.chain((location) => {
|
|
475
440
|
const id = location.split("/").pop();
|
|
@@ -477,75 +442,39 @@ var ApprovioUserClient = class extends BaseApprovioClient {
|
|
|
477
442
|
return TE.right(id);
|
|
478
443
|
}));
|
|
479
444
|
}
|
|
480
|
-
/**
|
|
481
|
-
* List groups.
|
|
482
|
-
*/
|
|
483
445
|
listGroups(params) {
|
|
484
446
|
return this.get("/groups", params);
|
|
485
447
|
}
|
|
486
|
-
/**
|
|
487
|
-
* Get group details.
|
|
488
|
-
*/
|
|
489
448
|
getGroup(groupIdentifier) {
|
|
490
449
|
return this.get(`/groups/${groupIdentifier}`);
|
|
491
450
|
}
|
|
492
|
-
/**
|
|
493
|
-
* List entities in a group.
|
|
494
|
-
*/
|
|
495
451
|
listGroupEntities(groupId, params) {
|
|
496
452
|
return this.get(`/groups/${groupId}/entities`, params);
|
|
497
453
|
}
|
|
498
|
-
/**
|
|
499
|
-
* Add entities to a group.
|
|
500
|
-
*/
|
|
501
454
|
addGroupEntities(groupId, data) {
|
|
502
455
|
return this.post(`/groups/${groupId}/entities`, data);
|
|
503
456
|
}
|
|
504
|
-
/**
|
|
505
|
-
* Remove entities from a group.
|
|
506
|
-
*/
|
|
507
457
|
removeGroupEntities(groupId, data) {
|
|
508
458
|
return this.delete(`/groups/${groupId}/entities`, data);
|
|
509
459
|
}
|
|
510
|
-
/**
|
|
511
|
-
* Create a new space.
|
|
512
|
-
*/
|
|
513
460
|
createSpace(data) {
|
|
514
461
|
return this.post("/spaces", data);
|
|
515
462
|
}
|
|
516
|
-
/**
|
|
517
|
-
* List spaces.
|
|
518
|
-
*/
|
|
519
463
|
listSpaces(params) {
|
|
520
464
|
return this.get("/spaces", params);
|
|
521
465
|
}
|
|
522
|
-
/**
|
|
523
|
-
* Get space details.
|
|
524
|
-
*/
|
|
525
466
|
getSpace(spaceId) {
|
|
526
467
|
return this.get(`/spaces/${spaceId}`);
|
|
527
468
|
}
|
|
528
|
-
/**
|
|
529
|
-
* Delete a space.
|
|
530
|
-
*/
|
|
531
469
|
deleteSpace(spaceId) {
|
|
532
470
|
return this.delete(`/spaces/${spaceId}`);
|
|
533
471
|
}
|
|
534
|
-
/**
|
|
535
|
-
* Add an organization admin.
|
|
536
|
-
*/
|
|
537
472
|
addOrganizationAdminToOrg(organizationName, data) {
|
|
538
473
|
return this.post(`/organization/${organizationName}/admins`, data);
|
|
539
474
|
}
|
|
540
|
-
/**
|
|
541
|
-
* List organization admins.
|
|
542
|
-
*/
|
|
543
475
|
listOrganizationAdminsForOrg(organizationName, params) {
|
|
544
476
|
return this.get(`/organization/${organizationName}/admins`, params);
|
|
545
477
|
}
|
|
546
|
-
/**
|
|
547
|
-
* Remove an organization admin.
|
|
548
|
-
*/
|
|
549
478
|
removeOrganizationAdminFromOrg(organizationName, data) {
|
|
550
479
|
return this.delete(`/organization/${organizationName}/admins`, data);
|
|
551
480
|
}
|
|
@@ -568,4 +497,4 @@ var ApprovioAgentClient = class extends BaseApprovioClient {
|
|
|
568
497
|
}
|
|
569
498
|
};
|
|
570
499
|
//#endregion
|
|
571
|
-
export { AgentAuthenticator, ApprovioAgentClient, ApprovioUserClient, AuthHelper, BaseApprovioClient, CliUserAuthenticator, WebAuthenticator };
|
|
500
|
+
export { AgentAuthenticator, ApprovioAgentClient, ApprovioUserClient, AuthHelper, BaseApprovioClient, CliUserAuthenticator, WebAuthenticator, isApprovioError };
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@approvio/ts-sdk",
|
|
3
|
-
"version": "0.0.
|
|
3
|
+
"version": "0.0.11",
|
|
4
4
|
"type": "module",
|
|
5
5
|
"main": "dist/index.cjs",
|
|
6
6
|
"module": "./dist/index.mjs",
|
|
@@ -30,7 +30,7 @@
|
|
|
30
30
|
"prepublishOnly": "yarn format && yarn lint && yarn build"
|
|
31
31
|
},
|
|
32
32
|
"dependencies": {
|
|
33
|
-
"@approvio/api": "0.0.
|
|
33
|
+
"@approvio/api": "0.0.37",
|
|
34
34
|
"axios": "1.13.2",
|
|
35
35
|
"jose": "6.1.3"
|
|
36
36
|
},
|