@sqb/connect 4.10.0 → 4.10.2
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 +3 -2
- package/types/client/adapter.d.ts +57 -0
- package/types/client/cursor-stream.d.ts +29 -0
- package/types/client/cursor.d.ts +116 -0
- package/types/client/extensions.d.ts +4 -0
- package/types/client/field-info-map.d.ts +12 -0
- package/types/client/helpers.d.ts +9 -0
- package/types/client/sqb-client.d.ts +65 -0
- package/types/client/sqb-connection.d.ts +74 -0
- package/types/client/types.d.ts +181 -0
- package/types/index.d.ts +34 -0
- package/types/orm/backward.d.ts +13 -0
- package/types/orm/base-entity.d.ts +8 -0
- package/types/orm/commands/command.helper.d.ts +14 -0
- package/types/orm/commands/count.command.d.ts +11 -0
- package/types/orm/commands/create.command.d.ts +20 -0
- package/types/orm/commands/delete.command.d.ts +11 -0
- package/types/orm/commands/find.command.d.ts +44 -0
- package/types/orm/commands/row-converter.d.ts +55 -0
- package/types/orm/commands/update.command.d.ts +22 -0
- package/types/orm/decorators/column.decorator.d.ts +4 -0
- package/types/orm/decorators/embedded.decorator.d.ts +3 -0
- package/types/orm/decorators/entity.decorator.d.ts +38 -0
- package/types/orm/decorators/events.decorator.d.ts +6 -0
- package/types/orm/decorators/foreignkey.decorator.d.ts +2 -0
- package/types/orm/decorators/index.decorator.d.ts +3 -0
- package/types/orm/decorators/link.decorator.d.ts +13 -0
- package/types/orm/decorators/primarykey.decorator.d.ts +3 -0
- package/types/orm/decorators/transform.decorator.d.ts +3 -0
- package/types/orm/model/association-field-metadata.d.ts +12 -0
- package/types/orm/model/association-node.d.ts +9 -0
- package/types/orm/model/association.d.ts +27 -0
- package/types/orm/model/column-field-metadata.d.ts +75 -0
- package/types/orm/model/embedded-field-metadata.d.ts +14 -0
- package/types/orm/model/entity-metadata.d.ts +50 -0
- package/types/orm/model/field-metadata.d.ts +16 -0
- package/types/orm/model/index-metadata.d.ts +18 -0
- package/types/orm/model/link-chain.d.ts +13 -0
- package/types/orm/orm.const.d.ts +2 -0
- package/types/orm/orm.type.d.ts +20 -0
- package/types/orm/repository.class.d.ts +140 -0
- package/types/orm/util/apply-mixins.d.ts +1 -0
- package/types/orm/util/extract-keyvalues.d.ts +2 -0
- package/types/orm/util/orm.helper.d.ts +13 -0
- package/types/orm/util/serialize-field.d.ts +2 -0
- package/types/types.d.ts +12 -0
|
@@ -0,0 +1,140 @@
|
|
|
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 {};
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export declare function applyMixins(derivedCtor: any, baseCtor: any, filter?: (k: string) => boolean): void;
|
|
@@ -0,0 +1,13 @@
|
|
|
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/types/types.d.ts
ADDED
|
@@ -0,0 +1,12 @@
|
|
|
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 {};
|