reach_commons 0.18.42__tar.gz → 0.18.43__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.
Files changed (36) hide show
  1. {reach_commons-0.18.42 → reach_commons-0.18.43}/PKG-INFO +1 -1
  2. {reach_commons-0.18.42 → reach_commons-0.18.43}/pyproject.toml +1 -1
  3. reach_commons-0.18.43/reach_commons/sms_smart_encoding.py +81 -0
  4. reach_commons-0.18.42/reach_commons/sms_smart_encoding.py +0 -47
  5. {reach_commons-0.18.42 → reach_commons-0.18.43}/README.md +0 -0
  6. {reach_commons-0.18.42 → reach_commons-0.18.43}/reach_commons/__init__.py +0 -0
  7. {reach_commons-0.18.42 → reach_commons-0.18.43}/reach_commons/app_logging/__init__.py +0 -0
  8. {reach_commons-0.18.42 → reach_commons-0.18.43}/reach_commons/app_logging/http_logger.py +0 -0
  9. {reach_commons-0.18.42 → reach_commons-0.18.43}/reach_commons/app_logging/log_deprecated_endpoints.py +0 -0
  10. {reach_commons-0.18.42 → reach_commons-0.18.43}/reach_commons/app_logging/logger.py +0 -0
  11. {reach_commons-0.18.42 → reach_commons-0.18.43}/reach_commons/app_logging/logging_config.py +0 -0
  12. {reach_commons-0.18.42 → reach_commons-0.18.43}/reach_commons/app_logging/logging_utils.py +0 -0
  13. {reach_commons-0.18.42 → reach_commons-0.18.43}/reach_commons/clients/__init__.py +0 -0
  14. {reach_commons-0.18.42 → reach_commons-0.18.43}/reach_commons/clients/event_processor.py +0 -0
  15. {reach_commons-0.18.42 → reach_commons-0.18.43}/reach_commons/clients/hubspot.py +0 -0
  16. {reach_commons-0.18.42 → reach_commons-0.18.43}/reach_commons/clients/outscraper.py +0 -0
  17. {reach_commons-0.18.42 → reach_commons-0.18.43}/reach_commons/clients/reach_data_bridge.py +0 -0
  18. {reach_commons-0.18.42 → reach_commons-0.18.43}/reach_commons/clients/reach_ops_api.py +0 -0
  19. {reach_commons-0.18.42 → reach_commons-0.18.43}/reach_commons/mongo/__init__.py +0 -0
  20. {reach_commons-0.18.42 → reach_commons-0.18.43}/reach_commons/mongo/customer_persistence.py +0 -0
  21. {reach_commons-0.18.42 → reach_commons-0.18.43}/reach_commons/mongo/customer_persistence_async.py +0 -0
  22. {reach_commons-0.18.42 → reach_commons-0.18.43}/reach_commons/mongo/validation/__init__.py +0 -0
  23. {reach_commons-0.18.42 → reach_commons-0.18.43}/reach_commons/reach_aws/__init__.py +0 -0
  24. {reach_commons-0.18.42 → reach_commons-0.18.43}/reach_commons/reach_aws/commons.py +0 -0
  25. {reach_commons-0.18.42 → reach_commons-0.18.43}/reach_commons/reach_aws/db_config.py +0 -0
  26. {reach_commons-0.18.42 → reach_commons-0.18.43}/reach_commons/reach_aws/dynamo_db.py +0 -0
  27. {reach_commons-0.18.42 → reach_commons-0.18.43}/reach_commons/reach_aws/exceptions.py +0 -0
  28. {reach_commons-0.18.42 → reach_commons-0.18.43}/reach_commons/reach_aws/firehose.py +0 -0
  29. {reach_commons-0.18.42 → reach_commons-0.18.43}/reach_commons/reach_aws/kms.py +0 -0
  30. {reach_commons-0.18.42 → reach_commons-0.18.43}/reach_commons/reach_aws/reach_rate_limiter.py +0 -0
  31. {reach_commons-0.18.42 → reach_commons-0.18.43}/reach_commons/reach_aws/s3.py +0 -0
  32. {reach_commons-0.18.42 → reach_commons-0.18.43}/reach_commons/reach_aws/sqs.py +0 -0
  33. {reach_commons-0.18.42 → reach_commons-0.18.43}/reach_commons/reach_base_model.py +0 -0
  34. {reach_commons-0.18.42 → reach_commons-0.18.43}/reach_commons/redis_manager.py +0 -0
  35. {reach_commons-0.18.42 → reach_commons-0.18.43}/reach_commons/utils.py +0 -0
  36. {reach_commons-0.18.42 → reach_commons-0.18.43}/reach_commons/validations.py +0 -0
@@ -1,6 +1,6 @@
1
1
  Metadata-Version: 2.1
2
2
  Name: reach_commons
3
- Version: 0.18.42
3
+ Version: 0.18.43
4
4
  Summary: Reach Commons is a versatile utility library designed to streamline and enhance development workflows within the Reach ecosystem.
5
5
  License: MIT
6
6
  Author: Engineering
