@rpcbase/client 0.195.0 → 0.196.0

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": "@rpcbase/client",
3
- "version": "0.195.0",
3
+ "version": "0.196.0",
4
4
  "scripts": {
5
5
  "build": "../../node_modules/.bin/wireit",
6
6
  "test": "../../node_modules/.bin/wireit"
@@ -98,9 +98,9 @@
98
98
  "js-tree": "2.0.2",
99
99
  "lz-string": "1.5.0",
100
100
  "posthog-js": "1.147.0",
101
- "pouchdb-adapter-indexeddb": "8.0.1",
102
- "pouchdb-core": "8.0.1",
103
- "pouchdb-find": "8.0.1",
101
+ "pouchdb-adapter-indexeddb": "9.0.0",
102
+ "pouchdb-core": "9.0.0",
103
+ "pouchdb-find": "9.0.0",
104
104
  "react-bootstrap-typeahead": "6.3.2",
105
105
  "react-i18next": "15.0.1",
106
106
  "rrweb": "1.1.3",
@@ -1,5 +1,4 @@
1
1
  /* @flow */
2
- import assert from "assert"
3
2
  import {Platform} from "react-native"
4
3
  import {useCallback, useEffect, useState, useMemo, useId, useRef} from "react"
5
4
  import debug from "debug"
@@ -25,9 +24,10 @@ const getUseQuery = (register_query) => (
25
24
  ) => {
26
25
  const id = useId()
27
26
 
27
+ // TODO: should the uid be gone here ? it's part of the auth layer, not this here
28
28
  // TODO: retrieve this from future AuthContext in client
29
29
  const uid = useMemo(() => {
30
- // TODO: why is there a options.userId here ??
30
+ // TODO: why is there a options.userId here?? (it was for mobile we need to unify this)
31
31
  const _uid = Platform.OS === "web" ? getUid() : options.userId
32
32
  return _uid
33
33
  }, [])
@@ -75,12 +75,16 @@ const getUseQuery = (register_query) => (
75
75
  // set data in a ref so that it doesn't force re-rendering ie: unsubscribe / resubscribe
76
76
  dataRef.current = newData
77
77
 
78
+ // useStorage currently used as a fast local cache, indexedDB
78
79
  // we only save network queries
80
+ // TODO: use localstorage in react native and pouchdb everywhere
79
81
  if (useStorage && context.source === "network") {
80
82
  if (Platform.OS === "web") {
81
83
  localStorage.setItem(storageKey, LZString.compressToUTF16(JSON.stringify(newData)))
82
84
  } else {
85
+ // TODO: this is done in pouchDB nOW ?????
83
86
  // TODO: RN MMKV
87
+ console.log("mmkv NYI")
84
88
  }
85
89
  }
86
90
 
@@ -147,7 +151,7 @@ const getUseQuery = (register_query) => (
147
151
  newData = _omit(queryResult, "__txn_id")
148
152
  }
149
153
 
150
- // We return once in any case!
154
+ // we return once in any case
151
155
  if (!hasFirstReply.current) {
152
156
  hasFirstReply.current = true
153
157
 
@@ -168,7 +172,7 @@ const getUseQuery = (register_query) => (
168
172
  return
169
173
  }
170
174
 
171
- if (isEqual(data, newData) && !isEqualValues(data, newData) && __DEV__) {
175
+ if (__DEV__ && isEqual(data, newData) && !isEqualValues(data, newData)) {
172
176
  alert("EQUALITY MISMATCH THIS SHOULD NOT HAPPEN!", data, newData)
173
177
  }
174
178
 
@@ -191,11 +195,11 @@ const getUseQuery = (register_query) => (
191
195
 
192
196
 
193
197
  const loadNextPage = useCallback(() => {
194
- console.log("NYI: will load next page after DOC")
198
+ console.log("loadNextPage NYI")
195
199
  }, [])
196
200
 
197
201
 
198
- const result = useMemo(() => ({data, source, error, loading}), [data, source, error, loading])
202
+ const result = useMemo(() => ({data, source, error, loading, loadNextPage}), [data, source, error, loading, loadNextPage])
199
203
 
200
204
  // TODO:
201
205
  // if (Array.isArray(result.data) && !result.source) {
package/rts/rts.js CHANGED
@@ -10,6 +10,7 @@ import getBaseUrl from "../getBaseUrl"
10
10
 
11
11
  import store from "./store"
12
12
 
13
+
13
14
  const log = debug("rb:socket")
14
15
 
15
16
  const TENANT_ID_HEADER = "rb-tenant-id"
@@ -197,8 +198,6 @@ export const register_query = (model_name, query, _options, _callback) => {
197
198
  }
198
199
  _queries_store[model_name][query]
199
200
 
200
- console.log("QUERY OPTIONSSS", options)
201
-
202
201
  // TODO: why both run and register query here ? the run_query should come straight from register ?
203
202
  _socket.emit("run_query", {model_name, query, query_key, options})
204
203
  _socket.emit("register_query", {model_name, query, query_key, options})
@@ -6,22 +6,26 @@ import FindPlugin from "pouchdb-find"
6
6
 
7
7
  import {RB_TENANT_ID, RB_APP_NAME} from "env"
8
8
 
9
+
9
10
  const log = debug("rb:rts:store")
10
11
 
11
- let prefix = `rb/${RB_TENANT_ID}/`
12
+ let prefix = `rb/`
12
13
 
13
14
  if (RB_APP_NAME) prefix += `${RB_APP_NAME}/`
14
15
 
16
+ prefix += `${RB_TENANT_ID}/`
17
+
18
+ log("prefix:", prefix)
19
+
15
20
  PouchDB.prefix = prefix
16
21
 
17
22
  PouchDB.plugin(IndexedDBAdapter)
18
23
  PouchDB.plugin(FindPlugin)
19
24
 
20
-
21
25
  const _cols_store = Object.create(null)
22
26
 
23
-
24
27
  const get_collection = (col_name) => {
28
+
25
29
  if (!col_name) {
26
30
  console.warn("supplied invalid / empty collection name to rts")
27
31
  }