@sqb/connect 4.9.1 → 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/model/association-node.js +0 -3
- package/cjs/orm/model/association.js +0 -13
- 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
package/esm/client/helpers.d.ts
DELETED
|
@@ -1,9 +0,0 @@
|
|
|
1
|
-
import { Maybe } from 'ts-gems';
|
|
2
|
-
import { Adapter } from './adapter.js';
|
|
3
|
-
import { FieldInfoMap } from './field-info-map.js';
|
|
4
|
-
import { ArrayRowset, FieldNaming, ObjectRowset, QueryRequest } from './types.js';
|
|
5
|
-
export declare function applyNamingStrategy(value: string, namingStrategy?: FieldNaming): Maybe<string>;
|
|
6
|
-
export declare function wrapAdapterFields(oldFields: Adapter.Field[], fieldNaming?: FieldNaming): FieldInfoMap;
|
|
7
|
-
export declare function normalizeRowsToObjectRows(fields: FieldInfoMap, rowType: 'array' | 'object', oldRows: ObjectRowset | ArrayRowset, options?: Pick<QueryRequest, 'ignoreNulls' | 'transform'>): Record<string, any>[];
|
|
8
|
-
export declare function normalizeRowsToArrayRows(fields: FieldInfoMap, rowType: 'array' | 'object', oldRows: ObjectRowset | ArrayRowset, options?: Pick<QueryRequest, 'ignoreNulls' | 'transform'>): any[][];
|
|
9
|
-
export declare function callFetchHooks(rows: ObjectRowset | ArrayRowset, request: QueryRequest): void;
|
|
@@ -1,65 +0,0 @@
|
|
|
1
|
-
import { Pool as LightningPool } from 'lightning-pool';
|
|
2
|
-
import { Maybe, Type } from 'ts-gems';
|
|
3
|
-
import { classes } from '@sqb/builder';
|
|
4
|
-
import { Repository } from '../orm/repository.class.js';
|
|
5
|
-
import { SqbConnection } from './sqb-connection.js';
|
|
6
|
-
import { ClientConfiguration, ClientDefaults, ConnectionOptions, QueryExecuteOptions, QueryRequest, QueryResult, TransactionFunction } from './types.js';
|
|
7
|
-
declare const inspect: unique symbol;
|
|
8
|
-
interface SqbClientEvents {
|
|
9
|
-
execute: (request: QueryRequest) => void;
|
|
10
|
-
error: (error: Error) => void;
|
|
11
|
-
closing: () => void;
|
|
12
|
-
close: () => void;
|
|
13
|
-
acquire: (connection: SqbConnection) => Promise<void>;
|
|
14
|
-
terminate: () => void;
|
|
15
|
-
'connection-return': (connection: SqbConnection) => Promise<void>;
|
|
16
|
-
}
|
|
17
|
-
declare const SqbClient_base: Type<import("strict-typed-events").TypedEventEmitter<any, SqbClientEvents, SqbClientEvents>>;
|
|
18
|
-
export declare class SqbClient extends SqbClient_base {
|
|
19
|
-
private readonly _adapter;
|
|
20
|
-
private readonly _pool;
|
|
21
|
-
private readonly _defaults;
|
|
22
|
-
private readonly _entities;
|
|
23
|
-
constructor(config: ClientConfiguration);
|
|
24
|
-
get defaults(): ClientDefaults;
|
|
25
|
-
/**
|
|
26
|
-
* Returns dialect
|
|
27
|
-
*/
|
|
28
|
-
get dialect(): string;
|
|
29
|
-
/**
|
|
30
|
-
* Returns database driver name
|
|
31
|
-
*/
|
|
32
|
-
get driver(): string;
|
|
33
|
-
/**
|
|
34
|
-
* Returns true if pool is closed
|
|
35
|
-
*/
|
|
36
|
-
get isClosed(): boolean;
|
|
37
|
-
get pool(): LightningPool;
|
|
38
|
-
/**
|
|
39
|
-
* Obtains a connection from the connection pool and executes the callback
|
|
40
|
-
*/
|
|
41
|
-
acquire(fn: TransactionFunction, options?: ConnectionOptions): Promise<any>;
|
|
42
|
-
/**
|
|
43
|
-
* Obtains a connection from the connection pool.
|
|
44
|
-
*/
|
|
45
|
-
acquire(options?: ConnectionOptions): Promise<SqbConnection>;
|
|
46
|
-
/**
|
|
47
|
-
* Shuts down the pool and destroys all resources.
|
|
48
|
-
*/
|
|
49
|
-
close(terminateWait?: number): Promise<void>;
|
|
50
|
-
/**
|
|
51
|
-
* Executes a query or callback with a new acquired connection.
|
|
52
|
-
*/
|
|
53
|
-
execute(query: string | classes.Query, options?: QueryExecuteOptions): Promise<QueryResult>;
|
|
54
|
-
/**
|
|
55
|
-
* Tests the pool
|
|
56
|
-
*/
|
|
57
|
-
test(): Promise<void>;
|
|
58
|
-
getRepository<T>(entity: Type<T> | string, opts?: {
|
|
59
|
-
schema?: string;
|
|
60
|
-
}): Repository<T>;
|
|
61
|
-
getEntity<T>(name: string): Maybe<Type<T>>;
|
|
62
|
-
toString(): string;
|
|
63
|
-
[inspect](): string;
|
|
64
|
-
}
|
|
65
|
-
export {};
|
|
@@ -1,74 +0,0 @@
|
|
|
1
|
-
import { Type } from 'ts-gems';
|
|
2
|
-
import { classes } from '@sqb/builder';
|
|
3
|
-
import { Repository } from '../orm/repository.class.js';
|
|
4
|
-
import { Adapter } from './adapter.js';
|
|
5
|
-
import { SqbClient } from './sqb-client.js';
|
|
6
|
-
import { ConnectionOptions, QueryExecuteOptions, QueryRequest } from './types.js';
|
|
7
|
-
interface SqbConnectionEvents {
|
|
8
|
-
close: () => void;
|
|
9
|
-
execute: (request: QueryRequest) => void;
|
|
10
|
-
error: (error: Error) => void;
|
|
11
|
-
retain: (refCount: number) => void;
|
|
12
|
-
release: (refCount: number) => void;
|
|
13
|
-
'start-transaction': () => void;
|
|
14
|
-
'set-savepoint': () => void;
|
|
15
|
-
'release-savepoint': () => void;
|
|
16
|
-
'rollback-savepoint': () => void;
|
|
17
|
-
commit: () => void;
|
|
18
|
-
rollback: () => void;
|
|
19
|
-
}
|
|
20
|
-
declare const SqbConnection_base: Type<import("strict-typed-events").TypedEventEmitter<any, SqbConnectionEvents, SqbConnectionEvents>>;
|
|
21
|
-
export declare class SqbConnection extends SqbConnection_base {
|
|
22
|
-
readonly client: SqbClient;
|
|
23
|
-
private _intlcon?;
|
|
24
|
-
private readonly _tasks;
|
|
25
|
-
private readonly _options?;
|
|
26
|
-
private _inTransaction;
|
|
27
|
-
private _refCount;
|
|
28
|
-
constructor(client: SqbClient, adapterConnection: Adapter.Connection, options?: ConnectionOptions);
|
|
29
|
-
/**
|
|
30
|
-
* Returns session id
|
|
31
|
-
*/
|
|
32
|
-
get sessionId(): string;
|
|
33
|
-
/**
|
|
34
|
-
* Returns reference counter value
|
|
35
|
-
*/
|
|
36
|
-
get refCount(): number;
|
|
37
|
-
/**
|
|
38
|
-
* Returns true if transaction started
|
|
39
|
-
*/
|
|
40
|
-
get inTransaction(): boolean;
|
|
41
|
-
/**
|
|
42
|
-
* Increases internal reference counter to keep session alive
|
|
43
|
-
*/
|
|
44
|
-
retain(): void;
|
|
45
|
-
/**
|
|
46
|
-
* Decreases the internal reference counter.
|
|
47
|
-
* When reference count is 0, connection returns to the pool.
|
|
48
|
-
* Returns true if connection released.
|
|
49
|
-
*/
|
|
50
|
-
release(): boolean;
|
|
51
|
-
/**
|
|
52
|
-
* Immediately releases the connection.
|
|
53
|
-
*/
|
|
54
|
-
close(): Promise<void>;
|
|
55
|
-
execute(query: string | classes.Query, options?: QueryExecuteOptions): Promise<any>;
|
|
56
|
-
getRepository<T>(entity: Type<T> | string, opts?: {
|
|
57
|
-
schema?: string;
|
|
58
|
-
}): Repository<T>;
|
|
59
|
-
getSchema(): Promise<string>;
|
|
60
|
-
setSchema(schema: string): Promise<void>;
|
|
61
|
-
/**
|
|
62
|
-
* Executes a query
|
|
63
|
-
*/
|
|
64
|
-
protected _execute(query: string | classes.Query, options?: QueryExecuteOptions): Promise<any>;
|
|
65
|
-
startTransaction(): Promise<void>;
|
|
66
|
-
commit(): Promise<void>;
|
|
67
|
-
rollback(): Promise<void>;
|
|
68
|
-
setSavepoint(savepoint: string): Promise<void>;
|
|
69
|
-
releaseSavepoint(savepoint: string): Promise<void>;
|
|
70
|
-
rollbackSavepoint(savepoint: string): Promise<void>;
|
|
71
|
-
test(): Promise<void>;
|
|
72
|
-
private _prepareQueryRequest;
|
|
73
|
-
}
|
|
74
|
-
export {};
|
package/esm/client/types.d.ts
DELETED
|
@@ -1,181 +0,0 @@
|
|
|
1
|
-
import type { PoolConfiguration } from 'lightning-pool';
|
|
2
|
-
import { Maybe } from 'ts-gems';
|
|
3
|
-
import { DataType, ParamOptions } from '@sqb/builder';
|
|
4
|
-
import type { Adapter } from './adapter';
|
|
5
|
-
import type { Cursor } from './cursor';
|
|
6
|
-
import type { FieldInfoMap } from './field-info-map';
|
|
7
|
-
import type { SqbConnection } from './sqb-connection';
|
|
8
|
-
export { DataType } from '@sqb/builder';
|
|
9
|
-
export type ExecuteHookFunction = (connection: SqbConnection, request: QueryRequest) => Promise<void>;
|
|
10
|
-
export type FetchFunction = (row: any, request: QueryRequest) => void;
|
|
11
|
-
export type ValueTransformFunction = (value: any, fieldInfo?: FieldInfo) => any;
|
|
12
|
-
export type TransactionFunction = (connection: SqbConnection) => Promise<any>;
|
|
13
|
-
export type RowType = 'array' | 'object';
|
|
14
|
-
export type FieldNaming = 'original' | 'lowercase' | 'uppercase' | 'camelcase' | 'pascalcase' | ((fieldName: string) => Maybe<string>);
|
|
15
|
-
export type ObjectRow = Record<string, any>;
|
|
16
|
-
export type ArrayRow = any[];
|
|
17
|
-
export type ObjectRowset = ObjectRow[];
|
|
18
|
-
export type ArrayRowset = ArrayRow[];
|
|
19
|
-
export interface ClientConfiguration {
|
|
20
|
-
/**
|
|
21
|
-
* Dialect to be used
|
|
22
|
-
*/
|
|
23
|
-
dialect?: string;
|
|
24
|
-
/**
|
|
25
|
-
* Database connection driver to be used
|
|
26
|
-
*/
|
|
27
|
-
driver?: string;
|
|
28
|
-
/**
|
|
29
|
-
* Connection name
|
|
30
|
-
*/
|
|
31
|
-
name?: string;
|
|
32
|
-
/**
|
|
33
|
-
* Database server address or url
|
|
34
|
-
*/
|
|
35
|
-
host?: string;
|
|
36
|
-
/**
|
|
37
|
-
* Database listener port number
|
|
38
|
-
*
|
|
39
|
-
*/
|
|
40
|
-
port?: number;
|
|
41
|
-
/**
|
|
42
|
-
* Database username.
|
|
43
|
-
*/
|
|
44
|
-
user?: string;
|
|
45
|
-
/**
|
|
46
|
-
* Database password.
|
|
47
|
-
*/
|
|
48
|
-
password?: string;
|
|
49
|
-
/**
|
|
50
|
-
* Database name
|
|
51
|
-
*/
|
|
52
|
-
database?: string;
|
|
53
|
-
/**
|
|
54
|
-
* Database schema
|
|
55
|
-
*/
|
|
56
|
-
schema?: string;
|
|
57
|
-
/**
|
|
58
|
-
* Connection options to be passed to the underlying driver
|
|
59
|
-
*/
|
|
60
|
-
driverOptions?: any;
|
|
61
|
-
/**
|
|
62
|
-
* Pooling options
|
|
63
|
-
*/
|
|
64
|
-
pool?: PoolConfiguration;
|
|
65
|
-
/**
|
|
66
|
-
* Default options
|
|
67
|
-
*/
|
|
68
|
-
defaults?: ClientDefaults;
|
|
69
|
-
}
|
|
70
|
-
export interface ClientDefaults {
|
|
71
|
-
autoCommit?: boolean;
|
|
72
|
-
cursor?: boolean;
|
|
73
|
-
objectRows?: boolean;
|
|
74
|
-
fieldNaming?: FieldNaming;
|
|
75
|
-
showSql?: boolean;
|
|
76
|
-
prettyPrint?: boolean;
|
|
77
|
-
ignoreNulls?: boolean;
|
|
78
|
-
/**
|
|
79
|
-
* Sets how many row will be fetched at a time
|
|
80
|
-
* Default = 10
|
|
81
|
-
*/
|
|
82
|
-
fetchRows?: number;
|
|
83
|
-
transform?: ValueTransformFunction;
|
|
84
|
-
}
|
|
85
|
-
export interface ConnectionOptions {
|
|
86
|
-
/**
|
|
87
|
-
* If this property is true, the transaction committed at the end of query execution.
|
|
88
|
-
* Default = false
|
|
89
|
-
*/
|
|
90
|
-
autoCommit?: boolean;
|
|
91
|
-
}
|
|
92
|
-
export interface QueryExecuteOptions {
|
|
93
|
-
/**
|
|
94
|
-
* Array of values or object that contains param/value pairs.
|
|
95
|
-
*/
|
|
96
|
-
params?: Record<string, any> | any[];
|
|
97
|
-
/**
|
|
98
|
-
* If this property is true, the transaction committed at the end of query execution.
|
|
99
|
-
* Default = false
|
|
100
|
-
*/
|
|
101
|
-
autoCommit?: boolean;
|
|
102
|
-
/**
|
|
103
|
-
* If this property is true, query returns a Cursor object that works
|
|
104
|
-
* in unidirectional "cursor" mode.
|
|
105
|
-
* Important! Cursor keeps connection open until cursor.close() method is called.
|
|
106
|
-
*/
|
|
107
|
-
cursor?: boolean;
|
|
108
|
-
/**
|
|
109
|
-
* Function for converting data before returning response.
|
|
110
|
-
*/
|
|
111
|
-
transform?: ValueTransformFunction;
|
|
112
|
-
/**
|
|
113
|
-
* In "cursor" mode; it provides an initial suggested number of rows to prefetch.
|
|
114
|
-
* Prefetching is a tuning option to maximize data transfer efficiency and
|
|
115
|
-
* minimize round-trips to the database. In regular mode;
|
|
116
|
-
* it provides the maximum number of rows that are fetched from Connection instance.
|
|
117
|
-
* Default = 10
|
|
118
|
-
*/
|
|
119
|
-
fetchRows?: number;
|
|
120
|
-
/**
|
|
121
|
-
* If set true, NULL fields will be ignored
|
|
122
|
-
* Default = false
|
|
123
|
-
*/
|
|
124
|
-
ignoreNulls?: boolean;
|
|
125
|
-
/**
|
|
126
|
-
* Sets the naming strategy for fields. It affects field names in object rows and metadata
|
|
127
|
-
*/
|
|
128
|
-
namingStrategy?: FieldNaming;
|
|
129
|
-
/**
|
|
130
|
-
* Determines whether query rows should be returned as Objects or Arrays.
|
|
131
|
-
* This property applies to ResultSet.objectRows property also.
|
|
132
|
-
* Default = driver default
|
|
133
|
-
*/
|
|
134
|
-
objectRows?: boolean;
|
|
135
|
-
/**
|
|
136
|
-
* If set true, result object contains executed sql and values.
|
|
137
|
-
* Default = false
|
|
138
|
-
*/
|
|
139
|
-
showSql?: boolean;
|
|
140
|
-
prettyPrint?: boolean;
|
|
141
|
-
action?: string;
|
|
142
|
-
fetchAsString?: DataType[];
|
|
143
|
-
}
|
|
144
|
-
export interface QueryResult {
|
|
145
|
-
executeTime: number;
|
|
146
|
-
fields?: FieldInfoMap;
|
|
147
|
-
rows?: any;
|
|
148
|
-
rowType?: RowType;
|
|
149
|
-
query?: QueryRequest;
|
|
150
|
-
returns?: any;
|
|
151
|
-
rowsAffected?: number;
|
|
152
|
-
cursor?: Cursor;
|
|
153
|
-
}
|
|
154
|
-
export type FieldInfo = {
|
|
155
|
-
index: number;
|
|
156
|
-
name: string;
|
|
157
|
-
} & Adapter.Field;
|
|
158
|
-
export interface QueryRequest {
|
|
159
|
-
dialect?: string;
|
|
160
|
-
dialectVersion?: string;
|
|
161
|
-
sql: string;
|
|
162
|
-
params?: any;
|
|
163
|
-
paramOptions?: Record<string, ParamOptions> | ParamOptions[];
|
|
164
|
-
returningFields?: {
|
|
165
|
-
field: string;
|
|
166
|
-
alias?: string;
|
|
167
|
-
}[];
|
|
168
|
-
autoCommit?: boolean;
|
|
169
|
-
cursor?: boolean;
|
|
170
|
-
objectRows?: boolean;
|
|
171
|
-
ignoreNulls?: boolean;
|
|
172
|
-
fetchRows?: number;
|
|
173
|
-
fieldNaming?: FieldNaming;
|
|
174
|
-
transform?: ValueTransformFunction;
|
|
175
|
-
showSql?: boolean;
|
|
176
|
-
prettyPrint?: boolean;
|
|
177
|
-
action?: string;
|
|
178
|
-
fetchAsString?: DataType[];
|
|
179
|
-
executeHooks?: ExecuteHookFunction[];
|
|
180
|
-
fetchHooks?: FetchFunction[];
|
|
181
|
-
}
|
package/esm/index.d.ts
DELETED
|
@@ -1,34 +0,0 @@
|
|
|
1
|
-
import 'reflect-metadata';
|
|
2
|
-
import { DeepBuildable, DeepPartial, DeepPickWritable, Maybe, Type } from 'ts-gems';
|
|
3
|
-
export { Type, Maybe, DeepPartial, DeepPickWritable, DeepBuildable };
|
|
4
|
-
export * from './types.js';
|
|
5
|
-
export * from './client/types.js';
|
|
6
|
-
export * from './client/adapter.js';
|
|
7
|
-
export * from './client/sqb-client.js';
|
|
8
|
-
export * from './client/sqb-connection.js';
|
|
9
|
-
export * from './client/cursor.js';
|
|
10
|
-
export { registerAdapter, unRegisterAdapter } from './client/extensions.js';
|
|
11
|
-
export * from './orm/orm.type.js';
|
|
12
|
-
export * from './orm/orm.const.js';
|
|
13
|
-
export * from './orm/base-entity.js';
|
|
14
|
-
export * from './orm/repository.class.js';
|
|
15
|
-
export * from './orm/model/entity-metadata.js';
|
|
16
|
-
export * from './orm/model/field-metadata.js';
|
|
17
|
-
export * from './orm/model/column-field-metadata.js';
|
|
18
|
-
export * from './orm/model/embedded-field-metadata.js';
|
|
19
|
-
export * from './orm/model/association-field-metadata.js';
|
|
20
|
-
export * from './orm/model/association.js';
|
|
21
|
-
export * from './orm/model/association-node.js';
|
|
22
|
-
export * from './orm/model/index-metadata.js';
|
|
23
|
-
export * from './orm/model/link-chain.js';
|
|
24
|
-
export * from './orm/decorators/column.decorator.js';
|
|
25
|
-
export * from './orm/decorators/embedded.decorator.js';
|
|
26
|
-
export * from './orm/decorators/entity.decorator.js';
|
|
27
|
-
export * from './orm/decorators/events.decorator.js';
|
|
28
|
-
export * from './orm/decorators/foreignkey.decorator.js';
|
|
29
|
-
export * from './orm/decorators/index.decorator.js';
|
|
30
|
-
export * from './orm/decorators/link.decorator.js';
|
|
31
|
-
export * from './orm/decorators/primarykey.decorator.js';
|
|
32
|
-
export * from './orm/decorators/transform.decorator.js';
|
|
33
|
-
export { isColumnField, isEmbeddedField, isAssociationField, isEntityClass } from './orm/util/orm.helper.js';
|
|
34
|
-
export * from './orm/backward.js';
|
package/esm/orm/backward.d.ts
DELETED
|
@@ -1,13 +0,0 @@
|
|
|
1
|
-
import { PickWritable, Type } from 'ts-gems';
|
|
2
|
-
import { Entity } from './decorators/entity.decorator.js';
|
|
3
|
-
export declare function getInsertColumnNames<T, K extends keyof PickWritable<T>>(ctor: Type<T>): K[];
|
|
4
|
-
export declare function getUpdateColumnNames<T, K extends keyof PickWritable<T>>(ctor: Type<T>): K[];
|
|
5
|
-
export declare function getNonAssociationElementNames<T, K extends keyof PickWritable<T>>(ctor: Type<T>): K[];
|
|
6
|
-
export declare function mixinEntities<A, B>(derivedCtor: Type<A>, baseB: Type<B>): Type<A & B>;
|
|
7
|
-
export declare function mixinEntities<A, B, C>(derivedCtor: Type<A>, baseB: Type<B>, baseC: Type<C>): Type<A & B & C>;
|
|
8
|
-
export declare function mixinEntities<A, B, C, D>(derivedCtor: Type<A>, baseB: Type<B>, baseC: Type<C>, baseD: Type<D>): Type<A & B & C & D>;
|
|
9
|
-
export declare function mixinEntities<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>;
|
|
10
|
-
export declare function mixinEntities<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>;
|
|
11
|
-
export declare const OmitEntity: typeof Entity.Omit;
|
|
12
|
-
export declare const PickEntity: typeof Entity.Pick;
|
|
13
|
-
export declare const UnionEntity: typeof Entity.Union;
|
package/esm/orm/base-entity.d.ts
DELETED
|
@@ -1,14 +0,0 @@
|
|
|
1
|
-
import { JoinStatement, LogicalOperator } from '@sqb/builder';
|
|
2
|
-
import { AssociationNode } from '../model/association-node.js';
|
|
3
|
-
import { EntityMetadata } from '../model/entity-metadata.js';
|
|
4
|
-
export interface JoinInfo {
|
|
5
|
-
association: AssociationNode;
|
|
6
|
-
sourceEntity: EntityMetadata;
|
|
7
|
-
targetEntity: EntityMetadata;
|
|
8
|
-
joinAlias: string;
|
|
9
|
-
join: JoinStatement;
|
|
10
|
-
}
|
|
11
|
-
export declare function joinAssociationGetFirst(joinInfos: JoinInfo[], association: AssociationNode, parentAlias: string, innerJoin?: boolean): Promise<JoinInfo>;
|
|
12
|
-
export declare function joinAssociationGetLast(joinInfos: JoinInfo[], association: AssociationNode, parentAlias: string, innerJoin?: boolean): Promise<JoinInfo>;
|
|
13
|
-
export declare function joinAssociation(joinInfos: JoinInfo[], association: AssociationNode, parentAlias: string, innerJoin?: boolean): Promise<JoinInfo[]>;
|
|
14
|
-
export declare function prepareFilter(entityDef: EntityMetadata, filter: any, trgOp: LogicalOperator, tableAlias?: string): Promise<void>;
|
|
@@ -1,11 +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 CountCommandArgs = {
|
|
5
|
-
entity: EntityMetadata;
|
|
6
|
-
connection: SqbConnection;
|
|
7
|
-
} & Repository.CountOptions;
|
|
8
|
-
export declare class CountCommand {
|
|
9
|
-
protected constructor();
|
|
10
|
-
static execute(args: CountCommandArgs): Promise<number>;
|
|
11
|
-
}
|
|
@@ -1,20 +0,0 @@
|
|
|
1
|
-
import { SqbConnection } from '../../client/sqb-connection.js';
|
|
2
|
-
import { EntityMetadata } from '../model/entity-metadata.js';
|
|
3
|
-
export type CreateCommandArgs = {
|
|
4
|
-
entity: EntityMetadata;
|
|
5
|
-
connection: SqbConnection;
|
|
6
|
-
values: any;
|
|
7
|
-
returning?: boolean;
|
|
8
|
-
};
|
|
9
|
-
type CreateCommandContext = {
|
|
10
|
-
entity: EntityMetadata;
|
|
11
|
-
queryParams: any;
|
|
12
|
-
queryValues: any;
|
|
13
|
-
colCount: number;
|
|
14
|
-
};
|
|
15
|
-
export declare class CreateCommand {
|
|
16
|
-
protected constructor();
|
|
17
|
-
static execute(args: CreateCommandArgs): Promise<any>;
|
|
18
|
-
protected static _prepareParams(ctx: CreateCommandContext, entity: EntityMetadata, values: any, prefix?: string, suffix?: string): Promise<void>;
|
|
19
|
-
}
|
|
20
|
-
export {};
|
|
@@ -1,11 +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 DestroyCommandArgs = {
|
|
5
|
-
entity: EntityMetadata;
|
|
6
|
-
connection: SqbConnection;
|
|
7
|
-
} & Repository.DeleteManyOptions;
|
|
8
|
-
export declare class DeleteCommand {
|
|
9
|
-
protected constructor();
|
|
10
|
-
static execute(args: DestroyCommandArgs): Promise<number>;
|
|
11
|
-
}
|
|
@@ -1,44 +0,0 @@
|
|
|
1
|
-
import { SqbConnection } from '../../client/sqb-connection.js';
|
|
2
|
-
import { AssociationNode } from '../model/association-node.js';
|
|
3
|
-
import { EntityMetadata } from '../model/entity-metadata.js';
|
|
4
|
-
import { Repository } from '../repository.class.js';
|
|
5
|
-
import { RowConverter } from './row-converter.js';
|
|
6
|
-
export type FindCommandArgs = {
|
|
7
|
-
entity: EntityMetadata;
|
|
8
|
-
connection: SqbConnection;
|
|
9
|
-
} & Repository.FindManyOptions;
|
|
10
|
-
export declare class FindCommand {
|
|
11
|
-
maxEagerFetch: number;
|
|
12
|
-
maxSubQueries: number;
|
|
13
|
-
readonly mainEntity: EntityMetadata;
|
|
14
|
-
readonly resultEntity: EntityMetadata;
|
|
15
|
-
readonly converter: RowConverter;
|
|
16
|
-
readonly mainAlias: string;
|
|
17
|
-
resultAlias: string;
|
|
18
|
-
private _joins;
|
|
19
|
-
private _selectColumns;
|
|
20
|
-
private _filter;
|
|
21
|
-
private _sort?;
|
|
22
|
-
protected constructor(selectEntity: EntityMetadata, outputEntity: EntityMetadata);
|
|
23
|
-
static create(source: EntityMetadata | AssociationNode, opts?: {
|
|
24
|
-
maxSubQueries?: number;
|
|
25
|
-
maxEagerFetch?: number;
|
|
26
|
-
}): Promise<FindCommand>;
|
|
27
|
-
static execute(args: FindCommandArgs): Promise<any[]>;
|
|
28
|
-
addFields(opts?: {
|
|
29
|
-
tableAlias?: string;
|
|
30
|
-
converter?: RowConverter;
|
|
31
|
-
entity?: EntityMetadata;
|
|
32
|
-
pick?: string[];
|
|
33
|
-
omit?: string[];
|
|
34
|
-
include?: string[];
|
|
35
|
-
sort?: string[];
|
|
36
|
-
prefix?: string;
|
|
37
|
-
suffix?: string;
|
|
38
|
-
}): Promise<void>;
|
|
39
|
-
private _selectColumn;
|
|
40
|
-
filter(filter: any): Promise<void>;
|
|
41
|
-
sort(sortFields: string[]): Promise<void>;
|
|
42
|
-
execute(args: Pick<FindCommandArgs, 'connection' | 'distinct' | 'offset' | 'limit' | 'params' | 'onTransformRow'>): Promise<any[]>;
|
|
43
|
-
private _getEntityFromAlias;
|
|
44
|
-
}
|
|
@@ -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 {};
|