@opra/sqb 0.31.2 → 0.31.5

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.
@@ -48,15 +48,15 @@ common_1.TypeDocumentFactory.prototype.prepareDataTypeInitArguments = async func
48
48
  fieldSchema.type = 'bigint';
49
49
  break;
50
50
  case connect_1.DataType.DATE:
51
- if (!fieldSchema.type || (detectType && (fieldSchema.type === 'timestamp' || fieldSchema.type === 'string')))
51
+ if (!fieldSchema.type || (detectType && (fieldSchema.type === 'datetime' || fieldSchema.type === 'string')))
52
52
  fieldSchema.type = 'date';
53
53
  break;
54
54
  case connect_1.DataType.TIMESTAMPTZ:
55
- if (!fieldSchema.type || (detectType && (fieldSchema.type === 'timestamp' || fieldSchema.type === 'string')))
55
+ if (!fieldSchema.type || (detectType && (fieldSchema.type === 'datetime' || fieldSchema.type === 'string')))
56
56
  fieldSchema.type = 'timestamptz';
57
57
  break;
58
58
  case connect_1.DataType.TIME:
59
- if (!fieldSchema.type || (detectType && (fieldSchema.type === 'timestamp' || fieldSchema.type === 'string')))
59
+ if (!fieldSchema.type || (detectType && (fieldSchema.type === 'datetime' || fieldSchema.type === 'string')))
60
60
  fieldSchema.type = 'time';
61
61
  break;
62
62
  case connect_1.DataType.BINARY:
@@ -80,7 +80,7 @@ common_1.TypeDocumentFactory.prototype.prepareDataTypeInitArguments = async func
80
80
  fieldSchema.type = 'number';
81
81
  break;
82
82
  case connect_1.DataType.TIMESTAMP:
83
- fieldSchema.type = 'timestamp';
83
+ fieldSchema.type = 'datetime';
84
84
  break;
85
85
  }
86
86
  }
@@ -152,10 +152,11 @@ class SqbEntityServiceBase extends core_1.ApiService {
152
152
  throw e;
153
153
  }
154
154
  }
