@approvio/ts-sdk 0.0.18 → 0.0.20

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
@@ -57,7 +57,7 @@ function validateURL(url) {
57
57
  function removeTrailingSlash(url) {
58
58
  return url.endsWith("/") ? url.slice(0, -1) : url;
59
59
  }
60
- const USER_AGENT = `Approvio-TS-SDK/0.0.18`;
60
+ const USER_AGENT = `Approvio-TS-SDK/0.0.20`;
61
61
  //#endregion
62
62
  //#region src/client/http.ts
63
63
  /**
@@ -300,6 +300,13 @@ var NetworkError = class extends Error {
300
300
  super(message);
301
301
  }
302
302
  };
303
+ var UnexpectedEntityTypeError = class extends Error {
304
+ constructor(expected, received) {
305
+ super(`Expected entity type ${expected} but received ${received}`);
306
+ this.expected = expected;
307
+ this.received = received;
308
+ }
309
+ };
303
310
  //#endregion
304
311
  //#region src/client/base.client.ts
305
312
  const networkCodes = [
@@ -531,6 +538,12 @@ var ApprovioUserClient = class extends BaseApprovioClient {
531
538
  getAgent(agentId) {
532
539
  return this.get(`/agents/${agentId}`);
533
540
  }
541
+ getEntityInfo() {
542
+ return (0, fp_ts_function.pipe)(super.getEntityInfo(), fp_ts_TaskEither.chain((info) => {
543
+ if (info.entityType === "user") return fp_ts_TaskEither.right(info);
544
+ return fp_ts_TaskEither.left(new UnexpectedEntityTypeError("user", info.entityType));
545
+ }));
546
+ }
534
547
  logout() {
535
548
  return this.post("/auth/web/logout");
536
549
  }
@@ -548,6 +561,12 @@ var ApprovioAgentClient = class extends BaseApprovioClient {
548
561
  getAuthenticator() {
549
562
  return this.authenticator;
550
563
  }
564
+ getEntityInfo() {
565
+ return (0, fp_ts_function.pipe)(super.getEntityInfo(), fp_ts_TaskEither.chain((info) => {
566
+ if (info.entityType === "agent") return fp_ts_TaskEither.right(info);
567
+ return fp_ts_TaskEither.left(new UnexpectedEntityTypeError("agent", info.entityType));
568
+ }));
569
+ }
551
570
  };
552
571
  //#endregion
553
572
  exports.AgentAuthenticator = AgentAuthenticator;
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, GetWorkflowVotes200Response, Group, GroupCreate, ListGroupEntities200Response, ListGroups200Response, ListGroupsParams, ListOrganizationAdminsForOrg200Response, ListRoleTemplates200Response, ListSpaces200Response, ListSpacesParams, ListUsers200Response, ListUsersParams, ListWorkflowTemplates200Response, ListWorkflowTemplatesParams, ListWorkflowVotesParams, 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, GetEntityInfoAgentResponse, GetEntityInfoUserResponse, GetWorkflowParams, GetWorkflowVotes200Response, Group, GroupCreate, ListGroupEntities200Response, ListGroups200Response, ListGroupsParams, ListOrganizationAdminsForOrg200Response, ListRoleTemplates200Response, ListSpaces200Response, ListSpacesParams, ListUsers200Response, ListUsersParams, ListWorkflowTemplates200Response, ListWorkflowTemplatesParams, ListWorkflowVotesParams, 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
@@ -127,6 +127,7 @@ declare class ApprovioUserClient extends BaseApprovioClient {
127
127
  }): TE.TaskEither<ApprovioError, ListOrganizationAdminsForOrg200Response>;
128
128
  removeOrganizationAdminFromOrg(organizationName: string, data: OrganizationAdminRemove): TE.TaskEither<ApprovioError, void>;
129
129
  getAgent(agentId: string): TE.TaskEither<ApprovioError, AgentGet200Response>;
130
+ getEntityInfo(): TE.TaskEither<ApprovioError, GetEntityInfoUserResponse>;
130
131
  logout(): TE.TaskEither<ApprovioError, void>;
131
132
  }
132
133
  //#endregion
@@ -135,6 +136,7 @@ declare class ApprovioAgentClient extends BaseApprovioClient {
135
136
  readonly authenticator: AgentAuthenticator;
136
137
  constructor(config: ApprovioServerConfig, authenticator: AgentAuthenticator);
137
138
  getAuthenticator(): Authenticator;
139
+ getEntityInfo(): TE.TaskEither<ApprovioError, GetEntityInfoAgentResponse>;
138
140
  }
139
141
  //#endregion
140
142
  //#region src/client/utils.d.ts
package/dist/index.d.mts CHANGED
@@ -1,4 +1,4 @@
1
- import { APIError, AddGroupEntitiesRequest, AgentGet200Response, AgentRegistrationRequest, AgentRegistrationResponse, AgentTokenResponse, CanVoteResponse, GetEntityInfo200Response, GetWorkflowParams, GetWorkflowVotes200Response, Group, GroupCreate, ListGroupEntities200Response, ListGroups200Response, ListGroupsParams, ListOrganizationAdminsForOrg200Response, ListRoleTemplates200Response, ListSpaces200Response, ListSpacesParams, ListUsers200Response, ListUsersParams, ListWorkflowTemplates200Response, ListWorkflowTemplatesParams, ListWorkflowVotesParams, ListWorkflows200Response, ListWorkflowsParams, OrganizationAdminCreate, OrganizationAdminRemove, RemoveGroupEntitiesRequest, RoleAssignmentRequest, RoleRemovalRequest, Space, SpaceCreate, TokenResponse, User, UserCreate, Workflow, WorkflowCreate, WorkflowTemplate, WorkflowTemplateCreate, WorkflowTemplateDeprecate, WorkflowTemplateUpdate, WorkflowVoteRequest } from "@approvio/api";
1
+ import { APIError, AddGroupEntitiesRequest, AgentGet200Response, AgentRegistrationRequest, AgentRegistrationResponse, AgentTokenResponse, CanVoteResponse, GetEntityInfo200Response, GetEntityInfoAgentResponse, GetEntityInfoUserResponse, GetWorkflowParams, GetWorkflowVotes200Response, Group, GroupCreate, ListGroupEntities200Response, ListGroups200Response, ListGroupsParams, ListOrganizationAdminsForOrg200Response, ListRoleTemplates200Response, ListSpaces200Response, ListSpacesParams, ListUsers200Response, ListUsersParams, ListWorkflowTemplates200Response, ListWorkflowTemplatesParams, ListWorkflowVotesParams, ListWorkflows200Response, ListWorkflowsParams, OrganizationAdminCreate, OrganizationAdminRemove, RemoveGroupEntitiesRequest, RoleAssignmentRequest, RoleRemovalRequest, Space, SpaceCreate, TokenResponse, User, UserCreate, Workflow, WorkflowCreate, WorkflowTemplate, WorkflowTemplateCreate, WorkflowTemplateDeprecate, WorkflowTemplateUpdate, WorkflowVoteRequest } from "@approvio/api";
2
2
  import { AxiosInstance } from "axios";
3
3
  import * as TE from "fp-ts/TaskEither";
4
4
 
@@ -127,6 +127,7 @@ declare class ApprovioUserClient extends BaseApprovioClient {
127
127
  }): TE.TaskEither<ApprovioError, ListOrganizationAdminsForOrg200Response>;
128
128
  removeOrganizationAdminFromOrg(organizationName: string, data: OrganizationAdminRemove): TE.TaskEither<ApprovioError, void>;
129
129
  getAgent(agentId: string): TE.TaskEither<ApprovioError, AgentGet200Response>;
130
+ getEntityInfo(): TE.TaskEither<ApprovioError, GetEntityInfoUserResponse>;
130
131
  logout(): TE.TaskEither<ApprovioError, void>;
131
132
  }
132
133
  //#endregion
@@ -135,6 +136,7 @@ declare class ApprovioAgentClient extends BaseApprovioClient {
135
136
  readonly authenticator: AgentAuthenticator;
136
137
  constructor(config: ApprovioServerConfig, authenticator: AgentAuthenticator);
137
138
  getAuthenticator(): Authenticator;
139
+ getEntityInfo(): TE.TaskEither<ApprovioError, GetEntityInfoAgentResponse>;
138
140
  }
139
141
  //#endregion
140
142
  //#region src/client/utils.d.ts
package/dist/index.mjs CHANGED
@@ -31,7 +31,7 @@ function validateURL(url) {
31
31
  function removeTrailingSlash(url) {
32
32
  return url.endsWith("/") ? url.slice(0, -1) : url;
33
33
  }
34
- const USER_AGENT = `Approvio-TS-SDK/0.0.18`;
34
+ const USER_AGENT = `Approvio-TS-SDK/0.0.20`;
35
35
  //#endregion
36
36
  //#region src/client/http.ts
37
37
  /**
@@ -274,6 +274,13 @@ var NetworkError = class extends Error {
274
274
  super(message);
275
275
  }
276
276
  };
277
+ var UnexpectedEntityTypeError = class extends Error {
278
+ constructor(expected, received) {
279
+ super(`Expected entity type ${expected} but received ${received}`);
280
+ this.expected = expected;
281
+ this.received = received;
282
+ }
283
+ };
277
284
  //#endregion
278
285
  //#region src/client/base.client.ts
279
286
  const networkCodes = [
@@ -505,6 +512,12 @@ var ApprovioUserClient = class extends BaseApprovioClient {
505
512
  getAgent(agentId) {
506
513
  return this.get(`/agents/${agentId}`);
507
514
  }
515
+ getEntityInfo() {
516
+ return pipe(super.getEntityInfo(), TE.chain((info) => {
517
+ if (info.entityType === "user") return TE.right(info);
518
+ return TE.left(new UnexpectedEntityTypeError("user", info.entityType));
519
+ }));
520
+ }
508
521
  logout() {
509
522
  return this.post("/auth/web/logout");
510
523
  }
@@ -522,6 +535,12 @@ var ApprovioAgentClient = class extends BaseApprovioClient {
522
535
  getAuthenticator() {
523
536
  return this.authenticator;
524
537
  }
538
+ getEntityInfo() {
539
+ return pipe(super.getEntityInfo(), TE.chain((info) => {
540
+ if (info.entityType === "agent") return TE.right(info);
541
+ return TE.left(new UnexpectedEntityTypeError("agent", info.entityType));
542
+ }));
543
+ }
525
544
  };
526
545
  //#endregion
527
546
  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.18",
3
+ "version": "0.0.20",
4
4
  "type": "module",
5
5
  "main": "dist/index.cjs",
6
6
  "module": "./dist/index.mjs",
@@ -34,7 +34,7 @@
34
34
  "prepublishOnly": "yarn format && yarn lint && yarn build"
35
35
  },
36
36
  "dependencies": {
37
- "@approvio/api": "0.0.50",
37
+ "@approvio/api": "0.0.52",
38
38
  "axios": "1.16.1",
39
39
  "jose": "6.2.3"
40
40
  },