@sqb/connect 4.5.4 → 4.5.6

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.
@@ -105,6 +105,8 @@ class Repository extends (0, strict_typed_events_1.TypedEventEmitterClass)(stric
105
105
  });
106
106
  }
107
107
  async _create(values, options) {
108
+ if (!values)
109
+ throw new TypeError('You must provide values');
108
110
  await this._emit('before-create', values, options);
109
111
  const keyValues = await create_command_js_1.CreateCommand.execute({
110
112
  ...options,
@@ -119,6 +121,8 @@ class Repository extends (0, strict_typed_events_1.TypedEventEmitterClass)(stric
119
121
  return result;
120
122
  }
121
123
  async _createOnly(values, options) {
124
+ if (!values)
125
+ throw new TypeError('You must provide values');
122
126
  await this._emit('before-create', values, options);
123
127
  await create_command_js_1.CreateCommand.execute({
124
128
  ...options,
@@ -200,6 +204,8 @@ class Repository extends (0, strict_typed_events_1.TypedEventEmitterClass)(stric
200
204
  return rowsAffected;
201
205
  }
202
206
  async _update(keyValue, values, options) {
207
+ if (!values)
208
+ throw new TypeError('You must provide values');
203
209
  await this._emit('before-update', keyValue, values, options);
204
210
  const keyValues = (0, extract_keyvalues_js_1.extractKeyValues)(this._entity, keyValue, true);
205
211
  const filter = [keyValues];
@@ -221,6 +227,8 @@ class Repository extends (0, strict_typed_events_1.TypedEventEmitterClass)(stric
221
227
  return rowsAffected ? keyValues : undefined;
222
228
  }
223
229
  async _updateAll(values, options) {
230
+ if (!values)
231
+ throw new TypeError('You must provide values');
224
232
  await this._emit('before-update-all', values, options);
225
233
  const rowsAffected = await update_command_js_1.UpdateCommand.execute({
226
234
  ...options,
@@ -6,16 +6,16 @@ import type { Cursor } from './cursor';
6
6
  import type { FieldInfoMap } from './field-info-map';
7
7
  import type { SqbConnection } from './sqb-connection';
8
8
  export { DataType } from '@sqb/builder';
9
- export declare type ExecuteHookFunction = (connection: SqbConnection, request: QueryRequest) => Promise<void>;
10
- export declare type FetchFunction = (row: any, request: QueryRequest) => void;
11
- export declare type ValueTransformFunction = (value: any, fieldInfo?: FieldInfo) => any;
12
- export declare type TransactionFunction = (connection: SqbConnection) => Promise<any>;
13
- export declare type RowType = 'array' | 'object';
14
- export declare type FieldNaming = 'original' | 'lowercase' | 'uppercase' | 'camelcase' | 'pascalcase' | ((fieldName: string) => Maybe<string>);
15
- export declare type ObjectRow = Record<string, any>;
16
- export declare type ArrayRow = any[];
17
- export declare type ObjectRowset = ObjectRow[];
18
- export declare type ArrayRowset = ArrayRow[];
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
19
  export interface ClientConfiguration {
20
20
  /**
21
21
  * Dialect to be used
@@ -151,7 +151,7 @@ export interface QueryResult {
151
151
  rowsAffected?: number;
152
152
  cursor?: Cursor;
153
153
  }
154
- export declare type FieldInfo = {
154
+ export type FieldInfo = {
155
155
  index: number;
156
156
  name: string;
157
157
  } & Adapter.Field;
package/esm/index.d.ts CHANGED
@@ -1,5 +1,6 @@
1
1
  import 'reflect-metadata';
2
- export { Type, Maybe, DeepPartial, DeepPickWritable, DeepBuildable } from 'ts-gems';
2
+ import { DeepBuildable, DeepPartial, DeepPickWritable, Maybe, Type } from 'ts-gems';
3
+ export { Type, Maybe, DeepPartial, DeepPickWritable, DeepBuildable };
3
4
  export * from './types.js';
4
5
  export * from './client/types.js';
5
6
  export * from './client/adapter.js';
@@ -1,7 +1,7 @@
1
1
  import { SqbConnection } from '../../client/sqb-connection.js';
2
2
  import { EntityMetadata } from '../model/entity-metadata.js';
3
3
  import { Repository } from '../repository.class.js';
4
- export declare type CountCommandArgs = {
4
+ export type CountCommandArgs = {
5
5
  entity: EntityMetadata;
6
6
  connection: SqbConnection;
7
7
  } & Repository.CountOptions;
@@ -1,12 +1,12 @@
1
1
  import { SqbConnection } from '../../client/sqb-connection.js';
2
2
  import { EntityMetadata } from '../model/entity-metadata.js';
3
- export declare type CreateCommandArgs = {
3
+ export type CreateCommandArgs = {
4
4
  entity: EntityMetadata;
5
5
  connection: SqbConnection;
6
6
  values: any;
7
7
  returning?: boolean;
8
8
  };
9
- declare type CreateCommandContext = {
9
+ type CreateCommandContext = {
10
10
  entity: EntityMetadata;
11
11
  queryParams: any;
12
12
  queryValues: any;
@@ -1,7 +1,7 @@
1
1
  import { SqbConnection } from '../../client/sqb-connection.js';
2
2
  import { EntityMetadata } from '../model/entity-metadata.js';
3
3
  import { Repository } from '../repository.class.js';
4
- export declare type DestroyCommandArgs = {
4
+ export type DestroyCommandArgs = {
5
5
  entity: EntityMetadata;
6
6
  connection: SqbConnection;
7
7
  } & Repository.DestroyOptions;
@@ -3,7 +3,7 @@ import { AssociationNode } from '../model/association-node.js';
3
3
  import { EntityMetadata } from '../model/entity-metadata.js';
4
4
  import { Repository } from '../repository.class.js';
5
5
  import { RowConverter } from './row-converter.js';
6
- export declare type FindCommandArgs = {
6
+ export type FindCommandArgs = {
7
7
  entity: EntityMetadata;
8
8
  connection: SqbConnection;
9
9
  } & Repository.FindAllOptions;
@@ -1,12 +1,12 @@
1
1
  import { SqbConnection } from '../../client/sqb-connection.js';
2
2
  import { EntityMetadata } from '../model/entity-metadata.js';
3
3
  import { Repository } from '../repository.class.js';
4
- export declare type UpdateCommandArgs = {
4
+ export type UpdateCommandArgs = {
5
5
  entity: EntityMetadata;
6
6
  connection: SqbConnection;
7
7
  values: any;
8
8
  } & Repository.UpdateAllOptions;
9
- declare type UpdateCommandContext = {
9
+ type UpdateCommandContext = {
10
10
  entity: EntityMetadata;
11
11
  queryParams: any;
12
12
  queryValues: any;
@@ -1,11 +1,11 @@
1
1
  import { AssociationFieldOptions } from '../model/association-field-metadata.js';
2
2
  import { TypeThunk } from '../orm.type.js';
3
- declare type LinkArgs<T> = {
3
+ type LinkArgs<T> = {
4
4
  sourceKey?: string;
5
5
  targetKey?: keyof T;
6
6
  where?: object | object[];
7
7
  };
8
- declare type LinkPropertyDecorator = PropertyDecorator & {
8
+ type LinkPropertyDecorator = PropertyDecorator & {
9
9
  toOne<T>(type: TypeThunk<T>, args?: LinkArgs<T>): LinkPropertyDecorator;
10
10
  toMany<T>(type: TypeThunk<T>, args?: LinkArgs<T>): LinkPropertyDecorator;
11
11
  };
@@ -1,7 +1,7 @@
1
1
  import { AssociationNode } from './association-node.js';
2
2
  import { EntityMetadata } from './entity-metadata.js';
3
3
  import { FieldMetadata } from './field-metadata.js';
4
- export declare type AssociationFieldOptions = Partial<Omit<AssociationFieldMetadata, 'entity' | 'name' | 'kind' | 'association'>>;
4
+ export type AssociationFieldOptions = Partial<Omit<AssociationFieldMetadata, 'entity' | 'name' | 'kind' | 'association'>>;
5
5
  export interface AssociationFieldMetadata extends FieldMetadata {
6
6
  readonly kind: 'association';
7
7
  readonly association: AssociationNode;
@@ -2,7 +2,7 @@ import { DataType } from '@sqb/builder';
2
2
  import type { ColumnAutoGenerationStrategy, ColumnTransformFunction, DefaultValueGetter, EnumValue, FieldValue } from '../orm.type.js';
3
3
  import type { EntityMetadata } from './entity-metadata.js';
4
4
  import { FieldMetadata } from './field-metadata.js';
5
- export declare type ColumnFieldOptions = Partial<Omit<ColumnFieldMetadata, 'entity' | 'name' | 'kind'>>;
5
+ export type ColumnFieldOptions = Partial<Omit<ColumnFieldMetadata, 'entity' | 'name' | 'kind'>>;
6
6
  export interface ColumnFieldMetadata extends FieldMetadata {
7
7
  readonly kind: 'column';
8
8
  /**
@@ -1,7 +1,7 @@
1
1
  import { TypeThunk } from '../orm.type.js';
2
2
  import type { EntityMetadata } from './entity-metadata.js';
3
3
  import { FieldMetadata } from './field-metadata.js';
4
- export declare type EmbeddedFieldOptions = Partial<Omit<EmbeddedFieldMetadata, 'entity' | 'name' | 'kind' | 'type'>>;
4
+ export type EmbeddedFieldOptions = Partial<Omit<EmbeddedFieldMetadata, 'entity' | 'name' | 'kind' | 'type'>>;
5
5
  export interface EmbeddedFieldMetadata extends FieldMetadata {
6
6
  readonly kind: 'object';
7
7
  type: TypeThunk;
@@ -6,8 +6,8 @@ import { AssociationNode } from './association-node.js';
6
6
  import { ColumnFieldMetadata, ColumnFieldOptions } from './column-field-metadata.js';
7
7
  import { EmbeddedFieldMetadata, EmbeddedFieldOptions } from './embedded-field-metadata.js';
8
8
  import { IndexMetadata } from './index-metadata.js';
9
- export declare type AnyFieldMetadata = ColumnFieldMetadata | EmbeddedFieldMetadata | AssociationFieldMetadata;
10
- export declare type EntityOptions = Partial<Pick<EntityMetadata, 'name' | 'schema' | 'comment' | 'tableName'>>;
9
+ export type AnyFieldMetadata = ColumnFieldMetadata | EmbeddedFieldMetadata | AssociationFieldMetadata;
10
+ export type EntityOptions = Partial<Pick<EntityMetadata, 'name' | 'schema' | 'comment' | 'tableName'>>;
11
11
  export interface EntityMetadata {
12
12
  readonly ctor: Type;
13
13
  readonly name: string;
@@ -1,16 +1,16 @@
1
1
  import { Type } from 'ts-gems';
2
- export declare type Ctor = Type | Function;
3
- export declare type FieldKind = 'column' | 'object' | 'association';
2
+ export type Ctor = Type | Function;
3
+ export type FieldKind = 'column' | 'object' | 'association';
4
4
  /**
5
5
  * Indicates auto generation strategy
6
6
  */
7
- export declare type ColumnAutoGenerationStrategy = 'increment' | 'uuid' | 'rowid' | 'timestamp' | 'custom';
8
- export declare type ColumnTransformFunction = (value: any, name: string) => any;
9
- export declare type TypeResolver<T> = () => Type<T> | Promise<Type<T>>;
10
- export declare type TypeThunk<T = any> = Type<T> | TypeResolver<T>;
11
- export declare type EnumValue = (FieldValue)[] | Object;
12
- export declare type FieldValue = string | number | boolean | Date | null;
13
- export declare type DefaultValueGetter = (obj?: any) => FieldValue | undefined;
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
14
  export interface AssociationSettings {
15
15
  source: TypeThunk;
16
16
  target: TypeThunk;
@@ -102,6 +102,8 @@ export class Repository extends TypedEventEmitterClass(AsyncEventEmitter) {
102
102
  });
103
103
  }
104
104
  async _create(values, options) {
105
+ if (!values)
106
+ throw new TypeError('You must provide values');
105
107
  await this._emit('before-create', values, options);
106
108
  const keyValues = await CreateCommand.execute({
107
109
  ...options,
@@ -116,6 +118,8 @@ export class Repository extends TypedEventEmitterClass(AsyncEventEmitter) {
116
118
  return result;
117
119
  }
118
120
  async _createOnly(values, options) {
121
+ if (!values)
122
+ throw new TypeError('You must provide values');
119
123
  await this._emit('before-create', values, options);
120
124
  await CreateCommand.execute({
121
125
  ...options,
@@ -197,6 +201,8 @@ export class Repository extends TypedEventEmitterClass(AsyncEventEmitter) {
197
201
  return rowsAffected;
198
202
  }
199
203
  async _update(keyValue, values, options) {
204
+ if (!values)
205
+ throw new TypeError('You must provide values');
200
206
  await this._emit('before-update', keyValue, values, options);
201
207
  const keyValues = extractKeyValues(this._entity, keyValue, true);
202
208
  const filter = [keyValues];
@@ -218,6 +224,8 @@ export class Repository extends TypedEventEmitterClass(AsyncEventEmitter) {
218
224
  return rowsAffected ? keyValues : undefined;
219
225
  }
220
226
  async _updateAll(values, options) {
227
+ if (!values)
228
+ throw new TypeError('You must provide values');
221
229
  await this._emit('before-update-all', values, options);
222
230
  const rowsAffected = await UpdateCommand.execute({
223
231
  ...options,
package/esm/types.d.ts CHANGED
@@ -1,8 +1,8 @@
1
1
  import { Builtin, DeepPickWritable } from 'ts-gems';
2
- export declare type EntityInput<T> = DeepNullableIfPartial<DeepPickWritable<T>>;
3
- export declare type EntityOutput<T> = DeepNullableIfPartial<T>;
4
- export declare type DeepNullableIfPartial<T> = _DeepNullableIfPartial<T>;
5
- declare type _DeepNullableIfPartial<T> = T extends Builtin ? T : T extends Promise<infer U> ? Promise<DeepNullableIfPartial<U>> : T extends (infer U)[] ? DeepNullableIfPartial<U>[] : {
2
+ export type EntityInput<T> = DeepNullableIfPartial<DeepPickWritable<T>>;
3
+ export type EntityOutput<T> = DeepNullableIfPartial<T>;
4
+ export type DeepNullableIfPartial<T> = _DeepNullableIfPartial<T>;
5
+ type _DeepNullableIfPartial<T> = T extends Builtin ? T : T extends Promise<infer U> ? Promise<DeepNullableIfPartial<U>> : T extends (infer U)[] ? DeepNullableIfPartial<U>[] : {
6
6
  [P in keyof T]?: DeepNullableIfPartial<Exclude<T[P], undefined>> | null;
7
7
  };
8
8
  export {};
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.5.4",
4
+ "version": "4.5.6",
5
5
  "author": "Panates",
6
6
  "contributors": [
7
7
  "Eray Hanoglu <e.hanoglu@panates.com>",
@@ -30,23 +30,23 @@
30
30
  },
31
31
  "dependencies": {
32
32
  "debug": "^4.3.4",
33
- "lightning-pool": "^4.2.0",
33
+ "lightning-pool": "^4.2.1",
34
34
  "lodash": "^4.17.21",
35
- "putil-isplainobject": "^1.1.4",
36
- "putil-merge": "^3.9.0",
37
- "putil-promisify": "^1.8.5",
38
- "putil-taskqueue": "^2.5.4",
39
- "putil-varhelpers": "^1.6.4",
35
+ "putil-isplainobject": "^1.1.5",
36
+ "putil-merge": "^3.10.1",
37
+ "putil-promisify": "^1.10.0",
38
+ "putil-taskqueue": "^2.5.5",
39
+ "putil-varhelpers": "^1.6.5",
40
40
  "reflect-metadata": "^0.1.13",
41
41
  "strict-typed-events": "^2.3.1",
42
- "ts-gems": "^2.2.1"
42
+ "ts-gems": "^2.3.0"
43
43
  },
44
44
  "devDependencies": {
45
45
  "@types/debug": "^4.1.7",
46
- "@types/lodash": "^4.14.186"
46
+ "@types/lodash": "^4.14.191"
47
47
  },
48
48
  "peerDependencies": {
49
- "@sqb/builder": "^4.5.4"
49
+ "@sqb/builder": "^4.5.6"
50
50
  },
51
51
  "type": "module",
52
52
  "types": "esm/index.d.ts",