pangea-server 1.0.75 → 1.0.77

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.
@@ -63,6 +63,10 @@ export declare class Db {
63
63
  restoreOne<BM extends BaseModel>(model: BaseModelCtor<BM>, target: Target<BM>): Promise<BM>;
64
64
  restoreMany<BM extends BaseModel>(model: BaseModelCtor<BM>, where: Where<BM>): Promise<void>;
65
65
  private __getInstance;
66
+ query(sql: string | {
67
+ query: string;
68
+ values: unknown[];
69
+ }): Promise<[unknown[], unknown]>;
66
70
  enableForeignKeyChecks(): Promise<[unknown[], unknown]>;
67
71
  disableForeignKeyChecks(): Promise<[unknown[], unknown]>;
68
72
  }
@@ -200,14 +200,16 @@ class Db {
200
200
  return target;
201
201
  return this.findOne(model, target, { paranoid });
202
202
  }
203
+ query(sql) {
204
+ const dbClient = (0, db_client_1.getDbClient)();
205
+ return dbClient.query(sql, { transaction: this.__tx });
206
+ }
203
207
  // foreign key methods
204
208
  enableForeignKeyChecks() {
205
- const dbClient = (0, db_client_1.getDbClient)();
206
- return dbClient.query('SET FOREIGN_KEY_CHECKS = 1', { transaction: this.__tx });
209
+ return this.query('SET FOREIGN_KEY_CHECKS = 1');
207
210
  }
208
211
  disableForeignKeyChecks() {
209
- const dbClient = (0, db_client_1.getDbClient)();
210
- return dbClient.query('SET FOREIGN_KEY_CHECKS = 0', { transaction: this.__tx });
212
+ return this.query('SET FOREIGN_KEY_CHECKS = 0');
211
213
  }
212
214
  }
213
215
  exports.Db = Db;
@@ -1,4 +1,7 @@
1
- import type { StatusCodeName, StatusCode, ErrorCode } from '../types/error.types';
1
+ import { StatusCodes } from 'http-status-codes';
2
+ type StatusCodeName = keyof typeof StatusCodes;
3
+ type StatusCode = (typeof StatusCodes)[StatusCodeName];
4
+ type ErrorCode = string;
2
5
  type AppErrorCtor = {
3
6
  statusCodeName: StatusCodeName;
4
7
  errorCode: ErrorCode;
@@ -1,2 +1 @@
1
- import './error.types';
2
1
  import './global.types';
@@ -1,4 +1,3 @@
1
1
  "use strict";
2
2
  Object.defineProperty(exports, "__esModule", { value: true });
3
- require("./error.types");
4
3
  require("./global.types");
@@ -10,23 +10,23 @@ export declare namespace Val {
10
10
  type Regex<T extends string> = string & tags.Pattern<T>;
11
11
  type Num = number;
12
12
  type Int = Val.Num & tags.Type<'int32'>;
13
- type Greater<T extends number = 0> = Val.Num & tags.Minimum<T>;
13
+ type GreaterEqual<T extends number = 0> = Val.Num & tags.Minimum<T>;
14
14
  type GreaterThan<T extends number = 0> = Val.Num & tags.ExclusiveMinimum<T>;
15
- type Less<T extends number = 0> = Val.Num & tags.Maximum<T>;
15
+ type LessEqual<T extends number = 0> = Val.Num & tags.Maximum<T>;
16
16
  type LessThan<T extends number = 0> = Val.Num & tags.ExclusiveMaximum<T>;
17
17
  type Bool = boolean;
18
18
  type Datetime = globalThis.Date;
19
19
  type Date = string & tags.Format<'date'>;
20
20
  type Time = string & tags.Format<'time'>;
21
- type Id = Val.Int & Val.Greater<1>;
21
+ type Id = Val.Int & Val.GreaterEqual<1>;
22
22
  type IdOptional = Val.Id | 0;
23
23
  type Ids = Val.Id[];
24
24
  interface IdParams {
25
25
  id: Val.Id;
26
26
  }
27
27
  interface GetManyQueryBase {
28
- page?: (Val.Int & Val.Greater<0>) | null;
29
- pageSize?: (Val.Int & Val.Greater<0>) | null;
28
+ page?: (Val.Int & Val.GreaterEqual<0>) | null;
29
+ pageSize?: (Val.Int & Val.GreaterEqual<0>) | null;
30
30
  search?: Val.Str | '' | null;
31
31
  }
32
32
  }
package/package.json CHANGED
@@ -1,7 +1,7 @@
1
1
  {
2
2
  "name": "pangea-server",
3
3
  "description": "",
4
- "version": "1.0.75",
4
+ "version": "1.0.77",
5
5
  "files": [
6
6
  "dist"
7
7
  ],