@opra/sqb 0.16.0 → 0.16.2

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.
@@ -8,32 +8,32 @@ class SqbCollectionResource {
8
8
  async create(ctx) {
9
9
  const prepared = sqb_adapter_js_1.SQBAdapter.transformRequest(ctx.request);
10
10
  const service = await this.getService(ctx);
11
- return service.create(ctx, prepared.data, prepared.options);
11
+ return service.with(ctx).create(prepared.data, prepared.options);
12
12
  }
13
13
  async delete(ctx) {
14
14
  const prepared = sqb_adapter_js_1.SQBAdapter.transformRequest(ctx.request);
15
15
  const service = await this.getService(ctx);
16
- return service.delete(ctx, prepared.key, prepared.options);
16
+ return service.with(ctx).delete(prepared.key, prepared.options);
17
17
  }
18
18
  async deleteMany(ctx) {
19
19
  const prepared = sqb_adapter_js_1.SQBAdapter.transformRequest(ctx.request);
20
20
  const service = await this.getService(ctx);
21
- return service.deleteMany(ctx, prepared.options);
21
+ return service.with(ctx).deleteMany(prepared.options);
22
22
  }
23
23
  async find(ctx) {
24
24
  const prepared = sqb_adapter_js_1.SQBAdapter.transformRequest(ctx.request);
25
25
  const service = await this.getService(ctx);
26
- return service.find(ctx, prepared.key, prepared.options);
26
+ return service.with(ctx).find(prepared.key, prepared.options);
27
27
  }
28
28
  async update(ctx) {
29
29
  const prepared = sqb_adapter_js_1.SQBAdapter.transformRequest(ctx.request);
30
30
  const service = await this.getService(ctx);
31
- return service.update(ctx, prepared.key, prepared.data, prepared.options);
31
+ return service.with(ctx).update(prepared.key, prepared.data, prepared.options);
32
32
  }
33
33
  async updateMany(ctx) {
34
34
  const prepared = sqb_adapter_js_1.SQBAdapter.transformRequest(ctx.request);
35
35
  const service = await this.getService(ctx);
36
- return service.updateMany(ctx, prepared.data, prepared.options);
36
+ return service.with(ctx).updateMany(prepared.data, prepared.options);
37
37
  }
38
38
  async search(ctx) {
39
39
  const prepared = sqb_adapter_js_1.SQBAdapter.transformRequest(ctx.request);
@@ -47,7 +47,7 @@ class SqbCollectionResource {
47
47
  return items;
48
48
  }
49
49
  else
50
- return service.findAll(ctx, prepared.options);
50
+ return service.with(ctx).findAll(prepared.options);
51
51
  }
52
52
  }
