Comparing version 0.0.52 to 0.0.53
@@ -24,3 +24,3 @@ export declare const actions: unique symbol; | ||
} | ||
export declare type ForeignKeyActions = "cascade" | "no action" | "restrict" | "set default" | "set null"; | ||
export type ForeignKeyActions = "cascade" | "no action" | "restrict" | "set default" | "set null"; | ||
export interface ForeignKeyOptions { | ||
@@ -27,0 +27,0 @@ onDelete?: ForeignKeyActions; |
import { Attribute, DB, EntryBase, ForeignKeyOptions, Transaction, Type } from "./db"; | ||
export { Action, Attribute, base, DB, deepCopy, deepDiff, EntryBase, ForeignKeyActions, ForeignKeyOptions, Index, loaded, size, Table, Transaction, transaction, Type } from "./db"; | ||
export declare type TypeDefinition<T, E> = (() => Type<T, E>) | Type<T, E>; | ||
export type TypeDefinition<T, E> = (() => Type<T, E>) | Type<T, E>; | ||
export interface AttributeOptions<T, E> { | ||
@@ -11,4 +11,4 @@ defaultValue?: T; | ||
} | ||
export declare type AttributeDefinition<T, E> = TypeDefinition<T, E> | AttributeOptions<T, E>; | ||
export declare type AttributesDefinition = { | ||
export type AttributeDefinition<T, E> = TypeDefinition<T, E> | AttributeOptions<T, E>; | ||
export type AttributesDefinition = { | ||
[key: string]: AttributeDefinition<unknown, unknown>; | ||
@@ -18,13 +18,13 @@ }; | ||
declare const methods: unique symbol; | ||
declare type ForeignKeysAttributes<T, k> = T extends AttributeDefinition<unknown, infer E> ? (E extends EntryBase ? k : never) : never; | ||
declare type ForeignKeys<A extends AttributesDefinition> = { | ||
type ForeignKeysAttributes<T, k> = T extends AttributeDefinition<unknown, infer E> ? (E extends EntryBase ? k : never) : never; | ||
type ForeignKeys<A extends AttributesDefinition> = { | ||
[a in keyof A]?: ForeignKeysAttributes<A[a], a>; | ||
}[keyof A]; | ||
declare type Native___<T> = T extends Type<infer N, unknown> ? N : never; | ||
declare type Native__<T> = T extends () => Type<infer N, infer E> ? Native___<Type<N, E>> : Native___<T>; | ||
declare type Native_<T, N, E> = T extends { | ||
type Native___<T> = T extends Type<infer N, unknown> ? N : never; | ||
type Native__<T> = T extends () => Type<infer N, infer E> ? Native___<Type<N, E>> : Native___<T>; | ||
type Native_<T, N, E> = T extends { | ||
notNull: true; | ||
} ? Native___<Type<N, E>> : Native___<Type<N, E>> | null; | ||
declare type Native<T> = T extends AttributeOptions<infer N, infer E> ? Native_<T, N, E> : Native__<T> | null; | ||
export declare type IndexAttributes = string[] | string; | ||
type Native<T> = T extends AttributeOptions<infer N, infer E> ? Native_<T, N, E> : Native__<T> | null; | ||
export type IndexAttributes = string[] | string; | ||
export interface IndexOptions { | ||
@@ -35,4 +35,4 @@ attributes: IndexAttributes; | ||
} | ||
export declare type IndexDefinition = IndexAttributes | IndexOptions; | ||
export declare type IndexesDefinition = { | ||
export type IndexDefinition = IndexAttributes | IndexOptions; | ||
export type IndexesDefinition = { | ||
[key: string]: IndexDefinition; | ||
@@ -50,24 +50,24 @@ }; | ||
} | ||
declare type ConditionAttribute<T> = T | ["=" | ">" | "<" | ">=" | "<=" | "<>", T] | ["IN", T[]] | ["IS NULL"] | ["LIKE", string] | ["NOT"]; | ||
declare type ConditionBase<A extends AttributesDefinition> = string | { | ||
type ConditionAttribute<T> = T | ["=" | ">" | "<" | ">=" | "<=" | "<>", T] | ["IN", T[]] | ["IS NULL"] | ["LIKE", string] | ["NOT"]; | ||
type ConditionBase<A extends AttributesDefinition> = string | { | ||
[a in keyof A]?: ConditionAttribute<Native<A[a]>>; | ||
}; | ||
declare type Condition<A extends AttributesDefinition> = ConditionBase<A> | ["NOT", Condition<A>] | ["AND", ...Condition<A>[]] | ["OR", ...Condition<A>[]]; | ||
declare type Order_<A extends AttributesDefinition> = keyof A | `-${string & keyof A}`; | ||
declare type Order<A extends AttributesDefinition> = Order_<A> | Order_<A>[]; | ||
declare type UnionToIntersection<U> = (U extends unknown ? (k: U) => void : never) extends (k: infer I) => void ? I : never; | ||
declare type IsUnion<T> = [T] extends [UnionToIntersection<T>] ? false : true; | ||
declare type BaseKeyType<B extends boolean> = IsUnion<B> extends true ? number : B extends true ? string : number; | ||
declare type KeyType<B extends boolean, P extends ModelStd> = P extends new () => EntryBase ? (P extends Attribute<infer T, EntryBase> ? T : never) : BaseKeyType<B>; | ||
declare type ForeignKey<A> = A extends AttributeDefinition<unknown, infer E> ? () => Promise<E> : never; | ||
declare type EntryBaseAttributes<A extends AttributesDefinition> = { | ||
type Condition<A extends AttributesDefinition> = ConditionBase<A> | ["NOT", Condition<A>] | ["AND", ...Condition<A>[]] | ["OR", ...Condition<A>[]]; | ||
type Order_<A extends AttributesDefinition> = keyof A | `-${string & keyof A}`; | ||
type Order<A extends AttributesDefinition> = Order_<A> | Order_<A>[]; | ||
type UnionToIntersection<U> = (U extends unknown ? (k: U) => void : never) extends (k: infer I) => void ? I : never; | ||
type IsUnion<T> = [T] extends [UnionToIntersection<T>] ? false : true; | ||
type BaseKeyType<B extends boolean> = IsUnion<B> extends true ? number : B extends true ? string : number; | ||
type KeyType<B extends boolean, P extends ModelStd> = P extends new () => EntryBase ? (P extends Attribute<infer T, EntryBase> ? T : never) : BaseKeyType<B>; | ||
type ForeignKey<A> = A extends AttributeDefinition<unknown, infer E> ? () => Promise<E> : never; | ||
type EntryBaseAttributes<A extends AttributesDefinition> = { | ||
[a in keyof A]: Native<A[a]>; | ||
}; | ||
declare type EntryMethodsBase<P extends ModelStd> = P extends new () => EntryBase ? P[typeof methods] : EntryBase; | ||
declare type EntryMethodsFK<A extends AttributesDefinition> = { | ||
type EntryMethodsBase<P extends ModelStd> = P extends new () => EntryBase ? P[typeof methods] : EntryBase; | ||
type EntryMethodsFK<A extends AttributesDefinition> = { | ||
[a in ForeignKeys<A> & string as `${a}Load`]: ForeignKey<A[a]>; | ||
}; | ||
declare type EntryMethods<A extends AttributesDefinition, P extends ModelStd> = keyof EntryMethodsFK<A> extends never ? EntryMethodsBase<P> : EntryMethodsBase<P> & EntryMethodsFK<A>; | ||
declare type ModelAttributesIf<A extends AttributesDefinition, T> = keyof A extends never ? T : T & A; | ||
declare type ModelAttributes<A extends AttributesDefinition, B extends boolean, K extends string, P extends ModelStd> = K extends keyof A ? A : ModelAttributesIf<A, P extends new () => EntryBase ? P[typeof attributes] : { | ||
type EntryMethods<A extends AttributesDefinition, P extends ModelStd> = keyof EntryMethodsFK<A> extends never ? EntryMethodsBase<P> : EntryMethodsBase<P> & EntryMethodsFK<A>; | ||
type ModelAttributesIf<A extends AttributesDefinition, T> = keyof A extends never ? T : T & A; | ||
type ModelAttributes<A extends AttributesDefinition, B extends boolean, K extends string, P extends ModelStd> = K extends keyof A ? A : ModelAttributesIf<A, P extends new () => EntryBase ? P[typeof attributes] : { | ||
id: { | ||
@@ -85,3 +85,3 @@ notNull: true; | ||
} | ||
declare type ModelBase<T, A extends AttributesDefinition, EA extends Record<string, unknown>, EM extends EntryBase, E extends EntryBase> = (new (from?: Partial<EA>, tx?: Transaction) => E) & Attribute<T, E> & { | ||
type ModelBase<T, A extends AttributesDefinition, EA extends Record<string, unknown>, EM extends EntryBase, E extends EntryBase> = (new (from?: Partial<EA>, tx?: Transaction) => E) & Attribute<T, E> & { | ||
[attributes]: A; | ||
@@ -95,4 +95,4 @@ foreignKeys: Record<string, boolean>; | ||
} & ModelLoad<A, E>; | ||
declare type Model<T, A extends AttributesDefinition, EM extends EntryBase> = ModelBase<T, A, EntryBaseAttributes<A>, EM, EntryBaseAttributes<A> & EM>; | ||
declare type ModelStd = Attribute<unknown, EntryBase> & { | ||
type Model<T, A extends AttributesDefinition, EM extends EntryBase> = ModelBase<T, A, EntryBaseAttributes<A>, EM, EntryBaseAttributes<A> & EM>; | ||
type ModelStd = Attribute<unknown, EntryBase> & { | ||
[attributes]: AttributesDefinition; | ||
@@ -103,4 +103,4 @@ foreignKeys: Record<string, boolean>; | ||
}; | ||
export declare type Entry<M> = M extends new () => infer E ? E : never; | ||
export declare type OrderBy<M> = M extends { | ||
export type Entry<M> = M extends new () => infer E ? E : never; | ||
export type OrderBy<M> = M extends { | ||
load(where: unknown, order?: infer T): void; | ||
@@ -110,3 +110,3 @@ load(where: unknown, limit?: number): void; | ||
} ? Exclude<T, undefined> : never; | ||
export declare type Where<M> = M extends { | ||
export type Where<M> = M extends { | ||
load(where: infer T): void; | ||
@@ -113,0 +113,0 @@ } ? T : never; |
@@ -61,3 +61,3 @@ { | ||
"types": "./dist/types/index.d.ts", | ||
"version": "0.0.52" | ||
"version": "0.0.53" | ||
} |
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
92455