@naturalcycles/js-lib 14.201.1 → 14.202.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/dist/types.d.ts +6 -3
- package/package.json +1 -1
- package/src/typeFest.ts +4 -8
- package/src/types.ts +8 -3
package/dist/types.d.ts
CHANGED
|
@@ -25,6 +25,9 @@ export interface CreatedUpdatedId extends CreatedUpdated {
|
|
|
25
25
|
export type ObjectWithId = {
|
|
26
26
|
id: string;
|
|
27
27
|
};
|
|
28
|
+
export type PartialObjectWithId = {
|
|
29
|
+
id?: string;
|
|
30
|
+
};
|
|
28
31
|
export interface AnyObjectWithId extends AnyObject, ObjectWithId {
|
|
29
32
|
}
|
|
30
33
|
/**
|
|
@@ -58,9 +61,9 @@ export type BaseDBEntity = {
|
|
|
58
61
|
*/
|
|
59
62
|
updated?: UnixTimestampNumber;
|
|
60
63
|
};
|
|
61
|
-
export type Saved<T extends
|
|
62
|
-
export type Unsaved<T extends
|
|
63
|
-
export type UnsavedId<T extends
|
|
64
|
+
export type Saved<T extends PartialObjectWithId> = T extends AnyObject ? Omit<T, 'id' | 'created' | 'updated'> & SavedDBEntity : T;
|
|
65
|
+
export type Unsaved<T extends PartialObjectWithId> = T extends AnyObject ? Omit<T, 'id' | 'created' | 'updated'> & BaseDBEntity : T;
|
|
66
|
+
export type UnsavedId<T extends PartialObjectWithId> = Omit<T, 'id'> & {
|
|
64
67
|
id?: T['id'];
|
|
65
68
|
};
|
|
66
69
|
/**
|
package/package.json
CHANGED
package/src/typeFest.ts
CHANGED
|
@@ -17,9 +17,8 @@ export type Simplify<T> = { [KeyType in keyof T]: T[KeyType] }
|
|
|
17
17
|
@link https://github.com/microsoft/TypeScript/issues/27024#issuecomment-421529650
|
|
18
18
|
@link https://stackoverflow.com/questions/68961864/how-does-the-equals-work-in-typescript/68963796#68963796
|
|
19
19
|
*/
|
|
20
|
-
export type IsEqual<T, U> =
|
|
21
|
-
? true
|
|
22
|
-
: false
|
|
20
|
+
export type IsEqual<T, U> =
|
|
21
|
+
(<G>() => G extends T ? 1 : 2) extends <G>() => G extends U ? 1 : 2 ? true : false
|
|
23
22
|
|
|
24
23
|
/**
|
|
25
24
|
* Filter out keys from an object.
|
|
@@ -27,11 +26,8 @@ export type IsEqual<T, U> = (<G>() => G extends T ? 1 : 2) extends <G>() => G ex
|
|
|
27
26
|
* Returns `never` if `Key` extends `Exclude`.
|
|
28
27
|
* Returns `Key` otherwise.
|
|
29
28
|
*/
|
|
30
|
-
type Filter<KeyType, ExcludeType> =
|
|
31
|
-
? never
|
|
32
|
-
: KeyType extends ExcludeType
|
|
33
|
-
? never
|
|
34
|
-
: KeyType
|
|
29
|
+
type Filter<KeyType, ExcludeType> =
|
|
30
|
+
IsEqual<KeyType, ExcludeType> extends true ? never : KeyType extends ExcludeType ? never : KeyType
|
|
35
31
|
|
|
36
32
|
/**
|
|
37
33
|
Create a type from an object type without certain keys.
|
package/src/types.ts
CHANGED
|
@@ -34,6 +34,11 @@ export type ObjectWithId = {
|
|
|
34
34
|
id: string
|
|
35
35
|
}
|
|
36
36
|
|
|
37
|
+
// eslint-disable-next-line @typescript-eslint/consistent-type-definitions
|
|
38
|
+
export type PartialObjectWithId = {
|
|
39
|
+
id?: string
|
|
40
|
+
}
|
|
41
|
+
|
|
37
42
|
export interface AnyObjectWithId extends AnyObject, ObjectWithId {}
|
|
38
43
|
|
|
39
44
|
/**
|
|
@@ -75,15 +80,15 @@ export type BaseDBEntity = {
|
|
|
75
80
|
updated?: UnixTimestampNumber
|
|
76
81
|
}
|
|
77
82
|
|
|
78
|
-
export type Saved<T extends
|
|
83
|
+
export type Saved<T extends PartialObjectWithId> = T extends AnyObject
|
|
79
84
|
? Omit<T, 'id' | 'created' | 'updated'> & SavedDBEntity
|
|
80
85
|
: T
|
|
81
86
|
|
|
82
|
-
export type Unsaved<T extends
|
|
87
|
+
export type Unsaved<T extends PartialObjectWithId> = T extends AnyObject
|
|
83
88
|
? Omit<T, 'id' | 'created' | 'updated'> & BaseDBEntity
|
|
84
89
|
: T
|
|
85
90
|
|
|
86
|
-
export type UnsavedId<T extends
|
|
91
|
+
export type UnsavedId<T extends PartialObjectWithId> = Omit<T, 'id'> & {
|
|
87
92
|
id?: T['id']
|
|
88
93
|
}
|
|
89
94
|
|