@rpcbase/client 0.153.0 → 0.154.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/get_object_id.js CHANGED
@@ -3,7 +3,7 @@ import assert from "assert"
3
3
 
4
4
  import isHexadecimal from "validator/lib/isHexadecimal"
5
5
 
6
- import {TENANT_PREFIX} from "env"
6
+ import {RB_TENANT_ID} from "env"
7
7
 
8
8
 
9
9
  const get_random_bytes = (n) => {
@@ -13,11 +13,11 @@ const get_random_bytes = (n) => {
13
13
  }
14
14
 
15
15
  // Validation: is defined
16
- assert(TENANT_PREFIX, "expected TENANT_PREFIX to be defined")
16
+ assert(RB_TENANT_ID, "expected RB_TENANT_ID to be defined")
17
17
  // is hexadecimal
18
- assert(isHexadecimal(TENANT_PREFIX), "expected TENANT_PREFIX to be a hexadecimal")
18
+ assert(isHexadecimal(RB_TENANT_ID), "expected RB_TENANT_ID to be a hexadecimal")
19
19
  // is 4 bytes
20
- assert(TENANT_PREFIX.length === 8, "TENANT_PREFIX must be exactly bytes long ie: 8 hex chars")
20
+ assert(RB_TENANT_ID.length === 8, "RB_TENANT_ID must be exactly bytes long ie: 8 hex chars")
21
21
 
22
22
  // generates a 12 bytes mongodb object id using the org id prefix or custom customer id
23
23
  const get_object_id = () => {
@@ -27,7 +27,7 @@ const get_object_id = () => {
27
27
  const random_bytes = get_random_bytes(4)
28
28
  const random_hex = Buffer.from(random_bytes).toString("hex")
29
29
 
30
- const obj_id = `${ts_bytes}${TENANT_PREFIX}${random_hex}`
30
+ const obj_id = `${ts_bytes}${RB_TENANT_ID}${random_hex}`
31
31
  return obj_id
32
32
  }
33
33
 
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@rpcbase/client",
3
- "version": "0.153.0",
3
+ "version": "0.154.0",
4
4
  "scripts": {
5
5
  "test": "../../node_modules/.bin/wireit"
6
6
  },
@@ -4,11 +4,11 @@ import PouchDB from "pouchdb-core"
4
4
  import IndexedDBAdapter from "pouchdb-adapter-indexeddb"
5
5
  import FindPlugin from "pouchdb-find"
6
6
 
7
- import {TENANT_PREFIX, RB_APP_NAME} from "env"
7
+ import {RB_TENANT_ID, RB_APP_NAME} from "env"
8
8
 
9
9
  const log = debug("rb:rts:store")
10
10
 
11
- let prefix = `rb/${TENANT_PREFIX}/`
11
+ let prefix = `rb/${RB_TENANT_ID}/`
12
12
 
13
13
  if (RB_APP_NAME) prefix += `${RB_APP_NAME}/`
14
14
 
@@ -43,7 +43,7 @@ const run_query = async({model_name, query, query_key, options}, callback) => {
43
43
  // console.log("run_query", {model_name, query, query_key, options})
44
44
  // console.time("store run_query")
45
45
 
46
- // TODO: we should prefix model_name with tenant_prefix + env_id
46
+ // TODO: we should prefix model_name with RB_TENANT_ID + env_id
47
47
  const collection = get_collection(model_name)
48
48
 
49
49
  const replaced_query = replace_query_keys(query, (k) => (k.startsWith("_") && k !== "_id") ? `${UNDERSCORE_PREFIX}${k}` : k)