From e9b5cb830c4186e2876a536fc3cad3851ec5062f Mon Sep 17 00:00:00 2001 From: "github-actions[bot]" <41898282+github-actions[bot]@users.noreply.github.com> Date: Wed, 18 Feb 2026 17:54:40 +0100 Subject: [PATCH] i18n - docs translations (#18040) Created by Github action Co-authored-by: github-actions --- .../developers/extend/capabilities/apps.mdx | 79 +++++++++++++++--- .../developers/extend/capabilities/apps.mdx | 79 +++++++++++++++--- .../developers/extend/capabilities/apps.mdx | 71 ++++++++++++++-- .../developers/extend/capabilities/apps.mdx | 81 ++++++++++++++++--- .../developers/extend/capabilities/apps.mdx | 79 +++++++++++++++--- .../developers/extend/capabilities/apps.mdx | 69 ++++++++++++++-- .../developers/extend/capabilities/apps.mdx | 81 ++++++++++++++++--- .../developers/extend/capabilities/apps.mdx | 69 ++++++++++++++-- .../developers/extend/capabilities/apps.mdx | 79 +++++++++++++++--- 9 files changed, 600 insertions(+), 87 deletions(-) diff --git a/packages/twenty-docs/l/ar/developers/extend/capabilities/apps.mdx b/packages/twenty-docs/l/ar/developers/extend/capabilities/apps.mdx index 0b9e8507c4..d17124a883 100644 --- a/packages/twenty-docs/l/ar/developers/extend/capabilities/apps.mdx +++ b/packages/twenty-docs/l/ar/developers/extend/capabilities/apps.mdx @@ -45,19 +45,22 @@ yarn twenty app:dev من هنا يمكنك: ```bash filename="Terminal" -# أضف كيانًا جديدًا إلى تطبيقك (موجّه) +# Add a new entity to your application (guided) yarn twenty entity:add -# راقب سجلات وظائف تطبيقك +# Watch your application's function logs yarn twenty function:logs -# نفّذ وظيفة بالاسم +# Execute a function by name yarn twenty function:execute -n my-function -p '{"name": "test"}' -# أزل تثبيت التطبيق من مساحة العمل الحالية +# Execute the post-install function +yarn twenty function:execute --postInstall + +# Uninstall the application from the current workspace yarn twenty app:uninstall -# اعرض مساعدة الأوامر +# Display commands' help yarn twenty help ``` @@ -70,7 +73,7 @@ yarn twenty help * ينسخ تطبيقًا أساسيًا مصغّرًا إلى `my-twenty-app/` * يضيف اعتمادًا محليًا `twenty-sdk` وتهيئة Yarn 4 * ينشئ ملفات ضبط ونصوصًا مرتبطة بـ `twenty` CLI -* يُولّد ضبطًا افتراضيًا للتطبيق ودورًا افتراضيًا للوظيفة +* Generates a default application config, a default function role, and a post-install function يبدو التطبيق المُنشأ حديثًا بالقالب كما يلي: @@ -86,15 +89,16 @@ my-twenty-app/ eslint.config.mjs tsconfig.json README.md - public/ # مجلد الأصول العامة (صور، خطوط، إلخ) + public/ # Public assets folder (images, fonts, etc.) src/ - ├── application-config.ts # مطلوب - التكوين الرئيسي للتطبيق + ├── application-config.ts # Required - main application configuration ├── roles/ - │ └── default-role.ts # الدور الافتراضي لوظائف المنطق + │ └── default-role.ts # Default role for logic functions ├── logic-functions/ - │ └── hello-world.ts # مثال لوظيفة منطقية + │ ├── hello-world.ts # Example logic function + │ └── post-install.ts # Post-install logic function └── front-components/ - └── hello-world.tsx # مثال لمكوّن الواجهة الأمامية + └── hello-world.tsx # Example front component ``` بشكل عام: @@ -290,6 +294,7 @@ export default defineObject({ * **هوية التطبيق**: المعرفات، اسم العرض، والوصف. * **كيفية تشغيل وظائفه**: الدور الذي تستخدمه للأذونات. * **متغيرات (اختياري)**: أزواج مفتاح-قيمة تُعرض لوظائفك كمتغيرات بيئة. +* **(Optional) post-install function**: a logic function that runs after the app is installed. Use `defineApplication()` to define your application configuration: @@ -297,6 +302,7 @@ Use `defineApplication()` to define your application configuration: // src/application-config.ts import { defineApplication } from 'twenty-sdk'; import { DEFAULT_ROLE_UNIVERSAL_IDENTIFIER } from 'src/roles/default-role'; +import { POST_INSTALL_UNIVERSAL_IDENTIFIER } from 'src/logic-functions/post-install'; export default defineApplication({ universalIdentifier: '4ec0391d-18d5-411c-b2f3-266ddc1c3ef7', @@ -312,6 +318,7 @@ export default defineApplication({ }, }, defaultRoleUniversalIdentifier: DEFAULT_ROLE_UNIVERSAL_IDENTIFIER, + postInstallLogicFunctionUniversalIdentifier: POST_INSTALL_UNIVERSAL_IDENTIFIER, }); ``` @@ -320,6 +327,7 @@ export default defineApplication({ * حقول `universalIdentifier` هي معرّفات حتمية تخصك؛ أنشئها مرة واحدة واحتفظ بها ثابتة عبر عمليات المزامنة. * `applicationVariables` تصبح متغيرات بيئة لوظائفك (على سبيل المثال، `DEFAULT_RECIPIENT_NAME` متاح كـ `process.env.DEFAULT_RECIPIENT_NAME`). * `defaultRoleUniversalIdentifier` يجب أن يطابق ملف الدور (انظر أدناه). +* `postInstallLogicFunctionUniversalIdentifier` (optional) points to a logic function that runs automatically after the app is installed. See [Post-install functions](#post-install-functions). #### الأدوار والصلاحيات @@ -458,6 +466,55 @@ export default defineLogicFunction({ * المصفوفة `triggers` اختيارية. يمكن استخدام الوظائف بدون مشغلات كوظائف مساعدة تُستدعى بواسطة وظائف أخرى. * يمكنك مزج أنواع متعددة من المشغلات في وظيفة واحدة. +### Post-install functions + +A post-install function is a logic function that runs automatically after your app is installed on a workspace. This is useful for one-time setup tasks such as seeding default data, creating initial records, or configuring workspace settings. + +When you scaffold a new app with `create-twenty-app`, a post-install function is generated for you at `src/logic-functions/post-install.ts`: + +```typescript +// src/logic-functions/post-install.ts +import { defineLogicFunction } from 'twenty-sdk'; + +export const POST_INSTALL_UNIVERSAL_IDENTIFIER = ''; + +const handler = async (): Promise => { + console.log('Post install logic function executed successfully!'); +}; + +export default defineLogicFunction({ + universalIdentifier: POST_INSTALL_UNIVERSAL_IDENTIFIER, + name: 'post-install', + description: 'Runs after installation to set up the application.', + timeoutSeconds: 300, + handler, +}); +``` + +The function is wired into your app by referencing its universal identifier in `application-config.ts`: + +```typescript +import { POST_INSTALL_UNIVERSAL_IDENTIFIER } from 'src/logic-functions/post-install'; + +export default defineApplication({ + // ... + postInstallLogicFunctionUniversalIdentifier: POST_INSTALL_UNIVERSAL_IDENTIFIER, +}); +``` + +You can also manually execute the post-install function at any time using the CLI: + +```bash filename="Terminal" +yarn twenty function:execute --postInstall +``` + +النقاط الرئيسية: + +* Post-install functions are standard logic functions — they use `defineLogicFunction()` like any other function. +* The `postInstallLogicFunctionUniversalIdentifier` field in `defineApplication()` is optional. If omitted, no function runs after installation. +* The default timeout is set to 300 seconds (5 minutes) to allow for longer setup tasks like data seeding. +* Post-install functions do not need triggers — they are invoked by the platform during installation or manually via `function:execute --postInstall`. + ### حمولة مشغل المسار diff --git a/packages/twenty-docs/l/cs/developers/extend/capabilities/apps.mdx b/packages/twenty-docs/l/cs/developers/extend/capabilities/apps.mdx index de0e21083a..e016981438 100644 --- a/packages/twenty-docs/l/cs/developers/extend/capabilities/apps.mdx +++ b/packages/twenty-docs/l/cs/developers/extend/capabilities/apps.mdx @@ -45,19 +45,22 @@ yarn twenty app:dev Odtud můžete: ```bash filename="Terminal" -# Přidejte do vaší aplikace novou entitu (s průvodcem) +# Add a new entity to your application (guided) yarn twenty entity:add -# Sledujte logy funkcí vaší aplikace +# Watch your application's function logs yarn twenty function:logs -# Spusťte funkci podle názvu +# Execute a function by name yarn twenty function:execute -n my-function -p '{"name": "test"}' -# Odinstalujte aplikaci z aktuálního pracovního prostoru +# Execute the post-install function +yarn twenty function:execute --postInstall + +# Uninstall the application from the current workspace yarn twenty app:uninstall -# Zobrazte nápovědu k příkazům +# Display commands' help yarn twenty help ``` @@ -70,7 +73,7 @@ Když spustíte `npx create-twenty-app@latest my-twenty-app`, scaffolder: * Zkopíruje minimální základní aplikaci do `my-twenty-app/` * Přidá lokální závislost `twenty-sdk` a konfiguraci pro Yarn 4 * Vytvoří konfigurační soubory a skripty napojené na `twenty` CLI -* Vygeneruje výchozí konfiguraci aplikace a výchozí roli funkcí +* Generates a default application config, a default function role, and a post-install function Čerstvě vytvořená aplikace vypadá takto: @@ -86,15 +89,16 @@ my-twenty-app/ eslint.config.mjs tsconfig.json README.md - public/ # Složka s veřejnými prostředky (obrázky, písma apod.) + public/ # Public assets folder (images, fonts, etc.) src/ - ├── application-config.ts # Povinné – hlavní konfigurace aplikace + ├── application-config.ts # Required - main application configuration ├── roles/ - │ └── default-role.ts # Výchozí role pro logické funkce + │ └── default-role.ts # Default role for logic functions ├── logic-functions/ - │ └── hello-world.ts # Ukázková logická funkce + │ ├── hello-world.ts # Example logic function + │ └── post-install.ts # Post-install logic function └── front-components/ - └── hello-world.tsx # Ukázková front-endová komponenta + └── hello-world.tsx # Example front component ``` V kostce: @@ -290,6 +294,7 @@ Každá aplikace má jeden soubor `application-config.ts`, který popisuje: * **Identitu aplikace**: identifikátory, zobrazovaný název a popis. * **Jak běží její funkce**: kterou roli používají pro oprávnění. * **(Volitelné) proměnné**: dvojice klíč–hodnota zpřístupněné vašim funkcím jako proměnné prostředí. +* **(Optional) post-install function**: a logic function that runs after the app is installed. Use `defineApplication()` to define your application configuration: @@ -297,6 +302,7 @@ Use `defineApplication()` to define your application configuration: // src/application-config.ts import { defineApplication } from 'twenty-sdk'; import { DEFAULT_ROLE_UNIVERSAL_IDENTIFIER } from 'src/roles/default-role'; +import { POST_INSTALL_UNIVERSAL_IDENTIFIER } from 'src/logic-functions/post-install'; export default defineApplication({ universalIdentifier: '4ec0391d-18d5-411c-b2f3-266ddc1c3ef7', @@ -312,6 +318,7 @@ export default defineApplication({ }, }, defaultRoleUniversalIdentifier: DEFAULT_ROLE_UNIVERSAL_IDENTIFIER, + postInstallLogicFunctionUniversalIdentifier: POST_INSTALL_UNIVERSAL_IDENTIFIER, }); ``` @@ -320,6 +327,7 @@ Poznámky: * Pole `universalIdentifier` jsou deterministická ID, která vlastníte; vygenerujte je jednou a udržujte je stabilní napříč synchronizacemi. * `applicationVariables` se stanou proměnnými prostředí pro vaše funkce (například `DEFAULT_RECIPIENT_NAME` je dostupné jako `process.env.DEFAULT_RECIPIENT_NAME`). * `defaultRoleUniversalIdentifier` se musí shodovat se souborem role (viz níže). +* `postInstallLogicFunctionUniversalIdentifier` (optional) points to a logic function that runs automatically after the app is installed. See [Post-install functions](#post-install-functions). #### Role a oprávnění @@ -458,6 +466,55 @@ Poznámky: * Pole `triggers` je volitelné. Funkce bez spouštěčů lze použít jako pomocné funkce volané jinými funkcemi. * V jedné funkci můžete kombinovat více typů spouštěčů. +### Post-install functions + +A post-install function is a logic function that runs automatically after your app is installed on a workspace. This is useful for one-time setup tasks such as seeding default data, creating initial records, or configuring workspace settings. + +When you scaffold a new app with `create-twenty-app`, a post-install function is generated for you at `src/logic-functions/post-install.ts`: + +```typescript +// src/logic-functions/post-install.ts +import { defineLogicFunction } from 'twenty-sdk'; + +export const POST_INSTALL_UNIVERSAL_IDENTIFIER = ''; + +const handler = async (): Promise => { + console.log('Post install logic function executed successfully!'); +}; + +export default defineLogicFunction({ + universalIdentifier: POST_INSTALL_UNIVERSAL_IDENTIFIER, + name: 'post-install', + description: 'Runs after installation to set up the application.', + timeoutSeconds: 300, + handler, +}); +``` + +The function is wired into your app by referencing its universal identifier in `application-config.ts`: + +```typescript +import { POST_INSTALL_UNIVERSAL_IDENTIFIER } from 'src/logic-functions/post-install'; + +export default defineApplication({ + // ... + postInstallLogicFunctionUniversalIdentifier: POST_INSTALL_UNIVERSAL_IDENTIFIER, +}); +``` + +You can also manually execute the post-install function at any time using the CLI: + +```bash filename="Terminal" +yarn twenty function:execute --postInstall +``` + +Hlavní body: + +* Post-install functions are standard logic functions — they use `defineLogicFunction()` like any other function. +* The `postInstallLogicFunctionUniversalIdentifier` field in `defineApplication()` is optional. If omitted, no function runs after installation. +* The default timeout is set to 300 seconds (5 minutes) to allow for longer setup tasks like data seeding. +* Post-install functions do not need triggers — they are invoked by the platform during installation or manually via `function:execute --postInstall`. + ### Payload spouštěče trasy diff --git a/packages/twenty-docs/l/de/developers/extend/capabilities/apps.mdx b/packages/twenty-docs/l/de/developers/extend/capabilities/apps.mdx index 39cc38e3ce..4b149cc0d0 100644 --- a/packages/twenty-docs/l/de/developers/extend/capabilities/apps.mdx +++ b/packages/twenty-docs/l/de/developers/extend/capabilities/apps.mdx @@ -45,19 +45,22 @@ yarn twenty app:dev Von hier aus können Sie: ```bash filename="Terminal" -# Eine neue Entität zu Ihrer Anwendung hinzufügen (geführt) +# Add a new entity to your application (guided) yarn twenty entity:add -# Die Funktionsprotokolle Ihrer Anwendung überwachen +# Watch your application's function logs yarn twenty function:logs -# Eine Funktion anhand ihres Namens ausführen +# Execute a function by name yarn twenty function:execute -n my-function -p '{"name": "test"}' -# Die Anwendung aus dem aktuellen Arbeitsbereich deinstallieren +# Execute the post-install function +yarn twenty function:execute --postInstall + +# Uninstall the application from the current workspace yarn twenty app:uninstall -# Hilfe zu Befehlen anzeigen +# Display commands' help yarn twenty help ``` @@ -70,7 +73,7 @@ Wenn Sie `npx create-twenty-app@latest my-twenty-app` ausführen, erledigt der S * Kopiert eine minimale Basisanwendung nach `my-twenty-app/` * Fügt eine lokale `twenty-sdk`-Abhängigkeit und die Yarn-4-Konfiguration hinzu * Erstellt Konfigurationsdateien und Skripte, die an die `twenty`-CLI angebunden sind -* Generiert eine Standard-Anwendungskonfiguration und eine Standard-Funktionsrolle +* Generates a default application config, a default function role, and a post-install function Eine frisch erzeugte App sieht so aus: @@ -92,7 +95,8 @@ my-twenty-app/ ├── roles/ │ └── default-role.ts # Default role for logic functions ├── logic-functions/ - │ └── hello-world.ts # Example logic function + │ ├── hello-world.ts # Example logic function + │ └── post-install.ts # Post-install logic function └── front-components/ └── hello-world.tsx # Example front component ``` @@ -290,6 +294,7 @@ Jede App hat eine einzelne Datei `application-config.ts`, die Folgendes beschrei * **Was die App ist**: Bezeichner, Anzeigename und Beschreibung. * **Wie ihre Funktionen ausgeführt werden**: welche Rolle sie für Berechtigungen verwenden. * **(Optional) Variablen**: Schlüssel–Wert-Paare, die Ihren Funktionen als Umgebungsvariablen zur Verfügung gestellt werden. +* **(Optional) post-install function**: a logic function that runs after the app is installed. Verwenden Sie `defineApplication()`, um Ihre Anwendungskonfiguration zu definieren: @@ -297,6 +302,7 @@ Verwenden Sie `defineApplication()`, um Ihre Anwendungskonfiguration zu definier // src/application-config.ts import { defineApplication } from 'twenty-sdk'; import { DEFAULT_ROLE_UNIVERSAL_IDENTIFIER } from 'src/roles/default-role'; +import { POST_INSTALL_UNIVERSAL_IDENTIFIER } from 'src/logic-functions/post-install'; export default defineApplication({ universalIdentifier: '4ec0391d-18d5-411c-b2f3-266ddc1c3ef7', @@ -312,6 +318,7 @@ export default defineApplication({ }, }, defaultRoleUniversalIdentifier: DEFAULT_ROLE_UNIVERSAL_IDENTIFIER, + postInstallLogicFunctionUniversalIdentifier: POST_INSTALL_UNIVERSAL_IDENTIFIER, }); ``` @@ -320,6 +327,7 @@ Notizen: * `universalIdentifier`-Felder sind deterministische IDs, die Sie besitzen; generieren Sie sie einmal und halten Sie sie über Synchronisierungen hinweg stabil. * `applicationVariables` werden zu Umgebungsvariablen für Ihre Funktionen (zum Beispiel ist `DEFAULT_RECIPIENT_NAME` als `process.env.DEFAULT_RECIPIENT_NAME` verfügbar). * `defaultRoleUniversalIdentifier` muss mit der Rollendatei übereinstimmen (siehe unten). +* `postInstallLogicFunctionUniversalIdentifier` (optional) points to a logic function that runs automatically after the app is installed. See [Post-install functions](#post-install-functions). #### Rollen und Berechtigungen @@ -458,6 +466,55 @@ Notizen: * Das Array `triggers` ist optional. Funktionen ohne Trigger können als von anderen Funktionen aufgerufene Utility-Funktionen verwendet werden. * Sie können mehrere Trigger-Typen in einer Funktion kombinieren. +### Post-install functions + +A post-install function is a logic function that runs automatically after your app is installed on a workspace. This is useful for one-time setup tasks such as seeding default data, creating initial records, or configuring workspace settings. + +When you scaffold a new app with `create-twenty-app`, a post-install function is generated for you at `src/logic-functions/post-install.ts`: + +```typescript +// src/logic-functions/post-install.ts +import { defineLogicFunction } from 'twenty-sdk'; + +export const POST_INSTALL_UNIVERSAL_IDENTIFIER = ''; + +const handler = async (): Promise => { + console.log('Post install logic function executed successfully!'); +}; + +export default defineLogicFunction({ + universalIdentifier: POST_INSTALL_UNIVERSAL_IDENTIFIER, + name: 'post-install', + description: 'Runs after installation to set up the application.', + timeoutSeconds: 300, + handler, +}); +``` + +The function is wired into your app by referencing its universal identifier in `application-config.ts`: + +```typescript +import { POST_INSTALL_UNIVERSAL_IDENTIFIER } from 'src/logic-functions/post-install'; + +export default defineApplication({ + // ... + postInstallLogicFunctionUniversalIdentifier: POST_INSTALL_UNIVERSAL_IDENTIFIER, +}); +``` + +You can also manually execute the post-install function at any time using the CLI: + +```bash filename="Terminal" +yarn twenty function:execute --postInstall +``` + +Hauptpunkte: + +* Post-install functions are standard logic functions — they use `defineLogicFunction()` like any other function. +* The `postInstallLogicFunctionUniversalIdentifier` field in `defineApplication()` is optional. If omitted, no function runs after installation. +* The default timeout is set to 300 seconds (5 minutes) to allow for longer setup tasks like data seeding. +* Post-install functions do not need triggers — they are invoked by the platform during installation or manually via `function:execute --postInstall`. + ### Routen-Trigger-Payload diff --git a/packages/twenty-docs/l/it/developers/extend/capabilities/apps.mdx b/packages/twenty-docs/l/it/developers/extend/capabilities/apps.mdx index c0508458c1..ee3a899554 100644 --- a/packages/twenty-docs/l/it/developers/extend/capabilities/apps.mdx +++ b/packages/twenty-docs/l/it/developers/extend/capabilities/apps.mdx @@ -45,19 +45,22 @@ yarn twenty app:dev Da qui puoi: ```bash filename="Terminal" -# Aggiungi una nuova entità alla tua applicazione (guidata) +# Add a new entity to your application (guided) yarn twenty entity:add -# Monitora i log delle funzioni della tua applicazione +# Watch your application's function logs yarn twenty function:logs -# Esegui una funzione per nome -yarn twenty function:execute -n my-function -p '{\"name\": \"test\"}' +# Execute a function by name +yarn twenty function:execute -n my-function -p '{"name": "test"}' -# Disinstalla l'applicazione dallo spazio di lavoro corrente +# Execute the post-install function +yarn twenty function:execute --postInstall + +# Uninstall the application from the current workspace yarn twenty app:uninstall -# Mostra l'aiuto dei comandi +# Display commands' help yarn twenty help ``` @@ -70,7 +73,7 @@ Quando esegui `npx create-twenty-app@latest my-twenty-app`, lo scaffolder: * Copia un'applicazione base minimale in `my-twenty-app/` * Aggiunge una dipendenza locale `twenty-sdk` e la configurazione di Yarn 4 * Crea file di configurazione e script collegati alla CLI `twenty` -* Genera una configurazione applicativa predefinita e un ruolo funzione predefinito +* Generates a default application config, a default function role, and a post-install function Un'app appena generata dallo scaffolder si presenta così: @@ -86,15 +89,16 @@ my-twenty-app/ eslint.config.mjs tsconfig.json README.md - public/ # Cartella delle risorse pubbliche (immagini, font, ecc.) + public/ # Public assets folder (images, fonts, etc.) src/ - ├── application-config.ts # Obbligatorio - configurazione principale dell'applicazione + ├── application-config.ts # Required - main application configuration ├── roles/ - │ └── default-role.ts # Ruolo predefinito per le funzioni logiche + │ └── default-role.ts # Default role for logic functions ├── logic-functions/ - │ └── hello-world.ts # Funzione logica di esempio + │ ├── hello-world.ts # Example logic function + │ └── post-install.ts # Post-install logic function └── front-components/ - └── hello-world.tsx # Componente front-end di esempio + └── hello-world.tsx # Example front component ``` A livello generale: @@ -290,6 +294,7 @@ Ogni app ha un singolo file `application-config.ts` che descrive: * **Identità dell'app**: identificatori, nome visualizzato e descrizione. * **Come vengono eseguite le sue funzioni**: quale ruolo usano per i permessi. * **Variabili (opzionali)**: coppie chiave–valore esposte alle funzioni come variabili d'ambiente. +* **(Optional) post-install function**: a logic function that runs after the app is installed. Usa `defineApplication()` per definire la configurazione della tua applicazione: @@ -297,6 +302,7 @@ Usa `defineApplication()` per definire la configurazione della tua applicazione: // src/application-config.ts import { defineApplication } from 'twenty-sdk'; import { DEFAULT_ROLE_UNIVERSAL_IDENTIFIER } from 'src/roles/default-role'; +import { POST_INSTALL_UNIVERSAL_IDENTIFIER } from 'src/logic-functions/post-install'; export default defineApplication({ universalIdentifier: '4ec0391d-18d5-411c-b2f3-266ddc1c3ef7', @@ -312,6 +318,7 @@ export default defineApplication({ }, }, defaultRoleUniversalIdentifier: DEFAULT_ROLE_UNIVERSAL_IDENTIFIER, + postInstallLogicFunctionUniversalIdentifier: POST_INSTALL_UNIVERSAL_IDENTIFIER, }); ``` @@ -320,6 +327,7 @@ Note: * I campi `universalIdentifier` sono ID deterministici sotto il tuo controllo; generali una volta e mantienili stabili tra le sincronizzazioni. * `applicationVariables` diventano variabili d'ambiente per le tue funzioni (ad esempio, `DEFAULT_RECIPIENT_NAME` è disponibile come `process.env.DEFAULT_RECIPIENT_NAME`). * `defaultRoleUniversalIdentifier` deve corrispondere al file del ruolo (vedi sotto). +* `postInstallLogicFunctionUniversalIdentifier` (optional) points to a logic function that runs automatically after the app is installed. See [Post-install functions](#post-install-functions). #### Ruoli e permessi @@ -458,6 +466,55 @@ Note: * L'array `triggers` è facoltativo. Le funzioni senza trigger possono essere utilizzate come funzioni di utilità richiamate da altre funzioni. * Puoi combinare più tipi di trigger in un'unica funzione. +### Post-install functions + +A post-install function is a logic function that runs automatically after your app is installed on a workspace. This is useful for one-time setup tasks such as seeding default data, creating initial records, or configuring workspace settings. + +When you scaffold a new app with `create-twenty-app`, a post-install function is generated for you at `src/logic-functions/post-install.ts`: + +```typescript +// src/logic-functions/post-install.ts +import { defineLogicFunction } from 'twenty-sdk'; + +export const POST_INSTALL_UNIVERSAL_IDENTIFIER = ''; + +const handler = async (): Promise => { + console.log('Post install logic function executed successfully!'); +}; + +export default defineLogicFunction({ + universalIdentifier: POST_INSTALL_UNIVERSAL_IDENTIFIER, + name: 'post-install', + description: 'Runs after installation to set up the application.', + timeoutSeconds: 300, + handler, +}); +``` + +The function is wired into your app by referencing its universal identifier in `application-config.ts`: + +```typescript +import { POST_INSTALL_UNIVERSAL_IDENTIFIER } from 'src/logic-functions/post-install'; + +export default defineApplication({ + // ... + postInstallLogicFunctionUniversalIdentifier: POST_INSTALL_UNIVERSAL_IDENTIFIER, +}); +``` + +You can also manually execute the post-install function at any time using the CLI: + +```bash filename="Terminal" +yarn twenty function:execute --postInstall +``` + +Punti chiave: + +* Post-install functions are standard logic functions — they use `defineLogicFunction()` like any other function. +* The `postInstallLogicFunctionUniversalIdentifier` field in `defineApplication()` is optional. If omitted, no function runs after installation. +* The default timeout is set to 300 seconds (5 minutes) to allow for longer setup tasks like data seeding. +* Post-install functions do not need triggers — they are invoked by the platform during installation or manually via `function:execute --postInstall`. + ### Payload del trigger di route diff --git a/packages/twenty-docs/l/pt/developers/extend/capabilities/apps.mdx b/packages/twenty-docs/l/pt/developers/extend/capabilities/apps.mdx index 990d02bf9c..86432a650c 100644 --- a/packages/twenty-docs/l/pt/developers/extend/capabilities/apps.mdx +++ b/packages/twenty-docs/l/pt/developers/extend/capabilities/apps.mdx @@ -45,19 +45,22 @@ yarn twenty app:dev A partir daqui você pode: ```bash filename="Terminal" -# Adicionar uma nova entidade à sua aplicação (assistido) +# Add a new entity to your application (guided) yarn twenty entity:add -# Acompanhar os logs das funções da sua aplicação +# Watch your application's function logs yarn twenty function:logs -# Executar uma função pelo nome +# Execute a function by name yarn twenty function:execute -n my-function -p '{"name": "test"}' -# Desinstalar a aplicação do espaço de trabalho atual +# Execute the post-install function +yarn twenty function:execute --postInstall + +# Uninstall the application from the current workspace yarn twenty app:uninstall -# Exibir a ajuda dos comandos +# Display commands' help yarn twenty help ``` @@ -70,7 +73,7 @@ Ao executar `npx create-twenty-app@latest my-twenty-app`, o gerador: * Copia um aplicativo base mínimo para `my-twenty-app/` * Adiciona uma dependência local `twenty-sdk` e a configuração do Yarn 4 * Cria arquivos de configuração e scripts conectados à CLI `twenty` -* Gera uma configuração de aplicativo padrão e um papel padrão para as funções +* Generates a default application config, a default function role, and a post-install function Um aplicativo recém-criado pelo scaffold fica assim: @@ -86,15 +89,16 @@ my-twenty-app/ eslint.config.mjs tsconfig.json README.md - public/ # Pasta de recursos públicos (imagens, fontes, etc.) + public/ # Public assets folder (images, fonts, etc.) src/ - ├── application-config.ts # Obrigatório - configuração principal da aplicação + ├── application-config.ts # Required - main application configuration ├── roles/ - │ └── default-role.ts # Papel padrão para funções de lógica + │ └── default-role.ts # Default role for logic functions ├── logic-functions/ - │ └── hello-world.ts # Exemplo de função de lógica + │ ├── hello-world.ts # Example logic function + │ └── post-install.ts # Post-install logic function └── front-components/ - └── hello-world.tsx # Exemplo de componente de front-end + └── hello-world.tsx # Example front component ``` Em alto nível: @@ -290,6 +294,7 @@ Todo aplicativo tem um único arquivo `application-config.ts` que descreve: * **O que é o aplicativo**: identificadores, nome de exibição e descrição. * **Como suas funções são executadas**: qual papel usam para permissões. * **Variáveis (opcional)**: pares chave–valor expostos às suas funções como variáveis de ambiente. +* **(Optional) post-install function**: a logic function that runs after the app is installed. Use `defineApplication()` to define your application configuration: @@ -297,6 +302,7 @@ Use `defineApplication()` to define your application configuration: // src/application-config.ts import { defineApplication } from 'twenty-sdk'; import { DEFAULT_ROLE_UNIVERSAL_IDENTIFIER } from 'src/roles/default-role'; +import { POST_INSTALL_UNIVERSAL_IDENTIFIER } from 'src/logic-functions/post-install'; export default defineApplication({ universalIdentifier: '4ec0391d-18d5-411c-b2f3-266ddc1c3ef7', @@ -312,6 +318,7 @@ export default defineApplication({ }, }, defaultRoleUniversalIdentifier: DEFAULT_ROLE_UNIVERSAL_IDENTIFIER, + postInstallLogicFunctionUniversalIdentifier: POST_INSTALL_UNIVERSAL_IDENTIFIER, }); ``` @@ -320,6 +327,7 @@ Notas: * `universalIdentifier` são IDs determinísticos que você controla; gere-os uma vez e mantenha-os estáveis entre sincronizações. * `applicationVariables` tornam-se variáveis de ambiente para suas funções (por exemplo, `DEFAULT_RECIPIENT_NAME` fica disponível como `process.env.DEFAULT_RECIPIENT_NAME`). * `defaultRoleUniversalIdentifier` deve corresponder ao arquivo do papel (veja abaixo). +* `postInstallLogicFunctionUniversalIdentifier` (optional) points to a logic function that runs automatically after the app is installed. See [Post-install functions](#post-install-functions). #### Papéis e permissões @@ -458,6 +466,55 @@ Notas: * O array `triggers` é opcional. Funções sem gatilhos podem ser usadas como funções utilitárias chamadas por outras funções. * Você pode misturar vários tipos de gatilho em uma única função. +### Post-install functions + +A post-install function is a logic function that runs automatically after your app is installed on a workspace. This is useful for one-time setup tasks such as seeding default data, creating initial records, or configuring workspace settings. + +When you scaffold a new app with `create-twenty-app`, a post-install function is generated for you at `src/logic-functions/post-install.ts`: + +```typescript +// src/logic-functions/post-install.ts +import { defineLogicFunction } from 'twenty-sdk'; + +export const POST_INSTALL_UNIVERSAL_IDENTIFIER = ''; + +const handler = async (): Promise => { + console.log('Post install logic function executed successfully!'); +}; + +export default defineLogicFunction({ + universalIdentifier: POST_INSTALL_UNIVERSAL_IDENTIFIER, + name: 'post-install', + description: 'Runs after installation to set up the application.', + timeoutSeconds: 300, + handler, +}); +``` + +The function is wired into your app by referencing its universal identifier in `application-config.ts`: + +```typescript +import { POST_INSTALL_UNIVERSAL_IDENTIFIER } from 'src/logic-functions/post-install'; + +export default defineApplication({ + // ... + postInstallLogicFunctionUniversalIdentifier: POST_INSTALL_UNIVERSAL_IDENTIFIER, +}); +``` + +You can also manually execute the post-install function at any time using the CLI: + +```bash filename="Terminal" +yarn twenty function:execute --postInstall +``` + +Pontos-chave: + +* Post-install functions are standard logic functions — they use `defineLogicFunction()` like any other function. +* The `postInstallLogicFunctionUniversalIdentifier` field in `defineApplication()` is optional. If omitted, no function runs after installation. +* The default timeout is set to 300 seconds (5 minutes) to allow for longer setup tasks like data seeding. +* Post-install functions do not need triggers — they are invoked by the platform during installation or manually via `function:execute --postInstall`. + ### Payload de gatilho de rota diff --git a/packages/twenty-docs/l/ro/developers/extend/capabilities/apps.mdx b/packages/twenty-docs/l/ro/developers/extend/capabilities/apps.mdx index f9a4e3026d..213506abe8 100644 --- a/packages/twenty-docs/l/ro/developers/extend/capabilities/apps.mdx +++ b/packages/twenty-docs/l/ro/developers/extend/capabilities/apps.mdx @@ -54,6 +54,9 @@ yarn twenty function:logs # Execută o funcție după nume yarn twenty function:execute -n my-function -p '{"name": "test"}' +# Execută funcția post-instalare +yarn twenty function:execute --postInstall + # Dezinstalează aplicația din spațiul de lucru curent yarn twenty app:uninstall @@ -70,7 +73,7 @@ Când rulați `npx create-twenty-app@latest my-twenty-app`, generatorul: * Copiază o aplicație de bază minimală în `my-twenty-app/` * Adaugă o dependență locală `twenty-sdk` și configurația Yarn 4 * Creează fișiere de configurare și scripturi conectate la CLI-ul `twenty` -* Generează o configurație implicită a aplicației și un rol implicit pentru funcții +* Generează o configurație implicită a aplicației, un rol implicit pentru funcții și o funcție post-instalare O aplicație nou generată arată astfel: @@ -86,15 +89,16 @@ my-twenty-app/ eslint.config.mjs tsconfig.json README.md - public/ # Public assets folder (images, fonts, etc.) + public/ # Director pentru resurse publice (imagini, fonturi etc.) src/ - ├── application-config.ts # Required - main application configuration + ├── application-config.ts # Obligatoriu - configurația principală a aplicației ├── roles/ - │ └── default-role.ts # Default role for logic functions + │ └── default-role.ts # Rol implicit pentru funcțiile logice ├── logic-functions/ - │ └── hello-world.ts # Example logic function + │ ├── hello-world.ts # Exemplu de funcție logică + │ └── post-install.ts # Funcție logică post-instalare └── front-components/ - └── hello-world.tsx # Example front component + └── hello-world.tsx # Exemplu de componentă de interfață ``` Pe scurt: @@ -290,6 +294,7 @@ Fiecare aplicație are un singur fișier `application-config.ts` care descrie: * **Cine este aplicația**: identificatori, nume de afișare și descriere. * **Cum rulează funcțiile**: ce rol folosesc pentru permisiuni. * **(Opțional) variabile**: perechi cheie–valoare expuse funcțiilor ca variabile de mediu. +* **(Opțional) funcție post-instalare**: o funcție logică care rulează după instalarea aplicației. Folosiți `defineApplication()` pentru a defini configurația aplicației: @@ -297,6 +302,7 @@ Folosiți `defineApplication()` pentru a defini configurația aplicației: // src/application-config.ts import { defineApplication } from 'twenty-sdk'; import { DEFAULT_ROLE_UNIVERSAL_IDENTIFIER } from 'src/roles/default-role'; +import { POST_INSTALL_UNIVERSAL_IDENTIFIER } from 'src/logic-functions/post-install'; export default defineApplication({ universalIdentifier: '4ec0391d-18d5-411c-b2f3-266ddc1c3ef7', @@ -312,6 +318,7 @@ export default defineApplication({ }, }, defaultRoleUniversalIdentifier: DEFAULT_ROLE_UNIVERSAL_IDENTIFIER, + postInstallLogicFunctionUniversalIdentifier: POST_INSTALL_UNIVERSAL_IDENTIFIER, }); ``` @@ -320,6 +327,7 @@ Notițe: * Câmpurile `universalIdentifier` sunt ID-uri deterministe pe care le dețineți; generați-le o singură dată și păstrați-le stabile între sincronizări. * `applicationVariables` devin variabile de mediu pentru funcțiile dvs. (de exemplu, `DEFAULT_RECIPIENT_NAME` este disponibil ca `process.env.DEFAULT_RECIPIENT_NAME`). * `defaultRoleUniversalIdentifier` trebuie să corespundă fișierului de rol (vedeți mai jos). +* `postInstallLogicFunctionUniversalIdentifier` (opțional) indică o funcție logică care rulează automat după instalarea aplicației. Vezi [Funcții post-instalare](#post-install-functions). #### Roluri și permisiuni @@ -458,6 +466,55 @@ Notițe: * Matricea `triggers` este opțională. Funcțiile fără declanșatoare pot fi folosite ca funcții utilitare apelate de alte funcții. * Puteți combina mai multe tipuri de declanșatoare într-o singură funcție. +### Funcții post-instalare + +O funcție post-instalare este o funcție logică care rulează automat după instalarea aplicației într-un spațiu de lucru. Aceasta este utilă pentru sarcini de configurare unice, cum ar fi popularea cu date implicite, crearea înregistrărilor inițiale sau configurarea setărilor spațiului de lucru. + +When you scaffold a new app with `create-twenty-app`, a post-install function is generated for you at `src/logic-functions/post-install.ts`: + +```typescript +// src/logic-functions/post-install.ts +import { defineLogicFunction } from 'twenty-sdk'; + +export const POST_INSTALL_UNIVERSAL_IDENTIFIER = ''; + +const handler = async (): Promise => { + console.log('Post install logic function executed successfully!'); +}; + +export default defineLogicFunction({ + universalIdentifier: POST_INSTALL_UNIVERSAL_IDENTIFIER, + name: 'post-install', + description: 'Runs after installation to set up the application.', + timeoutSeconds: 300, + handler, +}); +``` + +The function is wired into your app by referencing its universal identifier in `application-config.ts`: + +```typescript +import { POST_INSTALL_UNIVERSAL_IDENTIFIER } from 'src/logic-functions/post-install'; + +export default defineApplication({ + // ... + postInstallLogicFunctionUniversalIdentifier: POST_INSTALL_UNIVERSAL_IDENTIFIER, +}); +``` + +You can also manually execute the post-install function at any time using the CLI: + +```bash filename="Terminal" +yarn twenty function:execute --postInstall +``` + +Puncte cheie: + +* Post-install functions are standard logic functions — they use `defineLogicFunction()` like any other function. +* The `postInstallLogicFunctionUniversalIdentifier` field in `defineApplication()` is optional. If omitted, no function runs after installation. +* The default timeout is set to 300 seconds (5 minutes) to allow for longer setup tasks like data seeding. +* Post-install functions do not need triggers — they are invoked by the platform during installation or manually via `function:execute --postInstall`. + ### Payload-ul declanșatorului de rută diff --git a/packages/twenty-docs/l/ru/developers/extend/capabilities/apps.mdx b/packages/twenty-docs/l/ru/developers/extend/capabilities/apps.mdx index a4212b1ac1..e0865944cc 100644 --- a/packages/twenty-docs/l/ru/developers/extend/capabilities/apps.mdx +++ b/packages/twenty-docs/l/ru/developers/extend/capabilities/apps.mdx @@ -45,19 +45,22 @@ yarn twenty app:dev Отсюда вы можете: ```bash filename="Terminal" -# Добавить новую сущность в ваше приложение (с мастером) +# Add a new entity to your application (guided) yarn twenty entity:add -# Просматривать логи функций вашего приложения +# Watch your application's function logs yarn twenty function:logs -# Выполнить функцию по имени -yarn twenty function:execute -n my-function -p '{\"name\": \"test\"}' +# Execute a function by name +yarn twenty function:execute -n my-function -p '{"name": "test"}' -# Удалить приложение из текущего рабочего пространства +# Execute the post-install function +yarn twenty function:execute --postInstall + +# Uninstall the application from the current workspace yarn twenty app:uninstall -# Показать справку по командам +# Display commands' help yarn twenty help ``` @@ -70,7 +73,7 @@ yarn twenty help * Копирует минимальное базовое приложение в `my-twenty-app/` * Добавляет локальную зависимость `twenty-sdk` и конфигурацию Yarn 4 * Создаёт файлы конфигурации и скрипты, подключённые к CLI `twenty` -* Генерирует конфигурацию приложения по умолчанию и роль функции по умолчанию +* Generates a default application config, a default function role, and a post-install function Свежесгенерированное приложение выглядит так: @@ -86,15 +89,16 @@ my-twenty-app/ eslint.config.mjs tsconfig.json README.md - public/ # Папка общедоступных ресурсов (изображения, шрифты и т. п.) + public/ # Public assets folder (images, fonts, etc.) src/ - ├── application-config.ts # Обязательный — основная конфигурация приложения + ├── application-config.ts # Required - main application configuration ├── roles/ - │ └── default-role.ts # Роль по умолчанию для логических функций + │ └── default-role.ts # Default role for logic functions ├── logic-functions/ - │ └── hello-world.ts # Пример логической функции + │ ├── hello-world.ts # Example logic function + │ └── post-install.ts # Post-install logic function └── front-components/ - └── hello-world.tsx # Пример фронтенд-компонента + └── hello-world.tsx # Example front component ``` В общих чертах: @@ -290,6 +294,7 @@ export default defineObject({ * **Что это за приложение**: идентификаторы, отображаемое имя и описание. * **Как запускаются его функции**: какую роль они используют для прав доступа. * **(Необязательно) переменные**: пары ключ-значение, предоставляемые вашим функциям как переменные окружения. +* **(Optional) post-install function**: a logic function that runs after the app is installed. Используйте `defineApplication()` для определения конфигурации вашего приложения: @@ -297,6 +302,7 @@ export default defineObject({ // src/application-config.ts import { defineApplication } from 'twenty-sdk'; import { DEFAULT_ROLE_UNIVERSAL_IDENTIFIER } from 'src/roles/default-role'; +import { POST_INSTALL_UNIVERSAL_IDENTIFIER } from 'src/logic-functions/post-install'; export default defineApplication({ universalIdentifier: '4ec0391d-18d5-411c-b2f3-266ddc1c3ef7', @@ -312,6 +318,7 @@ export default defineApplication({ }, }, defaultRoleUniversalIdentifier: DEFAULT_ROLE_UNIVERSAL_IDENTIFIER, + postInstallLogicFunctionUniversalIdentifier: POST_INSTALL_UNIVERSAL_IDENTIFIER, }); ``` @@ -320,6 +327,7 @@ export default defineApplication({ * `universalIdentifier` — это детерминированные идентификаторы, которыми вы управляете; сгенерируйте их один раз и сохраняйте стабильными между синхронизациями. * `applicationVariables` становятся переменными окружения для ваших функций (например, `DEFAULT_RECIPIENT_NAME` доступна как `process.env.DEFAULT_RECIPIENT_NAME`). * `defaultRoleUniversalIdentifier` должен соответствовать файлу роли (см. ниже). +* `postInstallLogicFunctionUniversalIdentifier` (optional) points to a logic function that runs automatically after the app is installed. See [Post-install functions](#post-install-functions). #### Роли и разрешения @@ -458,6 +466,55 @@ export default defineLogicFunction({ * Массив `triggers` необязателен. Функции без триггеров можно использовать как вспомогательные, вызываемые другими функциями. * Вы можете сочетать несколько типов триггеров в одной функции. +### Post-install functions + +A post-install function is a logic function that runs automatically after your app is installed on a workspace. This is useful for one-time setup tasks such as seeding default data, creating initial records, or configuring workspace settings. + +When you scaffold a new app with `create-twenty-app`, a post-install function is generated for you at `src/logic-functions/post-install.ts`: + +```typescript +// src/logic-functions/post-install.ts +import { defineLogicFunction } from 'twenty-sdk'; + +export const POST_INSTALL_UNIVERSAL_IDENTIFIER = ''; + +const handler = async (): Promise => { + console.log('Post install logic function executed successfully!'); +}; + +export default defineLogicFunction({ + universalIdentifier: POST_INSTALL_UNIVERSAL_IDENTIFIER, + name: 'post-install', + description: 'Runs after installation to set up the application.', + timeoutSeconds: 300, + handler, +}); +``` + +The function is wired into your app by referencing its universal identifier in `application-config.ts`: + +```typescript +import { POST_INSTALL_UNIVERSAL_IDENTIFIER } from 'src/logic-functions/post-install'; + +export default defineApplication({ + // ... + postInstallLogicFunctionUniversalIdentifier: POST_INSTALL_UNIVERSAL_IDENTIFIER, +}); +``` + +You can also manually execute the post-install function at any time using the CLI: + +```bash filename="Terminal" +yarn twenty function:execute --postInstall +``` + +Основные моменты: + +* Post-install functions are standard logic functions — they use `defineLogicFunction()` like any other function. +* The `postInstallLogicFunctionUniversalIdentifier` field in `defineApplication()` is optional. If omitted, no function runs after installation. +* The default timeout is set to 300 seconds (5 minutes) to allow for longer setup tasks like data seeding. +* Post-install functions do not need triggers — they are invoked by the platform during installation or manually via `function:execute --postInstall`. + ### Полезная нагрузка триггера маршрута diff --git a/packages/twenty-docs/l/tr/developers/extend/capabilities/apps.mdx b/packages/twenty-docs/l/tr/developers/extend/capabilities/apps.mdx index ee15434d0c..9198f294bc 100644 --- a/packages/twenty-docs/l/tr/developers/extend/capabilities/apps.mdx +++ b/packages/twenty-docs/l/tr/developers/extend/capabilities/apps.mdx @@ -54,6 +54,9 @@ yarn twenty function:logs # Execute a function by name yarn twenty function:execute -n my-function -p '{"name": "test"}' +# Execute the post-install function +yarn twenty function:execute --postInstall + # Uninstall the application from the current workspace yarn twenty app:uninstall @@ -70,7 +73,7 @@ Ayrıca bkz.: [create-twenty-app](https://www.npmjs.com/package/create-twenty-ap * Minimal bir temel uygulamayı `my-twenty-app/` içine kopyalar * Yerel bir `twenty-sdk` bağımlılığı ve Yarn 4 yapılandırması ekler * `twenty` CLI ile bağlantılı yapılandırma dosyaları ve betikler oluşturur -* Varsayılan bir uygulama yapılandırması ve varsayılan bir fonksiyon rolü üretir +* Generates a default application config, a default function role, and a post-install function Yeni şablondan oluşturulan bir uygulama şöyle görünür: @@ -86,15 +89,16 @@ my-twenty-app/ eslint.config.mjs tsconfig.json README.md - public/ # Genel varlıklar klasörü (görseller, yazı tipleri vb.) + public/ # Public assets folder (images, fonts, etc.) src/ - ├── application-config.ts # Gerekli - ana uygulama yapılandırması + ├── application-config.ts # Required - main application configuration ├── roles/ - │ └── default-role.ts # Mantık işlevleri için varsayılan rol + │ └── default-role.ts # Default role for logic functions ├── logic-functions/ - │ └── hello-world.ts # Örnek mantık işlevi + │ ├── hello-world.ts # Example logic function + │ └── post-install.ts # Post-install logic function └── front-components/ - └── hello-world.tsx # Örnek ön uç bileşeni + └── hello-world.tsx # Example front component ``` Genel hatlarıyla: @@ -290,6 +294,7 @@ Her uygulamanın aşağıdakileri açıklayan tek bir `application-config.ts` do * **Uygulamanın kim olduğu**: tanımlayıcılar, görünen ad ve açıklama. * **Fonksiyonlarının nasıl çalıştığı**: izinler için hangi rolü kullandıkları. * **(İsteğe bağlı) değişkenler**: fonksiyonlarınıza ortam değişkenleri olarak sunulan anahtar–değer çiftleri. +* **(Optional) post-install function**: a logic function that runs after the app is installed. Uygulama yapılandırmanızı tanımlamak için `defineApplication()` kullanın: @@ -297,6 +302,7 @@ Uygulama yapılandırmanızı tanımlamak için `defineApplication()` kullanın: // src/application-config.ts import { defineApplication } from 'twenty-sdk'; import { DEFAULT_ROLE_UNIVERSAL_IDENTIFIER } from 'src/roles/default-role'; +import { POST_INSTALL_UNIVERSAL_IDENTIFIER } from 'src/logic-functions/post-install'; export default defineApplication({ universalIdentifier: '4ec0391d-18d5-411c-b2f3-266ddc1c3ef7', @@ -312,6 +318,7 @@ export default defineApplication({ }, }, defaultRoleUniversalIdentifier: DEFAULT_ROLE_UNIVERSAL_IDENTIFIER, + postInstallLogicFunctionUniversalIdentifier: POST_INSTALL_UNIVERSAL_IDENTIFIER, }); ``` @@ -320,6 +327,7 @@ Notlar: * `universalIdentifier` alanları size ait belirleyici kimliklerdir; bunları bir kez oluşturun ve eşitlemeler boyunca kararlı tutun. * `applicationVariables`, fonksiyonlarınız için ortam değişkenlerine dönüşür (örneğin, `DEFAULT_RECIPIENT_NAME` değeri `process.env.DEFAULT_RECIPIENT_NAME` olarak kullanılabilir). * `defaultRoleUniversalIdentifier`, rol dosyasıyla eşleşmelidir (aşağıya bakın). +* `postInstallLogicFunctionUniversalIdentifier` (optional) points to a logic function that runs automatically after the app is installed. See [Post-install functions](#post-install-functions). #### Roller ve izinler @@ -458,6 +466,55 @@ Notlar: * `triggers` dizisi isteğe bağlıdır. Tetikleyicisi olmayan fonksiyonlar, diğer fonksiyonlar tarafından çağrılan yardımcı fonksiyonlar olarak kullanılabilir. * Tek bir fonksiyonda birden çok tetikleyici türünü birleştirebilirsiniz. +### Post-install functions + +A post-install function is a logic function that runs automatically after your app is installed on a workspace. This is useful for one-time setup tasks such as seeding default data, creating initial records, or configuring workspace settings. + +When you scaffold a new app with `create-twenty-app`, a post-install function is generated for you at `src/logic-functions/post-install.ts`: + +```typescript +// src/logic-functions/post-install.ts +import { defineLogicFunction } from 'twenty-sdk'; + +export const POST_INSTALL_UNIVERSAL_IDENTIFIER = ''; + +const handler = async (): Promise => { + console.log('Post install logic function executed successfully!'); +}; + +export default defineLogicFunction({ + universalIdentifier: POST_INSTALL_UNIVERSAL_IDENTIFIER, + name: 'post-install', + description: 'Runs after installation to set up the application.', + timeoutSeconds: 300, + handler, +}); +``` + +The function is wired into your app by referencing its universal identifier in `application-config.ts`: + +```typescript +import { POST_INSTALL_UNIVERSAL_IDENTIFIER } from 'src/logic-functions/post-install'; + +export default defineApplication({ + // ... + postInstallLogicFunctionUniversalIdentifier: POST_INSTALL_UNIVERSAL_IDENTIFIER, +}); +``` + +You can also manually execute the post-install function at any time using the CLI: + +```bash filename="Terminal" +yarn twenty function:execute --postInstall +``` + +Önemli noktalar: + +* Post-install functions are standard logic functions — they use `defineLogicFunction()` like any other function. +* The `postInstallLogicFunctionUniversalIdentifier` field in `defineApplication()` is optional. If omitted, no function runs after installation. +* The default timeout is set to 300 seconds (5 minutes) to allow for longer setup tasks like data seeding. +* Post-install functions do not need triggers — they are invoked by the platform during installation or manually via `function:execute --postInstall`. + ### Rota tetikleyicisi yükü diff --git a/packages/twenty-docs/l/zh/developers/extend/capabilities/apps.mdx b/packages/twenty-docs/l/zh/developers/extend/capabilities/apps.mdx index 5cfdb1ead3..628a797956 100644 --- a/packages/twenty-docs/l/zh/developers/extend/capabilities/apps.mdx +++ b/packages/twenty-docs/l/zh/developers/extend/capabilities/apps.mdx @@ -45,19 +45,22 @@ yarn twenty app:dev 从这里您可以: ```bash filename="Terminal" -# 向你的应用添加一个新实体(引导式) +# Add a new entity to your application (guided) yarn twenty entity:add -# 监听你的应用函数日志 +# Watch your application's function logs yarn twenty function:logs -# 按名称执行一个函数 +# Execute a function by name yarn twenty function:execute -n my-function -p '{"name": "test"}' -# 从当前工作区卸载该应用 +# Execute the post-install function +yarn twenty function:execute --postInstall + +# Uninstall the application from the current workspace yarn twenty app:uninstall -# 显示命令帮助 +# Display commands' help yarn twenty help ``` @@ -70,7 +73,7 @@ yarn twenty help * 将一个最小的基础应用复制到 `my-twenty-app/` 中 * 添加本地 `twenty-sdk` 依赖和 Yarn 4 配置 * 创建与 `twenty` CLI 关联的配置文件和脚本 -* 生成默认的应用配置和默认的函数角色 +* Generates a default application config, a default function role, and a post-install function 一个新生成的脚手架应用如下所示: @@ -86,15 +89,16 @@ my-twenty-app/ eslint.config.mjs tsconfig.json README.md - public/ # 公共资源文件夹(图像、字体等) + public/ # Public assets folder (images, fonts, etc.) src/ - ├── application-config.ts # 必需 - 主应用程序配置 + ├── application-config.ts # Required - main application configuration ├── roles/ - │ └── default-role.ts # 用于逻辑函数的默认角色 + │ └── default-role.ts # Default role for logic functions ├── logic-functions/ - │ └── hello-world.ts # 示例逻辑函数 + │ ├── hello-world.ts # Example logic function + │ └── post-install.ts # Post-install logic function └── front-components/ - └── hello-world.tsx # 示例前端组件 + └── hello-world.tsx # Example front component ``` 总体来说: @@ -290,6 +294,7 @@ export default defineObject({ * **应用的身份**:标识符、显示名称和描述。 * **函数如何运行**:它们用于权限的角色。 * **(可选)变量**:以环境变量形式提供给函数的键值对。 +* **(Optional) post-install function**: a logic function that runs after the app is installed. 使用 `defineApplication()` 定义你的应用配置: @@ -297,6 +302,7 @@ export default defineObject({ // src/application-config.ts import { defineApplication } from 'twenty-sdk'; import { DEFAULT_ROLE_UNIVERSAL_IDENTIFIER } from 'src/roles/default-role'; +import { POST_INSTALL_UNIVERSAL_IDENTIFIER } from 'src/logic-functions/post-install'; export default defineApplication({ universalIdentifier: '4ec0391d-18d5-411c-b2f3-266ddc1c3ef7', @@ -312,6 +318,7 @@ export default defineApplication({ }, }, defaultRoleUniversalIdentifier: DEFAULT_ROLE_UNIVERSAL_IDENTIFIER, + postInstallLogicFunctionUniversalIdentifier: POST_INSTALL_UNIVERSAL_IDENTIFIER, }); ``` @@ -320,6 +327,7 @@ export default defineApplication({ * `universalIdentifier` 字段是你拥有的确定性 ID;生成一次并在多次同步中保持稳定。 * `applicationVariables` 会变成函数可用的环境变量(例如,`DEFAULT_RECIPIENT_NAME` 可作为 `process.env.DEFAULT_RECIPIENT_NAME` 使用)。 * `defaultRoleUniversalIdentifier` 必须与角色文件一致(见下文)。 +* `postInstallLogicFunctionUniversalIdentifier` (optional) points to a logic function that runs automatically after the app is installed. See [Post-install functions](#post-install-functions). #### 角色和权限 @@ -458,6 +466,55 @@ export default defineLogicFunction({ * `triggers` 数组是可选的。 没有触发器的函数可作为实用函数,被其他函数调用。 * 你可以在单个函数中混用多种触发器类型。 +### Post-install functions + +A post-install function is a logic function that runs automatically after your app is installed on a workspace. This is useful for one-time setup tasks such as seeding default data, creating initial records, or configuring workspace settings. + +When you scaffold a new app with `create-twenty-app`, a post-install function is generated for you at `src/logic-functions/post-install.ts`: + +```typescript +// src/logic-functions/post-install.ts +import { defineLogicFunction } from 'twenty-sdk'; + +export const POST_INSTALL_UNIVERSAL_IDENTIFIER = ''; + +const handler = async (): Promise => { + console.log('Post install logic function executed successfully!'); +}; + +export default defineLogicFunction({ + universalIdentifier: POST_INSTALL_UNIVERSAL_IDENTIFIER, + name: 'post-install', + description: 'Runs after installation to set up the application.', + timeoutSeconds: 300, + handler, +}); +``` + +The function is wired into your app by referencing its universal identifier in `application-config.ts`: + +```typescript +import { POST_INSTALL_UNIVERSAL_IDENTIFIER } from 'src/logic-functions/post-install'; + +export default defineApplication({ + // ... + postInstallLogicFunctionUniversalIdentifier: POST_INSTALL_UNIVERSAL_IDENTIFIER, +}); +``` + +You can also manually execute the post-install function at any time using the CLI: + +```bash filename="Terminal" +yarn twenty function:execute --postInstall +``` + +关键点: + +* Post-install functions are standard logic functions — they use `defineLogicFunction()` like any other function. +* The `postInstallLogicFunctionUniversalIdentifier` field in `defineApplication()` is optional. If omitted, no function runs after installation. +* The default timeout is set to 300 seconds (5 minutes) to allow for longer setup tasks like data seeding. +* Post-install functions do not need triggers — they are invoked by the platform during installation or manually via `function:execute --postInstall`. + ### 路由触发器负载