@hemia/db-connector 0.0.11 → 0.0.13

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.
@@ -2,7 +2,7 @@ import { createClient } from '@clickhouse/client';
2
2
  import { drizzle } from 'drizzle-orm/postgres-js';
3
3
  export { PostgresJsDatabase } from 'drizzle-orm/postgres-js';
4
4
  import { isNull as isNull$1, inArray as inArray$1, gt as gt$1, gte as gte$1, lt as lt$1, lte as lte$1, like as like$1, ilike as ilike$1, ne as ne$1, eq as eq$1, and as and$1 } from 'drizzle-orm';
5
- export { and, arrayContained, arrayContains, arrayOverlaps, asc, avg, avgDistinct, between, count, countDistinct, desc, eq, exists, gt, gte, ilike, inArray, isNotNull, isNull, like, lt, lte, max, min, ne, not, notBetween, notExists, notIlike, notInArray, notLike, or, sql, sum, sumDistinct } from 'drizzle-orm';
5
+ export { View, aliasedRelation, aliasedTable, aliasedTableColumn, and, arrayContained, arrayContains, arrayOverlaps, asc, avg, avgDistinct, between, count, countDistinct, desc, eq, exists, getOperators, getOrderByOperators, getTableColumns, getTableName, getTableUniqueName, getViewName, getViewSelectedFields, gt, gte, ilike, inArray, isConfig, isDriverValueEncoder, isNotNull, isNull, isSQLWrapper, isTable, isView, like, lt, lte, mapColumnsInAliasedSQLToAlias, mapColumnsInSQLToAlias, mapRelationalRow, max, min, ne, not, notBetween, notExists, notIlike, notInArray, notLike, or, sql, sum, sumDistinct } from 'drizzle-orm';
6
6
  import os from 'os';
7
7
  import fs from 'fs';
8
8
  import net from 'net';
