Typert リモート呼び出し
生成された Remote アーティファクト、Host ゲートウェイ、コンシューマー API アセンブリで共有される型です。Typert Gateway Agent Note がアーキテクチャとトランスポートの決定を担います。このページでは、dsh-typert-protocol と dsh-api-gateway のリテラルな公開契約を記録します。
Lookup と Context の宣言
ビジネスオブジェクトのパッケージは、宣言マージによって 2 つの空のマップを拡張します。lookup は 1 つの Host オブジェクト型をそのワイヤ ID に関連付け、Context 宣言は 1 つのスコープ付き Context 種別をそのワイヤ ID に関連付けます。生成された記述子はこれらのキーを指定し、ランタイムプロバイダーはライブの解決動作を提供します。
/** Merge-extensible Host object lookup declarations. */
interface TypertLookupMap {}/** Merge-extensible scoped Context declarations. */
interface TypertContextMap {}レジストリは、リゾルバーがアンロードされた後も lookup のワイヤ宣言を保持します。そのため SRC の検出では、このパラメーターを引き続き lookup として分類し、ワイヤ値を通常のビジネスオブジェクトとして受け入れるのではなく、利用不可として失敗します。
/** Stable wire declaration retained after a lookup provider unloads. */
interface TypertLookupDefinition {
/** Merge-declared lookup key. */
readonly key: string
/** Source parameter name recognized by the SRC weak parser. */
readonly parameter: string
/** Wire field replacing the Host object parameter. */
readonly wire: string
/** Canonical Host type symbol used by strict generation. */
readonly hostTypeSymbol: string
/** Canonical wire type symbol used by strict generation. */
readonly wireTypeSymbol: string
}呼び出し記述子
InvocationDescriptor はワイヤメッセージではなく、ローカルリフレクションです。Host ビルドとコンシューマービルドは対応する記述子を生成します。リクエストが送信するのはエンドポイントと名前付きの args のみです。厳密なコーデックは生成されたスキーマを運び、SRC コーデックは構造型を復元せずに JSON セーフな値を強制します。キャンセルはビジネスパラメーターの後に注入される帯域外のキャリアシグナルであり、args には決して入りません。
/** Codec attached to one invocation parameter or result. */
type TypertCodec =
| {
readonly mode: 'strict'
readonly typeSymbol: string
readonly schema: TypertSchema
}
| {
readonly mode: 'src-json'
}/** One ordered business parameter in a Remote invocation. */
interface InvocationParameterDescriptor {
/** Source-level parameter name. */
readonly name: string
/** Required key in the wire `args` object. */
readonly wire: string
/** Whether the value is JSON or requires a registered Host lookup. */
readonly source: 'json' | 'lookup'
/** Lookup key when `source` is `lookup`. */
readonly lookup?: string
/** Boundary codec for the wire representation. */
readonly codec: TypertCodec
/** Missing wire fields decode to `undefined` only for an explicitly declared `T | undefined`. */
readonly acceptsUndefined?: true
}/** Carrier-independent description of one exported method invocation. */
interface InvocationDescriptor {
/** Globally stable generated identity. */
readonly id: string
/** Cordis service key owning the method. */
readonly service: string
/** Wire namespace, defaulting to the service key. */
readonly namespace: string
/** Public instance method name. */
readonly method: string
/** Service member invoked when the exported method name is an alias. */
readonly implementation?: string
/** Receiver selection mode. */
readonly invocation:
| { readonly kind: 'direct' }
| {
readonly kind: 'context'
readonly context: string
readonly wire: string
readonly codec: TypertCodec
}
/** Optional consuming-Context projection for one direct lookup parameter. */
readonly scope?: {
/** Context kind whose Client binder supplies the identity. */
readonly context: string
/** Lookup parameter wire field replaced by the Context identity. */
readonly wire: string
}
/** Ordered business parameters. */
readonly parameters: readonly InvocationParameterDescriptor[]
/** Transport cancellation injected after business parameters instead of entering wire args. */
readonly cancellation?: {
/** Reserved final Host method parameter. */
readonly parameter: 'signal'
}
/** Codec for the resolved method result. */
readonly result: TypertCodec
/** Source declaration used only for diagnostics. */
readonly sourceLocation?: InvocationSourceLocation
}Typert レジストリ
ctx.typert は、現在の環境の記述子、明示的に選択された Remote コントリビューション、lookup プロバイダー、スコープ付き Context プロバイダーを分離します。lookup プロバイダーは安定したワイヤ宣言とデフォルトリゾルバーを所有します。Host 構成では、同じキーに対してエフェクトスコープの同期または非同期リゾルバーを設定でき、その設定をアンロードするとデフォルトポリシーが復元されます。登録は Cordis 所有のエフェクトであり、await 可能な disposer を返します。
/** Minimal Typert runtime consumed through dependency inversion. */
interface TypertRegistryContract {
readonly local: TypertLocalRegistry
readonly remotes: TypertRemoteRegistry
readonly lookups: TypertLookupRegistry
readonly contexts: TypertContextRegistry
}生成されたコンシューマー宣言は、TypertClientRemote が継承するマップへ直接名前空間をマージします。
/** Merge-extensible direct namespace surface generated for Client Remote services. */
interface TypertRemoteNamespaceMap {}Host ゲートウェイ
Connection は、ctx.typertGateway を呼び出す前にキャリアエンベロープをデコードします。リクエストには正確な名前付きワイヤフィールドと、キャリアのキャンセルシグナルが別途含まれます。インフラストラクチャーおよび境界の失敗には Gateway のプロセス内エラー分類が使用され、通常の例外は RPC アダプターによってトランスポートの internal エラーコードへ畳み込まれます。また、lookup ポリシーが TypertLookupFailure を通じて運ぶ既存の RPC エラーは変更せずに返されます。
/** One Remote method request after a carrier has decoded its envelope. */
interface InvokeRemoteRequest {
/** Remote namespace selected by the generated descriptor. */
readonly namespace: string
/** Exported Service method name. */
readonly method: string
/** Named wire values; fields must exactly match the descriptor. */
readonly args: Readonly<Record<string, unknown>>
/** Carrier or direct-caller cancellation injected only into cancellation-aware methods. */
readonly signal?: AbortSignal
}/** Stable infrastructure and boundary failures emitted before or after business execution. */
type TypertGatewayErrorCode =
| 'ambiguous-endpoint'
| 'arguments-invalid'
| 'binding-invalid'
| 'context-failed'
| 'context-not-found'
| 'context-unavailable'
| 'definition-unavailable'
| 'input-invalid'
| 'invocation-unavailable'
| 'lookup-failed'
| 'lookup-not-found'
| 'lookup-unavailable'
| 'method-unavailable'
| 'provider-mismatch'
| 'result-invalid'
| 'service-unavailable'
| 'signature-invalid'/** Host dispatcher consumed by Connection adapters. */
interface TypertGateway {
/**
* Invoke one live Remote method without assuming a carrier or response envelope.
* @param request - decoded endpoint and named wire arguments.
* @returns the validated business result.
* @throws {@link TypertGatewayError} for dispatch, provider, or boundary failures; lookup-policy and business errors retain identity.
*/
invoke(request: InvokeRemoteRequest): Promise<unknown>
}コンシューマー Remote
ctx.remote は、インポートされた /remote アーティファクトによって提供される名前空間のみを公開します。$mount() は、生成された記述子と具体的なメソッドを、ファイバーが所有する単一の操作としてインストールします。各名前空間は、マウントされたメソッドの存続期間にわたる、トレース対象の remote.<namespace> Cordis 子 Service です。JavaScript Proxy や Host ビジネス Service 型がコンシューマーに入ることはありません。
/** Client Remote capability implemented by the Gateway and consumed by Remote assemblies. */
interface TypertClientRemote extends TypertRemoteNamespaceMap {
/**
* Mount one generated Host-for-Client contribution in the caller's fiber.
* @param contribution - explicitly selected Remote package artifact.
* @returns disposer after namespace services and concrete methods are ready.
*/
$mount(contribution: TypertRemoteContribution): Promise<TypertDisposer>
/**
* Subscribe to one forwarded Host event; delivery is one-way, in registration
* order, and isolates a throwing listener from the rest.
* @template Event - forwarded event name selected by the Host assembly.
* @param event - forwarded Host event name, unchanged on the wire.
* @param listener - receives the Host's argument list as declared by Cordis `Events`.
* @returns disposer owned by the calling fiber.
*/
$on<Event extends TypertRemoteEvent>(event: Event, listener: Events[Event]): () => void
/**
* Hand one decoded forwarded frame to the subscription table. The carrier
* owning the Host frame sink calls this; a consumer subscribes with
* {@link TypertClientRemote.$on} and never calls it.
*
* `event` is a plain string because this is the wire boundary: the name is
* whatever the Host assembly's allowlist selected, and one nobody subscribed
* to is dropped silently.
* @param event - forwarded Host event name, exactly as the Host emitted it.
* @param args - the Host argument list, already JSON-decoded.
*/
$dispatch(event: string, args: readonly unknown[]): void
}Cordis API
scripts/gen-cordis-catalog.ts からソース生成されます(doc-sync で pnpm run verify-cordis-catalog により最新であることを検証し、pnpm run gen-cordis-catalog で再生成します)。このセクションは、ページの両言語版でバイト単位で同一です。シグネチャブロックでは ts cordis-catalog フェンスを使用し、元のソース JSDoc を保持します。ディスパッチモードは 入門 で定義されており、フレームワークから継承される ctx API は cordis-api/inherited.md にあります。
ctx.apiProxy — ApiProxy
統合 API のルートインターフェースです。新しいクライアントリクエストドメインには、新しいファイルペア 1 つ、このフィールド 1 つ、マップ行 1 つを追加します。
/**
* Response entry for server requests; not a domain method.
* @param message - Client response carrying the server request's rpcId.
* @returns Transport receipt for the response delivery.
*/
respond(message: ClientResponse): Promise<RpcReceipt>ソース: packages/host/apiproxy/src/api/index.ts:22
ctx.typert — TypertRegistry
生成されたスキーマ、パッケージリフレクション、呼び出し、Remote 依存プロバイダーのレジストリです。
/**
* Register one generated contribution atomically for the calling fiber.
* Duplicate package-face identities, schemas, invocation ids, or endpoints
* reject the whole batch.
* @param contribution - generated schemas, reflection, and Host invocations.
* @returns the exact effect disposer that removes this contribution.
*/
register(contribution: TypertContribution): TypertDisposer
/**
* Look up one schema by `<package>#<name>`.
* @param key - global schema key.
* @returns the live schema record, or `undefined` when absent.
*/
get(key: string): TypertSchemaRecord | undefined
/**
* Resolve one required schema.
* @param key - global schema key.
* @returns the live schema record.
* @throws when the key is malformed, the package face is absent, or the schema is not contributed.
*/
resolve(key: string): TypertSchemaRecord
/**
* Enumerate live schemas in registration order.
* @param filter - optional package and face restriction.
* @returns matching schema records.
*/
list(filter: TypertSchemaFilter = {}): TypertSchemaRecord[]
/**
* Look up generated reflection for one package face.
* @param packageName - exact npm package name.
* @param face - face to query; defaults to the host runtime.
* @returns the live package record, or `undefined` when absent.
*/
getPackage(packageName: string, face: TypertFace = 'host'): TypertPackageRecord | undefined
/**
* Enumerate generated package reflection in registration order.
* @param filter - optional package and face restriction.
* @returns matching package records.
*/
listPackages(filter: TypertPackageFilter = {}): TypertPackageRecord[]
/**
* Project a live Zod schema to JSON Schema without caching the result.
* @param key - global schema key.
* @param params - Zod projection parameters.
* @returns a fresh JSON Schema document.
*/
toJSONSchema(key: string, params?: z.core.ToJSONSchemaParams): z.core.JSONSchema.BaseSchema型: TypertContribution · TypertFace · TypertPackageFilter · TypertPackageRecord · TypertSchemaFilter · TypertSchemaRecord
ソース: packages/typert/registry/src/service.ts:446
ctx.typertGateway — TypertGatewayService
現在の Cordis Services と Typert プロバイダーに対して、厳密な生成定義または保守的な SRC マーカーを解決します。
/**
* Invoke one live Remote method through strict generated reflection or SRC markers.
* @param request - decoded endpoint and exact named wire arguments.
* @returns the validated business result.
* @throws {@link TypertGatewayError} for dispatch, provider, or boundary failures; lookup-policy and business errors retain identity.
*/
async invoke(request: InvokeRemoteRequest): Promise<unknown>