bigal 10.0.0-beta2 → 10.0.0-beta3

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/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "bigal",
3
- "version": "10.0.0-beta2",
3
+ "version": "10.0.0-beta3",
4
4
  "description": "A fast and lightweight orm for postgres and node.js, written in typescript.",
5
5
  "main": "index.js",
6
6
  "types": "index.d.ts",
@@ -58,6 +58,7 @@
58
58
  "typescript": "^4.5.4"
59
59
  },
60
60
  "scripts": {
61
+ "check:types": "tsc -p tsconfig.lint.json --noEmit",
61
62
  "prebuild": "rimraf dist",
62
63
  "build": "tsc",
63
64
  "test": "mocha -r ts-node/register tests/**/*.tests.ts",
@@ -1,24 +1,23 @@
1
1
  import type { Entity, NotEntityBrand } from '../Entity';
2
- import type { EntityPrimitiveOrId, ExcludeEntityCollections, ExcludeFunctions } from '../types';
3
- export declare type WhereClauseValue<TValue> = TValue extends NotEntityBrand | undefined ? Exclude<TValue, undefined> : TValue extends Entity ? {
4
- id: unknown;
5
- }[] | Exclude<EntityPrimitiveOrId<TValue>, undefined> | Exclude<EntityPrimitiveOrId<TValue>, undefined>[] | {
6
- id: unknown;
7
- } | null : Exclude<(TValue | null)[] | TValue, undefined> | null;
2
+ import type { ExcludeEntityCollections, ExcludeFunctions } from '../types';
3
+ declare type ExcludeUndefined<T> = Exclude<T, undefined>;
4
+ export declare type LiteralValues<TValue> = (ExcludeUndefined<TValue> | null)[] | ExcludeUndefined<TValue> | null;
5
+ export declare type WhereClauseValue<TValue> = TValue extends NotEntityBrand | undefined ? Exclude<TValue, undefined> : Extract<ExcludeUndefined<TValue>, Entity> extends Entity ? (ExcludeUndefined<Exclude<TValue, Entity>> | null)[] | (Pick<Extract<ExcludeUndefined<TValue>, Entity>, 'id'> | null)[] | ExcludeUndefined<Exclude<TValue, Entity>> | Pick<Extract<ExcludeUndefined<TValue>, Entity>, 'id'> | null : LiteralValues<TValue>;
8
6
  export declare type StringConstraint<TValue extends string> = {
9
- [P in 'contains' | 'endsWith' | 'like' | 'startsWith']?: WhereClauseValue<TValue>;
7
+ [P in 'contains' | 'endsWith' | 'like' | 'startsWith']?: LiteralValues<TValue>;
10
8
  };
11
9
  export declare type NumberOrDateConstraint<TValue extends Date | number> = {
12
- [P in '<' | '<=' | '>' | '>=']?: WhereClauseValue<TValue>;
10
+ [P in '<' | '<=' | '>' | '>=']?: LiteralValues<TValue>;
13
11
  };
14
12
  export declare type NegatableConstraint<TValue> = TValue | {
15
13
  '!': TValue;
16
14
  };
17
15
  export declare type WhereQueryStatement<TValue> = TValue extends string ? NegatableConstraint<StringConstraint<TValue> | WhereClauseValue<TValue>> : TValue extends Date | number ? NegatableConstraint<NumberOrDateConstraint<TValue> | WhereClauseValue<TValue>> : NegatableConstraint<WhereClauseValue<TValue>>;
18
16
  export declare type WhereQuery<T extends Entity> = {
19
- [K in keyof T as ExcludeEntityCollections<T[K], ExcludeFunctions<T[K], K>>]?: K extends 'id' ? WhereQueryStatement<T | T[K]> : T[K] extends (infer U)[] | undefined ? WhereQueryStatement<U> : Exclude<(T[K] | null)[] | T[K], undefined> | WhereQueryStatement<T[K]> | {
20
- '!': Exclude<(T[K] | null)[] | T[K], undefined>;
17
+ [K in keyof T as ExcludeEntityCollections<T[K], ExcludeFunctions<T[K], K>>]?: K extends 'id' ? WhereQueryStatement<T | T[K]> : T[K] extends (infer U)[] | undefined ? WhereQueryStatement<U> : (ExcludeUndefined<T[K]> | null)[] | T[K] | WhereQueryStatement<T[K]> | {
18
+ '!': LiteralValues<T[K]>;
21
19
  };
22
20
  } & {
23
21
  or?: WhereQuery<T>[];
24
22
  };
23
+ export {};
@@ -1,12 +1,9 @@
1
1
  import type { Entity, NotEntityBrand } from '../Entity';
2
- import type { EntityPrimitiveOrId } from './EntityPrimitiveOrId';
3
2
  import type { ExcludeEntityCollections } from './ExcludeEntityCollections';
4
3
  import type { ExcludeFunctions } from './ExcludeFunctions';
5
4
  /**
6
5
  * Changes all Entity value properties to Primitive (string|number) | Pick<Entity, 'id'>
7
6
  */
8
7
  export declare type CreateUpdateParams<T extends Entity> = {
9
- [K in keyof T as ExcludeEntityCollections<NonNullable<T[K]>, ExcludeFunctions<T[K], K>>]?: T[K] extends NotEntityBrand | undefined ? T[K] : T[K] extends Entity ? EntityPrimitiveOrId<T[K]> | {
10
- id: unknown;
11
- } : T[K];
8
+ [K in keyof T as ExcludeEntityCollections<NonNullable<T[K]>, ExcludeFunctions<T[K], K>>]?: T[K] extends NotEntityBrand | undefined ? T[K] : Extract<T[K], Entity> extends Entity ? Exclude<T[K], Entity> | Pick<Extract<T[K], Entity>, 'id'> : T[K];
12
9
  };
@@ -1,2 +1,2 @@
1
1
  import type { Entity } from '../Entity';
2
- export declare type EntityPrimitiveOrId<T extends Entity, TIdKey extends keyof T = 'id'> = T extends Entity ? Exclude<T, Entity> | Pick<T, TIdKey> : T;
2
+ export declare type EntityPrimitiveOrId<T extends Entity> = Extract<NonNullable<T>, Entity> extends Entity ? Exclude<NonNullable<T>, Entity> | Pick<T, 'id'> : T;