@livequery/nestjs 1.0.31 → 1.0.32
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.
|
@@ -7,12 +7,13 @@ declare type Datasource = {
|
|
|
7
7
|
export declare class UseDatasource {
|
|
8
8
|
private moduleRef;
|
|
9
9
|
private reflector;
|
|
10
|
-
static readonly UseDatasourceMetadata: unique symbol;
|
|
11
10
|
private static ControllerList;
|
|
12
11
|
constructor(moduleRef: ModuleRef, reflector: Reflector);
|
|
13
|
-
static createDatasourceMapper<T>(factory: {
|
|
12
|
+
static createDatasourceMapper<T = {}>(factory: {
|
|
14
13
|
new (): Datasource;
|
|
15
|
-
}): [(options: T
|
|
14
|
+
}): [(options: T & {
|
|
15
|
+
_manual_query?: boolean;
|
|
16
|
+
}) => <TFunction extends Function, Y>(target: object | TFunction, propertyKey?: string | symbol, descriptor?: TypedPropertyDescriptor<Y>) => void, () => {
|
|
16
17
|
paths: {
|
|
17
18
|
ref: string;
|
|
18
19
|
schema_ref: string;
|
|
@@ -20,14 +20,16 @@ const rxjs_1 = require("rxjs");
|
|
|
20
20
|
let UseDatasource = UseDatasource_1 = class UseDatasource {
|
|
21
21
|
moduleRef;
|
|
22
22
|
reflector;
|
|
23
|
-
static UseDatasourceMetadata = Symbol();
|
|
24
23
|
static ControllerList = [];
|
|
25
24
|
constructor(moduleRef, reflector) {
|
|
26
25
|
this.moduleRef = moduleRef;
|
|
27
26
|
this.reflector = reflector;
|
|
28
27
|
}
|
|
29
28
|
static createDatasourceMapper(factory) {
|
|
30
|
-
const decorator = (options) => (0, common_1.applyDecorators)((0, common_1.UseInterceptors)(LivequeryInterceptor_1.LivequeryInterceptor),
|
|
29
|
+
const decorator = (options) => (0, common_1.applyDecorators)((0, common_1.UseInterceptors)(LivequeryInterceptor_1.LivequeryInterceptor), ...options._manual_query == true ? [] : [
|
|
30
|
+
(0, common_1.SetMetadata)(UseDatasource_1, { options, factory }),
|
|
31
|
+
(0, common_1.UseInterceptors)(this)
|
|
32
|
+
], (target, method) => this.ControllerList.push({
|
|
31
33
|
target: target.constructor,
|
|
32
34
|
method,
|
|
33
35
|
options
|
|
@@ -43,7 +45,7 @@ let UseDatasource = UseDatasource_1 = class UseDatasource {
|
|
|
43
45
|
async intercept(context, next) {
|
|
44
46
|
const request = context.switchToHttp().getRequest();
|
|
45
47
|
const livequery = request[LivequeryRequest_1.LivequeryRequestKey];
|
|
46
|
-
const { factory } = this.reflector.get(UseDatasource_1
|
|
48
|
+
const { factory } = this.reflector.get(UseDatasource_1, context.getHandler());
|
|
47
49
|
const ds = await this.moduleRef.get(factory);
|
|
48
50
|
const result = await ds.query(livequery);
|
|
49
51
|
return next.handle().pipe((0, rxjs_1.map)(data => data ?? result));
|