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.
@@ -1,6 +1,6 @@
1
1
  Metadata-Version: 2.4
2
2
  Name: hexdb
3
- Version: 2.2.0
3
+ Version: 2.3.0
4
4
  Summary: Client for HexDB, the hexagonal document database.
5
5
  Author: Dream In Hex
6
6
  License-Expression: Apache-2.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.2.0"
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
 
@@ -1,6 +1,6 @@
1
1
  Metadata-Version: 2.4
2
2
  Name: hexdb
3
- Version: 2.2.0
3
+ Version: 2.3.0
4
4
  Summary: Client for HexDB, the hexagonal document database.
5
5
  Author: Dream In Hex
6
6
  License-Expression: Apache-2.0
@@ -4,7 +4,7 @@ build-backend = "setuptools.build_meta"
4
4
 
5
5
  [project]
6
6
  name = "hexdb"
7
- version = "2.2.0"
7
+ version = "2.3.0"
8
8
  description = "Client for HexDB, the hexagonal document database."
9
9
  readme = "README.md"
10
10
  requires-python = ">=3.9"
@@ -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