mosquito-transport-js 0.2.6 → 0.2.7

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/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "mosquito-transport-js",
3
- "version": "0.2.6",
3
+ "version": "0.2.7",
4
4
  "description": "Javascript web sdk for mosquito-transport (https://github.com/deflexable/mosquito-transport)",
5
5
  "main": "src/index.js",
6
6
  "type": "module",
@@ -17,7 +17,6 @@
17
17
  "javascript",
18
18
  "selfhosted",
19
19
  "serverless",
20
- "BaaS",
21
20
  "database",
22
21
  "react",
23
22
  "mongodb"
@@ -34,7 +33,7 @@
34
33
  "buffer": "^6.0.3",
35
34
  "crypto-js": "^4.2.0",
36
35
  "fast-json-stable-stringify": "^2.1.0",
37
- "guard-object": "^1.0.6",
36
+ "guard-object": "^1.0.7",
38
37
  "json-buffer": "^3.0.1",
39
38
  "lodash.get": "^4.4.2",
40
39
  "lodash.isequal": "^4.5.0",
@@ -36,8 +36,9 @@ export const insertRecord = async (builder, accessId, query, value) => {
36
36
  kaf = `${objToUniqueString(extraction || {})},${(excludeFields || []).join(',')},${(returnOnly || []).join(',')}`,
37
37
  colData = getLodash(CacheStore.DatabaseStore, [projectUrl, dbUrl, dbName, path, 'data', kaf], []);
38
38
 
39
+ // TODO:
39
40
  (Array.isArray(value) ? value : [value]).forEach(e => {
40
- const b4DocIndex = colData.findIndex(v => v._id === e._id);
41
+ const b4DocIndex = colData.findIndex(v => v?._id === e?._id);
41
42
  if (b4DocIndex === -1) {
42
43
  colData.push(e);
43
44
  } else colData[b4DocIndex] = e;
@@ -150,7 +150,7 @@ const listenDocument = (callback, onError, builder, config) => {
150
150
  const mtoken = disableAuth ? undefined : Scoped.AuthJWTToken[projectUrl],
151
151
  authObj = {
152
152
  commands: {
153
- config,
153
+ config: stripRequestConfig(config),
154
154
  path,
155
155
  find: findOne || find,
156
156
  sort,
@@ -370,6 +370,14 @@ const countCollection = async (builder, config) => {
370
370
  return g;
371
371
  }
372
372
 
373
+ const stripRequestConfig = (config) => {
374
+ const known_fields = ['extraction', 'returnOnly', 'excludeFields'];
375
+ const requestConfig = Object.entries({ ...config }).map(([k, v]) =>
376
+ known_fields.includes(k) ? [k, v] : null
377
+ ).filter(v => v);
378
+ return requestConfig.length ? Object.fromEntries(requestConfig) : undefined;
379
+ }
380
+
373
381
  const findObject = async (builder, config) => {
374
382
  const { projectUrl, serverE2E_PublicKey, dbUrl, dbName, accessKey, maxRetries = 7, path, disableCache, uglify, command } = builder,
375
383
  { find, findOne, sort, direction, limit, random } = command,
@@ -447,7 +455,15 @@ const findObject = async (builder, config) => {
447
455
 
448
456
  const [reqBuilder, [privateKey]] = buildFetchInterface({
449
457
  body: {
450
- commands: { config, path, find: findOne || find, sort, direction, limit, random },
458
+ commands: {
459
+ config: stripRequestConfig(config),
460
+ path,
461
+ find: findOne || find,
462
+ sort,
463
+ direction,
464
+ limit,
465
+ random
466
+ },
451
467
  dbName,
452
468
  dbUrl
453
469
  },