@naturalcycles/js-lib 14.112.0 → 14.113.1
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 -2
- package/dist/types.js +5 -1
- package/dist-esm/types.js +4 -0
- package/package.json +1 -2
- package/src/types.ts +14 -5
package/dist/types.d.ts
CHANGED
|
@@ -48,8 +48,8 @@ export interface SavedDBEntity<ID extends string | number = string> {
|
|
|
48
48
|
* When it's known to be saved - `SavedDBEntity` interface can be used instead.
|
|
49
49
|
*/
|
|
50
50
|
export declare type BaseDBEntity<ID extends string | number = string> = Partial<SavedDBEntity<ID>>;
|
|
51
|
-
export declare type Saved<T extends Partial<ObjectWithId>> = Omit<T, 'id' | 'created' | 'updated'> & SavedDBEntity<NonNullable<T['id']
|
|
52
|
-
export declare type Unsaved<T extends Partial<ObjectWithId>> = Omit<T, 'id' | 'created' | 'updated'> & BaseDBEntity<NonNullable<T['id']
|
|
51
|
+
export declare type Saved<T extends Partial<ObjectWithId>> = T extends AnyObject ? Omit<T, 'id' | 'created' | 'updated'> & SavedDBEntity<NonNullable<T['id']>> : T;
|
|
52
|
+
export declare type Unsaved<T extends Partial<ObjectWithId>> = T extends AnyObject ? Omit<T, 'id' | 'created' | 'updated'> & BaseDBEntity<NonNullable<T['id']>> : T;
|
|
53
53
|
export declare type UnsavedId<T extends Partial<ObjectWithId>> = Omit<T, 'id'> & {
|
|
54
54
|
id?: T['id'];
|
|
55
55
|
};
|
|
@@ -196,3 +196,7 @@ export declare type FalsyValue = false | '' | 0 | null | undefined;
|
|
|
196
196
|
* }
|
|
197
197
|
*/
|
|
198
198
|
export declare function _typeCast<T>(v: any): asserts v is T;
|
|
199
|
+
/**
|
|
200
|
+
* Type-safe Object.assign that checks that part is indeed a Partial<T>
|
|
201
|
+
*/
|
|
202
|
+
export declare const _objectAssign: <T extends AnyObject>(target: T, part: Partial<T>) => T;
|
package/dist/types.js
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
"use strict";
|
|
2
2
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
-
exports._typeCast = exports._objectKeys = exports._stringMapEntries = exports._stringMapValues = exports._passNothingPredicate = exports._passthroughPredicate = exports._noop = exports._passUndefinedMapper = exports._passthroughMapper = exports.SKIP = exports.END = void 0;
|
|
3
|
+
exports._objectAssign = exports._typeCast = exports._objectKeys = exports._stringMapEntries = exports._stringMapValues = exports._passNothingPredicate = exports._passthroughPredicate = exports._noop = exports._passUndefinedMapper = exports._passthroughMapper = exports.SKIP = exports.END = void 0;
|
|
4
4
|
/**
|
|
5
5
|
* Symbol to indicate END of Sequence.
|
|
6
6
|
*/
|
|
@@ -50,3 +50,7 @@ exports._objectKeys = Object.keys;
|
|
|
50
50
|
*/
|
|
51
51
|
function _typeCast(v) { }
|
|
52
52
|
exports._typeCast = _typeCast;
|
|
53
|
+
/**
|
|
54
|
+
* Type-safe Object.assign that checks that part is indeed a Partial<T>
|
|
55
|
+
*/
|
|
56
|
+
exports._objectAssign = Object.assign;
|
package/dist-esm/types.js
CHANGED
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@naturalcycles/js-lib",
|
|
3
|
-
"version": "14.
|
|
3
|
+
"version": "14.113.1",
|
|
4
4
|
"scripts": {
|
|
5
5
|
"prepare": "husky install",
|
|
6
6
|
"build-prod": "build-prod-esm-cjs",
|
|
@@ -16,7 +16,6 @@
|
|
|
16
16
|
"@naturalcycles/nodejs-lib": "^12.33.4",
|
|
17
17
|
"@naturalcycles/time-lib": "^3.5.1",
|
|
18
18
|
"@types/node": "^18.0.0",
|
|
19
|
-
"expect-type": "^0.14.2",
|
|
20
19
|
"jest": "^29.0.0",
|
|
21
20
|
"prettier": "^2.1.2",
|
|
22
21
|
"rxjs": "^7.0.1",
|
package/src/types.ts
CHANGED
|
@@ -62,12 +62,13 @@ export interface SavedDBEntity<ID extends string | number = string> {
|
|
|
62
62
|
*/
|
|
63
63
|
export type BaseDBEntity<ID extends string | number = string> = Partial<SavedDBEntity<ID>>
|
|
64
64
|
|
|
65
|
-
|
|
66
|
-
|
|
67
|
-
|
|
65
|
+
export type Saved<T extends Partial<ObjectWithId>> = T extends AnyObject
|
|
66
|
+
? Omit<T, 'id' | 'created' | 'updated'> & SavedDBEntity<NonNullable<T['id']>>
|
|
67
|
+
: T
|
|
68
68
|
|
|
69
|
-
export type Unsaved<T extends Partial<ObjectWithId>> =
|
|
70
|
-
BaseDBEntity<NonNullable<T['id']>>
|
|
69
|
+
export type Unsaved<T extends Partial<ObjectWithId>> = T extends AnyObject
|
|
70
|
+
? Omit<T, 'id' | 'created' | 'updated'> & BaseDBEntity<NonNullable<T['id']>>
|
|
71
|
+
: T
|
|
71
72
|
|
|
72
73
|
export type UnsavedId<T extends Partial<ObjectWithId>> = Omit<T, 'id'> & {
|
|
73
74
|
id?: T['id']
|
|
@@ -260,3 +261,11 @@ export type FalsyValue = false | '' | 0 | null | undefined
|
|
|
260
261
|
* }
|
|
261
262
|
*/
|
|
262
263
|
export function _typeCast<T>(v: any): asserts v is T {}
|
|
264
|
+
|
|
265
|
+
/**
|
|
266
|
+
* Type-safe Object.assign that checks that part is indeed a Partial<T>
|
|
267
|
+
*/
|
|
268
|
+
export const _objectAssign = Object.assign as <T extends AnyObject>(
|
|
269
|
+
target: T,
|
|
270
|
+
part: Partial<T>,
|
|
271
|
+
) => T
|