@bitgo/public-types 4.9.0 → 4.9.1

Sign up to get free protection for your applications and to get access to all the features.
@@ -1,2 +1,2 @@
1
1
  import * as t from "io-ts";
2
- export declare function arrayFromSingle<C extends t.Mixed>(codec: C, name?: string): t.Type<t.TypeOf<C>[], t.TypeOf<C>[], unknown>;
2
+ export declare function arrayFromSingle<C extends t.Mixed>(codec: C, name?: string): t.Type<any[], any[], unknown>;
@@ -23,12 +23,16 @@ var __importStar = (this && this.__importStar) || function (mod) {
23
23
  return result;
24
24
  };
25
25
  Object.defineProperty(exports, "__esModule", { value: true });
26
- exports.arrayFromSingle = void 0;
26
+ exports.arrayFromSingle = arrayFromSingle;
27
27
  const t = __importStar(require("io-ts"));
28
- const function_1 = require("fp-ts/function");
29
- const Either_1 = require("fp-ts/lib/Either");
28
+ const E = __importStar(require("fp-ts/lib/Either"));
30
29
  function arrayFromSingle(codec, name = `ArrayFromSingle<${codec.name}>`) {
31
- return new t.Type(name, t.array(codec).is, (u, c) => (0, function_1.pipe)(codec.validate(u, c), (0, Either_1.chain)((as) => t.array(codec).validate([as], c))), t.identity);
30
+ return new t.Type(name, t.array(codec).is, (u, c) => {
31
+ const valueE = codec.validate(u, c);
32
+ if (E.isLeft(valueE)) {
33
+ return valueE;
34
+ }
35
+ return E.right([valueE.right]);
36
+ }, t.identity);
32
37
  }
33
- exports.arrayFromSingle = arrayFromSingle;
34
38
  //# sourceMappingURL=arrayFromSingle.js.map
