wappa 0.1.9__py3-none-any.whl → 0.1.10__py3-none-any.whl

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.

Potentially problematic release.


This version of wappa might be problematic. Click here for more details.

Files changed (126) hide show
  1. wappa/__init__.py +4 -5
  2. wappa/api/controllers/webhook_controller.py +5 -2
  3. wappa/api/dependencies/__init__.py +0 -5
  4. wappa/api/middleware/error_handler.py +4 -4
  5. wappa/api/middleware/owner.py +11 -5
  6. wappa/api/routes/webhooks.py +2 -2
  7. wappa/cli/__init__.py +1 -1
  8. wappa/cli/examples/init/app/main.py +2 -1
  9. wappa/cli/examples/init/app/master_event.py +5 -3
  10. wappa/cli/examples/json_cache_example/app/__init__.py +1 -1
  11. wappa/cli/examples/json_cache_example/app/main.py +56 -44
  12. wappa/cli/examples/json_cache_example/app/master_event.py +181 -145
  13. wappa/cli/examples/json_cache_example/app/models/__init__.py +1 -1
  14. wappa/cli/examples/json_cache_example/app/models/json_demo_models.py +32 -51
  15. wappa/cli/examples/json_cache_example/app/scores/__init__.py +2 -2
  16. wappa/cli/examples/json_cache_example/app/scores/score_base.py +52 -46
  17. wappa/cli/examples/json_cache_example/app/scores/score_cache_statistics.py +70 -62
  18. wappa/cli/examples/json_cache_example/app/scores/score_message_history.py +41 -44
  19. wappa/cli/examples/json_cache_example/app/scores/score_state_commands.py +83 -71
  20. wappa/cli/examples/json_cache_example/app/scores/score_user_management.py +73 -57
  21. wappa/cli/examples/json_cache_example/app/utils/__init__.py +2 -2
  22. wappa/cli/examples/json_cache_example/app/utils/cache_utils.py +54 -56
  23. wappa/cli/examples/json_cache_example/app/utils/message_utils.py +85 -80
  24. wappa/cli/examples/openai_transcript/app/main.py +2 -1
  25. wappa/cli/examples/openai_transcript/app/master_event.py +31 -22
  26. wappa/cli/examples/openai_transcript/app/openai_utils/__init__.py +1 -1
  27. wappa/cli/examples/openai_transcript/app/openai_utils/audio_processing.py +37 -24
  28. wappa/cli/examples/redis_cache_example/app/__init__.py +1 -1
  29. wappa/cli/examples/redis_cache_example/app/main.py +56 -44
  30. wappa/cli/examples/redis_cache_example/app/master_event.py +181 -145
  31. wappa/cli/examples/redis_cache_example/app/models/redis_demo_models.py +31 -50
  32. wappa/cli/examples/redis_cache_example/app/scores/__init__.py +2 -2
  33. wappa/cli/examples/redis_cache_example/app/scores/score_base.py +52 -46
  34. wappa/cli/examples/redis_cache_example/app/scores/score_cache_statistics.py +70 -62
  35. wappa/cli/examples/redis_cache_example/app/scores/score_message_history.py +41 -44
  36. wappa/cli/examples/redis_cache_example/app/scores/score_state_commands.py +83 -71
  37. wappa/cli/examples/redis_cache_example/app/scores/score_user_management.py +73 -57
  38. wappa/cli/examples/redis_cache_example/app/utils/__init__.py +2 -2
  39. wappa/cli/examples/redis_cache_example/app/utils/cache_utils.py +54 -56
  40. wappa/cli/examples/redis_cache_example/app/utils/message_utils.py +85 -80
  41. wappa/cli/examples/simple_echo_example/app/__init__.py +1 -1
  42. wappa/cli/examples/simple_echo_example/app/main.py +41 -33
  43. wappa/cli/examples/simple_echo_example/app/master_event.py +78 -57
  44. wappa/cli/examples/wappa_full_example/app/__init__.py +1 -1
  45. wappa/cli/examples/wappa_full_example/app/handlers/__init__.py +1 -1
  46. wappa/cli/examples/wappa_full_example/app/handlers/command_handlers.py +134 -126
  47. wappa/cli/examples/wappa_full_example/app/handlers/message_handlers.py +237 -229
  48. wappa/cli/examples/wappa_full_example/app/handlers/state_handlers.py +170 -148
  49. wappa/cli/examples/wappa_full_example/app/main.py +51 -39
  50. wappa/cli/examples/wappa_full_example/app/master_event.py +179 -120
  51. wappa/cli/examples/wappa_full_example/app/models/__init__.py +1 -1
  52. wappa/cli/examples/wappa_full_example/app/models/state_models.py +113 -104
  53. wappa/cli/examples/wappa_full_example/app/models/user_models.py +92 -76
  54. wappa/cli/examples/wappa_full_example/app/models/webhook_metadata.py +109 -83
  55. wappa/cli/examples/wappa_full_example/app/utils/__init__.py +1 -1
  56. wappa/cli/examples/wappa_full_example/app/utils/cache_utils.py +132 -113
  57. wappa/cli/examples/wappa_full_example/app/utils/media_handler.py +175 -132
  58. wappa/cli/examples/wappa_full_example/app/utils/metadata_extractor.py +126 -87
  59. wappa/cli/main.py +9 -4
  60. wappa/core/__init__.py +18 -23
  61. wappa/core/config/settings.py +7 -5
  62. wappa/core/events/default_handlers.py +1 -1
  63. wappa/core/factory/wappa_builder.py +38 -25
  64. wappa/core/plugins/redis_plugin.py +1 -3
  65. wappa/core/plugins/wappa_core_plugin.py +7 -6
  66. wappa/core/types.py +12 -12
  67. wappa/core/wappa_app.py +10 -8
  68. wappa/database/__init__.py +3 -4
  69. wappa/domain/enums/messenger_platform.py +1 -2
  70. wappa/domain/factories/media_factory.py +5 -20
  71. wappa/domain/factories/message_factory.py +5 -20
  72. wappa/domain/factories/messenger_factory.py +2 -4
  73. wappa/domain/interfaces/cache_interface.py +7 -7
  74. wappa/domain/interfaces/media_interface.py +2 -5
  75. wappa/domain/models/media_result.py +1 -3
  76. wappa/domain/models/platforms/platform_config.py +1 -3
  77. wappa/messaging/__init__.py +9 -12
  78. wappa/messaging/whatsapp/handlers/whatsapp_media_handler.py +20 -22
  79. wappa/models/__init__.py +27 -35
  80. wappa/persistence/__init__.py +12 -15
  81. wappa/persistence/cache_factory.py +0 -1
  82. wappa/persistence/json/__init__.py +1 -1
  83. wappa/persistence/json/cache_adapters.py +37 -25
  84. wappa/persistence/json/handlers/state_handler.py +60 -52
  85. wappa/persistence/json/handlers/table_handler.py +51 -49
  86. wappa/persistence/json/handlers/user_handler.py +71 -55
  87. wappa/persistence/json/handlers/utils/file_manager.py +42 -39
  88. wappa/persistence/json/handlers/utils/key_factory.py +1 -1
  89. wappa/persistence/json/handlers/utils/serialization.py +13 -11
  90. wappa/persistence/json/json_cache_factory.py +4 -8
  91. wappa/persistence/json/storage_manager.py +66 -79
  92. wappa/persistence/memory/__init__.py +1 -1
  93. wappa/persistence/memory/cache_adapters.py +37 -25
  94. wappa/persistence/memory/handlers/state_handler.py +62 -52
  95. wappa/persistence/memory/handlers/table_handler.py +59 -53
  96. wappa/persistence/memory/handlers/user_handler.py +75 -55
  97. wappa/persistence/memory/handlers/utils/key_factory.py +1 -1
  98. wappa/persistence/memory/handlers/utils/memory_store.py +75 -71
  99. wappa/persistence/memory/handlers/utils/ttl_manager.py +59 -67
  100. wappa/persistence/memory/memory_cache_factory.py +3 -7
  101. wappa/persistence/memory/storage_manager.py +52 -62
  102. wappa/persistence/redis/cache_adapters.py +27 -21
  103. wappa/persistence/redis/ops.py +11 -11
  104. wappa/persistence/redis/redis_client.py +4 -6
  105. wappa/persistence/redis/redis_manager.py +12 -4
  106. wappa/processors/factory.py +5 -5
  107. wappa/schemas/factory.py +2 -5
  108. wappa/schemas/whatsapp/message_types/errors.py +3 -12
  109. wappa/schemas/whatsapp/validators.py +3 -3
  110. wappa/webhooks/__init__.py +17 -18
  111. wappa/webhooks/factory.py +3 -5
  112. wappa/webhooks/whatsapp/__init__.py +10 -13
  113. wappa/webhooks/whatsapp/message_types/audio.py +0 -4
  114. wappa/webhooks/whatsapp/message_types/document.py +1 -9
  115. wappa/webhooks/whatsapp/message_types/errors.py +3 -12
  116. wappa/webhooks/whatsapp/message_types/location.py +1 -21
  117. wappa/webhooks/whatsapp/message_types/sticker.py +1 -5
  118. wappa/webhooks/whatsapp/message_types/text.py +0 -6
  119. wappa/webhooks/whatsapp/message_types/video.py +1 -20
  120. wappa/webhooks/whatsapp/status_models.py +2 -2
  121. wappa/webhooks/whatsapp/validators.py +3 -3
  122. {wappa-0.1.9.dist-info → wappa-0.1.10.dist-info}/METADATA +362 -8
  123. {wappa-0.1.9.dist-info → wappa-0.1.10.dist-info}/RECORD +126 -126
  124. {wappa-0.1.9.dist-info → wappa-0.1.10.dist-info}/WHEEL +0 -0
  125. {wappa-0.1.9.dist-info → wappa-0.1.10.dist-info}/entry_points.txt +0 -0
  126. {wappa-0.1.9.dist-info → wappa-0.1.10.dist-info}/licenses/LICENSE +0 -0
