@sqb/connect 4.9.0 → 4.10.0
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/cjs/client/cursor-stream.js +2 -5
- package/cjs/client/cursor.js +5 -12
- package/cjs/client/field-info-map.js +0 -2
- package/cjs/client/sqb-client.js +1 -4
- package/cjs/client/sqb-connection.js +3 -6
- package/cjs/orm/base-entity.js +0 -1
- package/cjs/orm/commands/find.command.js +7 -11
- package/cjs/orm/commands/row-converter.js +1 -4
- package/cjs/orm/decorators/entity.decorator.js +1 -1
- package/cjs/orm/model/association-field-metadata.js +1 -1
- package/cjs/orm/model/association-node.js +0 -3
- package/cjs/orm/model/association.js +0 -13
- package/cjs/orm/model/column-field-metadata.js +1 -1
- package/cjs/orm/model/embedded-field-metadata.js +1 -1
- package/cjs/orm/model/entity-metadata.js +1 -1
- package/cjs/orm/model/link-chain.js +0 -3
- package/cjs/orm/repository.class.js +0 -3
- package/esm/client/cursor-stream.js +2 -5
- package/esm/client/cursor.js +5 -12
- package/esm/client/field-info-map.js +0 -2
- package/esm/client/sqb-client.js +1 -4
- package/esm/client/sqb-connection.js +3 -6
- package/esm/orm/base-entity.js +0 -1
- package/esm/orm/commands/find.command.js +7 -11
- package/esm/orm/commands/row-converter.js +1 -4
- package/esm/orm/model/association-node.js +0 -3
- package/esm/orm/model/association.js +0 -13
- package/esm/orm/model/link-chain.js +0 -3
- package/esm/orm/repository.class.js +0 -3
- package/package.json +14 -20
- package/esm/client/adapter.d.ts +0 -57
- package/esm/client/cursor-stream.d.ts +0 -29
- package/esm/client/cursor.d.ts +0 -116
- package/esm/client/extensions.d.ts +0 -4
- package/esm/client/field-info-map.d.ts +0 -12
- package/esm/client/helpers.d.ts +0 -9
- package/esm/client/sqb-client.d.ts +0 -65
- package/esm/client/sqb-connection.d.ts +0 -74
- package/esm/client/types.d.ts +0 -181
- package/esm/index.d.ts +0 -34
- package/esm/orm/backward.d.ts +0 -13
- package/esm/orm/base-entity.d.ts +0 -8
- package/esm/orm/commands/command.helper.d.ts +0 -14
- package/esm/orm/commands/count.command.d.ts +0 -11
- package/esm/orm/commands/create.command.d.ts +0 -20
- package/esm/orm/commands/delete.command.d.ts +0 -11
- package/esm/orm/commands/find.command.d.ts +0 -44
- package/esm/orm/commands/row-converter.d.ts +0 -55
- package/esm/orm/commands/update.command.d.ts +0 -22
- package/esm/orm/decorators/column.decorator.d.ts +0 -4
- package/esm/orm/decorators/embedded.decorator.d.ts +0 -3
- package/esm/orm/decorators/entity.decorator.d.ts +0 -38
- package/esm/orm/decorators/events.decorator.d.ts +0 -6
- package/esm/orm/decorators/foreignkey.decorator.d.ts +0 -2
- package/esm/orm/decorators/index.decorator.d.ts +0 -3
- package/esm/orm/decorators/link.decorator.d.ts +0 -13
- package/esm/orm/decorators/primarykey.decorator.d.ts +0 -3
- package/esm/orm/decorators/transform.decorator.d.ts +0 -3
- package/esm/orm/model/association-field-metadata.d.ts +0 -12
- package/esm/orm/model/association-node.d.ts +0 -9
- package/esm/orm/model/association.d.ts +0 -27
- package/esm/orm/model/column-field-metadata.d.ts +0 -75
- package/esm/orm/model/embedded-field-metadata.d.ts +0 -14
- package/esm/orm/model/entity-metadata.d.ts +0 -50
- package/esm/orm/model/field-metadata.d.ts +0 -16
- package/esm/orm/model/index-metadata.d.ts +0 -18
- package/esm/orm/model/link-chain.d.ts +0 -13
- package/esm/orm/orm.const.d.ts +0 -2
- package/esm/orm/orm.type.d.ts +0 -20
- package/esm/orm/repository.class.d.ts +0 -140
- package/esm/orm/util/apply-mixins.d.ts +0 -1
- package/esm/orm/util/extract-keyvalues.d.ts +0 -2
- package/esm/orm/util/orm.helper.d.ts +0 -13
- package/esm/orm/util/serialize-field.d.ts +0 -2
- package/esm/types.d.ts +0 -12
|
@@ -1,55 +0,0 @@
|
|
|
1
|
-
import { Type } from 'ts-gems';
|
|
2
|
-
import { DataType } from '@sqb/builder';
|
|
3
|
-
import type { FieldInfoMap } from '../../client/field-info-map';
|
|
4
|
-
import { SqbConnection } from '../../client/sqb-connection.js';
|
|
5
|
-
import { ColumnTransformFunction } from '../orm.type.js';
|
|
6
|
-
import type { Repository } from '../repository.class.js';
|
|
7
|
-
import type { FindCommand } from './find.command.js';
|
|
8
|
-
export interface ValueProperty {
|
|
9
|
-
fieldAlias: string;
|
|
10
|
-
dataType?: DataType;
|
|
11
|
-
parse?: ColumnTransformFunction;
|
|
12
|
-
}
|
|
13
|
-
export interface ObjectProperty {
|
|
14
|
-
converter: RowConverter;
|
|
15
|
-
type: Type;
|
|
16
|
-
}
|
|
17
|
-
export interface NestedProperty {
|
|
18
|
-
converter: RowConverter;
|
|
19
|
-
type: Type;
|
|
20
|
-
parentField: string;
|
|
21
|
-
keyField: string;
|
|
22
|
-
findCommand: FindCommand;
|
|
23
|
-
sort?: string[];
|
|
24
|
-
paramValues: any[];
|
|
25
|
-
}
|
|
26
|
-
export declare class RowConverter {
|
|
27
|
-
resultType: Type;
|
|
28
|
-
parent?: RowConverter | undefined;
|
|
29
|
-
private _properties;
|
|
30
|
-
private _propertyKeys?;
|
|
31
|
-
constructor(resultType: Type, parent?: RowConverter | undefined);
|
|
32
|
-
addValueProperty(args: {
|
|
33
|
-
name: string;
|
|
34
|
-
fieldAlias: string;
|
|
35
|
-
dataType?: DataType;
|
|
36
|
-
parse?: ColumnTransformFunction;
|
|
37
|
-
}): ValueProperty;
|
|
38
|
-
addObjectProperty(args: {
|
|
39
|
-
name: string;
|
|
40
|
-
type: Type;
|
|
41
|
-
}): ObjectProperty;
|
|
42
|
-
addNestedProperty(args: {
|
|
43
|
-
name: string;
|
|
44
|
-
type: Type;
|
|
45
|
-
findCommand: FindCommand;
|
|
46
|
-
parentField: string;
|
|
47
|
-
keyField: string;
|
|
48
|
-
sort?: string[];
|
|
49
|
-
}): NestedProperty;
|
|
50
|
-
get keys(): string[];
|
|
51
|
-
transform(connection: SqbConnection, fields: FieldInfoMap, rows: any, onTransform?: Repository.TransformRowFunction): Promise<any[]>;
|
|
52
|
-
private _rowToObject;
|
|
53
|
-
private _iterateForNested;
|
|
54
|
-
private _checkCircularDep;
|
|
55
|
-
}
|
|
@@ -1,22 +0,0 @@
|
|
|
1
|
-
import { SqbConnection } from '../../client/sqb-connection.js';
|
|
2
|
-
import { EntityMetadata } from '../model/entity-metadata.js';
|
|
3
|
-
import { Repository } from '../repository.class.js';
|
|
4
|
-
export type UpdateCommandArgs = {
|
|
5
|
-
entity: EntityMetadata;
|
|
6
|
-
connection: SqbConnection;
|
|
7
|
-
values: any;
|
|
8
|
-
} & Repository.UpdateManyOptions;
|
|
9
|
-
type UpdateCommandContext = {
|
|
10
|
-
entity: EntityMetadata;
|
|
11
|
-
queryParams: any;
|
|
12
|
-
queryValues: any;
|
|
13
|
-
queryFilter: any[];
|
|
14
|
-
colCount: number;
|
|
15
|
-
};
|
|
16
|
-
export declare class UpdateCommand {
|
|
17
|
-
protected constructor();
|
|
18
|
-
static execute(args: UpdateCommandArgs): Promise<number>;
|
|
19
|
-
protected static _prepareFilter(ctx: UpdateCommandContext, filter: any): Promise<void>;
|
|
20
|
-
protected static _prepareParams(ctx: UpdateCommandContext, entity: EntityMetadata, values: any, prefix?: string, suffix?: string): Promise<void>;
|
|
21
|
-
}
|
|
22
|
-
export {};
|
|
@@ -1,38 +0,0 @@
|
|
|
1
|
-
import { Maybe, Type } from 'ts-gems';
|
|
2
|
-
import { AssociationFieldMetadata } from '../model/association-field-metadata.js';
|
|
3
|
-
import { ColumnFieldMetadata } from '../model/column-field-metadata.js';
|
|
4
|
-
import { EmbeddedFieldMetadata } from '../model/embedded-field-metadata.js';
|
|
5
|
-
import { AnyFieldMetadata, EntityMetadata, EntityOptions } from '../model/entity-metadata.js';
|
|
6
|
-
import { IndexMetadata } from '../model/index-metadata.js';
|
|
7
|
-
export declare function Entity(options?: EntityOptions | string): ClassDecorator;
|
|
8
|
-
export declare namespace Entity {
|
|
9
|
-
const getMetadata: typeof EntityMetadata.get;
|
|
10
|
-
const getOwnMetadata: typeof EntityMetadata.getOwn;
|
|
11
|
-
function getField<T>(ctor: Type<T>, key: keyof T | string): Maybe<AnyFieldMetadata>;
|
|
12
|
-
function getColumnField<T>(ctor: Type<T>, key: keyof T | string): Maybe<ColumnFieldMetadata>;
|
|
13
|
-
function getEmbeddedField<T>(ctor: Type<T>, key: keyof T | string): Maybe<EmbeddedFieldMetadata>;
|
|
14
|
-
function getAssociationField<T>(ctor: Type<T>, key: keyof T | string): Maybe<AssociationFieldMetadata>;
|
|
15
|
-
function getColumnFieldByFieldName(ctor: Type, fieldName: string): Maybe<ColumnFieldMetadata>;
|
|
16
|
-
function find(ctor: Type, predicate: (el: AnyFieldMetadata) => boolean): Maybe<AnyFieldMetadata>;
|
|
17
|
-
function getFieldNames(ctor: Type, filter?: (el: AnyFieldMetadata) => boolean): string[];
|
|
18
|
-
function getColumnFieldNames(ctor: Type): string[];
|
|
19
|
-
function getEmbeddedFieldNames(ctor: Type): string[];
|
|
20
|
-
function getAssociationFieldNames(ctor: Type): string[];
|
|
21
|
-
function getNonAssociationFieldNames(ctor: Type): string[];
|
|
22
|
-
function getInsertColumnNames(ctor: Type): string[];
|
|
23
|
-
function getUpdateColumnNames(ctor: Type): string[];
|
|
24
|
-
function getPrimaryIndex(ctor: Type): Maybe<IndexMetadata>;
|
|
25
|
-
function getPrimaryIndexColumns(ctor: Type): ColumnFieldMetadata[];
|
|
26
|
-
function mixin<A, B>(derivedCtor: Type<A>, baseB: Type<B>): Type<A & B>;
|
|
27
|
-
function mixin<A, B, C>(derivedCtor: Type<A>, baseB: Type<B>, baseC: Type<C>): Type<A & B & C>;
|
|
28
|
-
function mixin<A, B, C, D>(derivedCtor: Type<A>, baseB: Type<B>, baseC: Type<C>, baseD: Type<D>): Type<A & B & C & D>;
|
|
29
|
-
function mixin<A, B, C, D, E>(derivedCtor: Type<A>, baseB: Type<B>, baseC: Type<C>, baseD: Type<D>, baseE: Type<E>): Type<A & B & C & D & E>;
|
|
30
|
-
function mixin<A, B, C, D, E, F>(derivedCtor: Type<A>, baseB: Type<B>, baseC: Type<C>, baseD: Type<D>, baseE: Type<E>, baseF: Type<F>): Type<A & B & C & D & E & F>;
|
|
31
|
-
function Pick<T, K extends keyof T>(classRef: Type<T>, keys: readonly K[]): Type<Pick<T, typeof keys[number]>>;
|
|
32
|
-
function Omit<T, K extends keyof T>(classRef: Type<T>, keys: readonly K[]): Type<Omit<T, typeof keys[number]>>;
|
|
33
|
-
function Union<A, B>(baseA: Type<A>, baseB: Type<B>): Type<A & B>;
|
|
34
|
-
function Union<A, B, C>(baseA: Type<A>, baseB: Type<B>, baseC: Type<C>): Type<A & B & C>;
|
|
35
|
-
function Union<A, B, C, D>(baseA: Type<A>, baseB: Type<B>, baseC: Type<C>, baseD: Type<D>): Type<A & B & C & D>;
|
|
36
|
-
function Union<A, B, C, D, E>(baseA: Type<A>, baseB: Type<B>, baseC: Type<C>, baseD: Type<D>, baseE: Type<E>): Type<A & B & C & D & E>;
|
|
37
|
-
function Union<A, B, C, D, E, F>(baseA: Type<A>, baseB: Type<B>, baseC: Type<C>, baseD: Type<D>, baseE: Type<E>, baseF: Type<F>): Type<A & B & C & D & E & F>;
|
|
38
|
-
}
|
|
@@ -1,6 +0,0 @@
|
|
|
1
|
-
export declare function BeforeInsert(): PropertyDecorator;
|
|
2
|
-
export declare function BeforeUpdate(): PropertyDecorator;
|
|
3
|
-
export declare function BeforeDestroy(): PropertyDecorator;
|
|
4
|
-
export declare function AfterInsert(): PropertyDecorator;
|
|
5
|
-
export declare function AfterUpdate(): PropertyDecorator;
|
|
6
|
-
export declare function AfterDestroy(): PropertyDecorator;
|
|
@@ -1,13 +0,0 @@
|
|
|
1
|
-
import { AssociationFieldOptions } from '../model/association-field-metadata.js';
|
|
2
|
-
import { TypeThunk } from '../orm.type.js';
|
|
3
|
-
type LinkArgs<T> = {
|
|
4
|
-
sourceKey?: string;
|
|
5
|
-
targetKey?: keyof T;
|
|
6
|
-
where?: object | object[];
|
|
7
|
-
};
|
|
8
|
-
type LinkPropertyDecorator = PropertyDecorator & {
|
|
9
|
-
toOne<T>(type: TypeThunk<T>, args?: LinkArgs<T>): LinkPropertyDecorator;
|
|
10
|
-
toMany<T>(type: TypeThunk<T>, args?: LinkArgs<T>): LinkPropertyDecorator;
|
|
11
|
-
};
|
|
12
|
-
export declare function Link(options?: AssociationFieldOptions): LinkPropertyDecorator;
|
|
13
|
-
export {};
|
|
@@ -1,3 +0,0 @@
|
|
|
1
|
-
import { IndexMetadata } from '../model/index-metadata.js';
|
|
2
|
-
export declare function PrimaryKey(fields: string | string[], options?: Omit<IndexMetadata, 'columns' | 'unique' | 'primary'>): ClassDecorator;
|
|
3
|
-
export declare function PrimaryKey(options?: Omit<IndexMetadata, 'columns' | 'unique' | 'primary'>): PropertyDecorator;
|
|
@@ -1,12 +0,0 @@
|
|
|
1
|
-
import { AssociationNode } from './association-node.js';
|
|
2
|
-
import { EntityMetadata } from './entity-metadata.js';
|
|
3
|
-
import { FieldMetadata } from './field-metadata.js';
|
|
4
|
-
export type AssociationFieldOptions = Partial<Omit<AssociationFieldMetadata, 'entity' | 'name' | 'kind' | 'association'>>;
|
|
5
|
-
export interface AssociationFieldMetadata extends FieldMetadata {
|
|
6
|
-
readonly kind: 'association';
|
|
7
|
-
readonly association: AssociationNode;
|
|
8
|
-
}
|
|
9
|
-
export declare namespace AssociationFieldMetadata {
|
|
10
|
-
function create(entity: EntityMetadata, name: string, association: AssociationNode, options?: AssociationFieldOptions): AssociationFieldMetadata;
|
|
11
|
-
function assign(target: AssociationFieldMetadata, options: AssociationFieldOptions): void;
|
|
12
|
-
}
|
|
@@ -1,9 +0,0 @@
|
|
|
1
|
-
import { Association } from './association.js';
|
|
2
|
-
export declare class AssociationNode extends Association {
|
|
3
|
-
prior?: AssociationNode;
|
|
4
|
-
next?: AssociationNode;
|
|
5
|
-
conditions?: any[];
|
|
6
|
-
getFirst(): AssociationNode;
|
|
7
|
-
getLast(): AssociationNode;
|
|
8
|
-
returnsMany(): boolean;
|
|
9
|
-
}
|
|
@@ -1,27 +0,0 @@
|
|
|
1
|
-
import { AssociationSettings, TypeThunk } from '../orm.type.js';
|
|
2
|
-
import { ColumnFieldMetadata } from './column-field-metadata.js';
|
|
3
|
-
import { EntityMetadata } from './entity-metadata.js';
|
|
4
|
-
export declare class Association {
|
|
5
|
-
private _resolved?;
|
|
6
|
-
private _source?;
|
|
7
|
-
private _target?;
|
|
8
|
-
private _sourceKey?;
|
|
9
|
-
private _targetKey?;
|
|
10
|
-
private _sourceProperty?;
|
|
11
|
-
private _targetProperty?;
|
|
12
|
-
name: string;
|
|
13
|
-
readonly source: TypeThunk;
|
|
14
|
-
readonly target: TypeThunk;
|
|
15
|
-
readonly sourceKey?: string;
|
|
16
|
-
readonly targetKey?: string;
|
|
17
|
-
readonly many: boolean;
|
|
18
|
-
constructor(name: string, args: AssociationSettings);
|
|
19
|
-
resolveSource(): Promise<EntityMetadata>;
|
|
20
|
-
resolveTarget(): Promise<EntityMetadata>;
|
|
21
|
-
resolveSourceKey(): Promise<string>;
|
|
22
|
-
resolveSourceProperty(): Promise<ColumnFieldMetadata>;
|
|
23
|
-
resolveTargetKey(): Promise<string>;
|
|
24
|
-
resolveTargetProperty(): Promise<ColumnFieldMetadata>;
|
|
25
|
-
returnsMany(): boolean;
|
|
26
|
-
protected _resolveKeys(): Promise<void>;
|
|
27
|
-
}
|
|
@@ -1,75 +0,0 @@
|
|
|
1
|
-
import { DataType } from '@sqb/builder';
|
|
2
|
-
import type { ColumnAutoGenerationStrategy, ColumnTransformFunction, DefaultValueGetter, EnumValue, FieldValue } from '../orm.type.js';
|
|
3
|
-
import type { EntityMetadata } from './entity-metadata.js';
|
|
4
|
-
import { FieldMetadata } from './field-metadata.js';
|
|
5
|
-
export type ColumnFieldOptions = Partial<Omit<ColumnFieldMetadata, 'entity' | 'name' | 'kind'>>;
|
|
6
|
-
export interface ColumnFieldMetadata extends FieldMetadata {
|
|
7
|
-
readonly kind: 'column';
|
|
8
|
-
/**
|
|
9
|
-
Name of table field
|
|
10
|
-
*/
|
|
11
|
-
fieldName: string;
|
|
12
|
-
/**
|
|
13
|
-
JS type. String, Boolean, Person etc
|
|
14
|
-
*/
|
|
15
|
-
type?: Function;
|
|
16
|
-
/**
|
|
17
|
-
* Column data type
|
|
18
|
-
*/
|
|
19
|
-
dataType?: DataType;
|
|
20
|
-
/**
|
|
21
|
-
* Field comment
|
|
22
|
-
*/
|
|
23
|
-
comment?: string;
|
|
24
|
-
/**
|
|
25
|
-
* Column's default value
|
|
26
|
-
*/
|
|
27
|
-
default?: FieldValue | DefaultValueGetter;
|
|
28
|
-
/**
|
|
29
|
-
* Indicates if column data is an array
|
|
30
|
-
*/
|
|
31
|
-
isArray?: boolean;
|
|
32
|
-
/**
|
|
33
|
-
* Indicates enum values
|
|
34
|
-
*/
|
|
35
|
-
enum?: EnumValue;
|
|
36
|
-
/**
|
|
37
|
-
* Character or byte length of column
|
|
38
|
-
*/
|
|
39
|
-
length?: number;
|
|
40
|
-
/**
|
|
41
|
-
* The precision for a decimal field
|
|
42
|
-
*/
|
|
43
|
-
precision?: number;
|
|
44
|
-
/**
|
|
45
|
-
* The scale for a decimal field
|
|
46
|
-
*/
|
|
47
|
-
scale?: number;
|
|
48
|
-
/**
|
|
49
|
-
* Fields's collation.
|
|
50
|
-
*/
|
|
51
|
-
collation?: string;
|
|
52
|
-
/**
|
|
53
|
-
* Indicates auto generation strategy
|
|
54
|
-
*/
|
|
55
|
-
autoGenerated?: ColumnAutoGenerationStrategy;
|
|
56
|
-
/**
|
|
57
|
-
* Indicates if column value can be null
|
|
58
|
-
*/
|
|
59
|
-
notNull?: boolean;
|
|
60
|
-
/**
|
|
61
|
-
* Indicates if column value is used in update queries
|
|
62
|
-
*/
|
|
63
|
-
noUpdate?: boolean;
|
|
64
|
-
/**
|
|
65
|
-
* Indicates if column value is used in insert queries
|
|
66
|
-
*/
|
|
67
|
-
noInsert?: boolean;
|
|
68
|
-
parse?: ColumnTransformFunction;
|
|
69
|
-
serialize?: ColumnTransformFunction;
|
|
70
|
-
}
|
|
71
|
-
export declare namespace ColumnFieldMetadata {
|
|
72
|
-
function create(entity: EntityMetadata, name: string, options?: ColumnFieldOptions): ColumnFieldMetadata;
|
|
73
|
-
function assign(target: ColumnFieldMetadata, options: ColumnFieldOptions): void;
|
|
74
|
-
function checkEnumValue(col: ColumnFieldMetadata, v: FieldValue): void;
|
|
75
|
-
}
|
|
@@ -1,14 +0,0 @@
|
|
|
1
|
-
import { TypeThunk } from '../orm.type.js';
|
|
2
|
-
import type { EntityMetadata } from './entity-metadata.js';
|
|
3
|
-
import { FieldMetadata } from './field-metadata.js';
|
|
4
|
-
export type EmbeddedFieldOptions = Partial<Omit<EmbeddedFieldMetadata, 'entity' | 'name' | 'kind' | 'type'>>;
|
|
5
|
-
export interface EmbeddedFieldMetadata extends FieldMetadata {
|
|
6
|
-
readonly kind: 'object';
|
|
7
|
-
type: TypeThunk;
|
|
8
|
-
fieldNamePrefix?: string;
|
|
9
|
-
fieldNameSuffix?: string;
|
|
10
|
-
}
|
|
11
|
-
export declare namespace EmbeddedFieldMetadata {
|
|
12
|
-
function create(entity: EntityMetadata, name: string, type: TypeThunk, options?: EmbeddedFieldOptions): EmbeddedFieldMetadata;
|
|
13
|
-
function resolveType(meta: EmbeddedFieldMetadata): Promise<EntityMetadata>;
|
|
14
|
-
}
|
|
@@ -1,50 +0,0 @@
|
|
|
1
|
-
import { Maybe, Type } from 'ts-gems';
|
|
2
|
-
import { Ctor, TypeThunk } from '../orm.type.js';
|
|
3
|
-
import { Association } from './association.js';
|
|
4
|
-
import { AssociationFieldMetadata, AssociationFieldOptions } from './association-field-metadata.js';
|
|
5
|
-
import { AssociationNode } from './association-node.js';
|
|
6
|
-
import { ColumnFieldMetadata, ColumnFieldOptions } from './column-field-metadata.js';
|
|
7
|
-
import { EmbeddedFieldMetadata, EmbeddedFieldOptions } from './embedded-field-metadata.js';
|
|
8
|
-
import { IndexMetadata } from './index-metadata.js';
|
|
9
|
-
export type AnyFieldMetadata = ColumnFieldMetadata | EmbeddedFieldMetadata | AssociationFieldMetadata;
|
|
10
|
-
export type EntityOptions = Partial<Pick<EntityMetadata, 'name' | 'schema' | 'comment' | 'tableName'>>;
|
|
11
|
-
export interface EntityMetadata {
|
|
12
|
-
readonly ctor: Type;
|
|
13
|
-
readonly name: string;
|
|
14
|
-
tableName?: string;
|
|
15
|
-
schema?: string;
|
|
16
|
-
comment?: string;
|
|
17
|
-
fields: Record<string, AnyFieldMetadata>;
|
|
18
|
-
indexes: IndexMetadata[];
|
|
19
|
-
foreignKeys: Association[];
|
|
20
|
-
eventListeners: Record<string, Function[]>;
|
|
21
|
-
}
|
|
22
|
-
export declare namespace EntityMetadata {
|
|
23
|
-
function define(ctor: Ctor): EntityMetadata;
|
|
24
|
-
function get(ctor: Ctor): Maybe<EntityMetadata>;
|
|
25
|
-
function getOwn(ctor: Ctor): Maybe<EntityMetadata>;
|
|
26
|
-
function getField(entity: EntityMetadata, fieldName: string): Maybe<AnyFieldMetadata>;
|
|
27
|
-
function getColumnField(entity: EntityMetadata, fieldName: string): Maybe<ColumnFieldMetadata>;
|
|
28
|
-
function getEmbeddedField(entity: EntityMetadata, fieldName: string): Maybe<EmbeddedFieldMetadata>;
|
|
29
|
-
function getAssociationField(entity: EntityMetadata, fieldName: string): Maybe<AssociationFieldMetadata>;
|
|
30
|
-
function findField(entity: EntityMetadata, predicate: (el: AnyFieldMetadata) => boolean): Maybe<AnyFieldMetadata>;
|
|
31
|
-
function getColumnFieldByFieldName(entity: EntityMetadata, fieldName: string): Maybe<ColumnFieldMetadata>;
|
|
32
|
-
function getFieldNames(entity: EntityMetadata, filter?: (el: AnyFieldMetadata) => boolean): string[];
|
|
33
|
-
function getColumnFieldNames(entity: EntityMetadata): string[];
|
|
34
|
-
function getEmbeddedFieldNames(entity: EntityMetadata): string[];
|
|
35
|
-
function getAssociationFieldNames(entity: EntityMetadata): string[];
|
|
36
|
-
function getNonAssociationFieldNames(entity: EntityMetadata): string[];
|
|
37
|
-
function getInsertColumnNames(entity: EntityMetadata): string[];
|
|
38
|
-
function getUpdateColumnNames(entity: EntityMetadata): string[];
|
|
39
|
-
function getPrimaryIndex(entity: EntityMetadata): Maybe<IndexMetadata>;
|
|
40
|
-
function getPrimaryIndexColumns(entity: EntityMetadata): ColumnFieldMetadata[];
|
|
41
|
-
function getForeignKeyFor(src: EntityMetadata, trg: EntityMetadata): Promise<Maybe<Association>>;
|
|
42
|
-
function addIndex(entity: EntityMetadata, index: IndexMetadata): void;
|
|
43
|
-
function addForeignKey(entity: EntityMetadata, propertyKey: string, target: TypeThunk, targetKey?: string): void;
|
|
44
|
-
function addEventListener(entity: EntityMetadata, event: string, fn: Function): void;
|
|
45
|
-
function defineColumnField(entity: EntityMetadata, name: string, options?: ColumnFieldOptions): ColumnFieldMetadata;
|
|
46
|
-
function defineEmbeddedField(entity: EntityMetadata, name: string, type: TypeThunk, options?: EmbeddedFieldOptions): EmbeddedFieldMetadata;
|
|
47
|
-
function defineAssociationField(entity: EntityMetadata, propertyKey: string, association: AssociationNode, options?: AssociationFieldOptions): AssociationFieldMetadata;
|
|
48
|
-
function setPrimaryKeys(entity: EntityMetadata, column: string | string[], options?: Omit<IndexMetadata, 'columns' | 'unique' | 'primary'>): void;
|
|
49
|
-
function mixin(derived: EntityMetadata, base: EntityMetadata, filter?: (n: string) => boolean): void;
|
|
50
|
-
}
|
|
@@ -1,16 +0,0 @@
|
|
|
1
|
-
import type { FieldKind } from '../orm.type.js';
|
|
2
|
-
import type { EntityMetadata } from './entity-metadata.js';
|
|
3
|
-
export interface FieldMetadata {
|
|
4
|
-
readonly entity: EntityMetadata;
|
|
5
|
-
readonly name: string;
|
|
6
|
-
readonly kind: FieldKind;
|
|
7
|
-
/**
|
|
8
|
-
* Indicates whether or not to hide this field by default when making queries.
|
|
9
|
-
*/
|
|
10
|
-
hidden?: boolean;
|
|
11
|
-
/**
|
|
12
|
-
* Indicates whether or not to include this field by default when making queries.
|
|
13
|
-
* If this set to "true" the field must be requested using "include" or "pick" option.
|
|
14
|
-
*/
|
|
15
|
-
exclusive?: boolean;
|
|
16
|
-
}
|
|
@@ -1,18 +0,0 @@
|
|
|
1
|
-
export interface IndexMetadata {
|
|
2
|
-
/**
|
|
3
|
-
* Columns of the index
|
|
4
|
-
*/
|
|
5
|
-
columns: string[];
|
|
6
|
-
/**
|
|
7
|
-
* Name of the index
|
|
8
|
-
*/
|
|
9
|
-
name?: string;
|
|
10
|
-
/**
|
|
11
|
-
* Specifies if index is unique
|
|
12
|
-
*/
|
|
13
|
-
unique?: boolean;
|
|
14
|
-
/**
|
|
15
|
-
* Specifies if index is primary
|
|
16
|
-
*/
|
|
17
|
-
primary?: boolean;
|
|
18
|
-
}
|
|
@@ -1,13 +0,0 @@
|
|
|
1
|
-
import { Type } from 'ts-gems';
|
|
2
|
-
import { TypeResolver, TypeThunk } from '../orm.type.js';
|
|
3
|
-
import { AssociationNode } from './association-node.js';
|
|
4
|
-
export declare class LinkChain<T> {
|
|
5
|
-
target: TypeThunk<T>;
|
|
6
|
-
first: AssociationNode;
|
|
7
|
-
current: AssociationNode;
|
|
8
|
-
constructor(target: TypeThunk<T>, targetKey?: keyof T, sourceKey?: string, many?: boolean);
|
|
9
|
-
where(conditions: object | object[]): this;
|
|
10
|
-
linkToOne<K>(target: Type<K> | TypeResolver<K>, targetColumn?: keyof K, parentColumn?: keyof T): LinkChain<K>;
|
|
11
|
-
linkToMany<K>(target: Type<K> | TypeResolver<K>, targetColumn?: keyof K, parentColumn?: keyof T): LinkChain<K>;
|
|
12
|
-
private _newNode;
|
|
13
|
-
}
|
package/esm/orm/orm.const.d.ts
DELETED
package/esm/orm/orm.type.d.ts
DELETED
|
@@ -1,20 +0,0 @@
|
|
|
1
|
-
import { Type } from 'ts-gems';
|
|
2
|
-
export type Ctor = Type | Function;
|
|
3
|
-
export type FieldKind = 'column' | 'object' | 'association';
|
|
4
|
-
/**
|
|
5
|
-
* Indicates auto generation strategy
|
|
6
|
-
*/
|
|
7
|
-
export type ColumnAutoGenerationStrategy = 'increment' | 'uuid' | 'rowid' | 'timestamp' | 'custom';
|
|
8
|
-
export type ColumnTransformFunction = (value: any, name: string) => any;
|
|
9
|
-
export type TypeResolver<T> = () => Type<T> | Promise<Type<T>>;
|
|
10
|
-
export type TypeThunk<T = any> = Type<T> | TypeResolver<T>;
|
|
11
|
-
export type EnumValue = (FieldValue)[] | Object;
|
|
12
|
-
export type FieldValue = string | number | boolean | Date | null;
|
|
13
|
-
export type DefaultValueGetter = (obj?: any) => FieldValue | undefined;
|
|
14
|
-
export interface AssociationSettings {
|
|
15
|
-
source: TypeThunk;
|
|
16
|
-
target: TypeThunk;
|
|
17
|
-
sourceKey?: string;
|
|
18
|
-
targetKey?: string;
|
|
19
|
-
many?: boolean;
|
|
20
|
-
}
|
|
@@ -1,140 +0,0 @@
|
|
|
1
|
-
import { StrictOmit, Type } from 'ts-gems';
|
|
2
|
-
import { FieldInfoMap } from '../client/field-info-map.js';
|
|
3
|
-
import { SqbClient } from '../client/sqb-client.js';
|
|
4
|
-
import { SqbConnection } from '../client/sqb-connection.js';
|
|
5
|
-
import { QueryRequest, TransactionFunction } from '../client/types.js';
|
|
6
|
-
import { EntityInput, EntityOutput } from '../types.js';
|
|
7
|
-
import { EntityMetadata } from './model/entity-metadata.js';
|
|
8
|
-
interface Projection {
|
|
9
|
-
pick?: string[];
|
|
10
|
-
omit?: string[];
|
|
11
|
-
include?: string[];
|
|
12
|
-
}
|
|
13
|
-
interface Filtering {
|
|
14
|
-
filter?: any;
|
|
15
|
-
params?: any;
|
|
16
|
-
}
|
|
17
|
-
export declare namespace Repository {
|
|
18
|
-
type TransformRowFunction = (fields: FieldInfoMap, row: object, obj: object) => void;
|
|
19
|
-
interface CommandOptions {
|
|
20
|
-
connection?: SqbConnection;
|
|
21
|
-
}
|
|
22
|
-
interface CreateOptions extends CommandOptions, Projection {
|
|
23
|
-
}
|
|
24
|
-
interface CountOptions extends CommandOptions, Filtering {
|
|
25
|
-
}
|
|
26
|
-
interface ExistsOptions extends CommandOptions, Filtering {
|
|
27
|
-
}
|
|
28
|
-
interface DeleteOptions extends CommandOptions, Filtering {
|
|
29
|
-
}
|
|
30
|
-
interface DeleteManyOptions extends CommandOptions, Filtering {
|
|
31
|
-
}
|
|
32
|
-
interface FindOptions extends CommandOptions, Projection, Filtering {
|
|
33
|
-
}
|
|
34
|
-
interface FindOneOptions extends CommandOptions, Projection, Filtering {
|
|
35
|
-
sort?: string[];
|
|
36
|
-
offset?: number;
|
|
37
|
-
}
|
|
38
|
-
interface FindManyOptions extends FindOneOptions {
|
|
39
|
-
limit?: number;
|
|
40
|
-
distinct?: boolean;
|
|
41
|
-
maxEagerFetch?: number;
|
|
42
|
-
maxSubQueries?: number;
|
|
43
|
-
onTransformRow?: TransformRowFunction;
|
|
44
|
-
}
|
|
45
|
-
interface UpdateOptions extends CommandOptions, Projection, Filtering {
|
|
46
|
-
}
|
|
47
|
-
interface UpdateManyOptions extends CommandOptions, Filtering {
|
|
48
|
-
}
|
|
49
|
-
/**
|
|
50
|
-
* @deprecated
|
|
51
|
-
*/
|
|
52
|
-
type FindAllOptions = FindManyOptions;
|
|
53
|
-
/**
|
|
54
|
-
* @deprecated
|
|
55
|
-
*/
|
|
56
|
-
type DestroyOptions = DeleteOptions;
|
|
57
|
-
/**
|
|
58
|
-
* @deprecated
|
|
59
|
-
*/
|
|
60
|
-
type UpdateAllOptions = UpdateManyOptions;
|
|
61
|
-
}
|
|
62
|
-
interface RepositoryEvents {
|
|
63
|
-
execute: (request: QueryRequest) => void;
|
|
64
|
-
error: (error: Error) => void;
|
|
65
|
-
acquire: (connection: SqbConnection) => Promise<void>;
|
|
66
|
-
}
|
|
67
|
-
declare const Repository_base: Type<import("strict-typed-events").TypedEventEmitter<any, RepositoryEvents, RepositoryEvents>>;
|
|
68
|
-
export declare class Repository<T> extends Repository_base {
|
|
69
|
-
private readonly _executor;
|
|
70
|
-
private readonly _entity;
|
|
71
|
-
private readonly _schema?;
|
|
72
|
-
constructor(entityDef: EntityMetadata, executor: SqbClient | SqbConnection, schema?: string);
|
|
73
|
-
get entity(): EntityMetadata;
|
|
74
|
-
get type(): Type<T>;
|
|
75
|
-
create(values: EntityInput<T>, options?: Repository.CreateOptions): Promise<EntityOutput<T>>;
|
|
76
|
-
createOnly(values: EntityInput<T>, options?: StrictOmit<Repository.CreateOptions, keyof Projection>): Promise<void>;
|
|
77
|
-
exists(keyValue: any | Record<string, any>, options?: Repository.ExistsOptions): Promise<boolean>;
|
|
78
|
-
count(options?: Repository.CountOptions): Promise<number>;
|
|
79
|
-
find(keyValue: any | Record<string, any>, options?: Repository.FindOptions): Promise<EntityOutput<T> | undefined>;
|
|
80
|
-
findOne(options?: Repository.FindOneOptions): Promise<EntityOutput<T> | undefined>;
|
|
81
|
-
findMany(options?: Repository.FindManyOptions): Promise<EntityOutput<T>[]>;
|
|
82
|
-
delete(keyValue: any | Record<string, any>, options?: Repository.DeleteOptions): Promise<boolean>;
|
|
83
|
-
deleteMany(options?: Repository.DeleteManyOptions): Promise<number>;
|
|
84
|
-
update(keyValue: any | Record<string, any>, values: EntityInput<T>, options?: Repository.UpdateOptions): Promise<EntityOutput<T> | undefined>;
|
|
85
|
-
updateOnly(keyValue: any | Record<string, any>, values: EntityInput<T>, options?: StrictOmit<Repository.UpdateOptions, keyof Projection>): Promise<boolean>;
|
|
86
|
-
updateMany(values: EntityInput<T>, options?: Repository.UpdateManyOptions): Promise<number>;
|
|
87
|
-
/**
|
|
88
|
-
*
|
|
89
|
-
* @deprecated
|
|
90
|
-
*/
|
|
91
|
-
destroy(keyValue: any | Record<string, any>, options?: Repository.DeleteOptions): Promise<boolean>;
|
|
92
|
-
/**
|
|
93
|
-
*
|
|
94
|
-
* @deprecated
|
|
95
|
-
*/
|
|
96
|
-
destroyAll(options?: Repository.DeleteManyOptions): Promise<number>;
|
|
97
|
-
/**
|
|
98
|
-
*
|
|
99
|
-
* @deprecated
|
|
100
|
-
*/
|
|
101
|
-
findAll(options?: Repository.FindManyOptions): Promise<EntityOutput<T>[]>;
|
|
102
|
-
/**
|
|
103
|
-
*
|
|
104
|
-
* @deprecated
|
|
105
|
-
*/
|
|
106
|
-
updateAll(values: EntityInput<T>, options?: Repository.UpdateManyOptions): Promise<number>;
|
|
107
|
-
protected _execute(fn: TransactionFunction, opts?: Repository.CommandOptions): Promise<any>;
|
|
108
|
-
protected _create(values: EntityInput<T>, options: Repository.CreateOptions & {
|
|
109
|
-
connection: SqbConnection;
|
|
110
|
-
returning?: boolean;
|
|
111
|
-
}): Promise<any>;
|
|
112
|
-
protected _exists(keyValue: any | Record<string, any>, options: Repository.ExistsOptions & {
|
|
113
|
-
connection: SqbConnection;
|
|
114
|
-
}): Promise<boolean>;
|
|
115
|
-
protected _count(options: Repository.CountOptions & {
|
|
116
|
-
connection: SqbConnection;
|
|
117
|
-
}): Promise<number>;
|
|
118
|
-
protected _findMany(options: Repository.FindManyOptions & {
|
|
119
|
-
connection: SqbConnection;
|
|
120
|
-
}): Promise<EntityOutput<T>[]>;
|
|
121
|
-
protected _findOne(options: Repository.FindOneOptions & {
|
|
122
|
-
connection: SqbConnection;
|
|
123
|
-
}): Promise<EntityOutput<T> | undefined>;
|
|
124
|
-
protected _find(keyValue: any | Record<string, any>, options: Repository.FindOptions & {
|
|
125
|
-
connection: SqbConnection;
|
|
126
|
-
}): Promise<EntityOutput<T> | undefined>;
|
|
127
|
-
protected _delete(keyValue: any | Record<string, any>, options: Repository.DeleteOptions & {
|
|
128
|
-
connection: SqbConnection;
|
|
129
|
-
}): Promise<boolean>;
|
|
130
|
-
protected _deleteMany(options: Repository.DeleteManyOptions & {
|
|
131
|
-
connection: SqbConnection;
|
|
132
|
-
}): Promise<number>;
|
|
133
|
-
protected _update(keyValue: any | Record<string, any>, values: EntityInput<T>, options: Repository.UpdateOptions & {
|
|
134
|
-
connection: SqbConnection;
|
|
135
|
-
}): Promise<Record<string, any> | undefined>;
|
|
136
|
-
protected _updateMany(values: EntityInput<T>, options: Repository.UpdateManyOptions & {
|
|
137
|
-
connection: SqbConnection;
|
|
138
|
-
}): Promise<number>;
|
|
139
|
-
}
|
|
140
|
-
export {};
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
export declare function applyMixins(derivedCtor: any, baseCtor: any, filter?: (k: string) => boolean): void;
|
|
@@ -1,13 +0,0 @@
|
|
|
1
|
-
import { Type } from 'ts-gems';
|
|
2
|
-
import { AssociationFieldMetadata } from '../model/association-field-metadata.js';
|
|
3
|
-
import type { ColumnFieldMetadata } from '../model/column-field-metadata.js';
|
|
4
|
-
import { EmbeddedFieldMetadata } from '../model/embedded-field-metadata.js';
|
|
5
|
-
import type { EntityMetadata } from '../model/entity-metadata.js';
|
|
6
|
-
import type { TypeThunk } from '../orm.type.js';
|
|
7
|
-
export declare function isClass(fn: any): fn is Type;
|
|
8
|
-
export declare function isEntityClass(fn: any): fn is Type;
|
|
9
|
-
export declare function isColumnField(f: any): f is ColumnFieldMetadata;
|
|
10
|
-
export declare const isEmbeddedField: (f: any) => f is EmbeddedFieldMetadata;
|
|
11
|
-
export declare const isAssociationField: (f: any) => f is AssociationFieldMetadata;
|
|
12
|
-
export declare function resolveEntity(ctorThunk: TypeThunk): Promise<Type | undefined>;
|
|
13
|
-
export declare function resolveEntityMeta(ctorThunk: TypeThunk): Promise<EntityMetadata | undefined>;
|
package/esm/types.d.ts
DELETED
|
@@ -1,12 +0,0 @@
|
|
|
1
|
-
import { Builtin, DeepPickWritable } from 'ts-gems';
|
|
2
|
-
export type EntityInput<T> = DeepNullablePartial<DeepPickWritable<T>>;
|
|
3
|
-
export type EntityOutput<T> = DeepPartial<T>;
|
|
4
|
-
export type DeepNullablePartial<T> = _DeepNullablePartial<T>;
|
|
5
|
-
type _DeepNullablePartial<T> = T extends Builtin ? T : T extends Promise<infer U> ? Promise<DeepNullablePartial<U>> : T extends (infer U)[] ? DeepNullablePartial<U>[] : {
|
|
6
|
-
[P in keyof T]?: DeepNullablePartial<Exclude<T[P], undefined>> | null;
|
|
7
|
-
};
|
|
8
|
-
export type DeepPartial<T> = _DeepPartial<T>;
|
|
9
|
-
type _DeepPartial<T> = T extends Builtin ? T : T extends Promise<infer U> ? Promise<DeepPartial<U>> : T extends (infer U)[] ? DeepPartial<U>[] : {
|
|
10
|
-
[P in keyof T]?: DeepPartial<Exclude<T[P], undefined>>;
|
|
11
|
-
};
|
|
12
|
-
export {};
|