nextlove 2.10.0 → 2.11.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.
package/bin.js CHANGED
@@ -10,7 +10,7 @@ const { unregister } = register({
10
10
  if (argv.help || argv.h) {
11
11
  console.log(
12
12
  `
13
- nextlove (generate-openapi | generate-route-types) [options]
13
+ nextlove (generate-openapi | generate-route-types | extract-route-specs) [options]
14
14
 
15
15
  --packageDir <path> Path to the package directory containing the Next.js app
16
16
  --outputFile <path> Path to the output file
@@ -54,4 +54,24 @@ if (argv._[0] === "generate-openapi") {
54
54
  console.log(result)
55
55
  }
56
56
  })
57
+ } else if (argv._[0] === "extract-route-specs") {
58
+ if (argv._.length === 2) {
59
+ argv.packageDir = argv._[1]
60
+ }
61
+ if (argv["package-dir"]) {
62
+ argv.packageDir = argv["package-dir"]
63
+ }
64
+ if (!argv["packageDir"]) throw new Error("Missing --packageDir")
65
+
66
+ if (argv["allowed-import-patterns"]) {
67
+ argv.allowedImportPatterns = Array.isArray(argv["allowed-import-patterns"]) ? argv["allowed-import-patterns"] : [argv["allowed-import-patterns"]]
68
+ }
69
+
70
+ require("./dist/generators")
71
+ .extractRouteSpecs(argv)
72
+ .then((result) => {
73
+ if (!argv.outputFile) {
74
+ console.log(result)
75
+ }
76
+ })
57
77
  }
@@ -1,3 +1,5 @@
1
+ import * as esbuild from 'esbuild';
2
+
1
3
  interface TagOption {
2
4
  name: string;
3
5
  description: string;
@@ -19,8 +21,27 @@ interface GenerateOpenAPIOpts {
19
21
  */
20
22
  declare function generateOpenAPI(opts: GenerateOpenAPIOpts): Promise<string>;
21
23
 
24
+ interface GenerateRouteTypesOpts$1 {
25
+ packageDir: string;
26
+ outputFile?: string;
27
+ pathGlob?: string;
28
+ apiPrefix?: string;
29
+ mapFilePathToHTTPRoute?: (file_path: string) => string;
30
+ /**
31
+ * If provided, only routes that return true will be included in the generated types.
32
+ */
33
+ filterRoutes?: (route: string) => boolean;
34
+ /**
35
+ * By default, routes that have `excludeFromOpenApi` set to true will be excluded from the generated types.
36
+ * Set this to true to include them.
37
+ */
38
+ includeOpenApiExcludedRoutes?: boolean;
39
+ }
40
+ declare const generateRouteTypes: (opts: GenerateRouteTypesOpts$1) => Promise<string>;
41
+
22
42
  interface GenerateRouteTypesOpts {
23
43
  packageDir: string;
44
+ allowedImportPatterns?: string[];
24
45
  outputFile?: string;
25
46
  pathGlob?: string;
26
47
  apiPrefix?: string;
@@ -34,7 +55,8 @@ interface GenerateRouteTypesOpts {
34
55
  * Set this to true to include them.
35
56
  */
36
57
  includeOpenApiExcludedRoutes?: boolean;
58
+ esbuildOptions?: esbuild.BuildOptions;
37
59
  }
38
- declare const generateRouteTypes: (opts: GenerateRouteTypesOpts) => Promise<string>;
60
+ declare const extractRouteSpecs: (opts: GenerateRouteTypesOpts) => Promise<void>;
39
61
 
40
- export { generateOpenAPI, generateRouteTypes };
62
+ export { extractRouteSpecs, generateOpenAPI, generateRouteTypes };