@pavanyn/docugen 1.3.1 → 1.4.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/dist/cli.d.ts +9 -0
- package/dist/cli.d.ts.map +1 -1
- package/dist/cli.js +18 -7
- package/dist/cli.js.map +1 -1
- package/dist/detect/workspaces.d.ts.map +1 -1
- package/dist/detect/workspaces.js +18 -0
- package/dist/detect/workspaces.js.map +1 -1
- package/dist/extract/csharp-source.d.ts +2 -0
- package/dist/extract/csharp-source.d.ts.map +1 -1
- package/dist/extract/csharp-source.js +1 -0
- package/dist/extract/csharp-source.js.map +1 -1
- package/dist/extract/endpoints/aspnet-chains.d.ts +4 -0
- package/dist/extract/endpoints/aspnet-chains.d.ts.map +1 -1
- package/dist/extract/endpoints/aspnet-chains.js +4 -1
- package/dist/extract/endpoints/aspnet-chains.js.map +1 -1
- package/dist/extract/endpoints/aspnet-minimal.js +24 -2
- package/dist/extract/endpoints/aspnet-minimal.js.map +1 -1
- package/dist/extract/endpoints/django.d.ts +11 -0
- package/dist/extract/endpoints/django.d.ts.map +1 -1
- package/dist/extract/endpoints/django.js +70 -10
- package/dist/extract/endpoints/django.js.map +1 -1
- package/dist/extract/endpoints/drf.d.ts +7 -1
- package/dist/extract/endpoints/drf.d.ts.map +1 -1
- package/dist/extract/endpoints/drf.js +66 -5
- package/dist/extract/endpoints/drf.js.map +1 -1
- package/dist/extract/endpoints/express.d.ts +4 -1
- package/dist/extract/endpoints/express.d.ts.map +1 -1
- package/dist/extract/endpoints/express.js +60 -10
- package/dist/extract/endpoints/express.js.map +1 -1
- package/dist/extract/endpoints/fastapi.d.ts +10 -0
- package/dist/extract/endpoints/fastapi.d.ts.map +1 -1
- package/dist/extract/endpoints/fastapi.js +236 -9
- package/dist/extract/endpoints/fastapi.js.map +1 -1
- package/dist/extract/endpoints/go-constants.d.ts +58 -0
- package/dist/extract/endpoints/go-constants.d.ts.map +1 -0
- package/dist/extract/endpoints/go-constants.js +218 -0
- package/dist/extract/endpoints/go-constants.js.map +1 -0
- package/dist/extract/endpoints/go-http.d.ts +8 -2
- package/dist/extract/endpoints/go-http.d.ts.map +1 -1
- package/dist/extract/endpoints/go-http.js +44 -6
- package/dist/extract/endpoints/go-http.js.map +1 -1
- package/dist/extract/endpoints/go-routes.d.ts +4 -1
- package/dist/extract/endpoints/go-routes.d.ts.map +1 -1
- package/dist/extract/endpoints/go-routes.js +141 -12
- package/dist/extract/endpoints/go-routes.js.map +1 -1
- package/dist/extract/endpoints/index.d.ts.map +1 -1
- package/dist/extract/endpoints/index.js +19 -2
- package/dist/extract/endpoints/index.js.map +1 -1
- package/dist/extract/endpoints/js-routers.d.ts +15 -0
- package/dist/extract/endpoints/js-routers.d.ts.map +1 -1
- package/dist/extract/endpoints/js-routers.js +2 -32
- package/dist/extract/endpoints/js-routers.js.map +1 -1
- package/dist/extract/endpoints/nest.d.ts +13 -0
- package/dist/extract/endpoints/nest.d.ts.map +1 -1
- package/dist/extract/endpoints/nest.js +70 -28
- package/dist/extract/endpoints/nest.js.map +1 -1
- package/dist/extract/endpoints/next-api.d.ts +10 -1
- package/dist/extract/endpoints/next-api.d.ts.map +1 -1
- package/dist/extract/endpoints/next-api.js +142 -9
- package/dist/extract/endpoints/next-api.js.map +1 -1
- package/dist/extract/endpoints/paths.d.ts +8 -0
- package/dist/extract/endpoints/paths.d.ts.map +1 -1
- package/dist/extract/endpoints/paths.js +40 -0
- package/dist/extract/endpoints/paths.js.map +1 -1
- package/dist/extract/endpoints/python.d.ts.map +1 -1
- package/dist/extract/endpoints/python.js +10 -2
- package/dist/extract/endpoints/python.js.map +1 -1
- package/dist/extract/endpoints/rails-routes.d.ts +5 -0
- package/dist/extract/endpoints/rails-routes.d.ts.map +1 -1
- package/dist/extract/endpoints/rails-routes.js +4 -0
- package/dist/extract/endpoints/rails-routes.js.map +1 -1
- package/dist/extract/endpoints/rails.d.ts.map +1 -1
- package/dist/extract/endpoints/rails.js +1 -0
- package/dist/extract/endpoints/rails.js.map +1 -1
- package/dist/extract/endpoints/vercel.d.ts +12 -1
- package/dist/extract/endpoints/vercel.d.ts.map +1 -1
- package/dist/extract/endpoints/vercel.js +87 -17
- package/dist/extract/endpoints/vercel.js.map +1 -1
- package/dist/extract/schema/efcore-fluent.d.ts.map +1 -1
- package/dist/extract/schema/efcore-fluent.js +5 -1
- package/dist/extract/schema/efcore-fluent.js.map +1 -1
- package/dist/extract/schema/efcore-scan.d.ts +8 -0
- package/dist/extract/schema/efcore-scan.d.ts.map +1 -1
- package/dist/extract/schema/efcore-scan.js +49 -1
- package/dist/extract/schema/efcore-scan.js.map +1 -1
- package/dist/extract/schema/efcore.js +80 -8
- package/dist/extract/schema/efcore.js.map +1 -1
- package/dist/extract/schema/gorm.d.ts.map +1 -1
- package/dist/extract/schema/gorm.js +7 -1
- package/dist/extract/schema/gorm.js.map +1 -1
- package/dist/extract/schema/laravel-blueprint.d.ts +5 -2
- package/dist/extract/schema/laravel-blueprint.d.ts.map +1 -1
- package/dist/extract/schema/laravel-blueprint.js +11 -2
- package/dist/extract/schema/laravel-blueprint.js.map +1 -1
- package/dist/extract/schema/laravel-conditionals.d.ts +45 -0
- package/dist/extract/schema/laravel-conditionals.d.ts.map +1 -0
- package/dist/extract/schema/laravel-conditionals.js +144 -0
- package/dist/extract/schema/laravel-conditionals.js.map +1 -0
- package/dist/extract/schema/laravel-migrations.d.ts.map +1 -1
- package/dist/extract/schema/laravel-migrations.js +86 -15
- package/dist/extract/schema/laravel-migrations.js.map +1 -1
- package/dist/extract/schema/prisma.d.ts +7 -1
- package/dist/extract/schema/prisma.d.ts.map +1 -1
- package/dist/extract/schema/prisma.js +162 -19
- package/dist/extract/schema/prisma.js.map +1 -1
- package/dist/extract/schema/python-model-scan.d.ts +2 -0
- package/dist/extract/schema/python-model-scan.d.ts.map +1 -1
- package/dist/extract/schema/python-model-scan.js +65 -7
- package/dist/extract/schema/python-model-scan.js.map +1 -1
- package/dist/extract/schema/python-models.d.ts +3 -1
- package/dist/extract/schema/python-models.d.ts.map +1 -1
- package/dist/extract/schema/python-models.js +71 -8
- package/dist/extract/schema/python-models.js.map +1 -1
- package/dist/extract/schema/sql-ddl.d.ts.map +1 -1
- package/dist/extract/schema/sql-ddl.js +83 -17
- package/dist/extract/schema/sql-ddl.js.map +1 -1
- package/dist/extract/test-sources.d.ts +6 -0
- package/dist/extract/test-sources.d.ts.map +1 -1
- package/dist/extract/test-sources.js +20 -0
- package/dist/extract/test-sources.js.map +1 -1
- package/dist/graph/from-extraction.d.ts.map +1 -1
- package/dist/graph/from-extraction.js +1 -0
- package/dist/graph/from-extraction.js.map +1 -1
- package/dist/graph/python-symbols.d.ts.map +1 -1
- package/dist/graph/python-symbols.js +8 -1
- package/dist/graph/python-symbols.js.map +1 -1
- package/dist/graph/store.d.ts +1 -1
- package/dist/graph/symbols.d.ts.map +1 -1
- package/dist/graph/symbols.js +12 -2
- package/dist/graph/symbols.js.map +1 -1
- package/dist/narrate/engine.js +1 -1
- package/dist/narrate/engine.js.map +1 -1
- package/dist/narrate/planners/synthesis-shared.d.ts +1 -0
- package/dist/narrate/planners/synthesis-shared.d.ts.map +1 -1
- package/dist/narrate/planners/synthesis-shared.js +10 -1
- package/dist/narrate/planners/synthesis-shared.js.map +1 -1
- package/dist/types/entries.d.ts +7 -0
- package/dist/types/entries.d.ts.map +1 -1
- package/package.json +1 -1
|
@@ -1,5 +1,6 @@
|
|
|
1
1
|
import type { Gap } from '../../types/core.js';
|
|
2
2
|
import type { EndpointEntry } from '../../types/entries.js';
|
|
3
|
+
import type { GoConstantFile } from './go-constants.js';
|
|
3
4
|
import type { GoFileAnalysis } from './go-routes.js';
|
|
4
5
|
/**
|
|
5
6
|
* Go HTTP endpoints: Gin, Echo, Fiber, chi, and net/http method patterns.
|
|
@@ -24,8 +25,13 @@ export interface GoEndpointsResult {
|
|
|
24
25
|
* find HTTP *clients*.
|
|
25
26
|
*/
|
|
26
27
|
export declare function analyseGoFile(file: string, rawContents: string): GoFileAnalysis | undefined;
|
|
27
|
-
/**
|
|
28
|
-
|
|
28
|
+
/**
|
|
29
|
+
* Evaluate analysed files into endpoint entries. Pure: no file system.
|
|
30
|
+
*
|
|
31
|
+
* `constants` are the string constants of every Go file in the repository,
|
|
32
|
+
* router-importing or not; without them only the analysed files' own are known.
|
|
33
|
+
*/
|
|
34
|
+
export declare function evaluateGoRoutes(analyses: readonly GoFileAnalysis[], constants?: readonly GoConstantFile[]): {
|
|
29
35
|
entries: readonly EndpointEntry[];
|
|
30
36
|
gaps: readonly Gap[];
|
|
31
37
|
};
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"go-http.d.ts","sourceRoot":"","sources":["../../../src/extract/endpoints/go-http.ts"],"names":[],"mappings":"AAGA,OAAO,KAAK,EAAE,GAAG,EAAE,MAAM,qBAAqB,CAAC;AAC/C,OAAO,KAAK,EAAE,aAAa,EAAE,MAAM,wBAAwB,CAAC;AAa5D,OAAO,KAAK,EAAE,cAAc,EAA2B,MAAM,gBAAgB,CAAC;AAE9E;;;;;;;;;GASG;AAEH,MAAM,WAAW,iBAAiB;IAChC,QAAQ,CAAC,KAAK,EAAE,OAAO,CAAC;IACxB,QAAQ,CAAC,OAAO,EAAE,SAAS,aAAa,EAAE,CAAC;IAC3C,QAAQ,CAAC,IAAI,EAAE,SAAS,GAAG,EAAE,CAAC;IAC9B,qDAAqD;IACrD,QAAQ,CAAC,UAAU,EAAE,SAAS,MAAM,EAAE,CAAC;CACxC;AAID;;;;GAIG;AACH,wBAAgB,aAAa,CAAC,IAAI,EAAE,MAAM,EAAE,WAAW,EAAE,MAAM,GAAG,cAAc,GAAG,SAAS,CA2B3F;AAED
|
|
1
|
+
{"version":3,"file":"go-http.d.ts","sourceRoot":"","sources":["../../../src/extract/endpoints/go-http.ts"],"names":[],"mappings":"AAGA,OAAO,KAAK,EAAE,GAAG,EAAE,MAAM,qBAAqB,CAAC;AAC/C,OAAO,KAAK,EAAE,aAAa,EAAE,MAAM,wBAAwB,CAAC;AAa5D,OAAO,KAAK,EAAE,cAAc,EAAE,MAAM,mBAAmB,CAAC;AAExD,OAAO,KAAK,EAAE,cAAc,EAA2B,MAAM,gBAAgB,CAAC;AAE9E;;;;;;;;;GASG;AAEH,MAAM,WAAW,iBAAiB;IAChC,QAAQ,CAAC,KAAK,EAAE,OAAO,CAAC;IACxB,QAAQ,CAAC,OAAO,EAAE,SAAS,aAAa,EAAE,CAAC;IAC3C,QAAQ,CAAC,IAAI,EAAE,SAAS,GAAG,EAAE,CAAC;IAC9B,qDAAqD;IACrD,QAAQ,CAAC,UAAU,EAAE,SAAS,MAAM,EAAE,CAAC;CACxC;AAID;;;;GAIG;AACH,wBAAgB,aAAa,CAAC,IAAI,EAAE,MAAM,EAAE,WAAW,EAAE,MAAM,GAAG,cAAc,GAAG,SAAS,CA2B3F;AAED;;;;;GAKG;AACH,wBAAgB,gBAAgB,CAC9B,QAAQ,EAAE,SAAS,cAAc,EAAE,EACnC,SAAS,GAAE,SAAS,cAAc,EAAkF,GACnH;IACD,OAAO,EAAE,SAAS,aAAa,EAAE,CAAC;IAClC,IAAI,EAAE,SAAS,GAAG,EAAE,CAAC;CACtB,CAoCA;AAED,wBAAsB,kBAAkB,CAAC,IAAI,EAAE;IAC7C,IAAI,EAAE,MAAM,CAAC;IACb,OAAO,EAAE,SAAS,MAAM,EAAE,CAAC;CAC5B,GAAG,OAAO,CAAC,iBAAiB,CAAC,CAgC7B;AA0DD;;;;;GAKG;AACH,wBAAgB,QAAQ,CAAC,SAAS,EAAE,MAAM,GAAG,SAAS,MAAM,EAAE,CAY7D"}
|
|
@@ -5,6 +5,7 @@ import { toPosix } from '../../util/paths.js';
|
|
|
5
5
|
import { compareStrings } from '../../util/sort.js';
|
|
6
6
|
import { findGoFunctions, GO_IGNORE, goPackageName, maskGoStrings, readGoImports, stripGoComments, } from '../go-source.js';
|
|
7
7
|
import { joinPath } from './paths.js';
|
|
8
|
+
import { GoConstantTable, readGoConstants } from './go-constants.js';
|
|
8
9
|
import { evaluateGoRouteGraph, GO_FRAMEWORK_IMPORTS, goDirOf } from './go-routes.js';
|
|
9
10
|
const EMPTY = Object.freeze({ found: false, entries: [], gaps: [], frameworks: [] });
|
|
10
11
|
/**
|
|
@@ -41,11 +42,16 @@ export function analyseGoFile(file, rawContents) {
|
|
|
41
42
|
frameworks: [...frameworks].sort(compareStrings),
|
|
42
43
|
};
|
|
43
44
|
}
|
|
44
|
-
/**
|
|
45
|
-
|
|
45
|
+
/**
|
|
46
|
+
* Evaluate analysed files into endpoint entries. Pure: no file system.
|
|
47
|
+
*
|
|
48
|
+
* `constants` are the string constants of every Go file in the repository,
|
|
49
|
+
* router-importing or not; without them only the analysed files' own are known.
|
|
50
|
+
*/
|
|
51
|
+
export function evaluateGoRoutes(analyses, constants = analyses.map((analysis) => readGoConstants(analysis.file, analysis.stripped))) {
|
|
46
52
|
const ordered = [...analyses].sort((a, b) => compareStrings(a.file, b.file));
|
|
47
|
-
const { routes, gaps } = evaluateGoRouteGraph(ordered);
|
|
48
|
-
const entries = collapseTrailingSlashTwins(routes).map((route) => {
|
|
53
|
+
const { routes, gaps } = evaluateGoRouteGraph(ordered, new GoConstantTable(constants));
|
|
54
|
+
const entries = collapseTrailingSlashTwins(dropHelperTwins(routes)).map((route) => {
|
|
49
55
|
const fullPath = joinPath('', route.rawPath);
|
|
50
56
|
return {
|
|
51
57
|
id: `endpoint:${route.method}:${fullPath}`,
|
|
@@ -65,7 +71,7 @@ export function evaluateGoRoutes(analyses) {
|
|
|
65
71
|
compareStrings(a.path, b.path) ||
|
|
66
72
|
compareStrings(a.source.file, b.source.file) ||
|
|
67
73
|
(a.source.line ?? 0) - (b.source.line ?? 0)),
|
|
68
|
-
gaps:
|
|
74
|
+
gaps: uniqueGaps(gaps).sort((a, b) => compareStrings(a.source?.file ?? '', b.source?.file ?? '') ||
|
|
69
75
|
(a.source?.line ?? 0) - (b.source?.line ?? 0) ||
|
|
70
76
|
compareStrings(a.kind, b.kind) ||
|
|
71
77
|
compareStrings(a.message, b.message)),
|
|
@@ -78,6 +84,9 @@ export async function extractGoEndpoints(args) {
|
|
|
78
84
|
if (files.length === 0)
|
|
79
85
|
return EMPTY;
|
|
80
86
|
const analyses = [];
|
|
87
|
+
// Constants come from every file: PhotoPrism's `config.ApiUri` lives in a
|
|
88
|
+
// package that imports no router, yet names the prefix of the whole API.
|
|
89
|
+
const constants = [];
|
|
81
90
|
for (const relative of files) {
|
|
82
91
|
let contents;
|
|
83
92
|
try {
|
|
@@ -89,10 +98,11 @@ export async function extractGoEndpoints(args) {
|
|
|
89
98
|
const analysis = analyseGoFile(relative, contents);
|
|
90
99
|
if (analysis !== undefined)
|
|
91
100
|
analyses.push(analysis);
|
|
101
|
+
constants.push(readGoConstants(relative, analysis?.stripped ?? contents));
|
|
92
102
|
}
|
|
93
103
|
if (analyses.length === 0)
|
|
94
104
|
return EMPTY;
|
|
95
|
-
const { entries, gaps } = evaluateGoRoutes(analyses);
|
|
105
|
+
const { entries, gaps } = evaluateGoRoutes(analyses, constants);
|
|
96
106
|
// A router import with no registration at all (a middleware package, say) is
|
|
97
107
|
// not an endpoint source; reporting it as one would produce an empty section.
|
|
98
108
|
if (entries.length === 0 && gaps.length === 0)
|
|
@@ -100,6 +110,34 @@ export async function extractGoEndpoints(args) {
|
|
|
100
110
|
const frameworks = [...new Set(analyses.flatMap((analysis) => analysis.frameworks))].sort(compareStrings);
|
|
101
111
|
return { found: true, entries, gaps, frameworks };
|
|
102
112
|
}
|
|
113
|
+
/**
|
|
114
|
+
* A registration function reached twice — once per router handed to it, or
|
|
115
|
+
* once from its caller and once more on its own — reports the same computed
|
|
116
|
+
* path twice. One gap per kind, site and message is enough.
|
|
117
|
+
*/
|
|
118
|
+
function uniqueGaps(gaps) {
|
|
119
|
+
const seen = new Set();
|
|
120
|
+
return gaps.filter((gap) => {
|
|
121
|
+
const key = [gap.kind, gap.source?.file ?? '', gap.source?.line ?? 0, gap.message].join('\u0000');
|
|
122
|
+
if (seen.has(key))
|
|
123
|
+
return false;
|
|
124
|
+
seen.add(key);
|
|
125
|
+
return true;
|
|
126
|
+
});
|
|
127
|
+
}
|
|
128
|
+
/**
|
|
129
|
+
* A route whose path went through a helper read as the identity, landing on
|
|
130
|
+
* the same method and path as one written plainly, is that helper's other
|
|
131
|
+
* case — PhotoPrism registers `/sw.js` and, only `if conf.BaseUri("") != ""`,
|
|
132
|
+
* `conf.BaseUri("/sw.js")` again under the configured base path. Reporting the
|
|
133
|
+
* pair as competing handlers would be a finding the code does not support; the
|
|
134
|
+
* plain route is kept and the helper site keeps its `go-route-path-helper` gap.
|
|
135
|
+
*/
|
|
136
|
+
function dropHelperTwins(routes) {
|
|
137
|
+
const keyOf = (route) => `${route.method}\u0000${joinPath('', route.rawPath)}\u0000${route.resolved}`;
|
|
138
|
+
const plain = new Set(routes.filter((route) => route.viaHelper !== true).map(keyOf));
|
|
139
|
+
return routes.filter((route) => route.viaHelper !== true || !plain.has(keyOf(route)));
|
|
140
|
+
}
|
|
103
141
|
/**
|
|
104
142
|
* `router.POST("", h)` next to `router.POST("/", h)` is one endpoint written
|
|
105
143
|
* twice so that both spellings answer without a redirect. docgen's paths drop
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"go-http.js","sourceRoot":"","sources":["../../../src/extract/endpoints/go-http.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,MAAM,WAAW,CAAC;AAC3B,OAAO,EAAE,MAAM,kBAAkB,CAAC;AAClC,OAAO,IAAI,MAAM,WAAW,CAAC;AAG7B,OAAO,EAAE,OAAO,EAAE,MAAM,qBAAqB,CAAC;AAC9C,OAAO,EAAE,cAAc,EAAE,MAAM,oBAAoB,CAAC;AACpD,OAAO,EACL,eAAe,EACf,SAAS,EACT,aAAa,EACb,aAAa,EACb,aAAa,EACb,eAAe,GAChB,MAAM,iBAAiB,CAAC;AACzB,OAAO,EAAE,QAAQ,EAAE,MAAM,YAAY,CAAC;AACtC,OAAO,EAA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ClD,IAAI,KAAK,EAAE,CAAC,CAAC,CAAC,KAAK,SAAS,EAAE,CAAC;YAC7B,KAAK,CAAC,IAAI,CAAC,KAAK,CAAC,CAAC,CAAC,CAAC,CAAC;YACrB,SAAS;QACX,CAAC;QACD,MAAM,KAAK,GAAG,wCAAwC,CAAC,IAAI,CAAC,OAAO,CAAC,CAAC;QACrE,IAAI,KAAK,EAAE,CAAC,CAAC,CAAC,KAAK,SAAS;YAAE,KAAK,CAAC,IAAI,CAAC,KAAK,CAAC,CAAC,CAAC,CAAC,CAAC;IACrD,CAAC;IACD,OAAO,KAAK,CAAC;AACf,CAAC"}
|
|
@@ -1,5 +1,6 @@
|
|
|
1
1
|
import type { Gap, SourceRef } from '../../types/core.js';
|
|
2
2
|
import type { HttpMethod } from '../../types/entries.js';
|
|
3
|
+
import { GoConstantTable } from './go-constants.js';
|
|
3
4
|
import type { GoFunction } from '../go-source.js';
|
|
4
5
|
/**
|
|
5
6
|
* The evaluator behind Go endpoint extraction.
|
|
@@ -44,8 +45,10 @@ export interface RawGoRoute {
|
|
|
44
45
|
readonly handler?: SourceRef;
|
|
45
46
|
/** False when the router this was registered on could not be traced to where it is served. */
|
|
46
47
|
readonly resolved: boolean;
|
|
48
|
+
/** The route's own path went through a helper call docgen read as returning its argument. */
|
|
49
|
+
readonly viaHelper?: boolean;
|
|
47
50
|
}
|
|
48
|
-
export declare function evaluateGoRouteGraph(analyses: readonly GoFileAnalysis[]): {
|
|
51
|
+
export declare function evaluateGoRouteGraph(analyses: readonly GoFileAnalysis[], constants?: GoConstantTable): {
|
|
49
52
|
routes: readonly RawGoRoute[];
|
|
50
53
|
gaps: readonly Gap[];
|
|
51
54
|
};
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"go-routes.d.ts","sourceRoot":"","sources":["../../../src/extract/endpoints/go-routes.ts"],"names":[],"mappings":"AACA,OAAO,KAAK,EAAE,GAAG,EAAE,SAAS,EAAE,MAAM,qBAAqB,CAAC;AAC1D,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AAC;IAC5B,kFAAkF;IAClF,QAAQ,CAAC,OAAO,EAAE,MAAM,CAAC;IACzB,QAAQ,CAAC,UAAU,EAAE,SAAS,MAAM,EAAE,CAAC;IACvC,QAAQ,CAAC,MAAM,EAAE,SAAS,CAAC;IAC3B,QAAQ,CAAC,OAAO,CAAC,EAAE,SAAS,CAAC;IAC7B,8FAA8F;IAC9F,QAAQ,CAAC,QAAQ,EAAE,OAAO,CAAC;IAC3B,6FAA6F;IAC7F,QAAQ,CAAC,SAAS,CAAC,EAAE,OAAO,CAAC;CAC9B;AA+DD,wBAAgB,oBAAoB,CAClC,QAAQ,EAAE,SAAS,cAAc,EAAE,EACnC,SAAS,GAAE,eAAyC,GACnD;IACD,MAAM,EAAE,SAAS,UAAU,EAAE,CAAC;IAC9B,IAAI,EAAE,SAAS,GAAG,EAAE,CAAC;CACtB,CA44BA;AAED,gEAAgE;AAChE,wBAAgB,OAAO,CAAC,IAAI,EAAE,MAAM,GAAG,MAAM,CAG5C"}
|
|
@@ -1,5 +1,6 @@
|
|
|
1
1
|
import path from 'node:path';
|
|
2
2
|
import { goCallsIn, goLineIndex, goMiddlewareName, goStringLiteral, matchingClose, resolveGoImportDir, } from '../go-source.js';
|
|
3
|
+
import { GoConstantTable } from './go-constants.js';
|
|
3
4
|
import { joinPath } from './paths.js';
|
|
4
5
|
/** Import path fragments that identify each supported router. */
|
|
5
6
|
export const GO_FRAMEWORK_IMPORTS = Object.freeze([
|
|
@@ -25,7 +26,7 @@ const HANDLE_NAMES = new Set(['Handle', 'HandleFunc', 'Method', 'MethodFunc', 'A
|
|
|
25
26
|
const MAX_DEPTH = 12;
|
|
26
27
|
/** Upper bound on function evaluations, so a pathological call graph cannot run away. */
|
|
27
28
|
const MAX_EVALUATIONS = 20_000;
|
|
28
|
-
export function evaluateGoRouteGraph(analyses) {
|
|
29
|
+
export function evaluateGoRouteGraph(analyses, constants = new GoConstantTable([])) {
|
|
29
30
|
const pending = [];
|
|
30
31
|
const gaps = [];
|
|
31
32
|
/** Gaps about a receiver nobody proved to be a router, dropped if the function is later followed. */
|
|
@@ -108,6 +109,41 @@ export function evaluateGoRouteGraph(analyses) {
|
|
|
108
109
|
shared.set(sharedKey(analysis.dir, `.${name}`), { root, prefix: '', middleware: [], resolved: false, framework, shared: true });
|
|
109
110
|
}
|
|
110
111
|
}
|
|
112
|
+
// `var APIv1 *gin.RouterGroup`: a package variable declared with only a
|
|
113
|
+
// type, filled in by an assignment in another function and read by a
|
|
114
|
+
// third. PhotoPrism builds its whole REST API this way —
|
|
115
|
+
// `APIv1 = router.Group(...)` in start.go, `api.GetAlbums(APIv1)` in
|
|
116
|
+
// routes.go — so without this every API route lost its prefix. Untraced
|
|
117
|
+
// until an evaluated `APIv1 = ...` replaces it.
|
|
118
|
+
const typedVars = [];
|
|
119
|
+
for (const match of analysis.masked.matchAll(/^var[ \t]+([A-Za-z_]\w*)[ \t]+(\*?[A-Za-z_]\w*\.[A-Za-z_]\w*)[ \t]*$/gm)) {
|
|
120
|
+
typedVars.push({ name: match[1], type: match[2], index: match.index });
|
|
121
|
+
}
|
|
122
|
+
for (const block of analysis.masked.matchAll(/^var[ \t]*\(/gm)) {
|
|
123
|
+
const open = block.index + block[0].length - 1;
|
|
124
|
+
const close = matchingClose(analysis.masked, open);
|
|
125
|
+
if (close === -1)
|
|
126
|
+
continue;
|
|
127
|
+
const body = analysis.masked.slice(open + 1, close);
|
|
128
|
+
for (const match of body.matchAll(/^[ \t]*([A-Za-z_]\w*)[ \t]+(\*?[A-Za-z_]\w*\.[A-Za-z_]\w*)[ \t]*$/gm)) {
|
|
129
|
+
typedVars.push({ name: match[1], type: match[2], index: open + 1 + match.index });
|
|
130
|
+
}
|
|
131
|
+
}
|
|
132
|
+
for (const { name, type, index } of typedVars) {
|
|
133
|
+
if (!ROUTER_TYPE.test(type))
|
|
134
|
+
continue;
|
|
135
|
+
const framework = frameworkOfType(analysis, type);
|
|
136
|
+
if (framework === undefined)
|
|
137
|
+
continue;
|
|
138
|
+
const root = newRoot();
|
|
139
|
+
root.untraced = {
|
|
140
|
+
kind: 'go-route-group-unresolved',
|
|
141
|
+
message: `Routes are registered on the router held in the package variable '${name}', which docgen could not trace ` +
|
|
142
|
+
'back to an engine, so their prefix and middleware are unknown.',
|
|
143
|
+
source: sourceAt(analysis, index),
|
|
144
|
+
};
|
|
145
|
+
shared.set(sharedKey(analysis.dir, name), { root, prefix: '', middleware: [], resolved: false, framework, shared: true });
|
|
146
|
+
}
|
|
111
147
|
const constructed = new RegExp(`(?:^var\\s+([A-Za-z_]\\w*)[^=\\n]*=|\\.([A-Za-z_]\\w*)\\s*=|\\b([A-Za-z_]\\w*)\\s*:)\\s*([A-Za-z_]\\w*)\\.(?:${constructorAlternation})\\s*\\(`, 'gm');
|
|
112
148
|
for (const match of analysis.masked.matchAll(constructed)) {
|
|
113
149
|
const framework = frameworkOf(analysis, match[4]);
|
|
@@ -239,16 +275,28 @@ export function evaluateGoRouteGraph(analyses) {
|
|
|
239
275
|
mount(call, receiverState, call.args[0], call.args[1]);
|
|
240
276
|
continue;
|
|
241
277
|
}
|
|
242
|
-
|
|
278
|
+
// chi's `Match(rctx, method, path)` is a lookup, not a registration.
|
|
279
|
+
if (call.name === 'Match' && receiverState !== undefined && (receiverState.framework === 'gin' || receiverState.framework === 'echo')) {
|
|
280
|
+
registerMatch(call, receiverState);
|
|
281
|
+
continue;
|
|
282
|
+
}
|
|
283
|
+
// `api.Options(APIv1)` in PhotoPrism: a function of another package of
|
|
284
|
+
// the repository that happens to share a verb's name. A package is never
|
|
285
|
+
// a router, so it is followed like any function handed one.
|
|
286
|
+
const packageCall = receiverState === undefined &&
|
|
287
|
+
call.receiver !== undefined &&
|
|
288
|
+
analysis.imports.has(call.receiver) &&
|
|
289
|
+
frameworkOf(analysis, call.receiver) === undefined;
|
|
290
|
+
if (!packageCall && call.receiver !== undefined && (VERBS.has(call.name) || TITLE_VERBS.has(call.name))) {
|
|
243
291
|
registerVerb(call, receiverState);
|
|
244
292
|
continue;
|
|
245
293
|
}
|
|
246
|
-
if (HANDLE_NAMES.has(call.name)) {
|
|
294
|
+
if (!packageCall && HANDLE_NAMES.has(call.name)) {
|
|
247
295
|
registerHandle(call, receiverState);
|
|
248
296
|
continue;
|
|
249
297
|
}
|
|
250
298
|
if ((call.name === 'Any' || call.name === 'All') && receiverState !== undefined) {
|
|
251
|
-
const literal = call.args[0] === undefined ? undefined :
|
|
299
|
+
const literal = call.args[0] === undefined ? undefined : constants.evaluate(text(call.args[0]), analysis, { helpers: true })?.value;
|
|
252
300
|
gap('go-route-any-method', `${call.receiver ?? ''}.${call.name}(${literal === undefined ? '...' : `"${joinPath(receiverState.prefix, literal)}"`}) ` +
|
|
253
301
|
'answers every HTTP method, so it is not listed as individual endpoints.', analysis, call.nameStart);
|
|
254
302
|
continue;
|
|
@@ -257,6 +305,68 @@ export function evaluateGoRouteGraph(analyses) {
|
|
|
257
305
|
evaluateInCallOrder(call);
|
|
258
306
|
}
|
|
259
307
|
bindFieldsBefore(span.end);
|
|
308
|
+
/**
|
|
309
|
+
* The value of a path argument: a literal, a string constant, a `+` of
|
|
310
|
+
* those, or a one-argument call around one — PhotoPrism wraps every
|
|
311
|
+
* top-level path in `conf.BaseUri(...)`, which prepends a base path only
|
|
312
|
+
* when one is configured. What such a helper does is not visible here, so
|
|
313
|
+
* the path is documented as its argument and a gap says so.
|
|
314
|
+
*/
|
|
315
|
+
function pathOf(call, arg) {
|
|
316
|
+
return pathValue(call, arg)?.value;
|
|
317
|
+
}
|
|
318
|
+
function pathValue(call, arg) {
|
|
319
|
+
const resolved = constants.evaluate(text(arg), analysis, { helpers: true });
|
|
320
|
+
if (resolved === undefined)
|
|
321
|
+
return undefined;
|
|
322
|
+
if (resolved.helpers.length > 0) {
|
|
323
|
+
const helpers = [...new Set(resolved.helpers)].map((name) => `${name}(...)`).join(', ');
|
|
324
|
+
gap('go-route-path-helper', `${call.receiver === undefined ? '' : `${call.receiver}.`}${call.name}(${text(arg).trim()}, ...) builds its path with ${helpers}, ` +
|
|
325
|
+
`which docgen read as returning "${resolved.value}" unchanged; anything it adds at run time (a configured ` +
|
|
326
|
+
'base path, say) is missing from the documented path.', analysis, call.nameStart);
|
|
327
|
+
}
|
|
328
|
+
return { value: resolved.value, viaHelper: resolved.helpers.length > 0 };
|
|
329
|
+
}
|
|
330
|
+
/** Gin and Echo `Match([]string{"GET", "HEAD"}, "/p", h)`: one route per listed method. */
|
|
331
|
+
function registerMatch(call, receiverState) {
|
|
332
|
+
const [methodsArg, pathArg] = call.args;
|
|
333
|
+
if (methodsArg === undefined || pathArg === undefined)
|
|
334
|
+
return;
|
|
335
|
+
const label = `${call.receiver ?? ''}.${call.name}(${text(methodsArg).trim()}, ...)`;
|
|
336
|
+
const methods = constants.evaluateStringSlice(localSlice(methodsArg) ?? text(methodsArg), analysis);
|
|
337
|
+
if (methods === undefined) {
|
|
338
|
+
gap('go-route-method-unresolved', `${label} registers a route for a list of HTTP methods docgen could not read, so it is not documented.`, analysis, call.nameStart);
|
|
339
|
+
return;
|
|
340
|
+
}
|
|
341
|
+
const upper = [...new Set(methods.map((method) => method.toUpperCase()))];
|
|
342
|
+
const unlisted = upper.filter((method) => !VERBS.has(method));
|
|
343
|
+
if (unlisted.length > 0) {
|
|
344
|
+
gap('go-route-method-unlisted', `${label} also answers ${unlisted.join(', ')}, which docgen does not list as endpoints.`, analysis, call.nameStart);
|
|
345
|
+
}
|
|
346
|
+
for (const method of upper) {
|
|
347
|
+
if (VERBS.has(method))
|
|
348
|
+
emit(call, receiverState, method, pathArg, call.args.slice(2));
|
|
349
|
+
}
|
|
350
|
+
}
|
|
351
|
+
/**
|
|
352
|
+
* `methods := []string{...}` earlier in the same function, for a `Match`
|
|
353
|
+
* handed a local: PhotoPrism's `/api/v1/echo`. Read as straight-line code,
|
|
354
|
+
* so the last such assignment before the call wins.
|
|
355
|
+
*/
|
|
356
|
+
function localSlice(arg) {
|
|
357
|
+
const name = text(arg).trim();
|
|
358
|
+
if (!/^[A-Za-z_]\w*$/.test(name))
|
|
359
|
+
return undefined;
|
|
360
|
+
const body = context.owner.fn.body;
|
|
361
|
+
const before = masked.slice(body.start, arg.start);
|
|
362
|
+
const assignments = [...before.matchAll(new RegExp(`(?:^|[^\\w.])${name}\\s*:?=\\s*\\[\\]\\s*string\\s*\\{`, 'g'))];
|
|
363
|
+
const last = assignments[assignments.length - 1];
|
|
364
|
+
if (last === undefined)
|
|
365
|
+
return undefined;
|
|
366
|
+
const open = body.start + last.index + last[0].length - 1;
|
|
367
|
+
const close = matchingClose(masked, open);
|
|
368
|
+
return close === -1 || close > arg.start ? undefined : stripped.slice(masked.lastIndexOf('[', open), close + 1);
|
|
369
|
+
}
|
|
260
370
|
/** A router produced by this call: a constructor, a sub-group, or a function returning one. */
|
|
261
371
|
function stateOfCall(call) {
|
|
262
372
|
if (call.receiver !== undefined && /^[A-Za-z_]\w*$/.test(call.receiver)) {
|
|
@@ -279,7 +389,7 @@ export function evaluateGoRouteGraph(analyses) {
|
|
|
279
389
|
if (first === undefined || /^\s*func\b/.test(masked.slice(first.start, first.end))) {
|
|
280
390
|
return { ...derived, prefix: base.prefix, middleware: [...base.middleware] };
|
|
281
391
|
}
|
|
282
|
-
const literal =
|
|
392
|
+
const literal = pathOf(call, first);
|
|
283
393
|
if (literal === undefined) {
|
|
284
394
|
gap('go-route-path-unresolved', `The prefix of ${call.receiver}.${call.name}(${text(first).trim()}) is computed, so the routes below it are documented without it.`, analysis, call.nameStart);
|
|
285
395
|
}
|
|
@@ -322,14 +432,24 @@ export function evaluateGoRouteGraph(analyses) {
|
|
|
322
432
|
// Only when the call is the whole right-hand side: `x := r.Group("/a").Use(m)` binds something else.
|
|
323
433
|
if (/^\s*\./.test(masked.slice(call.close + 1, call.close + 40)))
|
|
324
434
|
return;
|
|
325
|
-
const
|
|
435
|
+
const assignment = /(?:^|[\s;{(])([A-Za-z_][\w.]*)\s*(:?)=\s*$/.exec(masked.slice(Math.max(span.start, call.start - 120), call.start));
|
|
436
|
+
const target = assignment?.[1];
|
|
326
437
|
if (target === undefined)
|
|
327
438
|
return;
|
|
439
|
+
const before = env.get(target);
|
|
328
440
|
env.set(target, bound);
|
|
329
441
|
// `s.api = s.router.Group("/api")`: other methods read the field too.
|
|
330
442
|
if (target.includes('.')) {
|
|
331
443
|
bound.shared = true;
|
|
332
444
|
shared.set(sharedKey(analysis.dir, `.${target.split('.').pop() ?? ''}`), bound);
|
|
445
|
+
return;
|
|
446
|
+
}
|
|
447
|
+
// `APIv1 = router.Group("/api/v1")`: a plain `=` to a package variable,
|
|
448
|
+
// not shadowed by a local or a parameter, fills it for every reader.
|
|
449
|
+
const key = sharedKey(analysis.dir, target);
|
|
450
|
+
if (assignment?.[2] === '' && shared.has(key) && (before === undefined || before.shared === true)) {
|
|
451
|
+
bound.shared = true;
|
|
452
|
+
shared.set(key, bound);
|
|
333
453
|
}
|
|
334
454
|
}
|
|
335
455
|
/** A router value named by an expression: a variable, a field, or a chain of group calls. */
|
|
@@ -384,7 +504,7 @@ export function evaluateGoRouteGraph(analyses) {
|
|
|
384
504
|
}
|
|
385
505
|
return;
|
|
386
506
|
}
|
|
387
|
-
const literal = prefixOverride ?? (prefixArg === undefined ? undefined :
|
|
507
|
+
const literal = prefixOverride ?? (prefixArg === undefined ? undefined : pathOf(call, prefixArg));
|
|
388
508
|
if (literal === undefined) {
|
|
389
509
|
gap('go-route-path-unresolved', `The prefix of ${call.receiver ?? ''}.${call.name}(${prefixArg === undefined ? '' : text(prefixArg).trim()}, ...) is computed, ` +
|
|
390
510
|
'so the routes of the router it mounts are documented without it.', analysis, call.nameStart);
|
|
@@ -444,13 +564,20 @@ export function evaluateGoRouteGraph(analyses) {
|
|
|
444
564
|
const first = call.args[0];
|
|
445
565
|
if (routerState === undefined || first === undefined)
|
|
446
566
|
return;
|
|
447
|
-
const literal =
|
|
567
|
+
const literal = pathOf(call, first);
|
|
448
568
|
// Gin `Handle("GET", "/p", h)`, chi `Method("GET", "/p", h)`, Echo `Add("GET", "/p", h)`.
|
|
449
569
|
const second = call.args[1];
|
|
450
570
|
if (literal !== undefined && VERBS.has(literal.toUpperCase()) && call.args.length >= 3 && second !== undefined) {
|
|
451
571
|
emit(call, routerState, literal.toUpperCase(), second, call.args.slice(2));
|
|
452
572
|
return;
|
|
453
573
|
}
|
|
574
|
+
// Gin `Handle(header.MethodPropfind, path, h)`: a WebDAV or other
|
|
575
|
+
// extension method, now that `header.MethodPropfind` resolves. Not a path.
|
|
576
|
+
if (literal !== undefined && /^[A-Z]+$/.test(literal) && call.args.length >= 3 && call.name !== 'HandleFunc') {
|
|
577
|
+
gap('go-route-method-unlisted', `${call.receiver ?? ''}.${call.name}("${literal}", ${second === undefined ? '' : text(second).trim()}, ...) registers the ` +
|
|
578
|
+
`${literal} method, which docgen does not list as an endpoint.`, analysis, call.nameStart);
|
|
579
|
+
return;
|
|
580
|
+
}
|
|
454
581
|
if (call.name === 'Add')
|
|
455
582
|
return;
|
|
456
583
|
// net/http since Go 1.22: `mux.HandleFunc("GET /items/{id}", h)`.
|
|
@@ -488,14 +615,14 @@ export function evaluateGoRouteGraph(analyses) {
|
|
|
488
615
|
return true;
|
|
489
616
|
}
|
|
490
617
|
function emit(call, routerState, method, pathArg, handlers) {
|
|
491
|
-
const
|
|
492
|
-
if (
|
|
618
|
+
const resolved = pathValue(call, pathArg);
|
|
619
|
+
if (resolved === undefined) {
|
|
493
620
|
gap('go-route-path-unresolved', `The path of ${call.receiver ?? ''}.${call.name}(${text(pathArg).trim()}, ...) is computed, so the route is not documented.`, analysis, call.nameStart);
|
|
494
621
|
return;
|
|
495
622
|
}
|
|
496
|
-
pushRoute(call, routerState, method,
|
|
623
|
+
pushRoute(call, routerState, method, resolved.value, handlers, resolved.viaHelper);
|
|
497
624
|
}
|
|
498
|
-
function pushRoute(call, routerState, method, routePath, handlers) {
|
|
625
|
+
function pushRoute(call, routerState, method, routePath, handlers, viaHelper = false) {
|
|
499
626
|
// Gin and Fiber take (middleware..., handler); Echo takes (handler, middleware...).
|
|
500
627
|
const framework = routerState.framework ?? (analysis.frameworks.length === 1 ? analysis.frameworks[0] : undefined);
|
|
501
628
|
const handlerFirst = framework === 'echo';
|
|
@@ -511,6 +638,7 @@ export function evaluateGoRouteGraph(analyses) {
|
|
|
511
638
|
source: sourceAt(analysis, call.nameStart),
|
|
512
639
|
...(handler === undefined ? {} : { handler }),
|
|
513
640
|
entry: context.entry,
|
|
641
|
+
viaHelper,
|
|
514
642
|
});
|
|
515
643
|
}
|
|
516
644
|
function handlerRef(expression) {
|
|
@@ -713,6 +841,7 @@ export function evaluateGoRouteGraph(analyses) {
|
|
|
713
841
|
source: route.source,
|
|
714
842
|
...(route.handler === undefined ? {} : { handler: route.handler }),
|
|
715
843
|
resolved: route.resolved && placement.resolved,
|
|
844
|
+
...(route.viaHelper ? { viaHelper: true } : {}),
|
|
716
845
|
});
|
|
717
846
|
}
|
|
718
847
|
}
|