155
- forContext(context, db) {
156
- const instance = super.forContext(context);
157
- instance.db = db || this.db;
158
- return instance;
155
+ forContext(context, options) {
156
+ return super.forContext(context, {
157
+ newInstance: options?.newInstance ||
158
+ (options?.db && this.db !== options.db)
159
+ });
159
160
  }
160
161
  async _onError(error) {
161
162
  if (this.onError)
@@ -46,15 +46,15 @@ TypeDocumentFactory.prototype.prepareDataTypeInitArguments = async function (sch
46
46
  fieldSchema.type = 'bigint';
47
47
  break;
48
48
  case SqbDataType.DATE:
49
- if (!fieldSchema.type || (detectType && (fieldSchema.type === 'timestamp' || fieldSchema.type === 'string')))
49
+ if (!fieldSchema.type || (detectType && (fieldSchema.type === 'datetime' || fieldSchema.type === 'string')))
50
50
  fieldSchema.type = 'date';
51
51
  break;
52
52
  case SqbDataType.TIMESTAMPTZ:
53
- if (!fieldSchema.type || (detectType && (fieldSchema.type === 'timestamp' || fieldSchema.type === 'string')))
53
+ if (!fieldSchema.type || (detectType && (fieldSchema.type === 'datetime' || fieldSchema.type === 'string')))
54
54
  fieldSchema.type = 'timestamptz';
55
55
  break;
56
56
  case SqbDataType.TIME:
57
- if (!fieldSchema.type || (detectType && (fieldSchema.type === 'timestamp' || fieldSchema.type === 'string')))
57
+ if (!fieldSchema.type || (detectType && (fieldSchema.type === 'datetime' || fieldSchema.type === 'string')))
58
58
  fieldSchema.type = 'time';
59
59
  break;
60
60
  case SqbDataType.BINARY:
@@ -78,7 +78,7 @@ TypeDocumentFactory.prototype.prepareDataTypeInitArguments = async function (sch
78
78
  fieldSchema.type = 'number';
79
79
  break;
80
80
  case SqbDataType.TIMESTAMP:
81
- fieldSchema.type = 'timestamp';
81
+ fieldSchema.type = 'datetime';
82
82
  break;
83
83
  }
84
84
  }
@@ -149,10 +149,11 @@ export class SqbEntityServiceBase extends ApiService {
149
149
  throw e;
150
150
  }
151
151
  }
152
- forContext(context, db) {
153
- const instance = super.forContext(context);
154
- instance.db = db || this.db;
155
- return instance;
152
+ forContext(context, options) {
153
+ return super.forContext(context, {
154
+ newInstance: options?.newInstance ||
155
+ (options?.db && this.db !== options.db)
156
+ });
156
157
  }
157
158
  async _onError(error) {
158
159
  if (this.onError)
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@opra/sqb",
3
- "version": "0.31.2",
3
+ "version": "0.31.5",
4
4
  "description": "Opra SQB adapter package",
5
5
  "author": "Panates",
6
6
  "license": "MIT",
@@ -19,27 +19,28 @@
19
19
  "lint": "eslint . --max-warnings=0",
20
20
  "test": "jest",
21
21
  "cover": "jest --collect-coverage",
22
- "clean": "npm run clean:src && npm run clean:dist && npm run clean:cover",
23
- "clean:src": "ts-cleanup -s src --all && ts-cleanup -s test --all",
24
- "clean:dist": "rimraf ../../build/sqb",
25
- "clean:cover": "rimraf ../../coverage/sqb"
22
+ "clean": "npm run clean:src && npm run clean:test && npm run clean:dist && npm run clean:cover",
23
+ "clean:src": "ts-cleanup -s src --all",
24
+ "clean:test": "ts-cleanup -s test --all",
25
+ "clean:dist": "rimraf ../../build/client",
26
+ "clean:cover": "rimraf ../../coverage/client"
26
27
  },
27
28
  "dependencies": {
28
29
  "lodash.isnil": "^4.0.0",
29
30
  "lodash.omitby": "^4.6.0"
30
31
  },
31
32
  "devDependencies": {
32
- "@faker-js/faker": "^8.2.0",
33
- "@sqb/builder": "^4.9.1",
34
- "@sqb/connect": "^4.9.1",
35
- "@sqb/postgres": "^4.9.1",
36
- "@types/lodash.isnil": "^4.0.8",
37
- "@types/lodash.omitby": "^4.6.8",
38
- "postgresql-client": "^2.9.1",
33
+ "@faker-js/faker": "^8.3.1",
34
+ "@sqb/builder": "^4.10.4",
35
+ "@sqb/connect": "^4.10.4",
36
+ "@sqb/postgres": "^4.10.4",
37
+ "@types/lodash.isnil": "^4.0.9",
38
+ "@types/lodash.omitby": "^4.6.9",
39
+ "postgresql-client": "^2.10.1",
39
40
  "ts-gems": "^2.5.0"
40
41
  },
41
42
  "peerDependencies": {
42
- "@opra/core": "^0.31.2",
43
+ "@opra/core": "^0.31.5",
43
44
  "@sqb/connect": ">= 4.9.0"
44
45
  },
45
46
  "type": "module",
@@ -22,7 +22,10 @@ export declare class SqbEntityServiceBase<T> extends ApiService {
22
22
  protected _exists(options?: Repository.ExistsOptions): Promise<boolean>;
23
23
  protected _update(keyValue: any, data: EntityInput<T>, options?: Repository.UpdateOptions): Promise<Maybe<PartialOutput<T>>>;
24
24
  protected _updateMany(data: PartialInput<T>, options?: Repository.UpdateManyOptions): Promise<number>;
25
- forContext(context: RequestContext, db?: SqbClient | SqbConnection): this;
25
+ forContext(context: RequestContext, options?: {
26
+ newInstance?: boolean;
27
+ db?: SqbClient | SqbConnection;
28
+ }): this;
26
29
  protected _onError(error: unknown): Promise<void>;
27
30
  protected getConnection(): SqbConnection | SqbClient | Promise<SqbConnection | SqbClient>;
28
31
  protected onError?(error: unknown): void | Promise<void>;