@@ -47,29 +47,29 @@ from .master_event import WappaFullExampleHandler
47
47
  def validate_configuration() -> bool:
48
48
  """
49
49
  Validate required configuration settings.
50
-
50
+
51
51
  Returns:
52
52
  True if configuration is valid, False otherwise
53
53
  """
54
54
  missing_configs = []
55
-
55
+
56
56
  if not settings.wp_access_token:
57
57
  missing_configs.append("WP_ACCESS_TOKEN")
58
-
58
+
59
59
  if not settings.wp_phone_id:
60
60
  missing_configs.append("WP_PHONE_ID")
61
-
61
+
62
62
  if not settings.wp_bid:
63
63
  missing_configs.append("WP_BID")
64
-
64
+
65
65
  if not settings.has_redis:
66
66
  missing_configs.append("REDIS_URL")
67
-
67
+
68
68
  if missing_configs:
69
69
  logger.error(f"āŒ Missing required configuration: {', '.join(missing_configs)}")
70
70
  logger.error("šŸ’” Create a .env file with the required credentials")
71
71
  return False
72
-
72
+
73
73
  logger.info("āœ… Configuration validation passed")
74
74
  return True
75
75
 
@@ -81,7 +81,7 @@ def display_startup_information() -> None:
81
81
  print(f"šŸš€ Wappa v{__version__} - Full Example (Comprehensive Demo)")
