i18n - docs translations (#22511)
Created by Github action <!-- This is an auto-generated description by cubic. --> <a href="https://cubic.dev/pr/twentyhq/twenty/pull/22511?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. --> Co-authored-by: github-actions <github-actions@twenty.com>
This commit is contained in:
committed by
GitHub
parent
1db9b0c657
commit
b7fc0872c8
@@ -36,6 +36,60 @@ export default defineApplication({
|
||||
* يتم اكتشاف الدور الافتراضي تلقائيًا من ملف الدور المميز بـ [`defineApplicationRole()`](/l/ar/developers/extend/apps/config/roles) — لست بحاجة إلى الإشارة إليه من `defineApplication()`.
|
||||
* يتم اكتشاف دوال ما قبل التثبيت وما بعده تلقائيًا أثناء بناء البيان — لا حاجة للإشارة إليها في `defineApplication()`.
|
||||
* لا يزال تمرير `defaultRoleUniversalIdentifier` بشكل صريح مدعومًا من أجل التوافق مع الإصدارات السابقة، ولكنه مُهمل لصالح `defineApplicationRole()`.
|
||||
* `serverVariables` هي تكوينات وأسرار بنطاق المثيل (مثل مفاتيح واجهة برمجة التطبيقات). على عكس `applicationVariables`، فهي لا تصرح عن أي قيمة في ملف manifest — حيث يقوم مشغّل مساحة العمل بملئها من إعدادات التطبيق، ويتم حقنها في دوال المنطق فقط بعد تعيينها.
|
||||
|
||||
## أنواع المتغيرات
|
||||
|
||||
كل من `applicationVariables` و`serverVariables` يقبلان حقل `type` اختياريًا (ولـ `SELECT` / `MULTI_SELECT`، قائمة `options`). الأنواع المدعومة: `TEXT` (افتراضي)، `BOOLEAN`، `NUMBER`، `NUMERIC`، `DATE`، `DATE_TIME`، `SELECT`، `MULTI_SELECT`، `ARRAY`، `RAW_JSON`، `RICH_TEXT`.
|
||||
|
||||
```ts src/application-config.ts
|
||||
import { defineApplication, FieldType } from 'twenty-sdk/define';
|
||||
|
||||
export default defineApplication({
|
||||
// ...identity, role...
|
||||
applicationVariables: {
|
||||
MAX_POSTCARDS: {
|
||||
universalIdentifier: '5f4497e4-9030-4085-85eb-2c48b8d53713',
|
||||
description: 'Maximum postcards per batch',
|
||||
type: FieldType.NUMBER,
|
||||
value: 10,
|
||||
},
|
||||
DEFAULT_REGION: {
|
||||
universalIdentifier: '76c5c321-b6b6-46eb-b4fc-f9f04bb04227',
|
||||
description: 'Default shipping region',
|
||||
type: FieldType.SELECT,
|
||||
options: [
|
||||
{ label: 'Europe', value: 'eu' },
|
||||
{ label: 'United States', value: 'us' },
|
||||
],
|
||||
value: 'eu',
|
||||
},
|
||||
},
|
||||
});
|
||||
```
|
||||
|
||||
إن `type` يؤثر فقط على **العرض والتحقق** — حيث يختار حقل الإدخال المطابق في واجهة إعدادات مساحة العمل (زر تبديل، حقل أرقام، قائمة منسدلة، منتقي تاريخ، محرر JSON، …) ويسمح لعملية البناء بالتحقق من صحة إعداداتك (على سبيل المثال، يجب أن يعلن `SELECT` / `MULTI_SELECT` عن `options` غير فارغة). وهو **لا** يغيّر كيفية وصول القيمة إلى الشيفرة الخاصة بك.
|
||||
|
||||
تُحَقَن القيم **دائمًا كسلاسل نصية** — فهذا جزء جوهري من متغيرات البيئة (`process.env.*` نصية فقط). عند تشغيل دالة المنطق الخاصة بك، يقوم المنفّذ بتسلسل كل قيمة وفقًا لـ `type` المعلن أثناء بناء `process.env`، بحيث يكون تنسيق السلسلة النصية متّسقًا بغض النظر عن كيفية تعيين القيمة (قيمة افتراضية في manifest، من واجهة الإعدادات، أو من إصدار سابق):
|
||||
|
||||
| النوع | سلسلة نصية في `process.env` |
|
||||
| ------------------------------------- | -------------------------------------- |
|
||||
| `TEXT`، `SELECT`، `DATE`، `DATE_TIME` | القيمة الخام (`"eu"`، `"2026-01-01"`) |
|
||||
| `BOOLEAN` | `"true"` / `"false"` |
|
||||
| `NUMBER`، `NUMERIC` | سلسلة عشرية (`"10"`، `"2.5"`) |
|
||||
| `MULTI_SELECT`، `ARRAY` | مصفوفة JSON (`'["email","postcard"]'`) |
|
||||
| `RAW_JSON`، `RICH_TEXT` | كائن JSON (`'{"retries":3}'`) |
|
||||
|
||||
حوّل السلسلة النصية مرة أخرى إلى النوع الذي تتوقعه:
|
||||
|
||||
```ts
|
||||
const maxCards = Number(process.env.MAX_POSTCARDS); // "10" -> 10
|
||||
const enabled = process.env.ENABLE_TRACKING === 'true'; // "true" -> true
|
||||
const channels = JSON.parse(process.env.ENABLED_CHANNELS ?? '[]'); // '["email"]' -> ["email"]
|
||||
const config = JSON.parse(process.env.PROVIDER_CONFIG ?? '{}'); // '{"retries":3}' -> { retries: 3 }
|
||||
```
|
||||
|
||||
ينطبق الأمر نفسه على مكوّنات الواجهة الأمامية التي تقرأ القيم عبر `getApplicationVariable('VARIABLE_NAME')` — فالقيمة المعادة هي سلسلة نصية؛ قم بتحليلها حسب الحاجة.
|
||||
|
||||
## الدور الافتراضي للوظيفة
|
||||
|
||||
|
||||
@@ -377,6 +377,8 @@ export default defineFrontComponent({
|
||||
المتغيرات السرّية (`isSecret: true`) **لا** يتم كشفها لمكوّنات الواجهة. هي متاحة فقط في [دوال المنطق](/l/ar/developers/extend/apps/logic/logic-functions)، التي تعمل على جهة الخادم. هذا يمنع إرسال القيم الحساسة مثل مفاتيح API إلى المتصفح.
|
||||
</Warning>
|
||||
|
||||
تُرجِع الدالة `getApplicationVariable` دائمًا **سلسلة نصية** (أو `undefined`)، بغضّ النظر عن `type` المُعلَن للمتغيّر. تُسلسَل السلسلة النصية بشكل متسق حسب النوع (القيم المنطقية على هيئة "true" / "false"، الأعداد كسلاسل عشرية، والمصفوفات/الكائنات كـ JSON)، وهو نفس التنسيق المستخدم مع `process.env` في وظائف المنطق — قم بتحليلها بنفسك (`Number(...)`، `JSON.parse(...)`، `=== 'true'`). انظر قسم [أنواع المتغيرات](/l/ar/developers/extend/apps/config/application#variable-types).
|
||||
|
||||
متغيرات النظام التالية تكون متاحة دائمًا عبر `process.env`:
|
||||
|
||||
| المتغيّر | الوصف |
|
||||
|
||||
@@ -36,6 +36,60 @@ Poznámky:
|
||||
* Výchozí role je automaticky detekována ze souboru role označeného pomocí [`defineApplicationRole()`](/l/cs/developers/extend/apps/config/roles) — není potřeba na ni odkazovat z `defineApplication()`.
|
||||
* Předinstalační a postinstalační funkce jsou při sestavení manifestu detekovány automaticky — není třeba na ně odkazovat v `defineApplication()`.
|
||||
* Předávání `defaultRoleUniversalIdentifier` explicitně je stále podporováno kvůli zpětné kompatibilitě, ale je zastaralé ve prospěch `defineApplicationRole()`.
|
||||
* `serverVariables` představují konfiguraci a tajné údaje vázané na instanci (např. klíče API). Na rozdíl od `applicationVariables` neuvádějí v manifestu žádnou hodnotu — operátor pracovního prostoru je vyplní v nastavení aplikace a do logických funkcí jsou injektovány až poté, co jsou nastaveny.
|
||||
|
||||
## Typy proměnných
|
||||
|
||||
Jak `applicationVariables`, tak `serverVariables` přijímají volitelný `type` (a pro `SELECT` / `MULTI_SELECT` i seznam `options`). Podporované typy: `TEXT` (výchozí), `BOOLEAN`, `NUMBER`, `NUMERIC`, `DATE`, `DATE_TIME`, `SELECT`, `MULTI_SELECT`, `ARRAY`, `RAW_JSON`, `RICH_TEXT`.
|
||||
|
||||
```ts src/application-config.ts
|
||||
import { defineApplication, FieldType } from 'twenty-sdk/define';
|
||||
|
||||
export default defineApplication({
|
||||
// ...identity, role...
|
||||
applicationVariables: {
|
||||
MAX_POSTCARDS: {
|
||||
universalIdentifier: '5f4497e4-9030-4085-85eb-2c48b8d53713',
|
||||
description: 'Maximum postcards per batch',
|
||||
type: FieldType.NUMBER,
|
||||
value: 10,
|
||||
},
|
||||
DEFAULT_REGION: {
|
||||
universalIdentifier: '76c5c321-b6b6-46eb-b4fc-f9f04bb04227',
|
||||
description: 'Default shipping region',
|
||||
type: FieldType.SELECT,
|
||||
options: [
|
||||
{ label: 'Europe', value: 'eu' },
|
||||
{ label: 'United States', value: 'us' },
|
||||
],
|
||||
value: 'eu',
|
||||
},
|
||||
},
|
||||
});
|
||||
```
|
||||
|
||||
`type` ovlivňuje pouze **prezentaci a validaci** — v uživatelském rozhraní nastavení pracovního prostoru vybere odpovídající vstup (přepínač, číselné pole, rozbalovací seznam, výběr data, editor JSON, …) a umožní sestavení ověřit vaši konfiguraci (například `SELECT` / `MULTI_SELECT` musí deklarovat neprázdné `options`). Nijak **nemění** způsob, jakým se hodnota dostane do vašeho kódu.
|
||||
|
||||
Hodnoty jsou **vždy předávány jako řetězce** — je to dáno povahou proměnných prostředí (`process.env.*` obsahuje pouze řetězce). Když se spustí vaše logická funkce, executor serializuje každou hodnotu podle jejího deklarovaného `type` při sestavování `process.env`, takže formát řetězce je konzistentní bez ohledu na to, jak byla hodnota nastavena (výchozí hodnota v manifestu, v uživatelském rozhraní nastavení nebo v předchozí verzi):
|
||||
|
||||
| Typ | řetězec `process.env` |
|
||||
| ------------------------------------- | --------------------------------------- |
|
||||
| `TEXT`, `SELECT`, `DATE`, `DATE_TIME` | surová hodnota (`"eu"`, `"2026-01-01"`) |
|
||||
| `BOOLEAN` | `"true"` / `"false"` |
|
||||
| `NUMBER`, `NUMERIC` | desetinný řetězec (`"10"`, `"2.5"`) |
|
||||
| `MULTI_SELECT`, `ARRAY` | JSON pole (`'["email","postcard"]'`) |
|
||||
| `RAW_JSON`, `RICH_TEXT` | JSON objekt (`'{"retries":3}'`) |
|
||||
|
||||
Parsujte řetězec zpět do typu, který očekáváte:
|
||||
|
||||
```ts
|
||||
const maxCards = Number(process.env.MAX_POSTCARDS); // "10" -> 10
|
||||
const enabled = process.env.ENABLE_TRACKING === 'true'; // "true" -> true
|
||||
const channels = JSON.parse(process.env.ENABLED_CHANNELS ?? '[]'); // '["email"]' -> ["email"]
|
||||
const config = JSON.parse(process.env.PROVIDER_CONFIG ?? '{}'); // '{"retries":3}' -> { retries: 3 }
|
||||
```
|
||||
|
||||
Totéž platí pro frontendové komponenty, které čtou hodnoty pomocí `getApplicationVariable('VARIABLE_NAME')` — vrácená hodnota je řetězec; podle potřeby ji parsujte.
|
||||
|
||||
## Výchozí role funkce
|
||||
|
||||
|
||||
@@ -377,6 +377,8 @@ export default defineFrontComponent({
|
||||
Tajné proměnné (`isSecret: true`) **nejsou** zpřístupněny front-endovým komponentám. Jsou k dispozici pouze v [logických funkcích](/l/cs/developers/extend/apps/logic/logic-functions), které běží na straně serveru. Tím se zabrání odesílání citlivých hodnot, jako jsou API klíče, do prohlížeče.
|
||||
</Warning>
|
||||
|
||||
`getApplicationVariable` vždy vrací **string** (nebo `undefined`), bez ohledu na deklarovaný `type` proměnné. Řetězec je serializován konzistentně podle typu (logické hodnoty jako `"true"` / `"false"`, čísla jako desetinné řetězce, pole / objekty jako JSON), ve stejném formátu, jaký používá `process.env` v logických funkcích — zpracujte jej sami (`Number(...)`, `JSON.parse(...)`, `=== 'true'`). Viz [Typy proměnných](/l/cs/developers/extend/apps/config/application#variable-types).
|
||||
|
||||
Následující systémové proměnné jsou vždy dostupné přes `process.env`:
|
||||
|
||||
| Proměnná | Popis |
|
||||
|
||||
@@ -36,6 +36,60 @@ Notizen:
|
||||
* Die Standardrolle wird automatisch aus der Rollen-Datei erkannt, die mit [`defineApplicationRole()`](/l/de/developers/extend/apps/config/roles) markiert ist – Sie müssen sie nicht aus `defineApplication()` referenzieren.
|
||||
* Pre- und Post-Installationsfunktionen werden während des Manifest-Builds automatisch erkannt — Sie müssen sie in `defineApplication()` nicht referenzieren.
|
||||
* Die explizite Übergabe von `defaultRoleUniversalIdentifier` wird für die Abwärtskompatibilität weiterhin unterstützt, ist jedoch zugunsten von `defineApplicationRole()` veraltet.
|
||||
* `serverVariables` sind instanzbezogene Konfigurationen und Geheimnisse (z. B. API-Schlüssel). Im Gegensatz zu `applicationVariables` haben sie im Manifest keinen Wert definiert – die Workspace-Operatorin bzw. der Workspace-Operator trägt sie in den App-Einstellungen ein, und sie werden erst dann in Logikfunktionen eingespeist, wenn sie gesetzt sind.
|
||||
|
||||
## Variablentypen
|
||||
|
||||
Sowohl `applicationVariables` als auch `serverVariables` akzeptieren einen optionalen `type` (und für `SELECT` / `MULTI_SELECT` eine `options`-Liste). Unterstützte Typen: `TEXT` (Standard), `BOOLEAN`, `NUMBER`, `NUMERIC`, `DATE`, `DATE_TIME`, `SELECT`, `MULTI_SELECT`, `ARRAY`, `RAW_JSON`, `RICH_TEXT`.
|
||||
|
||||
```ts src/application-config.ts
|
||||
import { defineApplication, FieldType } from 'twenty-sdk/define';
|
||||
|
||||
export default defineApplication({
|
||||
// ...identity, role...
|
||||
applicationVariables: {
|
||||
MAX_POSTCARDS: {
|
||||
universalIdentifier: '5f4497e4-9030-4085-85eb-2c48b8d53713',
|
||||
description: 'Maximum postcards per batch',
|
||||
type: FieldType.NUMBER,
|
||||
value: 10,
|
||||
},
|
||||
DEFAULT_REGION: {
|
||||
universalIdentifier: '76c5c321-b6b6-46eb-b4fc-f9f04bb04227',
|
||||
description: 'Default shipping region',
|
||||
type: FieldType.SELECT,
|
||||
options: [
|
||||
{ label: 'Europe', value: 'eu' },
|
||||
{ label: 'United States', value: 'us' },
|
||||
],
|
||||
value: 'eu',
|
||||
},
|
||||
},
|
||||
});
|
||||
```
|
||||
|
||||
Der `type` beeinflusst nur die **Darstellung und Validierung** – er wählt das passende Eingabefeld in der UI der Arbeitsbereichseinstellungen aus (Schalter, Zahlenfeld, Dropdown, Datumsauswahl, JSON-Editor, …) und ermöglicht es dem Build, deine Konfiguration zu validieren (zum Beispiel müssen `SELECT` / `MULTI_SELECT` nicht-leere `options` deklarieren). Er ändert **nicht**, wie der Wert deinen Code erreicht.
|
||||
|
||||
Werte werden **immer als Strings bereitgestellt** – das ist inhärent bei Umgebungsvariablen (`process.env.*` enthält ausschließlich Strings). Wenn deine Logikfunktion ausgeführt wird, serialisiert der Executor jeden Wert anhand seines deklarierten `type` beim Aufbau von `process.env`, sodass das Stringformat konsistent ist, unabhängig davon, wie der Wert gesetzt wurde (Manifest-Standardwert, Einstellungs-UI oder eine vorherige Version):
|
||||
|
||||
| Typ | `process.env`-String |
|
||||
| ------------------------------------- | ------------------------------------- |
|
||||
| `TEXT`, `SELECT`, `DATE`, `DATE_TIME` | der Rohwert (`"eu"`, `"2026-01-01"`) |
|
||||
| `BOOLEAN` | `"true"` / `"false"` |
|
||||
| `NUMBER`, `NUMERIC` | Dezimal-String (`"10"`, `"2.5"`) |
|
||||
| `MULTI_SELECT`, `ARRAY` | JSON-Array (`'["email","postcard"]'`) |
|
||||
| `RAW_JSON`, `RICH_TEXT` | JSON-Objekt (`'{"retries":3}'`) |
|
||||
|
||||
Wandle den String zurück in den erwarteten Typ um:
|
||||
|
||||
```ts
|
||||
const maxCards = Number(process.env.MAX_POSTCARDS); // "10" -> 10
|
||||
const enabled = process.env.ENABLE_TRACKING === 'true'; // "true" -> true
|
||||
const channels = JSON.parse(process.env.ENABLED_CHANNELS ?? '[]'); // '["email"]' -> ["email"]
|
||||
const config = JSON.parse(process.env.PROVIDER_CONFIG ?? '{}'); // '{"retries":3}' -> { retries: 3 }
|
||||
```
|
||||
|
||||
Das Gleiche gilt für Frontend-Komponenten, die Werte über `getApplicationVariable('VARIABLE_NAME')` lesen – der zurückgegebene Wert ist ein String; wandle ihn bei Bedarf um.
|
||||
|
||||
## Standard-Funktionsrolle
|
||||
|
||||
|
||||
@@ -377,6 +377,8 @@ export default defineFrontComponent({
|
||||
Geheime Variablen (`isSecret: true`) werden **nicht** in Front-Komponenten offengelegt. Sie sind nur in [Logikfunktionen](/l/de/developers/extend/apps/logic/logic-functions) verfügbar, die serverseitig ausgeführt werden. Dadurch wird verhindert, dass sensible Werte wie API-Schlüssel an den Browser gesendet werden.
|
||||
</Warning>
|
||||
|
||||
`getApplicationVariable` gibt immer einen **String** (oder `undefined`) zurück, unabhängig vom deklarierten `type` der Variable. Der String wird je nach Typ konsistent serialisiert (boolesche Werte als `"true"` / `"false"`, Zahlen als Dezimalstrings, Arrays / Objekte als JSON), im selben Format, das für die Logikfunktion `process.env` verwendet wird — parsen Sie ihn selbst (`Number(...)`, `JSON.parse(...)`, `=== 'true'`). Siehe [Variablentypen](/l/de/developers/extend/apps/config/application#variable-types).
|
||||
|
||||
Die folgenden Systemvariablen sind immer über `process.env` verfügbar:
|
||||
|
||||
| Variable | Beschreibung |
|
||||
|
||||
@@ -36,6 +36,60 @@ Notas:
|
||||
* El rol predeterminado se detecta automáticamente a partir del archivo de rol marcado con [`defineApplicationRole()`](/l/es/developers/extend/apps/config/roles); no necesitas hacer referencia a él desde `defineApplication()`.
|
||||
* Las funciones de preinstalación y posinstalación se detectan automáticamente durante la compilación del manifiesto; no necesitas referenciarlas en `defineApplication()`.
|
||||
* Pasar `defaultRoleUniversalIdentifier` explícitamente sigue siendo compatible por motivos de retrocompatibilidad, pero está en desuso en favor de `defineApplicationRole()`.
|
||||
* `serverVariables` son configuraciones y secretos con ámbito de instancia (por ejemplo, claves de API). A diferencia de `applicationVariables`, no declaran ningún valor en el manifiesto: el operador del espacio de trabajo los completa desde la configuración de la aplicación, y se inyectan en las funciones lógicas solo una vez que se han establecido.
|
||||
|
||||
## Tipos de variables
|
||||
|
||||
Tanto `applicationVariables` como `serverVariables` aceptan un `type` opcional (y, para `SELECT` / `MULTI_SELECT`, una lista de `options`). Tipos admitidos: `TEXT` (predeterminado), `BOOLEAN`, `NUMBER`, `NUMERIC`, `DATE`, `DATE_TIME`, `SELECT`, `MULTI_SELECT`, `ARRAY`, `RAW_JSON`, `RICH_TEXT`.
|
||||
|
||||
```ts src/application-config.ts
|
||||
import { defineApplication, FieldType } from 'twenty-sdk/define';
|
||||
|
||||
export default defineApplication({
|
||||
// ...identity, role...
|
||||
applicationVariables: {
|
||||
MAX_POSTCARDS: {
|
||||
universalIdentifier: '5f4497e4-9030-4085-85eb-2c48b8d53713',
|
||||
description: 'Maximum postcards per batch',
|
||||
type: FieldType.NUMBER,
|
||||
value: 10,
|
||||
},
|
||||
DEFAULT_REGION: {
|
||||
universalIdentifier: '76c5c321-b6b6-46eb-b4fc-f9f04bb04227',
|
||||
description: 'Default shipping region',
|
||||
type: FieldType.SELECT,
|
||||
options: [
|
||||
{ label: 'Europe', value: 'eu' },
|
||||
{ label: 'United States', value: 'us' },
|
||||
],
|
||||
value: 'eu',
|
||||
},
|
||||
},
|
||||
});
|
||||
```
|
||||
|
||||
El `type` solo afecta a la **presentación y validación**: selecciona la entrada correspondiente en la interfaz de configuración del espacio de trabajo (un interruptor, campo numérico, lista desplegable, selector de fecha, editor JSON, …) y permite que la compilación valide tu configuración (por ejemplo, `SELECT` / `MULTI_SELECT` deben declarar `options` no vacías). **No** cambia cómo el valor llega a tu código.
|
||||
|
||||
Los valores **siempre se inyectan como cadenas**; esto es inherente a las variables de entorno (`process.env.*` solo admite cadenas). Cuando se ejecuta tu función lógica, el ejecutor serializa cada valor según su `type` declarado al construir `process.env`, por lo que el formato de cadena es coherente independientemente de cómo se haya establecido el valor (valor predeterminado del manifiesto, interfaz de configuración o una versión anterior):
|
||||
|
||||
| Tipo | Cadena de `process.env` |
|
||||
| ------------------------------------- | ---------------------------------------------- |
|
||||
| `TEXT`, `SELECT`, `DATE`, `DATE_TIME` | el valor sin procesar (`"eu"`, `"2026-01-01"`) |
|
||||
| `BOOLEAN` | `"true"` / `"false"` |
|
||||
| `NUMBER`, `NUMERIC` | cadena decimal (`"10"`, `"2.5"`) |
|
||||
| `MULTI_SELECT`, `ARRAY` | Array JSON (`'["email","postcard"]'`) |
|
||||
| `RAW_JSON`, `RICH_TEXT` | Objeto JSON (`'{"retries":3}'`) |
|
||||
|
||||
Analiza la cadena para volver al tipo que esperas:
|
||||
|
||||
```ts
|
||||
const maxCards = Number(process.env.MAX_POSTCARDS); // "10" -> 10
|
||||
const enabled = process.env.ENABLE_TRACKING === 'true'; // "true" -> true
|
||||
const channels = JSON.parse(process.env.ENABLED_CHANNELS ?? '[]'); // '["email"]' -> ["email"]
|
||||
const config = JSON.parse(process.env.PROVIDER_CONFIG ?? '{}'); // '{"retries":3}' -> { retries: 3 }
|
||||
```
|
||||
|
||||
Lo mismo se aplica a los componentes de interfaz que leen valores mediante `getApplicationVariable('VARIABLE_NAME')`: el valor devuelto es una cadena; analízalo según sea necesario.
|
||||
|
||||
## Rol de función predeterminado
|
||||
|
||||
|
||||
@@ -377,6 +377,8 @@ export default defineFrontComponent({
|
||||
Las variables secretas (`isSecret: true`) **no** se exponen a los componentes de front. Solo están disponibles en las [funciones de lógica](/l/es/developers/extend/apps/logic/logic-functions), que se ejecutan del lado del servidor. Esto evita que valores confidenciales como las claves de API se envíen al navegador.
|
||||
</Warning>
|
||||
|
||||
`getApplicationVariable` siempre devuelve una **cadena** (o `undefined`), independientemente del `type` declarado de la variable. La cadena se serializa de forma coherente según el tipo (booleanos como `"true"` / `"false"`, números como cadenas decimales, arrays / objetos como JSON), el mismo formato que se usa para la función lógica `process.env` — parsea tú mismo (`Number(...)`, `JSON.parse(...)`, `=== 'true'`). Consulta [Tipos de variables](/l/es/developers/extend/apps/config/application#variable-types).
|
||||
|
||||
Las siguientes variables de sistema siempre están disponibles a través de `process.env`:
|
||||
|
||||
| Variable | Descripción |
|
||||
|
||||
@@ -36,6 +36,60 @@ Notes :
|
||||
* Le rôle par défaut est détecté automatiquement à partir du fichier de rôle marqué avec [`defineApplicationRole()`](/l/fr/developers/extend/apps/config/roles) — vous n’avez pas besoin d’y faire référence depuis `defineApplication()`.
|
||||
* Les fonctions de pré-installation et de post-installation sont détectées automatiquement lors de la construction du manifeste — vous n'avez pas besoin de les référencer dans `defineApplication()`.
|
||||
* Le passage explicite de `defaultRoleUniversalIdentifier` est toujours pris en charge pour des raisons de rétrocompatibilité, mais il est obsolète au profit de `defineApplicationRole()`.
|
||||
* `serverVariables` sont des configurations et des secrets au niveau de l’instance (par exemple des clés d’API). Contrairement à `applicationVariables`, ils ne déclarent aucune valeur dans le manifeste — l’opérateur de l’espace de travail les renseigne dans les paramètres de l’application, et ils sont injectés dans les fonctions logiques uniquement une fois définis.
|
||||
|
||||
## Types de variables
|
||||
|
||||
`applicationVariables` et `serverVariables` acceptent tous deux un `type` optionnel (et, pour `SELECT` / `MULTI_SELECT`, une liste `options`). Types pris en charge : `TEXT` (par défaut), `BOOLEAN`, `NUMBER`, `NUMERIC`, `DATE`, `DATE_TIME`, `SELECT`, `MULTI_SELECT`, `ARRAY`, `RAW_JSON`, `RICH_TEXT`.
|
||||
|
||||
```ts src/application-config.ts
|
||||
import { defineApplication, FieldType } from 'twenty-sdk/define';
|
||||
|
||||
export default defineApplication({
|
||||
// ...identity, role...
|
||||
applicationVariables: {
|
||||
MAX_POSTCARDS: {
|
||||
universalIdentifier: '5f4497e4-9030-4085-85eb-2c48b8d53713',
|
||||
description: 'Maximum postcards per batch',
|
||||
type: FieldType.NUMBER,
|
||||
value: 10,
|
||||
},
|
||||
DEFAULT_REGION: {
|
||||
universalIdentifier: '76c5c321-b6b6-46eb-b4fc-f9f04bb04227',
|
||||
description: 'Default shipping region',
|
||||
type: FieldType.SELECT,
|
||||
options: [
|
||||
{ label: 'Europe', value: 'eu' },
|
||||
{ label: 'United States', value: 'us' },
|
||||
],
|
||||
value: 'eu',
|
||||
},
|
||||
},
|
||||
});
|
||||
```
|
||||
|
||||
Le `type` affecte uniquement **la présentation et la validation** — il sélectionne le champ de saisie correspondant dans l’interface des paramètres de l’espace de travail (un bouton bascule, un champ numérique, une liste déroulante, un sélecteur de date, un éditeur JSON, …) et permet au build de valider votre configuration (par exemple, `SELECT` / `MULTI_SELECT` doivent déclarer des `options` non vides). Il ne change **pas** la façon dont la valeur atteint votre code.
|
||||
|
||||
Les valeurs sont **toujours injectées sous forme de chaînes de caractères** — cela est inhérent aux variables d’environnement (`process.env.*` est uniquement composé de chaînes). Lorsque votre fonction logique s’exécute, l’exécuteur sérialise chaque valeur selon son `type` déclaré lors de la construction de `process.env`, de sorte que le format de chaîne soit cohérent, quelle que soit la manière dont la valeur a été définie (valeur par défaut du manifeste, interface des paramètres ou version précédente) :
|
||||
|
||||
| Type | chaîne `process.env` |
|
||||
| ------------------------------------- | ---------------------------------------- |
|
||||
| `TEXT`, `SELECT`, `DATE`, `DATE_TIME` | la valeur brute (`"eu"`, `"2026-01-01"`) |
|
||||
| `BOOLEAN` | `"true"` / `"false"` |
|
||||
| `NUMBER`, `NUMERIC` | chaîne décimale (`"10"`, `"2.5"`) |
|
||||
| `MULTI_SELECT`, `ARRAY` | tableau JSON (`'["email","postcard"]'`) |
|
||||
| `RAW_JSON`, `RICH_TEXT` | objet JSON (`'{"retries":3}'`) |
|
||||
|
||||
Analysez la chaîne pour la convertir dans le type attendu :
|
||||
|
||||
```ts
|
||||
const maxCards = Number(process.env.MAX_POSTCARDS); // "10" -> 10
|
||||
const enabled = process.env.ENABLE_TRACKING === 'true'; // "true" -> true
|
||||
const channels = JSON.parse(process.env.ENABLED_CHANNELS ?? '[]'); // '["email"]' -> ["email"]
|
||||
const config = JSON.parse(process.env.PROVIDER_CONFIG ?? '{}'); // '{"retries":3}' -> { retries: 3 }
|
||||
```
|
||||
|
||||
Il en va de même pour les composants front qui lisent les valeurs via `getApplicationVariable('VARIABLE_NAME')` — la valeur renvoyée est une chaîne ; analysez-la selon vos besoins.
|
||||
|
||||
## Rôle de fonction par défaut
|
||||
|
||||
|
||||
@@ -377,6 +377,8 @@ export default defineFrontComponent({
|
||||
Les variables secrètes (`isSecret: true`) ne sont **pas** exposées aux composants front. Elles sont uniquement disponibles dans les [fonctions logiques](/l/fr/developers/extend/apps/logic/logic-functions), qui s'exécutent côté serveur. Cela empêche l’envoi au navigateur de valeurs sensibles comme les clés d’API.
|
||||
</Warning>
|
||||
|
||||
`getApplicationVariable` renvoie toujours une **chaîne** (ou `undefined`), quel que soit le `type` déclaré de la variable. La chaîne est sérialisée de manière cohérente selon le type (booléens sous la forme `"true"` / `"false"`, nombres sous forme de chaînes décimales, tableaux / objets en JSON), dans le même format utilisé pour la fonction logique `process.env` — analysez-la vous-même (`Number(...)`, `JSON.parse(...)`, `=== 'true'`). Voir [Types de variables](/l/fr/developers/extend/apps/config/application#variable-types).
|
||||
|
||||
Les variables système suivantes sont toujours disponibles via `process.env` :
|
||||
|
||||
| Variable | Description |
|
||||
|
||||
@@ -36,6 +36,60 @@ Note:
|
||||
* Il ruolo predefinito viene rilevato automaticamente dal file di ruolo contrassegnato con [`defineApplicationRole()`](/l/it/developers/extend/apps/config/roles): non è necessario farvi riferimento da `defineApplication()`.
|
||||
* Le funzioni di pre-installazione e post-installazione vengono rilevate automaticamente durante il build del manifest — non è necessario farne riferimento in `defineApplication()`.
|
||||
* Il passaggio esplicito di `defaultRoleUniversalIdentifier` è ancora supportato per garantire la compatibilità con le versioni precedenti, ma è deprecato a favore di `defineApplicationRole()`.
|
||||
* `serverVariables` sono configurazioni e segreti con ambito di istanza (ad esempio chiavi API). A differenza di `applicationVariables`, non dichiarano alcun valore nel manifest — l’operatore dello spazio di lavoro li compila dalle impostazioni dell’app e vengono iniettati nelle funzioni di logica solo una volta impostati.
|
||||
|
||||
## Tipi di variabili
|
||||
|
||||
Sia `applicationVariables` che `serverVariables` accettano un `type` opzionale (e, per `SELECT` / `MULTI_SELECT`, un elenco di `options`). Tipi supportati: `TEXT` (predefinito), `BOOLEAN`, `NUMBER`, `NUMERIC`, `DATE`, `DATE_TIME`, `SELECT`, `MULTI_SELECT`, `ARRAY`, `RAW_JSON`, `RICH_TEXT`.
|
||||
|
||||
```ts src/application-config.ts
|
||||
import { defineApplication, FieldType } from 'twenty-sdk/define';
|
||||
|
||||
export default defineApplication({
|
||||
// ...identity, role...
|
||||
applicationVariables: {
|
||||
MAX_POSTCARDS: {
|
||||
universalIdentifier: '5f4497e4-9030-4085-85eb-2c48b8d53713',
|
||||
description: 'Maximum postcards per batch',
|
||||
type: FieldType.NUMBER,
|
||||
value: 10,
|
||||
},
|
||||
DEFAULT_REGION: {
|
||||
universalIdentifier: '76c5c321-b6b6-46eb-b4fc-f9f04bb04227',
|
||||
description: 'Default shipping region',
|
||||
type: FieldType.SELECT,
|
||||
options: [
|
||||
{ label: 'Europe', value: 'eu' },
|
||||
{ label: 'United States', value: 'us' },
|
||||
],
|
||||
value: 'eu',
|
||||
},
|
||||
},
|
||||
});
|
||||
```
|
||||
|
||||
Il `type` influisce solo su **presentazione e convalida**: seleziona l’input corrispondente nell’interfaccia delle impostazioni dell’area di lavoro (un interruttore, campo numerico, menu a discesa, selettore di data, editor JSON, …) e consente alla build di convalidare la tua configurazione (ad esempio, `SELECT` / `MULTI_SELECT` devono dichiarare `options` non vuote). **Non** cambia il modo in cui il valore arriva al tuo codice.
|
||||
|
||||
I valori sono **sempre inseriti come stringhe**: ciò è intrinseco alle variabili di ambiente (`process.env.*` accetta solo stringhe). Quando la tua funzione di logica viene eseguita, l’executor serializza ogni valore in base al `type` dichiarato mentre costruisce `process.env`, quindi il formato della stringa è coerente indipendentemente da come è stato impostato il valore (valore predefinito del manifest, interfaccia delle impostazioni o una versione precedente):
|
||||
|
||||
| Tipo | stringa di `process.env` |
|
||||
| ------------------------------------- | ----------------------------------------- |
|
||||
| `TEXT`, `SELECT`, `DATE`, `DATE_TIME` | il valore grezzo (`"eu"`, `"2026-01-01"`) |
|
||||
| `BOOLEAN` | `"true"` / `"false"` |
|
||||
| `NUMBER`, `NUMERIC` | stringa decimale (`"10"`, `"2.5"`) |
|
||||
| `MULTI_SELECT`, `ARRAY` | array JSON (`'["email","postcard"]'`) |
|
||||
| `RAW_JSON`, `RICH_TEXT` | oggetto JSON (`'{"retries":3}'`) |
|
||||
|
||||
Analizza nuovamente la stringa nel tipo che ti aspetti:
|
||||
|
||||
```ts
|
||||
const maxCards = Number(process.env.MAX_POSTCARDS); // "10" -> 10
|
||||
const enabled = process.env.ENABLE_TRACKING === 'true'; // "true" -> true
|
||||
const channels = JSON.parse(process.env.ENABLED_CHANNELS ?? '[]'); // '["email"]' -> ["email"]
|
||||
const config = JSON.parse(process.env.PROVIDER_CONFIG ?? '{}'); // '{"retries":3}' -> { retries: 3 }
|
||||
```
|
||||
|
||||
Lo stesso vale per i componenti front-end che leggono i valori tramite `getApplicationVariable('VARIABLE_NAME')`: il valore restituito è una stringa; analizzalo secondo le necessità.
|
||||
|
||||
## Ruolo funzione predefinito
|
||||
|
||||
|
||||
@@ -377,6 +377,8 @@ export default defineFrontComponent({
|
||||
Le variabili segrete (`isSecret: true`) **non** sono esposte ai componenti front-end. Sono disponibili solo nelle [funzioni logiche](/l/it/developers/extend/apps/logic/logic-functions), che vengono eseguite lato server. Questo impedisce che valori sensibili come le chiavi API vengano inviati al browser.
|
||||
</Warning>
|
||||
|
||||
`getApplicationVariable` restituisce sempre una **stringa** (o `undefined`), indipendentemente dal `type` dichiarato della variabile. La stringa viene serializzata in modo coerente in base al tipo (booleani come `"true"` / `"false"`, numeri come stringhe decimali, array / oggetti come JSON), lo stesso formato usato per la logic-function `process.env` — esegui il parsing manualmente (`Number(...)`, `JSON.parse(...)`, `=== 'true'`). Vedi [Tipi di variabili](/l/it/developers/extend/apps/config/application#variable-types).
|
||||
|
||||
Le seguenti variabili di sistema sono sempre disponibili tramite `process.env`:
|
||||
|
||||
| Variabile | Descrizione |
|
||||
|
||||
@@ -36,6 +36,60 @@ export default defineApplication({
|
||||
* デフォルトのロールは、[`defineApplicationRole()`](/l/ja/developers/extend/apps/config/roles) でマークされたロールファイルから自動的に検出されます。`defineApplication()` から参照する必要はありません。
|
||||
* プレインストール関数とポストインストール関数は、マニフェストのビルド中に自動検出されます—`defineApplication()` で参照する必要はありません。
|
||||
* 後方互換性のために `defaultRoleUniversalIdentifier` を明示的に渡すことも依然としてサポートされていますが、`defineApplicationRole()` が推奨されるため、非推奨となっています。
|
||||
* `serverVariables` はインスタンス単位の構成およびシークレット(例: API キー)です。 `applicationVariables` と異なり、マニフェスト内で値は宣言されません。ワークスペースのオペレーターがアプリの設定からそれらを入力し、設定された時点でのみロジック関数に注入されます。
|
||||
|
||||
## 変数の型
|
||||
|
||||
`applicationVariables` と `serverVariables` の両方は、オプションの `type`(および `SELECT` / `MULTI_SELECT` の場合は `options` リスト)を受け取ります。 サポートされている型: `TEXT` (既定), `BOOLEAN`, `NUMBER`, `NUMERIC`, `DATE`, `DATE_TIME`, `SELECT`, `MULTI_SELECT`, `ARRAY`, `RAW_JSON`, `RICH_TEXT`。
|
||||
|
||||
```ts src/application-config.ts
|
||||
import { defineApplication, FieldType } from 'twenty-sdk/define';
|
||||
|
||||
export default defineApplication({
|
||||
// ...identity, role...
|
||||
applicationVariables: {
|
||||
MAX_POSTCARDS: {
|
||||
universalIdentifier: '5f4497e4-9030-4085-85eb-2c48b8d53713',
|
||||
description: 'Maximum postcards per batch',
|
||||
type: FieldType.NUMBER,
|
||||
value: 10,
|
||||
},
|
||||
DEFAULT_REGION: {
|
||||
universalIdentifier: '76c5c321-b6b6-46eb-b4fc-f9f04bb04227',
|
||||
description: 'Default shipping region',
|
||||
type: FieldType.SELECT,
|
||||
options: [
|
||||
{ label: 'Europe', value: 'eu' },
|
||||
{ label: 'United States', value: 'us' },
|
||||
],
|
||||
value: 'eu',
|
||||
},
|
||||
},
|
||||
});
|
||||
```
|
||||
|
||||
`type` は **表示とバリデーション** のみに影響します。つまり、ワークスペース設定 UI で対応する入力(トグル、数値フィールド、ドロップダウン、日付ピッカー、JSON エディタ など)を選択します。 また、ビルド時に設定を検証できるようにします(たとえば、`SELECT` / `MULTI_SELECT` では空でない `options` を宣言する必要があります)。 これは、値がコードに届く方法を**変更しません**。
|
||||
|
||||
値は **常に文字列として注入されます**。これは環境変数の性質によるものです(`process.env.*` は文字列のみです)。 ロジック関数が実行されるとき、エグゼキュータは宣言された `type` に従って各値をシリアライズしながら `process.env` を構築します。そのため、値がどのように設定されたか(マニフェストのデフォルト、設定 UI、あるいは以前のバージョン)に関係なく、文字列形式は一貫したものになります。
|
||||
|
||||
| タイプ | `process.env` の文字列 |
|
||||
| ------------------------------------- | --------------------------------- |
|
||||
| `TEXT`, `SELECT`, `DATE`, `DATE_TIME` | 生の値(`"eu"`, `"2026-01-01"`) |
|
||||
| `BOOLEAN` | `"true"` / `"false"` |
|
||||
| `NUMBER`, `NUMERIC` | 10進数の文字列(`"10"`, `"2.5"`) |
|
||||
| `MULTI_SELECT`, `ARRAY` | JSON 配列(`'["email","postcard"]'`) |
|
||||
| `RAW_JSON`, `RICH_TEXT` | JSON オブジェクト(`'{"retries":3}'`) |
|
||||
|
||||
文字列を、想定している型に再度パースしてください:
|
||||
|
||||
```ts
|
||||
const maxCards = Number(process.env.MAX_POSTCARDS); // "10" -> 10
|
||||
const enabled = process.env.ENABLE_TRACKING === 'true'; // "true" -> true
|
||||
const channels = JSON.parse(process.env.ENABLED_CHANNELS ?? '[]'); // '["email"]' -> ["email"]
|
||||
const config = JSON.parse(process.env.PROVIDER_CONFIG ?? '{}'); // '{"retries":3}' -> { retries: 3 }
|
||||
```
|
||||
|
||||
同じことが、`getApplicationVariable('VARIABLE_NAME')` で値を読み取るフロントコンポーネントにも当てはまります。返される値は文字列なので、必要に応じてパースしてください。
|
||||
|
||||
## デフォルトの関数ロール
|
||||
|
||||
|
||||
@@ -377,6 +377,8 @@ export default defineFrontComponent({
|
||||
シークレット変数(`isSecret: true`)はフロントコンポーネントには公開**されません**。 それらは、サーバーサイドで実行される[ロジック関数](/l/ja/developers/extend/apps/logic/logic-functions)でのみ利用できます。 これにより、API キーなどの機密値がブラウザーに送信されるのを防ぎます。
|
||||
</Warning>
|
||||
|
||||
`getApplicationVariable` は、変数に宣言されている `type` に関係なく、常に **string**(または `undefined`)を返します。 文字列は型に応じて一貫した方法でシリアライズされます(boolean は `"true"` / `"false"`、number は 10 進数の文字列、配列 / オブジェクトは JSON)。これはロジック関数の `process.env` で使用されているのと同じ形式です。各自でパースしてください(`Number(...)`、`JSON.parse(...)`、`=== 'true'` など)。 [Variable types](/l/ja/developers/extend/apps/config/application#variable-types) を参照してください。
|
||||
|
||||
次のシステム変数は、常に `process.env` 経由で利用できます。
|
||||
|
||||
| 変数 | 説明 |
|
||||
|
||||
@@ -36,6 +36,60 @@ export default defineApplication({
|
||||
* 기본 역할은 [`defineApplicationRole()`](/l/ko/developers/extend/apps/config/roles)로 표시된 역할 파일에서 자동으로 감지되므로, `defineApplication()`에서 이를 참조할 필요가 없습니다.
|
||||
* 설치 전/후 함수는 매니페스트 빌드 중 자동으로 감지됩니다 — `defineApplication()`에서 별도로 참조할 필요가 없습니다.
|
||||
* 하위 호환성을 위해 `defaultRoleUniversalIdentifier`를 명시적으로 전달하는 방식도 계속 지원되지만, 이제는 `defineApplicationRole()` 사용을 권장하며 이전 방식은 더 이상 권장되지 않습니다.
|
||||
* `serverVariables`는 인스턴스 범위의 구성 및 비밀(예: API 키)입니다. `applicationVariables`와 달리, 매니페스트에는 값을 선언하지 않으며, 워크스페이스 운영자가 앱 설정에서 값을 채워 넣으면 설정된 이후에만 로직 함수에 주입됩니다.
|
||||
|
||||
## 변수 유형
|
||||
|
||||
`applicationVariables`와 `serverVariables`는 모두 선택적인 `type`을 허용하며, `SELECT` / `MULTI_SELECT`의 경우 `options` 목록을 허용합니다. 지원되는 타입: `TEXT`(기본값), `BOOLEAN`, `NUMBER`, `NUMERIC`, `DATE`, `DATE_TIME`, `SELECT`, `MULTI_SELECT`, `ARRAY`, `RAW_JSON`, `RICH_TEXT`.
|
||||
|
||||
```ts src/application-config.ts
|
||||
import { defineApplication, FieldType } from 'twenty-sdk/define';
|
||||
|
||||
export default defineApplication({
|
||||
// ...identity, role...
|
||||
applicationVariables: {
|
||||
MAX_POSTCARDS: {
|
||||
universalIdentifier: '5f4497e4-9030-4085-85eb-2c48b8d53713',
|
||||
description: 'Maximum postcards per batch',
|
||||
type: FieldType.NUMBER,
|
||||
value: 10,
|
||||
},
|
||||
DEFAULT_REGION: {
|
||||
universalIdentifier: '76c5c321-b6b6-46eb-b4fc-f9f04bb04227',
|
||||
description: 'Default shipping region',
|
||||
type: FieldType.SELECT,
|
||||
options: [
|
||||
{ label: 'Europe', value: 'eu' },
|
||||
{ label: 'United States', value: 'us' },
|
||||
],
|
||||
value: 'eu',
|
||||
},
|
||||
},
|
||||
});
|
||||
```
|
||||
|
||||
`type`은 **표현과 검증**에만 영향을 줍니다. 즉, 워크스페이스 설정 UI에서 해당하는 입력 요소(토글, 숫자 필드, 드롭다운, 날짜 선택기, JSON 편집기 등)를 선택합니다. 또한 빌드가 구성(config)을 검증하도록 합니다(예를 들어 `SELECT` / `MULTI_SELECT`는 비어 있지 않은 `options`를 선언해야 합니다). 값이 코드로 전달되는 방식은 **변경되지 않습니다**.
|
||||
|
||||
값은 **항상 문자열로 주입**됩니다. 이는 환경 변수의 특성 때문입니다(`process.env.*`는 문자열만 허용). 로직 함수가 실행될 때, 실행기는 선언된 `type`에 따라 각 값을 직렬화하여 `process.env`를 구성하므로, 값이 어떻게 설정되었는지(매니페스트 기본값, 설정 UI, 또는 이전 버전)와 관계없이 문자열 형식이 일관되게 유지됩니다:
|
||||
|
||||
| 유형 | `process.env` 문자열 |
|
||||
| ------------------------------------- | --------------------------------- |
|
||||
| `TEXT`, `SELECT`, `DATE`, `DATE_TIME` | 원시 값(`"eu"`, `"2026-01-01"`) |
|
||||
| `BOOLEAN` | `"true"` / `"false"` |
|
||||
| `NUMBER`, `NUMERIC` | 10진수 문자열(`"10"`, `"2.5"`) |
|
||||
| `MULTI_SELECT`, `ARRAY` | JSON 배열(`'["email","postcard"]'`) |
|
||||
| `RAW_JSON`, `RICH_TEXT` | JSON 객체(`'{"retries":3}'`) |
|
||||
|
||||
문자열을 다시 기대하는 타입으로 파싱하세요:
|
||||
|
||||
```ts
|
||||
const maxCards = Number(process.env.MAX_POSTCARDS); // "10" -> 10
|
||||
const enabled = process.env.ENABLE_TRACKING === 'true'; // "true" -> true
|
||||
const channels = JSON.parse(process.env.ENABLED_CHANNELS ?? '[]'); // '["email"]' -> ["email"]
|
||||
const config = JSON.parse(process.env.PROVIDER_CONFIG ?? '{}'); // '{"retries":3}' -> { retries: 3 }
|
||||
```
|
||||
|
||||
`getApplicationVariable('VARIABLE_NAME')`을 통해 값을 읽는 프런트 컴포넌트에도 동일하게 적용됩니다. 반환되는 값은 문자열이므로, 필요에 따라 파싱해야 합니다.
|
||||
|
||||
## 기본 함수 역할
|
||||
|
||||
|
||||
@@ -377,6 +377,8 @@ export default defineFrontComponent({
|
||||
비밀 변수(`isSecret: true`)는 프론트 컴포넌트에 **노출되지 않습니다**. 이 변수들은 서버 측에서 실행되는 [로직 함수](/l/ko/developers/extend/apps/logic/logic-functions)에서만 사용할 수 있습니다. 이는 API 키와 같은 민감한 값이 브라우저로 전송되는 것을 방지합니다.
|
||||
</Warning>
|
||||
|
||||
`getApplicationVariable`은(는) 변수에 선언된 `type`과 관계없이 항상 **문자열**(또는 `undefined`)을 반환합니다. 문자열은 타입에 따라 일관되게 직렬화됩니다(불리언은 `"true"` / `"false"`, 숫자는 10진수 문자열, 배열/객체는 JSON). 이는 로직 함수 `process.env`에 사용되는 것과 동일한 형식이므로, 직접 파싱해야 합니다(`Number(...)`, `JSON.parse(...)`, `=== 'true'`). [변수 타입](/l/ko/developers/extend/apps/config/application#variable-types)을(를) 참조하세요.
|
||||
|
||||
다음 시스템 변수는 항상 `process.env`를 통해 사용할 수 있습니다:
|
||||
|
||||
| 변수 | 설명 |
|
||||
|
||||
@@ -36,6 +36,60 @@ Notas:
|
||||
* O papel padrão é detectado automaticamente a partir do arquivo de definição de papel marcado com [`defineApplicationRole()`](/l/pt/developers/extend/apps/config/roles) — você não precisa referenciá-lo em `defineApplication()`.
|
||||
* As funções de pré-instalação e pós-instalação são detectadas automaticamente durante a construção do manifesto — você não precisa referenciá-las em `defineApplication()`.
|
||||
* Passar `defaultRoleUniversalIdentifier` explicitamente ainda é compatível para retrocompatibilidade, mas foi preterido em favor de `defineApplicationRole()`.
|
||||
* `serverVariables` são configurações e segredos com escopo de instância (por exemplo, chaves de API). Ao contrário de `applicationVariables`, eles não declaram nenhum valor no manifesto — o operador do workspace os preenche nas configurações do app, e eles são injetados nas funções de lógica somente depois de definidos.
|
||||
|
||||
## Tipos de variáveis
|
||||
|
||||
Tanto `applicationVariables` quanto `serverVariables` aceitam um `type` opcional (e, para `SELECT` / `MULTI_SELECT`, uma lista de `options`). Tipos compatíveis: `TEXT` (padrão), `BOOLEAN`, `NUMBER`, `NUMERIC`, `DATE`, `DATE_TIME`, `SELECT`, `MULTI_SELECT`, `ARRAY`, `RAW_JSON`, `RICH_TEXT`.
|
||||
|
||||
```ts src/application-config.ts
|
||||
import { defineApplication, FieldType } from 'twenty-sdk/define';
|
||||
|
||||
export default defineApplication({
|
||||
// ...identity, role...
|
||||
applicationVariables: {
|
||||
MAX_POSTCARDS: {
|
||||
universalIdentifier: '5f4497e4-9030-4085-85eb-2c48b8d53713',
|
||||
description: 'Maximum postcards per batch',
|
||||
type: FieldType.NUMBER,
|
||||
value: 10,
|
||||
},
|
||||
DEFAULT_REGION: {
|
||||
universalIdentifier: '76c5c321-b6b6-46eb-b4fc-f9f04bb04227',
|
||||
description: 'Default shipping region',
|
||||
type: FieldType.SELECT,
|
||||
options: [
|
||||
{ label: 'Europe', value: 'eu' },
|
||||
{ label: 'United States', value: 'us' },
|
||||
],
|
||||
value: 'eu',
|
||||
},
|
||||
},
|
||||
});
|
||||
```
|
||||
|
||||
O `type` afeta apenas a **apresentação e validação** — ele seleciona a entrada correspondente na interface de configurações do workspace (um toggle, campo numérico, dropdown, seletor de data, editor JSON, …) e permite que o build valide a sua configuração (por exemplo, `SELECT` / `MULTI_SELECT` devem declarar `options` não vazias). Ele **não** altera a forma como o valor chega ao seu código.
|
||||
|
||||
Os valores são **sempre injetados como strings** — isso é inerente às variáveis de ambiente (`process.env.*` aceita apenas string). Quando a sua função de lógica é executada, o executor serializa cada valor de acordo com o `type` declarado ao construir o `process.env`, para que o formato da string seja consistente, não importa como o valor foi definido (padrão do manifesto, interface de configurações ou uma versão anterior):
|
||||
|
||||
| Tipo | string de `process.env` |
|
||||
| ------------------------------------- | -------------------------------------- |
|
||||
| `TEXT`, `SELECT`, `DATE`, `DATE_TIME` | o valor bruto (`"eu"`, `"2026-01-01"`) |
|
||||
| `BOOLEAN` | `"true"` / `"false"` |
|
||||
| `NUMBER`, `NUMERIC` | string decimal (`"10"`, `"2.5"`) |
|
||||
| `MULTI_SELECT`, `ARRAY` | array JSON (`'["email","postcard"]'`) |
|
||||
| `RAW_JSON`, `RICH_TEXT` | objeto JSON (`'{"retries":3}'`) |
|
||||
|
||||
Converta a string de volta para o tipo que você espera:
|
||||
|
||||
```ts
|
||||
const maxCards = Number(process.env.MAX_POSTCARDS); // "10" -> 10
|
||||
const enabled = process.env.ENABLE_TRACKING === 'true'; // "true" -> true
|
||||
const channels = JSON.parse(process.env.ENABLED_CHANNELS ?? '[]'); // '["email"]' -> ["email"]
|
||||
const config = JSON.parse(process.env.PROVIDER_CONFIG ?? '{}'); // '{"retries":3}' -> { retries: 3 }
|
||||
```
|
||||
|
||||
O mesmo se aplica a componentes de front-end que leem valores via `getApplicationVariable('VARIABLE_NAME')` — o valor retornado é uma string; converta conforme necessário.
|
||||
|
||||
## Papel de função padrão
|
||||
|
||||
|
||||
@@ -377,6 +377,8 @@ export default defineFrontComponent({
|
||||
Variáveis secretas (`isSecret: true`) **não** são expostas aos componentes de front. Elas estão disponíveis apenas em [funções de lógica](/l/pt/developers/extend/apps/logic/logic-functions), que são executadas no lado do servidor. Isso impede que valores sigilosos, como chaves de API, sejam enviados para o navegador.
|
||||
</Warning>
|
||||
|
||||
`getApplicationVariable` sempre retorna uma **string** (ou `undefined`), independentemente do `type` declarado da variável. A string é serializada de forma consistente por tipo (booleanos como `"true"` / `"false"`, números como strings decimais, arrays / objetos como JSON), o mesmo formato usado para a logic-function `process.env` — faça você mesmo o parse (`Number(...)`, `JSON.parse(...)`, `=== 'true'`). Veja [Tipos de variáveis](/l/pt/developers/extend/apps/config/application#variable-types).
|
||||
|
||||
As seguintes variáveis de sistema estão sempre disponíveis via `process.env`:
|
||||
|
||||
| Variável | Descrição |
|
||||
|
||||
@@ -36,6 +36,60 @@ Notițe:
|
||||
* Rolul implicit este detectat automat din fișierul de rol marcat cu [`defineApplicationRole()`](/l/ro/developers/extend/apps/config/roles) — nu este necesar să faci referire la el în `defineApplication()`.
|
||||
* Funcțiile de pre-instalare și post-instalare sunt detectate automat în timpul construirii manifestului — nu trebuie să le referiți în `defineApplication()`.
|
||||
* Transmiterea explicită a `defaultRoleUniversalIdentifier` este în continuare acceptată pentru compatibilitate retroactivă, dar este considerată învechită în favoarea `defineApplicationRole()`.
|
||||
* `serverVariables` sunt configurări și secrete la nivel de instanță (de ex. chei API). Spre deosebire de `applicationVariables`, ele nu declară nicio valoare în manifest — operatorul spațiului de lucru le completează din setările aplicației și sunt injectate în funcțiile de logică doar după ce au fost setate.
|
||||
|
||||
## Tipuri de variabile
|
||||
|
||||
Atât `applicationVariables`, cât și `serverVariables` acceptă un câmp opțional `type` (și, pentru `SELECT` / `MULTI_SELECT`, o listă `options`). Tipuri acceptate: `TEXT` (implicit), `BOOLEAN`, `NUMBER`, `NUMERIC`, `DATE`, `DATE_TIME`, `SELECT`, `MULTI_SELECT`, `ARRAY`, `RAW_JSON`, `RICH_TEXT`.
|
||||
|
||||
```ts src/application-config.ts
|
||||
import { defineApplication, FieldType } from 'twenty-sdk/define';
|
||||
|
||||
export default defineApplication({
|
||||
// ...identity, role...
|
||||
applicationVariables: {
|
||||
MAX_POSTCARDS: {
|
||||
universalIdentifier: '5f4497e4-9030-4085-85eb-2c48b8d53713',
|
||||
description: 'Maximum postcards per batch',
|
||||
type: FieldType.NUMBER,
|
||||
value: 10,
|
||||
},
|
||||
DEFAULT_REGION: {
|
||||
universalIdentifier: '76c5c321-b6b6-46eb-b4fc-f9f04bb04227',
|
||||
description: 'Default shipping region',
|
||||
type: FieldType.SELECT,
|
||||
options: [
|
||||
{ label: 'Europe', value: 'eu' },
|
||||
{ label: 'United States', value: 'us' },
|
||||
],
|
||||
value: 'eu',
|
||||
},
|
||||
},
|
||||
});
|
||||
```
|
||||
|
||||
Proprietatea `type` afectează doar **prezentarea și validarea** — selectează câmpul de intrare corespunzător în interfața de setări a spațiului de lucru (un comutator, câmp numeric, listă derulantă, selector de dată, editor JSON, …) și permite build‑ului să valideze configurația (de exemplu, `SELECT` / `MULTI_SELECT` trebuie să declare o listă `options` negoală). Nu modifică **deloc** modul în care valoarea ajunge în codul tău.
|
||||
|
||||
Valorile sunt **întotdeauna injectate ca stringuri** — acest lucru este inerent pentru variabilele de mediu (`process.env.*` este doar string). Când rulează funcția ta de logică, executorul serializează fiecare valoare în funcție de `type`‑ul declarat în timp ce construiește `process.env`, astfel încât formatul stringului este consecvent indiferent de modul în care a fost setată valoarea (valoare implicită din manifest, interfața de setări sau o versiune anterioară):
|
||||
|
||||
| Tip | string `process.env` |
|
||||
| ------------------------------------- | --------------------------------------- |
|
||||
| `TEXT`, `SELECT`, `DATE`, `DATE_TIME` | valoarea brută (`"eu"`, `"2026-01-01"`) |
|
||||
| `BOOLEAN` | `"true"` / `"false"` |
|
||||
| `NUMBER`, `NUMERIC` | string zecimal (`"10"`, `"2.5"`) |
|
||||
| `MULTI_SELECT`, `ARRAY` | array JSON (`'["email","postcard"]'`) |
|
||||
| `RAW_JSON`, `RICH_TEXT` | obiect JSON (`'{"retries":3}'`) |
|
||||
|
||||
Parsează stringul înapoi în tipul pe care îl aștepți:
|
||||
|
||||
```ts
|
||||
const maxCards = Number(process.env.MAX_POSTCARDS); // "10" -> 10
|
||||
const enabled = process.env.ENABLE_TRACKING === 'true'; // "true" -> true
|
||||
const channels = JSON.parse(process.env.ENABLED_CHANNELS ?? '[]'); // '["email"]' -> ["email"]
|
||||
const config = JSON.parse(process.env.PROVIDER_CONFIG ?? '{}'); // '{"retries":3}' -> { retries: 3 }
|
||||
```
|
||||
|
||||
Același lucru se aplică și componentelor de interfață care citesc valori prin `getApplicationVariable('VARIABLE_NAME')` — valoarea returnată este un string; parseaz-o după cum este necesar.
|
||||
|
||||
## Rol implicit pentru funcții
|
||||
|
||||
|
||||
@@ -377,6 +377,8 @@ export default defineFrontComponent({
|
||||
Variabilele secrete (`isSecret: true`) **nu** sunt expuse componentelor de interfață. Acestea sunt disponibile doar în [funcțiile logice](/l/ro/developers/extend/apps/logic/logic-functions), care rulează pe server. Acest lucru împiedică trimiterea către browser a valorilor sensibile, cum ar fi cheile API.
|
||||
</Warning>
|
||||
|
||||
`getApplicationVariable` returnează întotdeauna un **string** (sau `undefined`), indiferent de `type`‑ul declarat al variabilei. Stringul este serializat în mod consecvent în funcție de tip (valorile boolean ca `"true"` / `"false"`, numerele ca stringuri zecimale, array‑urile / obiectele ca JSON), în același format folosit pentru `process.env` în funcțiile logice — parsează‑l tu însuți (`Number(...)`, `JSON.parse(...)`, `=== 'true'`). Vezi [Tipuri de variabile](/l/ro/developers/extend/apps/config/application#variable-types).
|
||||
|
||||
Următoarele variabile de sistem sunt întotdeauna disponibile prin `process.env`:
|
||||
|
||||
| Variabilă | Descriere |
|
||||
|
||||
@@ -36,6 +36,60 @@ Notlar:
|
||||
* Varsayılan rol, [`defineApplicationRole()`](/l/tr/developers/extend/apps/config/roles) ile işaretlenmiş rol dosyasından otomatik olarak algılanır — onu `defineApplication()` içinden belirtmenize gerek yoktur.
|
||||
* Kurulum öncesi ve kurulum sonrası fonksiyonlar manifest derlemesi sırasında otomatik olarak algılanır — bunlara `defineApplication()` içinde referans vermeniz gerekmez.
|
||||
* Geriye dönük uyumluluk için `defaultRoleUniversalIdentifier` değerini açıkça geçmek hâlâ desteklenmektedir, ancak `defineApplicationRole()` lehine kullanımdan kaldırılmıştır.
|
||||
* `serverVariables`, API anahtarları gibi örnek düzeyindeki yapılandırmalar ve gizli bilgilerdir. `applicationVariables`'ın aksine, manifest içinde herhangi bir değer belirtmezler — çalışma alanı operatörü bunları uygulamanın ayarlarından doldurur ve yalnızca ayarlandıklarında mantık fonksiyonlarına enjekte edilirler.
|
||||
|
||||
## Değişken türleri
|
||||
|
||||
Hem `applicationVariables` hem de `serverVariables`, isteğe bağlı bir `type` (ve `SELECT` / `MULTI_SELECT` için bir `options` listesi) kabul eder. Desteklenen türler: `TEXT` (varsayılan), `BOOLEAN`, `NUMBER`, `NUMERIC`, `DATE`, `DATE_TIME`, `SELECT`, `MULTI_SELECT`, `ARRAY`, `RAW_JSON`, `RICH_TEXT`.
|
||||
|
||||
```ts src/application-config.ts
|
||||
import { defineApplication, FieldType } from 'twenty-sdk/define';
|
||||
|
||||
export default defineApplication({
|
||||
// ...identity, role...
|
||||
applicationVariables: {
|
||||
MAX_POSTCARDS: {
|
||||
universalIdentifier: '5f4497e4-9030-4085-85eb-2c48b8d53713',
|
||||
description: 'Maximum postcards per batch',
|
||||
type: FieldType.NUMBER,
|
||||
value: 10,
|
||||
},
|
||||
DEFAULT_REGION: {
|
||||
universalIdentifier: '76c5c321-b6b6-46eb-b4fc-f9f04bb04227',
|
||||
description: 'Default shipping region',
|
||||
type: FieldType.SELECT,
|
||||
options: [
|
||||
{ label: 'Europe', value: 'eu' },
|
||||
{ label: 'United States', value: 'us' },
|
||||
],
|
||||
value: 'eu',
|
||||
},
|
||||
},
|
||||
});
|
||||
```
|
||||
|
||||
`type` yalnızca **görünümü ve doğrulamayı** etkiler — çalışma alanı ayarları arayüzünde eşleşen girdiyi seçer (açma/kapama düğmesi, sayı alanı, açılır liste, tarih seçici, JSON düzenleyici, …) ve derlemenin yapılandırmanızı doğrulamasını sağlar (örneğin, `SELECT` / `MULTI_SELECT` boş olmayan `options` bildirmelidir). Değerin kodunuza nasıl ulaştığını **değiştirmez**.
|
||||
|
||||
Değerler **her zaman string olarak eklenir** — bu, ortam değişkenlerinin doğasında vardır (`process.env.*` yalnızca string kabul eder). Mantık fonksiyonunuz çalıştığında, yürütücü her bir değeri `process.env` oluşturulurken bildirilen `type`'a göre serileştirir; böylece değerin nasıl ayarlandığından (manifest varsayılanı, ayarlar arayüzü veya önceki bir sürüm) bağımsız olarak string biçimi tutarlı olur:
|
||||
|
||||
| Tür | `process.env` string |
|
||||
| ------------------------------------- | -------------------------------------- |
|
||||
| `TEXT`, `SELECT`, `DATE`, `DATE_TIME` | ham değer (`"eu"`, `"2026-01-01"`) |
|
||||
| `BOOLEAN` | `"true"` / `"false"` |
|
||||
| `NUMBER`, `NUMERIC` | ondalık string (`"10"`, `"2.5"`) |
|
||||
| `MULTI_SELECT`, `ARRAY` | JSON dizisi (`'["email","postcard"]'`) |
|
||||
| `RAW_JSON`, `RICH_TEXT` | JSON nesnesi (`'{"retries":3}'`) |
|
||||
|
||||
String'i beklediğiniz türe geri ayrıştırın:
|
||||
|
||||
```ts
|
||||
const maxCards = Number(process.env.MAX_POSTCARDS); // "10" -> 10
|
||||
const enabled = process.env.ENABLE_TRACKING === 'true'; // "true" -> true
|
||||
const channels = JSON.parse(process.env.ENABLED_CHANNELS ?? '[]'); // '["email"]' -> ["email"]
|
||||
const config = JSON.parse(process.env.PROVIDER_CONFIG ?? '{}'); // '{"retries":3}' -> { retries: 3 }
|
||||
```
|
||||
|
||||
Aynısı, `getApplicationVariable('VARIABLE_NAME')` ile değerleri okuyan ön bileşenler için de geçerlidir — döndürülen değer bir stringtir; gerektiği gibi ayrıştırın.
|
||||
|
||||
## Varsayılan fonksiyon rolü
|
||||
|
||||
|
||||
@@ -377,6 +377,8 @@ export default defineFrontComponent({
|
||||
Gizli değişkenler (`isSecret: true`) ön uç bileşenlere açıklanmaz. Bunlar yalnızca sunucu tarafında çalışan [mantık işlevlerinde](/l/tr/developers/extend/apps/logic/logic-functions) kullanılabilir. Bu, API anahtarları gibi hassas değerlerin tarayıcıya gönderilmesini engeller.
|
||||
</Warning>
|
||||
|
||||
`getApplicationVariable`, değişkenin bildirilen `type` değerinden bağımsız olarak her zaman bir **string** (veya `undefined`) döndürür. String, türe göre tutarlı bir şekilde serileştirilir (boolean değerler `"true"` / `"false"`, sayılar ondalık dizeler olarak, diziler/nesneler JSON olarak) ve bu, `process.env` mantık işlevi için kullanılan formatla aynıdır — veriyi kendiniz ayrıştırın (`Number(...)`, `JSON.parse(...)`, `=== 'true'`). [Değişken türleri](/l/tr/developers/extend/apps/config/application#variable-types) bölümüne bakın.
|
||||
|
||||
Aşağıdaki sistem değişkenleri her zaman `process.env` aracılığıyla kullanılabilir:
|
||||
|
||||
| Değişken | Açıklama |
|
||||
|
||||
@@ -36,6 +36,60 @@ export default defineApplication({
|
||||
* 默认角色会根据使用 [`defineApplicationRole()`](/l/zh/developers/extend/apps/config/roles) 标记的角色文件自动检测——你不需要在 `defineApplication()` 中引用它。
|
||||
* 在构建清单时会自动检测安装前/安装后函数——无需在 `defineApplication()` 中引用它们。
|
||||
* 显式传递 `defaultRoleUniversalIdentifier` 仍然受支持以保持向后兼容性,但已弃用,推荐改用 `defineApplicationRole()`。
|
||||
* `serverVariables` 是实例级的配置和机密信息(例如 API 密钥)。 与 `applicationVariables` 不同,它们不会在 manifest 中声明具体值——工作区运维人员会在应用设置中填写这些值,并且它们只有在被设置后才会被注入到逻辑函数中。
|
||||
|
||||
## 变量类型
|
||||
|
||||
`applicationVariables` 和 `serverVariables` 都接受一个可选的 `type`(且对于 `SELECT` / `MULTI_SELECT`,还可以接受一个 `options` 列表)。 支持的类型:`TEXT`(默认)、`BOOLEAN`、`NUMBER`、`NUMERIC`、`DATE`、`DATE_TIME`、`SELECT`、`MULTI_SELECT`、`ARRAY`、`RAW_JSON`、`RICH_TEXT`。
|
||||
|
||||
```ts src/application-config.ts
|
||||
import { defineApplication, FieldType } from 'twenty-sdk/define';
|
||||
|
||||
export default defineApplication({
|
||||
// ...identity, role...
|
||||
applicationVariables: {
|
||||
MAX_POSTCARDS: {
|
||||
universalIdentifier: '5f4497e4-9030-4085-85eb-2c48b8d53713',
|
||||
description: 'Maximum postcards per batch',
|
||||
type: FieldType.NUMBER,
|
||||
value: 10,
|
||||
},
|
||||
DEFAULT_REGION: {
|
||||
universalIdentifier: '76c5c321-b6b6-46eb-b4fc-f9f04bb04227',
|
||||
description: 'Default shipping region',
|
||||
type: FieldType.SELECT,
|
||||
options: [
|
||||
{ label: 'Europe', value: 'eu' },
|
||||
{ label: 'United States', value: 'us' },
|
||||
],
|
||||
value: 'eu',
|
||||
},
|
||||
},
|
||||
});
|
||||
```
|
||||
|
||||
`type` 只影响**展示和校验**——它会在工作区设置界面中选择匹配的输入控件(开关、数字字段、下拉框、日期选择器、JSON 编辑器等)。 并让构建过程校验你的配置(例如,`SELECT` / `MULTI_SELECT` 必须声明非空的 `options`)。 它**不会**改变该值到达你代码的方式。
|
||||
|
||||
值**始终以字符串注入**——这是环境变量固有的特性(`process.env.*` 只能是字符串)。 当你的逻辑函数运行时,执行器会在构建 `process.env` 时按声明的 `type` 序列化每个值,因此无论该值是如何设置的(清单默认值、设置界面或先前的版本),字符串格式都是一致的:
|
||||
|
||||
| 类型 | `process.env` 字符串 |
|
||||
| ---------------------------------- | --------------------------------- |
|
||||
| `TEXT`、`SELECT`、`DATE`、`DATE_TIME` | 原始值(`"eu"`、`"2026-01-01"`) |
|
||||
| `BOOLEAN` | `"true"` / `"false"` |
|
||||
| `NUMBER`、`NUMERIC` | 十进制字符串(`"10"`、`"2.5"`) |
|
||||
| `MULTI_SELECT`、`ARRAY` | JSON 数组(`'["email","postcard"]'`) |
|
||||
| `RAW_JSON`、`RICH_TEXT` | JSON 对象(`'{"retries":3}'`) |
|
||||
|
||||
将该字符串再解析回你所期望的类型:
|
||||
|
||||
```ts
|
||||
const maxCards = Number(process.env.MAX_POSTCARDS); // "10" -> 10
|
||||
const enabled = process.env.ENABLE_TRACKING === 'true'; // "true" -> true
|
||||
const channels = JSON.parse(process.env.ENABLED_CHANNELS ?? '[]'); // '["email"]' -> ["email"]
|
||||
const config = JSON.parse(process.env.PROVIDER_CONFIG ?? '{}'); // '{"retries":3}' -> { retries: 3 }
|
||||
```
|
||||
|
||||
同样适用于通过 `getApplicationVariable('VARIABLE_NAME')` 读取值的前端组件——返回值是字符串;按需进行解析。
|
||||
|
||||
## 默认函数角色
|
||||
|
||||
|
||||
@@ -377,6 +377,8 @@ export default defineFrontComponent({
|
||||
机密变量(`isSecret: true`)**不会**暴露给前端组件。 它们仅在服务器端运行的 [逻辑函数](/l/zh/developers/extend/apps/logic/logic-functions) 中可用。 这可以防止诸如 API 密钥之类的敏感值被发送到浏览器。
|
||||
</Warning>
|
||||
|
||||
无论变量声明的 `type` 为何,`getApplicationVariable` 始终返回一个 **string**(或 `undefined`)。 该字符串会按照类型被一致地序列化(布尔值为 `"true"` / `"false"`,数字为十进制字符串,数组 / 对象为 JSON),与逻辑函数 `process.env` 使用的格式相同 —— 需要你自行解析(`Number(...)`、`JSON.parse(...)`、`=== 'true'`)。 参见[变量类型](/l/zh/developers/extend/apps/config/application#variable-types)。
|
||||
|
||||
以下系统变量始终可以通过 `process.env` 获取:
|
||||
|
||||
| 变量 | 描述 |
|
||||
|
||||
Reference in New Issue
Block a user