@opra/sqb 0.32.2 → 0.32.4
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.
- package/cjs/sqb-adapter.js +1 -3
- package/cjs/sqb-entity-service-base.js +4 -4
- package/esm/sqb-adapter.js +2 -4
- package/esm/sqb-entity-service-base.js +4 -4
- package/package.json +3 -9
- package/types/sqb-collection.d.ts +9 -9
- package/types/sqb-entity-service-base.d.ts +23 -20
- package/types/sqb-entity-service.d.ts +8 -8
- package/types/sqb-singleton.d.ts +7 -7
package/cjs/sqb-adapter.js
CHANGED
|
@@ -2,8 +2,6 @@
|
|
|
2
2
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
3
|
exports.SQBAdapter = void 0;
|
|
4
4
|
const tslib_1 = require("tslib");
|
|
5
|
-
const lodash_isnil_1 = tslib_1.__importDefault(require("lodash.isnil"));
|
|
6
|
-
const lodash_omitby_1 = tslib_1.__importDefault(require("lodash.omitby"));
|
|
7
5
|
const common_1 = require("@opra/common");
|
|
8
6
|
const connect_1 = require("@sqb/connect");
|
|
9
7
|
const transform_filter_js_1 = tslib_1.__importDefault(require("./transform-filter.js"));
|
|
@@ -44,7 +42,7 @@ var SQBAdapter;
|
|
|
44
42
|
options.distinct = params?.distinct;
|
|
45
43
|
options.count = params?.count;
|
|
46
44
|
}
|
|
47
|
-
options = (0,
|
|
45
|
+
options = (0, common_1.omitNullish)(options);
|
|
48
46
|
if (operation === 'create') {
|
|
49
47
|
return {
|
|
50
48
|
method: 'create',
|
|
@@ -152,8 +152,8 @@ class SqbEntityServiceBase extends core_1.ApiService {
|
|
|
152
152
|
throw e;
|
|
153
153
|
}
|
|
154
154
|
}
|
|
155
|
-
|
|
156
|
-
return super.
|
|
155
|
+
for(arg0, attributes) {
|
|
156
|
+
return super.for(arg0, attributes);
|
|
157
157
|
}
|
|
158
158
|
async _onError(error) {
|
|
159
159
|
if (this.onError)
|
|
@@ -166,8 +166,8 @@ class SqbEntityServiceBase extends core_1.ApiService {
|
|
|
166
166
|
throw new Error(`Database not set!`);
|
|
167
167
|
return this.db;
|
|
168
168
|
}
|
|
169
|
-
|
|
170
|
-
return super.
|
|
169
|
+
_instanceCompare(service, context, attributes) {
|
|
170
|
+
return super._instanceCompare(service, context, attributes) &&
|
|
171
171
|
(!attributes?.db || service.db === attributes.db);
|
|
172
172
|
}
|
|
173
173
|
}
|
package/esm/sqb-adapter.js
CHANGED
|
@@ -1,6 +1,4 @@
|
|
|
1
|
-
import
|
|
2
|
-
import omitBy from 'lodash.omitby';
|
|
3
|
-
import { Collection, Singleton } from '@opra/common';
|
|
1
|
+
import { Collection, omitNullish, Singleton } from '@opra/common';
|
|
4
2
|
import { EntityMetadata } from '@sqb/connect';
|
|
5
3
|
import _transformFilter from './transform-filter.js';
|
|
6
4
|
import _transformKeyValues from './transform-key-values.js';
|
|
@@ -40,7 +38,7 @@ export var SQBAdapter;
|
|
|
40
38
|
options.distinct = params?.distinct;
|
|
41
39
|
options.count = params?.count;
|
|
42
40
|
}
|
|
43
|
-
options =
|
|
41
|
+
options = omitNullish(options);
|
|
44
42
|
if (operation === 'create') {
|
|
45
43
|
return {
|
|
46
44
|
method: 'create',
|
|
@@ -149,8 +149,8 @@ export class SqbEntityServiceBase extends ApiService {
|
|
|
149
149
|
throw e;
|
|
150
150
|
}
|
|
151
151
|
}
|
|
152
|
-
|
|
153
|
-
return super.
|
|
152
|
+
for(arg0, attributes) {
|
|
153
|
+
return super.for(arg0, attributes);
|
|
154
154
|
}
|
|
155
155
|
async _onError(error) {
|
|
156
156
|
if (this.onError)
|
|
@@ -163,8 +163,8 @@ export class SqbEntityServiceBase extends ApiService {
|
|
|
163
163
|
throw new Error(`Database not set!`);
|
|
164
164
|
return this.db;
|
|
165
165
|
}
|
|
166
|
-
|
|
167
|
-
return super.
|
|
166
|
+
_instanceCompare(service, context, attributes) {
|
|
167
|
+
return super._instanceCompare(service, context, attributes) &&
|
|
168
168
|
(!attributes?.db || service.db === attributes.db);
|
|
169
169
|
}
|
|
170
170
|
}
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@opra/sqb",
|
|
3
|
-
"version": "0.32.
|
|
3
|
+
"version": "0.32.4",
|
|
4
4
|
"description": "Opra SQB adapter package",
|
|
5
5
|
"author": "Panates",
|
|
6
6
|
"license": "MIT",
|
|
@@ -25,22 +25,16 @@
|
|
|
25
25
|
"clean:dist": "rimraf ../../build/client",
|
|
26
26
|
"clean:cover": "rimraf ../../coverage/client"
|
|
27
27
|
},
|
|
28
|
-
"dependencies": {
|
|
29
|
-
"lodash.isnil": "^4.0.0",
|
|
30
|
-
"lodash.omitby": "^4.6.0"
|
|
31
|
-
},
|
|
32
28
|
"devDependencies": {
|
|
33
29
|
"@faker-js/faker": "^8.3.1",
|
|
34
30
|
"@sqb/builder": "^4.10.6",
|
|
35
31
|
"@sqb/connect": "^4.10.6",
|
|
36
32
|
"@sqb/postgres": "^4.10.6",
|
|
37
|
-
"@types/lodash.isnil": "^4.0.9",
|
|
38
|
-
"@types/lodash.omitby": "^4.6.9",
|
|
39
33
|
"postgresql-client": "^2.10.1",
|
|
40
|
-
"ts-gems": "^2.
|
|
34
|
+
"ts-gems": "^2.8.0"
|
|
41
35
|
},
|
|
42
36
|
"peerDependencies": {
|
|
43
|
-
"@opra/core": "^0.32.
|
|
37
|
+
"@opra/core": "^0.32.4",
|
|
44
38
|
"@sqb/connect": ">= 4.10.6"
|
|
45
39
|
},
|
|
46
40
|
"type": "module",
|
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
import { Maybe } from 'ts-gems';
|
|
2
|
-
import { ICollection,
|
|
2
|
+
import { ICollection, PartialDTO } from '@opra/common';
|
|
3
3
|
import { RequestContext } from '@opra/core';
|
|
4
4
|
import { SQBAdapter } from './sqb-adapter.js';
|
|
5
5
|
import { SqbEntityService } from './sqb-entity-service.js';
|
|
@@ -11,20 +11,20 @@ export declare namespace SqbCollection {
|
|
|
11
11
|
export declare abstract class SqbCollection<T> implements ICollection<T> {
|
|
12
12
|
defaultLimit?: number;
|
|
13
13
|
constructor(options?: SqbCollection.Options);
|
|
14
|
-
create?(ctx: RequestContext): Promise<
|
|
14
|
+
create?(ctx: RequestContext): Promise<PartialDTO<T>>;
|
|
15
15
|
delete?(ctx: RequestContext): Promise<number>;
|
|
16
16
|
deleteMany?(ctx: RequestContext): Promise<number>;
|
|
17
|
-
get?(ctx: RequestContext): Promise<Maybe<
|
|
18
|
-
update?(ctx: RequestContext): Promise<Maybe<
|
|
17
|
+
get?(ctx: RequestContext): Promise<Maybe<PartialDTO<T>>>;
|
|
18
|
+
update?(ctx: RequestContext): Promise<Maybe<PartialDTO<T>>>;
|
|
19
19
|
updateMany?(ctx: RequestContext): Promise<number>;
|
|
20
|
-
findMany?(ctx: RequestContext): Promise<
|
|
21
|
-
protected _create(ctx: RequestContext, prepared: SQBAdapter.TransformedRequest): Promise<
|
|
20
|
+
findMany?(ctx: RequestContext): Promise<PartialDTO<T>[]>;
|
|
21
|
+
protected _create(ctx: RequestContext, prepared: SQBAdapter.TransformedRequest): Promise<PartialDTO<T>>;
|
|
22
22
|
protected _delete(ctx: RequestContext, prepared: SQBAdapter.TransformedRequest): Promise<number>;
|
|
23
23
|
protected _deleteMany(ctx: RequestContext, prepared: SQBAdapter.TransformedRequest): Promise<number>;
|
|
24
|
-
protected _get(ctx: RequestContext, prepared: SQBAdapter.TransformedRequest): Promise<Maybe<
|
|
25
|
-
protected _update(ctx: RequestContext, prepared: SQBAdapter.TransformedRequest): Promise<Maybe<
|
|
24
|
+
protected _get(ctx: RequestContext, prepared: SQBAdapter.TransformedRequest): Promise<Maybe<PartialDTO<T>>>;
|
|
25
|
+
protected _update(ctx: RequestContext, prepared: SQBAdapter.TransformedRequest): Promise<Maybe<PartialDTO<T>>>;
|
|
26
26
|
protected _updateMany(ctx: RequestContext, prepared: SQBAdapter.TransformedRequest): Promise<number>;
|
|
27
|
-
protected _findMany(ctx: RequestContext, prepared: SQBAdapter.TransformedRequest): Promise<
|
|
27
|
+
protected _findMany(ctx: RequestContext, prepared: SQBAdapter.TransformedRequest): Promise<PartialDTO<T>[]>;
|
|
28
28
|
protected _prepare(ctx: RequestContext): Promise<SQBAdapter.TransformedRequest>;
|
|
29
29
|
onPrepare?(ctx: RequestContext, prepared: SQBAdapter.TransformedRequest): SQBAdapter.TransformedRequest | Promise<SQBAdapter.TransformedRequest>;
|
|
30
30
|
protected abstract getService(ctx: RequestContext): SqbEntityService<T> | Promise<SqbEntityService<T>>;
|
|
@@ -1,34 +1,37 @@
|
|
|
1
|
-
import {
|
|
2
|
-
import {
|
|
1
|
+
import { Type } from 'ts-gems';
|
|
2
|
+
import { DTO, PartialDTO, PatchDTO } from '@opra/common';
|
|
3
|
+
import { ApiService, RequestContext } from '@opra/core';
|
|
3
4
|
import { EntityInput, Repository, SqbClient, SqbConnection } from '@sqb/connect';
|
|
4
|
-
export declare namespace SqbEntityServiceBase {
|
|
5
|
-
interface Options {
|
|
6
|
-
db?: SqbClient | SqbConnection;
|
|
7
|
-
defaultLimit?: number;
|
|
8
|
-
}
|
|
9
|
-
}
|
|
10
5
|
export declare class SqbEntityServiceBase<T> extends ApiService {
|
|
11
6
|
readonly typeClass: Type<T>;
|
|
12
7
|
defaultLimit: number;
|
|
13
8
|
db?: SqbClient | SqbConnection;
|
|
14
9
|
constructor(typeClass: Type<T>, options?: SqbEntityServiceBase.Options);
|
|
15
10
|
protected _count(options?: Repository.CountOptions): Promise<number>;
|
|
16
|
-
protected _create(data:
|
|
11
|
+
protected _create(data: DTO<T>, options?: Repository.CreateOptions): Promise<PartialDTO<T>>;
|
|
17
12
|
protected _delete(keyValue: any, options?: Repository.DeleteOptions): Promise<number>;
|
|
18
13
|
protected _deleteMany(options?: Repository.DeleteManyOptions): Promise<number>;
|
|
19
|
-
protected _find(keyValue: any, options?: Repository.FindOptions): Promise<
|
|
20
|
-
protected _findOne(options?: Repository.FindOneOptions): Promise<
|
|
21
|
-
protected _findMany(options?: Repository.FindManyOptions): Promise<
|
|
14
|
+
protected _find(keyValue: any, options?: Repository.FindOptions): Promise<PartialDTO<T> | undefined>;
|
|
15
|
+
protected _findOne(options?: Repository.FindOneOptions): Promise<PartialDTO<T> | undefined>;
|
|
16
|
+
protected _findMany(options?: Repository.FindManyOptions): Promise<PartialDTO<T>[]>;
|
|
22
17
|
protected _exists(options?: Repository.ExistsOptions): Promise<boolean>;
|
|
23
|
-
protected _update(keyValue: any, data: EntityInput<T>, options?: Repository.UpdateOptions): Promise<
|
|
24
|
-
protected _updateMany(data:
|
|
25
|
-
|
|
26
|
-
|
|
27
|
-
|
|
28
|
-
}): this;
|
|
18
|
+
protected _update(keyValue: any, data: EntityInput<T>, options?: Repository.UpdateOptions): Promise<PartialDTO<T> | undefined>;
|
|
19
|
+
protected _updateMany(data: PatchDTO<T>, options?: Repository.UpdateManyOptions): Promise<number>;
|
|
20
|
+
for(context: RequestContext | ApiService): this;
|
|
21
|
+
for(context: RequestContext | ApiService, attributes?: SqbEntityServiceBase.ExtendOptions): this;
|
|
22
|
+
for<O extends ApiService.ExtendOptions>(attributes: O): this & O;
|
|
29
23
|
protected _onError(error: unknown): Promise<void>;
|
|
30
24
|
protected getConnection(): SqbConnection | SqbClient | Promise<SqbConnection | SqbClient>;
|
|
31
|
-
protected
|
|
25
|
+
protected _instanceCompare(service: ApiService, context: RequestContext, attributes?: any): boolean;
|
|
32
26
|
protected onError?(error: unknown): void | Promise<void>;
|
|
33
|
-
protected transformData?(row:
|
|
27
|
+
protected transformData?(row: PartialDTO<T>): PartialDTO<T>;
|
|
28
|
+
}
|
|
29
|
+
export declare namespace SqbEntityServiceBase {
|
|
30
|
+
interface Options {
|
|
31
|
+
db?: SqbClient | SqbConnection;
|
|
32
|
+
defaultLimit?: number;
|
|
33
|
+
}
|
|
34
|
+
interface ExtendOptions extends Options, ApiService.ExtendOptions {
|
|
35
|
+
db?: SqbClient | SqbConnection;
|
|
36
|
+
}
|
|
34
37
|
}
|
|
@@ -1,5 +1,5 @@
|
|
|
1
|
-
import {
|
|
2
|
-
import {
|
|
1
|
+
import { Type } from 'ts-gems';
|
|
2
|
+
import { DTO, PartialDTO, PatchDTO } from '@opra/common';
|
|
3
3
|
import { EntityInput, Repository } from '@sqb/connect';
|
|
4
4
|
import { SqbEntityServiceBase } from './sqb-entity-service-base.js';
|
|
5
5
|
export declare namespace SqbEntityService {
|
|
@@ -10,13 +10,13 @@ export declare class SqbEntityService<T> extends SqbEntityServiceBase<T> {
|
|
|
10
10
|
readonly typeClass: Type<T>;
|
|
11
11
|
constructor(typeClass: Type<T>, options?: SqbEntityService.Options);
|
|
12
12
|
count(options?: Repository.CountOptions): Promise<number>;
|
|
13
|
-
create(data:
|
|
13
|
+
create(data: DTO<T>, options?: Repository.CreateOptions): Promise<PartialDTO<T>>;
|
|
14
14
|
delete(keyValue: any, options?: Repository.DeleteOptions): Promise<number>;
|
|
15
15
|
deleteMany(options?: Repository.DeleteManyOptions): Promise<number>;
|
|
16
|
-
find(keyValue: any, options?: Repository.FindOptions): Promise<
|
|
17
|
-
findOne(options?: Repository.FindOneOptions): Promise<
|
|
18
|
-
findMany(options?: Repository.FindManyOptions): Promise<
|
|
16
|
+
find(keyValue: any, options?: Repository.FindOptions): Promise<PartialDTO<T> | undefined>;
|
|
17
|
+
findOne(options?: Repository.FindOneOptions): Promise<PartialDTO<T> | undefined>;
|
|
18
|
+
findMany(options?: Repository.FindManyOptions): Promise<PartialDTO<T>[]>;
|
|
19
19
|
exists(options?: Repository.ExistsOptions): Promise<boolean>;
|
|
20
|
-
update(keyValue: any, data: EntityInput<T>, options?: Repository.UpdateOptions): Promise<
|
|
21
|
-
updateMany(data:
|
|
20
|
+
update(keyValue: any, data: EntityInput<T>, options?: Repository.UpdateOptions): Promise<PartialDTO<T> | undefined>;
|
|
21
|
+
updateMany(data: PatchDTO<T>, options?: Repository.UpdateManyOptions): Promise<number>;
|
|
22
22
|
}
|
package/types/sqb-singleton.d.ts
CHANGED
|
@@ -1,17 +1,17 @@
|
|
|
1
1
|
import { Maybe } from 'ts-gems';
|
|
2
|
-
import { ISingleton,
|
|
2
|
+
import { ISingleton, PartialDTO } from '@opra/common';
|
|
3
3
|
import { RequestContext } from '@opra/core';
|
|
4
4
|
import { SQBAdapter } from './sqb-adapter.js';
|
|
5
5
|
import { SqbEntityService } from './sqb-entity-service.js';
|
|
6
6
|
export declare abstract class SqbSingleton<T> implements ISingleton<T> {
|
|
7
|
-
create?(ctx: RequestContext): Promise<
|
|
7
|
+
create?(ctx: RequestContext): Promise<PartialDTO<T>>;
|
|
8
8
|
delete?(ctx: RequestContext): Promise<number>;
|
|
9
|
-
get?(ctx: RequestContext): Promise<Maybe<
|
|
10
|
-
update?(ctx: RequestContext): Promise<Maybe<
|
|
11
|
-
protected _create(ctx: RequestContext, prepared: SQBAdapter.TransformedRequest): Promise<
|
|
9
|
+
get?(ctx: RequestContext): Promise<Maybe<PartialDTO<T>>>;
|
|
10
|
+
update?(ctx: RequestContext): Promise<Maybe<PartialDTO<T>>>;
|
|
11
|
+
protected _create(ctx: RequestContext, prepared: SQBAdapter.TransformedRequest): Promise<PartialDTO<T>>;
|
|
12
12
|
protected _delete(ctx: RequestContext, prepared: SQBAdapter.TransformedRequest): Promise<number>;
|
|
13
|
-
protected _get(ctx: RequestContext, prepared: SQBAdapter.TransformedRequest): Promise<Maybe<
|
|
14
|
-
protected _update(ctx: RequestContext, prepared: SQBAdapter.TransformedRequest): Promise<Maybe<
|
|
13
|
+
protected _get(ctx: RequestContext, prepared: SQBAdapter.TransformedRequest): Promise<Maybe<PartialDTO<T>>>;
|
|
14
|
+
protected _update(ctx: RequestContext, prepared: SQBAdapter.TransformedRequest): Promise<Maybe<PartialDTO<T>>>;
|
|
15
15
|
protected _prepare(ctx: RequestContext): Promise<SQBAdapter.TransformedRequest>;
|
|
16
16
|
onPrepare?(ctx: RequestContext, prepared: SQBAdapter.TransformedRequest): SQBAdapter.TransformedRequest | Promise<SQBAdapter.TransformedRequest>;
|
|
17
17
|
protected abstract getService(ctx: RequestContext): SqbEntityService<T> | Promise<SqbEntityService<T>>;
|