@livequery/nestjs 1.0.50 → 1.0.75

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/build/index.d.ts CHANGED
@@ -1,7 +1,7 @@
1
- export { LivequeryRequest } from './src/LivequeryRequest';
2
- export * from './src/LivequeryResponse';
3
- export * from './src/LivequeryInterceptor';
4
- export * from './src/LivequeryWebsocketSync';
5
- export * from './src/helpers/createDatasourceMapper';
6
- export { LivequeryDatasourceInterceptors } from './src/LivequeryDatasourceInterceptors';
7
- export { UseWebsocketPublicKey, UseWebsocketPrivateKey } from './src/UseWebsocketShareKeyPair';
1
+ export { LivequeryRequest } from './src/LivequeryRequest.js';
2
+ export { LivequeryResponse } from './src/LivequeryResponse.js';
3
+ export { LivequeryInterceptor, RealtimeSubscription, UseLivequeryInterceptor } from './src/LivequeryInterceptor.js';
4
+ export { LivequeryWebsocketSync } from './src/LivequeryWebsocketSync.js';
5
+ export { createDatasourceMapper } from './src/helpers/createDatasourceMapper.js';
6
+ export { LivequeryDatasourceInterceptors, XXXXX } from './src/LivequeryDatasourceInterceptors.js';
7
+ export { UseWebsocketPublicKey, UseWebsocketPrivateKey } from './src/UseWebsocketShareKeyPair.js';
package/build/index.js CHANGED
@@ -1,28 +1,8 @@
1
- "use strict";
2
- var __createBinding = (this && this.__createBinding) || (Object.create ? (function(o, m, k, k2) {
3
- if (k2 === undefined) k2 = k;
4
- var desc = Object.getOwnPropertyDescriptor(m, k);
5
- if (!desc || ("get" in desc ? !m.__esModule : desc.writable || desc.configurable)) {
6
- desc = { enumerable: true, get: function() { return m[k]; } };
7
- }
8
- Object.defineProperty(o, k2, desc);
9
- }) : (function(o, m, k, k2) {
10
- if (k2 === undefined) k2 = k;
11
- o[k2] = m[k];
12
- }));
13
- var __exportStar = (this && this.__exportStar) || function(m, exports) {
14
- for (var p in m) if (p !== "default" && !Object.prototype.hasOwnProperty.call(exports, p)) __createBinding(exports, m, p);
15
- };
16
- Object.defineProperty(exports, "__esModule", { value: true });
17
- exports.UseWebsocketPrivateKey = exports.UseWebsocketPublicKey = exports.LivequeryDatasourceInterceptors = exports.LivequeryRequest = void 0;
18
- var LivequeryRequest_1 = require("./src/LivequeryRequest");
19
- Object.defineProperty(exports, "LivequeryRequest", { enumerable: true, get: function () { return LivequeryRequest_1.LivequeryRequest; } });
20
- __exportStar(require("./src/LivequeryResponse"), exports);
21
- __exportStar(require("./src/LivequeryInterceptor"), exports);
22
- __exportStar(require("./src/LivequeryWebsocketSync"), exports);
23
- __exportStar(require("./src/helpers/createDatasourceMapper"), exports);
24
- var LivequeryDatasourceInterceptors_1 = require("./src/LivequeryDatasourceInterceptors");
25
- Object.defineProperty(exports, "LivequeryDatasourceInterceptors", { enumerable: true, get: function () { return LivequeryDatasourceInterceptors_1.LivequeryDatasourceInterceptors; } });
26
- var UseWebsocketShareKeyPair_1 = require("./src/UseWebsocketShareKeyPair");
27
- Object.defineProperty(exports, "UseWebsocketPublicKey", { enumerable: true, get: function () { return UseWebsocketShareKeyPair_1.UseWebsocketPublicKey; } });
28
- Object.defineProperty(exports, "UseWebsocketPrivateKey", { enumerable: true, get: function () { return UseWebsocketShareKeyPair_1.UseWebsocketPrivateKey; } });
1
+ export { LivequeryRequest } from './src/LivequeryRequest.js';
2
+ export { LivequeryResponse } from './src/LivequeryResponse.js';
3
+ export { LivequeryInterceptor, UseLivequeryInterceptor } from './src/LivequeryInterceptor.js';
4
+ export { LivequeryWebsocketSync } from './src/LivequeryWebsocketSync.js';
5
+ export { createDatasourceMapper } from './src/helpers/createDatasourceMapper.js';
6
+ export { LivequeryDatasourceInterceptors, XXXXX } from './src/LivequeryDatasourceInterceptors.js';
7
+ export { UseWebsocketPublicKey, UseWebsocketPrivateKey } from './src/UseWebsocketShareKeyPair.js';
8
+ //# sourceMappingURL=index.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"index.js","sourceRoot":"","sources":["../index.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,gBAAgB,EAAE,MAAM,2BAA2B,CAAA;AAC5D,OAAO,EAAE,iBAAiB,EAAE,MAAM,4BAA4B,CAAA;AAC9D,OAAO,EAAE,oBAAoB,EAAwB,uBAAuB,EAAE,MAAM,+BAA+B,CAAA;AACnH,OAAO,EAAE,sBAAsB,EAAE,MAAM,iCAAiC,CAAA;AACxE,OAAO,EAAE,sBAAsB,EAAE,MAAM,yCAAyC,CAAA;AAChF,OAAO,EAAE,+BAA+B,EAAE,KAAK,EAAE,MAAM,0CAA0C,CAAA;AACjG,OAAO,EAAE,qBAAqB,EAAE,sBAAsB,EAAE,MAAM,mCAAmC,CAAA"}
@@ -0,0 +1,28 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ exports.XXXXX = exports.LivequeryDatasourceInterceptors = exports.$__datasource_factory_token = exports.DatasourceList = void 0;
4
+ const tslib_1 = require("tslib");
5
+ const common_1 = require("@nestjs/common");
6
+ const rxjs_1 = require("rxjs");
7
+ const core_1 = require("@nestjs/core");
8
+ exports.DatasourceList = new Map();
9
+ exports.$__datasource_factory_token = Symbol();
10
+ let LivequeryDatasourceInterceptors = exports.LivequeryDatasourceInterceptors = class LivequeryDatasourceInterceptors {
11
+ moduleRef;
12
+ constructor(moduleRef) {
13
+ this.moduleRef = moduleRef;
14
+ }
15
+ async intercept(ctx, next) {
16
+ const token = Reflect.getMetadata(exports.$__datasource_factory_token, ctx.getHandler());
17
+ const datasource = exports.DatasourceList.has(token) ? exports.DatasourceList.get(token) : this.moduleRef.get(token);
18
+ const req = ctx.switchToHttp().getRequest();
19
+ req.livequery_response = await datasource.query(req.livequery);
20
+ return next.handle().pipe((0, rxjs_1.map)(rs => rs ?? req.livequery_response));
21
+ }
22
+ };
23
+ exports.LivequeryDatasourceInterceptors = LivequeryDatasourceInterceptors = tslib_1.__decorate([
24
+ (0, common_1.Injectable)(),
25
+ tslib_1.__metadata("design:paramtypes", [core_1.ModuleRef])
26
+ ], LivequeryDatasourceInterceptors);
27
+ exports.XXXXX = core_1.ModuleRef;
28
+ //# sourceMappingURL=LivequeryDatasourceInterceptors.cjs.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"LivequeryDatasourceInterceptors.cjs","sourceRoot":"","sources":["../../src/LivequeryDatasourceInterceptors.cts"],"names":[],"mappings":";;;;AAAA,2CAAoG;AACpG,+BAA2B;AAE3B,uCAAwC;AAM3B,QAAA,cAAc,GAAG,IAAI,GAAG,EAA4C,CAAA;AACpE,QAAA,2BAA2B,GAAG,MAAM,EAAE,CAAA;AAK5C,IAAM,+BAA+B,6CAArC,MAAM,+BAA+B;IAEpB;IAApB,YAAoB,SAAoB;QAApB,cAAS,GAAT,SAAS,CAAW;IAAI,CAAC;IAE7C,KAAK,CAAC,SAAS,CAAC,GAAqB,EAAE,IAAiB;QAEpD,MAAM,KAAK,GAAG,OAAO,CAAC,WAAW,CAAC,mCAA2B,EAAE,GAAG,CAAC,UAAU,EAAE,CAAC,CAAA;QAChF,MAAM,UAAU,GAAG,sBAAc,CAAC,GAAG,CAAC,KAAK,CAAC,CAAC,CAAC,CAAC,sBAAc,CAAC,GAAG,CAAC,KAAK,CAAC,CAAC,CAAC,CAAC,IAAI,CAAC,SAAS,CAAC,GAAG,CAAC,KAAK,CAAC,CAAA;QACpG,MAAM,GAAG,GAAG,GAAG,CAAC,YAAY,EAAE,CAAC,UAAU,EAAE,CAAA;QAC3C,GAAG,CAAC,kBAAkB,GAAG,MAAM,UAAU,CAAC,KAAK,CAAC,GAAG,CAAC,SAAS,CAAC,CAAA;QAC9D,OAAO,IAAI,CAAC,MAAM,EAAE,CAAC,IAAI,CACrB,IAAA,UAAG,EAAC,EAAE,CAAC,EAAE,CAAC,EAAE,IAAI,GAAG,CAAC,kBAAkB,CAAC,CAC1C,CAAA;IACL,CAAC;CACJ,CAAA;0CAdY,+BAA+B;IAD3C,IAAA,mBAAU,GAAE;6CAGsB,gBAAS;GAF/B,+BAA+B,CAc3C;AAGY,QAAA,KAAK,GAAG,gBAAS,CAAA"}
@@ -0,0 +1,17 @@
1
+ import { CallHandler, ExecutionContext, NestInterceptor } from '@nestjs/common';
2
+ import { LivequeryRequest } from '@livequery/types';
3
+ import { ModuleRef } from '@nestjs/core';
4
+ export type DatasourceOptions<T> = Array<T & {
5
+ refs: string[];
6
+ }>;
7
+ export type Datasource<T = any> = {
8
+ query(query: LivequeryRequest): any;
9
+ };
10
+ export declare const DatasourceList: Map<new (...args: any[]) => Datasource, Datasource<any>>;
11
+ export declare const $__datasource_factory_token: unique symbol;
12
+ export declare class LivequeryDatasourceInterceptors implements NestInterceptor {
13
+ private moduleRef;
14
+ constructor(moduleRef: ModuleRef);
15
+ intercept(ctx: ExecutionContext, next: CallHandler): Promise<import("rxjs").Observable<any>>;
16
+ }
17
+ export declare const XXXXX: typeof ModuleRef;
@@ -14,3 +14,4 @@ export declare class LivequeryDatasourceInterceptors implements NestInterceptor
14
14
  constructor(moduleRef: ModuleRef);