@@ -3085,27 +3085,12 @@ class DrizzlePostgresConnector extends DrizzleSqlConnector {
3085
3085
  return __awaiter(this, void 0, void 0, function* () {
3086
3086
  this.ensureConnected();
3087
3087
  try {
3088
- yield this.connection `BEGIN`;
3089
- const txMock = {
3090
- commit: () => __awaiter(this, void 0, void 0, function* () {
3091
- yield this.connection `COMMIT`;
3092
- }),
3093
- rollback: () => __awaiter(this, void 0, void 0, function* () {
3094
- yield this.connection `ROLLBACK`;
3095
- })
3096
- };
3097
- try {
3098
- const result = yield fn(txMock);
3099
- yield this.connection `COMMIT`;
3100
- return result;
3101
- }
3102
- catch (error) {
3103
- yield this.connection `ROLLBACK`;
3104
- throw error;
3105
- }
3088
+ return yield this.db.transaction((tx) => __awaiter(this, void 0, void 0, function* () {
3089
+ return yield fn(tx);
3090
+ }));
3106
3091
  }
3107
3092
  catch (error) {
3108
- console.error(error);
3093
+ console.error("Transaction Error:", error);
3109
3094
  throw this.createDatabaseError(error);
3110
3095
  }
3111
3096
  });
@@ -3083,27 +3083,12 @@ class DrizzlePostgresConnector extends DrizzleSqlConnector {
3083
3083
  return __awaiter(this, void 0, void 0, function* () {
3084
3084
  this.ensureConnected();
3085
3085
  try {
3086
- yield this.connection `BEGIN`;
3087
- const txMock = {
3088
- commit: () => __awaiter(this, void 0, void 0, function* () {
3089
- yield this.connection `COMMIT`;
3090
- }),
3091
- rollback: () => __awaiter(this, void 0, void 0, function* () {
3092
- yield this.connection `ROLLBACK`;
3093
- })
3094
- };
3095
- try {
3096
- const result = yield fn(txMock);
3097
- yield this.connection `COMMIT`;
3098
- return result;
3099
- }
3100
- catch (error) {
3101
- yield this.connection `ROLLBACK`;
3102
- throw error;
3103
- }
3086
+ return yield this.db.transaction((tx) => __awaiter(this, void 0, void 0, function* () {
3087
+ return yield fn(tx);
3088
+ }));
3104
3089
  }
3105
3090
  catch (error) {
3106
- console.error(error);
3091
+ console.error("Transaction Error:", error);
3107
3092
  throw this.createDatabaseError(error);
3108
3093
  }
3109
3094
  });
@@ -9404,6 +9389,22 @@ Object.defineProperty(exports, "PostgresJsDatabase", {
9404
9389
  enumerable: true,
9405
9390
  get: function () { return postgresJs.PostgresJsDatabase; }
9406
9391
  });
9392
+ Object.defineProperty(exports, "View", {
9393
+ enumerable: true,
9394
+ get: function () { return drizzleOrm.View; }
9395
+ });
9396
+ Object.defineProperty(exports, "aliasedRelation", {
9397
+ enumerable: true,
9398
+ get: function () { return drizzleOrm.aliasedRelation; }
9399
+ });
9400
+ Object.defineProperty(exports, "aliasedTable", {
9401
+ enumerable: true,
9402
+ get: function () { return drizzleOrm.aliasedTable; }
9403
+ });
9404
+ Object.defineProperty(exports, "aliasedTableColumn", {
9405
+ enumerable: true,
9406
+ get: function () { return drizzleOrm.aliasedTableColumn; }
9407
+ });
9407
9408
  Object.defineProperty(exports, "and", {
9408
9409
  enumerable: true,
9409
9410
  get: function () { return drizzleOrm.and; }
@@ -9456,6 +9457,34 @@ Object.defineProperty(exports, "exists", {
9456
9457
  enumerable: true,
9457
9458
  get: function () { return drizzleOrm.exists; }
9458
9459
  });
9460
+ Object.defineProperty(exports, "getOperators", {
9461
+ enumerable: true,
9462
+ get: function () { return drizzleOrm.getOperators; }
9463
+ });
9464
+ Object.defineProperty(exports, "getOrderByOperators", {
9465
+ enumerable: true,
9466
+ get: function () { return drizzleOrm.getOrderByOperators; }
9467
+ });
9468
+ Object.defineProperty(exports, "getTableColumns", {
9469
+ enumerable: true,
9470
+ get: function () { return drizzleOrm.getTableColumns; }
9471
+ });
9472
+ Object.defineProperty(exports, "getTableName", {
9473
+ enumerable: true,
9474
+ get: function () { return drizzleOrm.getTableName; }
9475
+ });
9476
+ Object.defineProperty(exports, "getTableUniqueName", {
9477
+ enumerable: true,
9478
+ get: function () { return drizzleOrm.getTableUniqueName; }
9479
+ });
9480
+ Object.defineProperty(exports, "getViewName", {
9481
+ enumerable: true,
9482
+ get: function () { return drizzleOrm.getViewName; }
9483
+ });
9484
+ Object.defineProperty(exports, "getViewSelectedFields", {
9485
+ enumerable: true,
9486
+ get: function () { return drizzleOrm.getViewSelectedFields; }
9487
+ });
9459
9488
  Object.defineProperty(exports, "gt", {
9460
9489
  enumerable: true,
9461
9490
  get: function () { return drizzleOrm.gt; }
@@ -9472,6 +9501,14 @@ Object.defineProperty(exports, "inArray", {
9472
9501
  enumerable: true,
9473
9502
  get: function () { return drizzleOrm.inArray; }
9474
9503
  });
9504
+ Object.defineProperty(exports, "isConfig", {
9505
+ enumerable: true,
9506
+ get: function () { return drizzleOrm.isConfig; }
9507
+ });
9508
+ Object.defineProperty(exports, "isDriverValueEncoder", {
9509
+ enumerable: true,
9510
+ get: function () { return drizzleOrm.isDriverValueEncoder; }
9511
+ });
9475
9512
  Object.defineProperty(exports, "isNotNull", {
9476
9513
  enumerable: true,
9477
9514
  get: function () { return drizzleOrm.isNotNull; }
@@ -9480,6 +9517,18 @@ Object.defineProperty(exports, "isNull", {
9480
9517
  enumerable: true,
9481
9518
  get: function () { return drizzleOrm.isNull; }
9482
9519
  });
9520
+ Object.defineProperty(exports, "isSQLWrapper", {
9521
+ enumerable: true,
9522
+ get: function () { return drizzleOrm.isSQLWrapper; }
9523
+ });
9524
+ Object.defineProperty(exports, "isTable", {
9525
+ enumerable: true,
9526
+ get: function () { return drizzleOrm.isTable; }
9527
+ });
9528
+ Object.defineProperty(exports, "isView", {
9529
+ enumerable: true,
9530
+ get: function () { return drizzleOrm.isView; }
9531
+ });
9483
9532
  Object.defineProperty(exports, "like", {
9484
9533
  enumerable: true,
9485
9534
  get: function () { return drizzleOrm.like; }
@@ -9492,6 +9541,18 @@ Object.defineProperty(exports, "lte", {
9492
9541
  enumerable: true,
9493
9542
  get: function () { return drizzleOrm.lte; }
9494
9543
  });
9544
+ Object.defineProperty(exports, "mapColumnsInAliasedSQLToAlias", {
9545
+ enumerable: true,
9546
+ get: function () { return drizzleOrm.mapColumnsInAliasedSQLToAlias; }
9547
+ });
9548
+ Object.defineProperty(exports, "mapColumnsInSQLToAlias", {
9549
+ enumerable: true,
9550
+ get: function () { return drizzleOrm.mapColumnsInSQLToAlias; }
9551
+ });
9552
+ Object.defineProperty(exports, "mapRelationalRow", {
9553
+ enumerable: true,
9554
+ get: function () { return drizzleOrm.mapRelationalRow; }
9555
+ });
9495
9556
  Object.defineProperty(exports, "max", {
9496
9557
  enumerable: true,
9497
9558
  get: function () { return drizzleOrm.max; }
@@ -1,6 +1,6 @@
1
1
  import { PostgresJsDatabase } from 'drizzle-orm/postgres-js';
2
2
  import { PgTable } from 'drizzle-orm/pg-core';
3
- import { DrizzleSqlConnector, DrizzleSelectOptions, DrizzleInsertOptions, DrizzleUpdateOptions, DrizzleDeleteOptions, DrizzleQueryOptions, DrizzleTransaction } from '../abstract/DrizzleSQLConnector';
3
+ import { DrizzleSqlConnector, DrizzleSelectOptions, DrizzleInsertOptions, DrizzleUpdateOptions, DrizzleDeleteOptions, DrizzleQueryOptions } from '../abstract/DrizzleSQLConnector';
4
4
  import { CredentialsConnection } from '../types/CredentialsConnection';
5
5
  export declare class DrizzlePostgresConnector extends DrizzleSqlConnector {
6
6
  private readonly creds;
@@ -19,7 +19,7 @@ export declare class DrizzlePostgresConnector extends DrizzleSqlConnector {
19
19
  update(entity: string, filter: Record<string, any>, data: Record<string, any>, options?: DrizzleUpdateOptions): Promise<number>;
20
20
  delete(entity: string, filter: Record<string, any>, options?: DrizzleDeleteOptions): Promise<number>;
21
21
  query<T = any>(sql: string, options?: DrizzleQueryOptions): Promise<T[]>;
22
- withTransaction<T>(fn: (tx: DrizzleTransaction) => Promise<T>): Promise<T>;
22
+ withTransaction<T>(fn: (tx: any) => Promise<T>): Promise<T>;
23
23
  private buildDrizzleWhere;
24
24
  private buildRawWhereClause;
25
25
  private executeRawQuery;
@@ -40,5 +40,5 @@ export declare abstract class DrizzleSqlConnector {
40
40
  abstract update(entity: string, filter: Record<string, any>, data: Record<string, any>, options?: DrizzleUpdateOptions): Promise<number>;
41
41
  abstract delete(entity: string, filter: Record<string, any>, options?: DrizzleDeleteOptions): Promise<number>;
42
42
  abstract query<T = any>(sql: string, options?: DrizzleQueryOptions): Promise<T[]>;
43
- abstract withTransaction<T>(fn: (tx: DrizzleTransaction) => Promise<T>): Promise<T>;
43
+ abstract withTransaction<T>(fn: (tx: any) => Promise<T>): Promise<T>;
44
44
  }
@@ -19,7 +19,7 @@ export { ClickHouseConnector } from './Core/ClickHouseConnector';
19
19
  export { DrizzlePostgresConnector } from './Core/DrizzleConnector';
20
20
  export { PostgresJsDatabase } from 'drizzle-orm/postgres-js';
21
21
  export type { InferSelectModel, InferInsertModel } from 'drizzle-orm';
22
- export { sql, eq, ne, gt, gte, lt, lte, like, ilike, notLike, notIlike, inArray, notInArray, isNull, isNotNull, not, and, or, exists, notExists, between, notBetween, arrayContains, arrayContained, arrayOverlaps } from 'drizzle-orm';
22
+ export { sql, eq, ne, gt, gte, lt, lte, like, ilike, notLike, notIlike, inArray, notInArray, isNull, isNotNull, not, and, or, exists, notExists, between, notBetween, arrayContains, arrayContained, arrayOverlaps, aliasedRelation, aliasedTable, aliasedTableColumn, AnyColumn, AnyTable, Assume, BuildColumn, BuildColumns, Casing, GetColumnData, IsUnion, View, getOperators, getTableColumns, getTableName, getViewName, getViewSelectedFields, getOrderByOperators, getTableUniqueName, mapColumnsInAliasedSQLToAlias, mapColumnsInSQLToAlias, mapRelationalRow, isTable, isView, isConfig, isDriverValueEncoder, isSQLWrapper } from 'drizzle-orm';
23
23
  export { count, countDistinct, avg, avgDistinct, sum, sumDistinct, max, min } from 'drizzle-orm';
24
24
  export { asc, desc } from 'drizzle-orm';
25
25
  export { pgTable, pgSchema, pgView, pgMaterializedView, pgEnum } from 'drizzle-orm/pg-core';
@@ -31,3 +31,4 @@ export { json, jsonb } from 'drizzle-orm/pg-core';
31
31
  export { inet, cidr, macaddr, macaddr8, point, line, geometry } from 'drizzle-orm/pg-core';
32
32
  export { primaryKey, foreignKey, unique, check, index, uniqueIndex } from 'drizzle-orm/pg-core';
33
33
  export type { AnyPgColumn } from 'drizzle-orm/pg-core';
34
+ export {} from 'drizzle-orm/pg-core';
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@hemia/db-connector",
3
- "version": "0.0.11",
3
+ "version": "0.0.13",
4
4
  "description": "Hemia Database Conector",
5
5
  "main": "dist/hemia-db-connector.js",
6
6
  "module": "dist/hemia-db-connector.esm.js",
@@ -13,7 +13,8 @@
13
13
  "prepublishOnly": "npm run build",
14
14
  "test": "jest --detectOpenHandles",
15
15
  "test:coverage": "jest --coverage",
16
- "test:watch": "jest --watch"
16
+ "test:watch": "jest --watch",
17
+ "prepublish": "npm run build"
17
18
  },
18
19
  "nyc": {
19
20
  "reporter": [