@typespec/http-server-js
Version:
TypeSpec HTTP server code generator for JavaScript
33 lines • 1.74 kB
TypeScript
import { ModelProperty, Scalar, Type } from "@typespec/compiler";
import { Encoder } from "../common/scalar.js";
import { JsContext, Module } from "../ctx.js";
/**
* A resolved encoding chain for a model property or scalar.
*/
export interface ResolvedEncodingChain {
/**
* The canonical type of the property -- a.k.a. the logical type that the service implementor will use.
*/
canonicalType: Type;
/**
* The ultimate encoding target. This will always be the same as the `.type` of the last encoder in the chain, or
* the same as the canonical type if there are no encoders.
*/
targetType: Type;
/**
* The chain of encoders tht apply to the canonical type. These are applied in order front-to-back to encode the
* canonical type into the target type, and are applied back-to-front to decode the canonical type from the target type.
*/
encoders: Encoder[];
}
/**
* Resolves the chain of `@encode` encoders that apply to a given property with a given canonical (logical) type.
*
* @param ctx - The context to use for resolving encoders.
* @param module - The module that the property is defined in.
* @param encodeSource - The original property to resolve encoders for.
* @param canonicalType - The canonical type of the property -- this might be different from the type of the property itself.
* @returns A resolved encoding chain describing the final canonical type, the ultimate target type of the chain, and the encoders that apply to the property in order.
*/
export declare function resolveEncodingChain(ctx: JsContext, module: Module, encodeSource: ModelProperty | Scalar, canonicalType: Type): ResolvedEncodingChain;
//# sourceMappingURL=encoding.d.ts.map