@gitpagedocs/cli 0.0.1
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/README.md +193 -0
- package/ai/application/ai-command.ts +24 -0
- package/ai/application/ai-provider-factory.ts +22 -0
- package/ai/application/docs-pattern.ts +72 -0
- package/ai/application/resolve-chat-credentials.ts +69 -0
- package/ai/application/run-ai-cli-command.ts +167 -0
- package/ai/config.ts +50 -0
- package/ai/core/chat-session.ts +44 -0
- package/ai/core/models/ai-cli-config.ts +33 -0
- package/ai/core/models/parse-ai-cli-config.ts +76 -0
- package/ai/core/ports/illm-provider.ts +32 -0
- package/ai/infrastructure/ai-config-file.ts +101 -0
- package/ai/infrastructure/file-system-adapter.ts +85 -0
- package/ai/infrastructure/llm/tools-llm-provider.ts +54 -0
- package/ai/infrastructure/version-docs-writer.ts +143 -0
- package/ai/presentation/ai-prompts.ts +239 -0
- package/application/config-only/handler.mjs +57 -0
- package/application/home/handler.mjs +87 -0
- package/application/ports/cli-runtime-ports.ts +93 -0
- package/application/report/config-only-reporter.mjs +68 -0
- package/application/use-cases/dispatch-mode.ts +18 -0
- package/builders/config-orchestrator.mjs +35 -0
- package/builders/language-bundles-builder.mjs +24 -0
- package/builders/project-links.mjs +50 -0
- package/builders/root-config-builder.d.mts +16 -0
- package/builders/root-config-builder.mjs +56 -0
- package/builders/route-builders.mjs +136 -0
- package/builders/theme-template.mjs +76 -0
- package/builders/version-config-builder.mjs +186 -0
- package/content/docs-en.mjs +556 -0
- package/content/docs-es.mjs +469 -0
- package/content/docs-pt.mjs +469 -0
- package/content/docs.mjs +9 -0
- package/contracts/doc-versions.mjs +3 -0
- package/contracts/index.mjs +11 -0
- package/contracts/langs-paths.mjs +28 -0
- package/contracts/languages.mjs +6 -0
- package/contracts/layouts-paths.d.mts +17 -0
- package/contracts/layouts-paths.mjs +68 -0
- package/contracts/path-segments.d.mts +2 -0
- package/contracts/path-segments.mjs +15 -0
- package/data/default-site-config.mjs +328 -0
- package/data/i18n-langmenu.mjs +350 -0
- package/data/i18n-translations.mjs +20 -0
- package/data/layouts.mjs +437 -0
- package/data/path-mappings.mjs +26 -0
- package/data/route-metas.mjs +93 -0
- package/data/theme-colors.mjs +444 -0
- package/data/urls.mjs +12 -0
- package/data/version-constants.mjs +3 -0
- package/domain/models/cli-options.ts +33 -0
- package/domain/services/layouts-migration.d.mts +15 -0
- package/domain/services/layouts-migration.mjs +74 -0
- package/domain/services/sanitize-segment.mjs +7 -0
- package/home/constants.mjs +4 -0
- package/home/home-file-writer.mjs +19 -0
- package/home/templates.mjs +51 -0
- package/index.mjs +38 -0
- package/infrastructure/config-only/runtime.mjs +17 -0
- package/infrastructure/gitpagedocs-config-file.ts +47 -0
- package/infrastructure/home/runtime.mjs +37 -0
- package/package.json +60 -0
- package/presentation/commands/ai-info.ts +57 -0
- package/presentation/commands/chat.ts +259 -0
- package/presentation/commands/config-clear.ts +23 -0
- package/presentation/commands/config-info.ts +72 -0
- package/presentation/commands/diagnostics.ts +174 -0
- package/presentation/commands/docs.ts +42 -0
- package/presentation/commands/mcp.ts +20 -0
- package/presentation/commands/pages.ts +103 -0
- package/presentation/commands/password.ts +62 -0
- package/presentation/commands/run-command.ts +72 -0
- package/presentation/index.ts +125 -0
- package/presentation/options/parser.ts +120 -0
- package/presentation/options/resolver.ts +46 -0
- package/presentation/options/schema.ts +14 -0
- package/presentation/ui/banner.ts +13 -0
- package/presentation/ui/clack.ts +91 -0
- package/presentation/ui/layouts-prompts.ts +124 -0
- package/presentation/ui/prompts.ts +147 -0
- package/presentation/ui/terminal-stream.ts +97 -0
- package/presentation/ui/tty.ts +37 -0
- package/runtime/doc-path-resolver.mjs +59 -0
- package/runtime/exec.mjs +168 -0
- package/runtime/git-ops.mjs +112 -0
- package/runtime/layouts-migrator.d.mts +11 -0
- package/runtime/layouts-migrator.mjs +117 -0
- package/runtime/output.mjs +201 -0
- package/runtime/workflow.mjs +131 -0
- package/start.mjs +14 -0
- package/ui/logger.mjs +9 -0
|
@@ -0,0 +1,16 @@
|
|
|
1
|
+
/** Options that shape the generated root config. */
|
|
2
|
+
export interface RootConfigOptions {
|
|
3
|
+
useLocalLayoutConfig?: boolean;
|
|
4
|
+
githubOwner?: string;
|
|
5
|
+
githubRepo?: string;
|
|
6
|
+
/** Repo-relative layouts home referenced by the generated config. */
|
|
7
|
+
layoutsDir?: string;
|
|
8
|
+
}
|
|
9
|
+
|
|
10
|
+
export interface RootConfig {
|
|
11
|
+
site: Record<string, unknown>;
|
|
12
|
+
VersionControl: { versions: Array<Record<string, unknown>> };
|
|
13
|
+
translations: Record<string, unknown>;
|
|
14
|
+
}
|
|
15
|
+
|
|
16
|
+
export declare function buildRootConfig(options?: RootConfigOptions): RootConfig;
|
|
@@ -0,0 +1,56 @@
|
|
|
1
|
+
/** Build root config for gitpagedocs */
|
|
2
|
+
import { OFFICIAL_LAYOUTS_CONFIG_URL, OFFICIAL_LAYOUTS_TEMPLATES_URL } from "../data/urls.mjs";
|
|
3
|
+
import {
|
|
4
|
+
resolveProjectLink,
|
|
5
|
+
resolveRenderingUrl,
|
|
6
|
+
resolveSourceViewerPath,
|
|
7
|
+
resolveLayoutsLinks,
|
|
8
|
+
} from "./project-links.mjs";
|
|
9
|
+
import { DOC_VERSIONS } from "../data/version-constants.mjs";
|
|
10
|
+
import { getDefaultSiteConfig } from "../data/default-site-config.mjs";
|
|
11
|
+
|
|
12
|
+
export function buildRootConfig(options = {}) {
|
|
13
|
+
const useLocalLayoutConfig = Boolean(options.useLocalLayoutConfig);
|
|
14
|
+
const useOfficialLayouts = !useLocalLayoutConfig;
|
|
15
|
+
const githubOwner = options.githubOwner;
|
|
16
|
+
const githubRepo = options.githubRepo;
|
|
17
|
+
const repositorySearchHome = true;
|
|
18
|
+
const renderingUrl = resolveRenderingUrl(githubOwner, githubRepo);
|
|
19
|
+
const projectLink = resolveProjectLink(githubOwner, githubRepo);
|
|
20
|
+
const sourceViewerPath = resolveSourceViewerPath(githubOwner, githubRepo);
|
|
21
|
+
const layoutsLinks = resolveLayoutsLinks(githubOwner, githubRepo, options.layoutsDir);
|
|
22
|
+
|
|
23
|
+
const versionEntries = DOC_VERSIONS.map((id) => ({
|
|
24
|
+
id,
|
|
25
|
+
path: `gitpagedocs/docs/versions/${id}/config.json`,
|
|
26
|
+
ProjectLink: projectLink,
|
|
27
|
+
PathConfig: `gitpagedocs/docs/versions/${id}/config.json`,
|
|
28
|
+
PreviewProject: "",
|
|
29
|
+
UpdateDate: "",
|
|
30
|
+
branch: "",
|
|
31
|
+
release: "",
|
|
32
|
+
commit: "",
|
|
33
|
+
"source-viewer": true,
|
|
34
|
+
"source-viewer-path": sourceViewerPath,
|
|
35
|
+
}));
|
|
36
|
+
|
|
37
|
+
const baseSiteConfig = getDefaultSiteConfig(projectLink, options.languageToggles);
|
|
38
|
+
|
|
39
|
+
return {
|
|
40
|
+
site: {
|
|
41
|
+
...baseSiteConfig,
|
|
42
|
+
layoutsConfigPathOficial: useOfficialLayouts,
|
|
43
|
+
layoutsConfigPathTemplatesOficial: useOfficialLayouts ? OFFICIAL_LAYOUTS_TEMPLATES_URL : "",
|
|
44
|
+
layoutsConfigPathOficialUrl: useOfficialLayouts ? OFFICIAL_LAYOUTS_CONFIG_URL : "",
|
|
45
|
+
layoutsConfigPath: useLocalLayoutConfig ? layoutsLinks.config : "",
|
|
46
|
+
layoutsConfigPathTemplates: useLocalLayoutConfig ? layoutsLinks.templates : "",
|
|
47
|
+
repositorySearchHome,
|
|
48
|
+
rendering: renderingUrl,
|
|
49
|
+
AiChatEnabled: true,
|
|
50
|
+
docsAccess: { enabled: false, publicKey: "" },
|
|
51
|
+
},
|
|
52
|
+
VersionControl: {
|
|
53
|
+
versions: versionEntries,
|
|
54
|
+
},
|
|
55
|
+
};
|
|
56
|
+
}
|
|
@@ -0,0 +1,136 @@
|
|
|
1
|
+
/** Build route objects for md, html, and video content types */
|
|
2
|
+
|
|
3
|
+
export function buildMdRoute(versionId, routeId, pathByLang, titles, descriptions, options = {}) {
|
|
4
|
+
const {
|
|
5
|
+
titleCss = "font-size: 1.85rem; font-weight: 700;",
|
|
6
|
+
titleDarkCss = "font-size: 1.85rem; font-weight: 700; color: var(--text);",
|
|
7
|
+
titleLightCss = "font-size: 1.85rem; font-weight: 700; color: var(--text);",
|
|
8
|
+
titlePosition = "center",
|
|
9
|
+
titleIsVisible = true,
|
|
10
|
+
descriptionCss = "font-size: 1.2rem; font-weight: 500;",
|
|
11
|
+
descriptionDarkCss = "font-size: 1.2rem; font-weight: 500; color: var(--text-secondary);",
|
|
12
|
+
descriptionLightCss = "font-size: 1.2rem; font-weight: 500; color: var(--text-secondary);",
|
|
13
|
+
descriptionPosition = "center",
|
|
14
|
+
descriptionIsVisible = true,
|
|
15
|
+
fullscreenEnabled = true,
|
|
16
|
+
marginTop = "",
|
|
17
|
+
marginBottom = "",
|
|
18
|
+
blockLink = true,
|
|
19
|
+
container,
|
|
20
|
+
browseAll = false,
|
|
21
|
+
RouteguideBrand = true,
|
|
22
|
+
RouteGuideSpeciFicbrand = [],
|
|
23
|
+
RouteguideBrandPosition = "center",
|
|
24
|
+
RouteguideBrandContainerTop = false,
|
|
25
|
+
audio,
|
|
26
|
+
authorization,
|
|
27
|
+
} = options;
|
|
28
|
+
const out = {
|
|
29
|
+
id: routeId,
|
|
30
|
+
title: titles ?? { pt: "Documentação", en: "Documentation", es: "Documentación" },
|
|
31
|
+
description: descriptions ?? { pt: "Descrição da página", en: "Page description", es: "Descripción de la página" },
|
|
32
|
+
titleCss,
|
|
33
|
+
titleDarkCss,
|
|
34
|
+
titleLightCss,
|
|
35
|
+
titlePosition,
|
|
36
|
+
titleIsVisible,
|
|
37
|
+
descriptionCss,
|
|
38
|
+
descriptionDarkCss,
|
|
39
|
+
descriptionLightCss,
|
|
40
|
+
descriptionPosition,
|
|
41
|
+
descriptionIsVisible,
|
|
42
|
+
path: pathByLang,
|
|
43
|
+
fullscreenEnabled,
|
|
44
|
+
marginTop,
|
|
45
|
+
marginBottom,
|
|
46
|
+
blockLink,
|
|
47
|
+
container,
|
|
48
|
+
browseAll,
|
|
49
|
+
RouteguideBrand,
|
|
50
|
+
RouteGuideSpeciFicbrand,
|
|
51
|
+
RouteguideBrandPosition,
|
|
52
|
+
RouteguideBrandContainerTop,
|
|
53
|
+
};
|
|
54
|
+
if (container !== undefined) out.container = container;
|
|
55
|
+
if (audio !== undefined) out.audio = audio;
|
|
56
|
+
if (authorization !== undefined) out.authorization = authorization;
|
|
57
|
+
return out;
|
|
58
|
+
}
|
|
59
|
+
|
|
60
|
+
export function buildHtmlRoute(versionId, routeId, pathByLang, titles, descriptions, options = {}) {
|
|
61
|
+
const base = buildMdRoute(versionId, routeId, pathByLang, titles, descriptions, options);
|
|
62
|
+
return { ...base };
|
|
63
|
+
}
|
|
64
|
+
|
|
65
|
+
export function buildVideoRoute(versionId, routeId, videoType, pathVideo, titles, descriptions, options = {}) {
|
|
66
|
+
const {
|
|
67
|
+
titleCss = "font-size: 1.85rem; font-weight: 700;",
|
|
68
|
+
titleDarkCss = "font-size: 1.85rem; font-weight: 700; color: var(--text);",
|
|
69
|
+
titleLightCss = "font-size: 1.85rem; font-weight: 700; color: var(--text);",
|
|
70
|
+
titlePosition = "center",
|
|
71
|
+
titleIsVisible = true,
|
|
72
|
+
descriptionCss = "font-size: 1.2rem; font-weight: 500;",
|
|
73
|
+
descriptionDarkCss = "font-size: 1.2rem; font-weight: 500; color: var(--text-secondary);",
|
|
74
|
+
descriptionLightCss = "font-size: 1.2rem; font-weight: 500; color: var(--text-secondary);",
|
|
75
|
+
descriptionPosition = "center",
|
|
76
|
+
descriptionIsVisible = true,
|
|
77
|
+
fullscreenEnabled = true,
|
|
78
|
+
marginTop = "",
|
|
79
|
+
marginBottom = "",
|
|
80
|
+
blockLink = true,
|
|
81
|
+
container,
|
|
82
|
+
browseAll = false,
|
|
83
|
+
authorization,
|
|
84
|
+
} = options;
|
|
85
|
+
const videoTypeByLang = typeof videoType === "string" ? { pt: videoType, en: videoType, es: videoType } : videoType;
|
|
86
|
+
const pathVideoByLang = typeof pathVideo === "string" ? { pt: pathVideo, en: pathVideo, es: pathVideo } : pathVideo;
|
|
87
|
+
const obj = {
|
|
88
|
+
id: routeId,
|
|
89
|
+
title: titles ?? { pt: "Vídeo", en: "Video", es: "Vídeo" },
|
|
90
|
+
description: descriptions ?? { pt: "Descrição do vídeo", en: "Video description", es: "Descripción del vídeo" },
|
|
91
|
+
titleCss,
|
|
92
|
+
titleDarkCss,
|
|
93
|
+
titleLightCss,
|
|
94
|
+
titlePosition,
|
|
95
|
+
titleIsVisible,
|
|
96
|
+
descriptionCss,
|
|
97
|
+
descriptionDarkCss,
|
|
98
|
+
descriptionLightCss,
|
|
99
|
+
descriptionPosition,
|
|
100
|
+
descriptionIsVisible,
|
|
101
|
+
fullscreenEnabled,
|
|
102
|
+
marginTop,
|
|
103
|
+
marginBottom,
|
|
104
|
+
blockLink,
|
|
105
|
+
browseAll,
|
|
106
|
+
video: { videoType: videoTypeByLang, pathVideo: pathVideoByLang },
|
|
107
|
+
};
|
|
108
|
+
if (container !== undefined) obj.container = container;
|
|
109
|
+
if (authorization !== undefined) obj.authorization = authorization;
|
|
110
|
+
return obj;
|
|
111
|
+
}
|
|
112
|
+
|
|
113
|
+
export function buildAudioRoute(versionId, routeId, audioType, pathAudio, titles, descriptions, options = {}) {
|
|
114
|
+
const base = buildVideoRoute(versionId, routeId, audioType, pathAudio, titles, descriptions, options);
|
|
115
|
+
const audioTypeByLang = typeof audioType === "string" ? { pt: audioType, en: audioType, es: audioType } : audioType;
|
|
116
|
+
const pathAudioByLang = typeof pathAudio === "string" ? { pt: pathAudio, en: pathAudio, es: pathAudio } : pathAudio;
|
|
117
|
+
const { video, ...rest } = base;
|
|
118
|
+
return {
|
|
119
|
+
...rest,
|
|
120
|
+
audio: { audioType: audioTypeByLang, pathAudio: pathAudioByLang },
|
|
121
|
+
};
|
|
122
|
+
}
|
|
123
|
+
|
|
124
|
+
export function buildSourceViewerRoute(routeId, sourceViewerPath, titles, descriptions, options = {}) {
|
|
125
|
+
const base = buildMdRoute("", routeId, {}, titles, descriptions, {
|
|
126
|
+
...options,
|
|
127
|
+
fullscreenEnabled: false,
|
|
128
|
+
RouteguideBrand: false,
|
|
129
|
+
});
|
|
130
|
+
delete base.path;
|
|
131
|
+
return {
|
|
132
|
+
...base,
|
|
133
|
+
"source-viewer": true,
|
|
134
|
+
"source-viewer-path": sourceViewerPath,
|
|
135
|
+
};
|
|
136
|
+
}
|
|
@@ -0,0 +1,76 @@
|
|
|
1
|
+
/** Build theme JSON template from layout definition */
|
|
2
|
+
|
|
3
|
+
import { PACKAGE_VERSION } from "../contracts/doc-versions.mjs";
|
|
4
|
+
import { THEME_COLORS } from "../data/theme-colors.mjs";
|
|
5
|
+
|
|
6
|
+
export function createThemeTemplate(layout, themeColors = THEME_COLORS) {
|
|
7
|
+
const colors = themeColors[layout.id] ?? themeColors.default;
|
|
8
|
+
const dark = layout.mode === "dark";
|
|
9
|
+
return {
|
|
10
|
+
id: layout.id,
|
|
11
|
+
name: layout.name,
|
|
12
|
+
author: layout.author,
|
|
13
|
+
version: PACKAGE_VERSION,
|
|
14
|
+
mode: layout.mode,
|
|
15
|
+
supportsLightAndDarkModes: layout.supportsLightAndDarkModes,
|
|
16
|
+
colors,
|
|
17
|
+
typography: {
|
|
18
|
+
fontFamily: "-apple-system, BlinkMacSystemFont, 'Segoe UI', Inter, Roboto, Helvetica, Arial, sans-serif",
|
|
19
|
+
fontSize: {
|
|
20
|
+
small: "0.875rem",
|
|
21
|
+
base: "1rem",
|
|
22
|
+
medium: "1.125rem",
|
|
23
|
+
large: "1.25rem",
|
|
24
|
+
xlarge: "2rem",
|
|
25
|
+
},
|
|
26
|
+
},
|
|
27
|
+
components: {
|
|
28
|
+
header: {
|
|
29
|
+
height: "80px",
|
|
30
|
+
backgroundColor: dark ? "#0B1220" : "#FFFFFF",
|
|
31
|
+
borderBottom: dark ? "1px solid #334155" : "1px solid #E2E8F0",
|
|
32
|
+
},
|
|
33
|
+
footer: {
|
|
34
|
+
height: "60px",
|
|
35
|
+
backgroundColor: dark ? "#0B1220" : "#FFFFFF",
|
|
36
|
+
borderTop: dark ? "1px solid #334155" : "1px solid #E2E8F0",
|
|
37
|
+
},
|
|
38
|
+
card: {
|
|
39
|
+
borderRadius: "16px",
|
|
40
|
+
padding: "24px",
|
|
41
|
+
boxShadow: dark ? "0 18px 60px rgba(0, 0, 0, 0.45)" : "0 18px 50px rgba(15, 23, 42, 0.08)",
|
|
42
|
+
},
|
|
43
|
+
button: {
|
|
44
|
+
borderRadius: "12px",
|
|
45
|
+
padding: "10px 18px",
|
|
46
|
+
border: dark ? "1px solid #334155" : "1px solid #E2E8F0",
|
|
47
|
+
hoverGlow: dark ? "0 0 0 3px rgba(124, 58, 237, 0.18)" : "0 0 0 4px rgba(109, 40, 217, 0.15)",
|
|
48
|
+
},
|
|
49
|
+
select: {
|
|
50
|
+
borderRadius: "12px",
|
|
51
|
+
padding: "10px 40px 10px 16px",
|
|
52
|
+
border: dark ? "1px solid #334155" : "1px solid #E2E8F0",
|
|
53
|
+
backgroundColor: dark ? "#0F172A" : "#FFFFFF",
|
|
54
|
+
textAlign: "center",
|
|
55
|
+
iconColor: colors.secondary,
|
|
56
|
+
hoverBorderColor: dark ? "rgba(34, 211, 238, 0.7)" : "rgba(8, 145, 178, 0.7)",
|
|
57
|
+
focusBorderColor: dark ? "rgba(124, 58, 237, 0.8)" : "rgba(109, 40, 217, 0.8)",
|
|
58
|
+
focusGlow: dark ? "0 0 0 4px rgba(124, 58, 237, 0.18)" : "0 0 0 4px rgba(109, 40, 217, 0.15)",
|
|
59
|
+
},
|
|
60
|
+
checkbox: {
|
|
61
|
+
width: "20px",
|
|
62
|
+
height: "20px",
|
|
63
|
+
accentColor: colors.primary,
|
|
64
|
+
borderColor: dark ? "#475569" : "#CBD5E1",
|
|
65
|
+
hoverBorderColor: dark ? "rgba(34, 211, 238, 0.75)" : "rgba(8, 145, 178, 0.7)",
|
|
66
|
+
checkMarkColor: colors.background,
|
|
67
|
+
borderRadius: "6px",
|
|
68
|
+
},
|
|
69
|
+
},
|
|
70
|
+
animations: {
|
|
71
|
+
enableTypingEffect: false,
|
|
72
|
+
enableGlow: dark,
|
|
73
|
+
transitionDuration: "0.22s",
|
|
74
|
+
},
|
|
75
|
+
};
|
|
76
|
+
}
|
|
@@ -0,0 +1,186 @@
|
|
|
1
|
+
/** Build version config (routes, menus) for each doc version */
|
|
2
|
+
|
|
3
|
+
import {
|
|
4
|
+
ROUTE_PATHS,
|
|
5
|
+
VIDEO_IDS,
|
|
6
|
+
AUDIO_IDS,
|
|
7
|
+
PAGE2_AUDIO,
|
|
8
|
+
} from "../data/path-mappings.mjs";
|
|
9
|
+
import {
|
|
10
|
+
ROUTE_META_ID1,
|
|
11
|
+
ROUTE_META_ID2,
|
|
12
|
+
ROUTE_META_ID3,
|
|
13
|
+
ROUTE_META_ID4,
|
|
14
|
+
ROUTE_META_ID5,
|
|
15
|
+
ROUTE_META_ID6,
|
|
16
|
+
VIDEO_META_ID1,
|
|
17
|
+
VIDEO_META_ID2,
|
|
18
|
+
VIDEO_META_ID3,
|
|
19
|
+
VIDEO_META_ID4,
|
|
20
|
+
AUDIO_META_ID12,
|
|
21
|
+
SOURCE_VIEWER_META,
|
|
22
|
+
DEFAULT_HIERARCHY,
|
|
23
|
+
} from "../data/route-metas.mjs";
|
|
24
|
+
import { buildAudioRoute, buildMdRoute, buildSourceViewerRoute, buildVideoRoute } from "./route-builders.mjs";
|
|
25
|
+
import { resolveSourceViewerPath } from "./project-links.mjs";
|
|
26
|
+
|
|
27
|
+
/** Demo route protections showcasing the "Authorized Routes" feature. They are
|
|
28
|
+
* applied only to the official (non-parameterized) scaffold — user sites
|
|
29
|
+
* generated with --owner/--repo stay public, since visitors of those sites
|
|
30
|
+
* have no discoverable unlock recipe. */
|
|
31
|
+
const EXTERNAL_AUTH_PROVIDERS = ["authjs", "clerk", "firebase", "jwt"];
|
|
32
|
+
const DOCS_ACCESS_KEY_ID = "docs-key";
|
|
33
|
+
const MAINTAINER_ROLE = "maintainer";
|
|
34
|
+
const VIDEO_ROUTE_AUTHORIZATION = {
|
|
35
|
+
requireExternalAuth: true,
|
|
36
|
+
allowedProviders: EXTERNAL_AUTH_PROVIDERS,
|
|
37
|
+
};
|
|
38
|
+
|
|
39
|
+
const ROUTE_METAS = {
|
|
40
|
+
1: ROUTE_META_ID1,
|
|
41
|
+
2: ROUTE_META_ID2,
|
|
42
|
+
3: ROUTE_META_ID3,
|
|
43
|
+
4: ROUTE_META_ID4,
|
|
44
|
+
5: ROUTE_META_ID5,
|
|
45
|
+
6: ROUTE_META_ID6,
|
|
46
|
+
};
|
|
47
|
+
const VIDEO_METAS = { 1: VIDEO_META_ID1, 2: VIDEO_META_ID2, 3: VIDEO_META_ID3, 4: VIDEO_META_ID4 };
|
|
48
|
+
|
|
49
|
+
function buildVersionMdRoutes(versionId, includeDemoAuthorization) {
|
|
50
|
+
const base = `gitpagedocs/docs/versions/${versionId}`;
|
|
51
|
+
return [1, 2, 3, 4, 5, 6].map((id) => {
|
|
52
|
+
const paths = ROUTE_PATHS[id];
|
|
53
|
+
const meta = ROUTE_METAS[id];
|
|
54
|
+
const pathByLang = {
|
|
55
|
+
pt: `${base}/pt/${paths.pt}`,
|
|
56
|
+
en: `${base}/en/${paths.en}`,
|
|
57
|
+
es: `${base}/es/${paths.es}`,
|
|
58
|
+
};
|
|
59
|
+
const routeOptions = {
|
|
60
|
+
...(id === 2 ? { audio: PAGE2_AUDIO } : {}),
|
|
61
|
+
...(includeDemoAuthorization && id === 3
|
|
62
|
+
? { authorization: { requiredRoles: [MAINTAINER_ROLE] } }
|
|
63
|
+
: {}),
|
|
64
|
+
...(includeDemoAuthorization && id === 6
|
|
65
|
+
? {
|
|
66
|
+
authorization: {
|
|
67
|
+
accessKeyId: DOCS_ACCESS_KEY_ID,
|
|
68
|
+
requiredRoles: [MAINTAINER_ROLE],
|
|
69
|
+
requireExternalAuth: true,
|
|
70
|
+
allowedProviders: EXTERNAL_AUTH_PROVIDERS,
|
|
71
|
+
},
|
|
72
|
+
}
|
|
73
|
+
: {}),
|
|
74
|
+
};
|
|
75
|
+
return buildMdRoute(versionId, id, pathByLang, meta.titles, meta.descriptions, routeOptions);
|
|
76
|
+
});
|
|
77
|
+
}
|
|
78
|
+
|
|
79
|
+
function buildVersionVideoRoutes(versionId, includeDemoAuthorization) {
|
|
80
|
+
return [1, 2, 3, 4].map((id) =>
|
|
81
|
+
buildVideoRoute(
|
|
82
|
+
versionId,
|
|
83
|
+
id + 7,
|
|
84
|
+
"youtube",
|
|
85
|
+
VIDEO_IDS[id - 1],
|
|
86
|
+
VIDEO_METAS[id].title,
|
|
87
|
+
VIDEO_METAS[id].description,
|
|
88
|
+
includeDemoAuthorization ? { authorization: VIDEO_ROUTE_AUTHORIZATION } : {},
|
|
89
|
+
)
|
|
90
|
+
);
|
|
91
|
+
}
|
|
92
|
+
|
|
93
|
+
function buildVersionAudioRoutes(versionId) {
|
|
94
|
+
return [
|
|
95
|
+
buildAudioRoute(
|
|
96
|
+
versionId,
|
|
97
|
+
AUDIO_META_ID12.id,
|
|
98
|
+
"youtube",
|
|
99
|
+
AUDIO_IDS[0],
|
|
100
|
+
AUDIO_META_ID12.title,
|
|
101
|
+
AUDIO_META_ID12.description,
|
|
102
|
+
),
|
|
103
|
+
];
|
|
104
|
+
}
|
|
105
|
+
|
|
106
|
+
function buildVersionSourceViewerRoutes(options = {}) {
|
|
107
|
+
return [
|
|
108
|
+
buildSourceViewerRoute(
|
|
109
|
+
SOURCE_VIEWER_META.id,
|
|
110
|
+
resolveSourceViewerPath(options.githubOwner, options.githubRepo),
|
|
111
|
+
SOURCE_VIEWER_META.titles,
|
|
112
|
+
SOURCE_VIEWER_META.descriptions,
|
|
113
|
+
),
|
|
114
|
+
];
|
|
115
|
+
}
|
|
116
|
+
|
|
117
|
+
function buildVersionMenus(versionId) {
|
|
118
|
+
const base = `gitpagedocs/docs/versions/${versionId}`;
|
|
119
|
+
const menuMd = [1, 2, 3, 4, 5, 6].map((id) => ({
|
|
120
|
+
id,
|
|
121
|
+
pt: { title: ROUTE_METAS[id].titles.pt, "path-click": `${base}/pt/${ROUTE_PATHS[id].pt}` },
|
|
122
|
+
en: { title: ROUTE_METAS[id].titles.en, "path-click": `${base}/en/${ROUTE_PATHS[id].en}` },
|
|
123
|
+
es: { title: ROUTE_METAS[id].titles.es, "path-click": `${base}/es/${ROUTE_PATHS[id].es}` },
|
|
124
|
+
}));
|
|
125
|
+
const menuVideo = [1, 2, 3, 4].map((id) => ({
|
|
126
|
+
id: id + 7,
|
|
127
|
+
pt: { title: `${VIDEO_METAS[id].title.pt.slice(0, 40)}...`, "path-click": `page:${id + 7}` },
|
|
128
|
+
en: { title: `${VIDEO_METAS[id].title.en.slice(0, 40)}...`, "path-click": `page:${id + 7}` },
|
|
129
|
+
es: { title: `${VIDEO_METAS[id].title.es.slice(0, 40)}...`, "path-click": `page:${id + 7}` },
|
|
130
|
+
}));
|
|
131
|
+
const menuAudio = [
|
|
132
|
+
{
|
|
133
|
+
id: AUDIO_META_ID12.id,
|
|
134
|
+
pt: { title: AUDIO_META_ID12.title.pt, "path-click": `page:${AUDIO_META_ID12.id}` },
|
|
135
|
+
en: { title: AUDIO_META_ID12.title.en, "path-click": `page:${AUDIO_META_ID12.id}` },
|
|
136
|
+
es: { title: AUDIO_META_ID12.title.es, "path-click": `page:${AUDIO_META_ID12.id}` },
|
|
137
|
+
},
|
|
138
|
+
];
|
|
139
|
+
const menuSourceViewer = [
|
|
140
|
+
{
|
|
141
|
+
id: SOURCE_VIEWER_META.id,
|
|
142
|
+
pt: { title: SOURCE_VIEWER_META.titles.pt, "path-click": `page:${SOURCE_VIEWER_META.id}` },
|
|
143
|
+
en: { title: SOURCE_VIEWER_META.titles.en, "path-click": `page:${SOURCE_VIEWER_META.id}` },
|
|
144
|
+
es: { title: SOURCE_VIEWER_META.titles.es, "path-click": `page:${SOURCE_VIEWER_META.id}` },
|
|
145
|
+
},
|
|
146
|
+
];
|
|
147
|
+
return { md: menuMd, sourceViewer: menuSourceViewer, html: [], video: menuVideo, audio: menuAudio };
|
|
148
|
+
}
|
|
149
|
+
|
|
150
|
+
/**
|
|
151
|
+
* Build version config for a single doc version.
|
|
152
|
+
* @param {string} versionId - e.g. "1.1.54"
|
|
153
|
+
* @param {object} [options] - { githubOwner, githubRepo } for the source-viewer link
|
|
154
|
+
* @returns {object} Version config with routes, menus, and hierarchy
|
|
155
|
+
*/
|
|
156
|
+
export function buildVersionConfig(versionId, options = {}) {
|
|
157
|
+
const includeDemoAuthorization = !options.githubOwner && !options.githubRepo;
|
|
158
|
+
const menus = buildVersionMenus(versionId);
|
|
159
|
+
|
|
160
|
+
return {
|
|
161
|
+
auth: {
|
|
162
|
+
accessKeys: {
|
|
163
|
+
"docs-key": "open-gitpagedocs-docs",
|
|
164
|
+
},
|
|
165
|
+
rolesStorageKey: "git-page-docs:route-auth:roles",
|
|
166
|
+
providers: [
|
|
167
|
+
{ type: "authjs", enabled: true, sessionEndpoint: "/api/auth/session", rolesClaimPath: "user.roles" },
|
|
168
|
+
{ type: "clerk", enabled: true, rolesClaimPath: "claims.publicMetadata.roles" },
|
|
169
|
+
{ type: "firebase", enabled: true, tokenStorageKey: "git-page-docs:firebase-token", rolesClaimPath: "roles" },
|
|
170
|
+
{ type: "jwt", enabled: true, tokenStorageKey: "git-page-docs:jwt-token", rolesClaimPath: "roles" },
|
|
171
|
+
],
|
|
172
|
+
},
|
|
173
|
+
"routes-md": buildVersionMdRoutes(versionId, includeDemoAuthorization),
|
|
174
|
+
"routes-source-viewer": buildVersionSourceViewerRoutes(options),
|
|
175
|
+
"routes-html": [],
|
|
176
|
+
"routes-video": buildVersionVideoRoutes(versionId, includeDemoAuthorization),
|
|
177
|
+
"routes-audio": buildVersionAudioRoutes(versionId),
|
|
178
|
+
"menus-header-md": menus.md,
|
|
179
|
+
"menus-header-source-viewer": menus.sourceViewer,
|
|
180
|
+
"menus-header-html": menus.html,
|
|
181
|
+
"menus-header-video": menus.video,
|
|
182
|
+
"menus-header-audio": menus.audio,
|
|
183
|
+
hierarchyPage: DEFAULT_HIERARCHY,
|
|
184
|
+
hierarchyMenu: DEFAULT_HIERARCHY,
|
|
185
|
+
};
|
|
186
|
+
}
|