apiforge-analyzer 1.3.8 → 1.3.9

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/cjs/cli.js CHANGED
@@ -111,6 +111,22 @@ async function main() {
111
111
  (0, prompts_1.cancel)('Cancelled.');
112
112
  process.exit(0);
113
113
  }
114
+ // ── Who can see the docs (APIForge spec §6.1 levels, chosen by the creator per §6.3) ──────────────────
115
+ const visibilityChoice = await (0, prompts_1.select)({
116
+ message: 'Who can see these docs?',
117
+ initialValue: 'PRIVATE', // "Only me" — the backend's default too
118
+ options: [
119
+ { value: 'ORG_WIDE', label: `${bold('Everyone in the org')} ${dim('— every member of your organization')}` },
120
+ { value: 'TEAM', label: `${bold('Team')} ${dim('— people you add, plus admins and the Superadmin')}` },
121
+ { value: 'PRIVATE', label: `${bold('Only me')} ${dim('— you, people you add, and the Superadmin')}` },
122
+ ],
123
+ });
124
+ if ((0, prompts_1.isCancel)(visibilityChoice)) {
125
+ (0, prompts_1.cancel)('Cancelled.');
126
+ process.exit(0);
127
+ }
128
+ // Read by uploadRoutes — in this process and in the server this CLI starts (it inherits the environment)
129
+ process.env.APIFORGE_VISIBILITY = visibilityChoice;
114
130
  const isLocal = backendChoice === 'local';
115
131
  const backendUrl = isLocal ? BACKEND_LOCAL : BACKEND_PROD;
116
132
  const dashboardUrl = isLocal ? DASHBOARD_LOCAL : DASHBOARD_PROD;
@@ -10,6 +10,16 @@ const axios_1 = __importDefault(require("axios"));
10
10
  const fs_1 = require("fs");
11
11
  const path_1 = require("path");
12
12
  const export_js_1 = require("./export.js");
13
+ /** The backend's fields for a visibility choice — nothing when none was made. */
14
+ function visibilityFields(choice) {
15
+ if (choice === 'ORG_WIDE')
16
+ return { visibility: 'ORG_WIDE', isPrivate: false };
17
+ if (choice === 'TEAM')
18
+ return { visibility: 'TEAM', isPrivate: false };
19
+ if (choice === 'PRIVATE')
20
+ return { visibility: 'TEAM', isPrivate: true };
21
+ return {};
22
+ }
13
23
  /** Status file written to the project root so the CLI can detect completion. */
14
24
  const STATUS_FILE = '.apiforge-status.json';
15
25
  function writeStatusFile(status, data) {
@@ -44,6 +54,7 @@ async function uploadRoutes(routes, options) {
44
54
  framework: enrichedRoutes[0]?.framework || 'unknown',
45
55
  architectureType: options.architectureType || 'monolithic',
46
56
  services: options.services || [],
57
+ ...visibilityFields(options.visibility ?? process.env.APIFORGE_VISIBILITY),
47
58
  };
48
59
  try {
49
60
  const response = await axios_1.default.post(`${backendUrl}/api/cli/submit`, payload, {
package/dist/esm/cli.js CHANGED
@@ -106,6 +106,22 @@ async function main() {
106
106
  cancel('Cancelled.');
107
107
  process.exit(0);
108
108
  }
109
+ // ── Who can see the docs (APIForge spec §6.1 levels, chosen by the creator per §6.3) ──────────────────
110
+ const visibilityChoice = await select({
111
+ message: 'Who can see these docs?',
112
+ initialValue: 'PRIVATE', // "Only me" — the backend's default too
113
+ options: [
114
+ { value: 'ORG_WIDE', label: `${bold('Everyone in the org')} ${dim('— every member of your organization')}` },
115
+ { value: 'TEAM', label: `${bold('Team')} ${dim('— people you add, plus admins and the Superadmin')}` },
116
+ { value: 'PRIVATE', label: `${bold('Only me')} ${dim('— you, people you add, and the Superadmin')}` },
117
+ ],
118
+ });
119
+ if (isCancel(visibilityChoice)) {
120
+ cancel('Cancelled.');
121
+ process.exit(0);
122
+ }
123
+ // Read by uploadRoutes — in this process and in the server this CLI starts (it inherits the environment)
124
+ process.env.APIFORGE_VISIBILITY = visibilityChoice;
109
125
  const isLocal = backendChoice === 'local';
110
126
  const backendUrl = isLocal ? BACKEND_LOCAL : BACKEND_PROD;
111
127
  const dashboardUrl = isLocal ? DASHBOARD_LOCAL : DASHBOARD_PROD;
@@ -2,6 +2,16 @@ import axios from 'axios';
2
2
  import { writeFileSync, unlinkSync, existsSync } from 'fs';
3
3
  import { join } from 'path';
4
4
  import { enrichRoutes } from './export.js';
5
+ /** The backend's fields for a visibility choice — nothing when none was made. */
6
+ function visibilityFields(choice) {
7
+ if (choice === 'ORG_WIDE')
8
+ return { visibility: 'ORG_WIDE', isPrivate: false };
9
+ if (choice === 'TEAM')
10
+ return { visibility: 'TEAM', isPrivate: false };
11
+ if (choice === 'PRIVATE')
12
+ return { visibility: 'TEAM', isPrivate: true };
13
+ return {};
14
+ }
5
15
  /** Status file written to the project root so the CLI can detect completion. */
6
16
  const STATUS_FILE = '.apiforge-status.json';
7
17
  export function writeStatusFile(status, data) {
@@ -36,6 +46,7 @@ export async function uploadRoutes(routes, options) {
36
46
  framework: enrichedRoutes[0]?.framework || 'unknown',
37
47
  architectureType: options.architectureType || 'monolithic',
38
48
  services: options.services || [],
49
+ ...visibilityFields(options.visibility ?? process.env.APIFORGE_VISIBILITY),
39
50
  };
40
51
  try {
41
52
  const response = await axios.post(`${backendUrl}/api/cli/submit`, payload, {
@@ -11,7 +11,13 @@ export interface UploadOptions {
11
11
  apiKey: string;
12
12
  architectureType?: ArchitectureType;
13
13
  services?: ServiceMeta[];
14
+ /**
15
+ * Who can see the new project (APIForge spec §6.1 levels, chosen at creation per §6.3). Defaults to the
16
+ * CLI's answer in APIFORGE_VISIBILITY; with neither, the backend's default ("Only me") applies.
17
+ */
18
+ visibility?: ProjectVisibility;
14
19
  }
20
+ export type ProjectVisibility = 'ORG_WIDE' | 'TEAM' | 'PRIVATE';
15
21
  export interface UploadResult {
16
22
  pendingImportId: string;
17
23
  routeCount: number;
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "apiforge-analyzer",
3
- "version": "1.3.8",
3
+ "version": "1.3.9",
4
4
  "description": "Universal API documentation generator for Express, Next.js, Vite, React Router, and Node.js",
5
5
  "type": "module",
6
6
  "main": "./dist/cjs/index.js",