Typert 원격 호출
생성된 Remote 아티팩트, Host 게이트웨이 및 소비자 API 어셈블리에서 공유하는 타입입니다. Typert Gateway Agent Note에서 아키텍처와 전송 결정 사항을 담당하며, 이 페이지에는 dsh-typert-protocol 및 dsh-api-gateway의 리터럴 공개 계약을 기록합니다.
Lookup 및 Context 선언
비즈니스 객체 패키지는 선언 병합을 통해 두 개의 빈 맵을 확장합니다. lookup은 하나의 Host 객체 타입을 해당 와이어 식별자와 연결하고, Context 선언은 하나의 범위가 지정된 Context 종류를 해당 와이어 식별자와 연결합니다. 생성된 디스크립터는 이러한 키의 이름을 지정하고, 런타임 공급자는 실제 해석 동작을 제공합니다.
/** Merge-extensible Host object lookup declarations. */
interface TypertLookupMap {}/** Merge-extensible scoped Context declarations. */
interface TypertContextMap {}레지스트리는 resolver가 언로드된 후에도 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 공급자는 안정적인 와이어 선언과 기본 resolver를 소유합니다. Host 구성은 동일한 키에 대해 효과 범위의 동기 또는 비동기 resolver를 설정할 수 있으며, 해당 구성을 언로드하면 기본 정책이 복원됩니다. 등록은 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()은(는) 생성된 디스크립터와 구체적인 메서드를 fiber 소유의 단일 작업으로 설치합니다. 각 네임스페이스는 마운트된 메서드의 수명 동안 유지되는 추적 가능한 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의 루트 인터페이스입니다. 새 클라이언트 요청 도메인 하나는 새 파일 쌍 하나, 이 위치의 필드 하나, 맵 행 하나로 구성됩니다.
/**
* 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>