@sqb/connect
Advanced tools
Comparing version 4.0.1-beta.1 to 4.0.1-beta.2
@@ -6,3 +6,3 @@ import { Pool as LightningPool } from 'lightning-pool'; | ||
import { SafeEventEmitter } from '../SafeEventEmitter'; | ||
import { Constructor } from '../orm/types'; | ||
import { Type } from '../types'; | ||
import { Repository } from '../orm/repository'; | ||
@@ -51,4 +51,4 @@ import { Maybe } from '../types'; | ||
test(): Promise<void>; | ||
getRepository<T>(entity: Constructor<T> | string): Repository<T>; | ||
getEntity<T>(name: string): Maybe<Constructor<T>>; | ||
getRepository<T>(entity: Type<T> | string): Repository<T>; | ||
getEntity<T>(name: string): Maybe<Type<T>>; | ||
toString(): string; | ||
@@ -55,0 +55,0 @@ [inspect](): string; |
@@ -6,3 +6,3 @@ import { classes } from '@sqb/builder'; | ||
import { SafeEventEmitter } from '../SafeEventEmitter'; | ||
import { Constructor } from '../orm/types'; | ||
import { Type } from '../types'; | ||
import { Repository } from '../orm/repository'; | ||
@@ -45,3 +45,3 @@ export declare class SqbConnection extends SafeEventEmitter implements QueryExecutor { | ||
execute(query: string | classes.Query, options?: QueryExecuteOptions): Promise<any>; | ||
getRepository<T>(entity: Constructor<T> | string): Repository<T>; | ||
getRepository<T>(entity: Type<T> | string): Repository<T>; | ||
getSchema(): Promise<string>; | ||
@@ -48,0 +48,0 @@ setSchema(schema: string): Promise<void>; |
import { REPOSITORY_KEY } from './consts'; | ||
import { PickWritable, Type } from '../types'; | ||
export declare abstract class BaseEntity<T> { | ||
@@ -8,6 +9,6 @@ private [REPOSITORY_KEY]; | ||
toJSON(): any; | ||
static getElementNames<TT extends BaseEntity<any>, K extends keyof TT>(): K[]; | ||
static getDataColumnNames<TT extends BaseEntity<any>, K extends keyof TT>(): K[]; | ||
static getInsertColumnNames<TT extends BaseEntity<any>, K extends keyof TT>(): K[]; | ||
static getUpdateColumnNames<TT extends BaseEntity<any>, K extends keyof TT>(): K[]; | ||
} | ||
export declare function getElementNames<T, K extends keyof PickWritable<T>>(classRef: Type<T>): K[]; | ||
export declare function getDataColumnNames<T, K extends keyof PickWritable<T>>(classRef: Type<T>): K[]; | ||
export declare function getInsertColumnNames<T, K extends keyof PickWritable<T>>(classRef: Type<T>): K[]; | ||
export declare function getUpdateColumnNames<T, K extends keyof PickWritable<T>>(classRef: Type<T>): K[]; |
"use strict"; | ||
Object.defineProperty(exports, "__esModule", { value: true }); | ||
exports.BaseEntity = void 0; | ||
exports.getUpdateColumnNames = exports.getInsertColumnNames = exports.getDataColumnNames = exports.getElementNames = exports.BaseEntity = void 0; | ||
const consts_1 = require("./consts"); | ||
@@ -27,15 +27,19 @@ const entity_meta_1 = require("./metadata/entity-meta"); | ||
} | ||
static getElementNames() { | ||
return (entity_meta_1.EntityMeta.getElementNames(this) || []); | ||
} | ||
static getDataColumnNames() { | ||
return (entity_meta_1.EntityMeta.getDataColumnNames(this) || []); | ||
} | ||
static getInsertColumnNames() { | ||
return (entity_meta_1.EntityMeta.getInsertColumnNames(this) || []); | ||
} | ||
static getUpdateColumnNames() { | ||
return (entity_meta_1.EntityMeta.getUpdateColumnNames(this) || []); | ||
} | ||
} | ||
exports.BaseEntity = BaseEntity; | ||
function getElementNames(classRef) { | ||
return (entity_meta_1.EntityMeta.getElementNames(classRef) || []); | ||
} | ||
exports.getElementNames = getElementNames; | ||
function getDataColumnNames(classRef) { | ||
return (entity_meta_1.EntityMeta.getDataColumnNames(classRef) || []); | ||
} | ||
exports.getDataColumnNames = getDataColumnNames; | ||
function getInsertColumnNames(classRef) { | ||
return (entity_meta_1.EntityMeta.getInsertColumnNames(classRef) || []); | ||
} | ||
exports.getInsertColumnNames = getInsertColumnNames; | ||
function getUpdateColumnNames(classRef) { | ||
return (entity_meta_1.EntityMeta.getUpdateColumnNames(classRef) || []); | ||
} | ||
exports.getUpdateColumnNames = getUpdateColumnNames; |
import 'reflect-metadata'; | ||
import { EntityMeta } from './metadata/entity-meta'; | ||
import { Constructor, ConstructorThunk } from './types'; | ||
export declare function isClass(fn: any): fn is Constructor; | ||
export declare function isEntityClass(fn: any): fn is Constructor; | ||
export declare function resolveEntity(ctorThunk: ConstructorThunk): Promise<Constructor | undefined>; | ||
import { ConstructorThunk } from './types'; | ||
import { Type } from '../types'; | ||
export declare function isClass(fn: any): fn is Type; | ||
export declare function isEntityClass(fn: any): fn is Type; | ||
export declare function resolveEntity(ctorThunk: ConstructorThunk): Promise<Type | undefined>; | ||
export declare function resolveEntityMeta(ctorThunk: ConstructorThunk): Promise<EntityMeta | undefined>; |
import { RelationElementMeta } from './relation-element-meta'; | ||
import { Constructor, IndexOptions, ConstructorThunk, ForeignKeyOptions, RelationColumnOptions, DataColumnOptions } from '../types'; | ||
import { Maybe } from '../../types'; | ||
import { IndexOptions, ConstructorThunk, ForeignKeyOptions, RelationColumnOptions, DataColumnOptions } from '../types'; | ||
import { Maybe, Type } from '../../types'; | ||
import { IndexMeta } from './index-meta'; | ||
@@ -37,4 +37,4 @@ import { ForeignKeyMeta } from './foreign-key-meta'; | ||
addForeignKey(target: ConstructorThunk, keyColumn: string, options?: ForeignKeyOptions): void; | ||
before(event: 'insert' | 'update' | 'destroy', fn: Constructor): void; | ||
after(event: 'insert' | 'update' | 'destroy', fn: Constructor): void; | ||
before(event: 'insert' | 'update' | 'destroy', fn: Type): void; | ||
after(event: 'insert' | 'update' | 'destroy', fn: Type): void; | ||
getPrimaryIndexColumns(): DataColumnMeta[]; | ||
@@ -41,0 +41,0 @@ getDataColumnNames(): string[]; |
import type { EntityElementMeta } from './metadata/entity-element-meta'; | ||
import type { Repository } from './repository'; | ||
import { DataType } from '..'; | ||
import { DataType, Type } from '..'; | ||
export declare type ElementKind = 'data' | 'relation' | 'embedded'; | ||
@@ -10,7 +10,4 @@ /** | ||
export declare type ColumnTransformFunction = (value: any, col: EntityElementMeta, row: any) => any; | ||
export interface Constructor<T = {}> extends Function { | ||
new (...args: any[]): T; | ||
} | ||
export declare type ConstructorResolver<T> = () => Constructor<T> | Promise<Constructor<T>>; | ||
export declare type ConstructorThunk<T = {}> = Constructor<T> | ConstructorResolver<T>; | ||
export declare type ConstructorResolver<T> = () => Type<T> | Promise<Type<T>>; | ||
export declare type ConstructorThunk<T = {}> = Type<T> | ConstructorResolver<T>; | ||
export declare type LazyResolver<T> = (options?: Repository.FindAllOptions) => Promise<T>; | ||
@@ -17,0 +14,0 @@ export declare type EnumValue = (FieldValue)[] | Object; |
export declare type Maybe<T> = T | undefined; | ||
export interface Type<T = any> extends Function { | ||
new (...args: any[]): T; | ||
} | ||
declare type IfEquals<X, Y, A = X, B = never> = (<T>() => T extends X ? 1 : 2) extends (<T>() => T extends Y ? 1 : 2) ? A : B; | ||
export declare type WritableKeys<T> = { | ||
export declare type NonFunctionKeys<T> = { | ||
[K in keyof T]-?: T[K] extends Function ? never : K; | ||
}[keyof T]; | ||
export declare type NonReadonlyKeys<T> = { | ||
[P in keyof T]-?: IfEquals<{ | ||
@@ -17,4 +23,5 @@ [Q in P]: T[P]; | ||
}[keyof T]; | ||
export declare type WritableKeys<T> = Exclude<NonFunctionKeys<T>, ReadonlyKeys<T>>; | ||
export declare type PickWritable<T> = Pick<T, WritableKeys<T>>; | ||
export declare type PartialWritable<T> = Partial<PickWritable<T>>; | ||
export {}; |
{ | ||
"name": "@sqb/connect", | ||
"description": "Multi-dialect database connection framework written with TypeScript", | ||
"version": "4.0.1-beta.1", | ||
"version": "4.0.1-beta.2", | ||
"author": "Panates Ltd.", | ||
@@ -47,3 +47,3 @@ "contributors": [ | ||
"peerDependencies": { | ||
"@sqb/builder": "^4.0.1-beta.1" | ||
"@sqb/builder": "^4.0.1-beta.2" | ||
}, | ||
@@ -50,0 +50,0 @@ "main": "dist/index.js", |
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
177110
4279