Channel Developers

thumbnail

Function 登録

このドキュメントは Channel App SDK と一緒に管理されています。最新 package とドキュメント全体の順序は、まず SDK README を確認してください。この Document の基準となる原文は GitHub 原文です。

Function は Channel または他の app が app server に送る typed RPC です。Request の method が Function の完全な name で、params が input です。App 固有 Function は orders.get のような standalone name で登録し、標準 Extension Function は Extension name と relative name を組み合わせます。

受信 call は次の JSON-RPC-like envelope を使用します。

JSON
  • method: discovery が公開する正確な完全 Function name

  • params: schema で検証する untrusted input

  • context: surface に応じた caller、Channel、language、auth、config data

  • systemVersion: 必要な場合に Extension contract version を選択

Public JSON field は TypeScript と Go の両方で camelCase を使用します。Raw body の x-signature 検証に成功した後だけ context を信頼してください。

成功時は result、想定可能な失敗時は structured error を返します。

JSON
JSON

主な code は unprocessable input 1、bad request 2、not found 3、unauthorized 4、method not found -32601、internal error -32603 です。Programmatic handling 用の type は安定させ、 error に credential や customer data を入れないでください。完全な envelope は 共通 protocolを基準にします。

Developer portal には Function root を登録し、AppStore は system version 付き route を呼び出します。

SDK が routing、dispatch、schema validation、error envelope、 extension.core.function.getFunctions discovery を処理します。Raw JSON-RPC router や manual discovery response を別に作らないでください。TypeScript は SignatureGuardrawBody: true、 Go は server.WithSignature で正確な request bytes を検証します。

Decorator API と Zod schema を使用します。

@Extension({ name: "command" }) がある provider の @Func("metadata.getCommands")extension.command.metadata.getCommands になります。Standalone Function のために fake Extension を作らないでください。Discovery されるよう、decorated class を NestJS module の providers に追加します。

Go は builder と generic handler を使用します。

Go

appsdk.Registerappsdk.MustRegister は Go struct から schema を作り、input が Validate() error を実装する場合は自動で呼び出します。明示的な contract には appsdk.InputSchemaappsdk.OutputSchema、proto helper を使用します。

Native Function は逆方向で、app が Channel operation を要求します。TokenManager から app token または channel token を取得し、typed proxy/client を優先してください。固定された document の 一覧ではなく、現在の TypeScript NativeFunctionTypeMap と Go native.Client export が基準です。

他の app または自分の登録済み Function を AppStore 経由で呼ぶ場合は SDK の app-function client を使用します。

Go

有効な access token は business authorization の代わりではありません。Target app、install 済み Channel、caller、requested resource の関係を handler で再確認してください。正確な API は TypeScript Native Function referenceGo Native Function referenceを確認します。

SDK schema と Function name を提供する標準 Extension helper を優先します。Go builder package には extension/configextension/oauthextension/calendarextension/commandextension/widgetextension/customtabextension/hookextension/pollingextension/storeextension/messagingextension/alftaskextension/wms などがあります。 SDK helper がない standalone Function だけを generic registration に分離してください。

次に Command ガイドWAM ガイドExtension 完全ガイド本番運用準備ガイドを確認してください。