typespec-fastify 0.1.0 → 0.3.0

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 (56) hide show
  1. package/LICENSE +21 -0
  2. package/dist/src/components/ModelsDirectory.js +8 -2
  3. package/dist/src/components/ModelsDirectory.js.map +1 -1
  4. package/dist/src/components/ModelsDirectory.jsx +4 -0
  5. package/dist/src/components/ModelsDirectory.jsx.map +1 -1
  6. package/dist/src/components/OperationInterface.js +45 -30
  7. package/dist/src/components/OperationInterface.js.map +1 -1
  8. package/dist/src/components/OperationInterface.jsx +30 -23
  9. package/dist/src/components/OperationInterface.jsx.map +1 -1
  10. package/dist/src/components/OperationsDirectory.js +12 -4
  11. package/dist/src/components/OperationsDirectory.js.map +1 -1
  12. package/dist/src/components/OperationsDirectory.jsx +14 -1
  13. package/dist/src/components/OperationsDirectory.jsx.map +1 -1
  14. package/dist/src/components/ResponseTypes.d.ts +4 -0
  15. package/dist/src/components/ResponseTypes.js +21 -0
  16. package/dist/src/components/ResponseTypes.js.map +1 -0
  17. package/dist/src/components/ResponseTypes.jsx +27 -0
  18. package/dist/src/components/ResponseTypes.jsx.map +1 -0
  19. package/dist/src/components/RouteRegistration.d.ts +2 -2
  20. package/dist/src/components/RouteRegistration.js +142 -71
  21. package/dist/src/components/RouteRegistration.js.map +1 -1
  22. package/dist/src/components/RouteRegistration.jsx +148 -49
  23. package/dist/src/components/RouteRegistration.jsx.map +1 -1
  24. package/dist/src/components/RouterFile.js +19 -15
  25. package/dist/src/components/RouterFile.js.map +1 -1
  26. package/dist/src/components/RouterFile.jsx +11 -9
  27. package/dist/src/components/RouterFile.jsx.map +1 -1
  28. package/dist/src/components/RoutesDirectory.js +27 -26
  29. package/dist/src/components/RoutesDirectory.js.map +1 -1
  30. package/dist/src/components/RoutesDirectory.jsx +12 -15
  31. package/dist/src/components/RoutesDirectory.jsx.map +1 -1
  32. package/dist/src/components/ZodSchemasDirectory.d.ts +9 -0
  33. package/dist/src/components/ZodSchemasDirectory.js +37 -0
  34. package/dist/src/components/ZodSchemasDirectory.js.map +1 -0
  35. package/dist/src/components/ZodSchemasDirectory.jsx +25 -0
  36. package/dist/src/components/ZodSchemasDirectory.jsx.map +1 -0
  37. package/dist/src/emitter.js +13 -1
  38. package/dist/src/emitter.js.map +1 -1
  39. package/dist/src/emitter.jsx +6 -1
  40. package/dist/src/emitter.jsx.map +1 -1
  41. package/dist/src/external-packages/fastify-type-provider-zod.d.ts +5 -0
  42. package/dist/src/external-packages/fastify-type-provider-zod.js +11 -0
  43. package/dist/src/external-packages/fastify-type-provider-zod.js.map +1 -0
  44. package/dist/src/lib.d.ts +8 -1
  45. package/dist/src/lib.js +8 -1
  46. package/dist/src/lib.js.map +1 -1
  47. package/dist/src/utils/http-helpers.d.ts +0 -13
  48. package/dist/src/utils/http-helpers.js +0 -22
  49. package/dist/src/utils/http-helpers.js.map +1 -1
  50. package/package.json +55 -24
  51. package/dist/test/hello.test.d.ts +0 -1
  52. package/dist/test/hello.test.js +0 -187
  53. package/dist/test/hello.test.js.map +0 -1
  54. package/dist/test/test-host.d.ts +0 -5
  55. package/dist/test/test-host.js +0 -52
  56. package/dist/test/test-host.js.map +0 -1
@@ -1,7 +1,8 @@
1
- import { memo as _$memo, createComponent as _$createComponent } from "@alloy-js/core/jsx-runtime";
2
- import { code } from "@alloy-js/core";
1
+ import { createComponent as _$createComponent, memo as _$memo } from "@alloy-js/core/jsx-runtime";
2
+ import { code, For } from "@alloy-js/core";
3
3
  import * as ts from "@alloy-js/typescript";
4
4
  import { fastifyLib } from "../external-packages/fastify.js";
5
+ import { fastifyTypeProviderZod } from "../external-packages/fastify-type-provider-zod.js";
5
6
  import { getOperationInterfaceRef } from "./OperationInterface.js";
