@tstdl/base 0.90.89 → 0.90.90
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.
|
@@ -4,7 +4,7 @@ import type { ObjectSchemaOrType } from '../../schema/types/types.js';
|
|
|
4
4
|
import type { Record } from '../../types.js';
|
|
5
5
|
import type { AuthenticationApiDefinition } from '../authentication.api.js';
|
|
6
6
|
export declare function getAuthenticationApiClient<AdditionalTokenPayload extends Record, AuthenticationData, AdditionalInitSecretResetData extends Record>(additionalTokenPayloadSchema: ObjectSchemaOrType<AdditionalTokenPayload>, authenticationDataSchema: SchemaTestable<AuthenticationData>, additionalInitSecretResetData: ObjectSchemaOrType<AdditionalInitSecretResetData>): ApiClient<AuthenticationApiDefinition<AdditionalTokenPayload, AuthenticationData, AdditionalInitSecretResetData>>;
|
|
7
|
-
declare const defaultAuthenticationApiClient: ApiClient<AuthenticationApiDefinition<
|
|
7
|
+
declare const defaultAuthenticationApiClient: ApiClient<AuthenticationApiDefinition<import("../../types.js").ObjectLiteral, unknown, import("../../types.js").ObjectLiteral>>;
|
|
8
8
|
export declare class AuthenticationApiClient extends defaultAuthenticationApiClient {
|
|
9
9
|
}
|
|
10
10
|
export {};
|
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
import { EntityRepository } from '../../database/index.js';
|
|
2
2
|
import { afterResolve } from '../../injector/index.js';
|
|
3
3
|
import { equals } from '../../utils/equals.js';
|
|
4
|
-
import {
|
|
4
|
+
import { filterUndefinedObjectProperties, objectEntries, objectKeys } from '../../utils/object/object.js';
|
|
5
5
|
import { _throw } from '../../utils/throw.js';
|
|
6
6
|
import { isDefined, isUndefined } from '../../utils/type-guards.js';
|
|
7
7
|
import { MongoBaseRepository } from './mongo-base.repository.js';
|
|
@@ -263,7 +263,7 @@ export class MongoEntityRepository extends EntityRepository {
|
|
|
263
263
|
function normalizeIndex(index) {
|
|
264
264
|
const { name: providedName, unique, v, background, ns, ...indexRest } = index; // eslint-disable-line @typescript-eslint/no-unused-vars
|
|
265
265
|
const name = providedName ?? objectKeys(index.key).join('_');
|
|
266
|
-
return
|
|
266
|
+
return filterUndefinedObjectProperties({ name, unique: (unique == true) ? true : undefined, ...indexRest });
|
|
267
267
|
}
|
|
268
268
|
function convertOptions(options, mappingMap) {
|
|
269
269
|
if (options == undefined) {
|
package/package.json
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
|
-
import type {
|
|
1
|
+
import type { ObjectLiteral, Optionalize, Record, SimplifyObject, TypedOmit } from '../../types.js';
|
|
2
2
|
import type { IfNever } from 'type-fest';
|
|
3
|
-
import type
|
|
3
|
+
import { type ObjectSchema, type ObjectSchemaProperties, type TypedObjectSchemaUnknownProperties } from '../types/index.js';
|
|
4
4
|
export type ObjectOptions<T extends Record = Record> = TypedOmit<ObjectSchema<T>, 'properties' | 'unknownProperties' | 'unknownPropertiesKey'>;
|
|
5
5
|
export declare function explicitObject<T extends Record>(properties: ObjectSchemaProperties<T>, options?: ObjectOptions<T>): ObjectSchema<T>;
|
|
6
|
-
export declare function object<T extends Record = Record<never>, K extends PropertyKey = any, V = never>(properties: ObjectSchemaProperties<T>, options?: ObjectOptions<T> & TypedObjectSchemaUnknownProperties<K, V>): ObjectSchema<SimplifyObject<
|
|
7
|
-
export declare const emptyObjectSchema: ObjectSchema<
|
|
6
|
+
export declare function object<T extends Record = Record<never>, K extends PropertyKey = any, V = never>(properties: ObjectSchemaProperties<T>, options?: ObjectOptions<T> & TypedObjectSchemaUnknownProperties<K, V>): ObjectSchema<SimplifyObject<Optionalize<T> & IfNever<V, ObjectLiteral, Record<K, V>>>>;
|
|
7
|
+
export declare const emptyObjectSchema: ObjectSchema<ObjectLiteral>;
|
package/types.d.ts
CHANGED
|
@@ -103,6 +103,7 @@ export type ReplaceIfUnknown<T, U> = IfUnknown<T, U, T>;
|
|
|
103
103
|
export type OmitNever<T extends Record> = {
|
|
104
104
|
[K in keyof T as T[K] extends never ? never : K]: T[K];
|
|
105
105
|
};
|
|
106
|
+
export type BaseType<T extends Exclude<Primitive, null | undefined>> = T extends string ? string : never | T extends number ? number : never | T extends boolean ? boolean : never | T extends bigint ? bigint : never | T extends symbol ? symbol : never;
|
|
106
107
|
export type SharedProperties<A, B, C = unknown, D = unknown, E = unknown, F = unknown, G = unknown, H = unknown, I = unknown, J = unknown> = OmitNever<Pick<A & B & C & D & E & F & G & H & I & J, keyof A & keyof B & keyof ReplaceIfUnknown<C, never> & keyof ReplaceIfUnknown<D, never> & keyof ReplaceIfUnknown<E, never> & keyof ReplaceIfUnknown<F, never> & keyof ReplaceIfUnknown<G, never> & keyof ReplaceIfUnknown<H, never> & keyof ReplaceIfUnknown<I, never> & keyof ReplaceIfUnknown<J, never>>>;
|
|
107
108
|
/**
|
|
108
109
|
* Omit properties from a type that extend from a specific type.
|
|
@@ -114,7 +115,6 @@ export type OmitBy<T, V> = Omit<T, {
|
|
|
114
115
|
* Normalize properties of a type that allow `undefined` to make them optional.
|
|
115
116
|
*/
|
|
116
117
|
export type Optionalize<T extends object> = OmitBy<T, undefined> & Partial<PickBy<T, undefined>>;
|
|
117
|
-
export type SimplifiedOptionalize<T extends object> = SimplifyObject<Optionalize<T>>;
|
|
118
118
|
export type Unoptionalize<T extends object> = SimplifyObject<OmitBy<T, undefined> & {
|
|
119
119
|
[P in PropertiesOfType<T, undefined>]: T[P] | undefined;
|
|
120
120
|
}>;
|
package/utils/object/object.d.ts
CHANGED
|
@@ -1,5 +1,4 @@
|
|
|
1
|
-
import type { FromEntries, ObjectLiteral, PickBy, Record, SimplifyObject } from '../../types.js';
|
|
2
|
-
import type { IsEqual } from 'type-fest';
|
|
1
|
+
import type { BaseType, FromEntries, ObjectLiteral, Optionalize, PickBy, Record, SimplifyObject } from '../../types.js';
|
|
3
2
|
export declare function hasOwnProperty<T extends Record>(obj: T, key: keyof T): boolean;
|
|
4
3
|
/**
|
|
5
4
|
* Returns object entries including those with symbols keys (which Object.entries does not)
|
|
@@ -19,10 +18,8 @@ export declare function mapObjectValuesAsync<T extends ObjectLiteral, V>(object:
|
|
|
19
18
|
export declare function filterObject<T extends ObjectLiteral, U extends T[keyof T]>(object: T, predicate: (value: T[keyof T], key: keyof T) => value is U): PickBy<T, U>;
|
|
20
19
|
export declare function filterObject<T extends ObjectLiteral>(object: T, predicate: (value: T[keyof T], key: keyof T) => boolean): Partial<T>;
|
|
21
20
|
export declare function filterObjectAsync<T extends ObjectLiteral>(object: T, predicate: (value: T[keyof T], key: keyof T) => Promise<boolean>): Promise<Partial<T>>;
|
|
22
|
-
export declare function filterUndefinedFromRecord<
|
|
23
|
-
export declare function filterUndefinedObjectProperties<T extends ObjectLiteral>(object: T):
|
|
24
|
-
[P in keyof T]?: IsEqual<T[P], undefined> extends true ? never : Exclude<T[P], undefined>;
|
|
25
|
-
};
|
|
21
|
+
export declare function filterUndefinedFromRecord<K extends PropertyKey, V>(record: Record<K, V>): Record<BaseType<K>, Exclude<V, undefined>>;
|
|
22
|
+
export declare function filterUndefinedObjectProperties<T extends ObjectLiteral>(object: T): SimplifyObject<Optionalize<T>>;
|
|
26
23
|
export declare function copyObjectProperties<T extends ObjectLiteral, U extends T>(source: T, target: U): void;
|
|
27
24
|
export declare function getGetter<T extends ObjectLiteral, U extends keyof T>(obj: T, property: keyof T, bind: boolean): () => T[U];
|
|
28
25
|
export declare function deepObjectEntries(object: ObjectLiteral, keepInnerObjects?: boolean, prefix?: string): [string, any][];
|