82
82
  print("=" * 80)
83
83
  print()
84
-
84
+
85
85
  print("šŸŽÆ *COMPREHENSIVE WAPPA FRAMEWORK DEMONSTRATION*")
86
86
  print(" This example showcases ALL major Wappa framework features:")
87
87
  print(" • Complete message type handling with metadata extraction")
@@ -91,15 +91,21 @@ def display_startup_information() -> None:
91
91
  print(" • Welcome messages for first-time users")
92
92
  print(" • Professional error handling and logging")
93
93
  print()
94
-
94
+
95
95
  print("šŸ“‹ *CONFIGURATION STATUS:*")
96
- print(f" • Access Token: {'āœ… Configured' if settings.wp_access_token else 'āŒ Missing'}")
97
- print(f" • Phone ID: {settings.wp_phone_id if settings.wp_phone_id else 'āŒ Missing'}")
96
+ print(
97
+ f" • Access Token: {'āœ… Configured' if settings.wp_access_token else 'āŒ Missing'}"
98
+ )
99
+ print(
100
+ f" • Phone ID: {settings.wp_phone_id if settings.wp_phone_id else 'āŒ Missing'}"
101
+ )
98
102
  print(f" • Business ID: {'āœ… Configured' if settings.wp_bid else 'āŒ Missing'}")
