@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.
Files changed (215) hide show
  1. package/CHANGELOG.md +69 -0
  2. package/LICENSE +21 -0
  3. package/README.md +183 -0
  4. package/build-helpers.ts +170 -0
  5. package/dist/generated-defs/helpers/header.d.ts +4 -0
  6. package/dist/generated-defs/helpers/header.d.ts.map +1 -0
  7. package/dist/generated-defs/helpers/header.js +76 -0
  8. package/dist/generated-defs/helpers/header.js.map +1 -0
  9. package/dist/generated-defs/helpers/http.d.ts +4 -0
  10. package/dist/generated-defs/helpers/http.d.ts.map +1 -0
  11. package/dist/generated-defs/helpers/http.js +134 -0
  12. package/dist/generated-defs/helpers/http.js.map +1 -0
  13. package/dist/generated-defs/helpers/index.d.ts +4 -0
  14. package/dist/generated-defs/helpers/index.d.ts.map +1 -0
  15. package/dist/generated-defs/helpers/index.js +21 -0
  16. package/dist/generated-defs/helpers/index.js.map +1 -0
  17. package/dist/generated-defs/helpers/multipart.d.ts +4 -0
  18. package/dist/generated-defs/helpers/multipart.d.ts.map +1 -0
  19. package/dist/generated-defs/helpers/multipart.js +249 -0
  20. package/dist/generated-defs/helpers/multipart.js.map +1 -0
  21. package/dist/generated-defs/helpers/router.d.ts +4 -0
  22. package/dist/generated-defs/helpers/router.d.ts.map +1 -0
  23. package/dist/generated-defs/helpers/router.js +259 -0
  24. package/dist/generated-defs/helpers/router.js.map +1 -0
  25. package/dist/src/common/declaration.d.ts +13 -0
  26. package/dist/src/common/declaration.d.ts.map +1 -0
  27. package/dist/src/common/declaration.js +45 -0
  28. package/dist/src/common/declaration.js.map +1 -0
  29. package/dist/src/common/documentation.d.ts +12 -0
  30. package/dist/src/common/documentation.d.ts.map +1 -0
  31. package/dist/src/common/documentation.js +21 -0
  32. package/dist/src/common/documentation.js.map +1 -0
  33. package/dist/src/common/enum.d.ts +10 -0
  34. package/dist/src/common/enum.d.ts.map +1 -0
  35. package/dist/src/common/enum.js +21 -0
  36. package/dist/src/common/enum.js.map +1 -0
  37. package/dist/src/common/interface.d.ts +50 -0
  38. package/dist/src/common/interface.d.ts.map +1 -0
  39. package/dist/src/common/interface.js +194 -0
  40. package/dist/src/common/interface.js.map +1 -0
  41. package/dist/src/common/model.d.ts +26 -0
  42. package/dist/src/common/model.d.ts.map +1 -0
  43. package/dist/src/common/model.js +115 -0
  44. package/dist/src/common/model.js.map +1 -0
  45. package/dist/src/common/namespace.d.ts +38 -0
  46. package/dist/src/common/namespace.d.ts.map +1 -0
  47. package/dist/src/common/namespace.js +184 -0
  48. package/dist/src/common/namespace.js.map +1 -0
  49. package/dist/src/common/reference.d.ts +46 -0
  50. package/dist/src/common/reference.d.ts.map +1 -0
  51. package/dist/src/common/reference.js +243 -0
  52. package/dist/src/common/reference.js.map +1 -0
  53. package/dist/src/common/scalar.d.ts +50 -0
  54. package/dist/src/common/scalar.d.ts.map +1 -0
  55. package/dist/src/common/scalar.js +144 -0
  56. package/dist/src/common/scalar.js.map +1 -0
  57. package/dist/src/common/serialization/index.d.ts +11 -0
  58. package/dist/src/common/serialization/index.d.ts.map +1 -0
  59. package/dist/src/common/serialization/index.js +72 -0
  60. package/dist/src/common/serialization/index.js.map +1 -0
  61. package/dist/src/common/serialization/json.d.ts +6 -0
  62. package/dist/src/common/serialization/json.d.ts.map +1 -0
  63. package/dist/src/common/serialization/json.js +341 -0
  64. package/dist/src/common/serialization/json.js.map +1 -0
  65. package/dist/src/common/union.d.ts +23 -0
  66. package/dist/src/common/union.d.ts.map +1 -0
  67. package/dist/src/common/union.js +57 -0
  68. package/dist/src/common/union.js.map +1 -0
  69. package/dist/src/ctx.d.ts +242 -0
  70. package/dist/src/ctx.d.ts.map +1 -0
  71. package/dist/src/ctx.js +211 -0
  72. package/dist/src/ctx.js.map +1 -0
  73. package/dist/src/helpers/header.d.ts +14 -0
  74. package/dist/src/helpers/header.d.ts.map +1 -0
  75. package/dist/src/helpers/header.js +38 -0
  76. package/dist/src/helpers/header.js.map +1 -0
  77. package/dist/src/helpers/http.d.ts +70 -0
  78. package/dist/src/helpers/http.d.ts.map +1 -0
  79. package/dist/src/helpers/http.js +86 -0
  80. package/dist/src/helpers/http.js.map +1 -0
  81. package/dist/src/helpers/multipart.d.ts +26 -0
  82. package/dist/src/helpers/multipart.d.ts.map +1 -0
  83. package/dist/src/helpers/multipart.js +182 -0
  84. package/dist/src/helpers/multipart.js.map +1 -0
  85. package/dist/src/helpers/router.d.ts +176 -0
  86. package/dist/src/helpers/router.d.ts.map +1 -0
  87. package/dist/src/helpers/router.js +55 -0
  88. package/dist/src/helpers/router.js.map +1 -0
  89. package/dist/src/http/index.d.ts +24 -0
  90. package/dist/src/http/index.d.ts.map +1 -0
  91. package/dist/src/http/index.js +52 -0
  92. package/dist/src/http/index.js.map +1 -0
  93. package/dist/src/http/server/index.d.ts +11 -0
  94. package/dist/src/http/server/index.d.ts.map +1 -0
  95. package/dist/src/http/server/index.js +413 -0
  96. package/dist/src/http/server/index.js.map +1 -0
  97. package/dist/src/http/server/multipart.d.ts +16 -0
  98. package/dist/src/http/server/multipart.d.ts.map +1 -0
  99. package/dist/src/http/server/multipart.js +214 -0
  100. package/dist/src/http/server/multipart.js.map +1 -0
  101. package/dist/src/http/server/router.d.ts +15 -0
  102. package/dist/src/http/server/router.d.ts.map +1 -0
  103. package/dist/src/http/server/router.js +459 -0
  104. package/dist/src/http/server/router.js.map +1 -0
  105. package/dist/src/index.d.ts +5 -0
  106. package/dist/src/index.d.ts.map +1 -0
  107. package/dist/src/index.js +38 -0
  108. package/dist/src/index.js.map +1 -0
  109. package/dist/src/lib.d.ts +141 -0
  110. package/dist/src/lib.d.ts.map +1 -0
  111. package/dist/src/lib.js +116 -0
  112. package/dist/src/lib.js.map +1 -0
  113. package/dist/src/scripts/scaffold/bin.d.mts +14 -0
  114. package/dist/src/scripts/scaffold/bin.d.mts.map +1 -0
  115. package/dist/src/scripts/scaffold/bin.mjs +559 -0
  116. package/dist/src/scripts/scaffold/bin.mjs.map +1 -0
  117. package/dist/src/testing/index.d.ts +3 -0
  118. package/dist/src/testing/index.d.ts.map +1 -0
  119. package/dist/src/testing/index.js +6 -0
  120. package/dist/src/testing/index.js.map +1 -0
  121. package/dist/src/util/case.d.ts +81 -0
  122. package/dist/src/util/case.d.ts.map +1 -0
  123. package/dist/src/util/case.js +111 -0
  124. package/dist/src/util/case.js.map +1 -0
  125. package/dist/src/util/differentiate.d.ts +251 -0
  126. package/dist/src/util/differentiate.d.ts.map +1 -0
  127. package/dist/src/util/differentiate.js +580 -0
  128. package/dist/src/util/differentiate.js.map +1 -0
  129. package/dist/src/util/error.d.ts +13 -0
  130. package/dist/src/util/error.d.ts.map +1 -0
  131. package/dist/src/util/error.js +25 -0
  132. package/dist/src/util/error.js.map +1 -0
  133. package/dist/src/util/extends.d.ts +10 -0
  134. package/dist/src/util/extends.d.ts.map +1 -0
  135. package/dist/src/util/extends.js +31 -0
  136. package/dist/src/util/extends.js.map +1 -0
  137. package/dist/src/util/iter.d.ts +39 -0
  138. package/dist/src/util/iter.d.ts.map +1 -0
  139. package/dist/src/util/iter.js +72 -0
  140. package/dist/src/util/iter.js.map +1 -0
  141. package/dist/src/util/keywords.d.ts +10 -0
  142. package/dist/src/util/keywords.d.ts.map +1 -0
  143. package/dist/src/util/keywords.js +85 -0
  144. package/dist/src/util/keywords.js.map +1 -0
  145. package/dist/src/util/name.d.ts +12 -0
  146. package/dist/src/util/name.d.ts.map +1 -0
  147. package/dist/src/util/name.js +26 -0
  148. package/dist/src/util/name.js.map +1 -0
  149. package/dist/src/util/once-queue.d.ts +24 -0
  150. package/dist/src/util/once-queue.d.ts.map +1 -0
  151. package/dist/src/util/once-queue.js +34 -0
  152. package/dist/src/util/once-queue.js.map +1 -0
  153. package/dist/src/util/openapi3.d.ts +23 -0
  154. package/dist/src/util/openapi3.d.ts.map +1 -0
  155. package/dist/src/util/openapi3.js +40 -0
  156. package/dist/src/util/openapi3.js.map +1 -0
  157. package/dist/src/util/pluralism.d.ts +23 -0
  158. package/dist/src/util/pluralism.d.ts.map +1 -0
  159. package/dist/src/util/pluralism.js +36 -0
  160. package/dist/src/util/pluralism.js.map +1 -0
  161. package/dist/src/util/scope.d.ts +85 -0
  162. package/dist/src/util/scope.d.ts.map +1 -0
  163. package/dist/src/util/scope.js +111 -0
  164. package/dist/src/util/scope.js.map +1 -0
  165. package/dist/src/write.d.ts +23 -0
  166. package/dist/src/write.d.ts.map +1 -0
  167. package/dist/src/write.js +62 -0
  168. package/dist/src/write.js.map +1 -0
  169. package/generated-defs/helpers/header.ts +83 -0
  170. package/generated-defs/helpers/http.ts +141 -0
  171. package/generated-defs/helpers/index.ts +27 -0
  172. package/generated-defs/helpers/multipart.ts +256 -0
  173. package/generated-defs/helpers/router.ts +266 -0
  174. package/package.json +71 -0
  175. package/src/common/declaration.ts +52 -0
  176. package/src/common/documentation.ts +26 -0
  177. package/src/common/enum.ts +28 -0
  178. package/src/common/interface.ts +264 -0
  179. package/src/common/model.ts +160 -0
  180. package/src/common/namespace.ts +243 -0
  181. package/src/common/reference.ts +319 -0
  182. package/src/common/scalar.ts +173 -0
  183. package/src/common/serialization/index.ts +124 -0
  184. package/src/common/serialization/json.ts +444 -0
  185. package/src/common/union.ts +76 -0
  186. package/src/ctx.ts +497 -0
  187. package/src/helpers/header.ts +55 -0
  188. package/src/helpers/http.ts +113 -0
  189. package/src/helpers/multipart.ts +228 -0
  190. package/src/helpers/router.ts +238 -0
  191. package/src/http/index.ts +81 -0
  192. package/src/http/server/index.ts +548 -0
  193. package/src/http/server/multipart.ts +272 -0
  194. package/src/http/server/router.ts +686 -0
  195. package/src/index.ts +56 -0
  196. package/src/lib.ts +130 -0
  197. package/src/scripts/scaffold/bin.mts +781 -0
  198. package/src/testing/index.ts +10 -0
  199. package/src/util/case.ts +182 -0
  200. package/src/util/differentiate.ts +957 -0
  201. package/src/util/error.ts +28 -0
  202. package/src/util/extends.ts +43 -0
  203. package/src/util/iter.ts +85 -0
  204. package/src/util/keywords.ts +90 -0
  205. package/src/util/name.ts +33 -0
  206. package/src/util/once-queue.ts +55 -0
  207. package/src/util/openapi3.ts +53 -0
  208. package/src/util/pluralism.ts +37 -0
  209. package/src/util/scope.ts +211 -0
  210. package/src/write.ts +88 -0
  211. package/temp/tsconfig.tsbuildinfo +1 -0
  212. package/test/header.test.ts +26 -0
  213. package/test/multipart.test.ts +169 -0
  214. package/tsconfig.json +10 -0
  215. package/vitest.config.ts +4 -0
