dea1f89904
## Summary - Inject non-secret application variables (`isSecret: false`) into front component `process.env` via the existing Web Worker `setWorkerEnv` mechanism - Filter secret variables server-side in the resolver so they never reach the browser - Set application variables before system variables (`TWENTY_API_URL`, `TWENTY_APP_ACCESS_TOKEN`) to prevent override - Wire up environment variable keys in the logic function code editor for TypeScript autocomplete ## Test plan - [x] Unit tests for `buildNonSecretEnvVar` (6 passing) - [x] Typecheck passes for `twenty-front` and `twenty-server` - [x] Install an app with both `isSecret: false` and `isSecret: true` variables, open a front component, verify only non-secret vars appear in `process.env` - [x] Open a logic function editor, verify autocomplete suggests declared variable keys
21 lines
605 B
TypeScript
21 lines
605 B
TypeScript
import { type FlatApplicationVariable } from 'src/engine/metadata-modules/flat-application-variable/types/flat-application-variable.type';
|
|
|
|
export const stripSecretFromApplicationVariables = (
|
|
flatApplicationVariables: FlatApplicationVariable[],
|
|
): Record<string, string> => {
|
|
return flatApplicationVariables.reduce<Record<string, string>>(
|
|
(acc, flatApplicationVariable) => {
|
|
if (flatApplicationVariable.isSecret) {
|
|
return acc;
|
|
}
|
|
|
|
acc[flatApplicationVariable.key] = String(
|
|
flatApplicationVariable.value ?? '',
|
|
);
|
|
|
|
return acc;
|
|
},
|
|
{},
|
|
);
|
|
};
|