@approvio/api 0.0.33 → 0.0.34

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");
@@ -817,19 +827,10 @@ function validateGetWorkflowParams(object) {
817
827
  return (0, fp_ts_Either.right)({ include });
818
828
  }
819
829
  function validateListWorkflowsParams(object) {
830
+ const sharedValidation = (0, fp_ts_function.pipe)(validateSharedListParams(object), (0, fp_ts_Either.mapLeft)((error) => error === "invalid_search" ? "malformed_object" : error));
831
+ if ((0, fp_ts_Either.isLeft)(sharedValidation)) return (0, fp_ts_Either.left)(sharedValidation.left);
832
+ const result = sharedValidation.right;
820
833
  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
834
  let include = void 0;
834
835
  if (hasOwnProperty(object, "include")) {
835
836
  const includeVal = object["include"];
@@ -853,13 +854,10 @@ function validateListWorkflowsParams(object) {
853
854
  if (typeof val !== "string") return (0, fp_ts_Either.left)("invalid_workflow_template_identifier");
854
855
  workflowTemplateIdentifier = val;
855
856
  }
856
- return (0, fp_ts_Either.right)({
857
- page,
858
- limit,
859
- include,
860
- includeOnlyNonTerminalState,
861
- workflowTemplateIdentifier
862
- });
857
+ if (include !== void 0) result.include = include;
858
+ if (includeOnlyNonTerminalState !== void 0) result.includeOnlyNonTerminalState = includeOnlyNonTerminalState;
859
+ if (workflowTemplateIdentifier !== void 0) result.workflowTemplateIdentifier = workflowTemplateIdentifier;
860
+ return (0, fp_ts_Either.right)(result);
863
861
  }
864
862
  function validateListWorkflows200Response(object) {
865
863
  if (typeof object !== "object" || object === null) return (0, fp_ts_Either.left)("malformed_object");
@@ -1247,21 +1245,10 @@ function validateAgentTokenResponse(object) {
1247
1245
  });
1248
1246
  }
1249
1247
  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
- });
1248
+ const sharedValidation = (0, fp_ts_function.pipe)(validateSharedListParams(object), (0, fp_ts_Either.mapLeft)((error) => error === "invalid_search" ? "malformed_object" : error));
1249
+ if ((0, fp_ts_Either.isLeft)(sharedValidation)) return (0, fp_ts_Either.left)(sharedValidation.left);
1250
+ const result = sharedValidation.right;
1251
+ return (0, fp_ts_Either.right)(result);
1265
1252
  }
1266
1253
  function validateListAgents200Response(object) {
1267
1254
  if (typeof object !== "object" || object === null) return (0, fp_ts_Either.left)("malformed_object");
@@ -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");
@@ -793,19 +803,10 @@ function validateGetWorkflowParams(object) {
793
803
  return right({ include });
794
804
  }
795
805
  function validateListWorkflowsParams(object) {
806
+ const sharedValidation = pipe(validateSharedListParams(object), mapLeft((error) => error === "invalid_search" ? "malformed_object" : error));
807
+ if (isLeft(sharedValidation)) return left(sharedValidation.left);
808
+ const result = sharedValidation.right;
796
809
  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
810
  let include = void 0;
810
811
  if (hasOwnProperty(object, "include")) {
811
812
  const includeVal = object["include"];
@@ -829,13 +830,10 @@ function validateListWorkflowsParams(object) {
829
830
  if (typeof val !== "string") return left("invalid_workflow_template_identifier");
830
831
  workflowTemplateIdentifier = val;
831
832
  }
832
- return right({
833
- page,
834
- limit,
835
- include,
836
- includeOnlyNonTerminalState,
837
- workflowTemplateIdentifier
838
- });
833
+ if (include !== void 0) result.include = include;
834
+ if (includeOnlyNonTerminalState !== void 0) result.includeOnlyNonTerminalState = includeOnlyNonTerminalState;
835
+ if (workflowTemplateIdentifier !== void 0) result.workflowTemplateIdentifier = workflowTemplateIdentifier;
836
+ return right(result);
839
837
  }
840
838
  function validateListWorkflows200Response(object) {
841
839
  if (typeof object !== "object" || object === null) return left("malformed_object");
@@ -1223,21 +1221,10 @@ function validateAgentTokenResponse(object) {
1223
1221
  });
1224
1222
  }
1225
1223
  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
- });
1224
+ const sharedValidation = pipe(validateSharedListParams(object), mapLeft((error) => error === "invalid_search" ? "malformed_object" : error));
1225
+ if (isLeft(sharedValidation)) return left(sharedValidation.left);
1226
+ const result = sharedValidation.right;
1227
+ return right(result);
1241
1228
  }
1242
1229
  function validateListAgents200Response(object) {
1243
1230
  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.34",
6
6
  "private": false,
7
7
  "type": "module",
8
8
  "main": "./dist/src/index.cjs",