@approvio/ts-sdk 0.0.25 → 0.0.26

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
@@ -22,15 +22,15 @@ var __toESM = (mod, isNodeMode, target) => (target = mod != null ? __create(__ge
22
22
  }) : target, mod));
23
23
  //#endregion
24
24
  let jose = require("jose");
25
- jose = __toESM(jose);
25
+ jose = __toESM(jose, 1);
26
26
  let _approvio_api = require("@approvio/api");
27
27
  let axios = require("axios");
28
- axios = __toESM(axios);
28
+ axios = __toESM(axios, 1);
29
29
  let node_crypto = require("node:crypto");
30
- node_crypto = __toESM(node_crypto);
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");
30
+ node_crypto = __toESM(node_crypto, 1);
31
+ let fp_ts_lib_TaskEither_js = require("fp-ts/lib/TaskEither.js");
32
+ fp_ts_lib_TaskEither_js = __toESM(fp_ts_lib_TaskEither_js, 1);
33
+ let fp_ts_lib_function_js = require("fp-ts/lib/function.js");
34
34
  //#region src/auth/utils.ts
35
35
  function isJwtTokenExpired(token) {
36
36
  if (!token) return true;
@@ -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.25`;
60
+ const USER_AGENT = `Approvio-TS-SDK/0.0.26`;
61
61
  //#endregion
62
62
  //#region src/client/http.ts
63
63
  /**
@@ -79,6 +79,9 @@ function createAxiosInstance(config) {
79
79
  * Handles automatic token renewal using a refresh token when the access token expires.
80
80
  */
81
81
  var CliUserAuthenticator = class {
82
+ accessToken;
83
+ refreshToken;
84
+ onTokenRefreshed;
82
85
  endpoint;
83
86
  axios;
84
87
  constructor(endpoint, accessToken, refreshToken, onTokenRefreshed) {
@@ -168,7 +171,7 @@ var AuthHelper = class {
168
171
  * Prompts the backend to return an authorization URL for the IDP.
169
172
  */
170
173
  initiateCliLogin(redirectUri) {
171
- return fp_ts_TaskEither.tryCatch(async () => {
174
+ return fp_ts_lib_TaskEither_js.tryCatch(async () => {
172
175
  return (await this.axios.post("/auth/cli/initiate", { redirectUri })).data.authorizationUrl;
173
176
  }, (error) => this.handleError(error));
174
177
  }
@@ -181,7 +184,7 @@ var AuthHelper = class {
181
184
  code,
182
185
  state
183
186
  };
184
- return fp_ts_TaskEither.tryCatch(async () => {
187
+ return fp_ts_lib_TaskEither_js.tryCatch(async () => {
185
188
  return (await this.axios.post("/auth/cli/token", request)).data;
186
189
  }, (error) => this.handleError(error));
187
190
  }
@@ -193,7 +196,7 @@ var AuthHelper = class {
193
196
  * 4. Exchange the assertion for an access token.
194
197
  */
195
198
  authenticateAgent(agentName, privateKeyPem) {
196
- return fp_ts_TaskEither.tryCatch(async () => {
199
+ return fp_ts_lib_TaskEither_js.tryCatch(async () => {
197
200
  const challengeRequest = { agentName };
198
201
  const { challenge: b64EncodedChallenge } = (await this.axios.post("/auth/agents/challenge", challengeRequest)).data;
199
202
  const encryptedBuffer = Buffer.from(b64EncodedChallenge, "base64");
@@ -240,6 +243,10 @@ var AuthHelper = class {
240
243
  * Handles automatic token renewal using a refresh token and DPoP proof when the access token expires.
241
244
  */
242
245
  var AgentAuthenticator = class {
246
+ privateKey;
247
+ accessToken;
248
+ refreshToken;
249
+ onTokenRefreshed;
243
250
  endpoint;
244
251
  axios;
245
252
  constructor(endpoint, privateKey, accessToken, refreshToken, onTokenRefreshed) {
@@ -301,6 +308,8 @@ var NetworkError = class extends Error {
301
308
  }
302
309
  };
303
310
  var UnexpectedEntityTypeError = class extends Error {
311
+ expected;
312
+ received;
304
313
  constructor(expected, received) {
305
314
  super(`Expected entity type ${expected} but received ${received}`);
306
315
  this.expected = expected;
@@ -319,6 +328,8 @@ const networkCodes = [
319
328
  * Base client for Approvio API.
320
329
  */
321
330
  var BaseApprovioClient = class {
331
+ config;
332
+ authenticator;
322
333
  axios;
323
334
  constructor(config, authenticator) {
324
335
  this.config = config;
@@ -347,7 +358,7 @@ var BaseApprovioClient = class {
347
358
  * Performs a GET request.
348
359
  */
349
360
  get(url, params) {
350
- return fp_ts_TaskEither.tryCatch(async () => {
361
+ return fp_ts_lib_TaskEither_js.tryCatch(async () => {
351
362
  return (await this.axios.get(url, { params })).data;
352
363
  }, (error) => this.handleError(error));
353
364
  }
@@ -355,12 +366,12 @@ var BaseApprovioClient = class {
355
366
  * Performs a POST request.
356
367
  */
357
368
  post(url, data) {
358
- return fp_ts_TaskEither.tryCatch(async () => {
369
+ return fp_ts_lib_TaskEither_js.tryCatch(async () => {
359
370
  return (await this.axios.post(url, data)).data;
360
371
  }, (error) => this.handleError(error));
361
372
  }
362
373
  postWithLocation(url, data) {
363
- return fp_ts_TaskEither.tryCatch(async () => {
374
+ return fp_ts_lib_TaskEither_js.tryCatch(async () => {
364
375
  const response = await this.axios.post(url, data);
365
376
  const location = response.headers["location"];
366
377
  if (!location) throw new LocationNotFoundError();
@@ -374,7 +385,7 @@ var BaseApprovioClient = class {
374
385
  * Performs a PUT request.
375
386
  */
376
387
  put(url, data) {
377
- return fp_ts_TaskEither.tryCatch(async () => {
388
+ return fp_ts_lib_TaskEither_js.tryCatch(async () => {
378
389
  return (await this.axios.put(url, data)).data;
379
390
  }, (error) => this.handleError(error));
380
391
  }
@@ -382,7 +393,7 @@ var BaseApprovioClient = class {
382
393
  * Performs a DELETE request.
383
394
  */
384
395
  delete(url, data) {
385
- return fp_ts_TaskEither.tryCatch(async () => {
396
+ return fp_ts_lib_TaskEither_js.tryCatch(async () => {
386
397
  const config = data !== void 0 ? { data } : void 0;
387
398
  return (await this.axios.delete(url, config)).data;
388
399
  }, (error) => this.handleError(error));
@@ -445,6 +456,7 @@ var BaseApprovioClient = class {
445
456
  * Client for Approvio API (Human/User).
446
457
  */
447
458
  var ApprovioUserClient = class extends BaseApprovioClient {
459
+ authenticator;
448
460
  constructor(config, authenticator) {
449
461
  super(config, authenticator);
450
462
  this.authenticator = authenticator;
@@ -462,10 +474,10 @@ var ApprovioUserClient = class extends BaseApprovioClient {
462
474
  return this.delete(`/agents/${agentId}/roles`, data);
463
475
  }
464
476
  createUser(data) {
465
- return (0, fp_ts_function.pipe)(this.postWithLocation("/users", data), fp_ts_TaskEither.map(({ location }) => location), fp_ts_TaskEither.chain((location) => {
477
+ return (0, fp_ts_lib_function_js.pipe)(this.postWithLocation("/users", data), fp_ts_lib_TaskEither_js.map(({ location }) => location), fp_ts_lib_TaskEither_js.chain((location) => {
466
478
  const id = location.split("/").pop();
467
- if (!id) return fp_ts_TaskEither.left(/* @__PURE__ */ new Error("Invalid location"));
468
- return fp_ts_TaskEither.right(id);
479
+ if (!id) return fp_ts_lib_TaskEither_js.left(/* @__PURE__ */ new Error("Invalid location"));
480
+ return fp_ts_lib_TaskEither_js.right(id);
469
481
  }));
470
482
  }
471
483
  getUser(userId) {
@@ -493,10 +505,10 @@ var ApprovioUserClient = class extends BaseApprovioClient {
493
505
  return this.post(`/workflow-templates/${templateName}/deprecate`, data);
494
506
  }
495
507
  createGroup(data) {
496
- return (0, fp_ts_function.pipe)(this.postWithLocation("/groups", data), fp_ts_TaskEither.map(({ location }) => location), fp_ts_TaskEither.chain((location) => {
508
+ return (0, fp_ts_lib_function_js.pipe)(this.postWithLocation("/groups", data), fp_ts_lib_TaskEither_js.map(({ location }) => location), fp_ts_lib_TaskEither_js.chain((location) => {
497
509
  const id = location.split("/").pop();
498
- if (!id) return fp_ts_TaskEither.left(/* @__PURE__ */ new Error("Invalid location"));
499
- return fp_ts_TaskEither.right(id);
510
+ if (!id) return fp_ts_lib_TaskEither_js.left(/* @__PURE__ */ new Error("Invalid location"));
511
+ return fp_ts_lib_TaskEither_js.right(id);
500
512
  }));
501
513
  }
502
514
  listGroups(params) {
@@ -539,9 +551,9 @@ var ApprovioUserClient = class extends BaseApprovioClient {
539
551
  return this.get(`/agents/${agentId}`);
540
552
  }
541
553
  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));
554
+ return (0, fp_ts_lib_function_js.pipe)(super.getEntityInfo(), fp_ts_lib_TaskEither_js.chain((info) => {
555
+ if (info.entityType === "user") return fp_ts_lib_TaskEither_js.right(info);
556
+ return fp_ts_lib_TaskEither_js.left(new UnexpectedEntityTypeError("user", info.entityType));
545
557
  }));
546
558
  }
547
559
  listAuditLogs(params) {
@@ -550,6 +562,9 @@ var ApprovioUserClient = class extends BaseApprovioClient {
550
562
  listMyAuditLogs(params) {
551
563
  return this.get("/audit-logs/me", params);
552
564
  }
565
+ resolveResources(params) {
566
+ return this.post("/resources/resolve", params);
567
+ }
553
568
  logout() {
554
569
  return this.post("/auth/web/logout");
555
570
  }
@@ -560,6 +575,7 @@ var ApprovioUserClient = class extends BaseApprovioClient {
560
575
  * Client for Approvio API (Agent).
561
576
  */
562
577
  var ApprovioAgentClient = class extends BaseApprovioClient {
578
+ authenticator;
563
579
  constructor(config, authenticator) {
564
580
  super(config, authenticator);
565
581
  this.authenticator = authenticator;
@@ -568,9 +584,9 @@ var ApprovioAgentClient = class extends BaseApprovioClient {
568
584
  return this.authenticator;
569
585
  }
570
586
  getEntityInfo() {
571
- return (0, fp_ts_function.pipe)(super.getEntityInfo(), fp_ts_TaskEither.chain((info) => {
572
- if (info.entityType === "agent") return fp_ts_TaskEither.right(info);
573
- return fp_ts_TaskEither.left(new UnexpectedEntityTypeError("agent", info.entityType));
587
+ return (0, fp_ts_lib_function_js.pipe)(super.getEntityInfo(), fp_ts_lib_TaskEither_js.chain((info) => {
588
+ if (info.entityType === "agent") return fp_ts_lib_TaskEither_js.right(info);
589
+ return fp_ts_lib_TaskEither_js.left(new UnexpectedEntityTypeError("agent", info.entityType));
574
590
  }));
575
591
  }
576
592
  };
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, GetEntityInfoAgentResponse, GetEntityInfoUserResponse, GetWorkflowParams, GetWorkflowVotes200Response, Group, GroupCreate, ListAuditLogs200Response, ListAuditLogsParams, ListGroupEntities200Response, ListGroups200Response, ListGroupsParams, ListMyAuditLogsParams, 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
- import * as TE from "fp-ts/TaskEither";
2
+ import { APIError, AddGroupEntitiesRequest, AgentGet200Response, AgentRegistrationRequest, AgentRegistrationResponse, AgentTokenResponse, CanVoteResponse, GetEntityInfo200Response, GetEntityInfoAgentResponse, GetEntityInfoUserResponse, GetWorkflowParams, GetWorkflowVotes200Response, Group, GroupCreate, ListAuditLogs200Response, ListAuditLogsParams, ListGroupEntities200Response, ListGroups200Response, ListGroupsParams, ListMyAuditLogsParams, ListOrganizationAdminsForOrg200Response, ListRoleTemplates200Response, ListSpaces200Response, ListSpacesParams, ListUsers200Response, ListUsersParams, ListWorkflowTemplates200Response, ListWorkflowTemplatesParams, ListWorkflowVotesParams, ListWorkflows200Response, ListWorkflowsParams, OrganizationAdminCreate, OrganizationAdminRemove, RemoveGroupEntitiesRequest, ResourceResolveRequest, ResourceResolveResponse, RoleAssignmentRequest, RoleRemovalRequest, Space, SpaceCreate, TokenResponse, User, UserCreate, Workflow, WorkflowCreate, WorkflowTemplate, WorkflowTemplateCreate, WorkflowTemplateDeprecate, WorkflowTemplateUpdate, WorkflowVoteRequest } from "@approvio/api";
3
+ import * as TE from "fp-ts/lib/TaskEither.js";
4
4
 
5
5
  //#region src/interfaces.d.ts
6
6
  interface Authenticator {
@@ -130,6 +130,7 @@ declare class ApprovioUserClient extends BaseApprovioClient {
130
130
  getEntityInfo(): TE.TaskEither<ApprovioError, GetEntityInfoUserResponse>;
131
131
  listAuditLogs(params?: ListAuditLogsParams): TE.TaskEither<ApprovioError, ListAuditLogs200Response>;
132
132
  listMyAuditLogs(params?: ListMyAuditLogsParams): TE.TaskEither<ApprovioError, ListAuditLogs200Response>;
133
+ resolveResources(params: ResourceResolveRequest): TE.TaskEither<ApprovioError, ResourceResolveResponse>;
133
134
  logout(): TE.TaskEither<ApprovioError, void>;
134
135
  }
135
136
  //#endregion
package/dist/index.d.mts CHANGED
@@ -1,6 +1,6 @@
1
- import { APIError, AddGroupEntitiesRequest, AgentGet200Response, AgentRegistrationRequest, AgentRegistrationResponse, AgentTokenResponse, CanVoteResponse, GetEntityInfo200Response, GetEntityInfoAgentResponse, GetEntityInfoUserResponse, GetWorkflowParams, GetWorkflowVotes200Response, Group, GroupCreate, ListAuditLogs200Response, ListAuditLogsParams, ListGroupEntities200Response, ListGroups200Response, ListGroupsParams, ListMyAuditLogsParams, 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, ListAuditLogs200Response, ListAuditLogsParams, ListGroupEntities200Response, ListGroups200Response, ListGroupsParams, ListMyAuditLogsParams, ListOrganizationAdminsForOrg200Response, ListRoleTemplates200Response, ListSpaces200Response, ListSpacesParams, ListUsers200Response, ListUsersParams, ListWorkflowTemplates200Response, ListWorkflowTemplatesParams, ListWorkflowVotesParams, ListWorkflows200Response, ListWorkflowsParams, OrganizationAdminCreate, OrganizationAdminRemove, RemoveGroupEntitiesRequest, ResourceResolveRequest, ResourceResolveResponse, RoleAssignmentRequest, RoleRemovalRequest, Space, SpaceCreate, TokenResponse, User, UserCreate, Workflow, WorkflowCreate, WorkflowTemplate, WorkflowTemplateCreate, WorkflowTemplateDeprecate, WorkflowTemplateUpdate, WorkflowVoteRequest } from "@approvio/api";
2
2
  import { AxiosInstance } from "axios";
3
- import * as TE from "fp-ts/TaskEither";
3
+ import * as TE from "fp-ts/lib/TaskEither.js";
4
4
 
5
5
  //#region src/interfaces.d.ts
6
6
  interface Authenticator {
@@ -130,6 +130,7 @@ declare class ApprovioUserClient extends BaseApprovioClient {
130
130
  getEntityInfo(): TE.TaskEither<ApprovioError, GetEntityInfoUserResponse>;
131
131
  listAuditLogs(params?: ListAuditLogsParams): TE.TaskEither<ApprovioError, ListAuditLogs200Response>;
132
132
  listMyAuditLogs(params?: ListMyAuditLogsParams): TE.TaskEither<ApprovioError, ListAuditLogs200Response>;
133
+ resolveResources(params: ResourceResolveRequest): TE.TaskEither<ApprovioError, ResourceResolveResponse>;
133
134
  logout(): TE.TaskEither<ApprovioError, void>;
134
135
  }
135
136
  //#endregion
package/dist/index.mjs CHANGED
@@ -3,8 +3,8 @@ import { decodeJwt } from "jose";
3
3
  import { isAPIError } from "@approvio/api";
4
4
  import axios from "axios";
5
5
  import * as crypto$1 from "node:crypto";
6
- import * as TE from "fp-ts/TaskEither";
7
- import { pipe } from "fp-ts/function";
6
+ import * as TE from "fp-ts/lib/TaskEither.js";
7
+ import { pipe } from "fp-ts/lib/function.js";
8
8
  //#region src/auth/utils.ts
9
9
  function isJwtTokenExpired(token) {
10
10
  if (!token) return true;
@@ -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.25`;
34
+ const USER_AGENT = `Approvio-TS-SDK/0.0.26`;
35
35
  //#endregion
36
36
  //#region src/client/http.ts
37
37
  /**
@@ -53,6 +53,9 @@ function createAxiosInstance(config) {
53
53
  * Handles automatic token renewal using a refresh token when the access token expires.
54
54
  */
55
55
  var CliUserAuthenticator = class {
56
+ accessToken;
57
+ refreshToken;
58
+ onTokenRefreshed;
56
59
  endpoint;
57
60
  axios;
58
61
  constructor(endpoint, accessToken, refreshToken, onTokenRefreshed) {
@@ -214,6 +217,10 @@ var AuthHelper = class {
214
217
  * Handles automatic token renewal using a refresh token and DPoP proof when the access token expires.
215
218
  */
216
219
  var AgentAuthenticator = class {
220
+ privateKey;
221
+ accessToken;
222
+ refreshToken;
223
+ onTokenRefreshed;
217
224
  endpoint;
218
225
  axios;
219
226
  constructor(endpoint, privateKey, accessToken, refreshToken, onTokenRefreshed) {
@@ -275,6 +282,8 @@ var NetworkError = class extends Error {
275
282
  }
276
283
  };
277
284
  var UnexpectedEntityTypeError = class extends Error {
285
+ expected;
286
+ received;
278
287
  constructor(expected, received) {
279
288
  super(`Expected entity type ${expected} but received ${received}`);
280
289
  this.expected = expected;
@@ -293,6 +302,8 @@ const networkCodes = [
293
302
  * Base client for Approvio API.
294
303
  */
295
304
  var BaseApprovioClient = class {
305
+ config;
306
+ authenticator;
296
307
  axios;
297
308
  constructor(config, authenticator) {
298
309
  this.config = config;
@@ -419,6 +430,7 @@ var BaseApprovioClient = class {
419
430
  * Client for Approvio API (Human/User).
420
431
  */
421
432
  var ApprovioUserClient = class extends BaseApprovioClient {
433
+ authenticator;
422
434
  constructor(config, authenticator) {
423
435
  super(config, authenticator);
424
436
  this.authenticator = authenticator;
@@ -524,6 +536,9 @@ var ApprovioUserClient = class extends BaseApprovioClient {
524
536
  listMyAuditLogs(params) {
525
537
  return this.get("/audit-logs/me", params);
526
538
  }
539
+ resolveResources(params) {
540
+ return this.post("/resources/resolve", params);
541
+ }
527
542
  logout() {
528
543
  return this.post("/auth/web/logout");
529
544
  }
@@ -534,6 +549,7 @@ var ApprovioUserClient = class extends BaseApprovioClient {
534
549
  * Client for Approvio API (Agent).
535
550
  */
536
551
  var ApprovioAgentClient = class extends BaseApprovioClient {
552
+ authenticator;
537
553
  constructor(config, authenticator) {
538
554
  super(config, authenticator);
539
555
  this.authenticator = authenticator;
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@approvio/ts-sdk",
3
- "version": "0.0.25",
3
+ "version": "0.0.26",
4
4
  "type": "module",
5
5
  "main": "dist/index.cjs",
6
6
  "module": "./dist/index.mjs",
@@ -55,10 +55,10 @@
55
55
  "fp-ts": "2.16.11",
56
56
  "io-ts": "2.2.20",
57
57
  "jest": "29.7.0",
58
- "prettier": "3.7.4",
58
+ "prettier": "3.8.3",
59
59
  "semver": "^7.8.0",
60
60
  "ts-jest": "29.4.6",
61
- "tsdown": "^0.21.4",
61
+ "tsdown": "^0.22.3",
62
62
  "typescript": "5.9.3"
63
63
  }
64
64
  }