15
15
  intercept(ctx: ExecutionContext, next: CallHandler): Promise<import("rxjs").Observable<any>>;
16
16
  }
17
+ export declare const XXXXX: typeof ModuleRef;
@@ -1,34 +1,25 @@
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
- Object.defineProperty(exports, "__esModule", { value: true });
12
- exports.LivequeryDatasourceInterceptors = exports.$__datasource_factory_token = exports.DatasourceList = void 0;
13
- const common_1 = require("@nestjs/common");
14
- const rxjs_1 = require("rxjs");
15
- const core_1 = require("@nestjs/core");
16
- exports.DatasourceList = new Map();
17
- exports.$__datasource_factory_token = Symbol();
18
- let LivequeryDatasourceInterceptors = exports.LivequeryDatasourceInterceptors = class LivequeryDatasourceInterceptors {
1
+ import { __decorate, __metadata } from "tslib";
2
+ import { Injectable } from '@nestjs/common';
3
+ import { map } from 'rxjs';
4
+ import { ModuleRef } from '@nestjs/core';
5
+ export const DatasourceList = new Map();
6
+ export const $__datasource_factory_token = Symbol();
7
+ export let LivequeryDatasourceInterceptors = class LivequeryDatasourceInterceptors {
19
8
  moduleRef;
20
9
  constructor(moduleRef) {
21
10
  this.moduleRef = moduleRef;
22
11
  }
23
12
  async intercept(ctx, next) {
24
- const token = Reflect.getMetadata(exports.$__datasource_factory_token, ctx.getHandler());
25
- const datasource = exports.DatasourceList.has(token) ? exports.DatasourceList.get(token) : this.moduleRef.get(token);
13
+ const token = Reflect.getMetadata($__datasource_factory_token, ctx.getHandler());
14
+ const datasource = DatasourceList.has(token) ? DatasourceList.get(token) : this.moduleRef.get(token);
26
15
  const req = ctx.switchToHttp().getRequest();
27
16
  req.livequery_response = await datasource.query(req.livequery);
28
- return next.handle().pipe((0, rxjs_1.map)(rs => rs ?? req.livequery_response));
17
+ return next.handle().pipe(map(rs => rs ?? req.livequery_response));
29
18
  }
30
19
  };
31
- exports.LivequeryDatasourceInterceptors = LivequeryDatasourceInterceptors = __decorate([
32
- (0, common_1.Injectable)(),
33
- __metadata("design:paramtypes", [core_1.ModuleRef])
20
+ LivequeryDatasourceInterceptors = __decorate([
21
+ Injectable(),
22
+ __metadata("design:paramtypes", [ModuleRef])
34
23
  ], LivequeryDatasourceInterceptors);
24
+ export const XXXXX = ModuleRef;
25
+ //# sourceMappingURL=LivequeryDatasourceInterceptors.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"LivequeryDatasourceInterceptors.js","sourceRoot":"","sources":["../../src/LivequeryDatasourceInterceptors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ionContext, NestInterceptor } from "@nestjs/common";
2
- import { LivequeryWebsocketSync } from "./LivequeryWebsocketSync";
2
+ import { LivequeryWebsocketSync } from "./LivequeryWebsocketSync.js";
3
3
  export type RealtimeSubscription = {
4
4
  collection_ref: string;
5
5
  doc_id: string;
@@ -1,25 +1,11 @@
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 __param = (this && this.__param) || function (paramIndex, decorator) {
12
- return function (target, key) { decorator(target, key, paramIndex); }
13
- };
14
- Object.defineProperty(exports, "__esModule", { value: true });
15
- exports.UseLivequeryInterceptor = exports.LivequeryInterceptor = void 0;
16
- const common_1 = require("@nestjs/common");
17
- const operators_1 = require("rxjs/operators");
18
- const PathHelper_1 = require("./helpers/PathHelper");
19
- const LivequeryWebsocketSync_1 = require("./LivequeryWebsocketSync");
20
- const UseWebsocketShareKeyPair_1 = require("./UseWebsocketShareKeyPair");
21
- const JWT = require('jsonwebtoken');
22
- let LivequeryInterceptor = exports.LivequeryInterceptor = class LivequeryInterceptor {
1
+ import { __decorate, __metadata, __param } from "tslib";
2
+ import { Inject, Injectable, Optional, UseInterceptors } from "@nestjs/common";
3
+ import { map } from "rxjs/operators";
4
+ import { PathHelper } from "./helpers/PathHelper.js";
5
+ import { LivequeryWebsocketSync } from "./LivequeryWebsocketSync.js";
6
+ import { InjectWebsocketPrivateKey } from "./UseWebsocketShareKeyPair.js";
7
+ import JWT from 'jsonwebtoken';
8
+ export let LivequeryInterceptor = class LivequeryInterceptor {
23
9
  LivequeryWebsocketSync;
24
10
  secret_or_private_key;
25
11
  constructor(LivequeryWebsocketSync, secret_or_private_key) {
@@ -40,8 +26,8 @@ let LivequeryInterceptor = exports.LivequeryInterceptor = class LivequeryInterce
40
26
  return [name, expression || 'eq', rest[key]];
41
27
  }
42
28
  });
43
- const { ref, is_collection, collection_ref, doc_id, } = PathHelper_1.PathHelper.parseHttpRequestPath(req._parsedUrl.pathname);
44
- const { collection_ref: schema_collection_ref, ref: schema_ref } = PathHelper_1.PathHelper.parseHttpRequestPath(req.route.path);
29
+ const { ref, is_collection, collection_ref, doc_id, } = PathHelper.parseHttpRequestPath(req._parsedUrl.pathname);
30
+ const { collection_ref: schema_collection_ref, ref: schema_ref } = PathHelper.parseHttpRequestPath(req.route.path);
45
31
  req.livequery = {
46
32
  ref,
47
33
  schema_ref,
@@ -63,20 +49,20 @@ let LivequeryInterceptor = exports.LivequeryInterceptor = class LivequeryInterce
63
49
  };
64
50
  req.method == 'GET' && req.headers.socket_id && this.LivequeryWebsocketSync?.listen(req.headers.socket_id, { collection_ref, doc_id });
65
51
  const realtime_token = await new Promise(s => {
66
- if (this.LivequeryWebsocketSync || !this.secret_or_private_key || req.method.toLowerCase() != 'get' || req.query._cursor)
52
+ if (!this.secret_or_private_key || req.method.toLowerCase() != 'get')
67
53
  return s(null);
68
54
  JWT.sign({ collection_ref, doc_id }, this.secret_or_private_key, {}, (error, data) => s(error ? null : data));
69
55
  });
70
- return next.handle().pipe((0, operators_1.map)(data => ({ data: { ...data, realtime_token } })));
56
+ return next.handle().pipe(map(data => ({ data: { ...data, realtime_token } })));
71
57
  }
72
58
  };
73
- exports.LivequeryInterceptor = LivequeryInterceptor = __decorate([
74
- (0, common_1.Injectable)(),
75
- __param(0, (0, common_1.Optional)()),
76
- __param(0, (0, common_1.Inject)((0, common_1.forwardRef)(() => LivequeryWebsocketSync_1.LivequeryWebsocketSync))),
77
- __param(1, (0, common_1.Optional)()),
78
- __param(1, (0, UseWebsocketShareKeyPair_1.InjectWebsocketPrivateKey)()),
79
- __metadata("design:paramtypes", [LivequeryWebsocketSync_1.LivequeryWebsocketSync, String])
59
+ LivequeryInterceptor = __decorate([
60
+ Injectable(),
61
+ __param(0, Optional()),
62
+ __param(0, Inject(LivequeryWebsocketSync)),
63
+ __param(1, Optional()),
64
+ __param(1, InjectWebsocketPrivateKey()),
65
+ __metadata("design:paramtypes", [LivequeryWebsocketSync, String])
80
66
  ], LivequeryInterceptor);
81
- const UseLivequeryInterceptor = () => (0, common_1.UseInterceptors)(LivequeryInterceptor);
82
- exports.UseLivequeryInterceptor = UseLivequeryInterceptor;
67
+ export const UseLivequeryInterceptor = () => UseInterceptors(LivequeryInterceptor);
68
+ //# sourceMappingURL=LivequeryInterceptor.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"LivequeryInterceptor.js","sourceRoot":"","sources":["../../src/LivequeryInterceptor.ts"],"names":[],"mappings":";AACA,OAAO,EAA6C,MAAM,EAAE,UAAU,EAAmB,QAAQ,EAAE,eAAe,EAAE,MAAM,gBAAgB,CAAC;AAC3I,OAAO,EAAE,GAAG,EAAE,MAAM,gBAAgB,CAAC;AACrC,OAAO,EAAE,UAAU,EAAE,MAAM,yBAAyB,CAAC;AACrD,OAAO,EAAE,sBAAsB,EAAE,MAAM,6BAA6B,CAAC;AACrE,OAAO,EAAE,yBAAyB,EAAE,MAAM,+BAA+B,CAAC;AAC1E,OAAO,GAAG,MAAM,cAAc,CAAA;AAQvB,WAAM,oBAAoB,GAA1B,MAAM,oBAAoB;IAG2B;IACH;IAFrD,YACwD,sBAA8C,EACjD,qBAA6B;QAD1B,2BAAsB,GAAtB,sBAAsB,CAAwB;QACjD,0BAAqB,GAArB,qBAAqB,CAAQ;IAElF,CAAC;IAED,KAAK,CAAC,SAAS,CAAC,OAAyB,EAAE,IAAiB;QAExD,MAAM,GAAG,GA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,oBAAoB,CAoEhC;AAGD,MAAM,CAAC,MAAM,uBAAuB,GAAG,GAAG,EAAE,CAAC,eAAe,CAAC,oBAAoB,CAAC,CAAA"}
@@ -1,8 +1,6 @@
1
- "use strict";
2
- Object.defineProperty(exports, "__esModule", { value: true });
3
- exports.LivequeryRequest = void 0;
4
- const common_1 = require("@nestjs/common");
5
- exports.LivequeryRequest = (0, common_1.createParamDecorator)((data, ctx) => {
1
+ import { createParamDecorator } from "@nestjs/common";
2
+ export const LivequeryRequest = createParamDecorator((data, ctx) => {
6
3
  const request = ctx.switchToHttp().getRequest();
7
4
  return request.livequery;
8
5
  });
6
+ //# sourceMappingURL=LivequeryRequest.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"LivequeryRequest.js","sourceRoot":"","sources":["../../src/LivequeryRequest.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,oBAAoB,EAAoB,MAAM,gBAAgB,CAAC;AAGxE,MAAM,CAAC,MAAM,gBAAgB,GAAG,oBAAoB,CAAC,CAAC,IAAa,EAAE,GAAqB,EAAE,EAAE;IAC1F,MAAM,OAAO,GAAG,GAAG,CAAC,YAAY,EAAE,CAAC,UAAU,EAAE,CAAA;IAC/C,OAAO,OAAO,CAAC,SAAS,CAAA;AAC5B,CAAC,CAAC,CAAA"}
@@ -1,5 +1,3 @@
1
- "use strict";
2
- Object.defineProperty(exports, "__esModule", { value: true });
3
- exports.LivequeryResponse = void 0;
4
- const common_1 = require("@nestjs/common");
5
- exports.LivequeryResponse = (0, common_1.createParamDecorator)((data, ctx) => ctx.switchToHttp().getRequest().livequery_response);
1
+ import { createParamDecorator } from "@nestjs/common";
2
+ export const LivequeryResponse = createParamDecorator((data, ctx) => ctx.switchToHttp().getRequest().livequery_response);
3
+ //# sourceMappingURL=LivequeryResponse.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"LivequeryResponse.js","sourceRoot":"","sources":["../../src/LivequeryResponse.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,oBAAoB,EAAoB,MAAM,gBAAgB,CAAC;AASxE,MAAM,CAAC,MAAM,iBAAiB,GAAG,oBAAoB,CACjD,CAAC,IAAa,EAAE,GAAqB,EAAE,EAAE,CAAC,GAAG,CAAC,YAAY,EAAE,CAAC,UAAU,EAAE,CAAC,kBAAkB,CAC/F,CAAA"}
@@ -1,12 +1,12 @@
1
1
  import { Subject } from "rxjs";
2
- import { LivequeryInterceptor, RealtimeSubscription } from "./LivequeryInterceptor";
2
+ import { RealtimeSubscription } from "./LivequeryInterceptor.js";
3
3
  import { UpdatedData, UpdatedDataType } from "@livequery/types";
4
4
  export declare class LivequeryWebsocketSync {
5
5
  private secret_or_public_key;
6
6
  private connections;
7
7
  private refs;
8
8
  readonly changes: Subject<UpdatedData>;
9
- constructor(secret_or_public_key: string, LivequeryInterceptor: LivequeryInterceptor);
9
+ constructor(secret_or_public_key: string);
10
10
  private handleDisconnect;
11
11
  sync_db_change<T extends {
12
12
  id: string;
@@ -14,7 +14,7 @@ export declare class LivequeryWebsocketSync {
14
14
  type: UpdatedDataType;
15
15
  old_data?: T;
16
16
  old_ref: string;
17
- new_data?: T;
17
+ new_data?: Partial<T>;
18
18
  new_ref: string;
19
19
  }): Promise<void>;
20
20
  start({ id }: {
@@ -1,34 +1,17 @@
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 __param = (this && this.__param) || function (paramIndex, decorator) {
12
- return function (target, key) { decorator(target, key, paramIndex); }
13
- };
14
- Object.defineProperty(exports, "__esModule", { value: true });
15
- exports.LivequeryWebsocketSync = void 0;
16
- const websockets_1 = require("@nestjs/websockets");
17
- const rxjs_1 = require("rxjs");
18
- const LivequeryInterceptor_1 = require("./LivequeryInterceptor");
19
- const crypto_1 = require("crypto");
20
- const common_1 = require("@nestjs/common");
21
- const UseWebsocketShareKeyPair_1 = require("./UseWebsocketShareKeyPair");
22
- const JWT = require('jsonwebtoken');
23
- let LivequeryWebsocketSync = exports.LivequeryWebsocketSync = class LivequeryWebsocketSync {
1
+ import { __decorate, __metadata, __param } from "tslib";
2
+ import { ConnectedSocket, MessageBody, SubscribeMessage, WebSocketGateway } from "@nestjs/websockets";
3
+ import { Subject } from "rxjs";
4
+ import { randomUUID } from 'crypto';
5
+ import { Optional } from "@nestjs/common";
6
+ import { InjectWebsocketPublicKey } from "./UseWebsocketShareKeyPair.js";
7
+ import JWT from 'jsonwebtoken';
8
+ export let LivequeryWebsocketSync = class LivequeryWebsocketSync {
24
9
  secret_or_public_key;
25
10
  connections = new Map();
26
11
  refs = new Map();
27
- changes = new rxjs_1.Subject();
28
- constructor(secret_or_public_key, LivequeryInterceptor) {
12
+ changes = new Subject();
13
+ constructor(secret_or_public_key) {
29
14
  this.secret_or_public_key = secret_or_public_key;
30
- if (!LivequeryInterceptor && !secret_or_public_key)
31
- throw new Error('Missing api-websocket key pair, please use UseWebsocketPublicKey in providers list');
32
15
  this.changes.subscribe(({ ref, data, type, ...rest }) => {
33
16
  const connections = new Set([
34
17
  ...this.refs.get(ref)?.values() || [],
@@ -47,9 +30,10 @@ let LivequeryWebsocketSync = exports.LivequeryWebsocketSync = class LivequeryWeb
47
30
  this.connections.delete(socket.id);
48
31
  }
49
32
  async sync_db_change(event) {
33
+ const id = event.old_data.id || event.new_data.id;
50
34
  if (event.type == 'added') {
51
35
  this.changes.next({
52
- data: event.new_data,
36
+ data: { ...event.new_data, id },
53
37
  ref: event.new_ref,
54
38
  type: event.type
55
39
  });
@@ -60,33 +44,33 @@ let LivequeryWebsocketSync = exports.LivequeryWebsocketSync = class LivequeryWeb
60
44
  this.changes.next({
61
45
  type: 'modified',
62
46
  ref: event.new_ref,
63
- data: event.new_data
47
+ data: { ...event.new_data, id }
64
48
  });
65
49
  }
66
50
  else {
67
51
  this.changes.next({
68
52
  type: 'removed',
69
53
  ref: event.old_ref,
70
- data: { id: event.old_data.id }
54
+ data: { id }
71
55
  });
72
56
  this.changes.next({
73
57
  type: 'added',
74
58
  ref: event.new_ref,
75
- data: { ...event.old_data || {}, ...event.new_data || {}, id: event.old_data.id }
59
+ data: { ...event.old_data || {}, ...event.new_data || {}, id }
76
60
  });
77
61
  }
78
62
  return;
79
63
  }
80
64
  if (event.type == 'removed') {
81
65
  this.changes.next({
82
- data: { id: event.old_data.id },
66
+ data: { id },
83
67
  ref: event.old_ref,
84
68
  type: event.type
85
69
  });
86
70
  return;
87
71
  }
88
72
  }
89
- start({ id = (0, crypto_1.randomUUID)() }, socket) {
73
+ start({ id = randomUUID() }, socket) {
90
74
  if (typeof id == 'string' && id.length < 40) {
91
75
  socket.id = id;
92
76
  this.connections.set(id, { socket, refs: new Set() });
@@ -115,34 +99,33 @@ let LivequeryWebsocketSync = exports.LivequeryWebsocketSync = class LivequeryWeb
115
99
  }
116
100
  };
117
101
  __decorate([
118
- (0, websockets_1.SubscribeMessage)('start'),
119
- __param(0, (0, websockets_1.MessageBody)()),
120
- __param(1, (0, websockets_1.ConnectedSocket)()),
102
+ SubscribeMessage('start'),
103
+ __param(0, MessageBody()),
104
+ __param(1, ConnectedSocket()),
121
105
  __metadata("design:type", Function),
122
106
  __metadata("design:paramtypes", [Object, Object]),
123
107
  __metadata("design:returntype", void 0)
124
108
  ], LivequeryWebsocketSync.prototype, "start", null);
125
109
  __decorate([
126
- (0, websockets_1.SubscribeMessage)('subscribe'),
127
- __param(0, (0, websockets_1.MessageBody)()),
128
- __param(1, (0, websockets_1.ConnectedSocket)()),
110
+ SubscribeMessage('subscribe'),
111
+ __param(0, MessageBody()),
112
+ __param(1, ConnectedSocket()),
129
113
  __metadata("design:type", Function),
130
114
  __metadata("design:paramtypes", [Object, Object]),
131
115
  __metadata("design:returntype", Promise)
132
116
  ], LivequeryWebsocketSync.prototype, "subscribe", null);
133
117
  __decorate([
134
- (0, websockets_1.SubscribeMessage)('unsubscribe'),
135
- __param(0, (0, websockets_1.MessageBody)()),
136
- __param(1, (0, websockets_1.ConnectedSocket)()),
118
+ SubscribeMessage('unsubscribe'),
119
+ __param(0, MessageBody()),
120
+ __param(1, ConnectedSocket()),
137
121
  __metadata("design:type", Function),
138
122
  __metadata("design:paramtypes", [Object, Object]),
139
123
  __metadata("design:returntype", void 0)
140
124
  ], LivequeryWebsocketSync.prototype, "unsubscribe", null);
141
- exports.LivequeryWebsocketSync = LivequeryWebsocketSync = __decorate([
142
- (0, websockets_1.WebSocketGateway)({ path: process.env.REALTIME_UPDATE_SOCKET_PATH || '/livequery/realtime-updates' }),
143
- __param(0, (0, common_1.Optional)()),
144
- __param(0, (0, UseWebsocketShareKeyPair_1.InjectWebsocketPublicKey)()),
145
- __param(1, (0, common_1.Optional)()),
146
- __param(1, (0, common_1.Inject)((0, common_1.forwardRef)(() => LivequeryInterceptor_1.LivequeryInterceptor))),
147
- __metadata("design:paramtypes", [String, LivequeryInterceptor_1.LivequeryInterceptor])
125
+ LivequeryWebsocketSync = __decorate([
126
+ WebSocketGateway({ path: process.env.REALTIME_UPDATE_SOCKET_PATH || '/livequery/realtime-updates' }),
127
+ __param(0, Optional()),
128
+ __param(0, InjectWebsocketPublicKey()),
129
+ __metadata("design:paramtypes", [String])
148
130
  ], LivequeryWebsocketSync);
131
+ //# sourceMappingURL=LivequeryWebsocketSync.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"LivequeryWebsocketSync.js","sourceRoot":"","sources":["../../src/LivequeryWebsocketSync.ts"],"names":[],"mappings":";AACA,OAA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AAC,IAAI,CAAC,GAAG,CAAC,GAAG,CAAC,CAAC,GAAG,CAAC,aAAa,EAAE,EAAE,MAAM,EAAE,CAAC,CAAA;SAE9F;IACL,CAAC;CACJ,CAAA;AAnDG;IADC,gBAAgB,CAAC,OAAO,CAAC;IAErB,WAAA,WAAW,EAAE,CAAA;IACb,WAAA,eAAe,EAAE,CAAA;;;;mDAOrB;AAGK;IADL,gBAAgB,CAAC,WAAW,CAAC;IAEzB,WAAA,WAAW,EAAE,CAAA;IACb,WAAA,eAAe,EAAE,CAAA;;;;uDAYrB;AAGD;IADC,gBAAgB,CAAC,aAAa,CAAC;IAE3B,WAAA,WAAW,EAAE,CAAA;IACb,WAAA,eAAe,EAAE,CAAA;;;;yDAIrB;AAhHQ,sBAAsB;IADlC,gBAAgB,CAAC,EAAE,IAAI,EAAE,OAAO,CAAC,GAAG,CAAC,2BAA2B,IAAI,6BAA6B,EAAE,CAAC;IAS5F,WAAA,QAAQ,EAAE,CAAA;IAAE,WAAA,wBAAwB,EAAE,CAAA;;GARlC,sBAAsB,CAgIlC"}
@@ -1,20 +1,14 @@
1
- "use strict";
2
- Object.defineProperty(exports, "__esModule", { value: true });
3
- exports.UseWebsocketPrivateKey = exports.UseWebsocketPublicKey = exports.InjectWebsocketPrivateKey = exports.InjectWebsocketPublicKey = void 0;
4
- const common_1 = require("@nestjs/common");
1
+ import { Inject } from "@nestjs/common";
5
2
  const WebsocketPublicKey = 'WebsocketPublicKey';
6
3
  const WebsocketPrivateKey = 'WebsocketPrivateKey';
7
- const InjectWebsocketPublicKey = () => (0, common_1.Inject)(WebsocketPublicKey);
8
- exports.InjectWebsocketPublicKey = InjectWebsocketPublicKey;
9
- const InjectWebsocketPrivateKey = () => (0, common_1.Inject)(WebsocketPrivateKey);
10
- exports.InjectWebsocketPrivateKey = InjectWebsocketPrivateKey;
11
- const UseWebsocketPublicKey = (secret_or_public_key) => ({
4
+ export const InjectWebsocketPublicKey = () => Inject(WebsocketPublicKey);
5
+ export const InjectWebsocketPrivateKey = () => Inject(WebsocketPrivateKey);
6
+ export const UseWebsocketPublicKey = (secret_or_public_key) => ({
12
7
  provide: WebsocketPublicKey,
13
8
  useFactory: () => secret_or_public_key
14
9
  });
15
- exports.UseWebsocketPublicKey = UseWebsocketPublicKey;
16
- const UseWebsocketPrivateKey = (secret_or_private_key) => ({
10
+ export const UseWebsocketPrivateKey = (secret_or_private_key) => ({
17
11
  provide: WebsocketPrivateKey,
18
12
  useFactory: () => secret_or_private_key
19
13
  });
20
- exports.UseWebsocketPrivateKey = UseWebsocketPrivateKey;
14
+ //# sourceMappingURL=UseWebsocketShareKeyPair.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"UseWebsocketShareKeyPair.js","sourceRoot":"","sources":["../../src/UseWebsocketShareKeyPair.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,MAAM,EAAY,MAAM,gBAAgB,CAAA;AAGjD,MAAM,kBAAkB,GAAG,oBAAoB,CAAA;AAC/C,MAAM,mBAAmB,GAAG,qBAAqB,CAAA;AAEjD,MAAM,CAAC,MAAM,wBAAwB,GAAG,GAAG,EAAE,CAAC,MAAM,CAAC,kBAAkB,CAAC,CAAA;AACxE,MAAM,CAAC,MAAM,yBAAyB,GAAG,GAAG,EAAE,CAAC,MAAM,CAAC,mBAAmB,CAAC,CAAA;AAG1E,MAAM,CAAC,MAAM,qBAAqB,GAAG,CAAC,oBAA4B,EAAE,EAAE,CAAC,CAAC;IACpE,OAAO,EAAE,kBAAkB;IAC3B,UAAU,EAAE,GAAG,EAAE,CAAC,oBAAoB;CAC5B,CAAA,CAAA;AAGd,MAAM,CAAC,MAAM,sBAAsB,GAAG,CAAC,qBAA6B,EAAE,EAAE,CAAC,CAAC;IACtE,OAAO,EAAE,mBAAmB;IAC5B,UAAU,EAAE,GAAG,EAAE,CAAC,qBAAqB;CAC7B,CAAA,CAAA"}
@@ -1,4 +1,2 @@
1
- "use strict";
2
- Object.defineProperty(exports, "__esModule", { value: true });
3
- exports.LIVEQUERY_MAGIC_KEY = void 0;
4
- exports.LIVEQUERY_MAGIC_KEY = `${process.env.LIVEQUERY_MAGIC_KEY || 'livequery'}/`;
1
+ export const LIVEQUERY_MAGIC_KEY = `${process.env.LIVEQUERY_MAGIC_KEY || 'livequery'}/`;
2
+ //# sourceMappingURL=const.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"const.js","sourceRoot":"","sources":["../../src/const.ts"],"names":[],"mappings":"AAAA,MAAM,CAAC,MAAM,mBAAmB,GAAG,GAC/B,OAAO,CAAC,GAAG,CAAC,mBAAmB,IAAI,WACvC,GAAG,CAAA"}
@@ -1,13 +1,10 @@
1
- "use strict";
2
- Object.defineProperty(exports, "__esModule", { value: true });
3
- exports.PathHelper = void 0;
4
- const const_1 = require("../const");
5
- class PathHelper {
1
+ import { LIVEQUERY_MAGIC_KEY } from "../const.js";
2
+ export class PathHelper {
6
3
  static trimLivequeryHotkey(path) {
7
4
  const ref = path
8
5
  ?.split('~')[0]
9
6
  ?.replaceAll(':', '')
10
- ?.split(const_1.LIVEQUERY_MAGIC_KEY)?.[1]
7
+ ?.split(LIVEQUERY_MAGIC_KEY)?.[1]
11
8
  ?.split('/')
12
9
  ?.filter(s => s.length > 0)
13
10
  ?.join('/');
@@ -19,7 +16,7 @@ class PathHelper {
19
16
  const refs = path
20
17
  ?.split('~')[0]
21
18
  ?.replaceAll(':', '')
22
- ?.split(const_1.LIVEQUERY_MAGIC_KEY)?.[1]
19
+ ?.split(LIVEQUERY_MAGIC_KEY)?.[1]
23
20
  ?.split('/')
24
21
  ?.filter(s => s.length > 0);
25
22
  if (!refs)
@@ -41,4 +38,4 @@ class PathHelper {
41
38
  .join('/'));
42
39
  }
43
40
  }
44
- exports.PathHelper = PathHelper;
41
+ //# sourceMappingURL=PathHelper.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"PathHelper.js","sourceRoot":"","sources":["../../../src/helpers/PathHelper.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,m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AC,CAAC,IAAI,CAAC,GAAG,CAAC,CAAA;QACrF,MAAM,UAAU,GAAG,IAAI,CAAC,MAAM,CAAC,CAAC,CAAC,EAAE,CAAC,EAAE,EAAE,CAAC,CAAC,GAAG,CAAC,IAAI,CAAC,CAAC,CAAC,IAAI,CAAC,GAAG,CAAC,CAAA;QAC9D,MAAM,MAAM,GAAG,aAAa,CAAC,CAAC,CAAC,IAAI,CAAC,CAAC,CAAC,IAAI,CAAC,IAAI,CAAC,MAAM,GAAG,CAAC,CAAC,CAAA;QAE3D,OAAO,EAAE,GAAG,EAAE,UAAU,EAAE,aAAa,EAAE,MAAM,EAAE,cAAc,EAAE,CAAA;IAErE,CAAC;IAED,MAAM,CAAC,IAAI,CAAC,CAAoB,EAAE,CAAoB;QAClD,OAAO,CAAC,CAAC,IAAI,EAAE,CAAC;aACX,IAAI,CAAC,CAAC,CAAC;aACP,GAAG,CAAC,EAAE,CAAC,EAAE,CAAC,CAAC,CAAC,IAAI,EAAE,CAAC,CAAC,IAAI,CAAC,CAAC,CAAC,CAAC,GAAG,CAAC,EAAE,CAAC,EAAE,CAAC,GAAG,EAAE,IAAI,EAAE,EAAE,CAAC,CAAC;aACrD,IAAI,CAAC,CAAC,CAAC;aACP,GAAG,CAAC,CAAC,CAAC,EAAE,CAAC,CAAC,CAAC,KAAK,CAAC,GAAG,CAAC;aACjB,MAAM,CAAC,CAAC,CAAC,EAAE,CAAC,CAAC,IAAI,EAAE,CAAC;aACpB,IAAI,CAAC,GAAG,CAAC,CAAC,CAAA;IACvB,CAAC;CAEJ"}
@@ -1,4 +1,4 @@
1
- import { Datasource } from "../LivequeryDatasourceInterceptors";
1
+ import { Datasource } from "../LivequeryDatasourceInterceptors.js";
2
2
  export declare const createDatasourceMapper: <T extends {}>(datasource_factory: new (...args: any[]) => Datasource) => [(options: T) => <TFunction extends Function, Y>(target: object | TFunction, propertyKey?: string | symbol, descriptor?: TypedPropertyDescriptor<Y>) => void, () => (T & {
3
3
  refs: string[];
4
4
  })[]];
@@ -1,21 +1,18 @@
1
- "use strict";
2
- Object.defineProperty(exports, "__esModule", { value: true });
3
- exports.createDatasourceMapper = void 0;
4
- const common_1 = require("@nestjs/common");
5
- const LivequeryDatasourceInterceptors_1 = require("../LivequeryDatasourceInterceptors");
6
- const LivequeryInterceptor_1 = require("../LivequeryInterceptor");
7
- const PathHelper_1 = require("./PathHelper");
8
- const createDatasourceMapper = (datasource_factory) => {
1
+ import { applyDecorators, UseInterceptors } from "@nestjs/common";
2
+ import { LivequeryDatasourceInterceptors, $__datasource_factory_token } from "../LivequeryDatasourceInterceptors.js";
3
+ import { UseLivequeryInterceptor } from "../LivequeryInterceptor.js";
4
+ import { PathHelper } from "./PathHelper.js";
5
+ export const createDatasourceMapper = (datasource_factory) => {
9
6
  const RouteConfigList = [];
10
- const decorator = (options) => (0, common_1.applyDecorators)((target, method) => RouteConfigList.push({ target, method, options }), (0, LivequeryInterceptor_1.UseLivequeryInterceptor)(), (0, common_1.UseInterceptors)(LivequeryDatasourceInterceptors_1.LivequeryDatasourceInterceptors), (target, method, descriptor) => {
11
- Reflect.defineMetadata(LivequeryDatasourceInterceptors_1.$__datasource_factory_token, datasource_factory, descriptor.value);
7
+ const decorator = (options) => applyDecorators((target, method) => RouteConfigList.push({ target, method, options }), UseLivequeryInterceptor(), UseInterceptors(LivequeryDatasourceInterceptors), (target, method, descriptor) => {
8
+ Reflect.defineMetadata($__datasource_factory_token, datasource_factory, descriptor.value);
12
9
  });
13
10
  const getDatasourceMetadatas = () => RouteConfigList.map(config => {
14
11
  return {
15
12
  ...(config.options || {}),
16
- refs: PathHelper_1.PathHelper.join(Reflect.getMetadata('path', config.target.constructor), Reflect.getMetadata('path', config.target[config.method])).map(PathHelper_1.PathHelper.trimLivequeryHotkey)
13
+ refs: PathHelper.join(Reflect.getMetadata('path', config.target.constructor), Reflect.getMetadata('path', config.target[config.method])).map(PathHelper.trimLivequeryHotkey)
17
14
  };
18
15
  });
19
16
  return [decorator, getDatasourceMetadatas];
20
17
  };
21
- exports.createDatasourceMapper = createDatasourceMapper;
18
+ //# sourceMappingURL=createDatasourceMapper.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"createDatasourceMapper.js","sourceRoot":"","sources":["../../../src/helpers/createDatasourceMapper.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,eAAe,EAAE,eAAe,EAAE,MAAM,gBAAgB,CAAC;AAClE,OAAO,EAAc,+BAA+B,EAAE,2BAA2B,EAAE,MAAM,uCAAuC,CAAC;AACjI,OAAO,EAAE,uBAAuB,EAAE,MAAM,4BAA4B,CAAC;AACrE,OAAO,EAAE,UAAU,EAAE,MAAM,iBAAiB,CAAC;AAI7C,MAAM,CAAC,MAAM,sBAAsB,GAAG,CAAe,kBAAgD,EAAE,EAAE;IAGrG,MAAM,eAAe,GAAuD,EAAE,CAAC;IAI/E,MAAM,SAAS,GAAG,CAAC,OAAU,EAAE,EAAE,CAAC,eAAe,CAC7C,CAAC,MAAM,EAAE,MAAM,EAAE,EAAE,CAAC,eAAe,CAAC,IAAI,CAAC,EAAE,MAAM,EAAE,MAAM,EAAE,OAAO,EAAE,CAAC,EACrE,uBAAuB,EAAE,EACzB,eAAe,CAAC,+BAA+B,CAAC,EAChD,CAAC,MAAM,EAAE,MAAM,EAAE,UAA8B,EAAE,EAAE;QAC/C,OAAO,CAAC,cAAc,CAAC,2BAA2B,EAAE,kBAAkB,EAAE,UAAU,CAAC,KAAK,CAAC,CAAA;IAC7F,CAAC,CACJ,CAAA;IAID,MAAM,sBAAsB,GAAG,GAAG,EAAE,CAAC,eAAe,CAAC,GAAG,CAAC,MAAM,CAAC,EAAE;QAC9D,OAAO;YACH,GAAG,CAAC,MAAM,CAAC,OAAO,IAAI,EAAE,CAAM;YAC9B,IAAI,EAAE,UAAU,CAAC,IAAI,CACjB,OAAO,CAAC,WAAW,CAAC,MAAM,EAAE,MAAM,CAAC,MAAM,CAAC,WAAW,CAAC,EACtD,OAAO,CAAC,WAAW,CAAC,MAAM,EAAE,MAAM,CAAC,MAAM,CAAC,MAAM,CAAC,MAAM,CAAC,CAAC,CAC5D,CAAC,GAAG,CAAC,UAAU,CAAC,mBAAmB,CAAC;SACxC,CAAA;IACL,CAAC,CAAC,CAAA;IAEF,OAAO,CAAC,SAAS,EAAE,sBAAsB,CAAsD,CAAA;AACnG,CAAC,CAAA"}
package/package.json CHANGED
@@ -1,42 +1,43 @@
1
1
  {
2
2
  "name": "@livequery/nestjs",
3
+ "author": "Duong Van Ba",
4
+ "license": "MIT",
3
5
  "repository": {
4
6
  "url": "git@github.com:livequery/nestjs.git"
5
7
  },
6
- "version": "1.0.50",
7
- "description": "",
8
+ "version": "1.0.75",
9
+ "description": "Nestjs decorators for @livequery ecosystem",
8
10
  "main": "build/index.js",
9
11
  "types": "build/index.d.ts",
10
12
  "files": [
11
13
  "build/**/*"
12
14
  ],
15
+ "exports": {
16
+ ".": {
17
+ "import": {
18
+ "types": "./build/index.d.ts",
19
+ "default": "./build/index.js"
20
+ }
21
+ }
22
+ },
23
+ "type": "module",
13
24
  "devDependencies": {
14
25
  "@livequery/types": "x",
15
26
  "@nestjs/common": "x",
16
27
  "@nestjs/core": "x",
17
28
  "@nestjs/websockets": "x",
18
29
  "@types/express": "x",
30
+ "@types/jsonwebtoken": "x",
19
31
  "@types/node": "x",
32
+ "jsonwebtoken": "x",
20
33
  "reflect-metadata": "x",
21
- "rxjs": "^.x"
22
- },
23
- "peerDependencies": {
24
- "@nestjs/common": "x",
25
- "@nestjs/core": "x",
26
- "@nestjs/websockets": "x",
27
- "reflect-metadata": "x",
28
- "rxjs": "x"
34
+ "rxjs": "x",
35
+ "tslib": "^2.6.1",
36
+ "typescript": "^5.1.6"
29
37
  },
30
38
  "scripts": {
31
39
  "test": "echo \"Error: no test specified\" && exit 1",
32
40
  "build": "tsc -b .",
33
41
  "deploy": "yarn build; git add .; git commit -m \"Update\"; git push origin master; npm publish --access public"
34
- },
35
- "author": "",
36
- "license": "ISC",
37
- "dependencies": {
38
- "@types/jsonwebtoken": "x",
39
- "jsonwebtoken": "x",
40
- "typescript": "^5.1.6"
41
42
  }
42
43
  }