react-native-mosquito-transport 0.0.34 → 0.0.35
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 +3 -3
- package/src/helpers/fs_manager.js +6 -6
- package/src/helpers/peripherals.js +3 -3
- package/src/helpers/purger.js +5 -5
- package/src/helpers/utils.js +2 -7
- package/src/helpers/values.js +1 -1
- package/src/helpers/variables.js +2 -9
- package/src/index.js +1 -1
- package/src/products/auth/index.js +1 -1
- package/src/products/database/accessor.js +97 -53
- package/src/products/database/bson.js +1 -1
- package/src/products/database/counter.js +5 -6
- package/src/products/database/index.js +22 -11
- package/src/products/database/types.js +16 -11
- package/src/products/database/validator.js +5 -5
- package/src/products/http_callable/counter.js +3 -4
- package/src/vendor/bson.d.ts +1723 -0
- package/src/vendor/bson.js +4650 -0
- package/src/vendor/encoder.js +37 -0
- package/src/vendor/utf8-validator.js +60 -0
- package/src/vendor/utf8-validator.test.js +35 -0
|
@@ -2,13 +2,13 @@ import { io } from "socket.io-client";
|
|
|
2
2
|
import EngineApi from "../../helpers/engine_api";
|
|
3
3
|
import { DatabaseRecordsListener } from "../../helpers/listeners";
|
|
4
4
|
import { deserializeE2E, listenReachableServer, niceTry, serializeE2E } from "../../helpers/peripherals";
|
|
5
|
-
import { awaitStore, buildFetchInterface, buildFetchResult, getReachableServer } from "../../helpers/utils";
|
|
5
|
+
import { awaitStore, buildFetchInterface, buildFetchResult, getReachableServer, updateCacheStore } from "../../helpers/utils";
|
|
6
6
|
import { CacheStore, Scoped } from "../../helpers/variables";
|
|
7
7
|
import { addPendingWrites, generateRecordID, getCountQuery, getRecord, insertCountQuery, insertRecord, listenQueryEntry, removePendingWrite, validateWriteValue } from "./accessor";
|
|
8
8
|
import { validateCollectionName, validateFilter, validateFindConfig, validateFindObject, validateListenFindConfig } from "./validator";
|
|
9
9
|
import { awaitRefreshToken, listenToken } from "../auth/accessor";
|
|
10
10
|
import { DELIVERY, RETRIEVAL } from "../../helpers/values";
|
|
11
|
-
import { ObjectId } from "
|
|
11
|
+
import { ObjectId } from "../../vendor/bson";
|
|
12
12
|
import { guardObject, Validator } from "guard-object";
|
|
13
13
|
import { simplifyCaughtError } from "simplify-error";
|
|
14
14
|
import cloneDeep from "lodash/cloneDeep";
|
|
@@ -622,13 +622,14 @@ const commitData = async (builder, value, type, config) => {
|
|
|
622
622
|
const writeId = `${Date.now() + ++Scoped.PendingIte}`;
|
|
623
623
|
const isBatchWrite = type === 'batchWrite';
|
|
624
624
|
const shouldCache = (delivery !== DELIVERY.DEFAULT || !disableCache) &&
|
|
625
|
-
![DELIVERY.NO_CACHE_AWAIT, DELIVERY.NO_CACHE_NO_AWAIT].includes();
|
|
625
|
+
![DELIVERY.NO_CACHE_AWAIT, DELIVERY.NO_CACHE_NO_AWAIT].includes(delivery);
|
|
626
626
|
|
|
627
627
|
await awaitStore();
|
|
628
628
|
if (shouldCache) {
|
|
629
|
-
await addPendingWrites(builder, writeId, { value, type,
|
|
629
|
+
await addPendingWrites(builder, writeId, { value, type, config: stripUndefined({ disableAuth, stepping }) });
|
|
630
630
|
Scoped.OutgoingWrites[writeId] = true;
|
|
631
|
-
|
|
631
|
+
if (Scoped.dispatchingWritesPromise[projectUrl])
|
|
632
|
+
await Scoped.dispatchingWritesPromise[projectUrl];
|
|
632
633
|
}
|
|
633
634
|
|
|
634
635
|
let retries = 0, hasFinalize;
|
|
@@ -649,10 +650,11 @@ const commitData = async (builder, value, type, config) => {
|
|
|
649
650
|
} else reject(b);
|
|
650
651
|
if (hasFinalize || !instantProcess) return;
|
|
651
652
|
hasFinalize = true;
|
|
653
|
+
if (Scoped.OutgoingWrites[writeId])
|
|
654
|
+
delete Scoped.OutgoingWrites[writeId];
|
|
655
|
+
|
|
652
656
|
if (shouldCache) {
|
|
653
657
|
if (removeCache) removePendingWrite(builder, writeId, revertCache);
|
|
654
|
-
if (Scoped.OutgoingWrites[writeId])
|
|
655
|
-
delete Scoped.OutgoingWrites[writeId];
|
|
656
658
|
}
|
|
657
659
|
};
|
|
658
660
|
|
|
@@ -717,9 +719,9 @@ const commitData = async (builder, value, type, config) => {
|
|
|
717
719
|
};
|
|
718
720
|
|
|
719
721
|
export const trySendPendingWrite = (projectUrl) => {
|
|
720
|
-
if (Scoped.dispatchingWritesPromise) return;
|
|
722
|
+
if (Scoped.dispatchingWritesPromise[projectUrl]) return;
|
|
721
723
|
|
|
722
|
-
Scoped.dispatchingWritesPromise = new Promise(async resolve => {
|
|
724
|
+
Scoped.dispatchingWritesPromise[projectUrl] = new Promise(async resolve => {
|
|
723
725
|
const sortedWrite = Object.entries(CacheStore.PendingWrites[projectUrl] || {})
|
|
724
726
|
.filter(([k]) => !Scoped.OutgoingWrites[k])
|
|
725
727
|
.sort((a, b) => a[1].addedOn - b[1].addedOn);
|
|
@@ -727,7 +729,13 @@ export const trySendPendingWrite = (projectUrl) => {
|
|
|
727
729
|
|
|
728
730
|
for (const [writeId, { snapshot, builder, attempts = 1 }] of sortedWrite) {
|
|
729
731
|
try {
|
|
730
|
-
await commitData(
|
|
732
|
+
await commitData(
|
|
733
|
+
{ ...Scoped.InitializedProject[projectUrl], ...builder, find: deserializeBSON(builder.find, true)._ },
|
|
734
|
+
deserializeBSON(snapshot.value, true)._,
|
|
735
|
+
snapshot.type,
|
|
736
|
+
{ ...snapshot.config, delivery: DELIVERY.NO_CACHE_NO_AWAIT }
|
|
737
|
+
);
|
|
738
|
+
|
|
731
739
|
delete CacheStore.PendingWrites[projectUrl][writeId];
|
|
732
740
|
++resolveCounts;
|
|
733
741
|
} catch (_) {
|
|
@@ -741,7 +749,10 @@ export const trySendPendingWrite = (projectUrl) => {
|
|
|
741
749
|
}
|
|
742
750
|
}
|
|
743
751
|
resolve();
|
|
744
|
-
Scoped.dispatchingWritesPromise
|
|
752
|
+
if (projectUrl in Scoped.dispatchingWritesPromise)
|
|
753
|
+
delete Scoped.dispatchingWritesPromise[projectUrl];
|
|
754
|
+
updateCacheStore(['PendingWrites']);
|
|
755
|
+
|
|
745
756
|
if (
|
|
746
757
|
(sortedWrite.length - resolveCounts) &&
|
|
747
758
|
await getReachableServer(projectUrl)
|
|
@@ -1,8 +1,9 @@
|
|
|
1
|
+
import { guardObject, GuardSignal, niceGuard } from "guard-object";
|
|
1
2
|
|
|
2
3
|
export const TIMESTAMP = { $timestamp: "now" };
|
|
3
4
|
export const TIMESTAMP_OFFSET = (v) => ({ $timestamp_offset: v });
|
|
4
5
|
|
|
5
|
-
export const IS_TIMESTAMP = (t) => t
|
|
6
|
+
export const IS_TIMESTAMP = (t) => niceGuard({ $timestamp: t => t === 'now' || typeof t.$timestamp === 'number' }, t);
|
|
6
7
|
|
|
7
8
|
export const DOCUMENT_EXTRACTION = (path) => ({ $dynamicValue: path });
|
|
8
9
|
|
|
@@ -11,13 +12,17 @@ export const GEO_JSON = (lat, lng) => ({
|
|
|
11
12
|
coordinates: [lng, lat],
|
|
12
13
|
});
|
|
13
14
|
|
|
14
|
-
export const FIND_GEO_JSON = (location, offSetMeters, centerMeters) =>
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
|
|
15
|
+
export const FIND_GEO_JSON = (location, offSetMeters, centerMeters) => {
|
|
16
|
+
guardObject(GuardSignal.COORDINATE.LAT_LNG_INT).validate(location);
|
|
17
|
+
|
|
18
|
+
return {
|
|
19
|
+
$nearSphere: {
|
|
20
|
+
$geometry: {
|
|
21
|
+
type: "Point",
|
|
22
|
+
coordinates: location.slice(0).reverse()
|
|
23
|
+
},
|
|
24
|
+
$minDistance: centerMeters || 0,
|
|
25
|
+
$maxDistance: offSetMeters
|
|
26
|
+
}
|
|
27
|
+
};
|
|
28
|
+
};
|
|
@@ -1,9 +1,9 @@
|
|
|
1
1
|
import { guardArray, GuardError, guardObject, GuardSignal, niceGuard, Validator } from "guard-object";
|
|
2
2
|
import { sameInstance } from "../../helpers/peripherals";
|
|
3
3
|
import { RETRIEVAL } from "../../helpers/values";
|
|
4
|
-
import
|
|
5
|
-
import { Binary, BSONRegExp, BSONSymbol, Code, DBRef, Decimal128, Double, Int32, Long, MaxKey, MinKey, ObjectId, Timestamp, UUID } from 'bson/lib/bson.rn.cjs';
|
|
4
|
+
import { Binary, BSONRegExp, BSONSymbol, Code, DBRef, Decimal128, Double, Int32, Long, MaxKey, MinKey, ObjectId, Timestamp, UUID } from '../../vendor/bson';
|
|
6
5
|
import { bboxPolygon, booleanIntersects, booleanWithin, circle, distance, polygon } from "@turf/turf";
|
|
6
|
+
import { grab } from "poke-object";
|
|
7
7
|
|
|
8
8
|
const DirectionList = [1, -1, 'asc', 'desc', 'ascending', 'descending'];
|
|
9
9
|
const FilterFootPrint = t => {
|
|
@@ -65,7 +65,7 @@ export const assignExtractionFind = (data, find) => {
|
|
|
65
65
|
if (!find) return find;
|
|
66
66
|
|
|
67
67
|
if (niceGuard({ $dynamicValue: GuardSignal.NON_EMPTY_STRING }, find)) {
|
|
68
|
-
return
|
|
68
|
+
return grab(data, find.$dynamicValue) || null;
|
|
69
69
|
} else if (Validator.OBJECT(find)) {
|
|
70
70
|
return Object.fromEntries(
|
|
71
71
|
Object.entries(find).map(([k, v]) =>
|
|
@@ -356,7 +356,7 @@ const FilterUtils = {
|
|
|
356
356
|
let { $field, $search, $caseSensitive } = q;
|
|
357
357
|
|
|
358
358
|
$field = (Array.isArray($field) ? $field : [$field]).map(v => {
|
|
359
|
-
const f =
|
|
359
|
+
const f = grab({ ...parent }, v);
|
|
360
360
|
return typeof f === 'string' ? f : '';
|
|
361
361
|
}).join(' ');
|
|
362
362
|
|
|
@@ -512,7 +512,7 @@ const evaluateFilter = (data, filter = {}, parentData, level = 0) => {
|
|
|
512
512
|
|
|
513
513
|
let thisData;
|
|
514
514
|
try {
|
|
515
|
-
thisData = data &&
|
|
515
|
+
thisData = data && grab(data, key);
|
|
516
516
|
} catch (_) { }
|
|
517
517
|
|
|
518
518
|
if (key === '$text' && !level) {
|
|
@@ -1,11 +1,10 @@
|
|
|
1
1
|
import { CacheStore } from "../../helpers/variables";
|
|
2
|
-
import
|
|
3
|
-
import setLodash from 'lodash/set';
|
|
2
|
+
import { grab, poke } from "poke-object";
|
|
4
3
|
|
|
5
4
|
export const incrementFetcherSize = (projectUrl, size = 0) => incrementFetcherSizeCore(CacheStore.DatabaseStats, projectUrl, size);
|
|
6
5
|
|
|
7
6
|
export const incrementFetcherSizeCore = (baseObj, projectUrl, size = 0) => {
|
|
8
7
|
baseObj._fetcher_size += size;
|
|
9
|
-
const b4 =
|
|
10
|
-
|
|
8
|
+
const b4 = grab(baseObj.fetchers, [projectUrl], 0);
|
|
9
|
+
poke(baseObj.fetchers, [projectUrl], b4 + size);
|
|
11
10
|
}
|