@trayio/commons 2.8.0 → 2.10.0

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.
@@ -6,6 +6,7 @@ export declare class RemoveNullValuesCodec implements Codec<unknown> {
6
6
  decode(value: unknown): E.Either<Error, unknown>;
7
7
  private isObject;
8
8
  private removeNullValuesIfPresent;
9
+ private removeNullFromArrayIfPresent;
9
10
  private removeNullFromObjectIfPresent;
10
11
  }
11
12
  //# sourceMappingURL=RemoveNullValuesCodec.d.ts.map
@@ -1 +1 @@
1
- {"version":3,"file":"RemoveNullValuesCodec.d.ts","sourceRoot":"","sources":["../../src/codec/RemoveNullValuesCodec.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,CAAC,MAAM,kBAAkB,CAAC;AACtC,OAAO,EAAE,KAAK,EAAE,MAAM,SAAS,CAAC;AAEhC,qBAAa,qBAAsB,YAAW,KAAK,CAAC,OAAO,CAAC;IAC3D,MAAM,CAAC,QAAQ,EAAE,KAAK,CAAC,OAAO,CAAC,CAA+B;IAE9D,MAAM,CAAC,KAAK,EAAE,OAAO,GAAG,OAAO;IAI/B,MAAM,CAAC,KAAK,EAAE,OAAO,GAAG,CAAC,CAAC,MAAM,CAAC,KAAK,EAAE,OAAO,CAAC;IAIhD,OAAO,CAAC,QAAQ;IAIhB,OAAO,CAAC,yBAAyB;IAUjC,OAAO,CAAC,6BAA6B;CAYrC"}
1
+ {"version":3,"file":"RemoveNullValuesCodec.d.ts","sourceRoot":"","sources":["../../src/codec/RemoveNullValuesCodec.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,CAAC,MAAM,kBAAkB,CAAC;AACtC,OAAO,EAAE,KAAK,EAAE,MAAM,SAAS,CAAC;AAEhC,qBAAa,qBAAsB,YAAW,KAAK,CAAC,OAAO,CAAC;IAC3D,MAAM,CAAC,QAAQ,EAAE,KAAK,CAAC,OAAO,CAAC,CAA+B;IAE9D,MAAM,CAAC,KAAK,EAAE,OAAO,GAAG,OAAO;IAI/B,MAAM,CAAC,KAAK,EAAE,OAAO,GAAG,CAAC,CAAC,MAAM,CAAC,KAAK,EAAE,OAAO,CAAC;IAIhD,OAAO,CAAC,QAAQ;IAIhB,OAAO,CAAC,yBAAyB;IAajC,OAAO,CAAC,4BAA4B;IASpC,OAAO,CAAC,6BAA6B;CAgBrC"}
@@ -42,8 +42,19 @@ class RemoveNullValuesCodec {
42
42
  if (this.isObject(value)) {
43
43
  return this.removeNullFromObjectIfPresent(value);
44
44
  }
45
+ if (Array.isArray(value)) {
46
+ return this.removeNullFromArrayIfPresent(value);
47
+ }
45
48
  return value;
46
49
  }
50
+ removeNullFromArrayIfPresent(value) {
51
+ return value.reduce((acc, propertyValue) => {
52
+ if (propertyValue == null) {
53
+ return acc;
54
+ }
55
+ return [...acc, this.removeNullValuesIfPresent(propertyValue)];
56
+ }, []);
57
+ }
47
58
  removeNullFromObjectIfPresent(value) {
48
59
  return Object.entries(value).reduce((acc, [key, propertyValue]) => {
49
60
  if (propertyValue == null) {
@@ -53,6 +64,10 @@ class RemoveNullValuesCodec {
53
64
  const nestedObject = this.removeNullFromObjectIfPresent(propertyValue);
54
65
  return Object.assign(Object.assign({}, acc), { [key]: nestedObject });
55
66
  }
67
+ if (Array.isArray(propertyValue)) {
68
+ const nestedArray = this.removeNullFromArrayIfPresent(propertyValue);
69
+ return Object.assign(Object.assign({}, acc), { [key]: nestedArray });
70
+ }
56
71
  return Object.assign(Object.assign({}, acc), { [key]: propertyValue });
57
72
  }, {});
58
73
  }
@@ -2,6 +2,8 @@
2
2
  import { Readable } from 'stream';
3
3
  import { TaskEither } from 'fp-ts/TaskEither';
4
4
  import * as t from 'io-ts';
5
+ import { Option } from 'fp-ts/lib/Option';
6
+ import { DynamicObject } from '../dynamictype/DynamicType';
5
7
  export type FileMetadata = {
6
8
  name: string;
7
9
  size?: number;
@@ -18,7 +20,7 @@ export type SharedUrl = {
18
20
  expires?: number;
19
21
  };
20
22
  export interface FileStorage {
21
- write(file: File): TaskEither<Error, File>;
23
+ write(file: File, writeOptions: Option<DynamicObject>): TaskEither<Error, File>;
22
24
  read(key: string, name?: string): TaskEither<Error, File>;
23
25
  getSharedUrl(key: string): TaskEither<Error, SharedUrl>;
24
26
  delete(key: string): TaskEither<Error, undefined>;
@@ -1 +1 @@
1
- {"version":3,"file":"File.d.ts","sourceRoot":"","sources":["../../src/file/File.ts"],"names":[],"mappings":";AAAA,OAAO,EAAE,QAAQ,EAAE,MAAM,QAAQ,CAAC;AAClC,OAAO,EAAE,UAAU,EAAE,MAAM,kBAAkB,CAAC;AAC9C,OAAO,KAAK,CAAC,MAAM,OAAO,CAAC;AAE3B,MAAM,MAAM,YAAY,GAAG;IAC1B,IAAI,EAAE,MAAM,CAAC;IACb,IAAI,CAAC,EAAE,MAAM,CAAC;IACd,WAAW,CAAC,EAAE,MAAM,CAAC;CACrB,CAAC;AACF,eAAO,MAAM,sBAAsB,EAAE,CAAC,CAAC,IAAI,CAAC,YAAY,EAAE,OAAO,CAY/D,CAAC;AAKH,MAAM,MAAM,IAAI,GAAG;IAElB,GAAG,EAAE,MAAM,CAAC;IACZ,QAAQ,EAAE,YAAY,CAAC;IACvB,OAAO,EAAE,QAAQ,CAAC;CAClB,CAAC;AAEF,MAAM,MAAM,SAAS,GAAG;IACvB,GAAG,EAAE,MAAM,CAAC;IACZ,OAAO,CAAC,EAAE,MAAM,CAAC;CACjB,CAAC;AAEF,MAAM,WAAW,WAAW;IAC3B,KAAK,CAAC,IAAI,EAAE,IAAI,GAAG,UAAU,CAAC,KAAK,EAAE,IAAI,CAAC,CAAC;IAC3C,IAAI,CAAC,GAAG,EAAE,MAAM,EAAE,IAAI,CAAC,EAAE,MAAM,GAAG,UAAU,CAAC,KAAK,EAAE,IAAI,CAAC,CAAC;IAC1D,YAAY,CAAC,GAAG,EAAE,MAAM,GAAG,UAAU,CAAC,KAAK,EAAE,SAAS,CAAC,CAAC;IACxD,MAAM,CAAC,GAAG,EAAE,MAAM,GAAG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AAG,UAAU,CAAC,KAAK,EAAE,SAAS,CAAC,CAAC;IACxD,MAAM,CAAC,GAAG,EAAE,MAAM,GAAG,UAAU,CAAC,KAAK,EAAE,SAAS,CAAC,CAAC;IAClD,eAAe,CAAC,GAAG,EAAE,MAAM,GAAG,UAAU,CAAC,KAAK,EAAE,SAAS,CAAC,CAAC;CAC3D"}
@@ -1 +1 @@
1
- {"version":3,"file":"FileStorage.abstract.test.d.ts","sourceRoot":"","sources":["../../src/file/FileStorage.abstract.test.ts"],"names":[],"mappings":"AAIA,OAAO,EAAE,WAAW,EAAQ,MAAM,QAAQ,CAAC;AAE3C,eAAO,MAAM,eAAe,gBAAiB,WAAW,SA0FvD,CAAC"}
1
+ {"version":3,"file":"FileStorage.abstract.test.d.ts","sourceRoot":"","sources":["../../src/file/FileStorage.abstract.test.ts"],"names":[],"mappings":"AAKA,OAAO,EAAE,WAAW,EAAQ,MAAM,QAAQ,CAAC;AAE3C,eAAO,MAAM,eAAe,gBAAiB,WAAW,SA0FvD,CAAC"}
@@ -35,6 +35,7 @@ Object.defineProperty(exports, "__esModule", { value: true });
35
35
  exports.fileStorageTest = void 0;
36
36
  const E = __importStar(require("fp-ts/Either"));
37
37
  const uuid_1 = require("uuid");
38
+ const O = __importStar(require("fp-ts/Option"));
38
39
  const stream_1 = require("stream");
39
40
  const JsonSerialization_1 = require("../serialization/JsonSerialization");
40
41
  const fileStorageTest = (fileStorage) => {
@@ -58,7 +59,7 @@ const fileStorageTest = (fileStorage) => {
58
59
  },
59
60
  content: readableStream,
60
61
  };
61
- const writtenFile = yield fileStorage.write(file)();
62
+ const writtenFile = yield fileStorage.write(file, O.none)();
62
63
  expect(writtenFile).toEqual(E.right(file));
63
64
  const sharedUrl = yield fileStorage.getSharedUrl(file.key)();
64
65
  expect(sharedUrl).toEqual(E.right(expect.objectContaining({
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@trayio/commons",
3
- "version": "2.8.0",
3
+ "version": "2.10.0",
4
4
  "description": "Extensions to the standard/core libraries and basic features",
5
5
  "exports": {
6
6
  "./*": "./dist/*.js"