@sqb/connect 4.26.1 → 5.0.1

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.
@@ -1,5 +1,5 @@
1
- import { classes } from '@sqb/builder';
2
- import { Maybe } from 'ts-gems';
1
+ import { Query } from '@sqb/builder';
2
+ import type { Maybe } from 'ts-gems';
3
3
  import { type ClientConfiguration, DataType, type QueryRequest, type RowType } from './types.js';
4
4
  export interface Adapter {
5
5
  driver: string;
@@ -26,7 +26,7 @@ export declare namespace Adapter {
26
26
  rollback: () => Promise<void>;
27
27
  setSchema?: (schema: string) => Promise<void>;
28
28
  getSchema?: () => Promise<string>;
29
- onGenerateQuery?: (request: QueryRequest, query: classes.Query) => void;
29
+ onGenerateQuery?: (request: QueryRequest, query: Query) => void;
30
30
  getInTransaction?: () => boolean;
31
31
  }
32
32
  interface Cursor {
@@ -1,5 +1,5 @@
1
1
  import type { Adapter } from './adapter.js';
2
- import { CursorStream, CursorStreamOptions } from './cursor-stream.js';
2
+ import { CursorStream, type CursorStreamOptions } from './cursor-stream.js';
3
3
  import type { FieldInfoMap } from './field-info-map.js';
4
4
  import type { SqbConnection } from './sqb-connection.js';
5
5
  import type { ObjectRow, QueryRequest } from './types.js';
@@ -1,4 +1,4 @@
1
- import { FieldInfo } from './types.js';
1
+ import type { FieldInfo } from './types.js';
2
2
  export declare class FieldInfoMap {
3
3
  private _obj;
4
4
  private _arr;
@@ -1,4 +1,4 @@
1
- import { Maybe } from 'ts-gems';
1
+ import type { Maybe } from 'ts-gems';
2
2
  import type { Adapter } from './adapter.js';
3
3
  import { FieldInfoMap } from './field-info-map.js';
4
4
  import type { ArrayRowset, FieldNaming, ObjectRowset, QueryRequest } from './types.js';
@@ -1,6 +1,6 @@
1
- import { classes } from '@sqb/builder';
1
+ import type { Query } from '@sqb/builder';
2
2
  import { Pool as LightningPool } from 'lightning-pool';
3
- import { Maybe, Type } from 'ts-gems';
3
+ import type { Maybe, Type } from 'ts-gems';
4
4
  import { Repository } from '../orm/repository.class.js';
5
5
  import { SqbConnection } from './sqb-connection.js';
6
6
  import type { ClientConfiguration, ClientDefaults, ConnectionOptions, QueryExecuteOptions, QueryRequest, QueryResult, TransactionFunction } from './types.js';
@@ -50,7 +50,7 @@ export declare class SqbClient extends SqbClient_base {
50
50
  /**
51
51
  * Executes a query or callback with a new acquired connection.
52
52
  */
53
- execute(query: string | classes.Query, options?: QueryExecuteOptions): Promise<QueryResult>;
53
+ execute(query: string | Query, options?: QueryExecuteOptions): Promise<QueryResult>;
54
54
  /**
55
55
  * Tests the pool
56
56
  */
@@ -1,4 +1,4 @@
1
- import { classes } from '@sqb/builder';
1
+ import { Query } from '@sqb/builder';
2
2
  import type { Type } from 'ts-gems';
3
3
  import { Repository } from '../orm/repository.class.js';
4
4
  import type { Adapter } from './adapter.js';
@@ -52,7 +52,7 @@ export declare class SqbConnection extends SqbConnection_base {
52
52
  * Immediately releases the connection.
53
53
  */
54
54
  close(): Promise<void>;
55
- execute(query: string | classes.Query, options?: QueryExecuteOptions): Promise<any>;
55
+ execute(query: string | Query, options?: QueryExecuteOptions): Promise<any>;
56
56
  getRepository<T>(entity: Type<T> | string, opts?: {
57
57
  schema?: string;
58
58
  }): Repository<T>;
@@ -61,7 +61,7 @@ export declare class SqbConnection extends SqbConnection_base {
61
61
  /**
62
62
  * Executes a query
63
63
  */
64
- protected _execute(query: string | classes.Query, options?: QueryExecuteOptions): Promise<any>;
64
+ protected _execute(query: string | Query, options?: QueryExecuteOptions): Promise<any>;
65
65
  startTransaction(): Promise<void>;
66
66
  commit(): Promise<void>;
67
67
  rollback(): Promise<void>;
@@ -1,4 +1,4 @@
1
- import { classes } from '@sqb/builder';
1
+ import { Query } from '@sqb/builder';
2
2
  import assert from 'assert';
3
3
  import _debug from 'debug';
4
4
  import { TaskQueue } from 'power-tasks';
@@ -253,7 +253,7 @@ export class SqbConnection extends TypedEventEmitterClass(AsyncEventEmitter) {
253
253
  fetchAsString: options.fetchAsString,
254
254
  };
255
255
  request.ignoreNulls = request.ignoreNulls && request.objectRows;
256
- if (query instanceof classes.Query) {
256
+ if (query instanceof Query) {
257
257
  if (this._intlcon.onGenerateQuery)
258
258
  this._intlcon.onGenerateQuery(request, query);
259
259
  const q = query.generate({
@@ -1,5 +1,5 @@
1
1
  import { Query } from '@sqb/builder';
2
- import { QueryExecuteOptions, QueryRequest } from './types.js';
2
+ import type { QueryExecuteOptions, QueryRequest } from './types.js';
3
3
  export declare class SQBError extends Error {
4
4
  cause?: Error;
5
5
  query: string | Query;
package/client/types.d.ts CHANGED
@@ -1,6 +1,6 @@
1
- import { DataType, ParamOptions } from '@sqb/builder';
1
+ import { DataType, type ParamOptions } from '@sqb/builder';
2
2
  import type { PoolConfiguration } from 'lightning-pool';
3
- import { Maybe } from 'ts-gems';
3
+ import type { Maybe } from 'ts-gems';
4
4
  import type { Adapter } from './adapter.js';
5
5
  import type { Cursor } from './cursor.js';
6
6
  import type { FieldInfoMap } from './field-info-map.js';
package/index.d.ts CHANGED
@@ -6,7 +6,6 @@ export * from './client/sqb-client.js';
6
6
  export * from './client/sqb-connection.js';
7
7
  export * from './client/sqb-error.js';
8
8
  export * from './client/types.js';
9
- export * from './orm/backward.js';
10
9
  export * from './orm/base-entity.js';
11
10
  export * from './orm/decorators/column.decorator.js';
12
11
  export * from './orm/decorators/embedded.decorator.js';
package/index.js CHANGED
@@ -6,7 +6,6 @@ export * from './client/sqb-client.js';
6
6
  export * from './client/sqb-connection.js';
7
7
  export * from './client/sqb-error.js';
8
8
  export * from './client/types.js';
9
- export * from './orm/backward.js';
10
9
  export * from './orm/base-entity.js';
11
10
  export * from './orm/decorators/column.decorator.js';
12
11
  export * from './orm/decorators/embedded.decorator.js';
@@ -1,4 +1,4 @@
1
- import { JoinStatement, LogicalOperator } from '@sqb/builder';
1
+ import { type Join, LogicalOperator } from '@sqb/builder';
2
2
  import { AssociationNode } from '../model/association-node.js';
3
3
  import { EntityMetadata } from '../model/entity-metadata.js';
4
4
  export interface JoinInfo {
@@ -7,7 +7,7 @@ export interface JoinInfo {
7
7
  targetEntity: EntityMetadata;
8
8
  joinAlias: string;
9
9
  parentAlias: string;
10
- join: JoinStatement;
10
+ join: Join;
11
11
  }
12
12
  export declare function joinAssociationGetFirst(joinInfos: JoinInfo[], association: AssociationNode, parentAlias: string, innerJoin?: boolean): Promise<JoinInfo>;
13
13
  export declare function joinAssociationGetLast(joinInfos: JoinInfo[], association: AssociationNode, parentAlias: string, innerJoin?: boolean): Promise<JoinInfo>;
@@ -1,4 +1,4 @@
1
- import { And, Eq, Exists, Field, InnerJoin, isCompOperator, isLogicalOperator, LeftOuterJoin, op, OperatorType, Raw, Select, } from '@sqb/builder';
1
+ import { And, Eq, Exists, Field, InnerJoin, isCompOperator, isLogicalOperator, LeftOuterJoin, OperatorType, Or, Raw, Select, } from '@sqb/builder';
2
2
  import { EntityMetadata } from '../model/entity-metadata.js';
3
3
  import { isAssociationField, isColumnField, isEmbeddedField, resolveEntityForEmbeddedField, } from '../util/orm.helper.js';
4
4
  export async function joinAssociationGetFirst(joinInfos, association, parentAlias, innerJoin) {
@@ -122,7 +122,7 @@ export async function prepareFilter(entityDef, filter, trgOp, tableAlias = 'T')
122
122
  subSelect.where(Eq(Field('K.' + targetCol.fieldName, targetCol.dataType, targetCol.isArray), Field(tableAlias + '.' + keyCol.fieldName, keyCol.dataType, keyCol.isArray)));
123
123
  currentOp.add(Exists(subSelect));
124
124
  if (currentOp._operatorType !== OperatorType.and) {
125
- currentOp = op.or();
125
+ currentOp = Or();
126
126
  subSelect.where(currentOp);
127
127
  }
128
128
  else
@@ -1,8 +1,8 @@
1
1
  import { DataType } from '@sqb/builder';
2
- import { Type } from 'ts-gems';
2
+ import type { Type } from 'ts-gems';
3
3
  import type { FieldInfoMap } from '../../client/field-info-map.js';
4
4
  import type { SqbConnection } from '../../client/sqb-connection.js';
5
- import { ColumnTransformFunction } from '../orm.type.js';
5
+ import type { ColumnTransformFunction } from '../orm.type.js';
6
6
  import type { Repository } from '../repository.class.js';
7
7
  import type { FindCommand } from './find.command.js';
8
8
  export interface ValueProperty {
@@ -1,5 +1,5 @@
1
1
  import { DataType } from '@sqb/builder';
2
- import { ColumnFieldOptions } from '../model/column-field-metadata.js';
2
+ import type { ColumnFieldOptions } from '../model/column-field-metadata.js';
3
3
  export declare function Column(type?: DataType): PropertyDecorator;
4
4
  export declare function Column(options?: ColumnFieldOptions): PropertyDecorator;
5
5
  export declare namespace Column { }
@@ -1,3 +1,3 @@
1
- import { EmbeddedFieldOptions } from '../model/embedded-field-metadata.js';
2
- import { TypeThunk } from '../orm.type.js';
1
+ import type { EmbeddedFieldOptions } from '../model/embedded-field-metadata.js';
2
+ import type { TypeThunk } from '../orm.type.js';
3
3
  export declare function Embedded(type?: TypeThunk, options?: EmbeddedFieldOptions): PropertyDecorator;
@@ -1,9 +1,9 @@
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';
1
+ import type { Maybe, Type } from 'ts-gems';
2
+ import type { AssociationFieldMetadata } from '../model/association-field-metadata.js';
3
+ import type { ColumnFieldMetadata } from '../model/column-field-metadata.js';
4
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';
5
+ import { type AnyFieldMetadata, EntityMetadata, type EntityOptions } from '../model/entity-metadata.js';
6
+ import type { IndexMetadata } from '../model/index-metadata.js';
7
7
  export declare function Entity(options?: EntityOptions | string): ClassDecorator;
8
8
  export declare namespace Entity {
9
9
  const getMetadata: typeof EntityMetadata.get;
@@ -1,2 +1,2 @@
1
- import { TypeThunk } from '../orm.type.js';
1
+ import type { TypeThunk } from '../orm.type.js';
2
2
  export declare function ForeignKey(type: TypeThunk, targetKey?: string): PropertyDecorator;
@@ -1,3 +1,3 @@
1
- import { IndexMetadata } from '../model/index-metadata.js';
1
+ import type { IndexMetadata } from '../model/index-metadata.js';
2
2
  export declare function Index(fields: string | string[], options?: Omit<IndexMetadata, 'columns'>): ClassDecorator;
3
3
  export declare function Index(options?: Omit<IndexMetadata, 'columns'>): PropertyDecorator;
@@ -1,5 +1,5 @@
1
- import { AssociationFieldOptions } from '../model/association-field-metadata.js';
2
- import { TypeThunk } from '../orm.type.js';
1
+ import type { AssociationFieldOptions } from '../model/association-field-metadata.js';
2
+ import type { TypeThunk } from '../orm.type.js';
3
3
  type LinkArgs<T> = {
4
4
  sourceKey?: string;
5
5
  targetKey?: keyof T;
@@ -1,3 +1,3 @@
1
- import { IndexMetadata } from '../model/index-metadata.js';
1
+ import type { IndexMetadata } from '../model/index-metadata.js';
2
2
  export declare function PrimaryKey(fields: string | string[], options?: Omit<IndexMetadata, 'columns' | 'unique' | 'primary'>): ClassDecorator;
3
3
  export declare function PrimaryKey(options?: Omit<IndexMetadata, 'columns' | 'unique' | 'primary'>): PropertyDecorator;
@@ -1,3 +1,3 @@
1
- import { ColumnTransformFunction } from '../orm.type.js';
1
+ import type { ColumnTransformFunction } from '../orm.type.js';
2
2
  export declare function Parse(fn: ColumnTransformFunction): PropertyDecorator;
3
3
  export declare function Serialize(fn: ColumnTransformFunction): PropertyDecorator;
@@ -1,5 +1,5 @@
1
1
  import { AssociationNode } from './association-node.js';
2
- import { FieldMetadata } from './field-metadata.js';
2
+ import type { FieldMetadata } from './field-metadata.js';
3
3
  export type AssociationFieldOptions = Partial<Omit<AssociationFieldMetadata, 'entity' | 'name' | 'kind' | 'association'>>;
4
4
  export interface AssociationFieldMetadata extends FieldMetadata {
5
5
  readonly kind: 'association';
@@ -1,6 +1,6 @@
1
1
  import { DataType } from '@sqb/builder';
2
2
  import type { ColumnAutoGenerationStrategy, ColumnTransformFunction, DefaultValueGetter, EnumValue, FieldValue } from '../orm.type.js';
3
- import { FieldMetadata } from './field-metadata.js';
3
+ import type { FieldMetadata } from './field-metadata.js';
4
4
  export type ColumnFieldOptions = Partial<Omit<ColumnFieldMetadata, 'entity' | 'name' | 'kind'>>;
5
5
  export interface ColumnFieldMetadata extends FieldMetadata {
6
6
  readonly kind: 'column';
@@ -1,6 +1,6 @@
1
- import { TypeThunk } from '../orm.type.js';
1
+ import type { TypeThunk } from '../orm.type.js';
2
2
  import type { EntityMetadata } from './entity-metadata.js';
3
- import { FieldMetadata } from './field-metadata.js';
3
+ import type { FieldMetadata } from './field-metadata.js';
4
4
  export type EmbeddedFieldOptions = Partial<Omit<EmbeddedFieldMetadata, 'entity' | 'name' | 'kind' | 'type'>>;
5
5
  export interface EmbeddedFieldMetadata extends FieldMetadata {
6
6
  readonly kind: 'object';
@@ -1,11 +1,11 @@
1
- import { Maybe, Type } from 'ts-gems';
2
- import { Ctor, TypeThunk } from '../orm.type.js';
1
+ import type { Maybe, Type } from 'ts-gems';
2
+ import type { Ctor, TypeThunk } from '../orm.type.js';
3
3
  import { Association } from './association.js';
4
4
  import type { AssociationFieldMetadata, AssociationFieldOptions } from './association-field-metadata.js';
5
5
  import { AssociationNode } from './association-node.js';
6
6
  import type { ColumnFieldMetadata, ColumnFieldOptions } from './column-field-metadata.js';
7
7
  import type { EmbeddedFieldMetadata, EmbeddedFieldOptions } from './embedded-field-metadata.js';
8
- import { IndexMetadata } from './index-metadata.js';
8
+ import type { IndexMetadata } from './index-metadata.js';
9
9
  export type AnyFieldMetadata = ColumnFieldMetadata | EmbeddedFieldMetadata | AssociationFieldMetadata;
10
10
  export type EntityOptions = Partial<Pick<EntityMetadata, 'name' | 'schema' | 'comment' | 'tableName'>>;
11
11
  export interface EntityMetadata {
@@ -1,5 +1,5 @@
1
- import { Type } from 'ts-gems';
2
- import { TypeResolver, TypeThunk } from '../orm.type.js';
1
+ import type { Type } from 'ts-gems';
2
+ import type { TypeResolver, TypeThunk } from '../orm.type.js';
3
3
  import { AssociationNode } from './association-node.js';
4
4
  export declare class LinkChain<T> {
5
5
  target: TypeThunk<T>;
package/orm/orm.type.d.ts CHANGED
@@ -1,4 +1,4 @@
1
- import { Type } from 'ts-gems';
1
+ import type { Type } from 'ts-gems';
2
2
  export type Ctor = Type | Function;
3
3
  export type FieldKind = 'column' | 'object' | 'association';
4
4
  /**
@@ -1,10 +1,9 @@
1
- import { LogicalOperator } from '@sqb/builder';
2
- import { OptimizerHintArgs } from '@sqb/builder/build/sql-objects/table-name';
3
- import { PartialDTO, PatchDTO, RequiredSome, StrictOmit, Type } from 'ts-gems';
1
+ import { LogicalOperator, type TableName } from '@sqb/builder';
2
+ import type { PartialDTO, PatchDTO, RequiredSome, StrictOmit, Type } from 'ts-gems';
4
3
  import { FieldInfoMap } from '../client/field-info-map.js';
5
4
  import type { SqbClient } from '../client/sqb-client.js';
6
5
  import type { SqbConnection } from '../client/sqb-connection.js';
7
- import { QueryRequest, TransactionFunction } from '../client/types.js';
6
+ import type { QueryRequest, TransactionFunction } from '../client/types.js';
8
7
  import { EntityMetadata } from './model/entity-metadata.js';
9
8
  interface Projection {
10
9
  projection?: string | string[];
@@ -25,7 +24,7 @@ export declare namespace Repository {
25
24
  comment: string;
26
25
  dialect?: string[];
27
26
  }[];
28
- optimizerHint?: string | string[] | OptimizerHintArgs | OptimizerHintArgs[];
27
+ optimizerHint?: string | string[] | TableName.OptimizerHint | TableName.OptimizerHint[];
29
28
  }
30
29
  interface CreateOptions extends CommandOptions, Projection {
31
30
  }
@@ -1,4 +1,4 @@
1
- import { Type } from 'ts-gems';
1
+ import type { Type } from 'ts-gems';
2
2
  import type { AssociationFieldMetadata } from '../model/association-field-metadata.js';
3
3
  import type { ColumnFieldMetadata } from '../model/column-field-metadata.js';
4
4
  import type { EmbeddedFieldMetadata } from '../model/embedded-field-metadata.js';
@@ -1,2 +1,2 @@
1
- import { FieldMetadata } from '../model/field-metadata.js';
1
+ import type { FieldMetadata } from '../model/field-metadata.js';
2
2
  export declare function serializeColumn(col: FieldMetadata, v: any): any;
package/package.json CHANGED
@@ -1,7 +1,7 @@
1
1
  {
2
2
  "name": "@sqb/connect",
3
3
  "description": "Multi-dialect database connection framework written with TypeScript",
4
- "version": "4.26.1",
4
+ "version": "5.0.1",
5
5
  "author": "Panates",
6
6
  "license": "Apache-2.0",
7
7
  "dependencies": {
@@ -17,11 +17,11 @@
17
17
  "putil-promisify": "^1.10.1",
18
18
  "putil-varhelpers": "^1.7.0",
19
19
  "strict-typed-events": "^2.8.0",
20
- "ts-gems": "^3.11.6",
20
+ "ts-gems": "^3.12.0",
21
21
  "tslib": "^2.8.1"
22
22
  },
23
23
  "peerDependencies": {
24
- "@sqb/builder": "^4.26.1",
24
+ "@sqb/builder": "^5.0.1",
25
25
  "reflect-metadata": "^0.2.2"
26
26
  },
27
27
  "type": "module",
package/orm/backward.d.ts DELETED
@@ -1,13 +0,0 @@
1
- import { MutableKeys, Type } from 'ts-gems';
2
- import { Entity } from './decorators/entity.decorator.js';
3
- export declare function getInsertColumnNames<T, K extends MutableKeys<T>>(ctor: Type<T>): K[];
4
- export declare function getUpdateColumnNames<T, K extends MutableKeys<T>>(ctor: Type<T>): K[];
5
- export declare function getNonAssociationElementNames<T, K extends MutableKeys<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/orm/backward.js DELETED
@@ -1,17 +0,0 @@
1
- import { Entity } from './decorators/entity.decorator.js';
2
- export function getInsertColumnNames(ctor) {
3
- return Entity.getInsertColumnNames(ctor);
4
- }
5
- export function getUpdateColumnNames(ctor) {
6
- return Entity.getUpdateColumnNames(ctor);
7
- }
8
- export function getNonAssociationElementNames(ctor) {
9
- return Entity.getNonAssociationFieldNames(ctor);
10
- }
11
- export function mixinEntities(derivedCtor, ...bases) {
12
- // @ts-ignore
13
- return Entity.mixin(derivedCtor, ...bases);
14
- }
15
- export const OmitEntity = Entity.Omit;
16
- export const PickEntity = Entity.Pick;
17
- export const UnionEntity = Entity.Union;