@approvio/ts-sdk 0.0.10 → 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 CHANGED
@@ -28,9 +28,9 @@ axios = __toESM(axios);
28
28
  let _approvio_api = require("@approvio/api");
29
29
  let node_crypto = require("node:crypto");
30
30
  node_crypto = __toESM(node_crypto);
31
- let fp_ts_TaskEither_js = require("fp-ts/TaskEither.js");
32
- fp_ts_TaskEither_js = __toESM(fp_ts_TaskEither_js);
33
- let fp_ts_function_js = require("fp-ts/function.js");
31
+ let fp_ts_TaskEither = require("fp-ts/TaskEither");
32
+ fp_ts_TaskEither = __toESM(fp_ts_TaskEither);
33
+ let fp_ts_function = require("fp-ts/function");
34
34
  //#region src/auth/utils.ts
35
35
  function isJwtTokenExpired(token) {
36
36
  if (!token) return true;
@@ -149,7 +149,7 @@ var AuthHelper = class {
149
149
  * Prompts the backend to return an authorization URL for the IDP.
150
150
  */
151
151
  initiateCliLogin(redirectUri) {
152
- return fp_ts_TaskEither_js.tryCatch(async () => {
152
+ return fp_ts_TaskEither.tryCatch(async () => {
153
153
  return (await axios.default.post(`${this.endpoint}/auth/cli/initiate`, { redirectUri })).data.authorizationUrl;
154
154
  }, (error) => this.handleError(error));
155
155
  }
@@ -162,7 +162,7 @@ var AuthHelper = class {
162
162
  code,
163
163
  state
164
164
  };
165
- return fp_ts_TaskEither_js.tryCatch(async () => {
165
+ return fp_ts_TaskEither.tryCatch(async () => {
166
166
  return (await axios.default.post(`${this.endpoint}/auth/cli/token`, request)).data;
167
167
  }, (error) => this.handleError(error));
168
168
  }
@@ -174,7 +174,7 @@ var AuthHelper = class {
174
174
  * 4. Exchange the assertion for an access token.
175
175
  */
176
176
  authenticateAgent(agentName, privateKeyPem) {
177
- return fp_ts_TaskEither_js.tryCatch(async () => {
177
+ return fp_ts_TaskEither.tryCatch(async () => {
178
178
  const challengeRequest = { agentName };
179
179
  const { challenge: b64EncodedChallenge } = (await axios.default.post(`${this.endpoint}/auth/agents/challenge`, challengeRequest)).data;
180
180
  const encryptedBuffer = Buffer.from(b64EncodedChallenge, "base64");
@@ -296,7 +296,10 @@ var BaseApprovioClient = class {
296
296
  this.config = config;
297
297
  this.authenticator = authenticator;
298
298
  validateURL(config.endpoint);
299
- this.axios = axios.default.create({ baseURL: removeTrailingSlash(config.endpoint) });
299
+ this.axios = axios.default.create({
300
+ baseURL: removeTrailingSlash(config.endpoint),
301
+ paramsSerializer: { indexes: null }
302
+ });
300
303
  this.authenticator.customizeAxios(this.axios);
301
304
  }
302
305
  handleError(error) {
@@ -316,7 +319,7 @@ var BaseApprovioClient = class {
316
319
  * Performs a GET request.
317
320
  */
318
321
  get(url, params) {
319
- return fp_ts_TaskEither_js.tryCatch(async () => {
322
+ return fp_ts_TaskEither.tryCatch(async () => {
320
323
  return (await this.axios.get(url, { params })).data;
321
324
  }, (error) => this.handleError(error));
322
325
  }
@@ -324,12 +327,12 @@ var BaseApprovioClient = class {
324
327
  * Performs a POST request.
325
328
  */
326
329
  post(url, data) {
327
- return fp_ts_TaskEither_js.tryCatch(async () => {
330
+ return fp_ts_TaskEither.tryCatch(async () => {
328
331
  return (await this.axios.post(url, data)).data;
329
332
  }, (error) => this.handleError(error));
330
333
  }
331
334
  postWithLocation(url, data) {
332
- return fp_ts_TaskEither_js.tryCatch(async () => {
335
+ return fp_ts_TaskEither.tryCatch(async () => {
333
336
  const response = await this.axios.post(url, data);
334
337
  const location = response.headers["location"];
335
338
  if (!location) throw new LocationNotFoundError();
@@ -343,7 +346,7 @@ var BaseApprovioClient = class {
343
346
  * Performs a PUT request.
344
347
  */
345
348
  put(url, data) {
346
- return fp_ts_TaskEither_js.tryCatch(async () => {
349
+ return fp_ts_TaskEither.tryCatch(async () => {
347
350
  return (await this.axios.put(url, data)).data;
348
351
  }, (error) => this.handleError(error));
349
352
  }
@@ -351,7 +354,7 @@ var BaseApprovioClient = class {
351
354
  * Performs a DELETE request.
352
355
  */
353
356
  delete(url, data) {
354
- return fp_ts_TaskEither_js.tryCatch(async () => {
357
+ return fp_ts_TaskEither.tryCatch(async () => {
355
358
  const config = data !== void 0 ? { data } : void 0;
356
359
  return (await this.axios.delete(url, config)).data;
357
360
  }, (error) => this.handleError(error));
@@ -369,7 +372,7 @@ var BaseApprovioClient = class {
369
372
  const queryParams = {
370
373
  page: params?.page,
371
374
  limit: params?.limit,
372
- "include-only-non-terminal-state": params?.includeOnlyNonTerminalState,
375
+ includeOnlyNonTerminalState: params?.includeOnlyNonTerminalState,
373
376
  include: params?.include
374
377
  };
375
378
  return this.get("/workflows", queryParams);
@@ -415,164 +418,89 @@ var ApprovioUserClient = class extends BaseApprovioClient {
415
418
  super(config, authenticator);
416
419
  this.authenticator = authenticator;
417
420
  }
418
- /**
419
- * Lists users.
420
- */
421
421
  listUsers(params) {
422
422
  return this.get("/users", params);
423
423
  }
424
424
  registerAgent(data) {
425
425
  return this.post("/agents/register", data);
426
426
  }
427
- /**
428
- * Assign roles to an agent.
429
- */
430
427
  assignAgentRoles(agentId, data) {
431
428
  return this.put(`/agents/${agentId}/roles`, data);
432
429
  }
433
- /**
434
- * Remove roles from an agent.
435
- */
436
430
  removeAgentRoles(agentId, data) {
437
431
  return this.delete(`/agents/${agentId}/roles`, data);
438
432
  }
439
- /**
440
- * Creates a new user.
441
- */
442
433
  createUser(data) {
443
- return (0, fp_ts_function_js.pipe)(this.postWithLocation("/users", data), fp_ts_TaskEither_js.map(({ location }) => location), fp_ts_TaskEither_js.chain((location) => {
434
+ return (0, fp_ts_function.pipe)(this.postWithLocation("/users", data), fp_ts_TaskEither.map(({ location }) => location), fp_ts_TaskEither.chain((location) => {
444
435
  const id = location.split("/").pop();
445
- if (!id) return fp_ts_TaskEither_js.left(/* @__PURE__ */ new Error("Invalid location"));
446
- return fp_ts_TaskEither_js.right(id);
436
+ if (!id) return fp_ts_TaskEither.left(/* @__PURE__ */ new Error("Invalid location"));
437
+ return fp_ts_TaskEither.right(id);
447
438
  }));
448
439
  }
449
- /**
450
- * Get user details.
451
- */
452
440
  getUser(userId) {
453
441
  return this.get(`/users/${userId}`);
454
442
  }
455
- /**
456
- * Assign roles to a user.
457
- */
458
443
  assignUserRoles(userId, data) {
459
444
  return this.put(`/users/${userId}/roles`, data);
460
445
  }
461
- /**
462
- * Remove roles from a user.
463
- */
464
446
  removeUserRoles(userId, data) {
465
447
  return this.delete(`/users/${userId}/roles`, data);
466
448
  }
467
- /**
468
- * Create a new workflow template.
469
- */
470
449
  createWorkflowTemplate(data) {
471
450
  return this.post("/workflow-templates", data);
472
451
  }
473
- /**
474
- * List workflow templates.
475
- */
476
- listWorkflowTemplates(params) {
477
- return this.get("/workflow-templates", params);
452
+ listWorkflowTemplates(request) {
453
+ return this.get("/workflow-templates", request);
478
454
  }
479
- /**
480
- * Get workflow template details.
481
- */
482
455
  getWorkflowTemplate(templateIdentifier) {
483
456
  return this.get(`/workflow-templates/${templateIdentifier}`);
484
457
  }
485
- /**
486
- * Update a workflow template.
487
- */
488
458
  updateWorkflowTemplate(templateIdentifier, data) {
489
459
  return this.put(`/workflow-templates/${templateIdentifier}`, data);
490
460
  }
491
- /**
492
- * Deprecate a workflow template.
493
- */
494
461
  deprecateWorkflowTemplate(templateName, data) {
495
462
  return this.post(`/workflow-templates/${templateName}/deprecate`, data);
496
463
  }
497
- /**
498
- * Create a new group.
499
- */
500
464
  createGroup(data) {
501
- return (0, fp_ts_function_js.pipe)(this.postWithLocation("/groups", data), fp_ts_TaskEither_js.map(({ location }) => location), fp_ts_TaskEither_js.chain((location) => {
465
+ return (0, fp_ts_function.pipe)(this.postWithLocation("/groups", data), fp_ts_TaskEither.map(({ location }) => location), fp_ts_TaskEither.chain((location) => {
502
466
  const id = location.split("/").pop();
503
- if (!id) return fp_ts_TaskEither_js.left(/* @__PURE__ */ new Error("Invalid location"));
504
- return fp_ts_TaskEither_js.right(id);
467
+ if (!id) return fp_ts_TaskEither.left(/* @__PURE__ */ new Error("Invalid location"));
468
+ return fp_ts_TaskEither.right(id);
505
469
  }));
506
470
  }
507
- /**
508
- * List groups.
509
- */
510
471
  listGroups(params) {
511
472
  return this.get("/groups", params);
512
473
  }
513
- /**
514
- * Get group details.
515
- */
516
474
  getGroup(groupIdentifier) {
517
475
  return this.get(`/groups/${groupIdentifier}`);
518
476
  }
519
- /**
520
- * List entities in a group.
521
- */
522
477
  listGroupEntities(groupId, params) {
523
478
  return this.get(`/groups/${groupId}/entities`, params);
524
479
  }
525
- /**
526
- * Add entities to a group.
527
- */
528
480
  addGroupEntities(groupId, data) {
529
481
  return this.post(`/groups/${groupId}/entities`, data);
530
482
  }
531
- /**
532
- * Remove entities from a group.
533
- */
534
483
  removeGroupEntities(groupId, data) {
535
484
  return this.delete(`/groups/${groupId}/entities`, data);
536
485
  }
537
- /**
538
- * Create a new space.
539
- */
540
486
  createSpace(data) {
541
487
  return this.post("/spaces", data);
542
488
  }
543
- /**
544
- * List spaces.
545
- */
546
489
  listSpaces(params) {
547
490
  return this.get("/spaces", params);
548
491
  }
549
- /**
550
- * Get space details.
551
- */
552
492
  getSpace(spaceId) {
553
493
  return this.get(`/spaces/${spaceId}`);
554
494
  }
555
- /**
556
- * Delete a space.
557
- */
558
495
  deleteSpace(spaceId) {
559
496
  return this.delete(`/spaces/${spaceId}`);
560
497
  }
561
- /**
562
- * Add an organization admin.
563
- */
564
498
  addOrganizationAdminToOrg(organizationName, data) {
565
499
  return this.post(`/organization/${organizationName}/admins`, data);
566
500
  }
567
- /**
568
- * List organization admins.
569
- */
570
501
  listOrganizationAdminsForOrg(organizationName, params) {
571
502
  return this.get(`/organization/${organizationName}/admins`, params);
572
503
  }
573
- /**
574
- * Remove an organization admin.
575
- */
576
504
  removeOrganizationAdminFromOrg(organizationName, data) {
577
505
  return this.delete(`/organization/${organizationName}/admins`, data);
578
506
  }
package/dist/index.d.cts 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, 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";
3
- import * as TE from "fp-ts/TaskEither.js";
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
+ import * as TE from "fp-ts/TaskEither";
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<T>(url: string, params?: Record<string, unknown>): TE.TaskEither<ApprovioError, T>;
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(params?: {
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>;
@@ -145,4 +135,4 @@ declare class ApprovioAgentClient extends BaseApprovioClient {
145
135
  //#region src/client/utils.d.ts
146
136
  declare function isApprovioError(data: unknown): data is APIError;
147
137
  //#endregion
148
- export { AgentAuthenticator, ApprovioAgentClient, ApprovioError, ApprovioServerConfig, ApprovioUserClient, AuthHelper, Authenticator, BaseApprovioClient, CliUserAuthenticator, TokenBaseAuthenticator, WebAuthenticator, isApprovioError };
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, 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";
3
- import * as TE from "fp-ts/TaskEither.js";
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
+ import * as TE from "fp-ts/TaskEither";
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<T>(url: string, params?: Record<string, unknown>): TE.TaskEither<ApprovioError, T>;
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(params?: {
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>;
@@ -145,4 +135,4 @@ declare class ApprovioAgentClient extends BaseApprovioClient {
145
135
  //#region src/client/utils.d.ts
146
136
  declare function isApprovioError(data: unknown): data is APIError;
147
137
  //#endregion
148
- export { AgentAuthenticator, ApprovioAgentClient, ApprovioError, ApprovioServerConfig, ApprovioUserClient, AuthHelper, Authenticator, BaseApprovioClient, CliUserAuthenticator, TokenBaseAuthenticator, WebAuthenticator, isApprovioError };
138
+ export { AgentAuthenticator, ApprovioAgentClient, ApprovioError, ApprovioServerConfig, ApprovioUserClient, AuthHelper, Authenticator, BaseApprovioClient, CliUserAuthenticator, SafeQueryParams, TokenBaseAuthenticator, WebAuthenticator, isApprovioError };
package/dist/index.mjs CHANGED
@@ -3,8 +3,8 @@ import { decodeJwt } from "jose";
3
3
  import axios from "axios";
4
4
  import { isAPIError } from "@approvio/api";
5
5
  import * as crypto$1 from "node:crypto";
6
- import * as TE from "fp-ts/TaskEither.js";
7
- import { pipe } from "fp-ts/function.js";
6
+ import * as TE from "fp-ts/TaskEither";
7
+ import { pipe } from "fp-ts/function";
8
8
  //#region src/auth/utils.ts
9
9
  function isJwtTokenExpired(token) {
10
10
  if (!token) return true;
@@ -270,7 +270,10 @@ var BaseApprovioClient = class {
270
270
  this.config = config;
271
271
  this.authenticator = authenticator;
272
272
  validateURL(config.endpoint);
273
- this.axios = axios.create({ baseURL: removeTrailingSlash(config.endpoint) });
273
+ this.axios = axios.create({
274
+ baseURL: removeTrailingSlash(config.endpoint),
275
+ paramsSerializer: { indexes: null }
276
+ });
274
277
  this.authenticator.customizeAxios(this.axios);
275
278
  }
276
279
  handleError(error) {
@@ -343,7 +346,7 @@ var BaseApprovioClient = class {
343
346
  const queryParams = {
344
347
  page: params?.page,
345
348
  limit: params?.limit,
346
- "include-only-non-terminal-state": params?.includeOnlyNonTerminalState,
349
+ includeOnlyNonTerminalState: params?.includeOnlyNonTerminalState,
347
350
  include: params?.include
348
351
  };
349
352
  return this.get("/workflows", queryParams);
@@ -389,30 +392,18 @@ var ApprovioUserClient = class extends BaseApprovioClient {
389
392
  super(config, authenticator);
390
393
  this.authenticator = authenticator;
391
394
  }
392
- /**
393
- * Lists users.
394
- */
395
395
  listUsers(params) {
396
396
  return this.get("/users", params);
397
397
  }
398
398
  registerAgent(data) {
399
399
  return this.post("/agents/register", data);
400
400
  }
401
- /**
402
- * Assign roles to an agent.
403
- */
404
401
  assignAgentRoles(agentId, data) {
405
402
  return this.put(`/agents/${agentId}/roles`, data);
406
403
  }
407
- /**
408
- * Remove roles from an agent.
409
- */
410
404
  removeAgentRoles(agentId, data) {
411
405
  return this.delete(`/agents/${agentId}/roles`, data);
412
406
  }
413
- /**
414
- * Creates a new user.
415
- */
416
407
  createUser(data) {
417
408
  return pipe(this.postWithLocation("/users", data), TE.map(({ location }) => location), TE.chain((location) => {
418
409
  const id = location.split("/").pop();
@@ -420,57 +411,30 @@ var ApprovioUserClient = class extends BaseApprovioClient {
420
411
  return TE.right(id);
421
412
  }));
422
413
  }
423
- /**
424
- * Get user details.
425
- */
426
414
  getUser(userId) {
427
415
  return this.get(`/users/${userId}`);
428
416
  }
429
- /**
430
- * Assign roles to a user.
431
- */
432
417
  assignUserRoles(userId, data) {
433
418
  return this.put(`/users/${userId}/roles`, data);
434
419
  }
435
- /**
436
- * Remove roles from a user.
437
- */
438
420
  removeUserRoles(userId, data) {
439
421
  return this.delete(`/users/${userId}/roles`, data);
440
422
  }
441
- /**
442
- * Create a new workflow template.
443
- */
444
423
  createWorkflowTemplate(data) {
445
424
  return this.post("/workflow-templates", data);
446
425
  }
447
- /**
448
- * List workflow templates.
449
- */
450
- listWorkflowTemplates(params) {
451
- return this.get("/workflow-templates", params);
426
+ listWorkflowTemplates(request) {
427
+ return this.get("/workflow-templates", request);
452
428
  }
453
- /**
454
- * Get workflow template details.
455
- */
456
429
  getWorkflowTemplate(templateIdentifier) {
457
430
  return this.get(`/workflow-templates/${templateIdentifier}`);
458
431
  }
459
- /**
460
- * Update a workflow template.
461
- */
462
432
  updateWorkflowTemplate(templateIdentifier, data) {
463
433
  return this.put(`/workflow-templates/${templateIdentifier}`, data);
464
434
  }
465
- /**
466
- * Deprecate a workflow template.
467
- */
468
435
  deprecateWorkflowTemplate(templateName, data) {
469
436
  return this.post(`/workflow-templates/${templateName}/deprecate`, data);
470
437
  }
471
- /**
472
- * Create a new group.
473
- */
474
438
  createGroup(data) {
475
439
  return pipe(this.postWithLocation("/groups", data), TE.map(({ location }) => location), TE.chain((location) => {
476
440
  const id = location.split("/").pop();
@@ -478,75 +442,39 @@ var ApprovioUserClient = class extends BaseApprovioClient {
478
442
  return TE.right(id);
479
443
  }));
480
444
  }
481
- /**
482
- * List groups.
483
- */
484
445
  listGroups(params) {
485
446
  return this.get("/groups", params);
486
447
  }
487
- /**
488
- * Get group details.
489
- */
490
448
  getGroup(groupIdentifier) {
491
449
  return this.get(`/groups/${groupIdentifier}`);
492
450
  }
493
- /**
494
- * List entities in a group.
495
- */
496
451
  listGroupEntities(groupId, params) {
497
452
  return this.get(`/groups/${groupId}/entities`, params);
498
453
  }
499
- /**
500
- * Add entities to a group.
501
- */
502
454
  addGroupEntities(groupId, data) {
503
455
  return this.post(`/groups/${groupId}/entities`, data);
504
456
  }
505
- /**
506
- * Remove entities from a group.
507
- */
508
457
  removeGroupEntities(groupId, data) {
509
458
  return this.delete(`/groups/${groupId}/entities`, data);
510
459
  }
511
- /**
512
- * Create a new space.
513
- */
514
460
  createSpace(data) {
515
461
  return this.post("/spaces", data);
516
462
  }
517
- /**
518
- * List spaces.
519
- */
520
463
  listSpaces(params) {
521
464
  return this.get("/spaces", params);
522
465
  }
523
- /**
524
- * Get space details.
525
- */
526
466
  getSpace(spaceId) {
527
467
  return this.get(`/spaces/${spaceId}`);
528
468
  }
529
- /**
530
- * Delete a space.
531
- */
532
469
  deleteSpace(spaceId) {
533
470
  return this.delete(`/spaces/${spaceId}`);
534
471
  }
535
- /**
536
- * Add an organization admin.
537
- */
538
472
  addOrganizationAdminToOrg(organizationName, data) {
539
473
  return this.post(`/organization/${organizationName}/admins`, data);
540
474
  }
541
- /**
542
- * List organization admins.
543
- */
544
475
  listOrganizationAdminsForOrg(organizationName, params) {
545
476
  return this.get(`/organization/${organizationName}/admins`, params);
546
477
  }
547
- /**
548
- * Remove an organization admin.
549
- */
550
478
  removeOrganizationAdminFromOrg(organizationName, data) {
551
479
  return this.delete(`/organization/${organizationName}/admins`, data);
552
480
  }
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@approvio/ts-sdk",
3
- "version": "0.0.10",
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.32",
33
+ "@approvio/api": "0.0.37",
34
34
  "axios": "1.13.2",
35
35
  "jose": "6.1.3"
36
36
  },