@livequery/nestjs 1.0.38 → 1.0.39

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.
@@ -57,7 +57,6 @@ let LivequeryInterceptor = class LivequeryInterceptor {
57
57
  body: req.body,
58
58
  method: req.method.toLowerCase()
59
59
  };
60
- console.log({ req: req.livequery });
61
60
  const socket_id = req.headers.socket_id;
62
61
  socket_id && this.LivequeryWebsocketSync?.listen(socket_id, collection_ref, doc_id);
63
62
  return next.handle().pipe((0, operators_1.map)(data => ({ data })));
package/package.json CHANGED
@@ -3,7 +3,7 @@
3
3
  "repository": {
4
4
  "url": "git@github.com:livequery/nestjs.git"
5
5
  },
6
- "version": "1.0.38",
6
+ "version": "1.0.39",
7
7
  "description": "",
8
8
  "main": "build/index.js",
9
9
  "types": "build/index.d.ts",
@@ -1,28 +0,0 @@
1
- import { LivequeryRequest } from "@livequery/types";
2
- import { CallHandler, ExecutionContext } from "@nestjs/common";
3
- import { ModuleRef, Reflector } from "@nestjs/core";
4
- declare type Datasource = {
5
- query(req: LivequeryRequest): Promise<any>;
6
- };
7
- export declare class UseDatasource {
8
- private moduleRef;
9
- private reflector;
10
- private static ControllerList;
11
- constructor(moduleRef: ModuleRef, reflector: Reflector);
12
- static createDatasourceMapper<T = {}>(factory: {
13
- new (): Datasource;
14
- }): [(options: T & {
15
- _manual_query?: boolean;
16
- }) => <TFunction extends Function, Y>(target: object | TFunction, propertyKey?: string | symbol, descriptor?: TypedPropertyDescriptor<Y>) => void, () => {
17
- paths: {
18
- ref: string;
19
- schema_ref: string;
20
- is_collection: boolean;
21
- doc_id: string;
22
- collection_ref: string;
23
- }[];
24
- options: T;
25
- }[]];
26
- intercept(context: ExecutionContext, next: CallHandler): Promise<import("rxjs").Observable<any>>;
27
- }
28
- export {};
@@ -1,59 +0,0 @@
1
- "use strict";
2
- var __decorate = (this && this.__decorate) || function (decorators, target, key, desc) {
3
- var c = arguments.length, r = c < 3 ? target : desc === null ? desc = Object.getOwnPropertyDescriptor(target, key) : desc, d;
4
- if (typeof Reflect === "object" && typeof Reflect.decorate === "function") r = Reflect.decorate(decorators, target, key, desc);
5
- else for (var i = decorators.length - 1; i >= 0; i--) if (d = decorators[i]) r = (c < 3 ? d(r) : c > 3 ? d(target, key, r) : d(target, key)) || r;
6
- return c > 3 && r && Object.defineProperty(target, key, r), r;
7
- };
8
- var __metadata = (this && this.__metadata) || function (k, v) {
9
- if (typeof Reflect === "object" && typeof Reflect.metadata === "function") return Reflect.metadata(k, v);
10
- };
11
- var UseDatasource_1;
12
- Object.defineProperty(exports, "__esModule", { value: true });
13
- exports.UseDatasource = void 0;
14
- const common_1 = require("@nestjs/common");
15
- const core_1 = require("@nestjs/core");
16
- const LivequeryInterceptor_1 = require("./LivequeryInterceptor");
17
- const LivequeryRequest_1 = require("./LivequeryRequest");
18
- const PathHelper_1 = require("./PathHelper");
19
- const rxjs_1 = require("rxjs");
20
- let UseDatasource = UseDatasource_1 = class UseDatasource {
21
- moduleRef;
22
- reflector;
23
- static ControllerList = [];
24
- constructor(moduleRef, reflector) {
25
- this.moduleRef = moduleRef;
26
- this.reflector = reflector;
27
- }
28
- static createDatasourceMapper(factory) {
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({
33
- target: target.constructor,
34
- method,
35
- options
36
- }));
37
- const list = () => this.ControllerList.map(({ method, target, options }) => {
38
- const paths = PathHelper_1.PathHelper.nestjsPathResolver(target, method).map(path => {
39
- return PathHelper_1.PathHelper.livequeryPathExtractor(path);
40
- });
41
- return { paths, options: options };
42
- }).flat(2);
43
- return [decorator, list];
44
- }
45
- async intercept(context, next) {
46
- const request = context.switchToHttp().getRequest();
47
- const livequery = request[LivequeryRequest_1.LivequeryRequestKey];
48
- const { factory } = this.reflector.get(UseDatasource_1, context.getHandler());
49
- const ds = await this.moduleRef.get(factory);
50
- const result = await ds.query(livequery);
51
- return next.handle().pipe((0, rxjs_1.map)(data => data ?? result));
52
- }
53
- };
54
- UseDatasource = UseDatasource_1 = __decorate([
55
- (0, common_1.Injectable)(),
56
- __metadata("design:paramtypes", [core_1.ModuleRef,
57
- core_1.Reflector])
58
- ], UseDatasource);
59
- exports.UseDatasource = UseDatasource;