ts-gems 3.1.0 → 3.2.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.
package/lib/dto.d.ts ADDED
@@ -0,0 +1,21 @@
1
+ import { IfNoDeepValue } from './helpers.js';
2
+ import { DeeperNullish } from './nullish.js';
3
+ import { DeeperPartial } from './partial.js';
4
+ import { IfNever } from './type-check.js';
5
+
6
+ /**
7
+ * Returns given type as a Data Transfer Object (DTO) interface, Removes symbol keys and function properties.
8
+ * @template T - The type of the data being transferred.
9
+ */
10
+ export type DTO<T> = {
11
+ [K in keyof T as (IfNever<Exclude<T[K], undefined | Function>, never, K>)]:
12
+ // Deep process arrays
13
+ Exclude<T[K], undefined | null> extends (infer U)[] ? DTO<U>[]
14
+ // Do not deep process No-Deep values
15
+ : IfNoDeepValue<Exclude<T[K], undefined | null>> extends true ? Exclude<T[K], undefined | null>
16
+ // Deep process objects
17
+ : DTO<Exclude<T[K], undefined | null>>
18
+ };
19
+
20
+ export type PartialDTO<T> = DeeperPartial<DTO<T>>;
21
+ export type PatchDTO<T> = DeeperNullish<DTO<T>>;
package/lib/index.d.ts CHANGED
@@ -1,4 +1,5 @@
1
1
  export * from "./combine";
2
+ export * from "./dto";
2
3
  export * from "./helpers";
3
4
  export * from "./logical.js";
4
5
  export * from "./mutable";
@@ -12,4 +13,3 @@ export * from "./readonly";
12
13
  export * from "./required";
13
14
  export * from "./type-check";
14
15
  export * from "./types";
15
-
package/lib/types.d.ts CHANGED
@@ -1,3 +1,17 @@
1
+ /**
2
+ * Declare ReadableStream and WritableStream in case dom.d.ts is not added to the tsconfig
3
+ * lib causing ReadableStream or WritableStream interface is not defined.
4
+ * For developers with dom.d.ts added, the ReadableStream and WritableStream
5
+ * interface will be merged correctly.
6
+ *
7
+ * This is also required for any clients with streaming interface where ReadableStream
8
+ * or WritableStream type is also referred.
9
+ */
10
+ declare global {
11
+ export interface ReadableStream {}
12
+ export interface WritableStream {}
13
+ }
14
+
1
15
  /**
2
16
  * BasicPrimitive
3
17
  * @desc Type representing [`BasicPrimitive`](https://www.typescriptlang.org/docs/handbook/release-notes/overview.html#smarter-type-alias-preservation) types in TypeScript
@@ -61,8 +75,8 @@ export type Nullish<T = null> = T | undefined | null;
61
75
  export type Awaited<T> = T extends PromiseLike<infer U> ? U : T;
62
76
 
63
77
 
64
- export type Thunk<T, Args extends any[] = any[]> = T | ((...args: Args) => T);
65
- export type ThunkAsync<T, Args extends any[] = any[]> = Thunk<T> | ((...args: Args) => Promise<T>);
78
+ export type Thunk<T> = T | (() => T);
79
+ export type ThunkAsync<T> = Thunk<T> | (() => Promise<T>)
66
80
  export type TypeThunk<T = any> = Thunk<Type<T>>;
67
81
  export type TypeThunkAsync<T = any> = ThunkAsync<Type<T>>;
68
82
 
package/package.json CHANGED
@@ -12,7 +12,7 @@
12
12
  "lodash",
13
13
  "underscore"
14
14
  ],
15
- "version": "3.1.0",
15
+ "version": "3.2.0",
16
16
  "types": "lib/index.d.ts",
17
17
  "main": "lib/index.js",
18
18
  "module": "lib/index.js",
@@ -32,10 +32,10 @@
32
32
  "lib/"
33
33
  ],
34
34
  "devDependencies": {
35
- "@types/jest": "^29.5.11",
36
- "eslint": "^8.55.0",
35
+ "@types/jest": "^29.5.12",
36
+ "eslint": "^8.57.0",
37
37
  "jest": "^29.7.0",
38
- "ts-jest": "^29.1.1",
39
- "typescript": "^5.3.3"
38
+ "ts-jest": "^29.1.2",
39
+ "typescript": "^5.4.2"
40
40
  }
41
41
  }