jac-scale 0.1.3__py3-none-any.whl → 0.1.4__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.
- jac_scale/config_loader.jac +2 -1
- jac_scale/impl/config_loader.impl.jac +28 -3
- jac_scale/impl/context.impl.jac +1 -3
- jac_scale/impl/serve.impl.jac +667 -32
- jac_scale/impl/webhook.impl.jac +212 -0
- jac_scale/jserver/impl/jfast_api.impl.jac +4 -0
- jac_scale/plugin_config.jac +1 -1
- jac_scale/serve.jac +30 -4
- jac_scale/tests/fixtures/test_api.jac +60 -0
- jac_scale/tests/fixtures/test_restspec.jac +51 -0
- jac_scale/tests/test_restspec.py +97 -0
- jac_scale/tests/test_serve.py +357 -4
- jac_scale/webhook.jac +93 -0
- {jac_scale-0.1.3.dist-info → jac_scale-0.1.4.dist-info}/METADATA +4 -4
- {jac_scale-0.1.3.dist-info → jac_scale-0.1.4.dist-info}/RECORD +18 -16
- {jac_scale-0.1.3.dist-info → jac_scale-0.1.4.dist-info}/WHEEL +0 -0
- {jac_scale-0.1.3.dist-info → jac_scale-0.1.4.dist-info}/entry_points.txt +0 -0
- {jac_scale-0.1.3.dist-info → jac_scale-0.1.4.dist-info}/top_level.txt +0 -0
jac_scale/config_loader.jac
CHANGED
|
@@ -12,7 +12,7 @@ import os;
|
|
|
12
12
|
|
|
13
13
|
"""Scale-specific configuration loader.
|
|
14
14
|
|
|
15
|
-
Provides access to jwt, sso, database, kubernetes, and
|
|
15
|
+
Provides access to jwt, sso, database, kubernetes, server and webhook configuration
|
|
16
16
|
from the [plugins.scale] section of jac.toml.
|
|
17
17
|
"""
|
|
18
18
|
class JacScaleConfig(PluginConfigBase) {
|
|
@@ -23,6 +23,7 @@ class JacScaleConfig(PluginConfigBase) {
|
|
|
23
23
|
def get_database_config(self: JacScaleConfig) -> dict[str, Any];
|
|
24
24
|
def get_kubernetes_config(self: JacScaleConfig) -> dict[str, Any];
|
|
25
25
|
def get_server_config(self: JacScaleConfig) -> dict[str, Any];
|
|
26
|
+
def get_webhook_config(self: JacScaleConfig) -> dict[str, Any];
|
|
26
27
|
}
|
|
27
28
|
|
|
28
29
|
glob _scale_config_instance: JacScaleConfig | None = None;
|
|
@@ -18,7 +18,11 @@ impl JacScaleConfig.get_plugin_name(self: JacScaleConfig) -> str {
|
|
|
18
18
|
"""Get default configuration structure for scale."""
|
|
19
19
|
impl JacScaleConfig.get_default_config(self: JacScaleConfig) -> dict[str, Any] {
|
|
20
20
|
return {
|
|
21
|
-
'jwt': {
|
|
21
|
+
'jwt': {
|
|
22
|
+
'secret': 'supersecretkey_for_testing_only!',
|
|
23
|
+
'algorithm': 'HS256',
|
|
24
|
+
'exp_delta_days': 7
|
|
25
|
+
},
|
|
22
26
|
'sso': {
|
|
23
27
|
'host': 'http://localhost:8000/sso',
|
|
24
28
|
'google': {'client_id': '', 'client_secret': ''}
|
|
@@ -50,7 +54,13 @@ impl JacScaleConfig.get_default_config(self: JacScaleConfig) -> dict[str, Any] {
|
|
|
50
54
|
'liveness_period': 20,
|
|
51
55
|
'liveness_failure_threshold': 80
|
|
52
56
|
},
|
|
53
|
-
'server': {'port': 8000, 'host': '0.0.0.0'}
|
|
57
|
+
'server': {'port': 8000, 'host': '0.0.0.0'},
|
|
58
|
+
'webhook': {
|
|
59
|
+
'secret': 'webhook-secret-key',
|
|
60
|
+
'signature_header': 'X-Webhook-Signature',
|
|
61
|
+
'verify_signature': True,
|
|
62
|
+
'api_key_expiry_days': 365
|
|
63
|
+
}
|
|
54
64
|
};
|
|
55
65
|
}
|
|
56
66
|
|
|
@@ -59,7 +69,7 @@ impl JacScaleConfig.get_jwt_config(self: JacScaleConfig) -> dict[str, Any] {
|
|
|
59
69
|
config = self.load();
|
|
60
70
|
jwt_config = config.get('jwt', {});
|
|
61
71
|
return {
|
|
62
|
-
'secret': jwt_config.get('secret', '
|
|
72
|
+
'secret': jwt_config.get('secret', 'supersecretkey_for_testing_only!'),
|
|
63
73
|
'algorithm': jwt_config.get('algorithm', 'HS256'),
|
|
64
74
|
'exp_delta_days': int(jwt_config.get('exp_delta_days', 7))
|
|
65
75
|
};
|
|
@@ -115,6 +125,21 @@ impl JacScaleConfig.get_server_config(self: JacScaleConfig) -> dict[str, Any] {
|
|
|
115
125
|
};
|
|
116
126
|
}
|
|
117
127
|
|
|
128
|
+
"""Get webhook configuration from jac.toml."""
|
|
129
|
+
impl JacScaleConfig.get_webhook_config(self: JacScaleConfig) -> dict[str, Any] {
|
|
130
|
+
config = self.load();
|
|
131
|
+
webhook_config = config.get('webhook', {});
|
|
132
|
+
return {
|
|
133
|
+
'secret': os.environ.get('WEBHOOK_SECRET')
|
|
134
|
+
or webhook_config.get('secret', 'webhook-secret-key'),
|
|
135
|
+
'signature_header': webhook_config.get(
|
|
136
|
+
'signature_header', 'X-Webhook-Signature'
|
|
137
|
+
),
|
|
138
|
+
'verify_signature': webhook_config.get('verify_signature', True),
|
|
139
|
+
'api_key_expiry_days': int(webhook_config.get('api_key_expiry_days', 365))
|
|
140
|
+
};
|
|
141
|
+
}
|
|
142
|
+
|
|
118
143
|
"""Get or create the global JacScaleConfig instance."""
|
|
119
144
|
impl get_scale_config(project_dir: Path | None = None) -> JacScaleConfig {
|
|
120
145
|
global _scale_config_instance;
|
jac_scale/impl/context.impl.jac
CHANGED
|
@@ -21,7 +21,5 @@ impl JScaleExecutionContext.init(self: JScaleExecutionContext) -> None {
|
|
|
21
21
|
# Default user_root and entry_node to system_root
|
|
22
22
|
self.user_root = self.system_root;
|
|
23
23
|
self.entry_node = self.system_root;
|
|
24
|
-
self.call_state: ContextVar[CallState] = ContextVar(
|
|
25
|
-
'call_state', default=CallState()
|
|
26
|
-
);
|
|
24
|
+
self.call_state: ContextVar[CallState] = ContextVar('call_state');
|
|
27
25
|
}
|