@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.
Files changed (2) hide show
  1. package/dist/bin.mjs +40 -4
  2. 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
- const doc = app.getOpenAPI31Document({ openapi: "3.1.0", info: { title: name, version: "1" } });
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
- const roles = security.flatMap((s) => Object.values(s).flat());
3157
- const access = security.length === 0 ? "public" : roles.length ? roles.join(", ") : "authenticated";
3158
- out.push({ app: name, method: method.toUpperCase(), path, summary: op.summary ?? "", access });
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
  }
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@tatara/cli",
3
- "version": "0.9.0",
3
+ "version": "0.9.2",
4
4
  "description": "Create and grow opinionated Hono backends",
5
5
  "type": "module",
6
6
  "license": "MIT",