@tatara/cli 0.9.0 → 0.9.2
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/bin.mjs +40 -4
- package/package.json +1 -1
package/dist/bin.mjs
CHANGED
|
@@ -3149,13 +3149,49 @@ async function listRoutes(project) {
|
|
|
3149
3149
|
const out = [];
|
|
3150
3150
|
for (const [name, spec] of ${JSON.stringify(apps)}) {
|
|
3151
3151
|
const { app } = await import(spec);
|
|
3152
|
-
|
|
3152
|
+
// Fetch from /openapi.json endpoint to get the document with all extensions applied
|
|
3153
|
+
const res = await app.request("/openapi.json");
|
|
3154
|
+
const doc = await res.json();
|
|
3155
|
+
const securitySchemes = doc.components?.securitySchemes ?? {};
|
|
3156
|
+
|
|
3153
3157
|
for (const [path, item] of Object.entries(doc.paths ?? {})) {
|
|
3154
3158
|
for (const [method, op] of Object.entries(item)) {
|
|
3159
|
+
const tags = op.tags ?? [];
|
|
3155
3160
|
const security = op.security ?? [];
|
|
3156
|
-
|
|
3157
|
-
|
|
3158
|
-
|
|
3161
|
+
|
|
3162
|
+
// Parse access label based on security schemes and tags
|
|
3163
|
+
let access = "public";
|
|
3164
|
+
|
|
3165
|
+
// Routes tagged "Auth" are from better-auth's merged document
|
|
3166
|
+
if (tags.includes("Auth")) {
|
|
3167
|
+
access = "better-auth";
|
|
3168
|
+
} else if (security.length > 0) {
|
|
3169
|
+
const labels = [];
|
|
3170
|
+
for (const requirement of security) {
|
|
3171
|
+
const schemes = Object.keys(requirement);
|
|
3172
|
+
if (schemes.length === 0) continue;
|
|
3173
|
+
|
|
3174
|
+
const schemeName = schemes[0];
|
|
3175
|
+
const roles = requirement[schemeName] ?? [];
|
|
3176
|
+
|
|
3177
|
+
// For bearer auth with specific roles, show the roles
|
|
3178
|
+
if (schemeName === "bearerAuth" && roles.length > 0) {
|
|
3179
|
+
labels.push(roles.join(", "));
|
|
3180
|
+
}
|
|
3181
|
+
// For bearer auth without roles, show "authenticated"
|
|
3182
|
+
else if (schemeName === "bearerAuth") {
|
|
3183
|
+
labels.push("authenticated");
|
|
3184
|
+
}
|
|
3185
|
+
// For other schemes (API keys, etc.), show the scheme name
|
|
3186
|
+
else {
|
|
3187
|
+
labels.push(schemeName);
|
|
3188
|
+
}
|
|
3189
|
+
}
|
|
3190
|
+
access = labels.length > 1 ? labels.join(" OR ") : (labels[0] ?? "authenticated");
|
|
3191
|
+
}
|
|
3192
|
+
|
|
3193
|
+
const summary = op.summary || op.description || "";
|
|
3194
|
+
out.push({ app: name, method: method.toUpperCase(), path, summary, access });
|
|
3159
3195
|
}
|
|
3160
3196
|
}
|
|
3161
3197
|
}
|