@opra/sqb 1.0.0-alpha.7 → 1.0.0-alpha.9

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.
@@ -59,16 +59,20 @@ DataTypeFactory._prepareComplexTypeArgs = async function (context, owner, initAr
59
59
  if (hasNoType || fieldSchema.type === String)
60
60
  fieldSchema.type = 'time';
61
61
  break;
62
+ default:
63
+ break;
62
64
  }
63
65
  }
64
66
  if ((0, connect_1.isAssociationField)(sqbField)) {
65
67
  if (sqbField.association.returnsMany())
66
68
  fieldSchema.isArray = true;
67
- if (!fieldSchema.hasOwnProperty('exclusive'))
69
+ if (!Object.prototype.hasOwnProperty.call(fieldSchema, 'exclusive'))
68
70
  fieldSchema.exclusive = true;
69
71
  }
70
- if (!fieldSchema.hasOwnProperty('exclusive') && sqbField.hasOwnProperty('exclusive'))
72
+ if (!Object.prototype.hasOwnProperty.call(fieldSchema, 'exclusive') &&
73
+ Object.prototype.hasOwnProperty.call(sqbField, 'exclusive')) {
71
74
  fieldSchema.exclusive = sqbField.exclusive;
75
+ }
72
76
  }
73
77
  }
74
78
  return _prepareComplexTypeArgs.apply(DataTypeFactory, [context, owner, initArgs, metadata]);
@@ -74,6 +74,8 @@ var SQBAdapter;
74
74
  };
75
75
  return { method: 'updateMany', data, options };
76
76
  }
77
+ default:
78
+ break;
77
79
  }
78
80
  }
79
81
  throw new Error(`This operation is not compatible to SQB Adapter`);
@@ -51,8 +51,9 @@ class SqbSingletonService extends sqb_entity_service_js_1.SqbEntityService {
51
51
  const primaryFields = connect_1.EntityMetadata.getPrimaryIndexColumns(this.entityMetadata);
52
52
  const data = { ...input };
53
53
  if (primaryFields.length > 1) {
54
- if (typeof primaryFields !== 'object')
54
+ if (typeof primaryFields !== 'object') {
55
55
  throw new TypeError(`"${this.entityMetadata.name}" should has multiple primary key fields. So you should provide and object that contains key fields`);
56
+ }
56
57
  for (const field of primaryFields) {
57
58
  data[field.name] = this.id[field.name];
58
59
  }
@@ -57,16 +57,20 @@ DataTypeFactory._prepareComplexTypeArgs = async function (context, owner, initAr
57
57
  if (hasNoType || fieldSchema.type === String)
58
58
  fieldSchema.type = 'time';
59
59
  break;
60
+ default:
61
+ break;
60
62
  }
61
63
  }
62
64
  if (isAssociationField(sqbField)) {
63
65
  if (sqbField.association.returnsMany())
64
66
  fieldSchema.isArray = true;
65
- if (!fieldSchema.hasOwnProperty('exclusive'))
67
+ if (!Object.prototype.hasOwnProperty.call(fieldSchema, 'exclusive'))
66
68
  fieldSchema.exclusive = true;
67
69
  }
68
- if (!fieldSchema.hasOwnProperty('exclusive') && sqbField.hasOwnProperty('exclusive'))
70
+ if (!Object.prototype.hasOwnProperty.call(fieldSchema, 'exclusive') &&
71
+ Object.prototype.hasOwnProperty.call(sqbField, 'exclusive')) {
69
72
  fieldSchema.exclusive = sqbField.exclusive;
73
+ }
70
74
  }
71
75
  }
72
76
  return _prepareComplexTypeArgs.apply(DataTypeFactory, [context, owner, initArgs, metadata]);
@@ -70,6 +70,8 @@ export var SQBAdapter;
70
70
  };
71
71
  return { method: 'updateMany', data, options };
72
72
  }
73
+ default:
74
+ break;
73
75
  }
