@typespec/http-server-js
Version:
TypeSpec HTTP server code generator for JavaScript
174 lines (173 loc) • 9.17 kB
TypeScript
export interface JsEmitterOptions {
/** If set to `true`, the emitter will generate a router that exposes an Express.js middleware function in addition to the ordinary Node.js HTTP server router.
If this option is not set to `true`, the `expressMiddleware` property will not be present on the generated router. */
express?: boolean;
/** By default, the emitter will create interfaces that represent all models in the service namespace. If this option is set
to `true`, the emitter will only emit those types that are reachable from an HTTP operation. */
"omit-unreachable-types": boolean;
/** If set to `true`, the emitter will not format the generated code using Prettier. */
"no-format": boolean;
/**
* The type of datetime models to use for TypeSpecs DateTime and Duration types.
*
* Options:
* - `temporal-polyfill`: (Default) Uses the Temporal API from the `temporal-polyfill` package.
* - `temporal`: Uses the native Temporal API, requires that your target environment supports it. This will become the default setting in the future.
* - `date-duration`: Uses the built-in `Date` and a custom `Duration` type. Not recommended.
*/
datetime?: "temporal-polyfill" | "temporal" | "date-duration";
}
export declare const $lib: import("@typespec/compiler").TypeSpecLibrary<{
"unrecognized-intrinsic": {
readonly default: import("@typespec/compiler").CallableMessage<["intrinsic"]>;
};
"unrecognized-scalar": {
readonly default: import("@typespec/compiler").CallableMessage<["scalar"]>;
};
"unrecognized-encoding": {
readonly default: import("@typespec/compiler").CallableMessage<["encoding", "type"]>;
};
"http-emit-disabled": {
readonly default: "HTTP emit is disabled because the HTTP library returned errors.";
};
"no-services-in-program": {
readonly default: "No services found in program.";
};
"undifferentiable-route": {
readonly default: "Shared route cannot be differentiated from other routes.";
};
"undifferentiable-scalar": {
readonly default: import("@typespec/compiler").CallableMessage<["competitor"]>;
};
"undifferentiable-model": {
readonly default: "Model type does not have enough unique properties to be differentiated from other models in some contexts.";
};
"unrepresentable-numeric-constant": {
readonly default: "JavaScript cannot accurately represent this numeric constant.";
};
"undifferentiable-union-variant": {
readonly default: "Union variant cannot be differentiated from other variants of the union an an ambiguous context.";
};
"unspeakable-status-code": {
readonly default: import("@typespec/compiler").CallableMessage<["name"]>;
};
"name-conflict": {
readonly default: import("@typespec/compiler").CallableMessage<["name"]>;
};
"dynamic-request-content-type": {
readonly default: "Operation has multiple possible content-type values and cannot be emitted.";
};
"openapi3-document-not-generated": {
readonly unable: "@typespec/openapi3 is installed, but the OpenAPI 3 document could not be generated.";
readonly versioned: "An OpenAPI3 document could not be generated for this service because versioned services are not yet supported by the HTTP server emitter for JavaScript.";
};
"unknown-encoding": {
readonly default: import("@typespec/compiler").CallableMessage<["encoding", "target", "type"]>;
};
"unrecognized-media-type": {
readonly default: import("@typespec/compiler").CallableMessage<["mediaType", "type"]>;
};
}, JsEmitterOptions, never>;
declare const reportDiagnostic: <C extends "unrecognized-intrinsic" | "unrecognized-scalar" | "unrecognized-encoding" | "http-emit-disabled" | "no-services-in-program" | "undifferentiable-route" | "undifferentiable-scalar" | "undifferentiable-model" | "unrepresentable-numeric-constant" | "undifferentiable-union-variant" | "unspeakable-status-code" | "name-conflict" | "dynamic-request-content-type" | "openapi3-document-not-generated" | "unknown-encoding" | "unrecognized-media-type", M extends keyof {
"unrecognized-intrinsic": {
readonly default: import("@typespec/compiler").CallableMessage<["intrinsic"]>;
};
"unrecognized-scalar": {
readonly default: import("@typespec/compiler").CallableMessage<["scalar"]>;
};
"unrecognized-encoding": {
readonly default: import("@typespec/compiler").CallableMessage<["encoding", "type"]>;
};
"http-emit-disabled": {
readonly default: "HTTP emit is disabled because the HTTP library returned errors.";
};
"no-services-in-program": {
readonly default: "No services found in program.";
};
"undifferentiable-route": {
readonly default: "Shared route cannot be differentiated from other routes.";
};
"undifferentiable-scalar": {
readonly default: import("@typespec/compiler").CallableMessage<["competitor"]>;
};
"undifferentiable-model": {
readonly default: "Model type does not have enough unique properties to be differentiated from other models in some contexts.";
};
"unrepresentable-numeric-constant": {
readonly default: "JavaScript cannot accurately represent this numeric constant.";
};
"undifferentiable-union-variant": {
readonly default: "Union variant cannot be differentiated from other variants of the union an an ambiguous context.";
};
"unspeakable-status-code": {
readonly default: import("@typespec/compiler").CallableMessage<["name"]>;
};
"name-conflict": {
readonly default: import("@typespec/compiler").CallableMessage<["name"]>;
};
"dynamic-request-content-type": {
readonly default: "Operation has multiple possible content-type values and cannot be emitted.";
};
"openapi3-document-not-generated": {
readonly unable: "@typespec/openapi3 is installed, but the OpenAPI 3 document could not be generated.";
readonly versioned: "An OpenAPI3 document could not be generated for this service because versioned services are not yet supported by the HTTP server emitter for JavaScript.";
};
"unknown-encoding": {
readonly default: import("@typespec/compiler").CallableMessage<["encoding", "target", "type"]>;
};
"unrecognized-media-type": {
readonly default: import("@typespec/compiler").CallableMessage<["mediaType", "type"]>;
};
}[C]>(program: import("@typespec/compiler").Program, diag: import("@typespec/compiler").DiagnosticReport<{
"unrecognized-intrinsic": {
readonly default: import("@typespec/compiler").CallableMessage<["intrinsic"]>;
};
"unrecognized-scalar": {
readonly default: import("@typespec/compiler").CallableMessage<["scalar"]>;
};
"unrecognized-encoding": {
readonly default: import("@typespec/compiler").CallableMessage<["encoding", "type"]>;
};
"http-emit-disabled": {
readonly default: "HTTP emit is disabled because the HTTP library returned errors.";
};
"no-services-in-program": {
readonly default: "No services found in program.";
};
"undifferentiable-route": {
readonly default: "Shared route cannot be differentiated from other routes.";
};
"undifferentiable-scalar": {
readonly default: import("@typespec/compiler").CallableMessage<["competitor"]>;
};
"undifferentiable-model": {
readonly default: "Model type does not have enough unique properties to be differentiated from other models in some contexts.";
};
"unrepresentable-numeric-constant": {
readonly default: "JavaScript cannot accurately represent this numeric constant.";
};
"undifferentiable-union-variant": {
readonly default: "Union variant cannot be differentiated from other variants of the union an an ambiguous context.";
};
"unspeakable-status-code": {
readonly default: import("@typespec/compiler").CallableMessage<["name"]>;
};
"name-conflict": {
readonly default: import("@typespec/compiler").CallableMessage<["name"]>;
};
"dynamic-request-content-type": {
readonly default: "Operation has multiple possible content-type values and cannot be emitted.";
};
"openapi3-document-not-generated": {
readonly unable: "@typespec/openapi3 is installed, but the OpenAPI 3 document could not be generated.";
readonly versioned: "An OpenAPI3 document could not be generated for this service because versioned services are not yet supported by the HTTP server emitter for JavaScript.";
};
"unknown-encoding": {
readonly default: import("@typespec/compiler").CallableMessage<["encoding", "target", "type"]>;
};
"unrecognized-media-type": {
readonly default: import("@typespec/compiler").CallableMessage<["mediaType", "type"]>;
};
}, C, M>) => void, createStateSymbol: (name: string) => symbol;
export { createStateSymbol, reportDiagnostic };
//# sourceMappingURL=lib.d.ts.map