@@ -1 +1 @@
1
- {"version":3,"file":"arrayFromSingle.js","sourceRoot":"","sources":["../../../src/utils/arrayFromSingle.ts"],"names":[],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;;AAAA,yCAA2B;AAC3B,6CAAsC;AACtC,6CAAyC;AAEzC,SAAgB,eAAe,CAC7B,KAAQ,EACR,OAAe,mBAAmB,KAAK,CAAC,IAAI,GAAG;IAE/C,OAAO,IAAI,CAAC,CAAC,IAAI,CACf,IAAI,EACJ,CAAC,CAAC,KAAK,CAAC,KAAK,CAAC,CAAC,EAAE,EACjB,CAAC,CAAC,EAAE,CAAC,EAAE,EAAE,CACP,IAAA,eAAI,EACF,KAAK,CAAC,QAAQ,CAAC,CAAC,EAAE,CAAC,CAAC,EACpB,IAAA,cAAK,EAAC,CAAC,EAAE,EAAE,EAAE,CAAC,CAAC,CAAC,KAAK,CAAC,KAAK,CAAC,CAAC,QAAQ,CAAC,CAAC,EAAE,CAAC,EAAE,CAAC,CAAC,CAAC,CAChD,EACH,CAAC,CAAC,QAAQ,CACX,CAAC;AACJ,CAAC;AAdD,0CAcC"}
1
+ {"version":3,"file":"arrayFromSingle.js","sourceRoot":"","sources":["../../../src/utils/arrayFromSingle.ts"],"names":[],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;AAGA,0CAgBC;AAnBD,yCAA2B;AAC3B,oDAAsC;AAEtC,SAAgB,eAAe,CAC7B,KAAQ,EACR,OAAe,mBAAmB,KAAK,CAAC,IAAI,GAAG;IAE/C,OAAO,IAAI,CAAC,CAAC,IAAI,CACf,IAAI,EACJ,CAAC,CAAC,KAAK,CAAC,KAAK,CAAC,CAAC,EAAE,EACjB,CAAC,CAAC,EAAE,CAAC,EAAE,EAAE;QACP,MAAM,MAAM,GAAG,KAAK,CAAC,QAAQ,CAAC,CAAC,EAAE,CAAC,CAAC,CAAC;QACpC,IAAI,CAAC,CAAC,MAAM,CAAC,MAAM,CAAC,EAAE,CAAC;YACrB,OAAO,MAAM,CAAC;QAChB,CAAC;QACD,OAAO,CAAC,CAAC,KAAK,CAAC,CAAC,MAAM,CAAC,KAAK,CAAC,CAAC,CAAC;IACjC,CAAC,EACD,CAAC,CAAC,QAAQ,CACX,CAAC;AACJ,CAAC"}
@@ -3,6 +3,6 @@ export interface IMinMaxArray<T> extends Array<T> {
3
3
  readonly minMaxArray: unique symbol;
4
4
  }
5
5
  export declare const minMaxArray: <C extends t.Mixed>(codec: C, { min, max, }?: {
6
- min?: number | undefined;
7
- max?: number | undefined;
6
+ min?: number;
7
+ max?: number;
8
8
  }) => t.BrandC<t.ArrayC<C>, IMinMaxArray<C>>;
@@ -23,10 +23,9 @@ var __importStar = (this && this.__importStar) || function (mod) {
23
23
  return result;
24
24
  };
25
25
  Object.defineProperty(exports, "__esModule", { value: true });
26
- exports.Optional = void 0;
26
+ exports.Optional = Optional;
27
27
  const t = __importStar(require("io-ts"));
28
28
  function Optional(type) {
29
29
  return t.union([type, t.undefined]);
30
30
  }
31
- exports.Optional = Optional;
32
31
  //# sourceMappingURL=optional.js.map
@@ -1 +1 @@
1
- {"version":3,"file":"optional.js","sourceRoot":"","sources":["../../../src/utils/optional.ts"],"names":[],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;;AAAA,yCAA2B;AAE3B,SAAgB,QAAQ,CAAI,IAAe;IACzC,OAAO,CAAC,CAAC,KAAK,CAAC,CAAC,IAAI,EAAE,CAAC,CAAC,SAAS,CAAC,CAAC,CAAC;AACtC,CAAC;AAFD,4BAEC"}
1
+ {"version":3,"file":"optional.js","sourceRoot":"","sources":["../../../src/utils/optional.ts"],"names":[],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;AAEA,4BAEC;AAJD,yCAA2B;AAE3B,SAAgB,QAAQ,CAAI,IAAe;IACzC,OAAO,CAAC,CAAC,KAAK,CAAC,CAAC,IAAI,EAAE,CAAC,CAAC,SAAS,CAAC,CAAC,CAAC;AACtC,CAAC"}
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@bitgo/public-types",
3
- "version": "4.9.0",
3
+ "version": "4.9.1",
4
4
  "description": "Collection of types exposed externally as part of the BitGo public API",
5
5
  "license": "UNLICENSED",
6
6
  "author": "",
@@ -23,7 +23,7 @@
23
23
  },
24
24
  "dependencies": {
25
25
  "@api-ts/io-ts-http": "^1.0.0",
26
- "fp-ts": "^2.16.2",
26
+ "fp-ts": "^2.0.0",
27
27
  "io-ts": "npm:@bitgo-forks/io-ts@2.1.4",
28
28
  "io-ts-types": "^0.5.16",
29
29
  "monocle-ts": "^2.3.13",
@@ -33,9 +33,9 @@
33
33
  "@semantic-release/git": "10.0.1",
34
34
  "@types/node": "20.11.2",
35
35
  "@vitest/coverage-v8": "1.2.2",
36
+ "prettier": "^3.2.4",
36
37
  "semantic-release": "23.0.2",
37
- "typescript": "5.3",
38
- "vitest": "1.3.0",
39
- "prettier": "^3.2.4"
38
+ "typescript": "5.6.3",
39
+ "vitest": "1.3.0"
40
40
  }
41
41
  }
@@ -1,6 +1,5 @@
1
1
  import * as t from "io-ts";
2
- import { pipe } from "fp-ts/function";
3
- import { chain } from "fp-ts/lib/Either";
2
+ import * as E from "fp-ts/lib/Either";
4
3
 
5
4
  export function arrayFromSingle<C extends t.Mixed>(
6
5
  codec: C,
@@ -9,11 +8,13 @@ export function arrayFromSingle<C extends t.Mixed>(
9
8
  return new t.Type(
10
9
  name,
11
10
  t.array(codec).is,
12
- (u, c) =>
13
- pipe(
14
- codec.validate(u, c),
15
- chain((as) => t.array(codec).validate([as], c)),
16
- ),
11
+ (u, c) => {
12
+ const valueE = codec.validate(u, c);
13
+ if (E.isLeft(valueE)) {
14
+ return valueE;
15
+ }
16
+ return E.right([valueE.right]);
17
+ },
17
18
  t.identity,
18
19
  );
19
20
  }