6
7
  /**
7
8
  * Generates the router.ts file which creates a router registration function.
@@ -11,14 +12,19 @@ export function RouterFile(props) {
11
12
  const containerNames = Array.from(props.groupedOperations.keys());
12
13
  const operationsType = _$createComponent(ts.InterfaceExpression, {
13
14
  get children() {
14
- return containerNames.map(function renderContainerProp(containerName) {
15
- const interfaceRef = getOperationInterfaceRef(containerName);
16
- return [_$createComponent(ts.InterfaceMember, {
17
- get name() {
18
- return containerName.toLowerCase();
19
- },
20
- children: interfaceRef
21
- }), "; "];
15
+ return _$createComponent(For, {
16
+ each: containerNames,
17
+ semicolon: true,
18
+ hardline: true,
19
+ children: containerName => {
20
+ const interfaceRef = getOperationInterfaceRef(containerName);
21
+ return _$createComponent(ts.InterfaceMember, {
22
+ get name() {
23
+ return containerName.toLowerCase();
24
+ },
25
+ children: interfaceRef
26
+ });
27
+ }
22
28
  });
23
29
  }
24
30
  });
@@ -40,14 +46,12 @@ export function RouterFile(props) {
40
46
  },
41
47
  returnType: "void",
42
48
  get children() {
43
- return code`await ${_$createComponent(ts.FunctionCallExpression, {
49
+ return [_$memo(() => code`server.setValidatorCompiler(${fastifyTypeProviderZod.validatorCompiler});`), _$memo(() => code`server.setSerializerCompiler(${fastifyTypeProviderZod.serializerCompiler});`), _$memo(() => code`await ${_$createComponent(ts.FunctionCallExpression, {
44
50
  get target() {
45
51
  return props.loadRoutesRef;
46
52
  },
47
- get args() {
48
- return [["server"], ["operations"]];
49
- }
50
- })};`;
53
+ args: ["server", "operations"]
54
+ })};`)];
51
55
  }
52
56
  });
53
57
  }
@@ -1 +1 @@
1
- {"version":3,"names":["code","ts","fastifyLib","getOperationInterfaceRef","RouterFile","props","containerNames","Array","from","groupedOperations","keys","operationsType","_$createComponent","InterfaceExpression","children","map","renderContainerProp","containerName","interfaceRef","InterfaceMember","name","toLowerCase","SourceFile","path","FunctionDeclaration","async","parameters","type","FastifyInstance","returnType","FunctionCallExpression","target","loadRoutesRef","args"],"sources":["../../../src/components/RouterFile.tsx"],"sourcesContent":[null],"mappings":";AAAA,SAASA,IAAI,QAAqB,gBAAgB;AAClD,OAAO,KAAKC,EAAE,MAAM,sBAAsB;AAE1C,SAASC,UAAU,QAAQ,iCAAiC;AAC5D,SAASC,wBAA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code","For","ts","fastifyLib","fastifyTypeProviderZod","getOperationInterfaceRef","RouterFile","props","containerNames","Array","from","groupedOperations","keys","operationsType","_$createComponent","InterfaceExpression","children","each","semicolon","hardline","containerName","interfaceRef","InterfaceMember","name","toLowerCase","SourceFile","path","FunctionDeclaration","async","parameters","type","FastifyInstance","returnType","_$memo","validatorCompiler","serializerCompiler","FunctionCallExpression","target","loadRoutesRef","args"],"sources":["../../../src/components/RouterFile.tsx"],"sourcesContent":[null],"mappings":";AAAA,SAASA,IAAI,EAAeC,GAAG,QAAQ,gBAAgB;AACvD,OAAO,KAAKC,EAAE,MAAM,sBAAsB;AAE1C,SAASC,UAAU,QAAQ,iCAAiC;AAC5D,SAASC,sBAAsB,QAAQ,mDAAmD;AAC1F,SAASC,wBAAwB,QAAQ,yBAAyB;AAQlE;AACA;AACA;AACA;AACA,OAAO,SAASC,UAAUA,CAACC,KAAsB,EAAE;EACjD,MAAMC,cAAc,GAAGC,KAAK,CAACC,IAAI,CAACH,KAAK,CAACI,iBAAiB,CAACC,IAAI,CAAC,CAAC,CAAC;EAEjE,MAAMC,cAAc,GAAAC,iBAAA,CACjBZ,EAAE,CAACa,mBAAmB;IAAA,IAAAC,SAAA;MAAA,OAAAF,iBAAA,CACpBb,GAAG;QAACgB,IAAI,EAAET,cAAc;QAAEU,SAAS;QAACC,QAAQ;QAAAH,QAAA,EACzCI,aAAa,IAAK;UAClB,MAAMC,YAAY,GAAGhB,wBAAwB,CAACe,aAAa,CAAC;UAC5D,OAAAN,iBAAA,CACGZ,EAAE,CAACoB,eAAe;YAAA,IAACC,IAAIA,CAAA;cAAA,OAAEH,aAAa,CAACI,WAAW,CAAC,CAAC;YAAA;YAAAR,QAAA,EAClDK;UAAY;QAGnB;MAAC;IAAA;EAAA,EAGN;EAED,OAAAP,iBAAA,CACGZ,EAAE,CAACuB,UAAU;IAACC,IAAI;IAAA,IAAAV,SAAA;MAAA,OAAAF,iBAAA,CAChBZ,EAAE,CAACyB,mBAAmB;QACrBJ,IAAI;QAAA;QAEJK,KAAK;QAAA,IACLC,UAAUA,CAAA;UAAA,OAAE,CACV;YAAEN,IAAI,EAAE,QAAQ;YAAEO,IAAI,EAAE3B,UAAU,CAAC4B;UAAgB,CAAC,EACpD;YAAER,IAAI,EAAE,YAAY;YAAEO,IAAI,EAAEjB;UAAe,CAAC,CAC7C;QAAA;QACDmB,UAAU;QAAA,IAAAhB,SAAA;UAAA,QAAAiB,MAAA,OAETjC,IAAI,+BAA+BI,sBAAsB,CAAC8B,iBAAiB,IAAI,GAAAD,MAAA,OAC/EjC,IAAI,gCAAgCI,sBAAsB,CAAC+B,kBAAkB,IAAI,GAAAF,MAAA,OACjFjC,IAAI,SAAAc,iBAAA,CACFZ,EAAE,CAACkC,sBAAsB;YAAA,IACxBC,MAAMA,CAAA;cAAA,OAAE9B,KAAK,CAAC+B,aAAa;YAAA;YAC3BC,IAAI,EAAE,CAAC,QAAQ,EAAE,YAAY;UAAC,KAE9B;QAAA;MAAA;IAAA;EAAA;AAIZ","ignoreList":[]}
@@ -1,6 +1,7 @@
1
- import { code } from "@alloy-js/core";
1
+ import { code, For } from "@alloy-js/core";
2
2
  import * as ts from "@alloy-js/typescript";
3
3
  import { fastifyLib } from "../external-packages/fastify.js";
4
+ import { fastifyTypeProviderZod } from "../external-packages/fastify-type-provider-zod.js";
4
5
  import { getOperationInterfaceRef } from "./OperationInterface.js";
5
6
  /**
6
7
  * Generates the router.ts file which creates a router registration function.
@@ -9,22 +10,23 @@ import { getOperationInterfaceRef } from "./OperationInterface.js";
9
10
  export function RouterFile(props) {
10
11
  const containerNames = Array.from(props.groupedOperations.keys());
11
12
  const operationsType = (<ts.InterfaceExpression>
12
- {containerNames.map(function renderContainerProp(containerName) {
13
+ <For each={containerNames} semicolon hardline>
14
+ {(containerName) => {
13
15
  const interfaceRef = getOperationInterfaceRef(containerName);
14
- return (<>
15
- <ts.InterfaceMember name={containerName.toLowerCase()}>
16
+ return (<ts.InterfaceMember name={containerName.toLowerCase()}>
16
17
  {interfaceRef}
17
- </ts.InterfaceMember>
18
- {"; "}
19
- </>);
20
- })}
18
+ </ts.InterfaceMember>);
19
+ }}
20
+ </For>
21
21
  </ts.InterfaceExpression>);
22
22
  return (<ts.SourceFile path="router.ts">
23
23
  <ts.FunctionDeclaration name="registerRoutes" export async parameters={[
24
24
  { name: "server", type: fastifyLib.FastifyInstance },
25
25
  { name: "operations", type: operationsType },
26
26
  ]} returnType="void">
27
- {code `await ${(<ts.FunctionCallExpression target={props.loadRoutesRef} args={[<>server</>, <>operations</>]}/>)};`}
27
+ {code `server.setValidatorCompiler(${fastifyTypeProviderZod.validatorCompiler});`}
28
+ {code `server.setSerializerCompiler(${fastifyTypeProviderZod.serializerCompiler});`}
29
+ {code `await ${(<ts.FunctionCallExpression target={props.loadRoutesRef} args={["server", "operations"]}/>)};`}
28
30
  </ts.FunctionDeclaration>
29
31
  </ts.SourceFile>);
30
32
  }
@@ -1 +1 @@
1
- {"version":3,"file":"RouterFile.jsx","sourceRoot":"","sources":["../../../src/components/RouterFile.tsx"],"names":[],"mappings":"AAAA,OAAO,EAAE,IAAI,EAAe,MAAM,gBAAgB,CAAC;AACnD,OAAO,KAAK,EAAE,MAAM,sBAAsB,CAAC;AAE3C,OAAO,EAAE,UAAU,EAAE,MAAM,iCAAiC,CAAC;AAC7D,OAAO,EAAE,wBAAwB,EAAE,MAAM,yBAAyB,CAAC;AAQnE;;;GAGG;AACH,MAAM,UAAU,UAAU,CAAC,KAAsB;IAC/C,MAAM,cAAc,GAAG,KAAK,CAAC,IAAI,CAAC,KAAK,CAAC,iBAAiB,CAAC,IAAI,EAAE,CAAC,CAAC;IAElE,MAAM,cAAc,GAAG,CACrB,CAAC,EAAE,CAAC,mBAAmB,CACrB;MAAA,CAAC,cAAc,CAAC,GAAG,CAAC,SAAS,mBAAmB,CAAC,aAAa;YAC5D,MAAM,YAAY,GAAG,wBAAwB,CAAC,aAAa,CAAC,CAAC;YAC7D,OAAO,CACL,EACE;YAA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ACZ,CAAC,EAAE,CAAC,sBAAsB,CACxB,MAAM,CAAC,CAAC,KAAK,CAAC,aAAa,CAAC,CAC5B,IAAI,CAAC,CAAC,CAAC,QAAQ,EAAE,YAAY,CAAC,CAAC,EAC/B,CACH,GAAG,CACN;MAAA,EAAE,EAAE,CAAC,mBAAmB,CAC1B;IAAA,EAAE,EAAE,CAAC,UAAU,CAAC,CACjB,CAAC;AACJ,CAAC"}
@@ -1,4 +1,4 @@
1
- import { memo as _$memo, createComponent as _$createComponent } from "@alloy-js/core/jsx-runtime";
1
+ import { createComponent as _$createComponent } from "@alloy-js/core/jsx-runtime";
2
2
  import { For, List, SourceDirectory } from "@alloy-js/core";
3
3
  import * as ts from "@alloy-js/typescript";
4
4
  import { RouteRegistration, getRouteRegistrationRef } from "./RouteRegistration.js";
@@ -15,14 +15,19 @@ export function RoutesDirectory(props) {
15
15
  const containerNames = Array.from(groupedOperations.keys());
16
16
  const operationsType = _$createComponent(ts.InterfaceExpression, {
17
17
  get children() {
18
- return containerNames.map(function renderContainerProp(containerName) {
19
- const interfaceRef = getOperationInterfaceRef(containerName);
20
- return [_$createComponent(ts.InterfaceMember, {
21
- get name() {
22
- return containerName.toLowerCase();
23
- },
24
- children: interfaceRef
25
- }), "; "];
18
+ return _$createComponent(For, {
19
+ each: containerNames,
20
+ semicolon: true,
21
+ hardline: true,
22
+ children: containerName => {
23
+ const interfaceRef = getOperationInterfaceRef(containerName);
24
+ return _$createComponent(ts.InterfaceMember, {
25
+ get name() {
26
+ return containerName.toLowerCase();
27
+ },
28
+ children: interfaceRef
29
+ });
30
+ }
26
31
  });
27
32
  }
28
33
  });
@@ -33,19 +38,17 @@ export function RoutesDirectory(props) {
33
38
  get each() {
34
39
  return Array.from(groupedOperations.entries());
35
40
  },
36
- children: function renderRoutes([containerName, operations]) {
37
- return _$createComponent(ts.SourceFile, {
38
- get path() {
39
- return `${containerName.toLowerCase()}.routes.ts`;
40
- },
41
- get children() {
42
- return _$createComponent(RouteRegistration, {
43
- containerName: containerName,
44
- operations: operations
45
- });
46
- }
47
- });
48
- }
41
+ children: ([containerName, operations]) => _$createComponent(ts.SourceFile, {
42
+ get path() {
43
+ return `${containerName.toLowerCase()}.routes.ts`;
44
+ },
45
+ get children() {
46
+ return _$createComponent(RouteRegistration, {
47
+ containerName: containerName,
48
+ operations: operations
49
+ });
50
+ }
51
+ })
49
52
  }), _$createComponent(ts.SourceFile, {
50
53
  path: "index.ts",
51
54
  get children() {
@@ -69,14 +72,12 @@ export function RoutesDirectory(props) {
69
72
  get children() {
70
73
  return _$createComponent(For, {
71
74
  each: containerNames,
72
- children: function renderRegistration(containerName) {
75
+ children: function (containerName) {
73
76
  const routeRegRef = getRouteRegistrationRef(containerName);
74
77
  const containerKey = containerName.toLowerCase();
75
78
  return ["await", " ", _$createComponent(ts.FunctionCallExpression, {
76
79
  target: routeRegRef,
77
- get args() {
78
- return [["server"], ["operations.", containerKey]];
79
- }
80
+ args: ["server", `operations.${containerKey}`]
80
81
  }), ";"];
81
82
  }
82
83
  });
@@ -1 +1 @@
1
- {"version":3,"names":["For","List","SourceDirectory","ts","RouteRegistration","getRouteRegistrationRef","fastifyLib","getOperationInterfaceRef","RoutesDirectory","props","groupedOperations","loadRoutesRef","containerNames","Array","from","keys","operationsType","_$createComponent","InterfaceExpression","children","map","renderContainerProp","containerName","interfaceRef","InterfaceMember","name","toLowerCase","path","each","entries","renderRoutes","operations","SourceFile","FunctionDeclaration","refkey","async","parameters","type","FastifyInstance","returnType","renderRegistration","routeRegRef","containerKey","FunctionCallExpression","target","args"],"sources":["../../../src/components/RoutesDirectory.tsx"],"sourcesContent":[null],"mappings":";AAAA,SAASA,GAAG,EAAEC,IAAI,EAAEC,eAAe,QAAqB,gBAAgB;AACxE,OAAO,KAAKC,EAAE,MAAM,sBAAsB;AAE1C,SACEC,iBAAiB,EACjBC,uBAAuB,QAClB,wBAAwB;AAC/B,SAASC,UAAU,QAAQ,iCAAiC;AAC5D,SAASC,wBAAwB,QAAQ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AACL,IAAI;QAAA,IAAAR,SAAA;UAAA,OAAAF,iBAAA,CAChBd,EAAE,CAAC8B,mBAAmB;YACrBR,IAAI;YAAA;YAEJS,MAAM,EAAEvB,aAAa;YACrBwB,KAAK;YAAA,IACLC,UAAUA,CAAA;cAAA,OAAE,CACV;gBAAEX,IAAI,EAAE,QAAQ;gBAAEY,IAAI,EAAE/B,UAAU,CAACgC;cAAgB,CAAC,EACpD;gBAAEb,IAAI,EAAE,YAAY;gBAAEY,IAAI,EAAErB;cAAe,CAAC,CAC7C;YAAA;YACDuB,UAAU;YAAA,IAAApB,SAAA;cAAA,OAAAF,iBAAA,CAEThB,IAAI;gBAAA,IAAAkB,SAAA;kBAAA,OAAAF,iBAAA,CACFjB,GAAG;oBAAC4B,IAAI,EAAEhB,cAAc;oBAAAO,QAAA,EACtB,SAASqB,kBAAkBA,CAAClB,aAAa,EAAE;sBAC1C,MAAMmB,WAAW,GAAGpC,uBAAuB,CAACiB,aAAa,CAAC;sBAC1D,MAAMoB,YAAY,GAAGpB,aAAa,CAACI,WAAW,CAAC,CAAC;sBAChD,iBAEU,GAAG,EAAAT,iBAAA,CACRd,EAAE,CAACwC,sBAAsB;wBACxBC,MAAM,EAAEH,WAAW;wBAAA,IACnBI,IAAIA,CAAA;0BAAA,OAAE,6BAA4BH,YAAY,EAAK;wBAAA;sBAAA,IAEpD,GAAG;oBAGV;kBAAC;gBAAA;cAAA;YAAA;UAAA;QAAA;MAAA;IAAA;EAAA;AAOf","ignoreList":[]}
1
+ {"version":3,"names":["For","List","SourceDirectory","ts","RouteRegistration","getRouteRegistrationRef","fastifyLib","getOperationInterfaceRef","RoutesDirectory","props","groupedOperations","loadRoutesRef","containerNames","Array","from","keys","operationsType","_$createComponent","InterfaceExpression","children","each","semicolon","hardline","containerName","interfaceRef","InterfaceMember","name","toLowerCase","path","entries","operations","SourceFile","FunctionDeclaration","refkey","async","parameters","type","FastifyInstance","returnType","routeRegRef","containerKey","FunctionCallExpression","target","args"],"sources":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  const containerNames = Array.from(groupedOperations.keys());
12
12
  const operationsType = (<ts.InterfaceExpression>
13
- {containerNames.map(function renderContainerProp(containerName) {
13
+ <For each={containerNames} semicolon hardline>
14
+ {(containerName) => {
14
15
  const interfaceRef = getOperationInterfaceRef(containerName);
15
- return (<>
16
- <ts.InterfaceMember name={containerName.toLowerCase()}>
16
+ return (<ts.InterfaceMember name={containerName.toLowerCase()}>
17
17
  {interfaceRef}
18
- </ts.InterfaceMember>
19
- {"; "}
20
- </>);
21
- })}
18
+ </ts.InterfaceMember>);
19
+ }}
20
+ </For>
22
21
  </ts.InterfaceExpression>);
23
22
  return (<SourceDirectory path="routes">
24
23
  <For each={Array.from(groupedOperations.entries())}>
25
- {function renderRoutes([containerName, operations]) {
26
- return (<ts.SourceFile path={`${containerName.toLowerCase()}.routes.ts`}>
27
- <RouteRegistration containerName={containerName} operations={operations}/>
28
- </ts.SourceFile>);
29
- }}
24
+ {([containerName, operations]) => (<ts.SourceFile path={`${containerName.toLowerCase()}.routes.ts`}>
25
+ <RouteRegistration containerName={containerName} operations={operations}/>
26
+ </ts.SourceFile>)}
30
27
  </For>
31
28
 
32
29
  <ts.SourceFile path="index.ts">
@@ -36,13 +33,13 @@ export function RoutesDirectory(props) {
36
33
  ]} returnType="void">
37
34
  <List>
38
35
  <For each={containerNames}>
39
- {function renderRegistration(containerName) {
36
+ {function (containerName) {
40
37
  const routeRegRef = getRouteRegistrationRef(containerName);
41
38
  const containerKey = containerName.toLowerCase();
42
39
  return (<>
43
40
  await{" "}
44
- <ts.FunctionCallExpression target={routeRegRef} args={[<>server</>, <>operations.{containerKey}</>]}/>
45
- {";"}
41
+ <ts.FunctionCallExpression target={routeRegRef} args={["server", `operations.${containerKey}`]}/>
42
+ ;
46
43
  </>);
47
44
  }}
48
45
  </For>
@@ -1 +1 @@
1
- {"version":3,"file":"RoutesDirectory.jsx","sourceRoot":"","sources":["../../../src/components/RoutesDirectory.tsx"],"names":[],"mappings":"AAAA,OAAO,EAAE,G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AE,CAAC,CAAC,EAEjD;;kBACF,GAAG,CACJ,CAAC;QACJ,CAAC,CACH;YAAA,EAAE,GAAG,CACP;UAAA,EAAE,IAAI,CACR;QAAA,EAAE,EAAE,CAAC,mBAAmB,CAC1B;MAAA,EAAE,EAAE,CAAC,UAAU,CACjB;IAAA,EAAE,eAAe,CAAC,CACnB,CAAC;AACJ,CAAC"}
@@ -0,0 +1,9 @@
1
+ import type { Type } from "@typespec/compiler";
2
+ export interface ZodSchemasDirectoryProps {
3
+ namespace: string;
4
+ types: Type[];
5
+ }
6
+ /**
7
+ * Generates Zod schemas for TypeSpec types using the typespec-zod library.
8
+ */
9
+ export declare function ZodSchemasDirectory(props: ZodSchemasDirectoryProps): import("@alloy-js/core").Children;
@@ -0,0 +1,37 @@
1
+ import { createComponent as _$createComponent } from "@alloy-js/core/jsx-runtime";
2
+ import { For, SourceDirectory } from "@alloy-js/core";
3
+ import * as ts from "@alloy-js/typescript";
4
+ import { ZodSchemaDeclaration } from "typespec-zod";
5
+ /**
6
+ * Generates Zod schemas for TypeSpec types using the typespec-zod library.
7
+ */
8
+ export function ZodSchemasDirectory(props) {
9
+ const declarationTypes = props.types.filter(isDeclarationType);
10
+ return _$createComponent(SourceDirectory, {
11
+ path: "schemas",
12
+ get children() {
13
+ return _$createComponent(ts.SourceFile, {
14
+ get path() {
15
+ return `${props.namespace.toLowerCase()}.ts`;
16
+ },
17
+ get children() {
18
+ return _$createComponent(For, {
19
+ each: declarationTypes,
20
+ hardline: true,
21
+ children: function (type) {
22
+ return _$createComponent(ZodSchemaDeclaration, {
23
+ "export": true,
24
+ "const": true,
25
+ type: type
26
+ });
27
+ }
28
+ });
29
+ }
30
+ });
31
+ }
32
+ });
33
+ }
34
+ function isDeclarationType(type) {
35
+ return type.kind === "Model" || type.kind === "Enum" || type.kind === "Union" || type.kind === "Scalar";
36
+ }
37
+ //# sourceMappingURL=ZodSchemasDirectory.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"names":["For","SourceDirectory","ts","ZodSchemaDeclaration","ZodSchemasDirectory","props","declarationTypes","types","filter","isDeclarationType","_$createComponent","path","children","SourceFile","namespace","toLowerCase","each","hardline","type","kind"],"sources":["../../../src/components/ZodSchemasDirectory.tsx"],"sourcesContent":[null],"mappings":";AAAA,SAASA,GAAG,EAAEC,eAAe,QAAQ,gBAAgB;AACrD,OAAO,KAAKC,EAAE,MAAM,sBAAsB;AAE1C,SAASC,oBAAoB,QAAQ,cAAc;AAOnD;AACA;AACA;AACA,OAAO,SAASC,mBAAmBA,CAACC,KAA+B,EAAE;EACnE,MAAMC,gBAAgB,GAAGD,KAAK,CAACE,KAAK,CAACC,MAAM,CAACC,iBAAiB,CAAC;EAE9D,OAAAC,iBAAA,CACGT,eAAe;IAACU,IAAI;IAAA,IAAAC,SAAA;MAAA,OAAAF,iBAAA,CAClBR,EAAE,CAACW,UAAU;QAAA,IAACF,IAAIA,CAAA;UAAA,OAAE,GAAGN,KAAK,CAACS,SAAS,CAACC,WAAW,CAAC,CAAC,KAAK;QAAA;QAAA,IAAAH,SAAA;UAAA,OAAAF,iBAAA,CACvDV,GAAG;YAACgB,IAAI,EAAEV,gBAAgB;YAAEW,QAAQ;YAAAL,QAAA,EAClC,SAAAA,CAAUM,IAAI,EAAE;cACf,OAAAR,iBAAA,CAAQP,oBAAoB;gBAAA;gBAAA;gBAAce,IAAI,EAAEA;cAAI;YACtD;UAAC;QAAA;MAAA;IAAA;EAAA;AAKX;AAOA,SAAST,iBAAiBA,CAACS,IAAU,EAA2B;EAC9D,OACEA,IAAI,CAACC,IAAI,KAAK,OAAO,IACrBD,IAAI,CAACC,IAAI,KAAK,MAAM,IACpBD,IAAI,CAACC,IAAI,KAAK,OAAO,IACrBD,IAAI,CAACC,IAAI,KAAK,QAAQ;AAE1B","ignoreList":[]}
@@ -0,0 +1,25 @@
1
+ import { For, SourceDirectory } from "@alloy-js/core";
2
+ import * as ts from "@alloy-js/typescript";
3
+ import { ZodSchemaDeclaration } from "typespec-zod";
4
+ /**
5
+ * Generates Zod schemas for TypeSpec types using the typespec-zod library.
6
+ */
7
+ export function ZodSchemasDirectory(props) {
8
+ const declarationTypes = props.types.filter(isDeclarationType);
9
+ return (<SourceDirectory path="schemas">
10
+ <ts.SourceFile path={`${props.namespace.toLowerCase()}.ts`}>
11
+ <For each={declarationTypes} hardline>
12
+ {function (type) {
13
+ return <ZodSchemaDeclaration export const type={type}/>;
14
+ }}
15
+ </For>
16
+ </ts.SourceFile>
17
+ </SourceDirectory>);
18
+ }
19
+ function isDeclarationType(type) {
20
+ return (type.kind === "Model" ||
21
+ type.kind === "Enum" ||
22
+ type.kind === "Union" ||
23
+ type.kind === "Scalar");
24
+ }
25
+ //# sourceMappingURL=ZodSchemasDirectory.jsx.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"ZodSchemasDirectory.jsx","sourceRoot":"","sources":["../../../src/components/ZodSchemasDirectory.tsx"],"names":[],"mappings":"AAAA,OAAO,EAAE,GAAG,EAAE,eAAe,EAAE,MAAM,gBAAgB,CAAC;AACtD,OAAO,KAAK,EAAE,MAAM,sBAAsB,CAAC;AAE3C,OAAO,EAAE,oBAAoB,EAAE,MAAM,cAAc,CAAC;AAOpD;;GAEG;AACH,MAAM,UAAU,mBAAmB,CAAC,KAA+B;IACjE,MAAM,gBAAgB,GAAG,KAAK,CAAC,KAAK,CAAC,MAAM,CAAC,iBAAiB,CAAC,CAAC;IAE/D,OAAO,CACL,CAAC,eAAe,CAAC,IAAI,CAAC,SAAS,CAC7B;MAAA,CAAC,EAAE,CAAC,UAAU,CAAC,IAAI,CAAC,CAAC,GAAG,KAAK,CAAC,SAAS,CAAC,WAAW,EAAE,KAAK,CAAC,CACzD;QAAA,CAAC,GAAG,CAAC,IAAI,CAAC,CAAC,gBAAgB,CAAC,CAAC,QAAQ,CACnC;UAAA,CAAC,UAAU,IAAI;YACb,OAAO,CAAC,oBAAoB,CAAC,MAAM,CAAC,KAAK,CAAC,IAAI,CAAC,CAAC,IAAI,CAAC,EAAG,CAAC;QAC3D,CAAC,CACH;QAAA,EAAE,GAAG,CACP;MAAA,EAAE,EAAE,CAAC,UAAU,CACjB;IAAA,EAAE,eAAe,CAAC,CACnB,CAAC;AACJ,CAAC;AAOD,SAAS,iBAAiB,CAAC,IAAU;IACnC,OAAO,CACL,IAAI,CAAC,IAAI,KAAK,OAAO;QACrB,IAAI,CAAC,IAAI,KAAK,MAAM;QACpB,IAAI,CAAC,IAAI,KAAK,OAAO;QACrB,IAAI,CAAC,IAAI,KAAK,QAAQ,CACvB,CAAC;AACJ,CAAC"}
@@ -1,11 +1,15 @@
1
1
  import { createComponent as _$createComponent } from "@alloy-js/core/jsx-runtime";