99
103
  print(f" • Redis URL: {'āœ… Configured' if settings.has_redis else 'āŒ Missing'}")
100
- print(f" • Environment: {'šŸ› ļø Development' if settings.is_development else 'šŸš€ Production'}")
104
+ print(
105
+ f" • Environment: {'šŸ› ļø Development' if settings.is_development else 'šŸš€ Production'}"
106
+ )
101
107
  print()
102
-
108
+
103
109
  print("šŸŽ® *INTERACTIVE DEMO COMMANDS:*")
104
110
  print(" • `/button` → Interactive button demo with animal selection")
105
111
  print(" - Creates buttons for Kitty 🐱 and Puppy 🐶")
@@ -120,7 +126,7 @@ def display_startup_information() -> None:
120
126
  print(" - Shares predefined location (BogotĆ”, Colombia)")
121
127
  print(" - Shows location message implementation")
122
128
  print()
123
-
129
+
124
130
  print("šŸ“Ø *MESSAGE TYPE HANDLING:*")
125
131
  print(" • Text Messages → Echo with 'Echo - {content}' + metadata")
126
132
  print(" • Media Messages → Relay same media using media_id + metadata")
@@ -128,14 +134,14 @@ def display_startup_information() -> None:
128
134
  print(" • Contact Messages → Echo contact information + metadata")
129
135
  print(" • Interactive Messages → Process selections + metadata")
130
136
  print()
131
-
137
+
132
138
  print("šŸ‘¤ *USER MANAGEMENT FEATURES:*")
133
139
  print(" • First-time user detection and welcome messages")
134
140
  print(" • User profile caching with activity tracking")
135
141
  print(" • Message count and interaction statistics")
136
142
  print(" • Command usage analytics")
137
143
  print()
138
-
144
+
139
145
  print("šŸ—ļø *TECHNICAL ARCHITECTURE:*")
140
146
  print(" • Redis cache for user profiles and interactive states")
141
147
  print(" • Comprehensive metadata extraction per message type")
@@ -144,7 +150,7 @@ def display_startup_information() -> None:
144
150
  print(" • Structured logging with performance metrics")
145
151
  print(" • Clean code architecture with separation of concerns")
146
152
  print()
147
-
153
+
148
154
  print("šŸ“Š *DEMONSTRATED PATTERNS:*")
149
155
  print(" • Complete IMessenger interface utilization")
150
156
  print(" • Media handling with download/upload capabilities")
@@ -158,7 +164,7 @@ def display_startup_information() -> None:
158
164
  def create_wappa_application() -> Wappa:
159
165
  """
160
166
  Create and configure the Wappa application.
161
-
167
+
162
168
  Returns:
163
169
  Configured Wappa application instance
164
170
  """
@@ -166,10 +172,10 @@ def create_wappa_application() -> Wappa:
166
172
  # Create Wappa instance with Redis cache
167
173
  logger.info("šŸ—ļø Creating Wappa application with Redis cache...")
168
174
  app = Wappa(cache="redis")
169
-
175
+
170
176
  logger.info("āœ… Wappa application created successfully")
