i18n - docs translations (#23186)
Created by Github action Co-authored-by: github-actions <github-actions@twenty.com>
This commit is contained in:
committed by
GitHub
parent
0108a34765
commit
f52643d170
@@ -42,6 +42,9 @@ export default defineConnectionProvider({
|
||||
// Optional: provider's RFC 7009 token revocation endpoint, called on disconnect.
|
||||
// revokeEndpoint: 'https://example.com/oauth/revoke',
|
||||
},
|
||||
// Optional: a logic function in this app to run right after a connection is
|
||||
// established. See "Run a logic function on connect".
|
||||
// onConnectLogicFunction: { universalIdentifier: '3a2b1c0d-...-...' },
|
||||
});
|
||||
```
|
||||
|
||||
@@ -87,6 +90,40 @@ https://<your-twenty-server>/auth/apps/callback
|
||||
|
||||
</Accordion>
|
||||
|
||||
<Accordion title="تشغيل دالة منطقية عند الاتصال" description="التفاعل فور إنشاء الاتصال">
|
||||
|
||||
بعض المزوّدين يسلّمونك بيانات وقت الاتصال تحتاج إلى الاحتفاظ بها قبل أن يصبح الاتصال قابلاً للاستخدام — المثال الكلاسيكي هو Slack، حيث يحدّد رد OAuth معرّف الفريق `team_id` الخاص بمساحة العمل الذي ستُربط به الأحداث الواردة. عيِّن `onConnectLogicFunction` للإشارة إلى دالة منطقية في التطبيق نفسه (حسب `universalIdentifier` الخاص بها)، وسيتم تشغيلها مباشرة بعد إنشاء `ConnectedAccount`.
|
||||
|
||||
```ts src/connection-providers/slack-connection.ts
|
||||
export default defineConnectionProvider({
|
||||
universalIdentifier: '...',
|
||||
name: 'slack',
|
||||
displayName: 'Slack',
|
||||
type: 'oauth',
|
||||
oauth: {
|
||||
/* ... */
|
||||
},
|
||||
// Runs claimSlackTeam after every successful Slack connection.
|
||||
onConnectLogicFunction: {
|
||||
universalIdentifier: '3a2b1c0d-1111-4222-8333-444455556666',
|
||||
},
|
||||
});
|
||||
```
|
||||
|
||||
يعمل الـ hook **بشكل غير متزامن في مساحة العمل التي تجري الاتصال** (يتم وضعه في قائمة الانتظار، ولا يُنتظر انتهاؤه)، لذلك لن يؤدي hook بطيء أو فاشل إلى حظر أو تعطيل رد نداء OAuth — اجعله قابلاً للتكرار دون آثار جانبية (idempotent) ويتولى إعادة المحاولات بنفسه. يتلقى المعالج:
|
||||
|
||||
```ts
|
||||
type OnConnectPayload = {
|
||||
connectionProviderId: string;
|
||||
connectionProviderName: string; // e.g. 'slack'
|
||||
connectedAccountId: string;
|
||||
};
|
||||
```
|
||||
|
||||
من هناك استخدم `getConnection(connectedAccountId)` لقراءة رمز الوصول الجديد واستدعاء واجهة برمجة تطبيقات المزوّد (على سبيل المثال، Slack `auth.test`) أو حفظ تعيين باستخدام [مخزن المفاتيح والقيم](/l/ar/developers/extend/apps/logic/key-value-store).
|
||||
|
||||
</Accordion>
|
||||
|
||||
<Accordion title="listConnections / getConnection" description="استخدم الاتصالات من دالة منطقية">
|
||||
|
||||
داخل معالج دالة منطقية، تُرجِع `listConnections({ providerName })` صفوف `ConnectedAccount` الخاصة بهذا التطبيق للمزوّد المحدَّد، مع رموز وصول محدَّثة.
|
||||
|
||||
@@ -42,6 +42,9 @@ export default defineConnectionProvider({
|
||||
// Optional: provider's RFC 7009 token revocation endpoint, called on disconnect.
|
||||
// revokeEndpoint: 'https://example.com/oauth/revoke',
|
||||
},
|
||||
// Optional: a logic function in this app to run right after a connection is
|
||||
// established. See "Run a logic function on connect".
|
||||
// onConnectLogicFunction: { universalIdentifier: '3a2b1c0d-...-...' },
|
||||
});
|
||||
```
|
||||
|
||||
@@ -87,6 +90,40 @@ https://<your-twenty-server>/auth/apps/callback
|
||||
|
||||
</Accordion>
|
||||
|
||||
<Accordion title="Spusťte logickou funkci při připojení" description="Reagujte ve chvíli, kdy je připojení navázáno">
|
||||
|
||||
Někteří poskytovatelé vám při připojení předají data, která je potřeba uložit dříve, než lze připojení používat — klasickým příkladem je Slack, kde odpověď OAuth určuje `team_id` pracovního prostoru, podle kterého budou příchozí události indexovány. Nastavte `onConnectLogicFunction` tak, aby odkazovala na logickou funkci ve stejné aplikaci (podle jejího `universalIdentifier`), a ta se spustí hned poté, co je vytvořen `ConnectedAccount`.
|
||||
|
||||
```ts src/connection-providers/slack-connection.ts
|
||||
export default defineConnectionProvider({
|
||||
universalIdentifier: '...',
|
||||
name: 'slack',
|
||||
displayName: 'Slack',
|
||||
type: 'oauth',
|
||||
oauth: {
|
||||
/* ... */
|
||||
},
|
||||
// Runs claimSlackTeam after every successful Slack connection.
|
||||
onConnectLogicFunction: {
|
||||
universalIdentifier: '3a2b1c0d-1111-4222-8333-444455556666',
|
||||
},
|
||||
});
|
||||
```
|
||||
|
||||
Hook běží **asynchronně v připojujícím se pracovním prostoru** (je zařazen do fronty, nečeká se na něj), takže pomalý nebo chybující hook nikdy neblokuje ani nenaruší OAuth callback — udělejte jej idempotentní a zajistěte, aby sám zpracovával opakované pokusy. Obslužná funkce přijímá:
|
||||
|
||||
```ts
|
||||
type OnConnectPayload = {
|
||||
connectionProviderId: string;
|
||||
connectionProviderName: string; // e.g. 'slack'
|
||||
connectedAccountId: string;
|
||||
};
|
||||
```
|
||||
|
||||
Odtud použijte `getConnection(connectedAccountId)` ke čtení čerstvého přístupového tokenu a zavolejte API poskytovatele (např. Slack `auth.test`) nebo uložte mapování pomocí [úložiště klíč–hodnota](/l/cs/developers/extend/apps/logic/key-value-store).
|
||||
|
||||
</Accordion>
|
||||
|
||||
<Accordion title="listConnections / getConnection" description="Použijte připojení z logické funkce">
|
||||
|
||||
Uvnitř handleru logické funkce vrací `listConnections({ providerName })` řádky `ConnectedAccount` této aplikace pro daného poskytovatele s obnovenými přístupovými tokeny.
|
||||
|
||||
@@ -42,6 +42,9 @@ export default defineConnectionProvider({
|
||||
// Optional: provider's RFC 7009 token revocation endpoint, called on disconnect.
|
||||
// revokeEndpoint: 'https://example.com/oauth/revoke',
|
||||
},
|
||||
// Optional: a logic function in this app to run right after a connection is
|
||||
// established. See "Run a logic function on connect".
|
||||
// onConnectLogicFunction: { universalIdentifier: '3a2b1c0d-...-...' },
|
||||
});
|
||||
```
|
||||
|
||||
@@ -87,6 +90,40 @@ https://<your-twenty-server>/auth/apps/callback
|
||||
|
||||
</Accordion>
|
||||
|
||||
<Accordion title="Beim Verbindungsaufbau eine Logikfunktion ausführen" description="Reagiere in dem Moment, in dem eine Verbindung hergestellt wird">
|
||||
|
||||
Einige Anbieter liefern dir beim Verbindungsaufbau Daten, die du persistieren musst, bevor die Verbindung nutzbar ist – das klassische Beispiel ist Slack, bei dem die OAuth-Antwort die `team_id` des Workspaces angibt, anhand derer eingehende Ereignisse zugeordnet werden. Setze `onConnectLogicFunction` so, dass auf eine Logikfunktion in derselben App (über ihren `universalIdentifier`) verwiesen wird; sie wird direkt nach dem Erstellen des `ConnectedAccount` ausgeführt.
|
||||
|
||||
```ts src/connection-providers/slack-connection.ts
|
||||
export default defineConnectionProvider({
|
||||
universalIdentifier: '...',
|
||||
name: 'slack',
|
||||
displayName: 'Slack',
|
||||
type: 'oauth',
|
||||
oauth: {
|
||||
/* ... */
|
||||
},
|
||||
// Runs claimSlackTeam after every successful Slack connection.
|
||||
onConnectLogicFunction: {
|
||||
universalIdentifier: '3a2b1c0d-1111-4222-8333-444455556666',
|
||||
},
|
||||
});
|
||||
```
|
||||
|
||||
Der Hook wird **asynchron im verbindenden Workspace** ausgeführt (er wird in eine Warteschlange gestellt, nicht abgewartet), sodass ein langsamer oder fehlerhafter Hook niemals den OAuth-Callback blockiert oder unterbricht – mache ihn idempotent und lass ihn seine eigenen Wiederholungen handhaben. Der Handler erhält:
|
||||
|
||||
```ts
|
||||
type OnConnectPayload = {
|
||||
connectionProviderId: string;
|
||||
connectionProviderName: string; // e.g. 'slack'
|
||||
connectedAccountId: string;
|
||||
};
|
||||
```
|
||||
|
||||
Verwenden Sie von dort `getConnection(connectedAccountId)`, um das aktuelle Zugriffstoken auszulesen und die API des Anbieters aufzurufen (z. B. Slack `auth.test`) oder eine Zuordnung im [Key-Value Store](/l/de/developers/extend/apps/logic/key-value-store) zu persistieren.
|
||||
|
||||
</Accordion>
|
||||
|
||||
<Accordion title="listConnections / getConnection" description="Verbindungen aus einer Logikfunktion verwenden">
|
||||
|
||||
Innerhalb eines Logikfunktions-Handlers gibt `listConnections({ providerName })` die `ConnectedAccount`-Zeilen dieser App für den angegebenen Anbieter zurück, mit aktualisierten Zugriffstoken.
|
||||
|
||||
@@ -42,6 +42,9 @@ export default defineConnectionProvider({
|
||||
// Optional: provider's RFC 7009 token revocation endpoint, called on disconnect.
|
||||
// revokeEndpoint: 'https://example.com/oauth/revoke',
|
||||
},
|
||||
// Optional: a logic function in this app to run right after a connection is
|
||||
// established. See "Run a logic function on connect".
|
||||
// onConnectLogicFunction: { universalIdentifier: '3a2b1c0d-...-...' },
|
||||
});
|
||||
```
|
||||
|
||||
@@ -87,6 +90,40 @@ https://<your-twenty-server>/auth/apps/callback
|
||||
|
||||
</Accordion>
|
||||
|
||||
<Accordion title="Ejecutar una función de lógica al conectar" description="Reaccionar en el momento en que se establece una conexión">
|
||||
|
||||
Algunos proveedores te entregan datos en el momento de la conexión que necesitas conservar antes de que la conexión sea utilizable: el ejemplo clásico es Slack, donde la respuesta de OAuth identifica el `team_id` del espacio de trabajo con el que se asociarán los eventos entrantes. Establece `onConnectLogicFunction` para que haga referencia a una función de lógica en la misma aplicación (por su `universalIdentifier`), y se ejecutará justo después de que se cree el `ConnectedAccount`.
|
||||
|
||||
```ts src/connection-providers/slack-connection.ts
|
||||
export default defineConnectionProvider({
|
||||
universalIdentifier: '...',
|
||||
name: 'slack',
|
||||
displayName: 'Slack',
|
||||
type: 'oauth',
|
||||
oauth: {
|
||||
/* ... */
|
||||
},
|
||||
// Runs claimSlackTeam after every successful Slack connection.
|
||||
onConnectLogicFunction: {
|
||||
universalIdentifier: '3a2b1c0d-1111-4222-8333-444455556666',
|
||||
},
|
||||
});
|
||||
```
|
||||
|
||||
El hook se ejecuta **de forma asíncrona en el espacio de trabajo que se está conectando** (se pone en cola, no se espera su finalización), por lo que un hook lento o con fallos nunca bloquea ni interrumpe el callback de OAuth; hazlo idempotente y haz que gestione sus propios reintentos. El controlador recibe:
|
||||
|
||||
```ts
|
||||
type OnConnectPayload = {
|
||||
connectionProviderId: string;
|
||||
connectionProviderName: string; // e.g. 'slack'
|
||||
connectedAccountId: string;
|
||||
};
|
||||
```
|
||||
|
||||
A partir de ahí, usa `getConnection(connectedAccountId)` para leer el token de acceso reciente y llamar a la API del proveedor (por ejemplo, Slack `auth.test`) o para conservar un mapeo con el [almacenamiento de pares clave-valor](/l/es/developers/extend/apps/logic/key-value-store).
|
||||
|
||||
</Accordion>
|
||||
|
||||
<Accordion title="listConnections / getConnection" description="Usa conexiones desde una función de lógica">
|
||||
|
||||
Dentro de un controlador de función de lógica, `listConnections({ providerName })` devuelve las filas `ConnectedAccount` de esta aplicación para el proveedor indicado, con tokens de acceso actualizados.
|
||||
|
||||
@@ -42,6 +42,9 @@ export default defineConnectionProvider({
|
||||
// Optional: provider's RFC 7009 token revocation endpoint, called on disconnect.
|
||||
// revokeEndpoint: 'https://example.com/oauth/revoke',
|
||||
},
|
||||
// Optional: a logic function in this app to run right after a connection is
|
||||
// established. See "Run a logic function on connect".
|
||||
// onConnectLogicFunction: { universalIdentifier: '3a2b1c0d-...-...' },
|
||||
});
|
||||
```
|
||||
|
||||
@@ -87,6 +90,40 @@ https://<your-twenty-server>/auth/apps/callback
|
||||
|
||||
</Accordion>
|
||||
|
||||
<Accordion title="Exécuter une fonction logique lors de la connexion" description="Réagir au moment où une connexion est établie">
|
||||
|
||||
Certains fournisseurs vous transmettent, au moment de la connexion, des données que vous devez conserver avant que la connexion ne soit exploitable — l’exemple classique est Slack, où la réponse OAuth identifie le `team_id` de l’espace de travail sur lequel les événements entrants seront indexés. Définissez `onConnectLogicFunction` pour référencer une fonction logique dans la même application (par son `universalIdentifier`), et elle s’exécute juste après la création du `ConnectedAccount`.
|
||||
|
||||
```ts src/connection-providers/slack-connection.ts
|
||||
export default defineConnectionProvider({
|
||||
universalIdentifier: '...',
|
||||
name: 'slack',
|
||||
displayName: 'Slack',
|
||||
type: 'oauth',
|
||||
oauth: {
|
||||
/* ... */
|
||||
},
|
||||
// Runs claimSlackTeam after every successful Slack connection.
|
||||
onConnectLogicFunction: {
|
||||
universalIdentifier: '3a2b1c0d-1111-4222-8333-444455556666',
|
||||
},
|
||||
});
|
||||
```
|
||||
|
||||
Le hook s’exécute **de manière asynchrone dans l’espace de travail en cours de connexion** (il est mis en file d’attente, non attendu), de sorte qu’un hook lent ou défaillant ne bloque ni n’interrompt jamais le callback OAuth — rendez-le idempotent et faites en sorte qu’il gère ses propres réessais. Le gestionnaire reçoit :
|
||||
|
||||
```ts
|
||||
type OnConnectPayload = {
|
||||
connectionProviderId: string;
|
||||
connectionProviderName: string; // e.g. 'slack'
|
||||
connectedAccountId: string;
|
||||
};
|
||||
```
|
||||
|
||||
À partir de là, utilisez `getConnection(connectedAccountId)` pour lire le jeton d’accès actualisé et appeler l’API du fournisseur (par exemple Slack `auth.test`) ou persister un mappage dans le [stockage clé-valeur](/l/fr/developers/extend/apps/logic/key-value-store).
|
||||
|
||||
</Accordion>
|
||||
|
||||
<Accordion title="listConnections / getConnection" description="Utilisez les connexions depuis une fonction logique">
|
||||
|
||||
Dans un gestionnaire de fonction logique, `listConnections({ providerName })` renvoie les lignes `ConnectedAccount` de cette application pour le fournisseur donné, avec des jetons d'accès actualisés.
|
||||
|
||||
@@ -42,6 +42,9 @@ export default defineConnectionProvider({
|
||||
// Optional: provider's RFC 7009 token revocation endpoint, called on disconnect.
|
||||
// revokeEndpoint: 'https://example.com/oauth/revoke',
|
||||
},
|
||||
// Optional: a logic function in this app to run right after a connection is
|
||||
// established. See "Run a logic function on connect".
|
||||
// onConnectLogicFunction: { universalIdentifier: '3a2b1c0d-...-...' },
|
||||
});
|
||||
```
|
||||
|
||||
@@ -87,6 +90,40 @@ https://<your-twenty-server>/auth/apps/callback
|
||||
|
||||
</Accordion>
|
||||
|
||||
<Accordion title="Esegui una funzione logica al momento della connessione" description="Reagisci non appena viene stabilita una connessione">
|
||||
|
||||
Alcuni provider ti forniscono dati al momento della connessione che devi memorizzare prima che la connessione sia utilizzabile — l'esempio classico è Slack, dove la risposta OAuth identifica il `team_id` dell'area di lavoro che fungerà da chiave per gli eventi in ingresso. Imposta `onConnectLogicFunction` per fare riferimento a una funzione logica nella stessa app (tramite il suo `universalIdentifier`), e questa verrà eseguita subito dopo la creazione di `ConnectedAccount`.
|
||||
|
||||
```ts src/connection-providers/slack-connection.ts
|
||||
export default defineConnectionProvider({
|
||||
universalIdentifier: '...',
|
||||
name: 'slack',
|
||||
displayName: 'Slack',
|
||||
type: 'oauth',
|
||||
oauth: {
|
||||
/* ... */
|
||||
},
|
||||
// Runs claimSlackTeam after every successful Slack connection.
|
||||
onConnectLogicFunction: {
|
||||
universalIdentifier: '3a2b1c0d-1111-4222-8333-444455556666',
|
||||
},
|
||||
});
|
||||
```
|
||||
|
||||
L'hook viene eseguito **in modo asincrono nell'area di lavoro che si sta connettendo** (viene messo in coda, non atteso), quindi un hook lento o che fallisce non blocca né interrompe mai il callback OAuth — rendilo idempotente e fai in modo che gestisca autonomamente i propri tentativi di ripetizione. Il gestore riceve:
|
||||
|
||||
```ts
|
||||
type OnConnectPayload = {
|
||||
connectionProviderId: string;
|
||||
connectionProviderName: string; // e.g. 'slack'
|
||||
connectedAccountId: string;
|
||||
};
|
||||
```
|
||||
|
||||
Da lì usa `getConnection(connectedAccountId)` per leggere il token di accesso aggiornato e chiamare l'API del provider (ad es. Slack `auth.test`) o salvare una mappatura con il [key-value store](/l/it/developers/extend/apps/logic/key-value-store).
|
||||
|
||||
</Accordion>
|
||||
|
||||
<Accordion title="listConnections / getConnection" description="Usa le connessioni da una funzione di logica">
|
||||
|
||||
All'interno di un gestore di funzione di logica, `listConnections({ providerName })` restituisce le righe `ConnectedAccount` di questa app per il provider indicato, con token di accesso aggiornati.
|
||||
|
||||
@@ -42,6 +42,9 @@ export default defineConnectionProvider({
|
||||
// Optional: provider's RFC 7009 token revocation endpoint, called on disconnect.
|
||||
// revokeEndpoint: 'https://example.com/oauth/revoke',
|
||||
},
|
||||
// Optional: a logic function in this app to run right after a connection is
|
||||
// established. See "Run a logic function on connect".
|
||||
// onConnectLogicFunction: { universalIdentifier: '3a2b1c0d-...-...' },
|
||||
});
|
||||
```
|
||||
|
||||
@@ -87,6 +90,40 @@ https://<your-twenty-server>/auth/apps/callback
|
||||
|
||||
</Accordion>
|
||||
|
||||
<Accordion title="接続時にロジック関数を実行する" description="接続が確立された瞬間に反応する">
|
||||
|
||||
一部のプロバイダは、接続時に、接続が実際に利用可能になる前に永続化しておく必要があるデータを渡してきます。典型的な例は Slack で、OAuth レスポンスに、受信イベントのキーとして使用されるワークスペースの `team_id` が含まれます。 `onConnectLogicFunction` を、同じアプリ内のロジック関数を `universalIdentifier` で参照するように設定すると、`ConnectedAccount` が作成された直後にその関数が実行されます。
|
||||
|
||||
```ts src/connection-providers/slack-connection.ts
|
||||
export default defineConnectionProvider({
|
||||
universalIdentifier: '...',
|
||||
name: 'slack',
|
||||
displayName: 'Slack',
|
||||
type: 'oauth',
|
||||
oauth: {
|
||||
/* ... */
|
||||
},
|
||||
// Runs claimSlackTeam after every successful Slack connection.
|
||||
onConnectLogicFunction: {
|
||||
universalIdentifier: '3a2b1c0d-1111-4222-8333-444455556666',
|
||||
},
|
||||
});
|
||||
```
|
||||
|
||||
このフックは**接続中のワークスペース内で非同期に**実行されます(待機されずにキューに入れられるため)、フックの実行が遅かったり失敗したりしても OAuth コールバックをブロックしたり壊したりすることは決してありません。冪等性を持たせ、自身でリトライ処理を行うようにしてください。 ハンドラーは次の内容を受け取ります:
|
||||
|
||||
```ts
|
||||
type OnConnectPayload = {
|
||||
connectionProviderId: string;
|
||||
connectionProviderName: string; // e.g. 'slack'
|
||||
connectedAccountId: string;
|
||||
};
|
||||
```
|
||||
|
||||
そこから `getConnection(connectedAccountId)` を使用して最新のアクセストークンを読み取り、プロバイダーの API(例: Slack `auth.test`)を呼び出すか、[key-value store](/l/ja/developers/extend/apps/logic/key-value-store) を使ってマッピングを永続化します。
|
||||
|
||||
</Accordion>
|
||||
|
||||
<Accordion title="listConnections / getConnection" description="ロジック関数から接続を使用する">
|
||||
|
||||
ロジック関数ハンドラー内では、`listConnections({ providerName })` が指定したプロバイダーに対するこのアプリの `ConnectedAccount` 行を、更新済みのアクセストークン付きで返します。
|
||||
|
||||
@@ -42,6 +42,9 @@ export default defineConnectionProvider({
|
||||
// Optional: provider's RFC 7009 token revocation endpoint, called on disconnect.
|
||||
// revokeEndpoint: 'https://example.com/oauth/revoke',
|
||||
},
|
||||
// Optional: a logic function in this app to run right after a connection is
|
||||
// established. See "Run a logic function on connect".
|
||||
// onConnectLogicFunction: { universalIdentifier: '3a2b1c0d-...-...' },
|
||||
});
|
||||
```
|
||||
|
||||
@@ -87,6 +90,40 @@ https://<your-twenty-server>/auth/apps/callback
|
||||
|
||||
</Accordion>
|
||||
|
||||
<Accordion title="연결 시 로직 함수 실행하기" description="연결이 성립되는 즉시 반응하기">
|
||||
|
||||
일부 공급자는 연결 시점에, 연결을 실제로 사용할 수 있게 되기 전에 유지해야 하는 데이터를 제공하기도 합니다. 대표적인 예로 Slack의 경우 OAuth 응답에, 수신 이벤트를 키로 사용할 워크스페이스의 `team_id`가 포함됩니다. `onConnectLogicFunction`을 동일한 앱의 로직 함수(그 로직 함수의 `universalIdentifier`로 식별)에 연결하면, `ConnectedAccount`가 생성된 직후 해당 로직 함수가 실행됩니다.
|
||||
|
||||
```ts src/connection-providers/slack-connection.ts
|
||||
export default defineConnectionProvider({
|
||||
universalIdentifier: '...',
|
||||
name: 'slack',
|
||||
displayName: 'Slack',
|
||||
type: 'oauth',
|
||||
oauth: {
|
||||
/* ... */
|
||||
},
|
||||
// Runs claimSlackTeam after every successful Slack connection.
|
||||
onConnectLogicFunction: {
|
||||
universalIdentifier: '3a2b1c0d-1111-4222-8333-444455556666',
|
||||
},
|
||||
});
|
||||
```
|
||||
|
||||
이 훅은 **연결 중인 워크스페이스에서 비동기적으로 실행**됩니다(대기하지 않고 큐에 넣어 처리하므로), 훅이 느리게 동작하거나 실패하더라도 OAuth 콜백을 절대 차단하거나 중단하지 않습니다. 따라서 멱등적으로 구현하고, 재시도를 스스로 처리하도록 하십시오. 핸들러는 다음을 수신합니다:
|
||||
|
||||
```ts
|
||||
type OnConnectPayload = {
|
||||
connectionProviderId: string;
|
||||
connectionProviderName: string; // e.g. 'slack'
|
||||
connectedAccountId: string;
|
||||
};
|
||||
```
|
||||
|
||||
이후에는 `getConnection(connectedAccountId)`를 사용하여 최신 액세스 토큰을 읽고, 공급자의 API(예: Slack `auth.test`)를 호출하거나 [key-value store](/l/ko/developers/extend/apps/logic/key-value-store)에 매핑을 저장합니다.
|
||||
|
||||
</Accordion>
|
||||
|
||||
<Accordion title="listConnections / getConnection" description="로직 함수에서 연결 사용">
|
||||
|
||||
로직 함수 핸들러 내부에서 `listConnections({ providerName })`는 지정된 제공자에 대한 이 앱의 `ConnectedAccount` 행을 갱신된 액세스 토큰과 함께 반환합니다.
|
||||
|
||||
@@ -42,6 +42,9 @@ export default defineConnectionProvider({
|
||||
// Optional: provider's RFC 7009 token revocation endpoint, called on disconnect.
|
||||
// revokeEndpoint: 'https://example.com/oauth/revoke',
|
||||
},
|
||||
// Optional: a logic function in this app to run right after a connection is
|
||||
// established. See "Run a logic function on connect".
|
||||
// onConnectLogicFunction: { universalIdentifier: '3a2b1c0d-...-...' },
|
||||
});
|
||||
```
|
||||
|
||||
@@ -87,6 +90,40 @@ https://<your-twenty-server>/auth/apps/callback
|
||||
|
||||
</Accordion>
|
||||
|
||||
<Accordion title="Execute uma função lógica ao conectar" description="Reaja no momento em que uma conexão é estabelecida">
|
||||
|
||||
Alguns provedores fornecem dados no momento da conexão que você precisa manter antes que a conexão possa ser usada — o exemplo clássico é o Slack, em que a resposta OAuth identifica o `team_id` do workspace pelo qual os eventos de entrada serão indexados. Defina `onConnectLogicFunction` para fazer referência a uma função lógica no mesmo app (pelo seu `universalIdentifier`), e ela será executada logo após o `ConnectedAccount` ser criado.
|
||||
|
||||
```ts src/connection-providers/slack-connection.ts
|
||||
export default defineConnectionProvider({
|
||||
universalIdentifier: '...',
|
||||
name: 'slack',
|
||||
displayName: 'Slack',
|
||||
type: 'oauth',
|
||||
oauth: {
|
||||
/* ... */
|
||||
},
|
||||
// Runs claimSlackTeam after every successful Slack connection.
|
||||
onConnectLogicFunction: {
|
||||
universalIdentifier: '3a2b1c0d-1111-4222-8333-444455556666',
|
||||
},
|
||||
});
|
||||
```
|
||||
|
||||
O hook é executado **de forma assíncrona no workspace que está se conectando** (ele é enfileirado, não aguardado), portanto um hook lento ou com falha nunca bloqueia ou quebra o callback OAuth — torne-o idempotente e faça com que ele mesmo gerencie suas próprias novas tentativas. O manipulador recebe:
|
||||
|
||||
```ts
|
||||
type OnConnectPayload = {
|
||||
connectionProviderId: string;
|
||||
connectionProviderName: string; // e.g. 'slack'
|
||||
connectedAccountId: string;
|
||||
};
|
||||
```
|
||||
|
||||
A partir daí, use `getConnection(connectedAccountId)` para ler o token de acesso atualizado e chamar a API do provedor (por exemplo, Slack `auth.test`) ou persistir um mapeamento com o [armazenamento de chave-valor](/l/pt/developers/extend/apps/logic/key-value-store).
|
||||
|
||||
</Accordion>
|
||||
|
||||
<Accordion title="listConnections / getConnection" description="Use conexões a partir de uma função de lógica">
|
||||
|
||||
Dentro de um handler de função de lógica, `listConnections({ providerName })` retorna as linhas `ConnectedAccount` deste app para o provedor fornecido, com tokens de acesso atualizados.
|
||||
|
||||
@@ -42,6 +42,9 @@ export default defineConnectionProvider({
|
||||
// Optional: provider's RFC 7009 token revocation endpoint, called on disconnect.
|
||||
// revokeEndpoint: 'https://example.com/oauth/revoke',
|
||||
},
|
||||
// Optional: a logic function in this app to run right after a connection is
|
||||
// established. See "Run a logic function on connect".
|
||||
// onConnectLogicFunction: { universalIdentifier: '3a2b1c0d-...-...' },
|
||||
});
|
||||
```
|
||||
|
||||
@@ -87,6 +90,40 @@ https://<your-twenty-server>/auth/apps/callback
|
||||
|
||||
</Accordion>
|
||||
|
||||
<Accordion title="Rulează o funcție logică la conectare" description="Reacționează în momentul în care o conexiune este stabilită">
|
||||
|
||||
Unii furnizori îți furnizează date în momentul conectării, pe care trebuie să le stochezi înainte ca conexiunea să poată fi utilizată — exemplul clasic este Slack, unde răspunsul OAuth identifică `team_id` al spațiului de lucru după care vor fi indexate evenimentele primite. Setează `onConnectLogicFunction` pentru a face referire la o funcție logică din aceeași aplicație (prin `universalIdentifier`), iar aceasta rulează imediat după ce `ConnectedAccount` este creat.
|
||||
|
||||
```ts src/connection-providers/slack-connection.ts
|
||||
export default defineConnectionProvider({
|
||||
universalIdentifier: '...',
|
||||
name: 'slack',
|
||||
displayName: 'Slack',
|
||||
type: 'oauth',
|
||||
oauth: {
|
||||
/* ... */
|
||||
},
|
||||
// Runs claimSlackTeam after every successful Slack connection.
|
||||
onConnectLogicFunction: {
|
||||
universalIdentifier: '3a2b1c0d-1111-4222-8333-444455556666',
|
||||
},
|
||||
});
|
||||
```
|
||||
|
||||
Hook-ul rulează **asincron în spațiul de lucru care se conectează** (este pus în coadă, nu este așteptat), astfel încât un hook lent sau care eșuează nu blochează și nu întrerupe niciodată callback-ul OAuth — fă-l idempotent și lasă-l să își gestioneze singur reîncercările. Handlerul primește:
|
||||
|
||||
```ts
|
||||
type OnConnectPayload = {
|
||||
connectionProviderId: string;
|
||||
connectionProviderName: string; // e.g. 'slack'
|
||||
connectedAccountId: string;
|
||||
};
|
||||
```
|
||||
|
||||
De acolo folosește `getConnection(connectedAccountId)` pentru a citi tokenul de acces proaspăt și a apela API-ul furnizorului (de ex. Slack `auth.test`) sau pentru a stoca o mapare în [magazinul cheie–valoare](/l/ro/developers/extend/apps/logic/key-value-store).
|
||||
|
||||
</Accordion>
|
||||
|
||||
<Accordion title="listConnections / getConnection" description="Folosește conexiunile dintr-o funcție logică">
|
||||
|
||||
În interiorul unui handler de funcție logică, `listConnections({ providerName })` returnează înregistrările `ConnectedAccount` ale acestei aplicații pentru furnizorul dat, cu tokenuri de acces reîmprospătate.
|
||||
|
||||
@@ -42,6 +42,9 @@ export default defineConnectionProvider({
|
||||
// Optional: provider's RFC 7009 token revocation endpoint, called on disconnect.
|
||||
// revokeEndpoint: 'https://example.com/oauth/revoke',
|
||||
},
|
||||
// Optional: a logic function in this app to run right after a connection is
|
||||
// established. See "Run a logic function on connect".
|
||||
// onConnectLogicFunction: { universalIdentifier: '3a2b1c0d-...-...' },
|
||||
});
|
||||
```
|
||||
|
||||
@@ -87,6 +90,40 @@ https://<your-twenty-server>/auth/apps/callback
|
||||
|
||||
</Accordion>
|
||||
|
||||
<Accordion title="Bağlanıldığında bir mantık fonksiyonu çalıştırın" description="Bir bağlantı kurulur kurulmaz tepki verin">
|
||||
|
||||
Bazı sağlayıcılar, bağlantı anında size, bağlantı kullanılabilir hale gelmeden önce kalıcı hale getirmeniz gereken veriler verir — klasik örnek Slack'tir; burada OAuth yanıtı, gelen olayların anahtarlanacağı çalışma alanının `team_id` bilgisini sağlar. `onConnectLogicFunction` değerini, aynı uygulamadaki bir mantık fonksiyonuna (onun `universalIdentifier` değeriyle) referans verecek şekilde ayarlayın; böylece `ConnectedAccount` oluşturulduktan hemen sonra çalışır.
|
||||
|
||||
```ts src/connection-providers/slack-connection.ts
|
||||
export default defineConnectionProvider({
|
||||
universalIdentifier: '...',
|
||||
name: 'slack',
|
||||
displayName: 'Slack',
|
||||
type: 'oauth',
|
||||
oauth: {
|
||||
/* ... */
|
||||
},
|
||||
// Runs claimSlackTeam after every successful Slack connection.
|
||||
onConnectLogicFunction: {
|
||||
universalIdentifier: '3a2b1c0d-1111-4222-8333-444455556666',
|
||||
},
|
||||
});
|
||||
```
|
||||
|
||||
Kanca, **bağlanan çalışma alanında eşzamansız olarak** çalışır (kuyruğa alınır, beklenmez), bu nedenle yavaşlayan veya başarısız olan bir kanca hiçbir zaman OAuth geri çağrısını engellemez veya bozmaz — onu idempotent yapın ve kendi tekrar denemelerini kendisi yönetsin. İşleyici şunları alır:
|
||||
|
||||
```ts
|
||||
type OnConnectPayload = {
|
||||
connectionProviderId: string;
|
||||
connectionProviderName: string; // e.g. 'slack'
|
||||
connectedAccountId: string;
|
||||
};
|
||||
```
|
||||
|
||||
Buradan `getConnection(connectedAccountId)` kullanarak yeni erişim belirtecini okuyun ve sağlayıcının API'sini (ör. Slack `auth.test`) çağırın veya [key-value store](/l/tr/developers/extend/apps/logic/key-value-store) ile bir eşleme kalıcı hale getirin.
|
||||
|
||||
</Accordion>
|
||||
|
||||
<Accordion title="listConnections / getConnection" description="Bir mantık işlevinden bağlantıları kullanın">
|
||||
|
||||
Bir mantık işlevi işleyicisi içinde, `listConnections({ providerName })`, verilen sağlayıcı için bu uygulamanın `ConnectedAccount` satırlarını, yenilenmiş erişim belirteçleriyle döndürür.
|
||||
|
||||
@@ -42,6 +42,9 @@ export default defineConnectionProvider({
|
||||
// Optional: provider's RFC 7009 token revocation endpoint, called on disconnect.
|
||||
// revokeEndpoint: 'https://example.com/oauth/revoke',
|
||||
},
|
||||
// Optional: a logic function in this app to run right after a connection is
|
||||
// established. See "Run a logic function on connect".
|
||||
// onConnectLogicFunction: { universalIdentifier: '3a2b1c0d-...-...' },
|
||||
});
|
||||
```
|
||||
|
||||
@@ -87,6 +90,40 @@ https://<your-twenty-server>/auth/apps/callback
|
||||
|
||||
</Accordion>
|
||||
|
||||
<Accordion title="在连接时运行逻辑函数" description="在连接建立时立即响应">
|
||||
|
||||
某些提供方会在连接时向你提供数据,而在连接真正可用之前,你需要先持久化这些数据——一个典型示例是 Slack,其中 OAuth 响应会标识工作区的 `team_id`,后续传入事件将会基于该值进行关联。 将 `onConnectLogicFunction` 设置为引用同一应用中的某个逻辑函数(通过其 `universalIdentifier`),该函数会在创建 `ConnectedAccount` 之后立即运行。
|
||||
|
||||
```ts src/connection-providers/slack-connection.ts
|
||||
export default defineConnectionProvider({
|
||||
universalIdentifier: '...',
|
||||
name: 'slack',
|
||||
displayName: 'Slack',
|
||||
type: 'oauth',
|
||||
oauth: {
|
||||
/* ... */
|
||||
},
|
||||
// Runs claimSlackTeam after every successful Slack connection.
|
||||
onConnectLogicFunction: {
|
||||
universalIdentifier: '3a2b1c0d-1111-4222-8333-444455556666',
|
||||
},
|
||||
});
|
||||
```
|
||||
|
||||
该钩子**在发起连接的工作区中以异步方式运行**(它会入队执行,而不是被等待),因此缓慢或失败的钩子永远不会阻塞或破坏 OAuth 回调——请确保该钩子是幂等的,并能自行处理重试。 处理程序会接收到:
|
||||
|
||||
```ts
|
||||
type OnConnectPayload = {
|
||||
connectionProviderId: string;
|
||||
connectionProviderName: string; // e.g. 'slack'
|
||||
connectedAccountId: string;
|
||||
};
|
||||
```
|
||||
|
||||
接下来,使用 `getConnection(connectedAccountId)` 读取最新的访问令牌,并调用提供商的 API(例如 Slack `auth.test`),或者使用[key-value store](/l/zh/developers/extend/apps/logic/key-value-store) 持久化映射。
|
||||
|
||||
</Accordion>
|
||||
|
||||
<Accordion title="listConnections / getConnection" description="在逻辑函数中使用连接">
|
||||
|
||||
在逻辑函数处理器内,`listConnections({ providerName })` 会返回此应用针对给定提供方的 `ConnectedAccount` 行,并附带已刷新的访问令牌。
|
||||
|
||||
Reference in New Issue
Block a user