74
76
  }
75
77
  throw new Error(`This operation is not compatible to SQB Adapter`);
@@ -48,8 +48,9 @@ export class SqbSingletonService extends SqbEntityService {
48
48
  const primaryFields = EntityMetadata.getPrimaryIndexColumns(this.entityMetadata);
49
49
  const data = { ...input };
50
50
  if (primaryFields.length > 1) {
51
- if (typeof primaryFields !== 'object')
51
+ if (typeof primaryFields !== 'object') {
52
52
  throw new TypeError(`"${this.entityMetadata.name}" should has multiple primary key fields. So you should provide and object that contains key fields`);
53
+ }
53
54
  for (const field of primaryFields) {
54
55
  data[field.name] = this.id[field.name];
55
56
  }
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@opra/sqb",
3
- "version": "1.0.0-alpha.7",
3
+ "version": "1.0.0-alpha.9",
4
4
  "description": "Opra SQB adapter package",
5
5
  "author": "Panates",
6
6
  "license": "MIT",
@@ -17,6 +17,7 @@
17
17
  "build:esm": "tsc -b tsconfig-build-esm.json",
18
18
  "postbuild": "cp README.md package.json ../../LICENSE ../../build/sqb && cp ../../package.cjs.json ../../build/sqb/cjs/package.json",
19
19
  "lint": "eslint . --max-warnings=0",
20
+ "lint:fix": "eslint . --max-warnings=0 --fix",
20
21
  "format": "prettier . --write --log-level=warn",
21
22
  "test": "jest --passWithNoTests",
22
23
  "cover": "jest --passWithNoTests --collect-coverage",
@@ -26,16 +27,19 @@
26
27
  "clean:dist": "rimraf ../../build/client",
27
28
  "clean:cover": "rimraf ../../coverage/client"
28
29
  },
30
+ "dependencies": {
31
+ "reflect-metadata": "^0.2.2"
32
+ },
29
33
  "devDependencies": {
30
34
  "@faker-js/faker": "^8.4.1",
31
- "@sqb/builder": "^4.12.0",
32
- "@sqb/connect": "^4.12.0",
33
- "@sqb/postgres": "^4.12.0",
34
- "postgresql-client": "^2.11.0",
35
+ "@sqb/builder": "^4.12.1",
36
+ "@sqb/connect": "^4.12.1",
37
+ "@sqb/postgres": "^4.12.1",
38
+ "postgresql-client": "^2.11.2",
35
39
  "ts-gems": "^3.4.0"
36
40
  },
37
41
  "peerDependencies": {
38
- "@opra/core": "^1.0.0-alpha.7",
42
+ "@opra/core": "^1.0.0-alpha.9",
39
43
  "@sqb/connect": ">= 4.10.6"
40
44
  },
41
45
  "type": "module",
@@ -1,8 +1,8 @@
1
- import { PartialDTO, PatchDTO, Type } from 'ts-gems';
2
- import { IsObject } from 'valgen';
3
1
  import { ComplexType } from '@opra/common';
4
2
  import { ServiceBase } from '@opra/core';
5
3
  import { EntityMetadata, Repository, SqbClient, SqbConnection } from '@sqb/connect';
4
+ import { PartialDTO, PatchDTO, Type } from 'ts-gems';
5
+ import { IsObject } from 'valgen';
6
6
  import { SQBAdapter } from './sqb-adapter.js';
7
7
  /**
8
8
  * @namespace SqbEntityService
@@ -1,5 +1,5 @@
1
- import { PartialDTO, PatchDTO, Type } from 'ts-gems';
2
1
  import { ColumnFieldMetadata } from '@sqb/connect';
2
+ import { PartialDTO, PatchDTO, Type } from 'ts-gems';
3
3
  import { SQBAdapter } from './sqb-adapter.js';
4
4
  import { SqbEntityService } from './sqb-entity-service.js';
5
5
  /**