@@ -1,7 +1,7 @@
1
1
  # isort .; black .; poetry build; poetry publish
2
2
  [tool.poetry]
3
3
  name = "reach_commons"
4
- version = "0.18.42"
4
+ version = "0.18.43"
5
5
  description = "Reach Commons is a versatile utility library designed to streamline and enhance development workflows within the Reach ecosystem."
6
6
  authors = ["Engineering <engineering@getreach.ai>"]
7
7
  license = "MIT"
@@ -0,0 +1,81 @@
1
+ from dataclasses import dataclass, field
2
+ from math import ceil
3
+ from typing import Union
4
+
5
+ # Basic GSM-7 char set (without extension table handling).
6
+ # If you want 100% accuracy for GSM-7, we can add the extension table later.
7
+ GSM7_BASIC = set(
8
+ "@£$¥èéùìòÇ\nØø\rÅåΔ_ΦΓΛΩΠΨΣΘΞ"
9
+ "ÆæßÉ !\"#¤%&'()*+,-./"
10
+ "0123456789:;<=>?"
11
+ "¡ABCDEFGHIJKLMNOPQRSTUVWXYZÄÖÑܧ"
12
+ "¿abcdefghijklmnopqrstuvwxyzäöñüà"
13
+ )
14
+
15
+
16
+ def is_gsm7(text: str) -> bool:
17
+ return all(ch in GSM7_BASIC for ch in text)
18
+
19
+
20
+ def ucs2_units(text: str) -> int:
21
+ # UTF-16 code units: emoji counts as 2 (surrogate pair), which matches UCS-2 segment math used in practice.
22
+ return len(text.encode("utf-16-be")) // 2
23
+
24
+
25
+ def fix_surrogates(text: str) -> str:
26
+ # Turns surrogate pairs like \uD83D\uDC96 into the real character (💖)
27
+ return text.encode("utf-16", "surrogatepass").decode("utf-16")
28
+
29
+
30
+ @dataclass
31
+ class MessageSmartEncoding:
32
+ """
33
+ Sms Message Representation
34
+ """
35
+
36
+ replacements = {
37
+ "“": '"',
38
+ "”": '"',
39
+ "‘": "'",
40
+ "’": "'",
41
+ "–": "-",
42
+ "—": "-",
43
+ "…": "...",
44
+ "•": "-",
45
+ "€": "EUR",
46
+ "™": "",
47
+ "©": "",
48
+ "®": "",
49
+ "\u0002": "",
50
+ "\u001b": "",
51
+ }
52
+ body: Union[str, list]
53
+ normalized_text: str = field(init=False)
54
+ length: int = field(init=False)
55
+ segments: int = field(init=False)
56
+
57
+ def __post_init__(self):
58
+ body_text = (
59
+ " ".join(map(str, self.body))
60
+ if isinstance(self.body, list)
61
+ else str(self.body)
62
+ )
63
+ self.normalized_text = fix_surrogates(self.normalize(body_text))
64
+
65
+ if is_gsm7(self.normalized_text):
66
+ self.encoding = "GSM-7"
67
+ text_length = len(self.normalized_text)
68
+ self.length = text_length
69
+ per_segment = 160 if text_length <= 160 else 153
70
+ self.segments = ceil(text_length / per_segment)
71
+ else:
72
+ self.encoding = "UCS-2"
73
+ text_units_count = ucs2_units(self.normalized_text)
74
+ self.length = text_units_count
75
+ per_segment = 70 if text_units_count <= 70 else 67
76
+ self.segments = ceil(text_units_count / per_segment)
77
+
78
+ def normalize(self, text: str) -> str:
79
+ for char, replacement in self.replacements.items():
80
+ text = text.replace(char, replacement)
81
+ return text
@@ -1,47 +0,0 @@
1
- from dataclasses import dataclass, field
2
- from math import ceil
3
- from typing import Union
4
-
5
-
6
- @dataclass
7
- class MessageSmartEncoding:
8
- """
9
- Sms Message Representation
10
- """
11
-
12
- replacements = {
13
- "“": '"',
14
- "”": '"',
15
- "‘": "'",
16
- "’": "'",
17
- "–": "-",
18
- "—": "-",
19
- "…": "...",
20
- "•": "-",
21
- "€": "EUR",
22
- "™": "",
23
- "©": "",
24
- "®": "",
25
- "\u0002": "",
26
- "\u001b": "",
27
- }
28
- body: Union[str, list]
29
- normalized_text: str = field(init=False)
30
- length: int = field(init=False)
31
- segments: int = field(init=False)
32
-
33
- def __post_init__(self):
34
- # Convert body to string if it's a list
35
- if isinstance(self.body, list):
36
- body_text = " ".join(str(item) for item in self.body)
37
- else:
38
- body_text = self.body
39
-
40
- self.normalized_text = self.normalize(body_text)
41
- self.length = len(self.normalized_text)
42
- self.segments = ceil(self.length / 160)
43
-
44
- def normalize(self, text: str) -> str:
45
- for char, replacement in self.replacements.items():
46
- text = text.replace(char, replacement)
47
- return text