@approvio/api 0.0.33 → 0.0.35

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.
@@ -370,12 +370,22 @@ function validateSharedListParams(object) {
370
370
  if (typeof object !== "object" || object === null) return (0, fp_ts_Either.left)("malformed_object");
371
371
  const result = {};
372
372
  if (hasOwnProperty(object, "page") && object.page !== void 0) {
373
- if (typeof object.page !== "number" || object.page < 1) return (0, fp_ts_Either.left)("invalid_page");
374
- result.page = object.page;
373
+ let page = object.page;
374
+ if (typeof page === "string" && page.trim() !== "") {
375
+ const parsed = Number(page);
376
+ if (!isNaN(parsed)) page = parsed;
377
+ }
378
+ if (typeof page !== "number" || !Number.isInteger(page) || page < 1) return (0, fp_ts_Either.left)("invalid_page");
379
+ result.page = page;
375
380
  }
376
381
  if (hasOwnProperty(object, "limit") && object.limit !== void 0) {
377
- if (typeof object.limit !== "number" || object.limit < 1) return (0, fp_ts_Either.left)("invalid_limit");
378
- result.limit = object.limit;
382
+ let limit = object.limit;
383
+ if (typeof limit === "string" && limit.trim() !== "") {
384
+ const parsed = Number(limit);
385
+ if (!isNaN(parsed)) limit = parsed;
386
+ }
387
+ if (typeof limit !== "number" || !Number.isInteger(limit) || limit < 1) return (0, fp_ts_Either.left)("invalid_limit");
388
+ result.limit = limit;
379
389
  }
380
390
  if (hasOwnProperty(object, "search") && object.search !== void 0) {
381
391
  if (typeof object.search !== "string" || object.search.trim() === "") return (0, fp_ts_Either.left)("invalid_search");
@@ -428,6 +438,11 @@ function getStringAsEnum(str, enumType) {
428
438
  if (Object.values(enumType).includes(str)) return str;
429
439
  }
430
440
  //#endregion
441
+ //#region src/utils/types.ts
442
+ function prefixLeft(prefix, value) {
443
+ return `${prefix}_${value}`;
444
+ }
445
+ //#endregion
431
446
  //#region src/validators/workflow-templates.validators.ts
432
447
  function validateEmailAction(object) {
433
448
  if (typeof object !== "object" || object === null) return (0, fp_ts_Either.left)("malformed_object");
@@ -675,11 +690,8 @@ function validateWorkflowTemplateScope(object) {
675
690
  if (typeof object !== "object" || object === null) return (0, fp_ts_Either.left)("malformed_object");
676
691
  if (!hasOwnProperty(object, "type") || object.type !== "workflow_template") return (0, fp_ts_Either.left)("invalid_type");
677
692
  if (!hasOwnProperty(object, "workflowTemplateId") || !isNonEmptyString(object.workflowTemplateId)) return (0, fp_ts_Either.left)("invalid_workflow_template_id");
678
- if (!hasOwnProperty(object, "type") || typeof object.type !== "string") return (0, fp_ts_Either.left)("invalid_type");
679
- const type = getStringAsEnum(object.type, WorkflowTemplateScope.TypeEnum);
680
- if (!type) return (0, fp_ts_Either.left)("invalid_type");
681
693
  return (0, fp_ts_Either.right)({
682
- type,
694
+ type: object.type,
683
695
  workflowTemplateId: object.workflowTemplateId
684
696
  });
685
697
  }
@@ -709,7 +721,7 @@ function validateListWorkflowTemplates200Response(object) {
709
721
  const data = [];
710
722
  for (const item of object.data) {
711
723
  const validatedItem = validateWorkflowTemplateSummary(item);
712
- if ((0, fp_ts_Either.isLeft)(validatedItem)) return (0, fp_ts_Either.left)("invalid_data_element");
724
+ if ((0, fp_ts_Either.isLeft)(validatedItem)) return (0, fp_ts_Either.left)(prefixLeft("data_item", validatedItem.left));
713
725
  data.push(validatedItem.right);
714
726
  }
715
727
  if (!hasOwnProperty(object, "pagination")) return (0, fp_ts_Either.left)("missing_pagination");
@@ -817,19 +829,10 @@ function validateGetWorkflowParams(object) {
817
829
  return (0, fp_ts_Either.right)({ include });
818
830
  }
819
831
  function validateListWorkflowsParams(object) {
832
+ const sharedValidation = (0, fp_ts_function.pipe)(validateSharedListParams(object), (0, fp_ts_Either.mapLeft)((error) => error === "invalid_search" ? "malformed_object" : error));
833
+ if ((0, fp_ts_Either.isLeft)(sharedValidation)) return (0, fp_ts_Either.left)(sharedValidation.left);
834
+ const result = sharedValidation.right;
820
835
  if (typeof object !== "object" || object === null) return (0, fp_ts_Either.left)("malformed_object");
821
- let page = void 0;
822
- if (hasOwnProperty(object, "page")) {
823
- const val = object["page"];
824
- if (typeof val !== "number") return (0, fp_ts_Either.left)("invalid_page");
825
- page = val;
826
- }
827
- let limit = void 0;
828
- if (hasOwnProperty(object, "limit")) {
829
- const val = object["limit"];
830
- if (typeof val !== "number") return (0, fp_ts_Either.left)("invalid_limit");
831
- limit = val;
832
- }
833
836
  let include = void 0;
834
837
  if (hasOwnProperty(object, "include")) {
835
838
  const includeVal = object["include"];
@@ -853,13 +856,10 @@ function validateListWorkflowsParams(object) {
853
856
  if (typeof val !== "string") return (0, fp_ts_Either.left)("invalid_workflow_template_identifier");
854
857
  workflowTemplateIdentifier = val;
855
858
  }
856
- return (0, fp_ts_Either.right)({
857
- page,
858
- limit,
859
- include,
860
- includeOnlyNonTerminalState,
861
- workflowTemplateIdentifier
862
- });
859
+ if (include !== void 0) result.include = include;
860
+ if (includeOnlyNonTerminalState !== void 0) result.includeOnlyNonTerminalState = includeOnlyNonTerminalState;
861
+ if (workflowTemplateIdentifier !== void 0) result.workflowTemplateIdentifier = workflowTemplateIdentifier;
862
+ return (0, fp_ts_Either.right)(result);
863
863
  }
864
864
  function validateListWorkflows200Response(object) {
865
865
  if (typeof object !== "object" || object === null) return (0, fp_ts_Either.left)("malformed_object");
@@ -1247,21 +1247,10 @@ function validateAgentTokenResponse(object) {
1247
1247
  });
1248
1248
  }
1249
1249
  function validateListAgentsParams(object) {
1250
- if (typeof object !== "object" || object === null) return (0, fp_ts_Either.left)("malformed_object");
1251
- let page = void 0;
1252
- if (hasOwnProperty(object, "page") && object.page !== void 0) {
1253
- if (typeof object.page !== "number") return (0, fp_ts_Either.left)("invalid_page");
1254
- page = object.page;
1255
- }
1256
- let limit = void 0;
1257
- if (hasOwnProperty(object, "limit") && object.limit !== void 0) {
1258
- if (typeof object.limit !== "number") return (0, fp_ts_Either.left)("invalid_limit");
1259
- limit = object.limit;
1260
- }
1261
- return (0, fp_ts_Either.right)({
1262
- page,
1263
- limit
1264
- });
1250
+ const sharedValidation = (0, fp_ts_function.pipe)(validateSharedListParams(object), (0, fp_ts_Either.mapLeft)((error) => error === "invalid_search" ? "malformed_object" : error));
1251
+ if ((0, fp_ts_Either.isLeft)(sharedValidation)) return (0, fp_ts_Either.left)(sharedValidation.left);
1252
+ const result = sharedValidation.right;
1253
+ return (0, fp_ts_Either.right)(result);
1265
1254
  }
1266
1255
  function validateListAgents200Response(object) {
1267
1256
  if (typeof object !== "object" || object === null) return (0, fp_ts_Either.left)("malformed_object");
@@ -1434,16 +1434,6 @@ declare function validateRoleRemovalRequest(object: unknown): Either<RoleOperati
1434
1434
  type ListUsersParamsValidationError = "malformed_object" | "invalid_page" | "invalid_limit" | "invalid_search";
1435
1435
  declare function validateListUsersParams(object: unknown): Either<ListUsersParamsValidationError, ListUsersParams>;
1436
1436
  //#endregion
1437
- //#region src/validators/workflow-templates.validators.d.ts
1438
- type ValidationError = "malformed_object" | "invalid_type" | "invalid_recipients" | "invalid_recipients_element" | "invalid_url" | "invalid_method" | "invalid_headers" | "invalid_headers_element" | "invalid_workflow_action_type" | "invalid_group_id" | "invalid_min_count" | "invalid_require_high_privilege" | "invalid_rules" | "invalid_rules_element" | "invalid_approval_rule_type" | "invalid_id" | "invalid_name" | "invalid_version" | "invalid_status" | "invalid_allow_voting" | "missing_approval_rule" | "invalid_approval_rule" | "invalid_space_id" | "invalid_created_at" | "invalid_updated_at" | "invalid_description" | "invalid_metadata" | "invalid_actions" | "invalid_actions_element" | "invalid_default_expires_in_hours" | "invalid_cancel_workflows" | "invalid_workflow_template_id" | "invalid_data" | "invalid_data_element" | "missing_pagination" | "invalid_pagination" | "invalid_page" | "invalid_limit" | "invalid_space_identifier" | "invalid_search";
1439
- declare function validateWorkflowTemplate(object: unknown): Either<ValidationError, WorkflowTemplate>;
1440
- declare function validateWorkflowTemplateCreate(object: unknown): Either<ValidationError, WorkflowTemplateCreate>;
1441
- declare function validateWorkflowTemplateUpdate(object: unknown): Either<ValidationError, WorkflowTemplateUpdate>;
1442
- declare function validateWorkflowTemplateDeprecate(object: unknown): Either<ValidationError, WorkflowTemplateDeprecate>;
1443
- declare function validateWorkflowTemplateScope(object: unknown): Either<ValidationError, WorkflowTemplateScope>;
1444
- declare function validateListWorkflowTemplates200Response(object: unknown): Either<ValidationError, ListWorkflowTemplates200Response>;
1445
- declare function validateListWorkflowTemplatesParams(object: unknown): Either<ValidationError, ListWorkflowTemplatesParams>;
1446
- //#endregion
1447
1437
  //#region src/validators/common.validators.d.ts
1448
1438
  type PaginationValidationError = "malformed_object" | "missing_total" | "invalid_total" | "missing_page" | "invalid_page" | "missing_limit" | "invalid_limit";
1449
1439
  type ListParamsValidationError = "malformed_object" | "invalid_page" | "invalid_limit" | "invalid_search";
@@ -1460,6 +1450,31 @@ declare function validateHealthResponse(object: unknown): Either<HealthResponseV
1460
1450
  type GetEntityInfo200ResponseValidationError = "malformed_object" | "missing_entity_type" | "invalid_entity_type" | "missing_groups" | "invalid_groups";
1461
1451
  declare function validateGetEntityInfo200Response(object: unknown): Either<GetEntityInfo200ResponseValidationError, GetEntityInfo200Response>;
1462
1452
  //#endregion
1453
+ //#region src/utils/types.d.ts
1454
+ /**
1455
+ * Create a union type with a prefix
1456
+ * @example
1457
+ * type MyUnion = PrefixUnion<"workflow", "name_empty" | "name_too_long"> // "workflow_name_empty" | "workflow_name_too_long"
1458
+ */
1459
+ type PrefixUnion<TPrefix extends string, TUnion extends string> = `${TPrefix}_${TUnion}`;
1460
+ //#endregion
1461
+ //#region src/validators/workflow-templates.validators.d.ts
1462
+ type WorkflowTemplateValidationError = "malformed_object" | "invalid_id" | "invalid_name" | "invalid_version" | "invalid_status" | "invalid_allow_voting" | "missing_approval_rule" | "invalid_approval_rule" | "invalid_space_id" | "invalid_created_at" | "invalid_updated_at" | "invalid_description" | "invalid_metadata" | "invalid_actions" | "invalid_actions_element" | "invalid_default_expires_in_hours";
1463
+ declare function validateWorkflowTemplate(object: unknown): Either<WorkflowTemplateValidationError, WorkflowTemplate>;
1464
+ type WorkflowTemplateCreateValidationError = "malformed_object" | "invalid_name" | "missing_approval_rule" | "invalid_approval_rule" | "invalid_space_id" | "invalid_description" | "invalid_metadata" | "invalid_actions" | "invalid_actions_element" | "invalid_default_expires_in_hours";
1465
+ declare function validateWorkflowTemplateCreate(object: unknown): Either<WorkflowTemplateCreateValidationError, WorkflowTemplateCreate>;
1466
+ type WorkflowTemplateUpdateValidationError = "malformed_object" | "invalid_description" | "invalid_metadata" | "invalid_approval_rule" | "invalid_actions" | "invalid_actions_element" | "invalid_default_expires_in_hours" | "invalid_cancel_workflows";
1467
+ declare function validateWorkflowTemplateUpdate(object: unknown): Either<WorkflowTemplateUpdateValidationError, WorkflowTemplateUpdate>;
1468
+ type WorkflowTemplateDeprecateValidationError = "malformed_object" | "invalid_cancel_workflows";
1469
+ declare function validateWorkflowTemplateDeprecate(object: unknown): Either<WorkflowTemplateDeprecateValidationError, WorkflowTemplateDeprecate>;
1470
+ type WorkflowTemplateScopeValidationError = "malformed_object" | "invalid_type" | "invalid_workflow_template_id";
1471
+ declare function validateWorkflowTemplateScope(object: unknown): Either<WorkflowTemplateScopeValidationError, WorkflowTemplateScope>;
1472
+ type WorkflowTemplateSummaryValidationError = "malformed_object" | "invalid_id" | "invalid_name" | "invalid_version" | "invalid_created_at" | "invalid_updated_at" | "invalid_description";
1473
+ type ListWorkflowTemplates200ResponseValidationError = "malformed_object" | "invalid_data" | "invalid_pagination" | "missing_pagination" | PrefixUnion<"data_item", WorkflowTemplateSummaryValidationError>;
1474
+ declare function validateListWorkflowTemplates200Response(object: unknown): Either<ListWorkflowTemplates200ResponseValidationError, ListWorkflowTemplates200Response>;
1475
+ type ListWorkflowTemplatesParamsValidationError = ListParamsValidationError | "invalid_space_identifier";
1476
+ declare function validateListWorkflowTemplatesParams(object: unknown): Either<ListWorkflowTemplatesParamsValidationError, ListWorkflowTemplatesParams>;
1477
+ //#endregion
1463
1478
  //#region src/validators/spaces.validators.d.ts
1464
1479
  type SpaceValidationError = "malformed_object" | "missing_id" | "invalid_id" | "missing_name" | "invalid_name" | "invalid_description" | "missing_created_at" | "invalid_created_at" | "missing_updated_at" | "invalid_updated_at";
1465
1480
  type SpaceCreateValidationError = "malformed_object" | "missing_name" | "invalid_name" | "invalid_description";
@@ -1532,4 +1547,4 @@ type APIErrorValidationError = "malformed_object" | "missing_code" | "invalid_co
1532
1547
  declare function validateAPIError(object: unknown): Either<APIErrorValidationError, APIError>;
1533
1548
  declare function isAPIError(object: unknown): object is APIError;
1534
1549
  //#endregion
1535
- export { APIError, APIErrorDetailsInner, APIErrorDetailsInnerValidationError, APIErrorValidationError, AddGroupEntitiesRequest, AddGroupEntitiesRequestValidationError, AgentChallengeRequest, AgentChallengeRequestValidationError, AgentChallengeResponse, AgentChallengeResponseValidationError, AgentGet200Response, AgentGet200ResponseValidationError, AgentRegistrationRequest, AgentRegistrationRequestValidationError, AgentRegistrationResponse, AgentRegistrationResponseValidationError, AgentSummary, AgentSummaryValidationError, AgentTokenRequest, AgentTokenRequestValidationError, AgentTokenResponse, AgentTokenResponseValidationError, AndRule, ApprovalRule, CanVoteResponse, CanVoteResponseValidationError, EmailAction, EntityMembershipAdd, EntityMembershipAddValidationError, EntityMembershipRemove, EntityMembershipRemoveValidationError, EntityReference, EntityReferenceValidationError, GetEntityInfo200Response, GetEntityInfo200ResponseValidationError, GetWorkflowParams, GetWorkflowParamsValidationError, GetWorkflowVotes200Response, GetWorkflowVotes200ResponseValidationError, Group, GroupCreate, GroupCreateValidationError, GroupInfo, GroupInfoValidationError, GroupMembership, GroupMembershipValidationError, GroupRequirementRule, GroupScope, GroupScopeValidationError, GroupValidationError, HealthResponse, HealthResponseValidationError, InitiateCliLogin200Response, InitiateCliLogin200ResponseValidationError, InitiateCliLoginRequest, InitiateCliLoginRequestValidationError, ListAgents200Response, ListAgents200ResponseValidationError, ListAgentsParams, ListAgentsParamsValidationError, ListGroupEntities200Response, ListGroupEntities200ResponseValidationError, ListGroups200Response, ListGroups200ResponseValidationError, ListGroupsParams, ListGroupsParamsValidationError, ListOrganizationAdminsForOrg200Response, ListOrganizationAdminsForOrg200ResponseValidationError, ListParamsValidationError, ListRoleTemplates200Response, ListRoleTemplates200ResponseValidationError, ListSpaces200Response, ListSpaces200ResponseValidationError, ListSpacesParams, ListSpacesParamsValidationError, ListUsers200Response, ListUsers200ResponseValidationError, ListUsersParams, ListUsersParamsValidationError, ListWorkflowTemplates200Response, ListWorkflowTemplatesParams, ListWorkflows200Response, ListWorkflows200ResponseValidationError, ListWorkflowsParams, ListWorkflowsParamsValidationError, OidcCallbackRequest, OidcCallbackRequestValidationError, OrRule, OrgScope, OrganizationAdmin, OrganizationAdminCreate, OrganizationAdminCreateValidationError, OrganizationAdminRemove, OrganizationAdminRemoveValidationError, OrganizationAdminValidationError, Pagination, PaginationValidationError, PrivilegedTokenExchangeRequest, PrivilegedTokenExchangeRequestValidationError, PrivilegedTokenResponse, PrivilegedTokenResponseValidationError, RefreshTokenRequest, RefreshTokenRequestValidationError, RemoveGroupEntitiesRequest, RemoveGroupEntitiesRequestValidationError, RoleAssignmentRequest, RoleOperationItem, RoleOperationItemValidationError, RoleOperationRequest, RoleOperationRequestValidationError, RoleRemovalRequest, RoleScope, RoleScopeValidationError, RoleTemplate, RoleTemplateValidationError, Space, SpaceCreate, SpaceCreateValidationError, SpaceScope, SpaceScopeValidationError, SpaceValidationError, TokenRequest, TokenRequestValidationError, TokenResponse, TokenResponseValidationError, User, UserCreate, UserCreateValidationError, UserSummary, UserSummaryValidationError, UserValidationError, ValidatedListParams, ValidationError, VoteApprove, VoteApproveValidationError, VoteVeto, VoteVetoValidationError, VoteWithdraw, VoteWithdrawValidationError, WebhookAction, Workflow, WorkflowAction, WorkflowCreate, WorkflowCreateValidationError, WorkflowRef, WorkflowRefValidationError, WorkflowTemplate, WorkflowTemplateCreate, WorkflowTemplateDeprecate, WorkflowTemplateScope, WorkflowTemplateSummary, WorkflowTemplateUpdate, WorkflowValidationError, WorkflowVote, WorkflowVoteRequest, WorkflowVoteRequestValidationError, WorkflowVoteRequestVoteType, WorkflowVoteRequestVoteTypeValidationError, WorkflowVoteValidationError, isAPIError, validateAPIError, validateAddGroupEntitiesRequest, validateAgentChallengeRequest, validateAgentChallengeResponse, validateAgentGet200Response, validateAgentRegistrationRequest, validateAgentRegistrationResponse, validateAgentTokenRequest, validateAgentTokenResponse, validateCanVoteResponse, validateGetEntityInfo200Response, validateGetWorkflowParams, validateGetWorkflowVotes200Response, validateGroupCreate, validateGroupInfo, validateGroupScope, validateHealthResponse, validateInitiateCliLogin200Response, validateInitiateCliLoginRequest, validateListAgents200Response, validateListAgentsParams, validateListGroupEntities200Response, validateListGroups200Response, validateListGroupsParams, validateListOrganizationAdminsForOrg200Response, validateListRoleTemplates200Response, validateListSpaces200Response, validateListSpacesParams, validateListUsers200Response, validateListUsersParams, validateListWorkflowTemplates200Response, validateListWorkflowTemplatesParams, validateListWorkflows200Response, validateListWorkflowsParams, validateOidcCallbackRequest, validateOrganizationAdminCreate, validateOrganizationAdminRemove, validatePagination, validatePrivilegedTokenExchangeRequest, validatePrivilegedTokenResponse, validateRefreshTokenRequest, validateRemoveGroupEntitiesRequest, validateRoleAssignmentRequest, validateRoleRemovalRequest, validateSharedListParams, validateSpaceCreate, validateSpaceScope, validateTokenRequest, validateTokenResponse, validateUser, validateUserCreate, validateWorkflowCreate, validateWorkflowTemplate, validateWorkflowTemplateCreate, validateWorkflowTemplateDeprecate, validateWorkflowTemplateScope, validateWorkflowTemplateUpdate, validateWorkflowVoteRequest };
1550
+ export { APIError, APIErrorDetailsInner, APIErrorDetailsInnerValidationError, APIErrorValidationError, AddGroupEntitiesRequest, AddGroupEntitiesRequestValidationError, AgentChallengeRequest, AgentChallengeRequestValidationError, AgentChallengeResponse, AgentChallengeResponseValidationError, AgentGet200Response, AgentGet200ResponseValidationError, AgentRegistrationRequest, AgentRegistrationRequestValidationError, AgentRegistrationResponse, AgentRegistrationResponseValidationError, AgentSummary, AgentSummaryValidationError, AgentTokenRequest, AgentTokenRequestValidationError, AgentTokenResponse, AgentTokenResponseValidationError, AndRule, ApprovalRule, CanVoteResponse, CanVoteResponseValidationError, EmailAction, EntityMembershipAdd, EntityMembershipAddValidationError, EntityMembershipRemove, EntityMembershipRemoveValidationError, EntityReference, EntityReferenceValidationError, GetEntityInfo200Response, GetEntityInfo200ResponseValidationError, GetWorkflowParams, GetWorkflowParamsValidationError, GetWorkflowVotes200Response, GetWorkflowVotes200ResponseValidationError, Group, GroupCreate, GroupCreateValidationError, GroupInfo, GroupInfoValidationError, GroupMembership, GroupMembershipValidationError, GroupRequirementRule, GroupScope, GroupScopeValidationError, GroupValidationError, HealthResponse, HealthResponseValidationError, InitiateCliLogin200Response, InitiateCliLogin200ResponseValidationError, InitiateCliLoginRequest, InitiateCliLoginRequestValidationError, ListAgents200Response, ListAgents200ResponseValidationError, ListAgentsParams, ListAgentsParamsValidationError, ListGroupEntities200Response, ListGroupEntities200ResponseValidationError, ListGroups200Response, ListGroups200ResponseValidationError, ListGroupsParams, ListGroupsParamsValidationError, ListOrganizationAdminsForOrg200Response, ListOrganizationAdminsForOrg200ResponseValidationError, ListParamsValidationError, ListRoleTemplates200Response, ListRoleTemplates200ResponseValidationError, ListSpaces200Response, ListSpaces200ResponseValidationError, ListSpacesParams, ListSpacesParamsValidationError, ListUsers200Response, ListUsers200ResponseValidationError, ListUsersParams, ListUsersParamsValidationError, ListWorkflowTemplates200Response, ListWorkflowTemplates200ResponseValidationError, ListWorkflowTemplatesParams, ListWorkflowTemplatesParamsValidationError, ListWorkflows200Response, ListWorkflows200ResponseValidationError, ListWorkflowsParams, ListWorkflowsParamsValidationError, OidcCallbackRequest, OidcCallbackRequestValidationError, OrRule, OrgScope, OrganizationAdmin, OrganizationAdminCreate, OrganizationAdminCreateValidationError, OrganizationAdminRemove, OrganizationAdminRemoveValidationError, OrganizationAdminValidationError, Pagination, PaginationValidationError, PrivilegedTokenExchangeRequest, PrivilegedTokenExchangeRequestValidationError, PrivilegedTokenResponse, PrivilegedTokenResponseValidationError, RefreshTokenRequest, RefreshTokenRequestValidationError, RemoveGroupEntitiesRequest, RemoveGroupEntitiesRequestValidationError, RoleAssignmentRequest, RoleOperationItem, RoleOperationItemValidationError, RoleOperationRequest, RoleOperationRequestValidationError, RoleRemovalRequest, RoleScope, RoleScopeValidationError, RoleTemplate, RoleTemplateValidationError, Space, SpaceCreate, SpaceCreateValidationError, SpaceScope, SpaceScopeValidationError, SpaceValidationError, TokenRequest, TokenRequestValidationError, TokenResponse, TokenResponseValidationError, User, UserCreate, UserCreateValidationError, UserSummary, UserSummaryValidationError, UserValidationError, ValidatedListParams, VoteApprove, VoteApproveValidationError, VoteVeto, VoteVetoValidationError, VoteWithdraw, VoteWithdrawValidationError, WebhookAction, Workflow, WorkflowAction, WorkflowCreate, WorkflowCreateValidationError, WorkflowRef, WorkflowRefValidationError, WorkflowTemplate, WorkflowTemplateCreate, WorkflowTemplateCreateValidationError, WorkflowTemplateDeprecate, WorkflowTemplateDeprecateValidationError, WorkflowTemplateScope, WorkflowTemplateScopeValidationError, WorkflowTemplateSummary, WorkflowTemplateUpdate, WorkflowTemplateUpdateValidationError, WorkflowTemplateValidationError, WorkflowValidationError, WorkflowVote, WorkflowVoteRequest, WorkflowVoteRequestValidationError, WorkflowVoteRequestVoteType, WorkflowVoteRequestVoteTypeValidationError, WorkflowVoteValidationError, isAPIError, validateAPIError, validateAddGroupEntitiesRequest, validateAgentChallengeRequest, validateAgentChallengeResponse, validateAgentGet200Response, validateAgentRegistrationRequest, validateAgentRegistrationResponse, validateAgentTokenRequest, validateAgentTokenResponse, validateCanVoteResponse, validateGetEntityInfo200Response, validateGetWorkflowParams, validateGetWorkflowVotes200Response, validateGroupCreate, validateGroupInfo, validateGroupScope, validateHealthResponse, validateInitiateCliLogin200Response, validateInitiateCliLoginRequest, validateListAgents200Response, validateListAgentsParams, validateListGroupEntities200Response, validateListGroups200Response, validateListGroupsParams, validateListOrganizationAdminsForOrg200Response, validateListRoleTemplates200Response, validateListSpaces200Response, validateListSpacesParams, validateListUsers200Response, validateListUsersParams, validateListWorkflowTemplates200Response, validateListWorkflowTemplatesParams, validateListWorkflows200Response, validateListWorkflowsParams, validateOidcCallbackRequest, validateOrganizationAdminCreate, validateOrganizationAdminRemove, validatePagination, validatePrivilegedTokenExchangeRequest, validatePrivilegedTokenResponse, validateRefreshTokenRequest, validateRemoveGroupEntitiesRequest, validateRoleAssignmentRequest, validateRoleRemovalRequest, validateSharedListParams, validateSpaceCreate, validateSpaceScope, validateTokenRequest, validateTokenResponse, validateUser, validateUserCreate, validateWorkflowCreate, validateWorkflowTemplate, validateWorkflowTemplateCreate, validateWorkflowTemplateDeprecate, validateWorkflowTemplateScope, validateWorkflowTemplateUpdate, validateWorkflowVoteRequest };
@@ -1434,16 +1434,6 @@ declare function validateRoleRemovalRequest(object: unknown): Either<RoleOperati
1434
1434
  type ListUsersParamsValidationError = "malformed_object" | "invalid_page" | "invalid_limit" | "invalid_search";
1435
1435
  declare function validateListUsersParams(object: unknown): Either<ListUsersParamsValidationError, ListUsersParams>;
1436
1436
  //#endregion
1437
- //#region src/validators/workflow-templates.validators.d.ts
1438
- type ValidationError = "malformed_object" | "invalid_type" | "invalid_recipients" | "invalid_recipients_element" | "invalid_url" | "invalid_method" | "invalid_headers" | "invalid_headers_element" | "invalid_workflow_action_type" | "invalid_group_id" | "invalid_min_count" | "invalid_require_high_privilege" | "invalid_rules" | "invalid_rules_element" | "invalid_approval_rule_type" | "invalid_id" | "invalid_name" | "invalid_version" | "invalid_status" | "invalid_allow_voting" | "missing_approval_rule" | "invalid_approval_rule" | "invalid_space_id" | "invalid_created_at" | "invalid_updated_at" | "invalid_description" | "invalid_metadata" | "invalid_actions" | "invalid_actions_element" | "invalid_default_expires_in_hours" | "invalid_cancel_workflows" | "invalid_workflow_template_id" | "invalid_data" | "invalid_data_element" | "missing_pagination" | "invalid_pagination" | "invalid_page" | "invalid_limit" | "invalid_space_identifier" | "invalid_search";
1439
- declare function validateWorkflowTemplate(object: unknown): Either<ValidationError, WorkflowTemplate>;
1440
- declare function validateWorkflowTemplateCreate(object: unknown): Either<ValidationError, WorkflowTemplateCreate>;
1441
- declare function validateWorkflowTemplateUpdate(object: unknown): Either<ValidationError, WorkflowTemplateUpdate>;
1442
- declare function validateWorkflowTemplateDeprecate(object: unknown): Either<ValidationError, WorkflowTemplateDeprecate>;
1443
- declare function validateWorkflowTemplateScope(object: unknown): Either<ValidationError, WorkflowTemplateScope>;
1444
- declare function validateListWorkflowTemplates200Response(object: unknown): Either<ValidationError, ListWorkflowTemplates200Response>;
1445
- declare function validateListWorkflowTemplatesParams(object: unknown): Either<ValidationError, ListWorkflowTemplatesParams>;
1446
- //#endregion
1447
1437
  //#region src/validators/common.validators.d.ts
1448
1438
  type PaginationValidationError = "malformed_object" | "missing_total" | "invalid_total" | "missing_page" | "invalid_page" | "missing_limit" | "invalid_limit";
1449
1439
  type ListParamsValidationError = "malformed_object" | "invalid_page" | "invalid_limit" | "invalid_search";
@@ -1460,6 +1450,31 @@ declare function validateHealthResponse(object: unknown): Either<HealthResponseV
1460
1450
  type GetEntityInfo200ResponseValidationError = "malformed_object" | "missing_entity_type" | "invalid_entity_type" | "missing_groups" | "invalid_groups";
1461
1451
  declare function validateGetEntityInfo200Response(object: unknown): Either<GetEntityInfo200ResponseValidationError, GetEntityInfo200Response>;
1462
1452
  //#endregion
1453
+ //#region src/utils/types.d.ts
1454
+ /**
1455
+ * Create a union type with a prefix
1456
+ * @example
1457
+ * type MyUnion = PrefixUnion<"workflow", "name_empty" | "name_too_long"> // "workflow_name_empty" | "workflow_name_too_long"
1458
+ */
1459
+ type PrefixUnion<TPrefix extends string, TUnion extends string> = `${TPrefix}_${TUnion}`;
1460
+ //#endregion
1461
+ //#region src/validators/workflow-templates.validators.d.ts
1462
+ type WorkflowTemplateValidationError = "malformed_object" | "invalid_id" | "invalid_name" | "invalid_version" | "invalid_status" | "invalid_allow_voting" | "missing_approval_rule" | "invalid_approval_rule" | "invalid_space_id" | "invalid_created_at" | "invalid_updated_at" | "invalid_description" | "invalid_metadata" | "invalid_actions" | "invalid_actions_element" | "invalid_default_expires_in_hours";
1463
+ declare function validateWorkflowTemplate(object: unknown): Either<WorkflowTemplateValidationError, WorkflowTemplate>;
1464
+ type WorkflowTemplateCreateValidationError = "malformed_object" | "invalid_name" | "missing_approval_rule" | "invalid_approval_rule" | "invalid_space_id" | "invalid_description" | "invalid_metadata" | "invalid_actions" | "invalid_actions_element" | "invalid_default_expires_in_hours";
1465
+ declare function validateWorkflowTemplateCreate(object: unknown): Either<WorkflowTemplateCreateValidationError, WorkflowTemplateCreate>;
1466
+ type WorkflowTemplateUpdateValidationError = "malformed_object" | "invalid_description" | "invalid_metadata" | "invalid_approval_rule" | "invalid_actions" | "invalid_actions_element" | "invalid_default_expires_in_hours" | "invalid_cancel_workflows";
1467
+ declare function validateWorkflowTemplateUpdate(object: unknown): Either<WorkflowTemplateUpdateValidationError, WorkflowTemplateUpdate>;
1468
+ type WorkflowTemplateDeprecateValidationError = "malformed_object" | "invalid_cancel_workflows";
1469
+ declare function validateWorkflowTemplateDeprecate(object: unknown): Either<WorkflowTemplateDeprecateValidationError, WorkflowTemplateDeprecate>;
1470
+ type WorkflowTemplateScopeValidationError = "malformed_object" | "invalid_type" | "invalid_workflow_template_id";
1471
+ declare function validateWorkflowTemplateScope(object: unknown): Either<WorkflowTemplateScopeValidationError, WorkflowTemplateScope>;
1472
+ type WorkflowTemplateSummaryValidationError = "malformed_object" | "invalid_id" | "invalid_name" | "invalid_version" | "invalid_created_at" | "invalid_updated_at" | "invalid_description";
1473
+ type ListWorkflowTemplates200ResponseValidationError = "malformed_object" | "invalid_data" | "invalid_pagination" | "missing_pagination" | PrefixUnion<"data_item", WorkflowTemplateSummaryValidationError>;
1474
+ declare function validateListWorkflowTemplates200Response(object: unknown): Either<ListWorkflowTemplates200ResponseValidationError, ListWorkflowTemplates200Response>;
1475
+ type ListWorkflowTemplatesParamsValidationError = ListParamsValidationError | "invalid_space_identifier";
1476
+ declare function validateListWorkflowTemplatesParams(object: unknown): Either<ListWorkflowTemplatesParamsValidationError, ListWorkflowTemplatesParams>;
1477
+ //#endregion
1463
1478
  //#region src/validators/spaces.validators.d.ts
1464
1479
  type SpaceValidationError = "malformed_object" | "missing_id" | "invalid_id" | "missing_name" | "invalid_name" | "invalid_description" | "missing_created_at" | "invalid_created_at" | "missing_updated_at" | "invalid_updated_at";
1465
1480
  type SpaceCreateValidationError = "malformed_object" | "missing_name" | "invalid_name" | "invalid_description";
@@ -1532,4 +1547,4 @@ type APIErrorValidationError = "malformed_object" | "missing_code" | "invalid_co
1532
1547
  declare function validateAPIError(object: unknown): Either<APIErrorValidationError, APIError>;
1533
1548
  declare function isAPIError(object: unknown): object is APIError;
1534
1549
  //#endregion
1535
- export { APIError, APIErrorDetailsInner, APIErrorDetailsInnerValidationError, APIErrorValidationError, AddGroupEntitiesRequest, AddGroupEntitiesRequestValidationError, AgentChallengeRequest, AgentChallengeRequestValidationError, AgentChallengeResponse, AgentChallengeResponseValidationError, AgentGet200Response, AgentGet200ResponseValidationError, AgentRegistrationRequest, AgentRegistrationRequestValidationError, AgentRegistrationResponse, AgentRegistrationResponseValidationError, AgentSummary, AgentSummaryValidationError, AgentTokenRequest, AgentTokenRequestValidationError, AgentTokenResponse, AgentTokenResponseValidationError, AndRule, ApprovalRule, CanVoteResponse, CanVoteResponseValidationError, EmailAction, EntityMembershipAdd, EntityMembershipAddValidationError, EntityMembershipRemove, EntityMembershipRemoveValidationError, EntityReference, EntityReferenceValidationError, GetEntityInfo200Response, GetEntityInfo200ResponseValidationError, GetWorkflowParams, GetWorkflowParamsValidationError, GetWorkflowVotes200Response, GetWorkflowVotes200ResponseValidationError, Group, GroupCreate, GroupCreateValidationError, GroupInfo, GroupInfoValidationError, GroupMembership, GroupMembershipValidationError, GroupRequirementRule, GroupScope, GroupScopeValidationError, GroupValidationError, HealthResponse, HealthResponseValidationError, InitiateCliLogin200Response, InitiateCliLogin200ResponseValidationError, InitiateCliLoginRequest, InitiateCliLoginRequestValidationError, ListAgents200Response, ListAgents200ResponseValidationError, ListAgentsParams, ListAgentsParamsValidationError, ListGroupEntities200Response, ListGroupEntities200ResponseValidationError, ListGroups200Response, ListGroups200ResponseValidationError, ListGroupsParams, ListGroupsParamsValidationError, ListOrganizationAdminsForOrg200Response, ListOrganizationAdminsForOrg200ResponseValidationError, ListParamsValidationError, ListRoleTemplates200Response, ListRoleTemplates200ResponseValidationError, ListSpaces200Response, ListSpaces200ResponseValidationError, ListSpacesParams, ListSpacesParamsValidationError, ListUsers200Response, ListUsers200ResponseValidationError, ListUsersParams, ListUsersParamsValidationError, ListWorkflowTemplates200Response, ListWorkflowTemplatesParams, ListWorkflows200Response, ListWorkflows200ResponseValidationError, ListWorkflowsParams, ListWorkflowsParamsValidationError, OidcCallbackRequest, OidcCallbackRequestValidationError, OrRule, OrgScope, OrganizationAdmin, OrganizationAdminCreate, OrganizationAdminCreateValidationError, OrganizationAdminRemove, OrganizationAdminRemoveValidationError, OrganizationAdminValidationError, Pagination, PaginationValidationError, PrivilegedTokenExchangeRequest, PrivilegedTokenExchangeRequestValidationError, PrivilegedTokenResponse, PrivilegedTokenResponseValidationError, RefreshTokenRequest, RefreshTokenRequestValidationError, RemoveGroupEntitiesRequest, RemoveGroupEntitiesRequestValidationError, RoleAssignmentRequest, RoleOperationItem, RoleOperationItemValidationError, RoleOperationRequest, RoleOperationRequestValidationError, RoleRemovalRequest, RoleScope, RoleScopeValidationError, RoleTemplate, RoleTemplateValidationError, Space, SpaceCreate, SpaceCreateValidationError, SpaceScope, SpaceScopeValidationError, SpaceValidationError, TokenRequest, TokenRequestValidationError, TokenResponse, TokenResponseValidationError, User, UserCreate, UserCreateValidationError, UserSummary, UserSummaryValidationError, UserValidationError, ValidatedListParams, ValidationError, VoteApprove, VoteApproveValidationError, VoteVeto, VoteVetoValidationError, VoteWithdraw, VoteWithdrawValidationError, WebhookAction, Workflow, WorkflowAction, WorkflowCreate, WorkflowCreateValidationError, WorkflowRef, WorkflowRefValidationError, WorkflowTemplate, WorkflowTemplateCreate, WorkflowTemplateDeprecate, WorkflowTemplateScope, WorkflowTemplateSummary, WorkflowTemplateUpdate, WorkflowValidationError, WorkflowVote, WorkflowVoteRequest, WorkflowVoteRequestValidationError, WorkflowVoteRequestVoteType, WorkflowVoteRequestVoteTypeValidationError, WorkflowVoteValidationError, isAPIError, validateAPIError, validateAddGroupEntitiesRequest, validateAgentChallengeRequest, validateAgentChallengeResponse, validateAgentGet200Response, validateAgentRegistrationRequest, validateAgentRegistrationResponse, validateAgentTokenRequest, validateAgentTokenResponse, validateCanVoteResponse, validateGetEntityInfo200Response, validateGetWorkflowParams, validateGetWorkflowVotes200Response, validateGroupCreate, validateGroupInfo, validateGroupScope, validateHealthResponse, validateInitiateCliLogin200Response, validateInitiateCliLoginRequest, validateListAgents200Response, validateListAgentsParams, validateListGroupEntities200Response, validateListGroups200Response, validateListGroupsParams, validateListOrganizationAdminsForOrg200Response, validateListRoleTemplates200Response, validateListSpaces200Response, validateListSpacesParams, validateListUsers200Response, validateListUsersParams, validateListWorkflowTemplates200Response, validateListWorkflowTemplatesParams, validateListWorkflows200Response, validateListWorkflowsParams, validateOidcCallbackRequest, validateOrganizationAdminCreate, validateOrganizationAdminRemove, validatePagination, validatePrivilegedTokenExchangeRequest, validatePrivilegedTokenResponse, validateRefreshTokenRequest, validateRemoveGroupEntitiesRequest, validateRoleAssignmentRequest, validateRoleRemovalRequest, validateSharedListParams, validateSpaceCreate, validateSpaceScope, validateTokenRequest, validateTokenResponse, validateUser, validateUserCreate, validateWorkflowCreate, validateWorkflowTemplate, validateWorkflowTemplateCreate, validateWorkflowTemplateDeprecate, validateWorkflowTemplateScope, validateWorkflowTemplateUpdate, validateWorkflowVoteRequest };
1550
+ export { APIError, APIErrorDetailsInner, APIErrorDetailsInnerValidationError, APIErrorValidationError, AddGroupEntitiesRequest, AddGroupEntitiesRequestValidationError, AgentChallengeRequest, AgentChallengeRequestValidationError, AgentChallengeResponse, AgentChallengeResponseValidationError, AgentGet200Response, AgentGet200ResponseValidationError, AgentRegistrationRequest, AgentRegistrationRequestValidationError, AgentRegistrationResponse, AgentRegistrationResponseValidationError, AgentSummary, AgentSummaryValidationError, AgentTokenRequest, AgentTokenRequestValidationError, AgentTokenResponse, AgentTokenResponseValidationError, AndRule, ApprovalRule, CanVoteResponse, CanVoteResponseValidationError, EmailAction, EntityMembershipAdd, EntityMembershipAddValidationError, EntityMembershipRemove, EntityMembershipRemoveValidationError, EntityReference, EntityReferenceValidationError, GetEntityInfo200Response, GetEntityInfo200ResponseValidationError, GetWorkflowParams, GetWorkflowParamsValidationError, GetWorkflowVotes200Response, GetWorkflowVotes200ResponseValidationError, Group, GroupCreate, GroupCreateValidationError, GroupInfo, GroupInfoValidationError, GroupMembership, GroupMembershipValidationError, GroupRequirementRule, GroupScope, GroupScopeValidationError, GroupValidationError, HealthResponse, HealthResponseValidationError, InitiateCliLogin200Response, InitiateCliLogin200ResponseValidationError, InitiateCliLoginRequest, InitiateCliLoginRequestValidationError, ListAgents200Response, ListAgents200ResponseValidationError, ListAgentsParams, ListAgentsParamsValidationError, ListGroupEntities200Response, ListGroupEntities200ResponseValidationError, ListGroups200Response, ListGroups200ResponseValidationError, ListGroupsParams, ListGroupsParamsValidationError, ListOrganizationAdminsForOrg200Response, ListOrganizationAdminsForOrg200ResponseValidationError, ListParamsValidationError, ListRoleTemplates200Response, ListRoleTemplates200ResponseValidationError, ListSpaces200Response, ListSpaces200ResponseValidationError, ListSpacesParams, ListSpacesParamsValidationError, ListUsers200Response, ListUsers200ResponseValidationError, ListUsersParams, ListUsersParamsValidationError, ListWorkflowTemplates200Response, ListWorkflowTemplates200ResponseValidationError, ListWorkflowTemplatesParams, ListWorkflowTemplatesParamsValidationError, ListWorkflows200Response, ListWorkflows200ResponseValidationError, ListWorkflowsParams, ListWorkflowsParamsValidationError, OidcCallbackRequest, OidcCallbackRequestValidationError, OrRule, OrgScope, OrganizationAdmin, OrganizationAdminCreate, OrganizationAdminCreateValidationError, OrganizationAdminRemove, OrganizationAdminRemoveValidationError, OrganizationAdminValidationError, Pagination, PaginationValidationError, PrivilegedTokenExchangeRequest, PrivilegedTokenExchangeRequestValidationError, PrivilegedTokenResponse, PrivilegedTokenResponseValidationError, RefreshTokenRequest, RefreshTokenRequestValidationError, RemoveGroupEntitiesRequest, RemoveGroupEntitiesRequestValidationError, RoleAssignmentRequest, RoleOperationItem, RoleOperationItemValidationError, RoleOperationRequest, RoleOperationRequestValidationError, RoleRemovalRequest, RoleScope, RoleScopeValidationError, RoleTemplate, RoleTemplateValidationError, Space, SpaceCreate, SpaceCreateValidationError, SpaceScope, SpaceScopeValidationError, SpaceValidationError, TokenRequest, TokenRequestValidationError, TokenResponse, TokenResponseValidationError, User, UserCreate, UserCreateValidationError, UserSummary, UserSummaryValidationError, UserValidationError, ValidatedListParams, VoteApprove, VoteApproveValidationError, VoteVeto, VoteVetoValidationError, VoteWithdraw, VoteWithdrawValidationError, WebhookAction, Workflow, WorkflowAction, WorkflowCreate, WorkflowCreateValidationError, WorkflowRef, WorkflowRefValidationError, WorkflowTemplate, WorkflowTemplateCreate, WorkflowTemplateCreateValidationError, WorkflowTemplateDeprecate, WorkflowTemplateDeprecateValidationError, WorkflowTemplateScope, WorkflowTemplateScopeValidationError, WorkflowTemplateSummary, WorkflowTemplateUpdate, WorkflowTemplateUpdateValidationError, WorkflowTemplateValidationError, WorkflowValidationError, WorkflowVote, WorkflowVoteRequest, WorkflowVoteRequestValidationError, WorkflowVoteRequestVoteType, WorkflowVoteRequestVoteTypeValidationError, WorkflowVoteValidationError, isAPIError, validateAPIError, validateAddGroupEntitiesRequest, validateAgentChallengeRequest, validateAgentChallengeResponse, validateAgentGet200Response, validateAgentRegistrationRequest, validateAgentRegistrationResponse, validateAgentTokenRequest, validateAgentTokenResponse, validateCanVoteResponse, validateGetEntityInfo200Response, validateGetWorkflowParams, validateGetWorkflowVotes200Response, validateGroupCreate, validateGroupInfo, validateGroupScope, validateHealthResponse, validateInitiateCliLogin200Response, validateInitiateCliLoginRequest, validateListAgents200Response, validateListAgentsParams, validateListGroupEntities200Response, validateListGroups200Response, validateListGroupsParams, validateListOrganizationAdminsForOrg200Response, validateListRoleTemplates200Response, validateListSpaces200Response, validateListSpacesParams, validateListUsers200Response, validateListUsersParams, validateListWorkflowTemplates200Response, validateListWorkflowTemplatesParams, validateListWorkflows200Response, validateListWorkflowsParams, validateOidcCallbackRequest, validateOrganizationAdminCreate, validateOrganizationAdminRemove, validatePagination, validatePrivilegedTokenExchangeRequest, validatePrivilegedTokenResponse, validateRefreshTokenRequest, validateRemoveGroupEntitiesRequest, validateRoleAssignmentRequest, validateRoleRemovalRequest, validateSharedListParams, validateSpaceCreate, validateSpaceScope, validateTokenRequest, validateTokenResponse, validateUser, validateUserCreate, validateWorkflowCreate, validateWorkflowTemplate, validateWorkflowTemplateCreate, validateWorkflowTemplateDeprecate, validateWorkflowTemplateScope, validateWorkflowTemplateUpdate, validateWorkflowVoteRequest };
@@ -1,5 +1,5 @@
1
1
  import * as E from "fp-ts/Either";
2
- import { isLeft, isRight, left, right } from "fp-ts/Either";
2
+ import { isLeft, isRight, left, mapLeft, right } from "fp-ts/Either";
3
3
  import { pipe } from "fp-ts/function";
4
4
  import * as A from "fp-ts/Array";
5
5
  //#region generated/openapi/model/agent-token-request.ts
@@ -346,12 +346,22 @@ function validateSharedListParams(object) {
346
346
  if (typeof object !== "object" || object === null) return left("malformed_object");
347
347
  const result = {};
348
348
  if (hasOwnProperty(object, "page") && object.page !== void 0) {
349
- if (typeof object.page !== "number" || object.page < 1) return left("invalid_page");
350
- result.page = object.page;
349
+ let page = object.page;
350
+ if (typeof page === "string" && page.trim() !== "") {
351
+ const parsed = Number(page);
352
+ if (!isNaN(parsed)) page = parsed;
353
+ }
354
+ if (typeof page !== "number" || !Number.isInteger(page) || page < 1) return left("invalid_page");
355
+ result.page = page;
351
356
  }
352
357
  if (hasOwnProperty(object, "limit") && object.limit !== void 0) {
353
- if (typeof object.limit !== "number" || object.limit < 1) return left("invalid_limit");
354
- result.limit = object.limit;
358
+ let limit = object.limit;
359
+ if (typeof limit === "string" && limit.trim() !== "") {
360
+ const parsed = Number(limit);
361
+ if (!isNaN(parsed)) limit = parsed;
362
+ }
363
+ if (typeof limit !== "number" || !Number.isInteger(limit) || limit < 1) return left("invalid_limit");
364
+ result.limit = limit;
355
365
  }
356
366
  if (hasOwnProperty(object, "search") && object.search !== void 0) {
357
367
  if (typeof object.search !== "string" || object.search.trim() === "") return left("invalid_search");
@@ -404,6 +414,11 @@ function getStringAsEnum(str, enumType) {
404
414
  if (Object.values(enumType).includes(str)) return str;
405
415
  }
406
416
  //#endregion
417
+ //#region src/utils/types.ts
418
+ function prefixLeft(prefix, value) {
419
+ return `${prefix}_${value}`;
420
+ }
421
+ //#endregion
407
422
  //#region src/validators/workflow-templates.validators.ts
408
423
  function validateEmailAction(object) {
409
424
  if (typeof object !== "object" || object === null) return left("malformed_object");
@@ -651,11 +666,8 @@ function validateWorkflowTemplateScope(object) {
651
666
  if (typeof object !== "object" || object === null) return left("malformed_object");
652
667
  if (!hasOwnProperty(object, "type") || object.type !== "workflow_template") return left("invalid_type");
653
668
  if (!hasOwnProperty(object, "workflowTemplateId") || !isNonEmptyString(object.workflowTemplateId)) return left("invalid_workflow_template_id");
654
- if (!hasOwnProperty(object, "type") || typeof object.type !== "string") return left("invalid_type");
655
- const type = getStringAsEnum(object.type, WorkflowTemplateScope.TypeEnum);
656
- if (!type) return left("invalid_type");
657
669
  return right({
658
- type,
670
+ type: object.type,
659
671
  workflowTemplateId: object.workflowTemplateId
660
672
  });
661
673
  }
@@ -685,7 +697,7 @@ function validateListWorkflowTemplates200Response(object) {
685
697
  const data = [];
686
698
  for (const item of object.data) {
687
699
  const validatedItem = validateWorkflowTemplateSummary(item);
688
- if (isLeft(validatedItem)) return left("invalid_data_element");
700
+ if (isLeft(validatedItem)) return left(prefixLeft("data_item", validatedItem.left));
689
701
  data.push(validatedItem.right);
690
702
  }
691
703
  if (!hasOwnProperty(object, "pagination")) return left("missing_pagination");
@@ -793,19 +805,10 @@ function validateGetWorkflowParams(object) {
793
805
  return right({ include });
794
806
  }
795
807
  function validateListWorkflowsParams(object) {
808
+ const sharedValidation = pipe(validateSharedListParams(object), mapLeft((error) => error === "invalid_search" ? "malformed_object" : error));
809
+ if (isLeft(sharedValidation)) return left(sharedValidation.left);
810
+ const result = sharedValidation.right;
796
811
  if (typeof object !== "object" || object === null) return left("malformed_object");
797
- let page = void 0;
798
- if (hasOwnProperty(object, "page")) {
799
- const val = object["page"];
800
- if (typeof val !== "number") return left("invalid_page");
801
- page = val;
802
- }
803
- let limit = void 0;
804
- if (hasOwnProperty(object, "limit")) {
805
- const val = object["limit"];
806
- if (typeof val !== "number") return left("invalid_limit");
807
- limit = val;
808
- }
809
812
  let include = void 0;
810
813
  if (hasOwnProperty(object, "include")) {
811
814
  const includeVal = object["include"];
@@ -829,13 +832,10 @@ function validateListWorkflowsParams(object) {
829
832
  if (typeof val !== "string") return left("invalid_workflow_template_identifier");
830
833
  workflowTemplateIdentifier = val;
831
834
  }
832
- return right({
833
- page,
834
- limit,
835
- include,
836
- includeOnlyNonTerminalState,
837
- workflowTemplateIdentifier
838
- });
835
+ if (include !== void 0) result.include = include;
836
+ if (includeOnlyNonTerminalState !== void 0) result.includeOnlyNonTerminalState = includeOnlyNonTerminalState;
837
+ if (workflowTemplateIdentifier !== void 0) result.workflowTemplateIdentifier = workflowTemplateIdentifier;
838
+ return right(result);
839
839
  }
840
840
  function validateListWorkflows200Response(object) {
841
841
  if (typeof object !== "object" || object === null) return left("malformed_object");
@@ -1223,21 +1223,10 @@ function validateAgentTokenResponse(object) {
1223
1223
  });
1224
1224
  }
1225
1225
  function validateListAgentsParams(object) {
1226
- if (typeof object !== "object" || object === null) return left("malformed_object");
1227
- let page = void 0;
1228
- if (hasOwnProperty(object, "page") && object.page !== void 0) {
1229
- if (typeof object.page !== "number") return left("invalid_page");
1230
- page = object.page;
1231
- }
1232
- let limit = void 0;
1233
- if (hasOwnProperty(object, "limit") && object.limit !== void 0) {
1234
- if (typeof object.limit !== "number") return left("invalid_limit");
1235
- limit = object.limit;
1236
- }
1237
- return right({
1238
- page,
1239
- limit
1240
- });
1226
+ const sharedValidation = pipe(validateSharedListParams(object), mapLeft((error) => error === "invalid_search" ? "malformed_object" : error));
1227
+ if (isLeft(sharedValidation)) return left(sharedValidation.left);
1228
+ const result = sharedValidation.right;
1229
+ return right(result);
1241
1230
  }
1242
1231
  function validateListAgents200Response(object) {
1243
1232
  if (typeof object !== "object" || object === null) return left("malformed_object");
package/package.json CHANGED
@@ -2,7 +2,7 @@
2
2
  "name": "@approvio/api",
3
3
  "author": "Giovanni Baratta",
4
4
  "license": "MIT",
5
- "version": "0.0.33",
5
+ "version": "0.0.35",
6
6
  "private": false,
7
7
  "type": "module",
8
8
  "main": "./dist/src/index.cjs",