@@ -0,0 +1,459 @@
1
+ // Copyright (c) Microsoft Corporation
2
+ // Licensed under the MIT license.
3
+ import { getHttpOperation, } from "@typespec/http";
4
+ import { createOrGetModuleForNamespace, emitNamespaceInterfaceReference, } from "../../common/namespace.js";
5
+ import { emitTypeReference } from "../../common/reference.js";
6
+ import { createModule } from "../../ctx.js";
7
+ import { parseCase } from "../../util/case.js";
8
+ import { bifilter, indent } from "../../util/iter.js";
9
+ import { keywordSafe } from "../../util/keywords.js";
10
+ import { module as headerHelpers } from "../../../generated-defs/helpers/header.js";
11
+ import { module as routerHelper } from "../../../generated-defs/helpers/router.js";
12
+ import { parseHeaderValueParameters } from "../../helpers/header.js";
13
+ import { reportDiagnostic } from "../../lib.js";
14
+ import { UnimplementedError } from "../../util/error.js";
15
+ /**
16
+ * Emit a router for the HTTP operations defined in a given service.
17
+ *
18
+ * The generated router will use optimal prefix matching to dispatch requests to the appropriate underlying
19
+ * implementation using the raw server.
20
+ *
21
+ * @param ctx - The emitter context.
22
+ * @param service - The HTTP service to emit a router for.
23
+ * @param serverRawModule - The module that contains the raw server implementation.
24
+ */
25
+ export function emitRouter(ctx, service, serverRawModule) {
26
+ const routerModule = createModule("router", ctx.httpModule);
27
+ const routeTree = createRouteTree(ctx, service);
28
+ routerModule.imports.push({
29
+ binder: "* as http",
30
+ from: "node:http",
31
+ });
32
+ routerModule.imports.push({
33
+ binder: "* as serverRaw",
34
+ from: serverRawModule,
35
+ });
36
+ routerModule.imports.push({
37
+ binder: ["parseHeaderValueParameters"],
38
+ from: headerHelpers,
39
+ });
40
+ routerModule.declarations.push([...emitRouterDefinition(ctx, service, routeTree, routerModule)]);
41
+ }
42
+ /**
43
+ * Writes the code for a router of a given service.
44
+ *
45
+ * @param ctx - The emitter context.
46
+ * @param service - The HTTP service to emit a router for.
47
+ * @param routeTree - The service's route tree.
48
+ * @param module - The module we're writing to.
49
+ */
50
+ function* emitRouterDefinition(ctx, service, routeTree, module) {
51
+ const routerName = parseCase(service.namespace.name).pascalCase + "Router";
52
+ const uniqueContainers = new Set(service.operations.map((operation) => operation.container));
53
+ const backends = new Map();
54
+ for (const container of uniqueContainers) {
55
+ const param = parseCase(container.name);
56
+ const traitConstraint = container.kind === "Namespace"
57
+ ? emitNamespaceInterfaceReference(ctx, container, module)
58
+ : emitTypeReference(ctx, container, container, module);
59
+ module.imports.push({
60
+ binder: [param.pascalCase],
61
+ from: createOrGetModuleForNamespace(ctx, container.namespace),
62
+ });
63
+ backends.set(container, [param, traitConstraint]);
64
+ }
65
+ module.imports.push({
66
+ binder: ["RouterOptions", "createPolicyChain", "createPolicyChainForRoute", "HttpContext"],
67
+ from: routerHelper,
68
+ });
69
+ yield `export interface ${routerName} {`;
70
+ yield ` /**`;
71
+ yield ` * Dispatches the request to the appropriate service based on the request path.`;
72
+ yield ` *`;
73
+ yield ` * This member function may be used directly as a handler for a Node HTTP server.`;
74
+ yield ` *`;
75
+ yield ` * @param request - The incoming HTTP request.`;
76
+ yield ` * @param response - The outgoing HTTP response.`;
77
+ yield ` */`;
78
+ yield ` dispatch(request: http.IncomingMessage, response: http.ServerResponse): void;`;
79
+ if (ctx.options.express) {
80
+ yield "";
81
+ yield ` /**`;
82
+ yield ` * An Express middleware function that dispatches the request to the appropriate service based on the request path.`;
83
+ yield ` *`;
84
+ yield ` * This member function may be used directly as an application-level middleware function in an Express app.`;
85
+ yield ` *`;
86
+ yield ` * If the router does not match a route, it will call the \`next\` middleware registered with the application,`;
87
+ yield ` * so it is sensible to insert this middleware at the beginning of the middleware stack.`;
88
+ yield ` *`;
89
+ yield ` * @param req - The incoming HTTP request.`;
90
+ yield ` * @param res - The outgoing HTTP response.`;
91
+ yield ` * @param next - The next middleware function in the stack.`;
92
+ yield ` */`;
93
+ yield ` expressMiddleware(req: http.IncomingMessage, res: http.ServerResponse, next: () => void): void;`;
94
+ }
95
+ yield "}";
96
+ yield "";
97
+ yield `export function create${routerName}(`;
98
+ for (const [param] of backends.values()) {
99
+ yield ` ${param.camelCase}: ${param.pascalCase},`;
100
+ }
101
+ yield ` options: RouterOptions<{`;
102
+ for (const [param] of backends.values()) {
103
+ yield ` ${param.camelCase}: ${param.pascalCase}<HttpContext>,`;
104
+ }
105
+ yield ` }> = {}`;
106
+ yield `): ${routerName} {`;
107
+ const [onRequestNotFound, onInvalidRequest, onInternalError] = [
108
+ "onRequestNotFound",
109
+ "onInvalidRequest",
110
+ "onInternalError",
111
+ ].map(ctx.gensym);
112
+ // Router error case handlers
113
+ yield ` const ${onRequestNotFound} = options.onRequestNotFound ?? ((ctx) => {`;
114
+ yield ` ctx.response.statusCode = 404;`;
115
+ yield ` ctx.response.setHeader("Content-Type", "text/plain");`;
116
+ yield ` ctx.response.end("Not Found");`;
117
+ yield ` });`;
118
+ yield "";
119
+ yield ` const ${onInvalidRequest} = options.onInvalidRequest ?? ((ctx, route, error) => {`;
120
+ yield ` ctx.response.statusCode = 400;`;
121
+ yield ` ctx.response.setHeader("Content-Type", "application/json");`;
122
+ yield ` ctx.response.end(JSON.stringify({ error }));`;
123
+ yield ` });`;
124
+ yield "";
125
+ yield ` const ${onInternalError} = options.onInternalError ?? ((ctx, error) => {`;
126
+ yield ` ctx.response.statusCode = 500;`;
127
+ yield ` ctx.response.setHeader("Content-Type", "text/plain");`;
128
+ yield ` ctx.response.end("Internal server error.");`;
129
+ yield ` });`;
130
+ yield "";
131
+ const routePolicies = ctx.gensym("routePolicies");
132
+ const routeHandlers = ctx.gensym("routeHandlers");
133
+ yield ` const ${routePolicies} = options.routePolicies ?? {};`;
134
+ yield "";
135
+ yield ` const ${routeHandlers} = {`;
136
+ // Policy chains for each operation
137
+ for (const operation of service.operations) {
138
+ const operationName = parseCase(operation.operation.name);
139
+ const containerName = parseCase(operation.container.name);
140
+ yield ` ${containerName.snakeCase}_${operationName.snakeCase}: createPolicyChainForRoute(`;
141
+ yield ` "${containerName.camelCase + operationName.pascalCase + "Dispatch"}",`;
142
+ yield ` ${routePolicies},`;
143
+ yield ` "${containerName.camelCase}",`;
144
+ yield ` "${operationName.camelCase}",`;
145
+ yield ` serverRaw.${containerName.snakeCase}_${operationName.snakeCase},`;
146
+ yield ` ),`;
147
+ }
148
+ yield ` } as const;`;
149
+ yield "";
150
+ // Core routing function definition
151
+ yield ` const dispatch = createPolicyChain("${routerName}Dispatch", options.policies ?? [], async function(ctx, request, response) {`;
152
+ yield ` const url = new URL(request.url!, \`http://\${request.headers.host}\`);`;
153
+ yield ` let path = url.pathname;`;
154
+ yield "";
155
+ yield* indent(indent(emitRouteHandler(ctx, routeHandlers, routeTree, backends, module)));
156
+ yield "";
157
+ yield ` return ctx.errorHandlers.onRequestNotFound(ctx);`;
158
+ yield ` });`;
159
+ yield "";
160
+ const errorHandlers = ctx.gensym("errorHandlers");
161
+ yield ` const ${errorHandlers} = {`;
162
+ yield ` onRequestNotFound: ${onRequestNotFound},`;
163
+ yield ` onInvalidRequest: ${onInvalidRequest},`;
164
+ yield ` onInternalError: ${onInternalError},`;
165
+ yield ` };`;
166
+ yield ` return {`;
167
+ yield ` dispatch(request, response) {`;
168
+ yield ` const ctx = { request, response, errorHandlers: ${errorHandlers} };`;
169
+ yield ` return dispatch(ctx, request, response).catch((e) => ${onInternalError}(ctx, e));`;
170
+ yield ` },`;
171
+ if (ctx.options.express) {
172
+ yield ` expressMiddleware: function (request, response, next) {`;
173
+ yield ` const ctx = { request, response, errorHandlers: ${errorHandlers} };`;
174
+ yield ` void dispatch(`;
175
+ yield ` { request, response, errorHandlers: {`;
176
+ yield ` ...${errorHandlers},`;
177
+ yield ` onRequestNotFound: function () { next() }`;
178
+ yield ` }},`;
179
+ yield ` request,`;
180
+ yield ` response`;
181
+ yield ` ).catch((e) => ${onInternalError}(ctx, e));`;
182
+ yield ` },`;
183
+ }
184
+ yield " }";
185
+ yield "}";
186
+ }
187
+ /**
188
+ * Writes handling code for a single route tree node.
189
+ *
190
+ * @param ctx - The emitter context.
191
+ * @param routeTree - The route tree node to write handling code for.
192
+ * @param backends - The map of backends for operations.
193
+ * @param module - The module we're writing to.
194
+ */
195
+ function* emitRouteHandler(ctx, routeHandlers, routeTree, backends, module) {
196
+ const mustTerminate = routeTree.edges.length === 0 && !routeTree.bind;
197
+ const onRouteNotFound = "ctx.errorHandlers.onRequestNotFound";
198
+ yield `if (path.length === 0) {`;
199
+ if (routeTree.operations.size > 0) {
200
+ yield* indent(emitRouteOperationDispatch(ctx, routeHandlers, routeTree.operations, backends));
201
+ }
202
+ else {
203
+ // Not found
204
+ yield ` return ${onRouteNotFound}(ctx);`;
205
+ }
206
+ yield `}`;
207
+ if (mustTerminate) {
208
+ // Not found
209
+ yield "else {";
210
+ yield ` return ${onRouteNotFound}(ctx);`;
211
+ yield `}`;
212
+ return;
213
+ }
214
+ for (const [edge, nextTree] of routeTree.edges) {
215
+ const edgePattern = edge.length === 1 ? `'${edge}'` : JSON.stringify(edge);
216
+ yield `else if (path.startsWith(${edgePattern})) {`;
217
+ yield ` path = path.slice(${edge.length});`;
218
+ yield* indent(emitRouteHandler(ctx, routeHandlers, nextTree, backends, module));
219
+ yield "}";
220
+ }
221
+ if (routeTree.bind) {
222
+ const [parameterSet, nextTree] = routeTree.bind;
223
+ const parameters = [...parameterSet];
224
+ yield `else {`;
225
+ const paramName = parameters.length === 1 ? parameters[0] : "param";
226
+ const idxName = `__${parseCase(paramName).snakeCase}_idx`;
227
+ yield ` let ${idxName} = path.indexOf("/");`;
228
+ yield ` ${idxName} = ${idxName} === -1 ? path.length : ${idxName};`;
229
+ yield ` const ${paramName} = path.slice(0, ${idxName});`;
230
+ yield ` path = path.slice(${idxName});`;
231
+ if (parameters.length !== 1) {
232
+ for (const p of parameters) {
233
+ yield ` const ${parseCase(p).camelCase} = param;`;
234
+ }
235
+ }
236
+ yield* indent(emitRouteHandler(ctx, routeHandlers, nextTree, backends, module));
237
+ yield `}`;
238
+ }
239
+ }
240
+ /**
241
+ * Writes the dispatch code for a specific set of operations mapped to the same route.
242
+ *
243
+ * @param ctx - The emitter context.
244
+ * @param operations - The operations mapped to the route.
245
+ * @param backends - The map of backends for operations.
246
+ */
247
+ function* emitRouteOperationDispatch(ctx, routeHandlers, operations, backends) {
248
+ yield `switch (request.method) {`;
249
+ for (const [verb, operationList] of operations.entries()) {
250
+ if (operationList.length === 1) {
251
+ const operation = operationList[0];
252
+ const [backend] = backends.get(operation.container);
253
+ const operationName = keywordSafe(backend.snakeCase + "_" + parseCase(operation.operation.name).snakeCase);
254
+ const backendMemberName = backend.camelCase;
255
+ const parameters = operation.parameters.length > 0
256
+ ? ", " + operation.parameters.map((param) => parseCase(param.name).camelCase).join(", ")
257
+ : "";
258
+ yield ` case ${JSON.stringify(verb.toUpperCase())}:`;
259
+ yield ` return ${routeHandlers}.${operationName}(ctx, ${backendMemberName}${parameters});`;
260
+ }
261
+ else {
262
+ // Shared route
263
+ const route = getHttpOperation(ctx.program, operationList[0].operation)[0].path;
264
+ yield ` case ${JSON.stringify(verb.toUpperCase())}:`;
265
+ yield* indent(indent(emitRouteOperationDispatchMultiple(ctx, routeHandlers, operationList, route, backends)));
266
+ }
267
+ }
268
+ yield ` default:`;
269
+ yield ` return ctx.errorHandlers.onRequestNotFound(ctx);`;
270
+ yield "}";
271
+ }
272
+ /**
273
+ * Writes the dispatch code for a specific set of operations mapped to the same route.
274
+ *
275
+ * @param ctx - The emitter context.
276
+ * @param operations - The operations mapped to the route.
277
+ * @param backends - The map of backends for operations.
278
+ */
279
+ function* emitRouteOperationDispatchMultiple(ctx, routeHandlers, operations, route, backends) {
280
+ const usedContentTypes = new Set();
281
+ const contentTypeMap = new Map();
282
+ for (const operation of operations) {
283
+ const [httpOperation] = getHttpOperation(ctx.program, operation.operation);
284
+ const operationContentType = httpOperation.parameters.parameters.find((param) => param.type === "header" && param.name.toLowerCase() === "content-type")?.param.type;
285
+ if (!operationContentType || operationContentType.kind !== "String") {
286
+ throw new UnimplementedError("Only string content-types are supported for route differentiation.");
287
+ }
288
+ if (usedContentTypes.has(operationContentType.value)) {
289
+ reportDiagnostic(ctx.program, {
290
+ code: "undifferentiable-route",
291
+ target: httpOperation.operation,
292
+ });
293
+ }
294
+ usedContentTypes.add(operationContentType.value);
295
+ contentTypeMap.set(operation, operationContentType.value);
296
+ }
297
+ const contentTypeName = ctx.gensym("contentType");
298
+ yield `const ${contentTypeName} = parseHeaderValueParameters(request.headers["content-type"])?.value;`;
299
+ yield `switch (${contentTypeName}) {`;
300
+ for (const [operation, contentType] of contentTypeMap.entries()) {
301
+ const [backend] = backends.get(operation.container);
302
+ const operationName = keywordSafe(backend.snakeCase + "_" + parseCase(operation.operation.name).snakeCase);
303
+ const backendMemberName = backend.camelCase;
304
+ const parameters = operation.parameters.length > 0
305
+ ? ", " + operation.parameters.map((param) => parseCase(param.name).camelCase).join(", ")
306
+ : "";
307
+ const contentTypeValue = parseHeaderValueParameters(contentType).value;
308
+ yield ` case ${JSON.stringify(contentTypeValue)}:`;
309
+ yield ` return ${routeHandlers}.${operationName}(ctx, ${backendMemberName}${parameters});`;
310
+ }
311
+ yield ` default:`;
312
+ yield ` return ctx.errorHandlers.onInvalidRequest(ctx, ${JSON.stringify(route)}, \`No operation in route '${route}' matched content-type "\${${contentTypeName}}"\`);`;
313
+ yield "}";
314
+ }
315
+ /**
316
+ * Create a route tree for a given service.
317
+ */
318
+ function createRouteTree(ctx, service) {
319
+ // First get the Route for each operation in the service.
320
+ const routes = service.operations.map(function (operation) {
321
+ const segments = getRouteSegments(ctx, operation);
322
+ return {
323
+ operation: operation.operation,
324
+ container: operation.container,
325
+ verb: operation.verb,
326
+ parameters: segments.filter((segment) => typeof segment !== "string"),
327
+ segments,
328
+ };
329
+ });
330
+ // Build the tree by iteratively removing common prefixes from the text segments.
331
+ const tree = intoRouteTree(routes);
332
+ return tree;
333
+ }
334
+ /**
335
+ * Build a route tree from a list of routes.
336
+ *
337
+ * This iteratively removes common segments from the routes and then for all routes matching a given common prefix,
338
+ * builds a nested tree from their subsequent segments.
339
+ *
340
+ * @param routes - the routes to build the tree from
341
+ */
342
+ function intoRouteTree(routes) {
343
+ const [operations, rest] = bifilter(routes, (route) => route.segments.length === 0);
344
+ const [literal, parameterized] = bifilter(rest, (route) => typeof route.segments[0] === "string");
345
+ const edgeMap = new Map();
346
+ // Group the routes by common prefix
347
+ outer: for (const literalRoute of literal) {
348
+ const segment = literalRoute.segments[0];
349
+ for (const edge of [...edgeMap.keys()]) {
350
+ const prefix = commonPrefix(segment, edge);
351
+ if (prefix.length > 0) {
352
+ const existing = edgeMap.get(edge);
353
+ edgeMap.delete(edge);
354
+ edgeMap.set(prefix, [...existing, literalRoute]);
355
+ continue outer;
356
+ }
357
+ }
358
+ edgeMap.set(segment, [literalRoute]);
359
+ }
360
+ const edges = [...edgeMap.entries()].map(([edge, routes]) => [
361
+ edge,
362
+ intoRouteTree(routes.map(function removePrefix(route) {
363
+ const [prefix, ...rest] = route.segments;
364
+ if (prefix === edge) {
365
+ return { ...route, segments: rest };
366
+ }
367
+ else {
368
+ return {
369
+ ...route,
370
+ segments: [prefix.substring(edge.length), ...rest],
371
+ };
372
+ }
373
+ })),
374
+ ]);
375
+ let bind;
376
+ if (parameterized.length > 0) {
377
+ const parameters = new Set();
378
+ const nextRoutes = [];
379
+ for (const parameterizedRoute of parameterized) {
380
+ const [{ name }, ...rest] = parameterizedRoute.segments;
381
+ parameters.add(name);
382
+ nextRoutes.push({ ...parameterizedRoute, segments: rest });
383
+ }
384
+ bind = [parameters, intoRouteTree(nextRoutes)];
385
+ }
386
+ const operationMap = new Map();
387
+ for (const operation of operations) {
388
+ let operations = operationMap.get(operation.verb);
389
+ if (!operations) {
390
+ operations = [];
391
+ operationMap.set(operation.verb, operations);
392
+ }
393
+ operations.push(operation);
394
+ }
395
+ return {
396
+ operations: operationMap,
397
+ bind,
398
+ edges,
399
+ };
400
+ function commonPrefix(a, b) {
401
+ let i = 0;
402
+ while (i < a.length && i < b.length && a[i] === b[i]) {
403
+ i++;
404
+ }
405
+ return a.substring(0, i);
406
+ }
407
+ }
408
+ function getRouteSegments(ctx, operation) {
409
+ // Parse the route template into segments of "prefixes" (i.e. literal strings)
410
+ // and parameters (names enclosed in curly braces). The "/" character does not
411
+ // actually matter for this. We just want to know what the segments of the route
412
+ // are.
413
+ //
414
+ // Examples:
415
+ // "" => []
416
+ // "/users" => ["/users"]
417
+ // "/users/{userId}" => ["/users/", {name: "userId"}]
418
+ // "/users/{userId}/posts/{postId}" => ["/users/", {name: "userId"}, "/posts/", {name: "postId"}]
419
+ const segments = [];
420
+ const parameterTypeMap = new Map([...operation.parameters.parameters.values()].map((p) => [
421
+ p.param.name,
422
+ p.param.type.kind === "ModelProperty" ? p.param.type.type : p.param.type,
423
+ ]));
424
+ let remainingTemplate = operation.path;
425
+ while (remainingTemplate.length > 0) {
426
+ // Scan for next `{` character
427
+ const openBraceIndex = remainingTemplate.indexOf("{");
428
+ if (openBraceIndex === -1) {
429
+ // No more parameters, just add the remaining string as a segment
430
+ segments.push(remainingTemplate);
431
+ break;
432
+ }
433
+ // Add the prefix before the parameter, if there is one
434
+ if (openBraceIndex > 0) {
435
+ segments.push(remainingTemplate.substring(0, openBraceIndex));
436
+ }
437
+ // Scan for next `}` character
438
+ const closeBraceIndex = remainingTemplate.indexOf("}", openBraceIndex);
439
+ if (closeBraceIndex === -1) {
440
+ // This is an error in the HTTP layer, so we'll just treat it as if the parameter ends here
441
+ // and captures the rest of the string as its name.
442
+ segments.push({
443
+ name: remainingTemplate.substring(openBraceIndex + 1),
444
+ type: undefined,
445
+ });
446
+ break;
447
+ }
448
+ // Extract the parameter name
449
+ const parameterName = remainingTemplate.substring(openBraceIndex + 1, closeBraceIndex);
450
+ segments.push({
451
+ name: parameterName,
452
+ type: parameterTypeMap.get(parameterName),
453
+ });
454
+ // Move to the next segment
455
+ remainingTemplate = remainingTemplate.substring(closeBraceIndex + 1);
456
+ }
457
+ return segments;
458
+ }
459
+ //# sourceMappingURL=router.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"router.js","sourceRoot":"","sources":["../../../../src/http/server/router.ts"],"names":[],"mappings":"AAAA,sCAAsC;AACtC,kCAAkC;AAGlC,OAAO,EAKL,gBAAgB,GACjB,MAAM,gBAAgB,CAAC;AACxB,OAAO,EACL,6BAA6B,EAC7B,+BAA+B,GAChC,MAAM,2BAA2B,CAAC;AACnC,OAAO,EAAE,iBAAiB,EAAE,MAAM,2BAA2B,CAAC;AAC9D,OAAO,EAAU,YAAY,EAAE,MAAM,cAAc,CAAC;AACpD,OAAO,EAAU,SAAS,EAAE,MAAM,oBAAoB,CAAC;AACvD,OAAO,EAAE,QAAQ,EAAE,MAAM,EAAE,MAAM,oBAAoB,CAAC;AACtD,OAAO,EAAE,WAAW,EAAE,MAAM,wBAAwB,CAAC;AAGrD,OAAO,EAAE,MAAM,IAAI,aAAa,EAAE,MAAM,2CAA2C,CAAC;AACpF,OAAO,EAAE,MAAM,IAAI,YAAY,EAAE,MAAM,2CAA2C,CAAC;AACnF,OAAO,EAAE,0BAA0B,EAAE,MAAM,yBAAyB,CAAC;AACrE,OAAO,EAAE,gBAAgB,EAAE,MAAM,cAAc,CAAC;AAChD,OAAO,EAAE,kBAAkB,EAAE,MAAM,qBAAqB,CAAC;AAEzD;;;;;;;;;GASG;AACH,MAAM,UAAU,UAAU,CAAC,GAAgB,EAAE,OAAoB,EAAE,eAAuB;IACxF,MAAM,YAAY,GAAG,YAAY,CAAC,QAAQ,EAAE,GAAG,CAAC,UAAU,CAAC,CAAC;IAE5D,MAAM,SAAS,GAAG,eAAe,CAAC,GAAG,E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
@@ -0,0 +1,5 @@
1
+ import { EmitContext } from "@typespec/compiler";
2
+ import { JsEmitterOptions } from "./lib.js";
3
+ export { $lib } from "./lib.js";
4
+ export declare function $onEmit(context: EmitContext<JsEmitterOptions>): Promise<void>;
5
+ //# sourceMappingURL=index.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../src/index.ts"],"names":[],"mappings":"AAGA,OAAO,EAAE,WAAW,EAAE,MAAM,oBAAoB,CAAC;AAGjD,OAAO,EAAE,gBAAgB,EAAE,MAAM,UAAU,CAAC;AAW5C,OAAO,EAAE,IAAI,EAAE,MAAM,UAAU,CAAC;AAEhC,wBAAsB,OAAO,CAAC,OAAO,EAAE,WAAW,CAAC,gBAAgB,CAAC,iBAoCnE"}
@@ -0,0 +1,38 @@
1
+ // Copyright (c) Microsoft Corporation
2
+ // Licensed under the MIT license.
3
+ import { visitAllTypes } from "./common/namespace.js";
4
+ import { createInitialContext } from "./ctx.js";
5
+ import { writeModuleTree } from "./write.js";
6
+ // #region features
7
+ import path from "node:path";
8
+ import { emitSerialization } from "./common/serialization/index.js";
9
+ import { emitHttp } from "./http/index.js";
10
+ // #endregion
11
+ export { $lib } from "./lib.js";
12
+ export async function $onEmit(context) {
13
+ const jsCtx = await createInitialContext(context.program, context.options);
14
+ if (!jsCtx)
15
+ return;
16
+ await emitHttp(jsCtx);
17
+ if (!context.options["omit-unreachable-types"]) {
18
+ // Visit everything in the service namespace to ensure we emit a full `models` module and not just the subparts that
19
+ // are reachable from the service impl.
20
+ visitAllTypes(jsCtx, jsCtx.service.type);
21
+ }
22
+ // Emit serialization code for all required types.
23
+ emitSerialization(jsCtx);
24
+ const srcGeneratedPath = path.join(context.emitterOutputDir, "src", "generated");
25
+ if (!context.program.compilerOptions.noEmit) {
26
+ try {
27
+ const stat = await context.program.host.stat(srcGeneratedPath);
28
+ if (stat.isDirectory()) {
29
+ await context.program.host.rm(srcGeneratedPath, {
30
+ recursive: true,
31
+ });
32
+ }
33
+ }
34
+ catch { }
35
+ await writeModuleTree(jsCtx, context.emitterOutputDir, jsCtx.rootModule, !context.options["no-format"]);
36
+ }
37
+ }
38
+ //# sourceMappingURL=index.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"index.js","sourceRoot":"","sources":["../../src/index.ts"],"names":[],"mappings":"AAAA,sCAAsC;AACtC,kCAAkC;AAGlC,OAAO,EAAE,aAAa,EAAE,MAAM,uBAAuB,CAAC;AACtD,OAAO,EAAE,oBAAoB,EAAE,MAAM,UAAU,CAAC;AAEhD,OAAO,EAAE,eAAe,EAAE,MAAM,YAAY,CAAC;AAE7C,mBAAmB;AAEnB,OAAO,IAAI,MAAM,WAAW,CAAC;AAC7B,OAAO,EAAE,iBAAiB,EAAE,MAAM,iCAAiC,CAAC;AACpE,OAAO,EAAE,QAAQ,EAAE,MAAM,iBAAiB,CAAC;AAE3C,aAAa;AAEb,OAAO,EAAE,IAAI,EAAE,MAAM,UAAU,CAAC;AAEhC,MAAM,CAAC,KAAK,UAAU,OAAO,CAAC,OAAsC;IAClE,MAAM,KAAK,GAAG,MAAM,oBAAoB,CAAC,OAAO,CAAC,OAAO,EAAE,OAAO,CAAC,OAAO,CAAC,CAAC;IAE3E,IAAI,CAAC,KAAK;QAAE,OAAO;IAEnB,MAAM,QAAQ,CAAC,KAAK,CAAC,CAAC;IAEtB,IAAI,CAAC,OAAO,CAAC,OAAO,CAAC,wBAAwB,CAAC,EAAE,CAAC;QAC/C,oHAAoH;QACpH,uCAAuC;QAEvC,aAAa,CAAC,KAAK,EAAE,KAAK,CAAC,OAAO,CAAC,IAAI,CAAC,CAAC;IAC3C,CAAC;IAED,kDAAkD;IAClD,iBAAiB,CAAC,KAAK,CAAC,CAAC;IAEzB,MAAM,gBAAgB,GAAG,IAAI,CAAC,IAAI,CAAC,OAAO,CAAC,gBAAgB,EAAE,KAAK,EAAE,WAAW,CAAC,CAAC;IAEjF,IAAI,CAAC,OAAO,CAAC,OAAO,C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