django-cfg 1.5.8__py3-none-any.whl → 1.5.20__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 django-cfg might be problematic. Click here for more details.
- django_cfg/__init__.py +1 -1
- django_cfg/apps/api/commands/serializers.py +152 -0
- django_cfg/apps/api/commands/views.py +32 -0
- django_cfg/apps/business/accounts/management/commands/otp_test.py +5 -2
- django_cfg/apps/business/accounts/serializers/profile.py +42 -0
- django_cfg/apps/business/agents/management/commands/create_agent.py +5 -194
- django_cfg/apps/business/agents/management/commands/load_agent_templates.py +205 -0
- django_cfg/apps/business/agents/management/commands/orchestrator_status.py +4 -2
- django_cfg/apps/business/knowbase/management/commands/knowbase_stats.py +4 -2
- django_cfg/apps/business/knowbase/management/commands/setup_knowbase.py +4 -2
- django_cfg/apps/business/newsletter/management/commands/test_newsletter.py +5 -2
- django_cfg/apps/business/payments/management/commands/check_payment_status.py +4 -2
- django_cfg/apps/business/payments/management/commands/create_payment.py +4 -2
- django_cfg/apps/business/payments/management/commands/sync_currencies.py +4 -2
- django_cfg/apps/business/support/serializers.py +3 -2
- django_cfg/apps/integrations/centrifugo/apps.py +2 -1
- django_cfg/apps/integrations/centrifugo/codegen/generators/typescript_thin/templates/rpc-client.ts.j2 +151 -12
- django_cfg/apps/integrations/centrifugo/management/commands/generate_centrifugo_clients.py +6 -6
- django_cfg/apps/integrations/centrifugo/serializers/__init__.py +2 -1
- django_cfg/apps/integrations/centrifugo/serializers/publishes.py +22 -2
- django_cfg/apps/integrations/centrifugo/services/__init__.py +6 -0
- django_cfg/apps/integrations/centrifugo/services/client/__init__.py +6 -1
- django_cfg/apps/integrations/centrifugo/services/client/direct_client.py +282 -0
- django_cfg/apps/integrations/centrifugo/services/publisher.py +371 -0
- django_cfg/apps/integrations/centrifugo/services/token_generator.py +122 -0
- django_cfg/apps/integrations/centrifugo/urls.py +8 -0
- django_cfg/apps/integrations/centrifugo/views/__init__.py +2 -0
- django_cfg/apps/integrations/centrifugo/views/monitoring.py +25 -40
- django_cfg/apps/integrations/centrifugo/views/testing_api.py +0 -79
- django_cfg/apps/integrations/centrifugo/views/token_api.py +101 -0
- django_cfg/apps/integrations/centrifugo/views/wrapper.py +257 -0
- django_cfg/apps/integrations/grpc/admin/__init__.py +7 -1
- django_cfg/apps/integrations/grpc/admin/config.py +113 -9
- django_cfg/apps/integrations/grpc/admin/grpc_api_key.py +129 -0
- django_cfg/apps/integrations/grpc/admin/grpc_request_log.py +72 -63
- django_cfg/apps/integrations/grpc/admin/grpc_server_status.py +236 -0
- django_cfg/apps/integrations/grpc/auth/__init__.py +11 -3
- django_cfg/apps/integrations/grpc/auth/api_key_auth.py +320 -0
- django_cfg/apps/integrations/grpc/centrifugo/__init__.py +29 -0
- django_cfg/apps/integrations/grpc/centrifugo/bridge.py +277 -0
- django_cfg/apps/integrations/grpc/centrifugo/config.py +167 -0
- django_cfg/apps/integrations/grpc/centrifugo/demo.py +626 -0
- django_cfg/apps/integrations/grpc/centrifugo/test_publish.py +229 -0
- django_cfg/apps/integrations/grpc/centrifugo/transformers.py +89 -0
- django_cfg/apps/integrations/grpc/interceptors/__init__.py +3 -1
- django_cfg/apps/integrations/grpc/interceptors/centrifugo.py +541 -0
- django_cfg/apps/integrations/grpc/interceptors/logging.py +17 -20
- django_cfg/apps/integrations/grpc/interceptors/metrics.py +15 -14
- django_cfg/apps/integrations/grpc/interceptors/request_logger.py +79 -59
- django_cfg/apps/integrations/grpc/management/commands/compile_proto.py +105 -0
- django_cfg/apps/integrations/grpc/management/commands/generate_protos.py +185 -0
- django_cfg/apps/integrations/grpc/management/commands/rungrpc.py +474 -95
- django_cfg/apps/integrations/grpc/management/commands/test_grpc_integration.py +75 -0
- django_cfg/apps/integrations/grpc/management/proto/__init__.py +3 -0
- django_cfg/apps/integrations/grpc/management/proto/compiler.py +194 -0
- django_cfg/apps/integrations/grpc/managers/__init__.py +2 -0
- django_cfg/apps/integrations/grpc/managers/grpc_api_key.py +192 -0
- django_cfg/apps/integrations/grpc/managers/grpc_server_status.py +19 -11
- django_cfg/apps/integrations/grpc/migrations/0005_grpcapikey.py +143 -0
- django_cfg/apps/integrations/grpc/migrations/0006_grpcrequestlog_api_key_and_more.py +34 -0
- django_cfg/apps/integrations/grpc/models/__init__.py +2 -0
- django_cfg/apps/integrations/grpc/models/grpc_api_key.py +198 -0
- django_cfg/apps/integrations/grpc/models/grpc_request_log.py +11 -0
- django_cfg/apps/integrations/grpc/models/grpc_server_status.py +39 -4
- django_cfg/apps/integrations/grpc/serializers/__init__.py +22 -6
- django_cfg/apps/integrations/grpc/serializers/api_keys.py +63 -0
- django_cfg/apps/integrations/grpc/serializers/charts.py +118 -120
- django_cfg/apps/integrations/grpc/serializers/config.py +65 -51
- django_cfg/apps/integrations/grpc/serializers/health.py +7 -7
- django_cfg/apps/integrations/grpc/serializers/proto_files.py +74 -0
- django_cfg/apps/integrations/grpc/serializers/requests.py +13 -7
- django_cfg/apps/integrations/grpc/serializers/service_registry.py +181 -112
- django_cfg/apps/integrations/grpc/serializers/services.py +14 -32
- django_cfg/apps/integrations/grpc/serializers/stats.py +50 -12
- django_cfg/apps/integrations/grpc/serializers/testing.py +66 -58
- django_cfg/apps/integrations/grpc/services/__init__.py +2 -0
- django_cfg/apps/integrations/grpc/services/discovery.py +7 -1
- django_cfg/apps/integrations/grpc/services/monitoring_service.py +149 -43
- django_cfg/apps/integrations/grpc/services/proto_files_manager.py +268 -0
- django_cfg/apps/integrations/grpc/services/service_registry.py +48 -46
- django_cfg/apps/integrations/grpc/services/testing_service.py +10 -15
- django_cfg/apps/integrations/grpc/urls.py +8 -0
- django_cfg/apps/integrations/grpc/utils/SERVER_LOGGING.md +164 -0
- django_cfg/apps/integrations/grpc/utils/__init__.py +4 -13
- django_cfg/apps/integrations/grpc/utils/integration_test.py +334 -0
- django_cfg/apps/integrations/grpc/utils/proto_gen.py +48 -8
- django_cfg/apps/integrations/grpc/utils/streaming_logger.py +378 -0
- django_cfg/apps/integrations/grpc/views/__init__.py +4 -0
- django_cfg/apps/integrations/grpc/views/api_keys.py +255 -0
- django_cfg/apps/integrations/grpc/views/charts.py +21 -14
- django_cfg/apps/integrations/grpc/views/config.py +8 -6
- django_cfg/apps/integrations/grpc/views/monitoring.py +51 -79
- django_cfg/apps/integrations/grpc/views/proto_files.py +214 -0
- django_cfg/apps/integrations/grpc/views/services.py +30 -21
- django_cfg/apps/integrations/grpc/views/testing.py +45 -43
- django_cfg/apps/integrations/rq/views/jobs.py +19 -9
- django_cfg/apps/integrations/rq/views/schedule.py +7 -3
- django_cfg/apps/system/dashboard/serializers/commands.py +25 -1
- django_cfg/apps/system/dashboard/serializers/config.py +95 -9
- django_cfg/apps/system/dashboard/serializers/statistics.py +9 -4
- django_cfg/apps/system/dashboard/services/commands_service.py +12 -1
- django_cfg/apps/system/frontend/views.py +87 -6
- django_cfg/apps/system/maintenance/management/commands/maintenance.py +5 -2
- django_cfg/apps/system/maintenance/management/commands/process_scheduled_maintenance.py +4 -2
- django_cfg/apps/system/maintenance/management/commands/sync_cloudflare.py +5 -2
- django_cfg/config.py +33 -0
- django_cfg/core/builders/security_builder.py +1 -0
- django_cfg/core/generation/integration_generators/api.py +2 -0
- django_cfg/core/generation/integration_generators/grpc_generator.py +30 -32
- django_cfg/management/commands/check_endpoints.py +2 -2
- django_cfg/management/commands/check_settings.py +3 -10
- django_cfg/management/commands/clear_constance.py +3 -10
- django_cfg/management/commands/create_token.py +4 -11
- django_cfg/management/commands/list_urls.py +4 -10
- django_cfg/management/commands/migrate_all.py +18 -12
- django_cfg/management/commands/migrator.py +4 -11
- django_cfg/management/commands/script.py +4 -10
- django_cfg/management/commands/show_config.py +8 -16
- django_cfg/management/commands/show_urls.py +5 -11
- django_cfg/management/commands/superuser.py +4 -11
- django_cfg/management/commands/tree.py +5 -10
- django_cfg/management/utils/README.md +402 -0
- django_cfg/management/utils/__init__.py +29 -0
- django_cfg/management/utils/mixins.py +176 -0
- django_cfg/middleware/pagination.py +53 -54
- django_cfg/models/api/grpc/__init__.py +15 -21
- django_cfg/models/api/grpc/config.py +155 -73
- django_cfg/models/ngrok/config.py +7 -6
- django_cfg/modules/django_client/core/generator/python/files_generator.py +5 -13
- django_cfg/modules/django_client/core/generator/python/templates/api_wrapper.py.jinja +16 -4
- django_cfg/modules/django_client/core/generator/python/templates/main_init.py.jinja +2 -3
- django_cfg/modules/django_client/core/generator/typescript/files_generator.py +6 -5
- django_cfg/modules/django_client/core/generator/typescript/generator.py +26 -0
- django_cfg/modules/django_client/core/generator/typescript/hooks_generator.py +7 -1
- django_cfg/modules/django_client/core/generator/typescript/models_generator.py +5 -0
- django_cfg/modules/django_client/core/generator/typescript/schemas_generator.py +11 -0
- django_cfg/modules/django_client/core/generator/typescript/templates/fetchers/fetchers.ts.jinja +1 -0
- django_cfg/modules/django_client/core/generator/typescript/templates/fetchers/function.ts.jinja +29 -1
- django_cfg/modules/django_client/core/generator/typescript/templates/hooks/hooks.ts.jinja +4 -0
- django_cfg/modules/django_client/core/generator/typescript/templates/main_index.ts.jinja +12 -8
- django_cfg/modules/django_client/core/ir/schema.py +15 -1
- django_cfg/modules/django_client/core/parser/base.py +126 -30
- django_cfg/modules/django_client/management/commands/generate_client.py +5 -2
- django_cfg/modules/django_client/management/commands/validate_openapi.py +5 -2
- django_cfg/modules/django_email/management/commands/test_email.py +4 -10
- django_cfg/modules/django_ngrok/management/commands/runserver_ngrok.py +16 -13
- django_cfg/modules/django_telegram/management/commands/test_telegram.py +4 -11
- django_cfg/modules/django_twilio/management/commands/test_twilio.py +4 -11
- django_cfg/modules/django_unfold/navigation.py +6 -18
- django_cfg/pyproject.toml +1 -1
- django_cfg/registry/modules.py +1 -4
- django_cfg/requirements.txt +52 -0
- django_cfg/static/frontend/admin.zip +0 -0
- {django_cfg-1.5.8.dist-info → django_cfg-1.5.20.dist-info}/METADATA +1 -1
- {django_cfg-1.5.8.dist-info → django_cfg-1.5.20.dist-info}/RECORD +158 -121
- django_cfg/apps/integrations/grpc/auth/jwt_auth.py +0 -295
- {django_cfg-1.5.8.dist-info → django_cfg-1.5.20.dist-info}/WHEEL +0 -0
- {django_cfg-1.5.8.dist-info → django_cfg-1.5.20.dist-info}/entry_points.txt +0 -0
- {django_cfg-1.5.8.dist-info → django_cfg-1.5.20.dist-info}/licenses/LICENSE +0 -0
|
@@ -0,0 +1,167 @@
|
|
|
1
|
+
"""
|
|
2
|
+
Pydantic Configuration Models for Centrifugo Bridge.
|
|
3
|
+
|
|
4
|
+
Type-safe, validated configuration using Pydantic v2.
|
|
5
|
+
"""
|
|
6
|
+
|
|
7
|
+
from pydantic import BaseModel, Field, field_validator
|
|
8
|
+
from typing import Optional, Callable, Any, Dict
|
|
9
|
+
|
|
10
|
+
|
|
11
|
+
class ChannelConfig(BaseModel):
|
|
12
|
+
"""
|
|
13
|
+
Configuration for a single gRPC field → Centrifugo channel mapping.
|
|
14
|
+
|
|
15
|
+
Example:
|
|
16
|
+
```python
|
|
17
|
+
ChannelConfig(
|
|
18
|
+
template='bot#{bot_id}#heartbeat',
|
|
19
|
+
rate_limit=0.1,
|
|
20
|
+
critical=False
|
|
21
|
+
)
|
|
22
|
+
```
|
|
23
|
+
|
|
24
|
+
Attributes:
|
|
25
|
+
template: Channel name template with {variable} placeholders
|
|
26
|
+
rate_limit: Minimum seconds between publishes (None = no limit)
|
|
27
|
+
critical: Critical events bypass rate limiting
|
|
28
|
+
enabled: Enable/disable this specific channel
|
|
29
|
+
metadata: Additional metadata included in published data
|
|
30
|
+
"""
|
|
31
|
+
|
|
32
|
+
template: str = Field(
|
|
33
|
+
...,
|
|
34
|
+
description="Channel template with {variable} placeholders",
|
|
35
|
+
examples=["bot#{bot_id}#heartbeat", "user#{user_id}#notifications"]
|
|
36
|
+
)
|
|
37
|
+
|
|
38
|
+
rate_limit: Optional[float] = Field(
|
|
39
|
+
None,
|
|
40
|
+
description="Minimum seconds between publishes (None = no limit)",
|
|
41
|
+
ge=0.0,
|
|
42
|
+
examples=[0.1, 1.0, None]
|
|
43
|
+
)
|
|
44
|
+
|
|
45
|
+
critical: bool = Field(
|
|
46
|
+
False,
|
|
47
|
+
description="Critical events bypass rate limiting"
|
|
48
|
+
)
|
|
49
|
+
|
|
50
|
+
enabled: bool = Field(
|
|
51
|
+
True,
|
|
52
|
+
description="Enable/disable this channel"
|
|
53
|
+
)
|
|
54
|
+
|
|
55
|
+
metadata: Dict[str, Any] = Field(
|
|
56
|
+
default_factory=dict,
|
|
57
|
+
description="Additional metadata to include in published data"
|
|
58
|
+
)
|
|
59
|
+
|
|
60
|
+
# Optional custom transform function (not serialized)
|
|
61
|
+
transform: Optional[Callable[[str, Any], dict]] = Field(
|
|
62
|
+
None,
|
|
63
|
+
exclude=True,
|
|
64
|
+
description="Custom transform function(field_name, field_value) -> dict"
|
|
65
|
+
)
|
|
66
|
+
|
|
67
|
+
@field_validator('template')
|
|
68
|
+
@classmethod
|
|
69
|
+
def validate_template(cls, v: str) -> str:
|
|
70
|
+
"""Ensure template contains at least one variable placeholder."""
|
|
71
|
+
if '{' not in v or '}' not in v:
|
|
72
|
+
raise ValueError(
|
|
73
|
+
f"Channel template must contain variables like {{bot_id}}: {v}"
|
|
74
|
+
)
|
|
75
|
+
return v
|
|
76
|
+
|
|
77
|
+
model_config = {
|
|
78
|
+
'arbitrary_types_allowed': True, # Allow Callable types
|
|
79
|
+
'extra': 'forbid', # Strict validation
|
|
80
|
+
}
|
|
81
|
+
|
|
82
|
+
|
|
83
|
+
class CentrifugoChannels(BaseModel):
|
|
84
|
+
"""
|
|
85
|
+
Base configuration model for Centrifugo channel mappings.
|
|
86
|
+
|
|
87
|
+
Inherit from this class to define your channel mappings:
|
|
88
|
+
|
|
89
|
+
Example:
|
|
90
|
+
```python
|
|
91
|
+
class BotChannels(CentrifugoChannels):
|
|
92
|
+
heartbeat: ChannelConfig = ChannelConfig(
|
|
93
|
+
template='bot#{bot_id}#heartbeat',
|
|
94
|
+
rate_limit=0.1
|
|
95
|
+
)
|
|
96
|
+
|
|
97
|
+
status: ChannelConfig = ChannelConfig(
|
|
98
|
+
template='bot#{bot_id}#status',
|
|
99
|
+
critical=True
|
|
100
|
+
)
|
|
101
|
+
|
|
102
|
+
class BotStreamingService(Servicer, CentrifugoBridgeMixin):
|
|
103
|
+
centrifugo_channels = BotChannels()
|
|
104
|
+
```
|
|
105
|
+
|
|
106
|
+
Attributes:
|
|
107
|
+
enabled: Enable/disable entire Centrifugo bridge
|
|
108
|
+
default_rate_limit: Default rate limit for all channels
|
|
109
|
+
graceful_degradation: Continue if Centrifugo unavailable
|
|
110
|
+
"""
|
|
111
|
+
|
|
112
|
+
enabled: bool = Field(
|
|
113
|
+
True,
|
|
114
|
+
description="Enable/disable entire Centrifugo bridge"
|
|
115
|
+
)
|
|
116
|
+
|
|
117
|
+
default_rate_limit: Optional[float] = Field(
|
|
118
|
+
None,
|
|
119
|
+
description="Default rate limit for all channels (can be overridden per channel)",
|
|
120
|
+
ge=0.0
|
|
121
|
+
)
|
|
122
|
+
|
|
123
|
+
graceful_degradation: bool = Field(
|
|
124
|
+
True,
|
|
125
|
+
description="Continue service operation if Centrifugo is unavailable"
|
|
126
|
+
)
|
|
127
|
+
|
|
128
|
+
def get_channel_mappings(self) -> Dict[str, ChannelConfig]:
|
|
129
|
+
"""
|
|
130
|
+
Extract all ChannelConfig fields as dictionary.
|
|
131
|
+
|
|
132
|
+
Returns:
|
|
133
|
+
Dict mapping field names to ChannelConfig instances
|
|
134
|
+
|
|
135
|
+
Example:
|
|
136
|
+
```python
|
|
137
|
+
channels = BotChannels()
|
|
138
|
+
mappings = channels.get_channel_mappings()
|
|
139
|
+
# {'heartbeat': ChannelConfig(...), 'status': ChannelConfig(...)}
|
|
140
|
+
```
|
|
141
|
+
"""
|
|
142
|
+
mappings = {}
|
|
143
|
+
|
|
144
|
+
for field_name, field_info in self.model_fields.items():
|
|
145
|
+
# Skip base config fields
|
|
146
|
+
if field_name in ('enabled', 'default_rate_limit', 'graceful_degradation'):
|
|
147
|
+
continue
|
|
148
|
+
|
|
149
|
+
# Get field value
|
|
150
|
+
field_value = getattr(self, field_name, None)
|
|
151
|
+
|
|
152
|
+
# Check if it's a ChannelConfig
|
|
153
|
+
if isinstance(field_value, ChannelConfig):
|
|
154
|
+
mappings[field_name] = field_value
|
|
155
|
+
|
|
156
|
+
return mappings
|
|
157
|
+
|
|
158
|
+
model_config = {
|
|
159
|
+
'extra': 'allow', # Allow additional ChannelConfig fields
|
|
160
|
+
'arbitrary_types_allowed': True,
|
|
161
|
+
}
|
|
162
|
+
|
|
163
|
+
|
|
164
|
+
__all__ = [
|
|
165
|
+
"ChannelConfig",
|
|
166
|
+
"CentrifugoChannels",
|
|
167
|
+
]
|