2
2
  import { refkey, SourceDirectory } from "@alloy-js/core";
3
+ import { createTSNamePolicy } from "@alloy-js/typescript";
3
4
  import { Output, writeOutput } from "@typespec/emitter-framework";
4
5
  import { ModelsDirectory } from "./components/ModelsDirectory.js";
5
6
  import { OperationsDirectory } from "./components/OperationsDirectory.js";
6
7
  import { RouterFile } from "./components/RouterFile.js";
7
8
  import { RoutesDirectory } from "./components/RoutesDirectory.js";
9
+ import { ZodSchemasDirectory } from "./components/ZodSchemasDirectory.js";
8
10
  import { fastifyLib } from "./external-packages/fastify.js";
11
+ import { fastifyTypeProviderZod } from "./external-packages/fastify-type-provider-zod.js";
12
+ import { zod } from "typespec-zod";
9
13
  import { getHttpOperations, groupOperationsByContainer } from "./utils/http-helpers.js";
10
14
  import { discoverTypesFromOperations } from "./utils/type-discovery.js";
11
15
  export async function $onEmit(context) {
@@ -21,7 +25,10 @@ export async function $onEmit(context) {
21
25
  get program() {
22
26
  return context.program;
23
27
  },
24
- externals: [fastifyLib],
28
+ externals: [fastifyLib, zod, fastifyTypeProviderZod],
29
+ get namePolicy() {
30
+ return createTSNamePolicy();
31
+ },
25
32
  get children() {
26
33
  return _$createComponent(SourceDirectory, {
27
34
  path: ".",
@@ -31,6 +38,11 @@ export async function $onEmit(context) {
31
38
  return httpInfo.namespace;
32
39
  },
33
40
  types: allTypes
41
+ }), _$createComponent(ZodSchemasDirectory, {
42
+ get namespace() {
43
+ return httpInfo.namespace;
44
+ },
45
+ types: allTypes
34
46
  }), _$createComponent(OperationsDirectory, {
35
47
  groupedOperations: groupedOperations
36
48
  }), _$createComponent(RoutesDirectory, {
@@ -1 +1 @@
1
- {"version":3,"names":["refkey","SourceDirectory","Output","writeOutput","ModelsDirectory","OperationsDirectory","RouterFile","RoutesDirectory","fastifyLib","getHttpOperations","groupOperationsByContainer","discoverTypesFromOperations","$onEmit","context","httpInfo","program","console","warn","groupedOperations","operations","allTypes","loadRoutesRef","_$createComponent","externals","children","path","namespace","types","emitterOutputDir"],"sources":["../../src/emitter.tsx"],"sourcesContent":[null],"mappings":";AAAA,SAASA,MAAM,EAAEC,eAAe,QAAQ,gBAAgB;AAExD,SAASC,MAAM,EAAEC,WAAW,QAAQ,6BAA6B;AACjE,SAASC,eAAe,QAAQ,iCAAiC;AACjE,SAASC,mBAAmB,QAAQ,qCAAqC;AACzE,SAASC,UAAU,QAAQ,4BAA4B;AACvD,SAASC,eAAe,QAAQ,iCAAiC;AACjE,SAASC,UAAU,QAAQ,gCAAgC;AAE3D,SACEC,iBAAiB,EACjBC,0BAA0B,QACrB,yBAAyB;AAChC,SAASC,2BAA2B,QAAQ,2BAA2B;AAEvE,OAAO,eAAeC,OAAOA,CAACC,OAAoC,EAAE;EAClE,MAAMC,QAAQ,GAAGL,iBAAiB,CAACI,OAAO,CAACE,OAAO,CAAC;EAEnD,IAAI,CAACD,QAAQ,EAAE;IACbE,OAAO,CAACC,IAAI,CAAC,kCAAkC,CAAC;IAChD;EACF;EAEA,MAAMC,iBAAiB,GAAGR,0BAA0B,CAACI,QAAQ,CAACK,UAAU,CAAC;EACzE,MAAMC,QAAQ,GAAGT,2BAA2B,CAC1CE,OAAO,CAACE,OAAO,EACfD,QAAQ,CAACK,UACX,CAAC;EAED,MAAME,aAAa,GAAGrB,MAAM,CAAC,YAAY,EAAE,cAAc,CAAC;EAE1D,MAAMG,WAAW,CACfU,OAAO,CAACE,OAAO,EAAAO,iBAAA,CACdpB,MAAM;IAAA,IAACa,OAAOA,CAAA;MAAA,OAAEF,OAAO,CAACE,OAAO;IAAA;IAAEQ,SAAS,EAAE,CAACf,UAAU,CAAC;IAAA,IAAAgB,SAAA;MAAA,OAAAF,iBAAA,CACtDrB,eAAe;QAACwB,IAAI;QAAA,IAAAD,SAAA;UAAA,QAAAF,iBAAA,CAClBlB,eAAe;YAAA,IAACsB,SAASA,CAAA;cAAA,OAAEZ,QAAQ,CAACY,SAAS;YAAA;YAAEC,KAAK,EAAEP;UAAQ,IAAAE,iBAAA,CAC9DjB,mBAAmB;YAACa,iBAAiB,EAAEA;UAAiB,IAAAI,iBAAA,CACxDf,eAAe;YACdW,iBAAiB,EAAEA,iBAAiB;YACpCG,aAAa,EAAEA;UAAa,IAAAC,iBAAA,CAE7BhB,UAAU;YAAA,IACToB,SAASA,CAAA;cAAA,OAAEZ,QAAQ,CAACY,SAAS;YAAA;YAC7BL,aAAa,EAAEA,aAAa;YAC5BH,iBAAiB,EAAEA;UAAiB;QAAA;MAAA;IAAA;EAAA,IAI1CL,OAAO,CAACe,gBACV,CAAC;AACH","ignoreList":[]}
1
+ {"version":3,"names":["refkey","SourceDirectory","createTSNamePolicy","Output","writeOutput","ModelsDirectory","OperationsDirectory","RouterFile","RoutesDirectory","ZodSchemasDirectory","fastifyLib","fastifyTypeProviderZod","zod","getHttpOperations","groupOperationsByContainer","discoverTypesFromOperations","$onEmit","context","httpInfo","program","console","warn","groupedOperations","operations","allTypes","loadRoutesRef","_$createComponent","externals","namePolicy","children","path","namespace","types","emitterOutputDir"],"sources":["../../src/emitter.tsx"],"sourcesContent":[null],"mappings":";AAAA,SAASA,MAAM,EAAEC,eAAe,QAAQ,gBAAgB;AACxD,SAASC,kBAAkB,QAAQ,sBAAsB;AAEzD,SAASC,MAAM,EAAEC,WAAW,QAAQ,6BAA6B;AACjE,SAASC,eAAe,QAAQ,iC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,EAAER;UAAQ,IAAAE,iBAAA,CAC9DjB,mBAAmB;YAAA,IAACsB,SAASA,CAAA;cAAA,OAAEb,QAAQ,CAACa,SAAS;YAAA;YAAEC,KAAK,EAAER;UAAQ,IAAAE,iBAAA,CAClEpB,mBAAmB;YAACgB,iBAAiB,EAAEA;UAAiB,IAAAI,iBAAA,CACxDlB,eAAe;YACdc,iBAAiB,EAAEA,iBAAiB;YACpCG,aAAa,EAAEA;UAAa,IAAAC,iBAAA,CAE7BnB,UAAU;YAAA,IACTwB,SAASA,CAAA;cAAA,OAAEb,QAAQ,CAACa,SAAS;YAAA;YAC7BN,aAAa,EAAEA,aAAa;YAC5BH,iBAAiB,EAAEA;UAAiB;QAAA;MAAA;IAAA;EAAA,IAI1CL,OAAO,CAACgB,gBACV,CAAC;AACH","ignoreList":[]}
@@ -1,10 +1,14 @@
1
1
  import { refkey, SourceDirectory } from "@alloy-js/core";
2
+ import { createTSNamePolicy } from "@alloy-js/typescript";
2
3
  import { Output, writeOutput } from "@typespec/emitter-framework";
3
4
  import { ModelsDirectory } from "./components/ModelsDirectory.js";
4
5
  import { OperationsDirectory } from "./components/OperationsDirectory.js";
5
6
  import { RouterFile } from "./components/RouterFile.js";
6
7
  import { RoutesDirectory } from "./components/RoutesDirectory.js";
8
+ import { ZodSchemasDirectory } from "./components/ZodSchemasDirectory.js";
7
9
  import { fastifyLib } from "./external-packages/fastify.js";
10
+ import { fastifyTypeProviderZod } from "./external-packages/fastify-type-provider-zod.js";
11
+ import { zod } from "typespec-zod";
8
12
  import { getHttpOperations, groupOperationsByContainer, } from "./utils/http-helpers.js";
9
13
  import { discoverTypesFromOperations } from "./utils/type-discovery.js";
10
14
  export async function $onEmit(context) {
@@ -16,9 +20,10 @@ export async function $onEmit(context) {
16
20
  const groupedOperations = groupOperationsByContainer(httpInfo.operations);
17
21
  const allTypes = discoverTypesFromOperations(context.program, httpInfo.operations);
18
22
  const loadRoutesRef = refkey("loadRoutes", "route-loader");
19
- await writeOutput(context.program, <Output program={context.program} externals={[fastifyLib]}>
23
+ await writeOutput(context.program, <Output program={context.program} externals={[fastifyLib, zod, fastifyTypeProviderZod]} namePolicy={createTSNamePolicy()}>
20
24
  <SourceDirectory path=".">
21
25
  <ModelsDirectory namespace={httpInfo.namespace} types={allTypes}/>
26
+ <ZodSchemasDirectory namespace={httpInfo.namespace} types={allTypes}/>
22
27
  <OperationsDirectory groupedOperations={groupedOperations}/>
23
28
  <RoutesDirectory groupedOperations={groupedOperations} loadRoutesRef={loadRoutesRef}/>
24
29
  <RouterFile namespace={httpInfo.namespace} loadRoutesRef={loadRoutesRef} groupedOperations={groupedOperations}/>
@@ -1 +1 @@
1
- {"version":3,"file":"emitter.jsx","sourceRoot":"","sources":["../../src/emitter.tsx"],"names":[],"mappings":"AAAA,OAAO,EAAE,MAAM,EAAE,eAAe,EAAE,MAAM,gBAAgB,CAAC;AAEzD,OAAO,EAAE,MAAM,EAAE,WAAW,EAAE,MAAM,6BAA6B,CAAC;AAClE,OAAO,EAAE,eAAe,EAAE,MAAM,iCAAiC,CAAC;AAClE,OAAO,EAAE,mBAAmB,EAAE,MAAM,qCAAqC,CAAC;AAC1E,OAAO,EAAE,UAAU,EAAE,MAAM,4BAA4B,CAAC;AACxD,OAAO,EAAE,eAAe,EAAE,MAAM,iCAAiC,CAAC;AAClE,OAAO,EAAE,UAAU,EAAE,MAAM,gCAAgC,CAAC;AAE5D,OAAO,EACL,iBAAiB,EACjB,0BAA0B,GAC3B,MAAM,yBAAyB,CAAC;AACjC,OAAO,EAAE,2BAA2B,EAAE,MAAM,2BAA2B,CAAC;AAExE,MAAM,CAAC,KAAK,UAAU,OAAO,CAAC,OAAoC;IAChE,MAAM,QAAQ,GAAG,iBAAiB,CAAC,OAAO,CAAC,OAAO,CAAC,CAAC;IAEpD,IAAI,CAAC,QAAQ,EAAE,CAAC;QACd,OAAO,CAAC,IAAI,CAAC,kCAAkC,CAAC,CAAC;QACjD,OAAO;IACT,CAAC;IAED,MAAM,i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AC,IAAI,CAAC,GAAG,CACvB;QAAA,CAAC,eAAe,CAAC,SAAS,CAAC,CAAC,QAAQ,CAAC,SAAS,CAAC,CAAC,KAAK,CAAC,CAAC,QAAQ,CAAC,EAChE;QAAA,CAAC,mBAAmB,CAAC,SAAS,CAAC,CAAC,QAAQ,CAAC,SAAS,CAAC,CAAC,KAAK,CAAC,CAAC,QAAQ,CAAC,EACpE;QAAA,CAAC,mBAAmB,CAAC,iBAAiB,CAAC,CAAC,iBAAiB,CAAC,EAC1D;QAAA,CAAC,eAAe,CACd,iBAAiB,CAAC,CAAC,iBAAiB,CAAC,CACrC,aAAa,CAAC,CAAC,aAAa,CAAC,EAE/B;QAAA,CAAC,UAAU,CACT,SAAS,CAAC,CAAC,QAAQ,CAAC,SAAS,CAAC,CAC9B,aAAa,CAAC,CAAC,aAAa,CAAC,CAC7B,iBAAiB,CAAC,CAAC,iBAAiB,CAAC,EAEzC;MAAA,EAAE,eAAe,CACnB;IAAA,EAAE,MAAM,CAAC,EACT,OAAO,CAAC,gBAAgB,CACzB,CAAC;AACJ,CAAC"}
@@ -0,0 +1,5 @@
1
+ export declare const fastifyTypeProviderZod: {
2
+ serializerCompiler: import("@alloy-js/core").Refkey;
3
+ validatorCompiler: import("@alloy-js/core").Refkey;
4
+ ZodTypeProvider: import("@alloy-js/core").Refkey;
5
+ } & {} & {} & import("@alloy-js/core").SymbolCreator & import("@alloy-js/typescript").ExternalPackage;
@@ -0,0 +1,11 @@
1
+ import { createPackage } from "@alloy-js/typescript";
2
+ export const fastifyTypeProviderZod = createPackage({
3
+ name: "fastify-type-provider-zod",
4
+ version: "^4.0.0",
5
+ descriptor: {
6
+ ".": {
7
+ named: ["serializerCompiler", "validatorCompiler", "ZodTypeProvider"]
8
+ }
9
+ }
10
+ });
11
+ //# sourceMappingURL=fastify-type-provider-zod.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"names":["createPackage","fastifyTypeProviderZod","name","version","descriptor","named"],"sources":["../../../src/external-packages/fastify-type-provider-zod.ts"],"sourcesContent":[null],"mappings":"AAAA,SAASA,aAAa,QAAQ,sBAAsB;AAEpD,OAAO,MAAMC,sBAAsB,GAAGD,aAAa,CAAC;EAClDE,IAAI,EAAE,2BAA2B;EACjCC,OAAO,EAAE,QAAQ;EACjBC,UAAU,EAAE;IACV,GAAG,EAAE;MACHC,KAAK,EAAE,CAAC,oBAAoB,EAAE,mBAAmB,EAAE,iBAAiB;IACtE;EACF;AACF,CAAC,CAAC","ignoreList":[]}
package/dist/src/lib.d.ts CHANGED
@@ -1,4 +1,11 @@
1
- export type EmitterOptions = Record<string, never>;
1
+ export interface EmitterOptions {
2
+ /**
3
+ * Schema validation library to use.
4
+ * Currently only "zod" is supported.
5
+ * @default "zod"
6
+ */
7
+ schemaType?: "zod" | "typebox";
8
+ }
2
9
  export declare const $lib: import("@typespec/compiler").TypeSpecLibrary<{
3
10
  "http-emit-disabled": {
4
11
  readonly default: "Cannot emit Fastify server due to errors in HTTP service definition.";
package/dist/src/lib.js CHANGED
@@ -2,7 +2,14 @@ import { createTypeSpecLibrary } from "@typespec/compiler";
2
2
  const EmitterOptionsSchema = {
3
3
  type: "object",
4
4
  additionalProperties: false,
5
- properties: {},
5
+ properties: {
6
+ schemaType: {
7
+ type: "string",
8
+ enum: ["zod", "typebox"],
9
+ nullable: true,
10
+ default: "zod"
11
+ }
12
+ },
6
13
  required: []
7
14
  };
8
15
  export const $lib = createTypeSpecLibrary({
@@ -1 +1 @@
1
- {"version":3,"names":["createTypeSpecLibrary","EmitterOptionsSchema","type","additionalProperties","properties","required","$lib","name","diagnostics","severity","messages","default","emitter","options","reportDiagnostic","createDiagnostic"],"sources":["../../src/lib.ts"],"sourcesContent":[null],"mappings":"AAAA,SAASA,qBAAqB,QAAwB,oBAAoB;AAI1E,MAAMC,oBAAoD,GAAG;EAC3DC,IAAI,EAAE,QAAQ;EACdC,oBAAoB,EAAE,KAAK;EAC3BC,UAAU,EAAE,CAAC,CAAC;EACdC,QAAQ,EAAE;AACZ,CAAC;AAED,OAAO,MAAMC,IAAI,GAAGN,qBAAqB,CAAC;EACxCO,IAAI,EAAE,0BAA0B;EAChCC,WAAW,EAAE;IACX,oBAAoB,EAAE;MACpBC,QAAQ,EAAE,OAAO;MACjBC,QAAQ,EAAE;QACRC,OAAO,EACL;MACJ;IACF,CAAC;IACD,wBAAwB,EAAE;MACxBF,QAAQ,EAAE,OAAO;MACjBC,QAAQ,EAAE;QACRC,OAAO,EACL;MACJ;IACF;EACF,CAAC;EACDC,OAAO,EAAE;IACPC,OAAO,EAAEZ;EACX;AACF,CAAC,CAAC;AAEF,OAAO,MAAM;EAAEa,gBAAgB;EAAEC;AAAiB,CAAC,GAAGT,IAAI","ignoreList":[]}
1
+ {"version":3,"names":["createTypeSpecLibrary","EmitterOptionsSchema","type","additionalProperties","properties","schemaType","enum","nullable","default","required","$lib","name","diagnostics","severity","messages","emitter","options","reportDiagnostic","createDiagnostic"],"sources":["../../src/lib.ts"],"sourcesContent":[null],"mappings":"AAAA,SAASA,qBAAqB,QAAwB,oBAAoB;AAW1E,MAAMC,oBAAoD,GAAG;EAC3DC,IAAI,EAAE,QAAQ;EACdC,oBAAoB,EAAE,KAAK;EAC3BC,UAAU,EAAE;IACVC,UAAU,EAAE;MACVH,IAAI,EAAE,QAAQ;MACdI,IAAI,EAAE,CAAC,KAAK,EAAE,SAAS,CAAC;MACxBC,QAAQ,EAAE,IAAI;MACdC,OAAO,EAAE;IACX;EACF,CAAC;EACDC,QAAQ,EAAE;AACZ,CAAC;AAED,OAAO,MAAMC,IAAI,GAAGV,qBAAqB,CAAC;EACxCW,IAAI,EAAE,0BAA0B;EAChCC,WAAW,EAAE;IACX,oBAAoB,EAAE;MACpBC,QAAQ,EAAE,OAAO;MACjBC,QAAQ,EAAE;QACRN,OAAO,EACL;MACJ;IACF,CAAC;IACD,wBAAwB,EAAE;MACxBK,QAAQ,EAAE,OAAO;MACjBC,QAAQ,EAAE;QACRN,OAAO,EACL;MACJ;IACF;EACF,CAAC;EACDO,OAAO,EAAE;IACPC,OAAO,EAAEf;EACX;AACF,CAAC,CAAC;AAEF,OAAO,MAAM;EAAEgB,gBAAgB;EAAEC;AAAiB,CAAC,GAAGR,IAAI","ignoreList":[]}
@@ -20,16 +20,3 @@ export declare function getHttpVerb(operation: HttpOperation): string;
20
20
  * Gets the path for an operation
21
21
  */
22
22
  export declare function getOperationPath(operation: HttpOperation): string;
23
- /**
24
- * Converts a name to camelCase
25
- */
26
- export declare function toCamelCase(name: string): string;
27
- /**
28
- * Converts a name to PascalCase
29
- */
30
- export declare function toPascalCase(name: string): string;
31
- /**
32
- * Converts a path to a route name
33
- * e.g., "/pets/{petId}" -> "pets-petId"
34
- */
35
- export declare function pathToRouteName(path: string): string;
@@ -53,26 +53,4 @@ export function getHttpVerb(operation) {
53
53
  export function getOperationPath(operation) {
54
54
  return operation.path;
55
55
  }
56
-
57
- /**
58
- * Converts a name to camelCase
59
- */
60
- export function toCamelCase(name) {
61
- return name.charAt(0).toLowerCase() + name.slice(1);
62
- }
63
-
64
- /**
65
- * Converts a name to PascalCase
66
- */
67
- export function toPascalCase(name) {
68
- return name.charAt(0).toUpperCase() + name.slice(1);
69
- }
70
-
71
- /**
72
- * Converts a path to a route name
73
- * e.g., "/pets/{petId}" -> "pets-petId"
74
- */
75
- export function pathToRouteName(path) {
76
- return path.replace(/^\//, "").replace(/\//g, "-").replace(/\{/g, "").replace(/\}/g, "");
77
- }
78
56
  //# sourceMappingURL=http-helpers.js.map
@@ -1 +1 @@
1
- {"version":3,"names":["listServices","getHttpService","getHttpOperations","program","services","length","undefined","service","httpService","diagnostics","type","hasErrors","some","checkError","d","severity","operations","namespace","name","groupOperationsByContainer","grouped","Map","operation","op","container","interface","containerName","has","set","get","push","getHttpVerb","verb","toLowerCase","getOperationPath","path","toCamelCase","charAt","slice","toPascalCase","toUpperCase","pathToRouteName","replace"],"sources":["../../../src/utils/http-helpers.ts"],"sourcesContent":[null],"mappings":"AACA,SAASA,YAAY,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AACR,SAAS,CAAC;EAC7C;EAEA,OAAOF,OAAO;AAChB;;AAEA;AACA;AACA;AACA,OAAO,SAASW,WAAWA,CAACT,SAAwB,EAAU;EAC5D,OAAOA,SAAS,CAACU,IAAI,CAACC,WAAW,CAAC,CAAC;AACrC;;AAEA;AACA;AACA;AACA,OAAO,SAASC,gBAAgBA,CAACZ,SAAwB,EAAU;EACjE,OAAOA,SAAS,CAACa,IAAI;AACvB;;AAEA;AACA;AACA;AACA,OAAO,SAASC,WAAWA,CAAClB,IAAY,EAAU;EAChD,OAAOA,IAAI,CAACmB,MAAM,CAAC,CAAC,CAAC,CAACJ,WAAW,CAAC,CAAC,GAAGf,IAAI,CAACoB,KAAK,CAAC,CAAC,CAAC;AACrD;;AAEA;AACA;AACA;AACA,OAAO,SAASC,YAAYA,CAACrB,IAAY,EAAU;EACjD,OAAOA,IAAI,CAACmB,MAAM,CAAC,CAAC,CAAC,CAACG,WAAW,CAAC,CAAC,GAAGtB,IAAI,CAACoB,KAAK,CAAC,CAAC,CAAC;AACrD;;AAEA;AACA;AACA;AACA;AACA,OAAO,SAASG,eAAeA,CAACN,IAAY,EAAU;EACpD,OAAOA,IAAI,CACRO,OAAO,CAAC,KAAK,EAAE,EAAE,CAAC,CAClBA,OAAO,CAAC,KAAK,EAAE,GAAG,CAAC,CACnBA,OAAO,CAAC,KAAK,EAAE,EAAE,CAAC,CAClBA,OAAO,CAAC,KAAK,EAAE,EAAE,CAAC;AACvB","ignoreList":[]}
1
+ {"version":3,"names":["listServices","getHttpService","getHttpOperations","program","services","length","undefined","service","httpService","diagnostics","type","hasErrors","some","checkError","d","severity","operations","namespace","name","groupOperationsByContainer","grouped","Map","operation","op","container","interface","containerName","has","set","get","push","getHttpVerb","verb","toLowerCase","getOperationPath","path"],"sources":["../../../src/utils/http-helpers.ts"],"sourcesContent":[null],"mappings":"AACA,SAASA,YAAY,QAAQ,oBAAoB;AACjD,SAASC,cAAc,QAA4B,gBAAgB;AAOnE;AACA;AACA;A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