ts-gems 3.1.1 → 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 +21 -0
- package/lib/index.d.ts +1 -1
- package/lib/types.d.ts +2 -2
- package/package.json +5 -5
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
|
@@ -75,8 +75,8 @@ export type Nullish<T = null> = T | undefined | null;
|
|
|
75
75
|
export type Awaited<T> = T extends PromiseLike<infer U> ? U : T;
|
|
76
76
|
|
|
77
77
|
|
|
78
|
-
export type Thunk<T
|
|
79
|
-
export type ThunkAsync<T
|
|
78
|
+
export type Thunk<T> = T | (() => T);
|
|
79
|
+
export type ThunkAsync<T> = Thunk<T> | (() => Promise<T>)
|
|
80
80
|
export type TypeThunk<T = any> = Thunk<Type<T>>;
|
|
81
81
|
export type TypeThunkAsync<T = any> = ThunkAsync<Type<T>>;
|
|
82
82
|
|
package/package.json
CHANGED
|
@@ -12,7 +12,7 @@
|
|
|
12
12
|
"lodash",
|
|
13
13
|
"underscore"
|
|
14
14
|
],
|
|
15
|
-
"version": "3.
|
|
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.
|
|
36
|
-
"eslint": "^8.
|
|
35
|
+
"@types/jest": "^29.5.12",
|
|
36
|
+
"eslint": "^8.57.0",
|
|
37
37
|
"jest": "^29.7.0",
|
|
38
|
-
"ts-jest": "^29.1.
|
|
39
|
-
"typescript": "^5.
|
|
38
|
+
"ts-jest": "^29.1.2",
|
|
39
|
+
"typescript": "^5.4.2"
|
|
40
40
|
}
|
|
41
41
|
}
|