53
53
  tslib_1.__decorate([
@@ -11,7 +11,7 @@ class SqbEntityService {
11
11
  this.db = options?.db;
12
12
  this.defaultLimit = options?.defaultLimit || 10;
13
13
  }
14
- async count(context, options) {
14
+ async count(options) {
15
15
  const conn = await this.getConnection();
16
16
  const repo = conn.getRepository(this.typeClass);
17
17
  try {
@@ -22,7 +22,7 @@ class SqbEntityService {
22
22
  throw e;
23
23
  }
24
24
  }
25
- async create(context, data, options) {
25
+ async create(data, options) {
26
26
  const conn = await this.getConnection();
27
27
  const repo = conn.getRepository(this.typeClass);
28
28
  let out;
@@ -39,7 +39,7 @@ class SqbEntityService {
39
39
  throw new Error('"create" operation returned no result!');
40
40
  return out;
41
41
  }
42
- async delete(context, keyValue, options) {
42
+ async delete(keyValue, options) {
43
43
  const conn = await this.getConnection();
44
44
  const repo = conn.getRepository(this.typeClass);
45
45
  try {
@@ -50,7 +50,7 @@ class SqbEntityService {
50
50
  throw e;
51
51
  }
52
52
  }
53
- async deleteMany(context, options) {
53
+ async deleteMany(options) {
54
54
  const conn = await this.getConnection();
55
55
  const repo = conn.getRepository(this.typeClass);
56
56
  try {
@@ -61,7 +61,7 @@ class SqbEntityService {
61
61
  throw e;
62
62
  }
63
63
  }
64
- async find(context, keyValue, options) {
64
+ async find(keyValue, options) {
65
65
  const conn = await this.getConnection();
66
66
  const repo = conn.getRepository(this.typeClass);
67
67
  let out;
@@ -76,7 +76,7 @@ class SqbEntityService {
76
76
  out = this.onTransformRow(out);
77
77
  return out;
78
78
  }
79
- async findOne(context, options) {
79
+ async findOne(options) {
80
80
  const conn = await this.getConnection();
81
81
  const repo = conn.getRepository(this.typeClass);
82
82
  let out;
@@ -91,7 +91,7 @@ class SqbEntityService {
91
91
  out = this.onTransformRow(out);
92
92
  return out;
93
93
  }
94
- async findAll(context, options) {
94
+ async findAll(options) {
95
95
  const conn = await this.getConnection();
96
96
  const repo = conn.getRepository(this.typeClass);
97
97
  let items;
@@ -113,7 +113,7 @@ class SqbEntityService {
113
113
  }
114
114
  return items;
115
115
  }
116
- async exists(context, options) {
116
+ async exists(options) {
117
117
  const conn = await this.getConnection();
118
118
  const repo = conn.getRepository(this.typeClass);
119
119
  try {
@@ -124,7 +124,7 @@ class SqbEntityService {
124
124
  throw e;
125
125
  }
126
126
  }
127
- async update(context, keyValue, data, options) {
127
+ async update(keyValue, data, options) {
128
128
  const conn = await this.getConnection();
129
129
  const repo = conn.getRepository(this.typeClass);
130
130
  let out;
@@ -139,7 +139,7 @@ class SqbEntityService {
139
139
  out = this.onTransformRow(out);
140
140
  return out;
141
141
  }
142
- async updateMany(context, data, options) {
142
+ async updateMany(data, options) {
143
143
  const conn = await this.getConnection();
144
144
  const repo = conn.getRepository(this.typeClass);
145
145
  try {
@@ -8,23 +8,23 @@ class SqbSingletonResource {
8
8
  async create(ctx) {
9
9
  const prepared = sqb_adapter_js_1.SQBAdapter.transformRequest(ctx.request);
10
10
  const service = await this.getService(ctx);
11
- return service.create(ctx, prepared.data, prepared.options);
11
+ return service.with(ctx).create(prepared.data, prepared.options);
12
12
  }
13
13
  async delete(ctx) {
14
14
  const prepared = sqb_adapter_js_1.SQBAdapter.transformRequest(ctx.request);
15
15
  const service = await this.getService(ctx);
16
- return !!(await service.deleteMany(ctx, prepared.options));
16
+ return !!(await service.with(ctx).deleteMany(prepared.options));
17
17
  }
18
18
  async get(ctx) {
19
19
  const prepared = sqb_adapter_js_1.SQBAdapter.transformRequest(ctx.request);
20
20
  const service = await this.getService(ctx);
21
- return service.findOne(ctx, prepared.options);
21
+ return service.with(ctx).findOne(prepared.options);
22
22
  }
23
23
  async update(ctx) {
24
24
  const prepared = sqb_adapter_js_1.SQBAdapter.transformRequest(ctx.request);
25
25
  const service = await this.getService(ctx);
26
- await service.updateMany(ctx, prepared.data, prepared.options);
27
- return service.findOne(ctx, prepared.options);
26
+ await service.with(ctx).updateMany(prepared.data, prepared.options);
27
+ return service.with(ctx).findOne(prepared.options);
28
28
  }
29
29
  }
30
30
  tslib_1.__decorate([
@@ -8,32 +8,32 @@ class SqbCollectionResource {
8
8
  async create(ctx) {
9
9
  const prepared = sqb_adapter_js_1.SQBAdapter.transformRequest(ctx.request);
10
10
  const service = await this.getService(ctx);
11
- return service.create(ctx, prepared.data, prepared.options);
11
+ return service.with(ctx).create(prepared.data, prepared.options);
12
12
  }
13
13
  async delete(ctx) {
14
14
  const prepared = sqb_adapter_js_1.SQBAdapter.transformRequest(ctx.request);
15
15
  const service = await this.getService(ctx);
16
- return service.delete(ctx, prepared.key, prepared.options);
16
+ return service.with(ctx).delete(prepared.key, prepared.options);
17
17
  }
18
18
  async deleteMany(ctx) {
19
19
  const prepared = sqb_adapter_js_1.SQBAdapter.transformRequest(ctx.request);
20
20
  const service = await this.getService(ctx);
21
- return service.deleteMany(ctx, prepared.options);
21
+ return service.with(ctx).deleteMany(prepared.options);
22
22
  }
23
23
  async find(ctx) {
24
24
  const prepared = sqb_adapter_js_1.SQBAdapter.transformRequest(ctx.request);
25
25
  const service = await this.getService(ctx);
26
- return service.find(ctx, prepared.key, prepared.options);
26
+ return service.with(ctx).find(prepared.key, prepared.options);
27
27
  }
28
28
  async update(ctx) {
29
29
  const prepared = sqb_adapter_js_1.SQBAdapter.transformRequest(ctx.request);
30
30
  const service = await this.getService(ctx);
31
- return service.update(ctx, prepared.key, prepared.data, prepared.options);
31
+ return service.with(ctx).update(prepared.key, prepared.data, prepared.options);
32
32
  }
33
33
  async updateMany(ctx) {
34
34
  const prepared = sqb_adapter_js_1.SQBAdapter.transformRequest(ctx.request);
35
35
  const service = await this.getService(ctx);
36
- return service.updateMany(ctx, prepared.data, prepared.options);
36
+ return service.with(ctx).updateMany(prepared.data, prepared.options);
37
37
  }
38
38
  async search(ctx) {
39
39
  const prepared = sqb_adapter_js_1.SQBAdapter.transformRequest(ctx.request);
@@ -47,7 +47,7 @@ class SqbCollectionResource {
47
47
  return items;
48
48
  }
49
49
  else
50
- return service.findAll(ctx, prepared.options);
50
+ return service.with(ctx).findAll(prepared.options);
51
51
  }
52
52
  }
53
53
  tslib_1.__decorate([
@@ -11,7 +11,7 @@ class SqbEntityService {
11
11
  this.db = options?.db;
12
12
  this.defaultLimit = options?.defaultLimit || 10;
13
13
  }
14
- async count(context, options) {
14
+ async count(options) {
15
15
  const conn = await this.getConnection();
16
16
  const repo = conn.getRepository(this.typeClass);
17
17
  try {
@@ -22,7 +22,7 @@ class SqbEntityService {
22
22
  throw e;
23
23
  }
24
24
  }
25
- async create(context, data, options) {
25
+ async create(data, options) {
26
26
  const conn = await this.getConnection();
27
27
  const repo = conn.getRepository(this.typeClass);
28
28
  let out;
@@ -39,7 +39,7 @@ class SqbEntityService {
39
39
  throw new Error('"create" operation returned no result!');
40
40
  return out;
41
41
  }
42
- async delete(context, keyValue, options) {
42
+ async delete(keyValue, options) {
43
43
  const conn = await this.getConnection();
44
44
  const repo = conn.getRepository(this.typeClass);
45
45
  try {
@@ -50,7 +50,7 @@ class SqbEntityService {
50
50
  throw e;
51
51
  }
52
52
  }
53
- async deleteMany(context, options) {
53
+ async deleteMany(options) {
54
54
  const conn = await this.getConnection();
55
55
  const repo = conn.getRepository(this.typeClass);
56
56
  try {
@@ -61,7 +61,7 @@ class SqbEntityService {
61
61
  throw e;
62
62
  }
63
63
  }
64
- async find(context, keyValue, options) {
64
+ async find(keyValue, options) {
65
65
  const conn = await this.getConnection();
66
66
  const repo = conn.getRepository(this.typeClass);
67
67
  let out;
@@ -76,7 +76,7 @@ class SqbEntityService {
76
76
  out = this.onTransformRow(out);
77
77
  return out;
78
78
  }
79
- async findOne(context, options) {
79
+ async findOne(options) {
80
80
  const conn = await this.getConnection();
81
81
  const repo = conn.getRepository(this.typeClass);
82
82
  let out;
@@ -91,7 +91,7 @@ class SqbEntityService {
91
91
  out = this.onTransformRow(out);
92
92
  return out;
93
93
  }
94
- async findAll(context, options) {
94
+ async findAll(options) {
95
95
  const conn = await this.getConnection();
96
96
  const repo = conn.getRepository(this.typeClass);
97
97
  let items;
@@ -113,7 +113,7 @@ class SqbEntityService {
113
113
  }
114
114
  return items;
115
115
  }
116
- async exists(context, options) {
116
+ async exists(options) {
117
117
  const conn = await this.getConnection();
118
118
  const repo = conn.getRepository(this.typeClass);
119
119
  try {
@@ -124,7 +124,7 @@ class SqbEntityService {
124
124
  throw e;
125
125
  }
126
126
  }
127
- async update(context, keyValue, data, options) {
127
+ async update(keyValue, data, options) {
128
128
  const conn = await this.getConnection();
129
129
  const repo = conn.getRepository(this.typeClass);
130
130
  let out;
@@ -139,7 +139,7 @@ class SqbEntityService {
139
139
  out = this.onTransformRow(out);
140
140
  return out;
141
141
  }
142
- async updateMany(context, data, options) {
142
+ async updateMany(data, options) {
143
143
  const conn = await this.getConnection();
144
144
  const repo = conn.getRepository(this.typeClass);
145
145
  try {
@@ -8,23 +8,23 @@ class SqbSingletonResource {
8
8
  async create(ctx) {
9
9
  const prepared = sqb_adapter_js_1.SQBAdapter.transformRequest(ctx.request);
10
10
  const service = await this.getService(ctx);
11
- return service.create(ctx, prepared.data, prepared.options);
11
+ return service.with(ctx).create(prepared.data, prepared.options);
12
12
  }
13
13
  async delete(ctx) {
14
14
  const prepared = sqb_adapter_js_1.SQBAdapter.transformRequest(ctx.request);
15
15
  const service = await this.getService(ctx);
16
- return !!(await service.deleteMany(ctx, prepared.options));
16
+ return !!(await service.with(ctx).deleteMany(prepared.options));
17
17
  }
18
18
  async get(ctx) {
19
19
  const prepared = sqb_adapter_js_1.SQBAdapter.transformRequest(ctx.request);
20
20
  const service = await this.getService(ctx);
21
- return service.findOne(ctx, prepared.options);
21
+ return service.with(ctx).findOne(prepared.options);
22
22
  }
23
23
  async update(ctx) {
24
24
  const prepared = sqb_adapter_js_1.SQBAdapter.transformRequest(ctx.request);
25
25
  const service = await this.getService(ctx);
26
- await service.updateMany(ctx, prepared.data, prepared.options);
27
- return service.findOne(ctx, prepared.options);
26
+ await service.with(ctx).updateMany(prepared.data, prepared.options);
27
+ return service.with(ctx).findOne(prepared.options);
28
28
  }
29
29
  }
30
30
  tslib_1.__decorate([
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@opra/sqb",
3
- "version": "0.16.0",
3
+ "version": "0.16.2",
4
4
  "description": "Opra SQB adapter package",
5
5
  "author": "Panates",
6
6
  "license": "MIT",
@@ -37,7 +37,7 @@
37
37
  "ts-gems": "^2.3.0"
38
38
  },
39
39
  "peerDependencies": {
40
- "@opra/core": "^0.16.0",
40
+ "@opra/core": "^0.16.2",
41
41
  "@sqb/connect": ">= 4.8.2"
42
42
  },
43
43
  "type": "module",
@@ -13,16 +13,16 @@ export declare class SqbEntityService<T, TOutput = PartialOutput<T>> {
13
13
  defaultLimit: number;
14
14
  db?: SqbClient | SqbConnection;
15
15
  constructor(typeClass: Type<T>, options?: SqbEntityService.Options);
16
- count(context: RequestContext, options?: Repository.CountOptions): Promise<number>;
17
- create(context: RequestContext, data: PartialInput<T>, options?: Repository.CreateOptions): Promise<TOutput>;
18
- delete(context: RequestContext, keyValue: any, options?: Repository.DestroyOptions): Promise<boolean>;
19
- deleteMany(context: RequestContext, options?: Repository.DestroyOptions): Promise<number>;
20
- find(context: RequestContext, keyValue: any, options?: Repository.FindOptions): Promise<Maybe<TOutput>>;
21
- findOne(context: RequestContext, options?: Repository.FindOneOptions): Promise<Maybe<TOutput>>;
22
- findAll(context: RequestContext, options?: Repository.FindAllOptions): Promise<TOutput[]>;
23
- exists(context: RequestContext, options?: Repository.ExistsOptions): Promise<boolean>;
24
- update(context: RequestContext, keyValue: any, data: EntityInput<T>, options?: Repository.UpdateOptions): Promise<Maybe<TOutput>>;
25
- updateMany(context: RequestContext, data: PartialInput<T>, options?: Repository.UpdateAllOptions): Promise<number>;
16
+ count(options?: Repository.CountOptions): Promise<number>;
17
+ create(data: PartialInput<T>, options?: Repository.CreateOptions): Promise<TOutput>;
18
+ delete(keyValue: any, options?: Repository.DestroyOptions): Promise<boolean>;
19
+ deleteMany(options?: Repository.DestroyOptions): Promise<number>;
20
+ find(keyValue: any, options?: Repository.FindOptions): Promise<Maybe<TOutput>>;
21
+ findOne(options?: Repository.FindOneOptions): Promise<Maybe<TOutput>>;
22
+ findAll(options?: Repository.FindManyOptions): Promise<TOutput[]>;
23
+ exists(options?: Repository.ExistsOptions): Promise<boolean>;
24
+ update(keyValue: any, data: EntityInput<T>, options?: Repository.UpdateOptions): Promise<Maybe<TOutput>>;
25
+ updateMany(data: PartialInput<T>, options?: Repository.UpdateManyOptions): Promise<number>;
26
26
  with(context: RequestContext, db?: SqbClient | SqbConnection): SqbEntityService<T, TOutput>;
27
27
  protected _onError(error: unknown): Promise<void>;
28
28
  protected getConnection(): SqbConnection | SqbClient | Promise<SqbConnection | SqbClient>;