Skip to content

Commit 7f0747b

Browse files
committed
fix(case-interceptor): exempt /system/event responses from snake→camel
Event names are response keys ("test_underscore._schema") and the backend matches scripts by the exact string. Transforming to camelCase in the UI broke the Script Type dropdown and would corrupt the saved script name for any service with an underscore. Exempt /system/event the same way /api_docs is exempted. Also drops the per-component snakeToCamelString workaround in df-script-details now that the response keys are raw again.
1 parent b9b828c commit 7f0747b

7 files changed

Lines changed: 17 additions & 16 deletions

File tree

Lines changed: 1 addition & 1 deletion
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

dist/index.html

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -10,5 +10,5 @@
1010
<body class="mat-typography">
1111
<df-root></df-root>
1212
<script type="text/javascript" src="https://assets.calendly.com/assets/external/widget.js"></script>
13-
<script src="runtime.a9db062fdf3cfd21.js" type="module"></script><script src="polyfills.cb64ea9d35bc0a9e.js" type="module"></script><script src="main.c130ec302a7a706b.js" type="module"></script></body>
13+
<script src="runtime.effd0a441ec6f24f.js" type="module"></script><script src="polyfills.cb64ea9d35bc0a9e.js" type="module"></script><script src="main.07d233d5ef7e8fbd.js" type="module"></script></body>
1414
</html>

dist/main.07d233d5ef7e8fbd.js

Lines changed: 1 addition & 0 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

dist/main.c130ec302a7a706b.js

Lines changed: 0 additions & 1 deletion
This file was deleted.
Lines changed: 1 addition & 1 deletion
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

src/app/adf-event-scripts/df-script-details/df-script-details.component.ts

Lines changed: 4 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -32,10 +32,7 @@ import { ScriptEventResponse } from 'src/app/shared/types/scripts';
3232
import { CommonModule } from '@angular/common';
3333
import { DfThemeService } from 'src/app/shared/services/df-theme.service';
3434
import { DfLinkServiceComponent } from 'src/app/shared/components/df-link-service/df-link-service.component';
35-
import {
36-
camelToSnakeString,
37-
snakeToCamelString,
38-
} from 'src/app/shared/utilities/case';
35+
import { camelToSnakeString } from 'src/app/shared/utilities/case';
3936

4037
@UntilDestroy({ checkProperties: true })
4138
@Component({
@@ -209,12 +206,9 @@ export class DfScriptDetailsComponent implements OnInit {
209206
.subscribe(response => {
210207
this.unGroupedEvents = response;
211208
this.scriptEvents = groupEvents(response);
212-
// The response interceptor converts snake_case keys to camelCase, so
213-
// any service whose name has an underscore (api_docs, triskele_db,
214-
// local_file, etc.) needs the same transform applied to the lookup
215-
// key — not just the previously hard-coded api_docs case.
216-
const serviceKey = snakeToCamelString(serviceName);
217-
this.ungroupedEventOptions = response[serviceKey] as ScriptEvent;
209+
// /system/event responses are now exempt from the case interceptor
210+
// (see case.interceptor.ts) so keys match the service name verbatim.
211+
this.ungroupedEventOptions = response[serviceName] as ScriptEvent;
218212
if (this.ungroupedEventOptions) {
219213
Object.keys(this.ungroupedEventOptions).forEach(key => {
220214
this.ungroupedEventItems.push(key);

src/app/shared/interceptors/case.interceptor.ts

Lines changed: 9 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -18,6 +18,14 @@ export const caseInterceptor: HttpInterceptorFn = (
1818
// property names that must not be transformed or Swagger UI won't parse them correctly
1919
const isApiDocsRequest = req.url.includes('/api_docs');
2020

21+
// Skip case transformation for /system/event responses. The response keys are
22+
// event names (e.g. "test_underscore._schema") that the backend uses verbatim
23+
// when matching scripts — transforming them to camelCase makes the UI show
24+
// bogus names and the script lookup drift from what the backend expects.
25+
const isSystemEventRequest = /\/system\/event(\?|$|\/)/.test(req.url);
26+
27+
const skipResponseTransform = isApiDocsRequest || isSystemEventRequest;
28+
2129
if (req.url.startsWith('/api') && !(req.body instanceof FormData)) {
2230
const transformedRequest = req.clone({
2331
body: isApiDocsRequest ? req.body : mapCamelToSnake(req.body),
@@ -28,8 +36,7 @@ export const caseInterceptor: HttpInterceptorFn = (
2836
event instanceof HttpResponse &&
2937
event.headers.get('Content-Type')?.includes('application/json')
3038
) {
31-
// Don't transform API docs responses - they need their original OpenAPI format
32-
if (isApiDocsRequest) {
39+
if (skipResponseTransform) {
3340
return event;
3441
}
3542
return event.clone({ body: mapSnakeToCamel(event.body) });

0 commit comments

Comments
 (0)