feat(applications): add type and options to application variables (#22157)

## Before
<img width="1452" height="709" alt="image"
src="https://github.com/user-attachments/assets/cd384ffa-cbe6-49d5-a807-ca8d580f55a9"
/>

<img width="1074" height="452" alt="image"
src="https://github.com/user-attachments/assets/720d38db-3495-4032-8831-17d24ec6a7e7"
/>

## After

<img width="1421" height="865" alt="image"
src="https://github.com/user-attachments/assets/2275c996-c895-4800-8324-2aa2ddfddd43"
/>

<img width="1348" height="870" alt="image"
src="https://github.com/user-attachments/assets/3e1a891d-6db0-4cbd-870a-2a5bbde4929d"
/>


## Summary

Adds typed application variables with optional select **options**. This
is the other half of #22059, split out from the custom-settings-tab
removal.

## Changes

- **Shared types**: `ApplicationVariable` / `ServerVariables` gain an
optional `type` (a `FieldMetadataType` subset — `TEXT`, `BOOLEAN`,
`NUMBER`, `DATE`, `SELECT`, `MULTI_SELECT`, `RAW_JSON`, `RICH_TEXT`,
`ARRAY`, …) and select `options`. New
`serializeApplicationVariableValue` /
`deserializeApplicationVariableValue` helpers convert typed values
to/from the encrypted string storage.
- **Server**: `type`/`options` columns on `applicationVariable` and
`applicationRegistrationVariable` (entities + DTOs), a fast `2-17`
instance command, manifest processing via the serialization helpers, and
a `QueryDeepPartialEntity` cast where the manifest JSON column is
persisted.
- **Frontend**: a polymorphic `SettingsApplicationVariableInput` that
renders the native `Form*` field component for each type (boolean,
number, date/date-time, select, multi-select, array, raw JSON, rich
text, text); fragment/query updates to fetch `type`/`options`.
- **SDK**: `defineApplication` validates that `SELECT`/`MULTI_SELECT`
variables declare non-empty `options` at build time (since `options` is
kept structurally optional for TypeORM/SDK compatibility).

Variables default to `TEXT` when no type is given, so existing manifests
are unaffected.

## Notes

The generated GraphQL artifacts (`type`/`options` on the variable types)
are regenerated by codegen; that change accompanies this PR.

https://claude.ai/code/session_013Z7UB35V2mvUozh55QHG23

---
_Generated by [Claude
Code](https://claude.ai/code/session_013Z7UB35V2mvUozh55QHG23)_

<!-- This is an auto-generated description by cubic. -->
<a
href="https://cubic.dev/pr/twentyhq/twenty/pull/22157?utm_source=github"
target="_blank" rel="noopener noreferrer"
data-no-image-dialog="true"><picture><source
media="(prefers-color-scheme: dark)"
srcset="https://www.cubic.dev/buttons/review-in-cubic-dark.svg"><source
media="(prefers-color-scheme: light)"
srcset="https://www.cubic.dev/buttons/review-in-cubic-light.svg"><img
alt="Review in cubic"
src="https://www.cubic.dev/buttons/review-in-cubic-dark.svg"></picture></a>
<!-- End of auto-generated description by cubic. -->
This commit is contained in:
martmull
2026-07-03 10:52:22 +02:00
committed by GitHub
parent 90f35658c5
commit 25fe66565c
42 changed files with 1318 additions and 594 deletions
@@ -1,3 +1,5 @@
import { FieldMetadataType } from 'twenty-shared/types';
import { type EncryptedString } from 'src/engine/core-modules/secret-encryption/branded-strings/encrypted-string.type';
import { buildEnvVar } from 'src/engine/core-modules/logic-function/logic-function-executor/utils/build-env-var';
import { type SecretEncryptionService } from 'src/engine/core-modules/secret-encryption/secret-encryption.service';
@@ -37,6 +39,8 @@ describe('buildEnvVar', () => {
`enc:v2:deadbeef:https://example.com|${workspaceA}` as EncryptedString,
description: 'Public URL',
isSecret: false,
type: FieldMetadataType.TEXT,
options: null,
applicationId: 'app-1',
workspaceId: workspaceA,
universalIdentifier: '00000000-0000-0000-0000-000000000000',
@@ -50,6 +54,8 @@ describe('buildEnvVar', () => {
value: `enc:v2:deadbeef:secret-123|${workspaceA}` as EncryptedString,
description: 'API secret',
isSecret: true,
type: FieldMetadataType.TEXT,
options: null,
applicationId: 'app-1',
workspaceId: workspaceA,
universalIdentifier: '00000000-0000-0000-0000-000000000000',
@@ -63,6 +69,8 @@ describe('buildEnvVar', () => {
value: `enc:v2:deadbeef:true|${workspaceA}` as EncryptedString,
description: 'Debug flag',
isSecret: false,
type: FieldMetadataType.TEXT,
options: null,
applicationId: 'app-1',
workspaceId: workspaceA,
universalIdentifier: '00000000-0000-0000-0000-000000000000',
@@ -92,6 +100,8 @@ describe('buildEnvVar', () => {
value: `enc:v2:deadbeef:value-a|${workspaceA}` as EncryptedString,
description: '',
isSecret: true,
type: FieldMetadataType.TEXT,
options: null,
applicationId: 'app-1',
workspaceId: workspaceA,
universalIdentifier: '00000000-0000-0000-0000-000000000000',
@@ -105,6 +115,8 @@ describe('buildEnvVar', () => {
value: `enc:v2:deadbeef:value-b|${workspaceB}` as EncryptedString,
description: '',
isSecret: true,
type: FieldMetadataType.TEXT,
options: null,
applicationId: 'app-1',
workspaceId: workspaceB,
universalIdentifier: '00000000-0000-0000-0000-000000000000',
@@ -136,6 +148,8 @@ describe('buildEnvVar', () => {
value: null as unknown as EncryptedString | '',
description: '',
isSecret: false,
type: FieldMetadataType.TEXT,
options: null,
applicationId: 'app-1',
workspaceId: workspaceA,
universalIdentifier: '00000000-0000-0000-0000-000000000000',
@@ -149,6 +163,8 @@ describe('buildEnvVar', () => {
value: undefined as unknown as EncryptedString | '',
description: '',
isSecret: false,
type: FieldMetadataType.TEXT,
options: null,
applicationId: 'app-1',
workspaceId: workspaceA,
universalIdentifier: '00000000-0000-0000-0000-000000000000',
@@ -174,6 +190,8 @@ describe('buildEnvVar', () => {
value: 123 as unknown as EncryptedString | '',
description: '',
isSecret: false,
type: FieldMetadataType.TEXT,
options: null,
applicationId: 'app-1',
workspaceId: workspaceA,
universalIdentifier: '00000000-0000-0000-0000-000000000000',