@typespec/http-server-js 0.58.0-alpha.10-dev.3
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/CHANGELOG.md +69 -0
- package/LICENSE +21 -0
- package/README.md +183 -0
- package/build-helpers.ts +170 -0
- package/dist/generated-defs/helpers/header.d.ts +4 -0
- package/dist/generated-defs/helpers/header.d.ts.map +1 -0
- package/dist/generated-defs/helpers/header.js +76 -0
- package/dist/generated-defs/helpers/header.js.map +1 -0
- package/dist/generated-defs/helpers/http.d.ts +4 -0
- package/dist/generated-defs/helpers/http.d.ts.map +1 -0
- package/dist/generated-defs/helpers/http.js +134 -0
- package/dist/generated-defs/helpers/http.js.map +1 -0
- package/dist/generated-defs/helpers/index.d.ts +4 -0
- package/dist/generated-defs/helpers/index.d.ts.map +1 -0
- package/dist/generated-defs/helpers/index.js +21 -0
- package/dist/generated-defs/helpers/index.js.map +1 -0
- package/dist/generated-defs/helpers/multipart.d.ts +4 -0
- package/dist/generated-defs/helpers/multipart.d.ts.map +1 -0
- package/dist/generated-defs/helpers/multipart.js +249 -0
- package/dist/generated-defs/helpers/multipart.js.map +1 -0
- package/dist/generated-defs/helpers/router.d.ts +4 -0
- package/dist/generated-defs/helpers/router.d.ts.map +1 -0
- package/dist/generated-defs/helpers/router.js +259 -0
- package/dist/generated-defs/helpers/router.js.map +1 -0
- package/dist/src/common/declaration.d.ts +13 -0
- package/dist/src/common/declaration.d.ts.map +1 -0
- package/dist/src/common/declaration.js +45 -0
- package/dist/src/common/declaration.js.map +1 -0
- package/dist/src/common/documentation.d.ts +12 -0
- package/dist/src/common/documentation.d.ts.map +1 -0
- package/dist/src/common/documentation.js +21 -0
- package/dist/src/common/documentation.js.map +1 -0
- package/dist/src/common/enum.d.ts +10 -0
- package/dist/src/common/enum.d.ts.map +1 -0
- package/dist/src/common/enum.js +21 -0
- package/dist/src/common/enum.js.map +1 -0
- package/dist/src/common/interface.d.ts +50 -0
- package/dist/src/common/interface.d.ts.map +1 -0
- package/dist/src/common/interface.js +194 -0
- package/dist/src/common/interface.js.map +1 -0
- package/dist/src/common/model.d.ts +26 -0
- package/dist/src/common/model.d.ts.map +1 -0
- package/dist/src/common/model.js +115 -0
- package/dist/src/common/model.js.map +1 -0
- package/dist/src/common/namespace.d.ts +38 -0
- package/dist/src/common/namespace.d.ts.map +1 -0
- package/dist/src/common/namespace.js +184 -0
- package/dist/src/common/namespace.js.map +1 -0
- package/dist/src/common/reference.d.ts +46 -0
- package/dist/src/common/reference.d.ts.map +1 -0
- package/dist/src/common/reference.js +243 -0
- package/dist/src/common/reference.js.map +1 -0
- package/dist/src/common/scalar.d.ts +50 -0
- package/dist/src/common/scalar.d.ts.map +1 -0
- package/dist/src/common/scalar.js +144 -0
- package/dist/src/common/scalar.js.map +1 -0
- package/dist/src/common/serialization/index.d.ts +11 -0
- package/dist/src/common/serialization/index.d.ts.map +1 -0
- package/dist/src/common/serialization/index.js +72 -0
- package/dist/src/common/serialization/index.js.map +1 -0
- package/dist/src/common/serialization/json.d.ts +6 -0
- package/dist/src/common/serialization/json.d.ts.map +1 -0
- package/dist/src/common/serialization/json.js +341 -0
- package/dist/src/common/serialization/json.js.map +1 -0
- package/dist/src/common/union.d.ts +23 -0
- package/dist/src/common/union.d.ts.map +1 -0
- package/dist/src/common/union.js +57 -0
- package/dist/src/common/union.js.map +1 -0
- package/dist/src/ctx.d.ts +242 -0
- package/dist/src/ctx.d.ts.map +1 -0
- package/dist/src/ctx.js +211 -0
- package/dist/src/ctx.js.map +1 -0
- package/dist/src/helpers/header.d.ts +14 -0
- package/dist/src/helpers/header.d.ts.map +1 -0
- package/dist/src/helpers/header.js +38 -0
- package/dist/src/helpers/header.js.map +1 -0
- package/dist/src/helpers/http.d.ts +70 -0
- package/dist/src/helpers/http.d.ts.map +1 -0
- package/dist/src/helpers/http.js +86 -0
- package/dist/src/helpers/http.js.map +1 -0
- package/dist/src/helpers/multipart.d.ts +26 -0
- package/dist/src/helpers/multipart.d.ts.map +1 -0
- package/dist/src/helpers/multipart.js +182 -0
- package/dist/src/helpers/multipart.js.map +1 -0
- package/dist/src/helpers/router.d.ts +176 -0
- package/dist/src/helpers/router.d.ts.map +1 -0
- package/dist/src/helpers/router.js +55 -0
- package/dist/src/helpers/router.js.map +1 -0
- package/dist/src/http/index.d.ts +24 -0
- package/dist/src/http/index.d.ts.map +1 -0
- package/dist/src/http/index.js +52 -0
- package/dist/src/http/index.js.map +1 -0
- package/dist/src/http/server/index.d.ts +11 -0
- package/dist/src/http/server/index.d.ts.map +1 -0
- package/dist/src/http/server/index.js +413 -0
- package/dist/src/http/server/index.js.map +1 -0
- package/dist/src/http/server/multipart.d.ts +16 -0
- package/dist/src/http/server/multipart.d.ts.map +1 -0
- package/dist/src/http/server/multipart.js +214 -0
- package/dist/src/http/server/multipart.js.map +1 -0
- package/dist/src/http/server/router.d.ts +15 -0
- package/dist/src/http/server/router.d.ts.map +1 -0
- package/dist/src/http/server/router.js +459 -0
- package/dist/src/http/server/router.js.map +1 -0
- package/dist/src/index.d.ts +5 -0
- package/dist/src/index.d.ts.map +1 -0
- package/dist/src/index.js +38 -0
- package/dist/src/index.js.map +1 -0
- package/dist/src/lib.d.ts +141 -0
- package/dist/src/lib.d.ts.map +1 -0
- package/dist/src/lib.js +116 -0
- package/dist/src/lib.js.map +1 -0
- package/dist/src/scripts/scaffold/bin.d.mts +14 -0
- package/dist/src/scripts/scaffold/bin.d.mts.map +1 -0
- package/dist/src/scripts/scaffold/bin.mjs +559 -0
- package/dist/src/scripts/scaffold/bin.mjs.map +1 -0
- package/dist/src/testing/index.d.ts +3 -0
- package/dist/src/testing/index.d.ts.map +1 -0
- package/dist/src/testing/index.js +6 -0
- package/dist/src/testing/index.js.map +1 -0
- package/dist/src/util/case.d.ts +81 -0
- package/dist/src/util/case.d.ts.map +1 -0
- package/dist/src/util/case.js +111 -0
- package/dist/src/util/case.js.map +1 -0
- package/dist/src/util/differentiate.d.ts +251 -0
- package/dist/src/util/differentiate.d.ts.map +1 -0
- package/dist/src/util/differentiate.js +580 -0
- package/dist/src/util/differentiate.js.map +1 -0
- package/dist/src/util/error.d.ts +13 -0
- package/dist/src/util/error.d.ts.map +1 -0
- package/dist/src/util/error.js +25 -0
- package/dist/src/util/error.js.map +1 -0
- package/dist/src/util/extends.d.ts +10 -0
- package/dist/src/util/extends.d.ts.map +1 -0
- package/dist/src/util/extends.js +31 -0
- package/dist/src/util/extends.js.map +1 -0
- package/dist/src/util/iter.d.ts +39 -0
- package/dist/src/util/iter.d.ts.map +1 -0
- package/dist/src/util/iter.js +72 -0
- package/dist/src/util/iter.js.map +1 -0
- package/dist/src/util/keywords.d.ts +10 -0
- package/dist/src/util/keywords.d.ts.map +1 -0
- package/dist/src/util/keywords.js +85 -0
- package/dist/src/util/keywords.js.map +1 -0
- package/dist/src/util/name.d.ts +12 -0
- package/dist/src/util/name.d.ts.map +1 -0
- package/dist/src/util/name.js +26 -0
- package/dist/src/util/name.js.map +1 -0
- package/dist/src/util/once-queue.d.ts +24 -0
- package/dist/src/util/once-queue.d.ts.map +1 -0
- package/dist/src/util/once-queue.js +34 -0
- package/dist/src/util/once-queue.js.map +1 -0
- package/dist/src/util/openapi3.d.ts +23 -0
- package/dist/src/util/openapi3.d.ts.map +1 -0
- package/dist/src/util/openapi3.js +40 -0
- package/dist/src/util/openapi3.js.map +1 -0
- package/dist/src/util/pluralism.d.ts +23 -0
- package/dist/src/util/pluralism.d.ts.map +1 -0
- package/dist/src/util/pluralism.js +36 -0
- package/dist/src/util/pluralism.js.map +1 -0
- package/dist/src/util/scope.d.ts +85 -0
- package/dist/src/util/scope.d.ts.map +1 -0
- package/dist/src/util/scope.js +111 -0
- package/dist/src/util/scope.js.map +1 -0
- package/dist/src/write.d.ts +23 -0
- package/dist/src/write.d.ts.map +1 -0
- package/dist/src/write.js +62 -0
- package/dist/src/write.js.map +1 -0
- package/generated-defs/helpers/header.ts +83 -0
- package/generated-defs/helpers/http.ts +141 -0
- package/generated-defs/helpers/index.ts +27 -0
- package/generated-defs/helpers/multipart.ts +256 -0
- package/generated-defs/helpers/router.ts +266 -0
- package/package.json +71 -0
- package/src/common/declaration.ts +52 -0
- package/src/common/documentation.ts +26 -0
- package/src/common/enum.ts +28 -0
- package/src/common/interface.ts +264 -0
- package/src/common/model.ts +160 -0
- package/src/common/namespace.ts +243 -0
- package/src/common/reference.ts +319 -0
- package/src/common/scalar.ts +173 -0
- package/src/common/serialization/index.ts +124 -0
- package/src/common/serialization/json.ts +444 -0
- package/src/common/union.ts +76 -0
- package/src/ctx.ts +497 -0
- package/src/helpers/header.ts +55 -0
- package/src/helpers/http.ts +113 -0
- package/src/helpers/multipart.ts +228 -0
- package/src/helpers/router.ts +238 -0
- package/src/http/index.ts +81 -0
- package/src/http/server/index.ts +548 -0
- package/src/http/server/multipart.ts +272 -0
- package/src/http/server/router.ts +686 -0
- package/src/index.ts +56 -0
- package/src/lib.ts +130 -0
- package/src/scripts/scaffold/bin.mts +781 -0
- package/src/testing/index.ts +10 -0
- package/src/util/case.ts +182 -0
- package/src/util/differentiate.ts +957 -0
- package/src/util/error.ts +28 -0
- package/src/util/extends.ts +43 -0
- package/src/util/iter.ts +85 -0
- package/src/util/keywords.ts +90 -0
- package/src/util/name.ts +33 -0
- package/src/util/once-queue.ts +55 -0
- package/src/util/openapi3.ts +53 -0
- package/src/util/pluralism.ts +37 -0
- package/src/util/scope.ts +211 -0
- package/src/write.ts +88 -0
- package/temp/tsconfig.tsbuildinfo +1 -0
- package/test/header.test.ts +26 -0
- package/test/multipart.test.ts +169 -0
- package/tsconfig.json +10 -0
- package/vitest.config.ts +4 -0
|
@@ -0,0 +1,12 @@
|
|
|
1
|
+
import { Type } from "@typespec/compiler";
|
|
2
|
+
import { JsContext } from "../ctx.js";
|
|
3
|
+
/**
|
|
4
|
+
* Emit the documentation for a type in JSDoc format.
|
|
5
|
+
*
|
|
6
|
+
* This assumes that the documentation may include Markdown formatting.
|
|
7
|
+
*
|
|
8
|
+
* @param ctx - The emitter context.
|
|
9
|
+
* @param type - The type to emit documentation for.
|
|
10
|
+
*/
|
|
11
|
+
export declare function emitDocumentation(ctx: JsContext, type: Type): Iterable<string>;
|
|
12
|
+
//# sourceMappingURL=documentation.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"documentation.d.ts","sourceRoot":"","sources":["../../../src/common/documentation.ts"],"names":[],"mappings":"AAGA,OAAO,EAAE,IAAI,EAAU,MAAM,oBAAoB,CAAC;AAClD,OAAO,EAAE,SAAS,EAAE,MAAM,WAAW,CAAC;AAGtC;;;;;;;GAOG;AACH,wBAAiB,iBAAiB,CAAC,GAAG,EAAE,SAAS,EAAE,IAAI,EAAE,IAAI,GAAG,QAAQ,CAAC,MAAM,CAAC,CAU/E"}
|
|
@@ -0,0 +1,21 @@
|
|
|
1
|
+
// Copyright (c) Microsoft Corporation
|
|
2
|
+
// Licensed under the MIT license.
|
|
3
|
+
import { getDoc } from "@typespec/compiler";
|
|
4
|
+
import { indent } from "../util/iter.js";
|
|
5
|
+
/**
|
|
6
|
+
* Emit the documentation for a type in JSDoc format.
|
|
7
|
+
*
|
|
8
|
+
* This assumes that the documentation may include Markdown formatting.
|
|
9
|
+
*
|
|
10
|
+
* @param ctx - The emitter context.
|
|
11
|
+
* @param type - The type to emit documentation for.
|
|
12
|
+
*/
|
|
13
|
+
export function* emitDocumentation(ctx, type) {
|
|
14
|
+
const doc = getDoc(ctx.program, type);
|
|
15
|
+
if (doc === undefined)
|
|
16
|
+
return;
|
|
17
|
+
yield `/**`;
|
|
18
|
+
yield* indent(doc.trim().split(/\r?\n/g), " * ");
|
|
19
|
+
yield ` */`;
|
|
20
|
+
}
|
|
21
|
+
//# sourceMappingURL=documentation.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"documentation.js","sourceRoot":"","sources":["../../../src/common/documentation.ts"],"names":[],"mappings":"AAAA,sCAAsC;AACtC,kCAAkC;AAElC,OAAO,EAAQ,MAAM,EAAE,MAAM,oBAAoB,CAAC;AAElD,OAAO,EAAE,MAAM,EAAE,MAAM,iBAAiB,CAAC;AAEzC;;;;;;;GAOG;AACH,MAAM,SAAS,CAAC,CAAC,iBAAiB,CAAC,GAAc,EAAE,IAAU;IAC3D,MAAM,GAAG,GAAG,MAAM,CAAC,GAAG,CAAC,OAAO,EAAE,IAAI,CAAC,CAAC;IAEtC,IAAI,GAAG,KAAK,SAAS;QAAE,OAAO;IAE9B,MAAM,KAAK,CAAC;IAEZ,KAAK,CAAC,CAAC,MAAM,CAAC,GAAG,CAAC,IAAI,EAAE,CAAC,KAAK,CAAC,QAAQ,CAAC,EAAE,KAAK,CAAC,CAAC;IAEjD,MAAM,KAAK,CAAC;AACd,CAAC"}
|
|
@@ -0,0 +1,10 @@
|
|
|
1
|
+
import { Enum } from "@typespec/compiler";
|
|
2
|
+
import { JsContext } from "../ctx.js";
|
|
3
|
+
/**
|
|
4
|
+
* Emit an enum declaration.
|
|
5
|
+
*
|
|
6
|
+
* @param ctx - The emitter context.
|
|
7
|
+
* @param enum_ - The enum to emit.
|
|
8
|
+
*/
|
|
9
|
+
export declare function emitEnum(ctx: JsContext, enum_: Enum): Iterable<string>;
|
|
10
|
+
//# sourceMappingURL=enum.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"enum.d.ts","sourceRoot":"","sources":["../../../src/common/enum.ts"],"names":[],"mappings":"AAGA,OAAO,EAAE,IAAI,EAAE,MAAM,oBAAoB,CAAC;AAC1C,OAAO,EAAE,SAAS,EAAE,MAAM,WAAW,CAAC;AAItC;;;;;GAKG;AACH,wBAAiB,QAAQ,CAAC,GAAG,EAAE,SAAS,EAAE,KAAK,EAAE,IAAI,GAAG,QAAQ,CAAC,MAAM,CAAC,CAavE"}
|
|
@@ -0,0 +1,21 @@
|
|
|
1
|
+
// Copyright (c) Microsoft Corporation
|
|
2
|
+
// Licensed under the MIT license.
|
|
3
|
+
import { parseCase } from "../util/case.js";
|
|
4
|
+
import { emitDocumentation } from "./documentation.js";
|
|
5
|
+
/**
|
|
6
|
+
* Emit an enum declaration.
|
|
7
|
+
*
|
|
8
|
+
* @param ctx - The emitter context.
|
|
9
|
+
* @param enum_ - The enum to emit.
|
|
10
|
+
*/
|
|
11
|
+
export function* emitEnum(ctx, enum_) {
|
|
12
|
+
yield* emitDocumentation(ctx, enum_);
|
|
13
|
+
const name = parseCase(enum_.name);
|
|
14
|
+
yield `export enum ${name.pascalCase} {`;
|
|
15
|
+
for (const member of enum_.members.values()) {
|
|
16
|
+
const nameCase = parseCase(member.name);
|
|
17
|
+
yield ` ${nameCase.pascalCase} = ${JSON.stringify(member.value)},`;
|
|
18
|
+
}
|
|
19
|
+
yield `}`;
|
|
20
|
+
}
|
|
21
|
+
//# sourceMappingURL=enum.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"enum.js","sourceRoot":"","sources":["../../../src/common/enum.ts"],"names":[],"mappings":"AAAA,sCAAsC;AACtC,kCAAkC;AAIlC,OAAO,EAAE,SAAS,EAAE,MAAM,iBAAiB,CAAC;AAC5C,OAAO,EAAE,iBAAiB,EAAE,MAAM,oBAAoB,CAAC;AAEvD;;;;;GAKG;AACH,MAAM,SAAS,CAAC,CAAC,QAAQ,CAAC,GAAc,EAAE,KAAW;IACnD,KAAK,CAAC,CAAC,iBAAiB,CAAC,GAAG,EAAE,KAAK,CAAC,CAAC;IAErC,MAAM,IAAI,GAAG,SAAS,CAAC,KAAK,CAAC,IAAI,CAAC,CAAC;IAEnC,MAAM,eAAe,IAAI,CAAC,UAAU,IAAI,CAAC;IAEzC,KAAK,MAAM,MAAM,IAAI,KAAK,CAAC,OAAO,CAAC,MAAM,EAAE,EAAE,CAAC;QAC5C,MAAM,QAAQ,GAAG,SAAS,CAAC,MAAM,CAAC,IAAI,CAAC,CAAC;QACxC,MAAM,KAAK,QAAQ,CAAC,UAAU,MAAM,IAAI,CAAC,SAAS,CAAC,MAAM,CAAC,KAAK,CAAC,GAAG,CAAC;IACtE,CAAC;IAED,MAAM,GAAG,CAAC;AACZ,CAAC"}
|
|
@@ -0,0 +1,50 @@
|
|
|
1
|
+
import { Interface, Operation, Type, UnionVariant } from "@typespec/compiler";
|
|
2
|
+
import { JsContext, Module, PathCursor } from "../ctx.js";
|
|
3
|
+
/**
|
|
4
|
+
* Emit an interface declaration.
|
|
5
|
+
*
|
|
6
|
+
* @param ctx - The emitter context.
|
|
7
|
+
* @param iface - The interface to emit.
|
|
8
|
+
* @param module - The module that this interface is written into.
|
|
9
|
+
*/
|
|
10
|
+
export declare function emitInterface(ctx: JsContext, iface: Interface, module: Module): Iterable<string>;
|
|
11
|
+
/**
|
|
12
|
+
* Emit a list of operation signatures.
|
|
13
|
+
*
|
|
14
|
+
* @param ctx - The emitter context.
|
|
15
|
+
* @param operations - The operations to emit.
|
|
16
|
+
* @param module - The module that the operations are written into.
|
|
17
|
+
*/
|
|
18
|
+
export declare function emitOperationGroup(ctx: JsContext, operations: Iterable<Operation>, module: Module): Iterable<string>;
|
|
19
|
+
/**
|
|
20
|
+
* Emit a single operation signature.
|
|
21
|
+
*
|
|
22
|
+
* @param ctx - The emitter context.
|
|
23
|
+
* @param op - The operation to emit.
|
|
24
|
+
* @param module - The module that the operation is written into.
|
|
25
|
+
*/
|
|
26
|
+
export declare function emitOperation(ctx: JsContext, op: Operation, module: Module): Iterable<string>;
|
|
27
|
+
/**
|
|
28
|
+
* Emit a declaration for an options type including the optional parameters of an operation.
|
|
29
|
+
*
|
|
30
|
+
* @param ctx - The emitter context.
|
|
31
|
+
* @param operation - The operation to emit the options type for.
|
|
32
|
+
* @param module - The module that the options type is written into.
|
|
33
|
+
* @param optionsTypeName - The name of the options type.
|
|
34
|
+
*/
|
|
35
|
+
export declare function emitOptionsType(ctx: JsContext, operation: Operation, module: Module, optionsTypeName: string): void;
|
|
36
|
+
export interface SplitReturnTypeCommon {
|
|
37
|
+
typeReference: string;
|
|
38
|
+
target: Type | [PathCursor, string] | undefined;
|
|
39
|
+
}
|
|
40
|
+
export interface OrdinarySplitReturnType extends SplitReturnTypeCommon {
|
|
41
|
+
kind: "ordinary";
|
|
42
|
+
}
|
|
43
|
+
export interface UnionSplitReturnType extends SplitReturnTypeCommon {
|
|
44
|
+
kind: "union";
|
|
45
|
+
variants: UnionVariant[];
|
|
46
|
+
}
|
|
47
|
+
export type SplitReturnType = OrdinarySplitReturnType | UnionSplitReturnType;
|
|
48
|
+
export declare function isInfallible(split: SplitReturnType): boolean;
|
|
49
|
+
export declare function splitReturnType(ctx: JsContext, type: Type, module: Module, altBaseName: string): [SplitReturnType, SplitReturnType];
|
|
50
|
+
//# sourceMappingURL=interface.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"interface.d.ts","sourceRoot":"","sources":["../../../src/common/interface.ts"],"names":[],"mappings":"AAGA,OAAO,EAAE,SAAS,EAAE,SAAS,EAAE,IAAI,EAAE,YAAY,EAAgB,MAAM,oBAAoB,CAAC;AAC5F,OAAO,EAAE,SAAS,EAAE,MAAM,EAAE,UAAU,EAAE,MAAM,WAAW,CAAC;AAQ1D;;;;;;GAMG;AACH,wBAAiB,aAAa,CAAC,GAAG,EAAE,SAAS,EAAE,KAAK,EAAE,SAAS,EAAE,MAAM,EAAE,MAAM,GAAG,QAAQ,CAAC,MAAM,CAAC,CAQjG;AAED;;;;;;GAMG;AACH,wBAAiB,kBAAkB,CACjC,GAAG,EAAE,SAAS,EACd,UAAU,EAAE,QAAQ,CAAC,SAAS,CAAC,EAC/B,MAAM,EAAE,MAAM,GACb,QAAQ,CAAC,MAAM,CAAC,CAKlB;AAED;;;;;;GAMG;AACH,wBAAiB,aAAa,CAAC,GAAG,EAAE,SAAS,EAAE,EAAE,EAAE,SAAS,EAAE,MAAM,EAAE,MAAM,GAAG,QAAQ,CAAC,MAAM,CAAC,CAmD9F;AAED;;;;;;;GAOG;AACH,wBAAgB,eAAe,CAC7B,GAAG,EAAE,SAAS,EACd,SAAS,EAAE,SAAS,EACpB,MAAM,EAAE,MAAM,EACd,eAAe,EAAE,MAAM,QAmBxB;AAED,MAAM,WAAW,qBAAqB;IACpC,aAAa,EAAE,MAAM,CAAC;IACtB,MAAM,EAAE,IAAI,GAAG,CAAC,UAAU,EAAE,MAAM,CAAC,GAAG,SAAS,CAAC;CACjD;AAED,MAAM,WAAW,uBAAwB,SAAQ,qBAAqB;IACpE,IAAI,EAAE,UAAU,CAAC;CAClB;AAED,MAAM,WAAW,oBAAqB,SAAQ,qBAAqB;IACjE,IAAI,EAAE,OAAO,CAAC;IACd,QAAQ,EAAE,YAAY,EAAE,CAAC;CAC1B;AAED,MAAM,MAAM,eAAe,GAAG,uBAAuB,GAAG,oBAAoB,CAAC;AAS7E,wBAAgB,YAAY,CAAC,KAAK,EAAE,eAAe,GAAG,OAAO,CAK5D;AAED,wBAAgB,eAAe,CAC7B,GAAG,EAAE,SAAS,EACd,IAAI,EAAE,IAAI,EACV,MAAM,EAAE,MAAM,EACd,WAAW,EAAE,MAAM,GAClB,CAAC,eAAe,EAAE,eAAe,CAAC,CAwFpC"}
|
|
@@ -0,0 +1,194 @@
|
|
|
1
|
+
// Copyright (c) Microsoft Corporation
|
|
2
|
+
// Licensed under the MIT license.
|
|
3
|
+
import { isErrorModel } from "@typespec/compiler";
|
|
4
|
+
import { parseCase } from "../util/case.js";
|
|
5
|
+
import { getAllProperties } from "../util/extends.js";
|
|
6
|
+
import { bifilter, indent } from "../util/iter.js";
|
|
7
|
+
import { emitDocumentation } from "./documentation.js";
|
|
8
|
+
import { emitTypeReference, isValueLiteralType } from "./reference.js";
|
|
9
|
+
import { emitUnionType } from "./union.js";
|
|
10
|
+
/**
|
|
11
|
+
* Emit an interface declaration.
|
|
12
|
+
*
|
|
13
|
+
* @param ctx - The emitter context.
|
|
14
|
+
* @param iface - The interface to emit.
|
|
15
|
+
* @param module - The module that this interface is written into.
|
|
16
|
+
*/
|
|
17
|
+
export function* emitInterface(ctx, iface, module) {
|
|
18
|
+
const name = parseCase(iface.name).pascalCase;
|
|
19
|
+
yield* emitDocumentation(ctx, iface);
|
|
20
|
+
yield `export interface ${name}<Context = unknown> {`;
|
|
21
|
+
yield* indent(emitOperationGroup(ctx, iface.operations.values(), module));
|
|
22
|
+
yield "}";
|
|
23
|
+
yield "";
|
|
24
|
+
}
|
|
25
|
+
/**
|
|
26
|
+
* Emit a list of operation signatures.
|
|
27
|
+
*
|
|
28
|
+
* @param ctx - The emitter context.
|
|
29
|
+
* @param operations - The operations to emit.
|
|
30
|
+
* @param module - The module that the operations are written into.
|
|
31
|
+
*/
|
|
32
|
+
export function* emitOperationGroup(ctx, operations, module) {
|
|
33
|
+
for (const op of operations) {
|
|
34
|
+
yield* emitOperation(ctx, op, module);
|
|
35
|
+
yield "";
|
|
36
|
+
}
|
|
37
|
+
}
|
|
38
|
+
/**
|
|
39
|
+
* Emit a single operation signature.
|
|
40
|
+
*
|
|
41
|
+
* @param ctx - The emitter context.
|
|
42
|
+
* @param op - The operation to emit.
|
|
43
|
+
* @param module - The module that the operation is written into.
|
|
44
|
+
*/
|
|
45
|
+
export function* emitOperation(ctx, op, module) {
|
|
46
|
+
const opNameCase = parseCase(op.name);
|
|
47
|
+
const opName = opNameCase.camelCase;
|
|
48
|
+
const allParameters = getAllProperties(op.parameters);
|
|
49
|
+
const hasOptions = allParameters.some((p) => p.optional);
|
|
50
|
+
const returnTypeReference = emitTypeReference(ctx, op.returnType, op, module, {
|
|
51
|
+
altName: opNameCase.pascalCase + "Result",
|
|
52
|
+
});
|
|
53
|
+
const returnType = `Promise<${returnTypeReference}>`;
|
|
54
|
+
const params = [];
|
|
55
|
+
for (const param of allParameters) {
|
|
56
|
+
// If the type is a value literal, then we consider it a _setting_ and not a parameter.
|
|
57
|
+
// This allows us to exclude metadata parameters (such as contentType) from the generated interface.
|
|
58
|
+
if (param.optional || isValueLiteralType(param.type))
|
|
59
|
+
continue;
|
|
60
|
+
const paramNameCase = parseCase(param.name);
|
|
61
|
+
const paramName = paramNameCase.camelCase;
|
|
62
|
+
const outputTypeReference = emitTypeReference(ctx, param.type, param, module, {
|
|
63
|
+
altName: opNameCase.pascalCase + paramNameCase.pascalCase,
|
|
64
|
+
});
|
|
65
|
+
params.push(`${paramName}: ${outputTypeReference}`);
|
|
66
|
+
}
|
|
67
|
+
const paramsDeclarationLine = params.join(", ");
|
|
68
|
+
yield* emitDocumentation(ctx, op);
|
|
69
|
+
if (hasOptions) {
|
|
70
|
+
const optionsTypeName = opNameCase.pascalCase + "Options";
|
|
71
|
+
emitOptionsType(ctx, op, module, optionsTypeName);
|
|
72
|
+
const paramsFragment = params.length > 0 ? `${paramsDeclarationLine}, ` : "";
|
|
73
|
+
// prettier-ignore
|
|
74
|
+
yield `${opName}(ctx: Context, ${paramsFragment}options?: ${optionsTypeName}): ${returnType};`;
|
|
75
|
+
yield "";
|
|
76
|
+
}
|
|
77
|
+
else {
|
|
78
|
+
// prettier-ignore
|
|
79
|
+
yield `${opName}(ctx: Context, ${paramsDeclarationLine}): ${returnType};`;
|
|
80
|
+
yield "";
|
|
81
|
+
}
|
|
82
|
+
}
|
|
83
|
+
/**
|
|
84
|
+
* Emit a declaration for an options type including the optional parameters of an operation.
|
|
85
|
+
*
|
|
86
|
+
* @param ctx - The emitter context.
|
|
87
|
+
* @param operation - The operation to emit the options type for.
|
|
88
|
+
* @param module - The module that the options type is written into.
|
|
89
|
+
* @param optionsTypeName - The name of the options type.
|
|
90
|
+
*/
|
|
91
|
+
export function emitOptionsType(ctx, operation, module, optionsTypeName) {
|
|
92
|
+
module.imports.push({
|
|
93
|
+
binder: [optionsTypeName],
|
|
94
|
+
from: ctx.syntheticModule,
|
|
95
|
+
});
|
|
96
|
+
const options = [...operation.parameters.properties.values()].filter((p) => p.optional);
|
|
97
|
+
ctx.syntheticModule.declarations.push([
|
|
98
|
+
`export interface ${optionsTypeName} {`,
|
|
99
|
+
...options.flatMap((p) => [
|
|
100
|
+
` ${parseCase(p.name).camelCase}?: ${emitTypeReference(ctx, p.type, p, module, {
|
|
101
|
+
altName: optionsTypeName + parseCase(p.name).pascalCase,
|
|
102
|
+
})};`,
|
|
103
|
+
]),
|
|
104
|
+
"}",
|
|
105
|
+
"",
|
|
106
|
+
]);
|
|
107
|
+
}
|
|
108
|
+
const DEFAULT_NO_VARIANT_RETURN_TYPE = "never";
|
|
109
|
+
const DEFAULT_NO_VARIANT_SPLIT = {
|
|
110
|
+
kind: "ordinary",
|
|
111
|
+
typeReference: DEFAULT_NO_VARIANT_RETURN_TYPE,
|
|
112
|
+
target: undefined,
|
|
113
|
+
};
|
|
114
|
+
export function isInfallible(split) {
|
|
115
|
+
return ((split.kind === "ordinary" && split.typeReference === "never") ||
|
|
116
|
+
(split.kind === "union" && split.variants.length === 0));
|
|
117
|
+
}
|
|
118
|
+
export function splitReturnType(ctx, type, module, altBaseName) {
|
|
119
|
+
const successAltName = altBaseName + "Response";
|
|
120
|
+
const errorAltName = altBaseName + "ErrorResponse";
|
|
121
|
+
if (type.kind === "Union") {
|
|
122
|
+
const [successVariants, errorVariants] = bifilter(type.variants.values(), (v) => !isErrorModel(ctx.program, v.type));
|
|
123
|
+
const successTypeReference = successVariants.length === 0
|
|
124
|
+
? DEFAULT_NO_VARIANT_RETURN_TYPE
|
|
125
|
+
: successVariants.length === 1
|
|
126
|
+
? emitTypeReference(ctx, successVariants[0].type, successVariants[0], module, {
|
|
127
|
+
altName: successAltName,
|
|
128
|
+
})
|
|
129
|
+
: emitUnionType(ctx, successVariants, module);
|
|
130
|
+
const errorTypeReference = errorVariants.length === 0
|
|
131
|
+
? DEFAULT_NO_VARIANT_RETURN_TYPE
|
|
132
|
+
: errorVariants.length === 1
|
|
133
|
+
? emitTypeReference(ctx, errorVariants[0].type, errorVariants[0], module, {
|
|
134
|
+
altName: errorAltName,
|
|
135
|
+
})
|
|
136
|
+
: emitUnionType(ctx, errorVariants, module);
|
|
137
|
+
const successSplit = successVariants.length > 1
|
|
138
|
+
? {
|
|
139
|
+
kind: "union",
|
|
140
|
+
variants: successVariants,
|
|
141
|
+
typeReference: successTypeReference,
|
|
142
|
+
target: undefined,
|
|
143
|
+
}
|
|
144
|
+
: {
|
|
145
|
+
kind: "ordinary",
|
|
146
|
+
typeReference: successTypeReference,
|
|
147
|
+
target: successVariants[0]?.type,
|
|
148
|
+
};
|
|
149
|
+
const errorSplit = errorVariants.length > 1
|
|
150
|
+
? {
|
|
151
|
+
kind: "union",
|
|
152
|
+
variants: errorVariants,
|
|
153
|
+
typeReference: errorTypeReference,
|
|
154
|
+
// target: module.cursor.resolveRelativeItemPath(errorTypeReference),
|
|
155
|
+
target: undefined,
|
|
156
|
+
}
|
|
157
|
+
: {
|
|
158
|
+
kind: "ordinary",
|
|
159
|
+
typeReference: errorTypeReference,
|
|
160
|
+
target: errorVariants[0]?.type,
|
|
161
|
+
};
|
|
162
|
+
return [successSplit, errorSplit];
|
|
163
|
+
}
|
|
164
|
+
else {
|
|
165
|
+
// No splitting, just figure out if the type is an error type or not and make the other infallible.
|
|
166
|
+
if (isErrorModel(ctx.program, type)) {
|
|
167
|
+
const typeReference = emitTypeReference(ctx, type, type, module, {
|
|
168
|
+
altName: altBaseName + "ErrorResponse",
|
|
169
|
+
});
|
|
170
|
+
return [
|
|
171
|
+
DEFAULT_NO_VARIANT_SPLIT,
|
|
172
|
+
{
|
|
173
|
+
kind: "ordinary",
|
|
174
|
+
typeReference,
|
|
175
|
+
target: type,
|
|
176
|
+
},
|
|
177
|
+
];
|
|
178
|
+
}
|
|
179
|
+
else {
|
|
180
|
+
const typeReference = emitTypeReference(ctx, type, type, module, {
|
|
181
|
+
altName: altBaseName + "SuccessResponse",
|
|
182
|
+
});
|
|
183
|
+
return [
|
|
184
|
+
{
|
|
185
|
+
kind: "ordinary",
|
|
186
|
+
typeReference,
|
|
187
|
+
target: type,
|
|
188
|
+
},
|
|
189
|
+
DEFAULT_NO_VARIANT_SPLIT,
|
|
190
|
+
];
|
|
191
|
+
}
|
|
192
|
+
}
|
|
193
|
+
}
|
|
194
|
+
//# sourceMappingURL=interface.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"interface.js","sourceRoot":"","sources":["../../../src/common/interface.ts"],"names":[],"mappings":"AAAA,sCAAsC;AACtC,kCAAkC;AAElC,OAAO,EAA4C,YAAY,EAAE,MAAM,oBAAoB,CAAC;AAE5F,OAAO,EAAE,SAAS,EAAE,MAAM,iBAAiB,CAAC;AAC5C,OAAO,EAAE,gBAAgB,EAAE,MAAM,oBAAoB,CAAC;AACtD,OAAO,EAAE,QAAQ,EAAE,MAAM,EAAE,MAAM,iBAAiB,CAAC;AACnD,OAAO,EAAE,iBAAiB,EAAE,MAAM,oBAAoB,CAAC;AACvD,OAAO,EAAE,iBAAiB,EAAE,kBAAkB,EAAE,MAAM,gBAAgB,CAAC;AACvE,OAAO,EAAE,aAAa,EAAE,MAAM,YAAY,CAAC;AAE3C;;;;;;GAMG;AACH,MAAM,SAAS,CAAC,CAAC,aAAa,CAAC,GAAc,EAAE,KAAgB,EAAE,MAAc;IAC7E,MAAM,IAAI,GAAG,SAAS,CAAC,KAAK,CAAC,IAAI,CAAC,CAAC,UAAU,CAAC;IAE9C,KAAK,CAAC,CAAC,iBAAiB,CAAC,GAAG,EAAE,KAAK,CAAC,CAAC;IACrC,MAAM,oBAAoB,IAAI,uBAAuB,CAAC;IACtD,KAAK,CAAC,CAAC,MAAM,CAAC,kBAAkB,CAAC,GAAG,EAAE,KAAK,CAAC,UAAU,CAAC,MAAM,EAAE,EAAE,MAAM,CAAC,CAAC,CAAC;IAC1E,MAAM,GAAG,CAAC;IACV,MAAM,EAAE,CAAC;AACX,CAAC;AAED;;;;;;GAMG;AACH,MAAM,SAAS,CAAC,CAAC,kBAAkB,CACjC,GAAc,EACd,UAA+B,EAC/B,MAAc;IAEd,KAAK,MAAM,EAAE,IAAI,UAAU,EAAE,CAAC;QAC5B,KAAK,CAAC,CAAC,aAAa,CAAC,GAAG,EAAE,EAAE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,IAAI,EAAE,UAAU;gBAChB,aAAa,EAAE,kBAAkB;gBACjC,MAAM,EAAE,aAAa,CAAC,CAAC,CAAC,EAAE,IAAI;aAC/B,CAAC;QAER,OAAO,CAAC,YAAY,EAAE,UAAU,CAAC,CAAC;IACpC,CAAC;SAAM,CAAC;QACN,mGAAmG;QAEnG,IAAI,YAAY,CAAC,GAAG,CAAC,OAAO,EAAE,IAAI,CAAC,EAAE,CAAC;YACpC,MAAM,aAAa,GAAG,iBAAiB,CAAC,GAAG,EAAE,IAAI,EAAE,IAAI,EAAE,MAAM,EAAE;gBAC/D,OAAO,EAAE,WAAW,GAAG,eAAe;aACvC,CAAC,CAAC;YAEH,OAAO;gBACL,wBAAwB;gBACxB;oBACE,IAAI,EAAE,UAAU;oBAChB,aAAa;oBACb,MAAM,EAAE,IAAI;iBACb;aACF,CAAC;QACJ,CAAC;aAAM,CAAC;YACN,MAAM,aAAa,GAAG,iBAAiB,CAAC,GAAG,EAAE,IAAI,EAAE,IAAI,EAAE,MAAM,EAAE;gBAC/D,OAAO,EAAE,WAAW,GAAG,iBAAiB;aACzC,CAAC,CAAC;YACH,OAAO;gBACL;oBACE,IAAI,EAAE,UAAU;oBAChB,aAAa;oBACb,MAAM,EAAE,IAAI;iBACb;gBACD,wBAAwB;aACzB,CAAC;QACJ,CAAC;IACH,CAAC;AACH,CAAC"}
|
|
@@ -0,0 +1,26 @@
|
|
|
1
|
+
import { Model } from "@typespec/compiler";
|
|
2
|
+
import { JsContext, Module } from "../ctx.js";
|
|
3
|
+
/**
|
|
4
|
+
* Emit a model declaration.
|
|
5
|
+
*
|
|
6
|
+
* @param ctx - The emitter context.
|
|
7
|
+
* @param model - The model to emit.
|
|
8
|
+
* @param module - The module that this model is written into.
|
|
9
|
+
* @param altName - An alternative name to use for the model if it is not named.
|
|
10
|
+
*/
|
|
11
|
+
export declare function emitModel(ctx: JsContext, model: Model, module: Module, altName?: string): Iterable<string>;
|
|
12
|
+
export declare function emitModelLiteral(ctx: JsContext, model: Model, module: Module): string;
|
|
13
|
+
/**
|
|
14
|
+
* Determines whether a model is an instance of a well-known model, such as TypeSpec.Record or TypeSpec.Array.
|
|
15
|
+
*/
|
|
16
|
+
export declare function isWellKnownModel(ctx: JsContext, type: Model): boolean;
|
|
17
|
+
/**
|
|
18
|
+
* Emits a well-known model, such as TypeSpec.Record or TypeSpec.Array.
|
|
19
|
+
*
|
|
20
|
+
* @param ctx - The emitter context.
|
|
21
|
+
* @param type - The model to emit.
|
|
22
|
+
* @param module - The module that this model is written into.
|
|
23
|
+
* @param preferredAlternativeName - An alternative name to use for the model if it is not named.
|
|
24
|
+
*/
|
|
25
|
+
export declare function emitWellKnownModel(ctx: JsContext, type: Model, module: Module, preferredAlternativeName?: string): string;
|
|
26
|
+
//# sourceMappingURL=model.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"model.d.ts","sourceRoot":"","sources":["../../../src/common/model.ts"],"names":[],"mappings":"AAGA,OAAO,EACL,KAAK,EAIN,MAAM,oBAAoB,CAAC;AAC5B,OAAO,EAAE,SAAS,EAAE,MAAM,EAAE,MAAM,WAAW,CAAC;AAS9C;;;;;;;GAOG;AACH,wBAAiB,SAAS,CACxB,GAAG,EAAE,SAAS,EACd,KAAK,EAAE,KAAK,EACZ,MAAM,EAAE,MAAM,EACd,OAAO,CAAC,EAAE,MAAM,GACf,QAAQ,CAAC,MAAM,CAAC,CAwDlB;AAED,wBAAgB,gBAAgB,CAAC,GAAG,EAAE,SAAS,EAAE,KAAK,EAAE,KAAK,EAAE,MAAM,EAAE,MAAM,GAAG,MAAM,CAiBrF;AAED;;GAEG;AACH,wBAAgB,gBAAgB,CAAC,GAAG,EAAE,SAAS,EAAE,IAAI,EAAE,KAAK,GAAG,OAAO,CAGrE;AAED;;;;;;;GAOG;AACH,wBAAgB,kBAAkB,CAChC,GAAG,EAAE,SAAS,EACd,IAAI,EAAE,KAAK,EACX,MAAM,EAAE,MAAM,EACd,wBAAwB,CAAC,EAAE,MAAM,GAChC,MAAM,CA8BR"}
|
|
@@ -0,0 +1,115 @@
|
|
|
1
|
+
// Copyright (c) Microsoft Corporation
|
|
2
|
+
// Licensed under the MIT license.
|
|
3
|
+
import { getFriendlyName, isTemplateDeclaration, isTemplateInstance, } from "@typespec/compiler";
|
|
4
|
+
import { isUnspeakable, parseCase } from "../util/case.js";
|
|
5
|
+
import { indent } from "../util/iter.js";
|
|
6
|
+
import { KEYWORDS } from "../util/keywords.js";
|
|
7
|
+
import { getFullyQualifiedTypeName } from "../util/name.js";
|
|
8
|
+
import { asArrayType, getArrayElementName, getRecordValueName } from "../util/pluralism.js";
|
|
9
|
+
import { emitDocumentation } from "./documentation.js";
|
|
10
|
+
import { emitTypeReference } from "./reference.js";
|
|
11
|
+
/**
|
|
12
|
+
* Emit a model declaration.
|
|
13
|
+
*
|
|
14
|
+
* @param ctx - The emitter context.
|
|
15
|
+
* @param model - The model to emit.
|
|
16
|
+
* @param module - The module that this model is written into.
|
|
17
|
+
* @param altName - An alternative name to use for the model if it is not named.
|
|
18
|
+
*/
|
|
19
|
+
export function* emitModel(ctx, model, module, altName) {
|
|
20
|
+
const isTemplate = isTemplateInstance(model);
|
|
21
|
+
const friendlyName = getFriendlyName(ctx.program, model);
|
|
22
|
+
if (isTemplateDeclaration(model)) {
|
|
23
|
+
return;
|
|
24
|
+
}
|
|
25
|
+
const modelNameCase = parseCase(friendlyName
|
|
26
|
+
? friendlyName
|
|
27
|
+
: isTemplate
|
|
28
|
+
? model.templateMapper.args.map((a) => ("name" in a ? String(a.name) : "")).join("_") +
|
|
29
|
+
model.name
|
|
30
|
+
: model.name);
|
|
31
|
+
if (model.name === "" && !altName) {
|
|
32
|
+
throw new Error("UNREACHABLE: Anonymous model with no altName");
|
|
33
|
+
}
|
|
34
|
+
yield* emitDocumentation(ctx, model);
|
|
35
|
+
const ifaceName = model.name === "" ? altName : modelNameCase.pascalCase;
|
|
36
|
+
const extendsClause = model.baseModel
|
|
37
|
+
? `extends ${emitTypeReference(ctx, model.baseModel, model, module)} `
|
|
38
|
+
: "";
|
|
39
|
+
yield `export interface ${ifaceName} ${extendsClause}{`;
|
|
40
|
+
for (const field of model.properties.values()) {
|
|
41
|
+
// Skip properties with unspeakable names.
|
|
42
|
+
if (isUnspeakable(field.name)) {
|
|
43
|
+
continue;
|
|
44
|
+
}
|
|
45
|
+
const nameCase = parseCase(field.name);
|
|
46
|
+
const basicName = nameCase.camelCase;
|
|
47
|
+
const typeReference = emitTypeReference(ctx, field.type, field, module, {
|
|
48
|
+
altName: modelNameCase.pascalCase + nameCase.pascalCase,
|
|
49
|
+
});
|
|
50
|
+
const name = KEYWORDS.has(basicName) ? `_${basicName}` : basicName;
|
|
51
|
+
yield* indent(emitDocumentation(ctx, field));
|
|
52
|
+
const questionMark = field.optional ? "?" : "";
|
|
53
|
+
yield ` ${name}${questionMark}: ${typeReference};`;
|
|
54
|
+
yield "";
|
|
55
|
+
}
|
|
56
|
+
yield "}";
|
|
57
|
+
yield "";
|
|
58
|
+
}
|
|
59
|
+
export function emitModelLiteral(ctx, model, module) {
|
|
60
|
+
const properties = [...model.properties.values()]
|
|
61
|
+
.map((prop) => {
|
|
62
|
+
if (isUnspeakable(prop.name)) {
|
|
63
|
+
return undefined;
|
|
64
|
+
}
|
|
65
|
+
const nameCase = parseCase(prop.name);
|
|
66
|
+
const questionMark = prop.optional ? "?" : "";
|
|
67
|
+
const name = KEYWORDS.has(nameCase.camelCase) ? `_${nameCase.camelCase}` : nameCase.camelCase;
|
|
68
|
+
return `${name}${questionMark}: ${emitTypeReference(ctx, prop.type, prop, module)}`;
|
|
69
|
+
})
|
|
70
|
+
.filter((p) => !!p);
|
|
71
|
+
return `{ ${properties.join("; ")} }`;
|
|
72
|
+
}
|
|
73
|
+
/**
|
|
74
|
+
* Determines whether a model is an instance of a well-known model, such as TypeSpec.Record or TypeSpec.Array.
|
|
75
|
+
*/
|
|
76
|
+
export function isWellKnownModel(ctx, type) {
|
|
77
|
+
const fullName = getFullyQualifiedTypeName(type);
|
|
78
|
+
return ["TypeSpec.Record", "TypeSpec.Array", "TypeSpec.Http.HttpPart"].includes(fullName);
|
|
79
|
+
}
|
|
80
|
+
/**
|
|
81
|
+
* Emits a well-known model, such as TypeSpec.Record or TypeSpec.Array.
|
|
82
|
+
*
|
|
83
|
+
* @param ctx - The emitter context.
|
|
84
|
+
* @param type - The model to emit.
|
|
85
|
+
* @param module - The module that this model is written into.
|
|
86
|
+
* @param preferredAlternativeName - An alternative name to use for the model if it is not named.
|
|
87
|
+
*/
|
|
88
|
+
export function emitWellKnownModel(ctx, type, module, preferredAlternativeName) {
|
|
89
|
+
switch (type.name) {
|
|
90
|
+
case "Record": {
|
|
91
|
+
const arg = type.indexer.value;
|
|
92
|
+
return `{ [k: string]: ${emitTypeReference(ctx, arg, type, module, {
|
|
93
|
+
altName: preferredAlternativeName && getRecordValueName(preferredAlternativeName),
|
|
94
|
+
})} }`;
|
|
95
|
+
}
|
|
96
|
+
case "Array": {
|
|
97
|
+
const arg = type.indexer.value;
|
|
98
|
+
return asArrayType(emitTypeReference(ctx, arg, type, module, {
|
|
99
|
+
altName: preferredAlternativeName && getArrayElementName(preferredAlternativeName),
|
|
100
|
+
}));
|
|
101
|
+
}
|
|
102
|
+
case "HttpPart": {
|
|
103
|
+
const argument = type.templateMapper.args[0];
|
|
104
|
+
if (!(argument.entityKind === "Type" && argument.kind === "Model")) {
|
|
105
|
+
throw new Error("UNREACHABLE: HttpPart must have a Model argument");
|
|
106
|
+
}
|
|
107
|
+
return emitTypeReference(ctx, argument, type, module, {
|
|
108
|
+
altName: preferredAlternativeName && `${preferredAlternativeName}HttpPart`,
|
|
109
|
+
});
|
|
110
|
+
}
|
|
111
|
+
default:
|
|
112
|
+
throw new Error(`UNREACHABLE: ${type.name}`);
|
|
113
|
+
}
|
|
114
|
+
}
|
|
115
|
+
//# sourceMappingURL=model.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"model.js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AAG,EAAE,QAAQ,EAAE,IAAI,EAAE,MAAM,EAAE;gBACpD,OAAO,EAAE,wBAAwB,IAAI,GAAG,wBAAwB,UAAU;aAC3E,CAAC,CAAC;QACL,CAAC;QACD;YACE,MAAM,IAAI,KAAK,CAAC,gBAAgB,IAAI,CAAC,IAAI,EAAE,CAAC,CAAC;IACjD,CAAC;AACH,CAAC"}
|
|
@@ -0,0 +1,38 @@
|
|
|
1
|
+
import { Namespace } from "@typespec/compiler";
|
|
2
|
+
import { JsContext, Module } from "../ctx.js";
|
|
3
|
+
import { OnceQueue } from "../util/once-queue.js";
|
|
4
|
+
/**
|
|
5
|
+
* Enqueue all declarations in the namespace to be included in the emit, recursively.
|
|
6
|
+
*
|
|
7
|
+
* @param ctx - The emitter context.
|
|
8
|
+
* @param namespace - The root namespace to begin traversing.
|
|
9
|
+
*/
|
|
10
|
+
export declare function visitAllTypes(ctx: JsContext, namespace: Namespace): void;
|
|
11
|
+
/**
|
|
12
|
+
* Create a module for a namespace, or get an existing module if one has already been created.
|
|
13
|
+
*
|
|
14
|
+
* @param ctx - The emitter context.
|
|
15
|
+
* @param namespace - The namespace to create a module for.
|
|
16
|
+
* @returns the module for the namespace.
|
|
17
|
+
*/
|
|
18
|
+
export declare function createOrGetModuleForNamespace(ctx: JsContext, namespace: Namespace, root?: Module): Module;
|
|
19
|
+
/**
|
|
20
|
+
* Get a reference to the interface representing the namespace's floating operations.
|
|
21
|
+
*
|
|
22
|
+
* This does not check that such an interface actually exists, so it should only be called in situations where it is
|
|
23
|
+
* known to exist (for example, if an operation comes from the namespace).
|
|
24
|
+
*
|
|
25
|
+
* @param ctx - The emitter context.
|
|
26
|
+
* @param namespace - The namespace to get the interface reference for.
|
|
27
|
+
* @param module - The module the the reference will be written to.
|
|
28
|
+
*/
|
|
29
|
+
export declare function emitNamespaceInterfaceReference(ctx: JsContext, namespace: Namespace, module: Module): string;
|
|
30
|
+
/**
|
|
31
|
+
* Emits the body of a module file.
|
|
32
|
+
*
|
|
33
|
+
* @param ctx - The emitter context.
|
|
34
|
+
* @param module - The module to emit.
|
|
35
|
+
* @param queue - The queue to add any submodules to for later processing.
|
|
36
|
+
*/
|
|
37
|
+
export declare function emitModuleBody(ctx: JsContext, module: Module, queue: OnceQueue<Module>): Iterable<string>;
|
|
38
|
+
//# sourceMappingURL=namespace.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"namespace.d.ts","sourceRoot":"","sources":["../../../src/common/namespace.ts"],"names":[],"mappings":"AAGA,OAAO,EAAE,SAAS,EAAwB,MAAM,oBAAoB,CAAC;AACrE,OAAO,EAEL,SAAS,EACT,MAAM,EAIP,MAAM,WAAW,CAAC;AAInB,OAAO,EAAE,SAAS,EAAE,MAAM,uBAAuB,CAAC;AAGlD;;;;;GAKG;AACH,wBAAgB,aAAa,CAAC,GAAG,EAAE,SAAS,EAAE,SAAS,EAAE,SAAS,QAmCjE;AAED;;;;;;GAMG;AACH,wBAAgB,6BAA6B,CAC3C,GAAG,EAAE,SAAS,EACd,SAAS,EAAE,SAAS,EACpB,IAAI,GAAE,MAAkC,GACvC,MAAM,CAoBR;AAED;;;;;;;;;GASG;AACH,wBAAgB,+BAA+B,CAC7C,GAAG,EAAE,SAAS,EACd,SAAS,EAAE,SAAS,EACpB,MAAM,EAAE,MAAM,GACb,MAAM,CAaR;AAqGD;;;;;;GAMG;AACH,wBAAiB,cAAc,CAC7B,GAAG,EAAE,SAAS,EACd,MAAM,EAAE,MAAM,EACd,KAAK,EAAE,SAAS,CAAC,MAAM,CAAC,GACvB,QAAQ,CAAC,MAAM,CAAC,CASlB"}
|