@karmaniverous/entity-tools
Advanced tools
Comparing version 0.6.7 to 0.6.8
@@ -6,2 +6,3 @@ 'use strict'; | ||
var sort = require('./sort.js'); | ||
var updateRecord = require('./updateRecord.js'); | ||
@@ -13,1 +14,2 @@ | ||
exports.sort = sort.sort; | ||
exports.updateRecord = updateRecord.updateRecord; |
@@ -174,4 +174,6 @@ /** | ||
/** | ||
* The base Entity type: string keys with an `unknown` value. All Entities should extend this type. | ||
* The base Entity type. Supports string keys with any value. Derived types will accept unspecified string keys. All Entities should extend this type. | ||
* | ||
* NOTE: This type is essential to support document databases that can accept unknown keys. It does NOT play well with the {@link Omit | `Omit`} utility type! Use {@link MakeOptional | `MakeOptional`} instead. | ||
* | ||
* @category Entities | ||
@@ -261,3 +263,3 @@ */ | ||
*/ | ||
type MakeUpdatable<T extends object, U extends keyof T> = { | ||
type MakeUpdatable<T extends object, U extends keyof T = never> = { | ||
[P in keyof T as P extends U ? never : P]+?: undefined extends T[P] ? T[P] | null : T[P]; | ||
@@ -455,2 +457,21 @@ } & Required<Pick<T, U>>; | ||
/** | ||
* Creates a shallow update of `record` with the properties of `update` according to the following conventions: | ||
* | ||
* * `record` and `update` must be compatible types. | ||
* * `undefined` properties in `update` are ignored. | ||
* * `null` properties in `update` are assigned to `record`. | ||
* * All `undefined` and `null` properties in the resulting update are removed. | ||
* | ||
* Does not mutate `record` or `update`. | ||
* | ||
* @param record - The record to update. | ||
* @param update - A compatible record with properties to update. | ||
* | ||
* @returns A shallow copy of `record` merged with the properties of `update`. | ||
* | ||
* @category Entities | ||
*/ | ||
declare const updateRecord: <T extends object>(record: T, update: MakeUpdatable<T>) => T; | ||
/** | ||
* Returns an object type with specific properties rendered required and non-nullable. | ||
@@ -467,2 +488,2 @@ * | ||
export { type AllDisjoint, type ConditionalProperty, type DefaultTranscodeMap, type Entity, type EntityKeys, type EntityMap, type EntityMapValues, type EntityValue, type Exactify, type FlattenEntityMap, type MakeOptional, type MakeRequired, type MakeUpdatable, type MutuallyExclusive, type Nil, type NotNever, type PropertiesNotOfType, type PropertiesOfType, type ReplaceKey, type ReplaceKeys, type SortOrder, type TranscodableProperties, type TranscodeMap, type Transcodes, type UntranscodableProperties, type WithRequiredAndNonNullable, conditionalize, defaultTranscodes, isNil, sort }; | ||
export { type AllDisjoint, type ConditionalProperty, type DefaultTranscodeMap, type Entity, type EntityKeys, type EntityMap, type EntityMapValues, type EntityValue, type Exactify, type FlattenEntityMap, type MakeOptional, type MakeRequired, type MakeUpdatable, type MutuallyExclusive, type Nil, type NotNever, type PropertiesNotOfType, type PropertiesOfType, type ReplaceKey, type ReplaceKeys, type SortOrder, type TranscodableProperties, type TranscodeMap, type Transcodes, type UntranscodableProperties, type WithRequiredAndNonNullable, conditionalize, defaultTranscodes, isNil, sort, updateRecord }; |
export { defaultTranscodes } from './defaultTranscodes.js'; | ||
export { isNil } from './Nil.js'; | ||
export { sort } from './sort.js'; | ||
export { updateRecord } from './updateRecord.js'; |
@@ -129,3 +129,3 @@ { | ||
"types": "dist/index.d.ts", | ||
"version": "0.6.7", | ||
"version": "0.6.8", | ||
"dependencies": { | ||
@@ -132,0 +132,0 @@ "radash": "^12.1.0" |
37167
13
874