@farming-labs/docs 0.2.41 → 0.2.43
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/{agent-WcXCJ4EN.mjs → agent-DXDOMJBw.mjs} +6 -6
- package/dist/{agents-BjTEkCsY.mjs → agents-DjhjZaNP.mjs} +5 -5
- package/dist/analytics-BZEwTK-8.mjs +177 -0
- package/dist/cli/index.mjs +27 -27
- package/dist/client/react.d.mts +45 -0
- package/dist/client/react.mjs +223 -0
- package/dist/{cloud-wcDf1YC0.mjs → cloud-Bk-eppay.mjs} +158 -14
- package/dist/cloud-analytics-Dlk_byos.mjs +132 -0
- package/dist/cloud-ask-ai-Cl-xaV8j.mjs +382 -0
- package/dist/cloud-ask-ai-DcMe6xOf.d.mts +23 -0
- package/dist/{codeblocks-DTlvGTH4.mjs → codeblocks-z9iT794h.mjs} +3 -3
- package/dist/{dev-DxVevOP_.mjs → dev-CBha7knT.mjs} +2 -2
- package/dist/docs-cloud-server.d.mts +70 -0
- package/dist/docs-cloud-server.mjs +310 -0
- package/dist/{doctor-VwhpJct8.mjs → doctor-O9o9kjN8.mjs} +7 -7
- package/dist/{downgrade-ghVFFHKi.mjs → downgrade-7PGER59g.mjs} +2 -2
- package/dist/index.d.mts +2 -2
- package/dist/index.mjs +4 -3
- package/dist/{init-DkcasCws.mjs → init-Ds7QM9po.mjs} +3 -3
- package/dist/{mcp-DfJiBC0f.mjs → mcp-DuCPNHS-.mjs} +4 -4
- package/dist/mcp.d.mts +1 -1
- package/dist/mcp.mjs +3 -2
- package/dist/{package-version-CeNAB4NZ.mjs → package-version-DPQSBBsX.mjs} +1 -1
- package/dist/{review-Bnd4NH9y.mjs → review-lm3dt7yy.mjs} +2 -2
- package/dist/{robots-BrBGgn1w.mjs → robots-DV7u4Ire.mjs} +4 -4
- package/dist/{robots-CVoC0w0i.mjs → robots-XVPs9lVz.mjs} +1 -1
- package/dist/{search-CA3H4Dfv.mjs → search-B6nEkx86.mjs} +4 -4
- package/dist/{search-BuOU4idW.mjs → search-BWuU70B0.mjs} +2 -306
- package/dist/{search-BEe1Gdu7.d.mts → search-DFEhf9-s.d.mts} +1 -1
- package/dist/server.d.mts +5 -23
- package/dist/server.mjs +8 -5
- package/dist/{sitemap-CUtSSoGG.mjs → sitemap-BEiKy4Iy.mjs} +5 -5
- package/dist/{sitemap-server-PLcNxmtk.mjs → sitemap-server-xEHtDUDB.mjs} +2 -382
- package/dist/{types-DKCNILor.d.mts → types-XqGLsmOD.d.mts} +17 -0
- package/dist/{upgrade-aexO-zom.mjs → upgrade-CkdKWRlk.mjs} +2 -2
- package/package.json +21 -1
- /package/dist/{agent-B6szuz_8.mjs → agent-CaOBIVFy.mjs} +0 -0
- /package/dist/{config-De5z-2LK.mjs → config-tiQCZ46q.mjs} +0 -0
- /package/dist/{errors-Dw5gMhEZ.mjs → errors-CW1LnxaQ.mjs} +0 -0
- /package/dist/{review-CJD85JTm.mjs → review-B7goPYUb.mjs} +0 -0
- /package/dist/{templates-BOoV0cIR.mjs → templates-CEcOVbV0.mjs} +0 -0
- /package/dist/{utils-CoHZJ1i4.mjs → utils-D-xTRNuh.mjs} +0 -0
|
@@ -1,9 +1,9 @@
|
|
|
1
1
|
import "./reading-time-CPAy1SWO.mjs";
|
|
2
|
-
import "./
|
|
3
|
-
import "./
|
|
4
|
-
import "./robots-
|
|
5
|
-
import "./sitemap-server-
|
|
6
|
-
import "./config-
|
|
7
|
-
import { a as readPageTokenBudget, i as printAgentCompactHelp, n as inspectAgentCompactionState, o as scanDocsPageTargets, r as parseAgentCompactArgs, t as compactAgentDocs } from "./codeblocks-
|
|
2
|
+
import "./agent-CaOBIVFy.mjs";
|
|
3
|
+
import "./search-BWuU70B0.mjs";
|
|
4
|
+
import "./robots-XVPs9lVz.mjs";
|
|
5
|
+
import "./sitemap-server-xEHtDUDB.mjs";
|
|
6
|
+
import "./config-tiQCZ46q.mjs";
|
|
7
|
+
import { a as readPageTokenBudget, i as printAgentCompactHelp, n as inspectAgentCompactionState, o as scanDocsPageTargets, r as parseAgentCompactArgs, t as compactAgentDocs } from "./codeblocks-z9iT794h.mjs";
|
|
8
8
|
|
|
9
9
|
export { compactAgentDocs, parseAgentCompactArgs, printAgentCompactHelp };
|
|
@@ -1,10 +1,10 @@
|
|
|
1
|
-
import "./
|
|
2
|
-
import
|
|
3
|
-
import {
|
|
1
|
+
import { $ as renderDocsAgentsDocument, C as DEFAULT_OPENAPI_SCHEMA_ROUTE, a as DEFAULT_AGENT_MD_ROUTE, it as resolveDocsAgentFeedbackConfig, n as DEFAULT_AGENTS_MD_WELL_KNOWN_ROUTE, o as DEFAULT_AGENT_MD_WELL_KNOWN_ROUTE, t as DEFAULT_AGENTS_MD_ROUTE } from "./agent-CaOBIVFy.mjs";
|
|
2
|
+
import "./search-BWuU70B0.mjs";
|
|
3
|
+
import { S as resolveApiReferenceConfig } from "./sitemap-server-xEHtDUDB.mjs";
|
|
4
4
|
import { resolveDocsMcpConfig } from "./mcp.mjs";
|
|
5
5
|
import "./server.mjs";
|
|
6
|
-
import { c as readNavTitle, f as readTopLevelStringProperty, i as loadDocsConfigModule, o as readBooleanProperty, p as resolveDocsConfigPath, t as extractNestedObjectLiteral, u as readStringProperty } from "./config-
|
|
7
|
-
import { t as detectFramework } from "./utils-
|
|
6
|
+
import { c as readNavTitle, f as readTopLevelStringProperty, i as loadDocsConfigModule, o as readBooleanProperty, p as resolveDocsConfigPath, t as extractNestedObjectLiteral, u as readStringProperty } from "./config-tiQCZ46q.mjs";
|
|
7
|
+
import { t as detectFramework } from "./utils-D-xTRNuh.mjs";
|
|
8
8
|
import { existsSync, mkdirSync, readFileSync, writeFileSync } from "node:fs";
|
|
9
9
|
import path from "node:path";
|
|
10
10
|
import pc from "picocolors";
|
|
@@ -0,0 +1,177 @@
|
|
|
1
|
+
import { n as sendDocsCloudAnalyticsEvent, t as resolveDocsCloudAnalyticsOptions } from "./cloud-analytics-Dlk_byos.mjs";
|
|
2
|
+
|
|
3
|
+
//#region src/analytics.ts
|
|
4
|
+
const ANALYTICS_LOG_PREFIX = "[@farming-labs/docs:analytics]";
|
|
5
|
+
const OBSERVABILITY_LOG_PREFIX = "[@farming-labs/docs:observability]";
|
|
6
|
+
const DOCS_AGENT_TRACE_EVENT_TYPES = [
|
|
7
|
+
"run.start",
|
|
8
|
+
"run.end",
|
|
9
|
+
"run.error",
|
|
10
|
+
"user.input",
|
|
11
|
+
"prompt.build",
|
|
12
|
+
"retrieval.query",
|
|
13
|
+
"retrieval.result",
|
|
14
|
+
"retrieval.error",
|
|
15
|
+
"model.call",
|
|
16
|
+
"model.response",
|
|
17
|
+
"model.stream",
|
|
18
|
+
"model.error",
|
|
19
|
+
"tool.call",
|
|
20
|
+
"tool.result",
|
|
21
|
+
"tool.error",
|
|
22
|
+
"retry",
|
|
23
|
+
"timeout",
|
|
24
|
+
"error",
|
|
25
|
+
"agent.final"
|
|
26
|
+
];
|
|
27
|
+
function composeAnalyticsHandlers(userOnEvent, cloudOnEvent) {
|
|
28
|
+
if (typeof userOnEvent !== "function" && !cloudOnEvent) return;
|
|
29
|
+
return async (event) => {
|
|
30
|
+
let userError;
|
|
31
|
+
if (typeof userOnEvent === "function") try {
|
|
32
|
+
await userOnEvent(event);
|
|
33
|
+
} catch (error) {
|
|
34
|
+
userError = error;
|
|
35
|
+
}
|
|
36
|
+
if (cloudOnEvent) try {
|
|
37
|
+
await cloudOnEvent(event);
|
|
38
|
+
} catch {}
|
|
39
|
+
if (typeof userError !== "undefined") throw userError;
|
|
40
|
+
};
|
|
41
|
+
}
|
|
42
|
+
function resolveConsoleLevel(value, hasEventHandler) {
|
|
43
|
+
if (value === false) return false;
|
|
44
|
+
if (value === true) return "info";
|
|
45
|
+
if (value === "log" || value === "info" || value === "debug") return value;
|
|
46
|
+
return hasEventHandler ? false : "info";
|
|
47
|
+
}
|
|
48
|
+
function createDocsAgentTraceId(prefix = "trace") {
|
|
49
|
+
return `${prefix.replace(/[^a-zA-Z0-9_-]/g, "_") || "trace"}_${Date.now().toString(36)}_${Math.random().toString(36).slice(2, 10)}`;
|
|
50
|
+
}
|
|
51
|
+
function createDocsAgentTraceContext(name = "agent.run") {
|
|
52
|
+
return {
|
|
53
|
+
traceId: createDocsAgentTraceId("run"),
|
|
54
|
+
name,
|
|
55
|
+
startedAt: (/* @__PURE__ */ new Date()).toISOString(),
|
|
56
|
+
startedMs: Date.now()
|
|
57
|
+
};
|
|
58
|
+
}
|
|
59
|
+
function getDocsRequestAnalyticsProperties(request) {
|
|
60
|
+
const userAgent = request.headers.get("user-agent")?.trim();
|
|
61
|
+
return userAgent ? { userAgent } : {};
|
|
62
|
+
}
|
|
63
|
+
function resolveDocsAnalyticsConfig(analytics) {
|
|
64
|
+
if (analytics === false) return {
|
|
65
|
+
enabled: false,
|
|
66
|
+
console: false,
|
|
67
|
+
includeInputs: false
|
|
68
|
+
};
|
|
69
|
+
const cloudOptions = resolveDocsCloudAnalyticsOptions(analytics);
|
|
70
|
+
const cloudOnEvent = cloudOptions ? async (event) => {
|
|
71
|
+
await sendDocsCloudAnalyticsEvent(cloudOptions, event);
|
|
72
|
+
} : void 0;
|
|
73
|
+
if (!analytics) {
|
|
74
|
+
if (!cloudOnEvent) return {
|
|
75
|
+
enabled: false,
|
|
76
|
+
console: false,
|
|
77
|
+
includeInputs: false
|
|
78
|
+
};
|
|
79
|
+
return {
|
|
80
|
+
enabled: true,
|
|
81
|
+
console: false,
|
|
82
|
+
includeInputs: false,
|
|
83
|
+
onEvent: cloudOnEvent
|
|
84
|
+
};
|
|
85
|
+
}
|
|
86
|
+
if (analytics === true) return {
|
|
87
|
+
enabled: true,
|
|
88
|
+
console: "info",
|
|
89
|
+
includeInputs: false,
|
|
90
|
+
onEvent: cloudOnEvent
|
|
91
|
+
};
|
|
92
|
+
const userOnEvent = analytics.onEvent;
|
|
93
|
+
const hasEventHandler = typeof userOnEvent === "function" || Boolean(cloudOnEvent);
|
|
94
|
+
const onEvent = composeAnalyticsHandlers(userOnEvent, cloudOnEvent);
|
|
95
|
+
return {
|
|
96
|
+
enabled: analytics.enabled !== false,
|
|
97
|
+
console: resolveConsoleLevel(analytics.console, hasEventHandler),
|
|
98
|
+
includeInputs: analytics.includeInputs === true,
|
|
99
|
+
onEvent
|
|
100
|
+
};
|
|
101
|
+
}
|
|
102
|
+
function resolveDocsObservabilityConfig(observability) {
|
|
103
|
+
if (!observability) return {
|
|
104
|
+
enabled: false,
|
|
105
|
+
console: false,
|
|
106
|
+
includeInputs: false
|
|
107
|
+
};
|
|
108
|
+
if (observability === true) return {
|
|
109
|
+
enabled: true,
|
|
110
|
+
console: "info",
|
|
111
|
+
includeInputs: false
|
|
112
|
+
};
|
|
113
|
+
const hasEventHandler = typeof observability.onEvent === "function";
|
|
114
|
+
return {
|
|
115
|
+
enabled: observability.enabled !== false,
|
|
116
|
+
console: resolveConsoleLevel(observability.console, hasEventHandler),
|
|
117
|
+
includeInputs: observability.includeInputs === true,
|
|
118
|
+
onEvent: observability.onEvent
|
|
119
|
+
};
|
|
120
|
+
}
|
|
121
|
+
function normalizeAnalyticsEvent(event, config) {
|
|
122
|
+
const normalized = {
|
|
123
|
+
...event,
|
|
124
|
+
source: event.source ?? "server",
|
|
125
|
+
timestamp: event.timestamp ?? (/* @__PURE__ */ new Date()).toISOString()
|
|
126
|
+
};
|
|
127
|
+
if (!config.includeInputs && normalized.input) delete normalized.input;
|
|
128
|
+
return normalized;
|
|
129
|
+
}
|
|
130
|
+
function normalizeObservabilityEvent(event, config) {
|
|
131
|
+
const normalized = {
|
|
132
|
+
...event,
|
|
133
|
+
source: event.source ?? "server",
|
|
134
|
+
timestamp: event.timestamp ?? (/* @__PURE__ */ new Date()).toISOString()
|
|
135
|
+
};
|
|
136
|
+
if (!config.includeInputs && normalized.input) delete normalized.input;
|
|
137
|
+
return normalized;
|
|
138
|
+
}
|
|
139
|
+
async function emitDocsAnalyticsEvent(analytics, event) {
|
|
140
|
+
const resolved = resolveDocsAnalyticsConfig(analytics);
|
|
141
|
+
if (!resolved.enabled) return;
|
|
142
|
+
const normalized = normalizeAnalyticsEvent(event, resolved);
|
|
143
|
+
if (resolved.console) (console[resolved.console] ?? console.info).call(console, ANALYTICS_LOG_PREFIX, normalized);
|
|
144
|
+
if (!resolved.onEvent) return;
|
|
145
|
+
try {
|
|
146
|
+
await resolved.onEvent(normalized);
|
|
147
|
+
} catch (error) {
|
|
148
|
+
if (resolved.console !== false) console.warn(`${ANALYTICS_LOG_PREFIX} onEvent failed`, error);
|
|
149
|
+
}
|
|
150
|
+
}
|
|
151
|
+
async function emitDocsObservabilityEvent(observability, event) {
|
|
152
|
+
const resolved = resolveDocsObservabilityConfig(observability);
|
|
153
|
+
if (!resolved.enabled) return;
|
|
154
|
+
const normalized = normalizeObservabilityEvent(event, resolved);
|
|
155
|
+
if (resolved.console) (console[resolved.console] ?? console.info).call(console, OBSERVABILITY_LOG_PREFIX, normalized);
|
|
156
|
+
if (!resolved.onEvent) return;
|
|
157
|
+
try {
|
|
158
|
+
await resolved.onEvent(normalized);
|
|
159
|
+
} catch (error) {
|
|
160
|
+
if (resolved.console !== false) console.warn(`${OBSERVABILITY_LOG_PREFIX} onEvent failed`, error);
|
|
161
|
+
}
|
|
162
|
+
}
|
|
163
|
+
async function emitDocsAgentTraceEvent(observability, event) {
|
|
164
|
+
const timestamp = event.timestamp ?? (/* @__PURE__ */ new Date()).toISOString();
|
|
165
|
+
await emitDocsObservabilityEvent(observability, {
|
|
166
|
+
...event,
|
|
167
|
+
timestamp,
|
|
168
|
+
source: event.source ?? "server",
|
|
169
|
+
traceId: event.traceId ?? createDocsAgentTraceId("run"),
|
|
170
|
+
spanId: event.spanId ?? createDocsAgentTraceId("span"),
|
|
171
|
+
startedAt: event.startedAt ?? timestamp,
|
|
172
|
+
status: event.status ?? "success"
|
|
173
|
+
});
|
|
174
|
+
}
|
|
175
|
+
|
|
176
|
+
//#endregion
|
|
177
|
+
export { emitDocsAnalyticsEvent as a, resolveDocsAnalyticsConfig as c, emitDocsAgentTraceEvent as i, resolveDocsObservabilityConfig as l, createDocsAgentTraceContext as n, emitDocsObservabilityEvent as o, createDocsAgentTraceId as r, getDocsRequestAnalyticsProperties as s, DOCS_AGENT_TRACE_EVENT_TYPES as t };
|
package/dist/cli/index.mjs
CHANGED
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
#!/usr/bin/env node
|
|
2
|
-
import { i as wasCliErrorReported, r as shouldPrintStackTrace, t as formatCliError } from "../errors-
|
|
2
|
+
import { i as wasCliErrorReported, r as shouldPrintStackTrace, t as formatCliError } from "../errors-CW1LnxaQ.mjs";
|
|
3
3
|
import pc from "picocolors";
|
|
4
4
|
|
|
5
5
|
//#region src/cli/index.ts
|
|
@@ -105,43 +105,43 @@ async function main() {
|
|
|
105
105
|
]
|
|
106
106
|
};
|
|
107
107
|
if (!parsedCommand.command || parsedCommand.command === "init") {
|
|
108
|
-
const { init } = await import("../init-
|
|
108
|
+
const { init } = await import("../init-Ds7QM9po.mjs");
|
|
109
109
|
await init(initOptions);
|
|
110
110
|
} else if (parsedCommand.command === "dev") {
|
|
111
|
-
const { dev } = await import("../dev-
|
|
111
|
+
const { dev } = await import("../dev-CBha7knT.mjs");
|
|
112
112
|
await dev(devOptions);
|
|
113
113
|
} else if (parsedCommand.command === "deploy") {
|
|
114
|
-
const { runCloudDeploy } = await import("../cloud-
|
|
114
|
+
const { runCloudDeploy } = await import("../cloud-Bk-eppay.mjs");
|
|
115
115
|
await runCloudDeploy(cloudOptions);
|
|
116
116
|
} else if (parsedCommand.command === "preview") {
|
|
117
|
-
const { runCloudPreview } = await import("../cloud-
|
|
117
|
+
const { runCloudPreview } = await import("../cloud-Bk-eppay.mjs");
|
|
118
118
|
await runCloudPreview(cloudOptions);
|
|
119
119
|
} else if (parsedCommand.command === "cloud" && subcommand === "deploy") {
|
|
120
|
-
const { runCloudDeploy } = await import("../cloud-
|
|
120
|
+
const { runCloudDeploy } = await import("../cloud-Bk-eppay.mjs");
|
|
121
121
|
await runCloudDeploy(cloudOptions);
|
|
122
122
|
} else if (parsedCommand.command === "cloud" && subcommand === "preview") {
|
|
123
|
-
const { runCloudPreview } = await import("../cloud-
|
|
123
|
+
const { runCloudPreview } = await import("../cloud-Bk-eppay.mjs");
|
|
124
124
|
await runCloudPreview(cloudOptions);
|
|
125
125
|
} else if (parsedCommand.command === "cloud" && subcommand === "init") {
|
|
126
|
-
const { runCloudInit } = await import("../cloud-
|
|
126
|
+
const { runCloudInit } = await import("../cloud-Bk-eppay.mjs");
|
|
127
127
|
await runCloudInit(cloudOptions);
|
|
128
128
|
} else if (parsedCommand.command === "cloud" && subcommand === "sync") {
|
|
129
|
-
const { syncCloudConfig } = await import("../cloud-
|
|
129
|
+
const { syncCloudConfig } = await import("../cloud-Bk-eppay.mjs");
|
|
130
130
|
await syncCloudConfig(cloudOptions);
|
|
131
131
|
} else if (parsedCommand.command === "cloud" && subcommand === "check") {
|
|
132
|
-
const { runCloudCheck } = await import("../cloud-
|
|
132
|
+
const { runCloudCheck } = await import("../cloud-Bk-eppay.mjs");
|
|
133
133
|
await runCloudCheck(cloudOptions);
|
|
134
134
|
} else if (parsedCommand.command === "cloud") {
|
|
135
135
|
console.error(pc.red(`Unknown cloud subcommand: ${subcommand ?? "(missing)"}`));
|
|
136
136
|
console.error();
|
|
137
|
-
const { printCloudHelp } = await import("../cloud-
|
|
137
|
+
const { printCloudHelp } = await import("../cloud-Bk-eppay.mjs");
|
|
138
138
|
printCloudHelp();
|
|
139
139
|
process.exit(1);
|
|
140
140
|
} else if (parsedCommand.command === "mcp") {
|
|
141
|
-
const { runMcp } = await import("../mcp-
|
|
141
|
+
const { runMcp } = await import("../mcp-DuCPNHS-.mjs");
|
|
142
142
|
await runMcp(mcpOptions);
|
|
143
143
|
} else if (parsedCommand.command === "agent" && subcommand === "compact") {
|
|
144
|
-
const { compactAgentDocs, parseAgentCompactArgs, printAgentCompactHelp } = await import("../agent-
|
|
144
|
+
const { compactAgentDocs, parseAgentCompactArgs, printAgentCompactHelp } = await import("../agent-DXDOMJBw.mjs");
|
|
145
145
|
const agentCompactOptions = parseAgentCompactArgs(args.slice(2));
|
|
146
146
|
if (agentCompactOptions.help) {
|
|
147
147
|
printAgentCompactHelp();
|
|
@@ -151,11 +151,11 @@ async function main() {
|
|
|
151
151
|
} else if (parsedCommand.command === "agent") {
|
|
152
152
|
console.error(pc.red(`Unknown agent subcommand: ${subcommand ?? "(missing)"}`));
|
|
153
153
|
console.error();
|
|
154
|
-
const { printAgentCompactHelp } = await import("../agent-
|
|
154
|
+
const { printAgentCompactHelp } = await import("../agent-DXDOMJBw.mjs");
|
|
155
155
|
printAgentCompactHelp();
|
|
156
156
|
process.exit(1);
|
|
157
157
|
} else if (parsedCommand.command === "agents" && subcommand === "generate") {
|
|
158
|
-
const { generateAgents, parseAgentsGenerateArgs, printAgentsGenerateHelp } = await import("../agents-
|
|
158
|
+
const { generateAgents, parseAgentsGenerateArgs, printAgentsGenerateHelp } = await import("../agents-DjhjZaNP.mjs");
|
|
159
159
|
const agentsOptions = parseAgentsGenerateArgs(args.slice(2));
|
|
160
160
|
if (agentsOptions.help) {
|
|
161
161
|
printAgentsGenerateHelp();
|
|
@@ -165,11 +165,11 @@ async function main() {
|
|
|
165
165
|
} else if (parsedCommand.command === "agents") {
|
|
166
166
|
console.error(pc.red(`Unknown agents subcommand: ${subcommand ?? "(missing)"}`));
|
|
167
167
|
console.error();
|
|
168
|
-
const { printAgentsGenerateHelp } = await import("../agents-
|
|
168
|
+
const { printAgentsGenerateHelp } = await import("../agents-DjhjZaNP.mjs");
|
|
169
169
|
printAgentsGenerateHelp();
|
|
170
170
|
process.exit(1);
|
|
171
171
|
} else if (parsedCommand.command === "doctor") {
|
|
172
|
-
const { parseDoctorArgs, printDoctorHelp, runDoctor } = await import("../doctor-
|
|
172
|
+
const { parseDoctorArgs, printDoctorHelp, runDoctor } = await import("../doctor-O9o9kjN8.mjs");
|
|
173
173
|
const doctorOptions = parseDoctorArgs(args.slice(1));
|
|
174
174
|
if (doctorOptions.help) {
|
|
175
175
|
printDoctorHelp();
|
|
@@ -177,7 +177,7 @@ async function main() {
|
|
|
177
177
|
}
|
|
178
178
|
await runDoctor(doctorOptions);
|
|
179
179
|
} else if (parsedCommand.command === "review") {
|
|
180
|
-
const { parseReviewArgs, printReviewHelp, runReview } = await import("../review-
|
|
180
|
+
const { parseReviewArgs, printReviewHelp, runReview } = await import("../review-lm3dt7yy.mjs");
|
|
181
181
|
const reviewOptions = parseReviewArgs(args.slice(1));
|
|
182
182
|
if (reviewOptions.help) {
|
|
183
183
|
printReviewHelp();
|
|
@@ -185,7 +185,7 @@ async function main() {
|
|
|
185
185
|
}
|
|
186
186
|
await runReview(reviewOptions);
|
|
187
187
|
} else if ((parsedCommand.command === "codeblocks" || parsedCommand.command === "code-blocks") && subcommand === "validate") {
|
|
188
|
-
const { parseCodeBlocksValidateArgs, printCodeBlocksValidateHelp, runCodeBlocksValidate } = await import("../codeblocks-
|
|
188
|
+
const { parseCodeBlocksValidateArgs, printCodeBlocksValidateHelp, runCodeBlocksValidate } = await import("../codeblocks-z9iT794h.mjs");
|
|
189
189
|
const codeBlocksOptions = parseCodeBlocksValidateArgs(args.slice(2));
|
|
190
190
|
if (codeBlocksOptions.help) {
|
|
191
191
|
printCodeBlocksValidateHelp();
|
|
@@ -195,11 +195,11 @@ async function main() {
|
|
|
195
195
|
} else if (parsedCommand.command === "codeblocks" || parsedCommand.command === "code-blocks") {
|
|
196
196
|
console.error(pc.red(`Unknown codeblocks subcommand: ${subcommand ?? "(missing)"}`));
|
|
197
197
|
console.error();
|
|
198
|
-
const { printCodeBlocksValidateHelp } = await import("../codeblocks-
|
|
198
|
+
const { printCodeBlocksValidateHelp } = await import("../codeblocks-z9iT794h.mjs");
|
|
199
199
|
printCodeBlocksValidateHelp();
|
|
200
200
|
process.exit(1);
|
|
201
201
|
} else if (parsedCommand.command === "search" && subcommand === "sync") {
|
|
202
|
-
const { syncSearch } = await import("../search-
|
|
202
|
+
const { syncSearch } = await import("../search-B6nEkx86.mjs");
|
|
203
203
|
await syncSearch(searchSyncOptions);
|
|
204
204
|
} else if (parsedCommand.command === "search") {
|
|
205
205
|
console.error(pc.red(`Unknown search subcommand: ${subcommand ?? "(missing)"}`));
|
|
@@ -207,7 +207,7 @@ async function main() {
|
|
|
207
207
|
printHelp();
|
|
208
208
|
process.exit(1);
|
|
209
209
|
} else if (parsedCommand.command === "sitemap" && subcommand === "generate") {
|
|
210
|
-
const { generateSitemap, parseSitemapGenerateArgs, printSitemapGenerateHelp } = await import("../sitemap-
|
|
210
|
+
const { generateSitemap, parseSitemapGenerateArgs, printSitemapGenerateHelp } = await import("../sitemap-BEiKy4Iy.mjs");
|
|
211
211
|
const sitemapOptions = parseSitemapGenerateArgs(args.slice(2));
|
|
212
212
|
if (sitemapOptions.help) {
|
|
213
213
|
printSitemapGenerateHelp();
|
|
@@ -217,11 +217,11 @@ async function main() {
|
|
|
217
217
|
} else if (parsedCommand.command === "sitemap") {
|
|
218
218
|
console.error(pc.red(`Unknown sitemap subcommand: ${subcommand ?? "(missing)"}`));
|
|
219
219
|
console.error();
|
|
220
|
-
const { printSitemapGenerateHelp } = await import("../sitemap-
|
|
220
|
+
const { printSitemapGenerateHelp } = await import("../sitemap-BEiKy4Iy.mjs");
|
|
221
221
|
printSitemapGenerateHelp();
|
|
222
222
|
process.exit(1);
|
|
223
223
|
} else if (parsedCommand.command === "robots" && subcommand === "generate") {
|
|
224
|
-
const { generateRobots, parseRobotsGenerateArgs, printRobotsGenerateHelp } = await import("../robots-
|
|
224
|
+
const { generateRobots, parseRobotsGenerateArgs, printRobotsGenerateHelp } = await import("../robots-DV7u4Ire.mjs");
|
|
225
225
|
const robotsOptions = parseRobotsGenerateArgs(args.slice(2));
|
|
226
226
|
if (robotsOptions.help) {
|
|
227
227
|
printRobotsGenerateHelp();
|
|
@@ -231,11 +231,11 @@ async function main() {
|
|
|
231
231
|
} else if (parsedCommand.command === "robots") {
|
|
232
232
|
console.error(pc.red(`Unknown robots subcommand: ${subcommand ?? "(missing)"}`));
|
|
233
233
|
console.error();
|
|
234
|
-
const { printRobotsGenerateHelp } = await import("../robots-
|
|
234
|
+
const { printRobotsGenerateHelp } = await import("../robots-DV7u4Ire.mjs");
|
|
235
235
|
printRobotsGenerateHelp();
|
|
236
236
|
process.exit(1);
|
|
237
237
|
} else if (parsedCommand.command === "downgrade") {
|
|
238
|
-
const { downgrade } = await import("../downgrade-
|
|
238
|
+
const { downgrade } = await import("../downgrade-7PGER59g.mjs");
|
|
239
239
|
const framework = (typeof flags.framework === "string" ? flags.framework : void 0) ?? (args[1] && !args[1].startsWith("--") ? args[1] : void 0);
|
|
240
240
|
const hasVersionFlag = args.includes("--version") || args.some((arg) => arg.startsWith("--version="));
|
|
241
241
|
await downgrade({
|
|
@@ -244,7 +244,7 @@ async function main() {
|
|
|
244
244
|
dryRun: flags["dry-run"] === true
|
|
245
245
|
});
|
|
246
246
|
} else if (parsedCommand.command === "upgrade") {
|
|
247
|
-
const { upgrade } = await import("../upgrade-
|
|
247
|
+
const { upgrade } = await import("../upgrade-CkdKWRlk.mjs");
|
|
248
248
|
const framework = (typeof flags.framework === "string" ? flags.framework : void 0) ?? (args[1] && !args[1].startsWith("--") ? args[1] : void 0);
|
|
249
249
|
const hasVersionFlag = args.includes("--version") || args.some((arg) => arg.startsWith("--version="));
|
|
250
250
|
const version = typeof flags.version === "string" ? flags.version : hasVersionFlag ? "" : void 0;
|
|
@@ -0,0 +1,45 @@
|
|
|
1
|
+
import { v as DocsAnalyticsConfig } from "../types-XqGLsmOD.mjs";
|
|
2
|
+
import { ReactNode } from "react";
|
|
3
|
+
|
|
4
|
+
//#region src/docs-cloud-client.d.ts
|
|
5
|
+
type DocsCloudClientRuntimeValue<T = string> = T | undefined | null | (() => T | undefined | null);
|
|
6
|
+
type DocsCloudClientRuntimeEnv = Record<string, string | undefined> | (() => Record<string, string | undefined>);
|
|
7
|
+
interface DocsCloudClientOptions {
|
|
8
|
+
projectId?: DocsCloudClientRuntimeValue;
|
|
9
|
+
endpoint?: DocsCloudClientRuntimeValue;
|
|
10
|
+
analyticsEndpoint?: DocsCloudClientRuntimeValue;
|
|
11
|
+
apiBaseUrl?: DocsCloudClientRuntimeValue;
|
|
12
|
+
analyticsKey?: DocsCloudClientRuntimeValue;
|
|
13
|
+
enabled?: DocsCloudClientRuntimeValue<boolean | string>;
|
|
14
|
+
includeInputs?: DocsCloudClientRuntimeValue<boolean>;
|
|
15
|
+
env?: DocsCloudClientRuntimeEnv;
|
|
16
|
+
fetch?: typeof fetch;
|
|
17
|
+
metadata?: Record<string, unknown>;
|
|
18
|
+
properties?: Record<string, unknown>;
|
|
19
|
+
}
|
|
20
|
+
//#endregion
|
|
21
|
+
//#region src/client/react.d.ts
|
|
22
|
+
interface DocsCloudAnalyticsProps extends DocsCloudClientOptions {
|
|
23
|
+
analytics?: boolean | DocsAnalyticsConfig;
|
|
24
|
+
children?: ReactNode;
|
|
25
|
+
}
|
|
26
|
+
type DocsCloudAnalyticsOptions = Omit<DocsCloudAnalyticsProps, "children">;
|
|
27
|
+
type DocsCloudAnalyticsProjectId = DocsCloudClientRuntimeValue;
|
|
28
|
+
declare function DocsCloudAnalytics({
|
|
29
|
+
analytics,
|
|
30
|
+
children,
|
|
31
|
+
projectId,
|
|
32
|
+
endpoint,
|
|
33
|
+
analyticsEndpoint,
|
|
34
|
+
apiBaseUrl,
|
|
35
|
+
analyticsKey,
|
|
36
|
+
enabled,
|
|
37
|
+
includeInputs,
|
|
38
|
+
env,
|
|
39
|
+
fetch,
|
|
40
|
+
metadata,
|
|
41
|
+
properties
|
|
42
|
+
}: DocsCloudAnalyticsProps): ReactNode;
|
|
43
|
+
declare const DocsCloudAnalyticsProvider: typeof DocsCloudAnalytics;
|
|
44
|
+
//#endregion
|
|
45
|
+
export { DocsCloudAnalytics, DocsCloudAnalyticsOptions, DocsCloudAnalyticsProjectId, DocsCloudAnalyticsProps, DocsCloudAnalyticsProvider };
|
|
@@ -0,0 +1,223 @@
|
|
|
1
|
+
"use client";
|
|
2
|
+
|
|
3
|
+
import { n as sendDocsCloudAnalyticsEvent } from "../cloud-analytics-Dlk_byos.mjs";
|
|
4
|
+
import { useEffect } from "react";
|
|
5
|
+
|
|
6
|
+
//#region src/docs-cloud-client.ts
|
|
7
|
+
const DEFAULT_DOCS_CLOUD_API_BASE_URL = "https://api.farming-labs.dev";
|
|
8
|
+
const DOCS_CLOUD_PROJECT_ID_ENVS = [
|
|
9
|
+
"NEXT_PUBLIC_DOCS_CLOUD_PROJECT_ID",
|
|
10
|
+
"PUBLIC_DOCS_CLOUD_PROJECT_ID",
|
|
11
|
+
"DOCS_CLOUD_PROJECT_ID"
|
|
12
|
+
];
|
|
13
|
+
const DOCS_CLOUD_API_BASE_URL_ENVS = [
|
|
14
|
+
"NEXT_PUBLIC_DOCS_CLOUD_URL",
|
|
15
|
+
"PUBLIC_DOCS_CLOUD_URL",
|
|
16
|
+
"DOCS_CLOUD_API_BASE_URL",
|
|
17
|
+
"DOCS_CLOUD_API_URL"
|
|
18
|
+
];
|
|
19
|
+
const DOCS_CLOUD_ANALYTICS_ENDPOINT_ENVS = [
|
|
20
|
+
"NEXT_PUBLIC_DOCS_CLOUD_ANALYTICS_ENDPOINT",
|
|
21
|
+
"PUBLIC_DOCS_CLOUD_ANALYTICS_ENDPOINT",
|
|
22
|
+
"DOCS_CLOUD_ANALYTICS_ENDPOINT"
|
|
23
|
+
];
|
|
24
|
+
const DOCS_CLOUD_ANALYTICS_ENABLED_ENVS = [
|
|
25
|
+
"NEXT_PUBLIC_DOCS_CLOUD_ANALYTICS_ENABLED",
|
|
26
|
+
"PUBLIC_DOCS_CLOUD_ANALYTICS_ENABLED",
|
|
27
|
+
"DOCS_CLOUD_ANALYTICS_ENABLED"
|
|
28
|
+
];
|
|
29
|
+
const DOCS_CLOUD_ANALYTICS_KEY_ENVS = [
|
|
30
|
+
"NEXT_PUBLIC_DOCS_CLOUD_ANALYTICS_KEY",
|
|
31
|
+
"PUBLIC_DOCS_CLOUD_ANALYTICS_KEY",
|
|
32
|
+
"DOCS_CLOUD_ANALYTICS_KEY"
|
|
33
|
+
];
|
|
34
|
+
function normalizeRuntimeString(value) {
|
|
35
|
+
return typeof value === "string" && value.trim().length > 0 ? value.trim() : void 0;
|
|
36
|
+
}
|
|
37
|
+
function resolveRuntimeValue(value) {
|
|
38
|
+
return (typeof value === "function" ? value() : value) ?? void 0;
|
|
39
|
+
}
|
|
40
|
+
function resolveRuntimeString(value) {
|
|
41
|
+
return normalizeRuntimeString(resolveRuntimeValue(value));
|
|
42
|
+
}
|
|
43
|
+
function resolveRuntimeEnv(env) {
|
|
44
|
+
return typeof env === "function" ? env() : env ?? {};
|
|
45
|
+
}
|
|
46
|
+
function readProcessEnv(name) {
|
|
47
|
+
if (typeof process === "undefined") return void 0;
|
|
48
|
+
if (!process.env) return void 0;
|
|
49
|
+
switch (name) {
|
|
50
|
+
case "NEXT_PUBLIC_DOCS_CLOUD_PROJECT_ID": return normalizeRuntimeString(process.env.NEXT_PUBLIC_DOCS_CLOUD_PROJECT_ID);
|
|
51
|
+
case "NEXT_PUBLIC_DOCS_CLOUD_URL": return normalizeRuntimeString(process.env.NEXT_PUBLIC_DOCS_CLOUD_URL);
|
|
52
|
+
case "NEXT_PUBLIC_DOCS_CLOUD_ANALYTICS_ENDPOINT": return normalizeRuntimeString(process.env.NEXT_PUBLIC_DOCS_CLOUD_ANALYTICS_ENDPOINT);
|
|
53
|
+
case "NEXT_PUBLIC_DOCS_CLOUD_ANALYTICS_ENABLED": return normalizeRuntimeString(process.env.NEXT_PUBLIC_DOCS_CLOUD_ANALYTICS_ENABLED);
|
|
54
|
+
case "NEXT_PUBLIC_DOCS_CLOUD_ANALYTICS_KEY": return normalizeRuntimeString(process.env.NEXT_PUBLIC_DOCS_CLOUD_ANALYTICS_KEY);
|
|
55
|
+
default: return;
|
|
56
|
+
}
|
|
57
|
+
}
|
|
58
|
+
function readEnv(name, env) {
|
|
59
|
+
return normalizeRuntimeString(env[name]) ?? readProcessEnv(name);
|
|
60
|
+
}
|
|
61
|
+
function readFirstEnv(names, env) {
|
|
62
|
+
for (const name of names) {
|
|
63
|
+
const value = readEnv(name, env);
|
|
64
|
+
if (value) return value;
|
|
65
|
+
}
|
|
66
|
+
}
|
|
67
|
+
function isFalsy(value) {
|
|
68
|
+
if (value === false) return true;
|
|
69
|
+
if (typeof value !== "string") return false;
|
|
70
|
+
return /^(0|false|no|off)$/i.test(value.trim());
|
|
71
|
+
}
|
|
72
|
+
function stripTrailingSlash(value) {
|
|
73
|
+
return value.replace(/\/+$/, "");
|
|
74
|
+
}
|
|
75
|
+
function mergeRecords(...records) {
|
|
76
|
+
const merged = {};
|
|
77
|
+
for (const record of records) {
|
|
78
|
+
if (!record) continue;
|
|
79
|
+
Object.assign(merged, record);
|
|
80
|
+
}
|
|
81
|
+
return Object.keys(merged).length > 0 ? merged : void 0;
|
|
82
|
+
}
|
|
83
|
+
function getBrowserLocation() {
|
|
84
|
+
return typeof window !== "undefined" ? window.location : void 0;
|
|
85
|
+
}
|
|
86
|
+
function getBrowserReferrer() {
|
|
87
|
+
if (typeof document === "undefined") return void 0;
|
|
88
|
+
return document.referrer || void 0;
|
|
89
|
+
}
|
|
90
|
+
function createDocsCloudClient(options = {}) {
|
|
91
|
+
function env() {
|
|
92
|
+
return resolveRuntimeEnv(options.env);
|
|
93
|
+
}
|
|
94
|
+
function projectId() {
|
|
95
|
+
const runtimeEnv = env();
|
|
96
|
+
return resolveRuntimeString(options.projectId) ?? readFirstEnv(DOCS_CLOUD_PROJECT_ID_ENVS, runtimeEnv);
|
|
97
|
+
}
|
|
98
|
+
function apiBaseUrl() {
|
|
99
|
+
const runtimeEnv = env();
|
|
100
|
+
return stripTrailingSlash(resolveRuntimeString(options.apiBaseUrl) ?? readFirstEnv(DOCS_CLOUD_API_BASE_URL_ENVS, runtimeEnv) ?? DEFAULT_DOCS_CLOUD_API_BASE_URL);
|
|
101
|
+
}
|
|
102
|
+
function endpoint() {
|
|
103
|
+
const runtimeEnv = env();
|
|
104
|
+
return resolveRuntimeString(options.endpoint) ?? resolveRuntimeString(options.analyticsEndpoint) ?? readFirstEnv(DOCS_CLOUD_ANALYTICS_ENDPOINT_ENVS, runtimeEnv) ?? `${apiBaseUrl()}/v1/analytics/events`;
|
|
105
|
+
}
|
|
106
|
+
function analyticsKey() {
|
|
107
|
+
const runtimeEnv = env();
|
|
108
|
+
return resolveRuntimeString(options.analyticsKey) ?? readFirstEnv(DOCS_CLOUD_ANALYTICS_KEY_ENVS, runtimeEnv);
|
|
109
|
+
}
|
|
110
|
+
function enabled() {
|
|
111
|
+
const runtimeEnv = env();
|
|
112
|
+
return !isFalsy(resolveRuntimeValue(options.enabled) ?? readFirstEnv(DOCS_CLOUD_ANALYTICS_ENABLED_ENVS, runtimeEnv));
|
|
113
|
+
}
|
|
114
|
+
function includeInputs() {
|
|
115
|
+
return resolveRuntimeValue(options.includeInputs) === true;
|
|
116
|
+
}
|
|
117
|
+
function getConfig() {
|
|
118
|
+
const id = projectId();
|
|
119
|
+
return {
|
|
120
|
+
enabled: enabled(),
|
|
121
|
+
configured: Boolean(id),
|
|
122
|
+
...id ? { projectId: id } : {},
|
|
123
|
+
endpoint: endpoint()
|
|
124
|
+
};
|
|
125
|
+
}
|
|
126
|
+
async function trackEvent(event, trackOptions = {}) {
|
|
127
|
+
const config = getConfig();
|
|
128
|
+
if (!config.enabled || !config.projectId) return false;
|
|
129
|
+
const location = getBrowserLocation();
|
|
130
|
+
const normalized = {
|
|
131
|
+
...event,
|
|
132
|
+
source: event.source ?? "client",
|
|
133
|
+
timestamp: event.timestamp ?? (/* @__PURE__ */ new Date()).toISOString(),
|
|
134
|
+
url: event.url ?? location?.href,
|
|
135
|
+
path: event.path ?? location?.pathname,
|
|
136
|
+
referrer: event.referrer ?? getBrowserReferrer(),
|
|
137
|
+
locale: event.locale ?? trackOptions.locale,
|
|
138
|
+
metadata: mergeRecords(options.metadata, trackOptions.metadata, event.metadata),
|
|
139
|
+
properties: mergeRecords(options.properties, trackOptions.properties, event.properties)
|
|
140
|
+
};
|
|
141
|
+
if (!includeInputs()) delete normalized.input;
|
|
142
|
+
await sendDocsCloudAnalyticsEvent({
|
|
143
|
+
endpoint: config.endpoint,
|
|
144
|
+
projectId: config.projectId,
|
|
145
|
+
apiKey: analyticsKey(),
|
|
146
|
+
fetch: options.fetch
|
|
147
|
+
}, normalized);
|
|
148
|
+
return true;
|
|
149
|
+
}
|
|
150
|
+
return {
|
|
151
|
+
analytics: { track: trackEvent },
|
|
152
|
+
trackEvent,
|
|
153
|
+
getConfig,
|
|
154
|
+
isConfigured() {
|
|
155
|
+
const config = getConfig();
|
|
156
|
+
return config.enabled && config.configured;
|
|
157
|
+
}
|
|
158
|
+
};
|
|
159
|
+
}
|
|
160
|
+
|
|
161
|
+
//#endregion
|
|
162
|
+
//#region src/client/react.ts
|
|
163
|
+
function isDocsCloudAnalyticsDisabled(analytics, enabled) {
|
|
164
|
+
return Boolean(enabled === false || analytics === false || analytics && typeof analytics === "object" && (analytics.enabled === false || analytics.cloud === false));
|
|
165
|
+
}
|
|
166
|
+
function callAnalyticsHandler(handler, event) {
|
|
167
|
+
if (!handler) return;
|
|
168
|
+
try {
|
|
169
|
+
Promise.resolve(handler(event)).catch(() => {});
|
|
170
|
+
} catch {}
|
|
171
|
+
}
|
|
172
|
+
function DocsCloudAnalytics({ analytics, children, projectId, endpoint, analyticsEndpoint, apiBaseUrl, analyticsKey, enabled, includeInputs, env, fetch, metadata, properties }) {
|
|
173
|
+
useEffect(() => {
|
|
174
|
+
if (typeof window === "undefined") return;
|
|
175
|
+
if (isDocsCloudAnalyticsDisabled(analytics, enabled)) return;
|
|
176
|
+
const client = createDocsCloudClient({
|
|
177
|
+
projectId,
|
|
178
|
+
endpoint,
|
|
179
|
+
analyticsEndpoint,
|
|
180
|
+
apiBaseUrl,
|
|
181
|
+
analyticsKey,
|
|
182
|
+
enabled,
|
|
183
|
+
includeInputs: includeInputs ?? (typeof analytics === "object" && analytics.includeInputs === true),
|
|
184
|
+
env,
|
|
185
|
+
fetch,
|
|
186
|
+
metadata,
|
|
187
|
+
properties
|
|
188
|
+
});
|
|
189
|
+
if (!client.isConfigured()) return;
|
|
190
|
+
const target = window;
|
|
191
|
+
const previous = target.__fdAnalytics__;
|
|
192
|
+
const handler = (event) => {
|
|
193
|
+
callAnalyticsHandler(previous, event);
|
|
194
|
+
client.trackEvent(event).catch(() => {});
|
|
195
|
+
};
|
|
196
|
+
target.__fdAnalytics__ = handler;
|
|
197
|
+
const queued = target.__fdAnalyticsQueue__ ?? [];
|
|
198
|
+
delete target.__fdAnalyticsQueue__;
|
|
199
|
+
for (const event of queued) handler(event);
|
|
200
|
+
return () => {
|
|
201
|
+
if (target.__fdAnalytics__ === handler) if (typeof previous === "function") target.__fdAnalytics__ = previous;
|
|
202
|
+
else delete target.__fdAnalytics__;
|
|
203
|
+
};
|
|
204
|
+
}, [
|
|
205
|
+
analytics,
|
|
206
|
+
analyticsEndpoint,
|
|
207
|
+
analyticsKey,
|
|
208
|
+
apiBaseUrl,
|
|
209
|
+
enabled,
|
|
210
|
+
endpoint,
|
|
211
|
+
env,
|
|
212
|
+
fetch,
|
|
213
|
+
includeInputs,
|
|
214
|
+
metadata,
|
|
215
|
+
projectId,
|
|
216
|
+
properties
|
|
217
|
+
]);
|
|
218
|
+
return children ?? null;
|
|
219
|
+
}
|
|
220
|
+
const DocsCloudAnalyticsProvider = DocsCloudAnalytics;
|
|
221
|
+
|
|
222
|
+
//#endregion
|
|
223
|
+
export { DocsCloudAnalytics, DocsCloudAnalyticsProvider };
|