@thallylabs/migrate 0.1.0
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/LICENSE +21 -0
- package/README.md +5 -0
- package/dist/index.d.ts +197 -0
- package/dist/index.js +1421 -0
- package/dist/index.js.map +1 -0
- package/package.json +48 -0
package/LICENSE
ADDED
|
@@ -0,0 +1,21 @@
|
|
|
1
|
+
MIT License
|
|
2
|
+
|
|
3
|
+
Copyright (c) Thally Labs
|
|
4
|
+
|
|
5
|
+
Permission is hereby granted, free of charge, to any person obtaining a copy
|
|
6
|
+
of this software and associated documentation files (the "Software"), to deal
|
|
7
|
+
in the Software without restriction, including without limitation the rights
|
|
8
|
+
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
|
|
9
|
+
copies of the Software, and to permit persons to whom the Software is
|
|
10
|
+
furnished to do so, subject to the following conditions:
|
|
11
|
+
|
|
12
|
+
The above copyright notice and this permission notice shall be included in all
|
|
13
|
+
copies or substantial portions of the Software.
|
|
14
|
+
|
|
15
|
+
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
|
|
16
|
+
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
|
|
17
|
+
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
|
|
18
|
+
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
|
|
19
|
+
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
|
|
20
|
+
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
|
|
21
|
+
SOFTWARE.
|
package/README.md
ADDED
package/dist/index.d.ts
ADDED
|
@@ -0,0 +1,197 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Canonical migration contracts shared by repository, CLI, MCP, and hosted
|
|
3
|
+
* import paths. Callers materialize this bundle only after discovery and
|
|
4
|
+
* normalization finish, so a partial crawl can never leave a half-written site.
|
|
5
|
+
*/
|
|
6
|
+
type MigrationPlatform = 'mintlify' | 'docusaurus' | 'gitbook' | 'nextra' | 'vitepress' | 'starlight' | 'thally' | 'generic' | 'unknown';
|
|
7
|
+
interface MigrationNavigationGroup {
|
|
8
|
+
group: string;
|
|
9
|
+
icon?: string;
|
|
10
|
+
pages: Array<string | MigrationNavigationGroup>;
|
|
11
|
+
}
|
|
12
|
+
interface MigrationNavigationTab {
|
|
13
|
+
tab: string;
|
|
14
|
+
href?: string;
|
|
15
|
+
groups?: Array<MigrationNavigationGroup>;
|
|
16
|
+
api?: {
|
|
17
|
+
source: string;
|
|
18
|
+
};
|
|
19
|
+
}
|
|
20
|
+
interface MigrationDocsConfig {
|
|
21
|
+
tabs: Array<MigrationNavigationTab>;
|
|
22
|
+
theme?: 'default' | 'maple' | 'sharp' | 'minimal';
|
|
23
|
+
ai?: {
|
|
24
|
+
chat?: boolean;
|
|
25
|
+
label?: string;
|
|
26
|
+
icon?: string;
|
|
27
|
+
};
|
|
28
|
+
admin?: {
|
|
29
|
+
enabled?: boolean;
|
|
30
|
+
};
|
|
31
|
+
analytics?: {
|
|
32
|
+
enabled?: boolean;
|
|
33
|
+
};
|
|
34
|
+
redirects?: Array<{
|
|
35
|
+
source: string;
|
|
36
|
+
destination: string;
|
|
37
|
+
permanent?: boolean;
|
|
38
|
+
}>;
|
|
39
|
+
i18n?: {
|
|
40
|
+
defaultLocale: string;
|
|
41
|
+
locales: Array<{
|
|
42
|
+
code: string;
|
|
43
|
+
label: string;
|
|
44
|
+
}>;
|
|
45
|
+
};
|
|
46
|
+
}
|
|
47
|
+
interface MigrationPage {
|
|
48
|
+
/** Path below `src/content`, without the `.mdx` extension. */
|
|
49
|
+
id: string;
|
|
50
|
+
/** Locale-independent page id used by the shared navigation projection. */
|
|
51
|
+
navigationId: string;
|
|
52
|
+
locale?: string;
|
|
53
|
+
title: string;
|
|
54
|
+
description: string;
|
|
55
|
+
keywords: Array<string>;
|
|
56
|
+
body: string;
|
|
57
|
+
source: string;
|
|
58
|
+
}
|
|
59
|
+
interface MigrationAsset {
|
|
60
|
+
/** Path below `public`, always normalized and traversal-free. */
|
|
61
|
+
path: string;
|
|
62
|
+
content: Uint8Array;
|
|
63
|
+
}
|
|
64
|
+
interface MigrationWarning {
|
|
65
|
+
code: 'collision' | 'invalid-page' | 'missing-page' | 'unsupported-config' | 'limit-reached' | 'fetch-failed' | 'skipped-file';
|
|
66
|
+
message: string;
|
|
67
|
+
source?: string;
|
|
68
|
+
}
|
|
69
|
+
interface MigrationBundle {
|
|
70
|
+
sourceUrl: string;
|
|
71
|
+
sourceKind: 'repository' | 'url';
|
|
72
|
+
platform: MigrationPlatform;
|
|
73
|
+
pages: Array<MigrationPage>;
|
|
74
|
+
assets: Array<MigrationAsset>;
|
|
75
|
+
docsConfig: MigrationDocsConfig;
|
|
76
|
+
warnings: Array<MigrationWarning>;
|
|
77
|
+
stats: {
|
|
78
|
+
discovered: number;
|
|
79
|
+
imported: number;
|
|
80
|
+
skipped: number;
|
|
81
|
+
};
|
|
82
|
+
}
|
|
83
|
+
interface MigrationFetchRequest {
|
|
84
|
+
accept: string;
|
|
85
|
+
}
|
|
86
|
+
interface MigrationFetchResponse {
|
|
87
|
+
finalUrl: URL;
|
|
88
|
+
body: string;
|
|
89
|
+
contentType: string;
|
|
90
|
+
headers?: Record<string, string | undefined>;
|
|
91
|
+
}
|
|
92
|
+
/**
|
|
93
|
+
* Network boundary injected by each host. Thally Cloud supplies a DNS-pinned,
|
|
94
|
+
* SSRF-safe implementation; the local CLI uses the user's normal network.
|
|
95
|
+
*/
|
|
96
|
+
type MigrationFetcher = (url: URL, request: MigrationFetchRequest) => Promise<MigrationFetchResponse>;
|
|
97
|
+
interface RenderedMigrationFile {
|
|
98
|
+
path: string;
|
|
99
|
+
content: string | Uint8Array;
|
|
100
|
+
}
|
|
101
|
+
|
|
102
|
+
/**
|
|
103
|
+
* Repository adapter for the shared migration engine. Traversal is bounded,
|
|
104
|
+
* symbolic links are ignored, and Git is always invoked with an argument array
|
|
105
|
+
* so source-controlled branch names can never become shell commands.
|
|
106
|
+
*/
|
|
107
|
+
|
|
108
|
+
interface GitHubRepositorySource {
|
|
109
|
+
owner: string;
|
|
110
|
+
repo: string;
|
|
111
|
+
branch: string;
|
|
112
|
+
docsDir: string;
|
|
113
|
+
cloneUrl: string;
|
|
114
|
+
}
|
|
115
|
+
interface RepositoryMigrationOptions {
|
|
116
|
+
repositoryDir: string;
|
|
117
|
+
sourceUrl: string;
|
|
118
|
+
docsDir?: string;
|
|
119
|
+
platform?: MigrationPlatform;
|
|
120
|
+
}
|
|
121
|
+
/** Parse and validate a public GitHub repository URL. */
|
|
122
|
+
declare function parseGitHubRepositoryUrl(rawUrl: string): GitHubRepositorySource;
|
|
123
|
+
/** Clone a repository without a shell; callers own and remove `targetDir`. */
|
|
124
|
+
declare function cloneGitHubRepository(source: GitHubRepositorySource, targetDir: string): Promise<void>;
|
|
125
|
+
/** Detect a supported repository docs platform from unambiguous config files. */
|
|
126
|
+
declare function detectRepositoryPlatform(repositoryDir: string): MigrationPlatform;
|
|
127
|
+
/** Pick the first conventional content root containing Markdown. */
|
|
128
|
+
declare function detectRepositoryDocsDir(repositoryDir: string): string;
|
|
129
|
+
/** Import an already-available repository directory into a canonical bundle. */
|
|
130
|
+
declare function migrateRepository(options: RepositoryMigrationOptions): MigrationBundle;
|
|
131
|
+
|
|
132
|
+
/**
|
|
133
|
+
* Navigation projection for imported sites. Mintlify's schema is intentionally
|
|
134
|
+
* more expressive than Thally's tab/group model, so complex containers are
|
|
135
|
+
* flattened predictably while preserving page order and nested groups.
|
|
136
|
+
*/
|
|
137
|
+
|
|
138
|
+
interface MintlifyPageReference {
|
|
139
|
+
ref: string;
|
|
140
|
+
navigationId: string;
|
|
141
|
+
locale?: string;
|
|
142
|
+
}
|
|
143
|
+
interface MintlifyNavigationResult {
|
|
144
|
+
docsConfig: MigrationDocsConfig;
|
|
145
|
+
pageReferences: Array<MintlifyPageReference>;
|
|
146
|
+
warnings: Array<MigrationWarning>;
|
|
147
|
+
}
|
|
148
|
+
/** Read `docs.json`/`mint.json`, including bounded local JSON references. */
|
|
149
|
+
declare function readMintlifyConfig(repositoryRoot: string): Record<string, unknown> | null;
|
|
150
|
+
/** Convert current and legacy Mintlify navigation into Thally's schema. */
|
|
151
|
+
declare function projectMintlifyNavigation(config: Record<string, unknown>): MintlifyNavigationResult;
|
|
152
|
+
/** Build deterministic fallback navigation from imported default-locale pages. */
|
|
153
|
+
declare function buildNavigationFromPages(pages: Array<MigrationPage>): MigrationDocsConfig;
|
|
154
|
+
|
|
155
|
+
/** Markdown/MDX normalization that preserves every component Thally supports. */
|
|
156
|
+
|
|
157
|
+
/** Normalize only syntax Thally cannot render; supported Mintlify JSX stays intact. */
|
|
158
|
+
declare function normalizeMdx(body: string): string;
|
|
159
|
+
/** Parse source Markdown or MDX into the canonical page representation. */
|
|
160
|
+
declare function parseMarkdownPage(input: {
|
|
161
|
+
id: string;
|
|
162
|
+
navigationId?: string;
|
|
163
|
+
locale?: string;
|
|
164
|
+
raw: string;
|
|
165
|
+
source: string;
|
|
166
|
+
}): MigrationPage | null;
|
|
167
|
+
|
|
168
|
+
/** Render canonical migration bundles into a portable Thally repository tree. */
|
|
169
|
+
|
|
170
|
+
/** Merge imported tabs into an existing site without duplicating changelog tabs. */
|
|
171
|
+
declare function mergeMigrationConfig(existing: MigrationDocsConfig, incoming: MigrationDocsConfig): MigrationDocsConfig;
|
|
172
|
+
/** Materialize every canonical page, asset, and config as repository file changes. */
|
|
173
|
+
declare function renderMigrationFiles(bundle: MigrationBundle, options?: {
|
|
174
|
+
existingConfig?: MigrationDocsConfig;
|
|
175
|
+
}): Array<RenderedMigrationFile>;
|
|
176
|
+
|
|
177
|
+
/**
|
|
178
|
+
* Public URL adapter for the shared migration engine. Discovery prefers
|
|
179
|
+
* machine-readable Markdown and sitemaps, remains scoped to the submitted docs
|
|
180
|
+
* path, then falls back to bounded navigation crawling and HTML extraction.
|
|
181
|
+
*/
|
|
182
|
+
|
|
183
|
+
interface UrlMigrationOptions {
|
|
184
|
+
sourceUrl: string;
|
|
185
|
+
fetcher?: MigrationFetcher;
|
|
186
|
+
maxPages?: number;
|
|
187
|
+
concurrency?: number;
|
|
188
|
+
maxTotalBytes?: number;
|
|
189
|
+
}
|
|
190
|
+
/** Validate the transport-level shape of a docs URL; hosted callers add SSRF checks. */
|
|
191
|
+
declare function validateMigrationUrl(value: string): URL;
|
|
192
|
+
/** Fetch implementation for local CLI usage. Cloud injects its pinned network boundary. */
|
|
193
|
+
declare const defaultMigrationFetcher: MigrationFetcher;
|
|
194
|
+
/** Crawl one public docs origin into a canonical, caller-independent bundle. */
|
|
195
|
+
declare function migrateUrl(options: UrlMigrationOptions): Promise<MigrationBundle>;
|
|
196
|
+
|
|
197
|
+
export { type GitHubRepositorySource, type MigrationAsset, type MigrationBundle, type MigrationDocsConfig, type MigrationFetchRequest, type MigrationFetchResponse, type MigrationFetcher, type MigrationNavigationGroup, type MigrationNavigationTab, type MigrationPage, type MigrationPlatform, type MigrationWarning, type RenderedMigrationFile, type RepositoryMigrationOptions, type UrlMigrationOptions, buildNavigationFromPages, cloneGitHubRepository, defaultMigrationFetcher, detectRepositoryDocsDir, detectRepositoryPlatform, mergeMigrationConfig, migrateRepository, migrateUrl, normalizeMdx, parseGitHubRepositoryUrl, parseMarkdownPage, projectMintlifyNavigation, readMintlifyConfig, renderMigrationFiles, validateMigrationUrl };
|