hexdb 2.2.0__tar.gz → 2.3.0__tar.gz
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.
- {hexdb-2.2.0 → hexdb-2.3.0}/PKG-INFO +1 -1
- {hexdb-2.2.0 → hexdb-2.3.0}/hexdb/__init__.py +6 -1
- {hexdb-2.2.0 → hexdb-2.3.0}/hexdb.egg-info/PKG-INFO +1 -1
- {hexdb-2.2.0 → hexdb-2.3.0}/pyproject.toml +1 -1
- {hexdb-2.2.0 → hexdb-2.3.0}/tests/test_client.py +9 -0
- {hexdb-2.2.0 → hexdb-2.3.0}/README.md +0 -0
- {hexdb-2.2.0 → hexdb-2.3.0}/hexdb.egg-info/SOURCES.txt +0 -0
- {hexdb-2.2.0 → hexdb-2.3.0}/hexdb.egg-info/dependency_links.txt +0 -0
- {hexdb-2.2.0 → hexdb-2.3.0}/hexdb.egg-info/top_level.txt +0 -0
- {hexdb-2.2.0 → hexdb-2.3.0}/setup.cfg +0 -0
|
@@ -26,7 +26,7 @@ import urllib.request
|
|
|
26
26
|
from typing import Any, BinaryIO, Callable, Dict, Iterator, List, Optional, Sequence, Tuple, Union
|
|
27
27
|
|
|
28
28
|
__all__ = ["HexDB", "HexDBError", "Tessellation", "Stream", "Files"]
|
|
29
|
-
__version__ = "2.
|
|
29
|
+
__version__ = "2.3.0"
|
|
30
30
|
|
|
31
31
|
Json = Any
|
|
32
32
|
Document = Dict[str, Any]
|
|
@@ -305,6 +305,11 @@ class Tessellation:
|
|
|
305
305
|
"""Insert or replace documents matched by key fields."""
|
|
306
306
|
return self.db.request("POST", f"{self.path}/_upsert", {"key": key if isinstance(key, str) else list(key), "documents": list(docs)}, _idem(idempotency_key))
|
|
307
307
|
|
|
308
|
+
def detokenize(self, tokens: Sequence[str]) -> Dict[str, Optional[str]]:
|
|
309
|
+
"""The values behind vault tokens of tokenized fields (up to 1,000; needs the
|
|
310
|
+
detokenize permission; audited). One-way and unknown tokens map to None."""
|
|
311
|
+
return self.db.request("POST", f"/tessellations/{_quote(self.name)}/detokenize", {"tokens": list(tokens)})["values"]
|
|
312
|
+
|
|
308
313
|
def update_where(self, filter: Dict[str, Any], update: Dict[str, Any]) -> Dict[str, int]:
|
|
309
314
|
return self.db.request("POST", f"{self.path}/_update", {"filter": filter, "update": update})
|
|
310
315
|
|
|
@@ -86,6 +86,15 @@ class ClientTest(unittest.TestCase):
|
|
|
86
86
|
thread.join(timeout=35)
|
|
87
87
|
self.assertEqual(received[0]["id"], doc["id"])
|
|
88
88
|
|
|
89
|
+
def test_tokenized_fields(self):
|
|
90
|
+
accounts = self.tess("accounts")
|
|
91
|
+
accounts.insert({"card": "0000000000000000"})
|
|
92
|
+
self.db.request("POST", f"/tessellations/{accounts.name}/schemas", {"fields": {"card": {"type": "string", "tokenize": "vault"}}})
|
|
93
|
+
doc = accounts.insert({"card": "4111111111111111"})
|
|
94
|
+
self.assertTrue(doc["card"].startswith("tok_") and doc["card"].endswith("_1111"), doc["card"])
|
|
95
|
+
self.assertEqual(accounts.query({"card": "4111111111111111"})["documents"][0]["id"], doc["id"])
|
|
96
|
+
self.assertEqual(accounts.detokenize([doc["card"]])[doc["card"]], "4111111111111111")
|
|
97
|
+
|
|
89
98
|
def test_streams(self):
|
|
90
99
|
name = f"{self.prefix}-events"
|
|
91
100
|
self.db.request("POST", "/streams", {"name": name})
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|