@livequery/nestjs 1.0.46 → 1.0.48

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.
@@ -61,7 +61,7 @@ let LivequeryInterceptor = class LivequeryInterceptor {
61
61
  body: req.body,
62
62
  method: req.method.toLowerCase()
63
63
  };
64
- req.headers.socket_id && this.LivequeryWebsocketSync?.listen(req.headers.socket_id, { collection_ref, doc_id });
64
+ req.method == 'GET' && req.headers.socket_id && this.LivequeryWebsocketSync?.listen(req.headers.socket_id, { collection_ref, doc_id });
65
65
  const realtime_token = await new Promise(s => {
66
66
  if (this.LivequeryWebsocketSync || !this.secret_or_private_key || req.method.toLowerCase() != 'get' || req.query._cursor)
67
67
  return s(null);
@@ -16,7 +16,7 @@ exports.LivequeryWebsocketSync = void 0;
16
16
  const websockets_1 = require("@nestjs/websockets");
17
17
  const rxjs_1 = require("rxjs");
18
18
  const LivequeryInterceptor_1 = require("./LivequeryInterceptor");
19
- const uuid_1 = require("uuid");
19
+ const crypto_1 = require("crypto");
20
20
  const common_1 = require("@nestjs/common");
21
21
  const UseWebsocketShareKeyPair_1 = require("./UseWebsocketShareKeyPair");
22
22
  const JWT = require('jsonwebtoken');
@@ -46,7 +46,7 @@ let LivequeryWebsocketSync = class LivequeryWebsocketSync {
46
46
  });
47
47
  this.connections.delete(socket.id);
48
48
  }
49
- start({ id = uuid_1.v4() }, socket) {
49
+ start({ id = crypto_1.randomUUID() }, socket) {
50
50
  if (typeof id == 'string' && id.length < 40) {
51
51
  socket.id = id;
52
52
  this.connections.set(id, { socket, refs: new Set() });
@@ -5,7 +5,6 @@ const const_1 = require("../const");
5
5
  class PathHelper {
6
6
  static trimLivequeryHotkey(path) {
7
7
  const ref = path
8
- ?.split('~')[0]
9
8
  ?.replaceAll(':', '')
10
9
  ?.split(const_1.LIVEQUERY_MAGIC_KEY)?.[1]
11
10
  ?.split('/')
@@ -17,18 +16,19 @@ class PathHelper {
17
16
  }
18
17
  static parseHttpRequestPath(path) {
19
18
  const refs = path
20
- ?.split('~')[0]
21
19
  ?.replaceAll(':', '')
22
20
  ?.split(const_1.LIVEQUERY_MAGIC_KEY)?.[1]
23
21
  ?.split('/')
24
22
  ?.filter(s => s.length > 0);
25
23
  if (!refs)
26
24
  throw 'LIVEQUERY_MAGIC_KEY_NOT_FOUND';
27
- const is_collection = refs.length % 2 == 1;
28
25
  const ref = refs.join('/');
29
- const collection_ref = is_collection ? ref : refs.slice(0, refs.length - 1).join('/');
30
- const schema_ref = refs.filter((_, i) => i % 2 == 0).join('/');
31
- const doc_id = is_collection ? null : refs[refs.length - 1];
26
+ const ref_without_action = ref.split('/~')[0];
27
+ const refs_without_action = ref_without_action.split('/');
28
+ const is_collection = refs_without_action.length % 2 == 1;
29
+ const collection_ref = is_collection ? ref_without_action : refs_without_action.slice(0, refs_without_action.length - 1).join('/');
30
+ const schema_ref = refs_without_action.filter((_, i) => i % 2 == 0).join('/');
31
+ const doc_id = is_collection ? null : refs_without_action[refs_without_action.length - 1];
32
32
  return { ref, schema_ref, is_collection, doc_id, collection_ref };
33
33
  }
34
34
  static join(a, b) {
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.46",
6
+ "version": "1.0.48",
7
7
  "description": "",
8
8
  "main": "build/index.js",
9
9
  "types": "build/index.d.ts",