171
177
  return app
172
-
178
+
173
179
  except Exception as e:
174
180
  logger.error(f"āŒ Failed to create Wappa application: {e}")
175
181
  raise
@@ -178,7 +184,7 @@ def create_wappa_application() -> Wappa:
178
184
  def main() -> None:
179
185
  """
180
186
  Main application entry point.
181
-
187
+
182
188
  Demonstrates complete Wappa framework integration with:
183
189
  - Configuration validation
184
190
  - Application setup
@@ -186,50 +192,54 @@ def main() -> None:
186
192
  - Professional startup flow
187
193
  """
188
194
  logger.info("šŸš€ Starting Wappa Full Example - Comprehensive Demo")
189
-
195
+
190
196
  try:
191
197
  # Display comprehensive startup information
192
198
  display_startup_information()
193
-
199
+
194
200
  # Validate configuration before proceeding
195
201
  if not validate_configuration():
196
- logger.error("āŒ Configuration validation failed - cannot start application")
202
+ logger.error(
203
+ "āŒ Configuration validation failed - cannot start application"
204
+ )
197
205
  return
198
-
206
+
199
207
  # Create Wappa application
200
208
  app = create_wappa_application()
201
-
209
+
202
210
  # Create and set our comprehensive WappaEventHandler implementation
203
211
  handler = WappaFullExampleHandler()
204
212
  app.set_event_handler(handler)
205
-
206
- logger.info("āœ… Application initialization completed with comprehensive WappaEventHandler")
207
-
213
+
214
+ logger.info(
215
+ "āœ… Application initialization completed with comprehensive WappaEventHandler"
216
+ )
217
+
208
218
  print("🌐 Starting comprehensive Wappa demo server...")
209
219
  print("šŸ’” Press CTRL+C to stop the server")
210
220
  print()
211
221
  print("šŸŽÆ *Try these features once connected:*")
212
222
  print(" 1. Send any message → See metadata extraction + echo")
213
223
  print(" 2. Send /button → Interactive button demo")
214
- print(" 3. Send /list → Interactive list demo")
224
+ print(" 3. Send /list → Interactive list demo")
215
225
  print(" 4. Send /cta → Call-to-action button")
216
226
  print(" 5. Send /location → Location sharing demo")
217
227
  print(" 6. Send media files → See media relay functionality")
218
228
  print("=" * 80)
219
229
  print()
220
-
230
+
221
231
  # Start the application
222
232
  # The framework will handle dependency injection automatically
223
233
  app.run()
224
-
234
+
225
235
  except KeyboardInterrupt:
226
236
  logger.info("šŸ‘‹ Application stopped by user")
227
237
  print("\nšŸ‘‹ Wappa Full Example stopped by user")
228
-
238
+
229
239
  except Exception as e:
230
240
  logger.error(f"āŒ Application startup error: {e}", exc_info=True)
231
241
  print(f"\nāŒ Server error: {e}")
232
-
242
+
233
243
  finally:
234
244
  logger.info("šŸ Wappa Full Example completed")
235
245
  print("šŸ Wappa Full Example completed")
@@ -241,17 +251,19 @@ def main() -> None:
241
251
  try:
242
252
  logger.info("šŸ“¦ Creating module-level Wappa application instance")
243
253
  app = Wappa(cache="redis")
244
-
254
+
245
255
  # Create and set our comprehensive WappaEventHandler implementation
246
256
  handler = WappaFullExampleHandler()
247
257
  app.set_event_handler(handler)
248
-
249
- logger.info("āœ… Module-level application instance ready with comprehensive WappaEventHandler")
250
-
258
+
259
+ logger.info(
260
+ "āœ… Module-level application instance ready with comprehensive WappaEventHandler"
261
+ )
262
+
251
263
  except Exception as e:
252
264
  logger.error(f"āŒ Failed to create module-level app instance: {e}")
253
265
  raise
254
266
 
255
267
 
256
268
  if __name__ == "__main__":
257
- main()
269
+ main()