@mintlify/cli 4.0.1084 → 4.0.1086

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/workflow.js CHANGED
@@ -13,7 +13,7 @@ import { addLog, addLogs, SuccessLog } from '@mintlify/previewing';
13
13
  import fse from 'fs-extra';
14
14
  import { Text } from 'ink';
15
15
  import path from 'path';
16
- import { CMD_EXEC_PATH } from './constants.js';
16
+ import { CMD_EXEC_PATH } from './helpers.js';
17
17
  export function slugify(name) {
18
18
  return name
19
19
  .toLowerCase()
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@mintlify/cli",
3
- "version": "4.0.1084",
3
+ "version": "4.0.1086",
4
4
  "description": "The Mintlify CLI",
5
5
  "engines": {
6
6
  "node": ">=18.0.0"
@@ -93,5 +93,5 @@
93
93
  "vitest": "2.1.9",
94
94
  "vitest-mock-process": "1.0.4"
95
95
  },
96
- "gitHead": "b98237c830a5b1786611dea52270ae3b8a350fb1"
96
+ "gitHead": "cda0cfd7e97b5961ec6dd405b5f8dc6d9be2faef"
97
97
  }
@@ -6,8 +6,7 @@ import { Text } from 'ink';
6
6
 
7
7
  import { checkDocsColors, type AccessibilityCheckResult } from './accessibility.js';
8
8
  import { ContrastResult } from './accessibility.js';
9
- import { CMD_EXEC_PATH } from './constants.js';
10
- import { checkForDocsJson } from './helpers.js';
9
+ import { CMD_EXEC_PATH, checkForDocsJson } from './helpers.js';
11
10
 
12
11
  export type TerminateCode = 0 | 1;
13
12
 
@@ -0,0 +1,164 @@
1
+ import type {
2
+ BucketThreadsResponse,
3
+ BucketsResponse,
4
+ ConversationResponse,
5
+ FeedbackByPageResponse,
6
+ FeedbackResponse,
7
+ KpiResponse,
8
+ SearchResponse,
9
+ ViewsResponse,
10
+ VisitorsResponse,
11
+ } from './types.js';
12
+
13
+ const API_BASE = process.env.MINTLIFY_API_URL ?? 'http://localhost:5000';
14
+
15
+ type Params = Record<string, string | number | undefined>;
16
+
17
+ async function getAuthHeaders(): Promise<Record<string, string>> {
18
+ try {
19
+ const { getAccessToken } = await import('../keyring.js');
20
+ const token = await getAccessToken();
21
+ if (token) {
22
+ return { Authorization: `Bearer ${token}` };
23
+ }
24
+ } catch {}
25
+
26
+ const envToken = process.env.MINTLIFY_SESSION_TOKEN;
27
+ if (envToken) {
28
+ return { Authorization: `Bearer ${envToken}` };
29
+ }
30
+
31
+ throw new Error('Not authenticated. Run `mint login` to authenticate.');
32
+ }
33
+
34
+ async function request<T>(path: string, params: Params = {}): Promise<T> {
35
+ const url = new URL(`${API_BASE}/api/cli/analytics${path}`);
36
+ for (const [key, value] of Object.entries(params)) {
37
+ if (value !== undefined) url.searchParams.set(key, String(value));
38
+ }
39
+
40
+ const authHeaders = await getAuthHeaders();
41
+ const res = await fetch(url, {
42
+ headers: { ...authHeaders, Accept: 'application/json' },
43
+ });
44
+
45
+ if (!res.ok) {
46
+ const body = await res.text().catch(() => '');
47
+ throw new Error(`API error (${res.status}): ${body || res.statusText}`);
48
+ }
49
+
50
+ return res.json() as Promise<T>;
51
+ }
52
+
53
+ export function getKpi(
54
+ opts: {
55
+ dateFrom: string;
56
+ dateTo: string;
57
+ page?: string;
58
+ },
59
+ subdomain?: string
60
+ ) {
61
+ return request<KpiResponse>('/kpi', { ...opts, subdomain });
62
+ }
63
+
64
+ export function getFeedback(
65
+ opts: {
66
+ dateFrom: string;
67
+ dateTo: string;
68
+ limit?: number;
69
+ cursor?: string;
70
+ source?: string;
71
+ status?: string;
72
+ },
73
+ subdomain?: string
74
+ ) {
75
+ return request<FeedbackResponse>('/feedback', { ...opts, subdomain });
76
+ }
77
+
78
+ export function getFeedbackByPage(
79
+ opts: {
80
+ dateFrom: string;
81
+ dateTo: string;
82
+ limit?: number;
83
+ source?: string;
84
+ status?: string;
85
+ },
86
+ subdomain?: string
87
+ ) {
88
+ return request<FeedbackByPageResponse>('/feedback/by-page', { ...opts, subdomain });
89
+ }
90
+
91
+ export function getConversations(
92
+ opts: {
93
+ dateFrom: string;
94
+ dateTo: string;
95
+ limit?: number;
96
+ cursor?: string;
97
+ },
98
+ subdomain?: string
99
+ ) {
100
+ return request<ConversationResponse>('/assistant', { ...opts, subdomain });
101
+ }
102
+
103
+ export function getSearches(
104
+ opts: {
105
+ dateFrom: string;
106
+ dateTo: string;
107
+ limit?: number;
108
+ cursor?: string;
109
+ },
110
+ subdomain?: string
111
+ ) {
112
+ return request<SearchResponse>('/searches', { ...opts, subdomain });
113
+ }
114
+
115
+ export function getViews(
116
+ opts: {
117
+ dateFrom: string;
118
+ dateTo: string;
119
+ limit?: number;
120
+ offset?: number;
121
+ },
122
+ subdomain?: string
123
+ ) {
124
+ return request<ViewsResponse>('/views', { ...opts, subdomain });
125
+ }
126
+
127
+ export function getVisitors(
128
+ opts: {
129
+ dateFrom: string;
130
+ dateTo: string;
131
+ limit?: number;
132
+ offset?: number;
133
+ },
134
+ subdomain?: string
135
+ ) {
136
+ return request<VisitorsResponse>('/visitors', { ...opts, subdomain });
137
+ }
138
+
139
+ export function getBuckets(
140
+ opts: {
141
+ dateFrom?: string;
142
+ dateTo?: string;
143
+ topK?: number;
144
+ },
145
+ subdomain?: string
146
+ ) {
147
+ return request<BucketsResponse>('/conversations/buckets', { ...opts, subdomain });
148
+ }
149
+
150
+ export function getBucketThreads(
151
+ bucketId: string,
152
+ opts: {
153
+ dateFrom?: string;
154
+ dateTo?: string;
155
+ limit?: number;
156
+ cursor?: string;
157
+ },
158
+ subdomain?: string
159
+ ) {
160
+ return request<BucketThreadsResponse>(`/conversations/buckets/${encodeURIComponent(bucketId)}`, {
161
+ ...opts,
162
+ subdomain,
163
+ });
164
+ }
@@ -0,0 +1,13 @@
1
+ export function num(n: number): string {
2
+ return n.toLocaleString('en-US');
3
+ }
4
+
5
+ export function pct(n: number, total: number): string {
6
+ if (total === 0) return '\u2014';
7
+ return ((n / total) * 100).toFixed(1) + '%';
8
+ }
9
+
10
+ export function truncate(s: string, max: number): string {
11
+ if (s.length <= max) return s;
12
+ return s.slice(0, max - 1) + '\u2026';
13
+ }